@useorgx/openclaw-plugin 0.7.11 → 0.7.15

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.
Files changed (189) hide show
  1. package/README.md +94 -122
  2. package/dashboard/dist/assets/0RUEVzJa.js +1 -0
  3. package/dashboard/dist/assets/0RUEVzJa.js.br +0 -0
  4. package/dashboard/dist/assets/0RUEVzJa.js.gz +0 -0
  5. package/dashboard/dist/assets/3TtV4moZ.js +1 -0
  6. package/dashboard/dist/assets/3TtV4moZ.js.br +0 -0
  7. package/dashboard/dist/assets/3TtV4moZ.js.gz +0 -0
  8. package/dashboard/dist/assets/3VwNyxUf.js +1 -0
  9. package/dashboard/dist/assets/3VwNyxUf.js.br +0 -0
  10. package/dashboard/dist/assets/3VwNyxUf.js.gz +0 -0
  11. package/dashboard/dist/assets/{beHYBbh6.js → 7DhYqBrM.js} +2 -2
  12. package/dashboard/dist/assets/7DhYqBrM.js.br +0 -0
  13. package/dashboard/dist/assets/7DhYqBrM.js.gz +0 -0
  14. package/dashboard/dist/assets/{tcEHYcbW.js → BCudUvwg.js} +1 -1
  15. package/dashboard/dist/assets/BCudUvwg.js.br +0 -0
  16. package/dashboard/dist/assets/BCudUvwg.js.gz +0 -0
  17. package/dashboard/dist/assets/BV0BcV1u.js +53 -0
  18. package/dashboard/dist/assets/BV0BcV1u.js.br +0 -0
  19. package/dashboard/dist/assets/BV0BcV1u.js.gz +0 -0
  20. package/dashboard/dist/assets/BVvffj0x.js +1 -0
  21. package/dashboard/dist/assets/BVvffj0x.js.br +0 -0
  22. package/dashboard/dist/assets/BVvffj0x.js.gz +0 -0
  23. package/dashboard/dist/assets/BiOgVMED.js +1 -0
  24. package/dashboard/dist/assets/BiOgVMED.js.br +0 -0
  25. package/dashboard/dist/assets/BiOgVMED.js.gz +0 -0
  26. package/dashboard/dist/assets/BjK42gtU.js +1 -0
  27. package/dashboard/dist/assets/BjK42gtU.js.br +0 -0
  28. package/dashboard/dist/assets/BjK42gtU.js.gz +0 -0
  29. package/dashboard/dist/assets/C-MOJWHs.js +1 -0
  30. package/dashboard/dist/assets/C-MOJWHs.js.br +0 -0
  31. package/dashboard/dist/assets/C-MOJWHs.js.gz +0 -0
  32. package/dashboard/dist/assets/{CD-q5mdP.js → C91KLKit.js} +1 -1
  33. package/dashboard/dist/assets/C91KLKit.js.br +0 -0
  34. package/dashboard/dist/assets/C91KLKit.js.gz +0 -0
  35. package/dashboard/dist/assets/{AqVoI3SF.js → C9fvfXmS.js} +1 -1
  36. package/dashboard/dist/assets/C9fvfXmS.js.br +0 -0
  37. package/dashboard/dist/assets/C9fvfXmS.js.gz +0 -0
  38. package/dashboard/dist/assets/CFZ4Swr5.js +1 -0
  39. package/dashboard/dist/assets/CFZ4Swr5.js.br +0 -0
  40. package/dashboard/dist/assets/CFZ4Swr5.js.gz +0 -0
  41. package/dashboard/dist/assets/{DCP-C7fn.js → CGj8kRhg.js} +1 -1
  42. package/dashboard/dist/assets/CGj8kRhg.js.br +0 -0
  43. package/dashboard/dist/assets/CGj8kRhg.js.gz +0 -0
  44. package/dashboard/dist/assets/CJjEAGFN.js +1 -0
  45. package/dashboard/dist/assets/CJjEAGFN.js.br +0 -0
  46. package/dashboard/dist/assets/CJjEAGFN.js.gz +0 -0
  47. package/dashboard/dist/assets/CKrH5fYO.js +1 -0
  48. package/dashboard/dist/assets/CKrH5fYO.js.br +0 -0
  49. package/dashboard/dist/assets/CKrH5fYO.js.gz +0 -0
  50. package/dashboard/dist/assets/CMTTPXch.js +1 -0
  51. package/dashboard/dist/assets/CMTTPXch.js.br +0 -0
  52. package/dashboard/dist/assets/CMTTPXch.js.gz +0 -0
  53. package/dashboard/dist/assets/CSlBSRyv.js +1 -0
  54. package/dashboard/dist/assets/CSlBSRyv.js.br +0 -0
  55. package/dashboard/dist/assets/CSlBSRyv.js.gz +0 -0
  56. package/dashboard/dist/assets/CnPC783_.js +1 -0
  57. package/dashboard/dist/assets/CnPC783_.js.br +0 -0
  58. package/dashboard/dist/assets/CnPC783_.js.gz +0 -0
  59. package/dashboard/dist/assets/Ctw95IkC.js +1 -0
  60. package/dashboard/dist/assets/Ctw95IkC.js.br +0 -0
  61. package/dashboard/dist/assets/Ctw95IkC.js.gz +0 -0
  62. package/dashboard/dist/assets/DHz-aQPw.js +1 -0
  63. package/dashboard/dist/assets/DHz-aQPw.js.br +0 -0
  64. package/dashboard/dist/assets/DHz-aQPw.js.gz +0 -0
  65. package/dashboard/dist/assets/DNX2foSJ.css +1 -0
  66. package/dashboard/dist/assets/DNX2foSJ.css.br +0 -0
  67. package/dashboard/dist/assets/DNX2foSJ.css.gz +0 -0
  68. package/dashboard/dist/assets/Dj2k1r16.js +8 -0
  69. package/dashboard/dist/assets/Dj2k1r16.js.br +0 -0
  70. package/dashboard/dist/assets/Dj2k1r16.js.gz +0 -0
  71. package/dashboard/dist/assets/DxUw4FMR.js +212 -0
  72. package/dashboard/dist/assets/DxUw4FMR.js.br +0 -0
  73. package/dashboard/dist/assets/DxUw4FMR.js.gz +0 -0
  74. package/dashboard/dist/assets/T2NFtzAv.js +1 -0
  75. package/dashboard/dist/assets/T2NFtzAv.js.br +0 -0
  76. package/dashboard/dist/assets/T2NFtzAv.js.gz +0 -0
  77. package/dashboard/dist/assets/cX2e-TLi.js +1 -0
  78. package/dashboard/dist/assets/cX2e-TLi.js.br +0 -0
  79. package/dashboard/dist/assets/cX2e-TLi.js.gz +0 -0
  80. package/dashboard/dist/assets/eeHXe_OQ.js +9 -0
  81. package/dashboard/dist/assets/eeHXe_OQ.js.br +0 -0
  82. package/dashboard/dist/assets/eeHXe_OQ.js.gz +0 -0
  83. package/dashboard/dist/assets/{Du1wfrXa.js → gZr_xKlA.js} +2 -2
  84. package/dashboard/dist/assets/gZr_xKlA.js.br +0 -0
  85. package/dashboard/dist/assets/gZr_xKlA.js.gz +0 -0
  86. package/dashboard/dist/brand/control-tower.png +0 -0
  87. package/dashboard/dist/brand/design-codex.png +0 -0
  88. package/dashboard/dist/brand/engineering-autopilot.png +0 -0
  89. package/dashboard/dist/brand/launch-captain.png +0 -0
  90. package/dashboard/dist/brand/orgx-logo.png +0 -0
  91. package/dashboard/dist/brand/pipeline-intelligence.png +0 -0
  92. package/dashboard/dist/brand/product-orchestrator.png +0 -0
  93. package/dashboard/dist/brand/xandy-orchestrator.png +0 -0
  94. package/dashboard/dist/index.html +8 -6
  95. package/dashboard/dist/index.html.br +0 -0
  96. package/dashboard/dist/index.html.gz +0 -0
  97. package/dist/hash-utils.d.ts +1 -0
  98. package/dist/hash-utils.js +4 -0
  99. package/dist/http/helpers/auto-continue-engine.js +124 -67
  100. package/dist/http/helpers/autopilot-slice-utils.js +112 -66
  101. package/dist/http/helpers/hash-utils.d.ts +1 -1
  102. package/dist/http/helpers/hash-utils.js +1 -1
  103. package/dist/http/helpers/mission-control.js +5 -2
  104. package/dist/http/helpers/queue-constants.d.ts +37 -0
  105. package/dist/http/helpers/queue-constants.js +34 -0
  106. package/dist/http/helpers/slice-experience-v2.js +2 -5
  107. package/dist/http/helpers/slice-run-projections.js +2 -5
  108. package/dist/http/helpers/workspace-scope.js +4 -3
  109. package/dist/http/index.js +101 -60
  110. package/dist/http/routes/chat.js +1 -21
  111. package/dist/http/routes/live-snapshot.js +4 -23
  112. package/dist/http/routes/mission-control-actions.js +2 -18
  113. package/dist/http/routes/mission-control-read.js +4 -107
  114. package/dist/lib/type-coercion.d.ts +10 -0
  115. package/dist/lib/type-coercion.js +82 -0
  116. package/dist/mcp-http-handler.js +14 -2
  117. package/dist/openclaw.plugin.json +1 -1
  118. package/dist/services/experiment-randomization.js +9 -2
  119. package/openclaw.plugin.json +1 -1
  120. package/package.json +3 -2
  121. package/dashboard/dist/assets/AqVoI3SF.js.br +0 -0
  122. package/dashboard/dist/assets/AqVoI3SF.js.gz +0 -0
  123. package/dashboard/dist/assets/BC4WvnHJ.js +0 -1
  124. package/dashboard/dist/assets/BC4WvnHJ.js.br +0 -0
  125. package/dashboard/dist/assets/BC4WvnHJ.js.gz +0 -0
  126. package/dashboard/dist/assets/BG5mwTkg.js +0 -1
  127. package/dashboard/dist/assets/BG5mwTkg.js.br +0 -0
  128. package/dashboard/dist/assets/BG5mwTkg.js.gz +0 -0
  129. package/dashboard/dist/assets/BJgZIVUQ.js +0 -53
  130. package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
  131. package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
  132. package/dashboard/dist/assets/BNh-XYPV.js +0 -1
  133. package/dashboard/dist/assets/BNh-XYPV.js.br +0 -0
  134. package/dashboard/dist/assets/BNh-XYPV.js.gz +0 -0
  135. package/dashboard/dist/assets/BTAEErUY.js +0 -1
  136. package/dashboard/dist/assets/BTAEErUY.js.br +0 -0
  137. package/dashboard/dist/assets/BTAEErUY.js.gz +0 -0
  138. package/dashboard/dist/assets/BepW_590.js +0 -1
  139. package/dashboard/dist/assets/BepW_590.js.br +0 -0
  140. package/dashboard/dist/assets/BepW_590.js.gz +0 -0
  141. package/dashboard/dist/assets/BerAfzjq.js +0 -1
  142. package/dashboard/dist/assets/BerAfzjq.js.br +0 -0
  143. package/dashboard/dist/assets/BerAfzjq.js.gz +0 -0
  144. package/dashboard/dist/assets/Bp3N-QL5.js +0 -212
  145. package/dashboard/dist/assets/Bp3N-QL5.js.br +0 -0
  146. package/dashboard/dist/assets/Bp3N-QL5.js.gz +0 -0
  147. package/dashboard/dist/assets/C-KIc3Wc.js +0 -1
  148. package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
  149. package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
  150. package/dashboard/dist/assets/C3dZRz9P.css +0 -1
  151. package/dashboard/dist/assets/C3dZRz9P.css.br +0 -0
  152. package/dashboard/dist/assets/C3dZRz9P.css.gz +0 -0
  153. package/dashboard/dist/assets/CD-q5mdP.js.br +0 -0
  154. package/dashboard/dist/assets/CD-q5mdP.js.gz +0 -0
  155. package/dashboard/dist/assets/CL_wXqR7.js +0 -1
  156. package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
  157. package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
  158. package/dashboard/dist/assets/CdvjC9G9.js +0 -1
  159. package/dashboard/dist/assets/CdvjC9G9.js.br +0 -0
  160. package/dashboard/dist/assets/CdvjC9G9.js.gz +0 -0
  161. package/dashboard/dist/assets/Ck2agw-s.js +0 -1
  162. package/dashboard/dist/assets/Ck2agw-s.js.br +0 -0
  163. package/dashboard/dist/assets/Ck2agw-s.js.gz +0 -0
  164. package/dashboard/dist/assets/CxQ08qFN.js +0 -9
  165. package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
  166. package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
  167. package/dashboard/dist/assets/D2CH1H6k.js +0 -1
  168. package/dashboard/dist/assets/D2CH1H6k.js.br +0 -0
  169. package/dashboard/dist/assets/D2CH1H6k.js.gz +0 -0
  170. package/dashboard/dist/assets/D9esz7jd.js +0 -1
  171. package/dashboard/dist/assets/D9esz7jd.js.br +0 -0
  172. package/dashboard/dist/assets/D9esz7jd.js.gz +0 -0
  173. package/dashboard/dist/assets/DCP-C7fn.js.br +0 -0
  174. package/dashboard/dist/assets/DCP-C7fn.js.gz +0 -0
  175. package/dashboard/dist/assets/DJASCd69.js +0 -1
  176. package/dashboard/dist/assets/DJASCd69.js.br +0 -0
  177. package/dashboard/dist/assets/DJASCd69.js.gz +0 -0
  178. package/dashboard/dist/assets/Dm9AybAp.js +0 -1
  179. package/dashboard/dist/assets/Dm9AybAp.js.br +0 -0
  180. package/dashboard/dist/assets/Dm9AybAp.js.gz +0 -0
  181. package/dashboard/dist/assets/Du1wfrXa.js.br +0 -0
  182. package/dashboard/dist/assets/Du1wfrXa.js.gz +0 -0
  183. package/dashboard/dist/assets/beHYBbh6.js.br +0 -0
  184. package/dashboard/dist/assets/beHYBbh6.js.gz +0 -0
  185. package/dashboard/dist/assets/cNrhgGc1.js +0 -8
  186. package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
  187. package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
  188. package/dashboard/dist/assets/tcEHYcbW.js.br +0 -0
  189. package/dashboard/dist/assets/tcEHYcbW.js.gz +0 -0
@@ -0,0 +1 @@
1
+ import{r as j,j as e}from"./Dj2k1r16.js";import{D as B,F as N,N as ke,e as x,B as M,O as Ve,Q as Ge,R as Ne,r as O,j as Ie,A as Xe,C as Ke,S as Qe,M as He,m as Je}from"./DxUw4FMR.js";import{u as Ye}from"./C9fvfXmS.js";import{A as Ze,m as I}from"./eeHXe_OQ.js";import"./BiOgVMED.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const De=/^[0-9a-f-]{20,}$/i,et=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(i){return typeof i=="string"&&i.trim().length>0}function ce(i){return(i??"").trim().toLowerCase()}function rt(i){return(i??"").trim().replace(/\s+/g," ").toLowerCase()}function st(i){return tt.has(rt(i))}function V(i,t=3){return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} +${i.length-t} more`}function G(i,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(W=>W.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(i))for(const h of i)c(h);return c(t??null),f}function it(i){if(i.runId&&i.runId.trim().length>0)return i.runId.trim();const t=i.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function at(i){const t=ce(i.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(i.phase);if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(i.state);return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":et.has(t)?t:i.blockers.length>0?"blocked":t||"unknown"}function nt(i,t,f){var h;const c=[((h=i.blockerDiagnostics)==null?void 0:h.reason)??null,i.blockerReason??null,...i.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(W=>!st(W))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(i){return i==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":i==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":i==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":i==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:i=>({opacity:1,y:0,transition:{duration:.28,delay:i*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:i=>({opacity:1,y:0,transition:{duration:.22,delay:i*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(i){return i==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:i==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:i==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:i==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:W,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[L,T]=j.useState(null),[U,he]=j.useState(!1),[re,z]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ye();j.useEffect(()=>{if(!t){z("");return}if(C!=null&&C.text){z(C.text);return}z("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const q=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?q.size===0?[]:f.filter(r=>{const l=it(r);return!!(l&&q.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,q]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",E=((we=m.runId)==null?void 0:we.trim())??"";if(A&&q.has(A)||E&&q.has(E))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const E=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(E)?E:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,q,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(E=>E.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!De.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),S=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,S,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,S]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:M("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",W),disabled:!W||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),L&&e.jsx("p",{className:"text-caption text-secondary",children:L})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=at(t),p=$[0]??null,ie=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ie),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ie>0,blockingDecisionCount:ie,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ae=nt(t,k,S),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Se=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Me=!["archived","cancelled"].includes(k),Le=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Ee=o.status!=="in_progress"&&!ne,We=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",qe=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,n=(a==null?void 0:a.context)??null,le=[v(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,v(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,v(a==null?void 0:a.errorCategory)?`Category: ${a.errorCategory.trim()}`:null,(a==null?void 0:a.retryable)===!0?"Retryable: yes":(a==null?void 0:a.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(a&&(v(a.reason)||le.length>0||b.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),Z=v(ae)?ae:null,ze=Z!==null&&!(S&&(Z===S||S.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=L?L.toLowerCase().includes("fail")||L.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:M("inline-flex items-center gap-1.5 rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-widest",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),Le]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsxs("div",{className:M("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(Ze,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-[28px] font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),S&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:S,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:M("rounded-xl border px-4 py-3",qe),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),ze&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??ae??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(a==null?void 0:a.suggestedActions)&&a.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:a.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(a==null?void 0:a.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(a.eventTimestamp).toLocaleString()," ·"," ",O(a.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:M("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:We},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[L&&e.jsx("p",{className:M("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:L}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>z(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Se&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Me&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),z("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Ee,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
@@ -0,0 +1 @@
1
+ import{e as t}from"./DxUw4FMR.js";const e={QUEUED:"queued",RUNNING:"running",BLOCKED:"blocked",IDLE:"idle",COMPLETED:"completed"};function n(r){switch(r){case e.RUNNING:return"border-teal-300/35 bg-teal-400/[0.12] text-teal-100";case e.BLOCKED:return"border-amber-300/35 bg-amber-400/[0.12] text-amber-100";case e.IDLE:return"border-strong bg-white/[0.05] text-secondary";default:return"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}}function c(r){switch(r){case e.RUNNING:return"Running";case e.BLOCKED:return"Needs input";case e.IDLE:return"Idle";case e.COMPLETED:return"Completed";case e.QUEUED:return"Queued";default:return r.replace(/_/g," ")}}function o(r){switch(r){case e.QUEUED:case e.IDLE:return 0;case e.BLOCKED:return 1;case e.RUNNING:return 2;case e.COMPLETED:return 3;default:return 4}}function i(r){switch(r){case e.RUNNING:return"from-teal-300/0 via-teal-300/60 to-teal-300/0";case e.BLOCKED:return"from-amber-300/0 via-amber-300/55 to-amber-300/0";case e.IDLE:return"from-white/0 via-white/35 to-white/0";default:return"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}}function s(r){switch(r){case e.RUNNING:return"Current";case e.BLOCKED:return"Blocked on";default:return"Next"}}function E(r){switch(r){case e.RUNNING:return t.lime;case e.BLOCKED:return t.red;case e.IDLE:return t.iris;case e.QUEUED:return t.teal;default:return t.amber}}function d(r){switch(r){case e.RUNNING:return{background:`linear-gradient(to right, ${t.lime}, ${t.teal})`};case e.BLOCKED:return{background:`linear-gradient(to right, ${t.red}, ${t.amber})`};case e.IDLE:return{background:`linear-gradient(to right, ${t.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${t.lime}B3, ${t.teal}66)`}}}function l(r,a){if(a)return"Scope Under Review";switch(r){case e.COMPLETED:return"Completed Scope";case e.RUNNING:return"Current Work";case e.BLOCKED:return"Blocked Work";default:return"Next Work"}}function N(r){return r.some(a=>a.queueState===e.RUNNING)?e.RUNNING:r.some(a=>a.queueState===e.BLOCKED)?e.BLOCKED:r.some(a=>a.queueState===e.QUEUED)?e.QUEUED:r.some(a=>a.queueState===e.IDLE)?e.IDLE:e.COMPLETED}export{e as Q,c as a,n as b,i as c,N as d,s as e,d as f,E as g,o as q,l as w};
@@ -1,2 +1,2 @@
1
- import{r as d,j as e}from"./cNrhgGc1.js";import{y as C,E as k,e as m,r as S}from"./Bp3N-QL5.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";function $(i){const o=i.trim().toLowerCase();return o==="fulfilled"||o==="completed"?m.lime:o==="claimed"?m.teal:o==="blocked"?m.red:m.amber}function J({open:i,onClose:o,handoffs:x}){const[p,g]=d.useState(""),[c,h]=d.useState(new Set),[y,n]=d.useState(null);d.useEffect(()=>{i&&n(null)},[i]);const b=d.useMemo(()=>[...x].sort((t,s)=>Date.parse(s.updatedAt??"")-Date.parse(t.updatedAt??"")),[x]),r=d.useMemo(()=>{const t=p.trim().toLowerCase();return t?b.filter(s=>[s.title,s.summary,s.status,s.priority].filter(Boolean).join(" ").toLowerCase().includes(t)):b},[b,p]);d.useEffect(()=>{i&&h(t=>{const s=new Set(r.map(a=>a.id)),l=new Set;for(const a of t)s.has(a)&&l.add(a);return l})},[r,i]);const u=c.size,f=r.length>0&&r.every(t=>c.has(t.id)),w=()=>{h(t=>r.length===0?t:f?new Set:new Set(r.map(s=>s.id)))},j=t=>{h(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},N=async()=>{const t=r.filter(a=>u===0||c.has(a.id)),s=[];s.push(`# Handoffs (${t.length})`),s.push("");for(const a of t)s.push(`- **${a.title}** — ${a.status}${a.priority?` (priority: ${a.priority})`:""}`),a.summary&&s.push(` - ${a.summary}`),s.push(` - Updated: ${a.updatedAt}`);const l=s.join(`
2
- `);try{await navigator.clipboard.writeText(l),n("Copied markdown."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}},v=async()=>{const t=r.filter(s=>u===0||c.has(s.id));try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n("Copied JSON."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}};return e.jsx(C,{open:i,onClose:o,maxWidth:"max-w-3xl",children:e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(k,{type:"handoff",size:14}),e.jsx("span",{className:"truncate",children:"Handoffs"}),e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.04] px-2 py-0.5 text-caption font-semibold text-primary",children:x.length})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Review and export current handoffs. Select items for a tighter export."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close handoffs modal",children:"Close"})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"sr-only",htmlFor:"bulk-handoffs-search",children:"Search handoffs"}),e.jsx("input",{id:"bulk-handoffs-search",value:p,onChange:t=>g(t.target.value),placeholder:"Search title, summary, status…","data-modal-autofocus":"true",className:"w-full rounded-lg border border-strong bg-black/25 px-3 py-2 text-body text-white placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-[#BFFF00]/35"})]}),e.jsx("button",{type:"button",onClick:w,disabled:r.length===0,className:"rounded-lg border border-strong bg-white/[0.03] px-3 py-2 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:f?"Clear all":`Select all (${r.length})`})]}),y&&e.jsx("div",{className:"mt-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-body text-secondary",children:y})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:r.length===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"No handoffs match this view."}):e.jsx("div",{className:"space-y-2",children:r.map(t=>{const s=c.has(t.id),l=$(t.status);return e.jsx("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2.5",style:{borderColor:s?`${m.lime}40`:"rgba(255,255,255,0.08)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:()=>j(t.id),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40","aria-label":`Select handoff ${t.title}`}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:t.title}),t.summary&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",children:t.summary}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:["Updated ",S(t.updatedAt)]})]}),e.jsx("span",{className:"shrink-0 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",style:{borderColor:`${l}30`,backgroundColor:`${l}14`,color:l},children:t.status})]})})]})},t.id)})})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-subtle px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"text-caption text-secondary",children:u>0?`${u} selected`:"No selection (exporting will include all filtered handoffs)"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:N,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy markdown"}),e.jsx("button",{type:"button",onClick:v,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy JSON"})]})]})]})})}export{J as BulkHandoffsModal};
1
+ import{r as d,j as e}from"./Dj2k1r16.js";import{y as C,E as k,e as m,r as S}from"./DxUw4FMR.js";import"./BiOgVMED.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function $(i){const o=i.trim().toLowerCase();return o==="fulfilled"||o==="completed"?m.lime:o==="claimed"?m.teal:o==="blocked"?m.red:m.amber}function z({open:i,onClose:o,handoffs:x}){const[p,g]=d.useState(""),[c,h]=d.useState(new Set),[y,n]=d.useState(null);d.useEffect(()=>{i&&n(null)},[i]);const b=d.useMemo(()=>[...x].sort((t,s)=>Date.parse(s.updatedAt??"")-Date.parse(t.updatedAt??"")),[x]),r=d.useMemo(()=>{const t=p.trim().toLowerCase();return t?b.filter(s=>[s.title,s.summary,s.status,s.priority].filter(Boolean).join(" ").toLowerCase().includes(t)):b},[b,p]);d.useEffect(()=>{i&&h(t=>{const s=new Set(r.map(a=>a.id)),l=new Set;for(const a of t)s.has(a)&&l.add(a);return l})},[r,i]);const u=c.size,f=r.length>0&&r.every(t=>c.has(t.id)),w=()=>{h(t=>r.length===0?t:f?new Set:new Set(r.map(s=>s.id)))},j=t=>{h(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},N=async()=>{const t=r.filter(a=>u===0||c.has(a.id)),s=[];s.push(`# Handoffs (${t.length})`),s.push("");for(const a of t)s.push(`- **${a.title}** — ${a.status}${a.priority?` (priority: ${a.priority})`:""}`),a.summary&&s.push(` - ${a.summary}`),s.push(` - Updated: ${a.updatedAt}`);const l=s.join(`
2
+ `);try{await navigator.clipboard.writeText(l),n("Copied markdown."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}},v=async()=>{const t=r.filter(s=>u===0||c.has(s.id));try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n("Copied JSON."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}};return e.jsx(C,{open:i,onClose:o,maxWidth:"max-w-3xl",children:e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(k,{type:"handoff",size:14}),e.jsx("span",{className:"truncate",children:"Handoffs"}),e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.04] px-2 py-0.5 text-caption font-semibold text-primary",children:x.length})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Review and export current handoffs. Select items for a tighter export."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close handoffs modal",children:"Close"})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"sr-only",htmlFor:"bulk-handoffs-search",children:"Search handoffs"}),e.jsx("input",{id:"bulk-handoffs-search",value:p,onChange:t=>g(t.target.value),placeholder:"Search title, summary, status…","data-modal-autofocus":"true",className:"w-full rounded-lg border border-strong bg-black/25 px-3 py-2 text-body text-white placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-[#BFFF00]/35"})]}),e.jsx("button",{type:"button",onClick:w,disabled:r.length===0,className:"rounded-lg border border-strong bg-white/[0.03] px-3 py-2 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:f?"Clear all":`Select all (${r.length})`})]}),y&&e.jsx("div",{className:"mt-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-body text-secondary",children:y})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:r.length===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"No handoffs match this view."}):e.jsx("div",{className:"space-y-2",children:r.map(t=>{const s=c.has(t.id),l=$(t.status);return e.jsx("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2.5",style:{borderColor:s?`${m.lime}40`:"rgba(255,255,255,0.08)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:()=>j(t.id),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40","aria-label":`Select handoff ${t.title}`}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:t.title}),t.summary&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",children:t.summary}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:["Updated ",S(t.updatedAt)]})]}),e.jsx("span",{className:"shrink-0 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",style:{borderColor:`${l}30`,backgroundColor:`${l}14`,color:l},children:t.status})]})})]})},t.id)})})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-subtle px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"text-caption text-secondary",children:u>0?`${u} selected`:"No selection (exporting will include all filtered handoffs)"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:N,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy markdown"}),e.jsx("button",{type:"button",onClick:v,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy JSON"})]})]})]})})}export{z as BulkHandoffsModal};
@@ -1 +1 @@
1
- import{j as s}from"./cNrhgGc1.js";function n({metrics:a,className:l}){return s.jsx("div",{className:`flex items-center gap-12 ${l??""}`,children:a.map(e=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-muted",children:e.label}),s.jsxs("p",{className:"mt-1 text-2xl font-light",style:{color:typeof e.value=="number"&&e.value===0||e.value==="0"?"rgba(255,255,255,0.2)":e.color??"rgba(242,247,255,0.78)",fontVariantNumeric:"tabular-nums"},children:[e.value,e.suffix&&s.jsx("span",{className:"ml-0.5 text-sm font-normal text-muted",children:e.suffix})]})]},e.label))})}export{n as M};
1
+ import{j as s}from"./Dj2k1r16.js";function n({metrics:a,className:l}){return s.jsx("div",{className:`flex items-center gap-12 ${l??""}`,children:a.map(e=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-muted",children:e.label}),s.jsxs("p",{className:"mt-1 text-2xl font-light",style:{color:typeof e.value=="number"&&e.value===0||e.value==="0"?"rgba(255,255,255,0.2)":e.color??"rgba(242,247,255,0.78)",fontVariantNumeric:"tabular-nums"},children:[e.value,e.suffix&&s.jsx("span",{className:"ml-0.5 text-sm font-normal text-muted",children:e.suffix})]})]},e.label))})}export{n as M};
@@ -0,0 +1,53 @@
1
+ import{g as Wn,r as ee}from"./Dj2k1r16.js";var gr="vercel.ai.error",qn=Symbol.for(gr),zt,Ot,Q=class vr extends(Ot=Error,zt=qn,Ot){constructor({name:t,message:r,cause:n}){super(r),this[zt]=!0,this.name=t,this.cause=n}static isInstance(t){return vr.hasMarker(t,gr)}static hasMarker(t,r){const n=Symbol.for(r);return t!=null&&typeof t=="object"&&n in t&&typeof t[n]=="boolean"&&t[n]===!0}};function _r(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var yr="AI_InvalidArgumentError",br=`vercel.ai.error.${yr}`,Yn=Symbol.for(br),Tt,Zt,Gn=class extends(Zt=Q,Tt=Yn,Zt){constructor({message:e,cause:t,argument:r}){super({name:yr,message:e,cause:t}),this[Tt]=!0,this.argument=r}static isInstance(e){return Q.hasMarker(e,br)}},wr="AI_JSONParseError",Er=`vercel.ai.error.${wr}`,Hn=Symbol.for(Er),$t,Nt,At=class extends(Nt=Q,$t=Hn,Nt){constructor({text:e,cause:t}){super({name:wr,message:`JSON parsing failed: Text: ${e}.
2
+ Error message: ${_r(t)}`,cause:t}),this[$t]=!0,this.text=e}static isInstance(e){return Q.hasMarker(e,Er)}},Ir="AI_TypeValidationError",Sr=`vercel.ai.error.${Ir}`,Xn=Symbol.for(Sr),Pt,Rt,_e=class st extends(Rt=Q,Pt=Xn,Rt){constructor({value:t,cause:r,context:n}){let o="Type validation failed";if(n!=null&&n.field&&(o+=` for ${n.field}`),n!=null&&n.entityName||n!=null&&n.entityId){o+=" (";const s=[];n.entityName&&s.push(n.entityName),n.entityId&&s.push(`id: "${n.entityId}"`),o+=s.join(", "),o+=")"}super({name:Ir,message:`${o}: Value: ${JSON.stringify(t)}.
3
+ Error message: ${_r(r)}`,cause:r}),this[Pt]=!0,this.value=t,this.context=n}static isInstance(t){return Q.hasMarker(t,Sr)}static wrap({value:t,cause:r,context:n}){var o,s,i;return st.isInstance(r)&&r.value===t&&((o=r.context)==null?void 0:o.field)===(n==null?void 0:n.field)&&((s=r.context)==null?void 0:s.entityName)===(n==null?void 0:n.entityName)&&((i=r.context)==null?void 0:i.entityId)===(n==null?void 0:n.entityId)?r:new st({value:t,cause:r,context:n})}};function p(e,t,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){const m=l[d];m in a||(a[m]=u[m].bind(a))}}const o=(r==null?void 0:r.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=r!=null&&r.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,u;return r!=null&&r.Parent&&a instanceof r.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class kr extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const zr={};function oe(e){return zr}function Or(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function at(e,t){return typeof t=="bigint"?t.toString():t}function Ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function mt(e){return e==null}function gt(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Kn(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const c=n.match(/\d?e-(\d?)/);c!=null&&c[1]&&(o=Number.parseInt(c[1]))}const s=r>o?r:o,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Ct=Symbol("evaluating");function O(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ct)return n===void 0&&(n=Ct,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function de(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ae(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function xt(e){return JSON.stringify(e)}function Qn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Tr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const eo=Ye(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ye(e){if(Oe(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Oe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zr(e){return ye(e)?{...e}:Array.isArray(e)?[...e]:e}const to=new Set(["string","number","symbol"]);function be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 ro(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const no={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 oo(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=ae(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=r.shape[a])}return de(this,"shape",i),i},checks:[]});return ie(e,s)}function so(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=ae(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return de(this,"shape",i),i},checks:[]});return ie(e,s)}function ao(e,t){if(!ye(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ae(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return de(this,"shape",s),s}});return ie(e,o)}function io(e,t){if(!ye(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=ae(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return de(this,"shape",n),n}});return ie(e,r)}function uo(e,t){const r=ae(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return de(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return ie(e,r)}function co(e,t,r){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=ae(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(r)for(const u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return de(this,"shape",c),c},checks:[]});return ie(t,i)}function lo(e,t,r){const n=ae(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(r)for(const i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return de(this,"shape",s),s}});return ie(t,n)}function me(e,t=0){var r;if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(((r=e.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function ge(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ce(e){return typeof e=="string"?e:e==null?void 0:e.message}function se(e,t,r){var o,s,i,a,c,u;const n={...e,path:e.path??[]};if(!e.message){const l=Ce((i=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??Ce((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Ce((c=r.customError)==null?void 0:c.call(r,e))??Ce((u=r.localeError)==null?void 0:u.call(r,e))??"Invalid input";n.message=l}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function vt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Te(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const $r=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,at,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Nr=p("$ZodError",$r),Ar=p("$ZodError",$r,{Parent:Error});function po(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function fo(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>n({issues:i}));else if(s.code==="invalid_key")n({issues:s.issues});else if(s.code==="invalid_element")n({issues:s.issues});else if(s.path.length===0)r._errors.push(t(s));else{let i=r,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return n(e),r}const _t=e=>(t,r,n,o)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ve;if(i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>se(c,s,oe())));throw Tr(a,o==null?void 0:o.callee),a}return i.value},yt=e=>async(t,r,n,o)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>se(c,s,oe())));throw Tr(a,o==null?void 0:o.callee),a}return i.value},Ge=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ve;return s.issues.length?{success:!1,error:new(e??Nr)(s.issues.map(i=>se(i,o,oe())))}:{success:!0,data:s.value}},ho=Ge(Ar),He=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>se(i,o,oe())))}:{success:!0,data:s.value}},mo=He(Ar),go=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _t(e)(t,r,o)},vo=e=>(t,r,n)=>_t(e)(t,r,n),_o=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return yt(e)(t,r,o)},yo=e=>async(t,r,n)=>yt(e)(t,r,n),bo=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ge(e)(t,r,o)},wo=e=>(t,r,n)=>Ge(e)(t,r,n),Eo=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return He(e)(t,r,o)},Io=e=>async(t,r,n)=>He(e)(t,r,n),So=/^[cC][^\s-]{8,}$/,ko=/^[0-9a-z]+$/,zo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Oo=/^[0-9a-vA-V]{20}$/,To=/^[A-Za-z0-9]{27}$/,Zo=/^[a-zA-Z0-9_-]{21}$/,$o=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,No=/^([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})$/,jt=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)$/,Ao=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Po="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ro(){return new RegExp(Po,"u")}const Co=/^(?:(?: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])$/,xo=/^(([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}|:))$/,jo=/^((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])$/,Mo=/^(([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])$/,Do=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pr=/^[A-Za-z0-9_-]*$/,Uo=/^\+[1-9]\d{6,14}$/,Rr="(?:(?:\\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])))",Lo=new RegExp(`^${Rr}$`);function Cr(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 Fo(e){return new RegExp(`^${Cr(e)}$`)}function Jo(e){const t=Cr({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Rr}T(?:${n})$`)}const Vo=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bo=/^-?\d+$/,xr=/^-?\d+(?:\.\d+)?$/,Wo=/^(?:true|false)$/i,qo=/^null$/i,Yo=/^[^A-Z]*$/,Go=/^[^a-z]*$/,B=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),jr={number:"number",bigint:"bigint",object:"date"},Mr=p("$ZodCheckLessThan",(e,t)=>{B.init(e,t);const r=jr[typeof t.value];e._zod.onattach.push(n=>{const o=n._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=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dr=p("$ZodCheckGreaterThan",(e,t)=>{B.init(e,t);const r=jr[typeof t.value];e._zod.onattach.push(n=>{const o=n._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=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ho=p("$ZodCheckMultipleOf",(e,t)=>{B.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Kn(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Xo=p("$ZodCheckNumberFormat",(e,t)=>{var i;B.init(e,t),t.format=t.format||"float64";const r=(i=t.format)==null?void 0:i.includes("int"),n=r?"int":"number",[o,s]=no[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,r&&(c.pattern=Bo)}),e._zod.check=a=>{const c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Ko=p("$ZodCheckMaxLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!mt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const i=vt(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Qo=p("$ZodCheckMinLength",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!mt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const i=vt(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),es=p("$ZodCheckLengthEquals",(e,t)=>{var r;B.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!mt(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,s=o.length;if(s===t.length)return;const i=vt(o),a=s>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Xe=p("$ZodCheckStringFormat",(e,t)=>{var r,n;B.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?(r=e._zod).check??(r.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})}):(n=e._zod).check??(n.check=()=>{})}),ts=p("$ZodCheckRegex",(e,t)=>{Xe.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),rs=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Yo),Xe.init(e,t)}),ns=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Go),Xe.init(e,t)}),os=p("$ZodCheckIncludes",(e,t)=>{B.init(e,t);const r=be(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),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})}}),ss=p("$ZodCheckStartsWith",(e,t)=>{B.init(e,t);const r=new RegExp(`^${be(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),as=p("$ZodCheckEndsWith",(e,t)=>{B.init(e,t);const r=new RegExp(`.*${be(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),is=p("$ZodCheckOverwrite",(e,t)=>{B.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class us{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 n=t.split(`
4
+ `).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.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,r=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...r,o.join(`
5
+ `))}}const cs={major:4,minor:3,patch:6},x=p("$ZodType",(e,t)=>{var o;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=cs;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const s of n)for(const i of s._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,u)=>{let l=me(a),d;for(const m of c){if(m._zod.def.when){if(!m._zod.def.when(a))continue}else if(l)continue;const h=a.issues.length,_=m._zod.check(a);if(_ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new ve;if(d||_ instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await _,a.issues.length!==h&&(l||(l=me(a,h)))});else{if(a.issues.length===h)continue;l||(l=me(a,h))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(me(a))return a.aborted=!0,a;const l=s(c,n,u);if(l instanceof Promise){if(u.async===!1)throw new ve;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 ve;return u.then(l=>s(l,n,c))}return s(u,n,c)}}O(e,"~standard",()=>({validate:s=>{var i;try{const a=ho(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return mo(e,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),bt=p("$ZodString",(e,t)=>{var r;x.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??Vo(e._zod.bag),e._zod.parse=(n,o)=>{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}}),M=p("$ZodStringFormat",(e,t)=>{Xe.init(e,t),bt.init(e,t)}),ls=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=No),M.init(e,t)}),ds=p("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=jt(n))}else t.pattern??(t.pattern=jt());M.init(e,t)}),ps=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ao),M.init(e,t)}),fs=p("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.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)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),hs=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ro()),M.init(e,t)}),ms=p("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Zo),M.init(e,t)}),gs=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=So),M.init(e,t)}),vs=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ko),M.init(e,t)}),_s=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=zo),M.init(e,t)}),ys=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Oo),M.init(e,t)}),bs=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=To),M.init(e,t)}),ws=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Jo(t)),M.init(e,t)}),Es=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Lo),M.init(e,t)}),Is=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fo(t)),M.init(e,t)}),Ss=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=$o),M.init(e,t)}),ks=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Co),M.init(e,t),e._zod.bag.format="ipv4"}),zs=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=xo),M.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Os=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=jo),M.init(e,t)}),Ts=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Mo),M.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,s]=n;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Ur(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Zs=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Do),M.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Ur(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function $s(e){if(!Pr.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ur(r)}const Ns=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Pr),M.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{$s(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),As=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Uo),M.init(e,t)});function Ps(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Rs=p("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=r=>{Ps(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Lr=p("$ZodNumber",(e,t)=>{x.init(e,t),e._zod.pattern=e._zod.bag.pattern??xr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Cs=p("$ZodNumberFormat",(e,t)=>{Xo.init(e,t),Lr.init(e,t)}),xs=p("$ZodBoolean",(e,t)=>{x.init(e,t),e._zod.pattern=Wo,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),js=p("$ZodNull",(e,t)=>{x.init(e,t),e._zod.pattern=qo,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{const o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Ms=p("$ZodUnknown",(e,t)=>{x.init(e,t),e._zod.parse=r=>r}),Ds=p("$ZodNever",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Mt(e,t,r){e.issues.length&&t.issues.push(...ge(r,e.issues)),t.value[r]=e.value}const Us=p("$ZodArray",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.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:[]},n);c instanceof Promise?s.push(c.then(u=>Mt(u,r,i))):Mt(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Ue(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...ge(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Fr(e){var n,o,s,i;const t=Object.keys(e.shape);for(const a of t)if(!((i=(s=(o=(n=e.shape)==null?void 0:n[a])==null?void 0:o._zod)==null?void 0:s.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const r=ro(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Jr(e,t,r,n,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout==="optional";for(const d in t){if(a.has(d))continue;if(u==="never"){i.push(d);continue}const m=c.run({value:t[d],issues:[]},n);m instanceof Promise?e.push(m.then(h=>Ue(h,r,d,t,l))):Ue(m,r,d,t,l)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}const Ls=p("$ZodObject",(e,t)=>{x.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!(r!=null&&r.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const n=Ye(()=>Fr(t));O(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(const d of l.values)c[u].add(d)}}return c});const o=Oe,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=n.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const l=[],d=i.shape;for(const m of i.keys){const h=d[m],_=h._zod.optout==="optional",v=h._zod.run({value:u[m],issues:[]},c);v instanceof Promise?l.push(v.then(b=>Ue(b,a,m,u,_))):Ue(v,a,m,u,_)}return s?Jr(l,u,a,c,n.value,e):l.length?Promise.all(l).then(()=>a):a}}),Fs=p("$ZodObjectJIT",(e,t)=>{Ls.init(e,t);const r=e._zod.parse,n=Ye(()=>Fr(t)),o=m=>{var f;const h=new us(["shape","payload","ctx"]),_=n.value,v=$=>{const T=xt($);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let E=0;for(const $ of _.keys)b[$]=`key_${E++}`;h.write("const newResult = {};");for(const $ of _.keys){const T=b[$],k=xt($),Z=m[$],V=((f=Z==null?void 0:Z._zod)==null?void 0:f.optout)==="optional";h.write(`const ${T} = ${v($)};`),V?h.write(`
6
+ if (${T}.issues.length) {
7
+ if (${k} in input) {
8
+ payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
9
+ ...iss,
10
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
11
+ })));
12
+ }
13
+ }
14
+
15
+ if (${T}.value === undefined) {
16
+ if (${k} in input) {
17
+ newResult[${k}] = undefined;
18
+ }
19
+ } else {
20
+ newResult[${k}] = ${T}.value;
21
+ }
22
+
23
+ `):h.write(`
24
+ if (${T}.issues.length) {
25
+ payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
26
+ ...iss,
27
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
28
+ })));
29
+ }
30
+
31
+ if (${T}.value === undefined) {
32
+ if (${k} in input) {
33
+ newResult[${k}] = undefined;
34
+ }
35
+ } else {
36
+ newResult[${k}] = ${T}.value;
37
+ }
38
+
39
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const S=h.compile();return($,T)=>S(m,$,T)};let s;const i=Oe,a=!zr.jitless,u=a&&eo.value,l=t.catchall;let d;e._zod.parse=(m,h)=>{d??(d=n.value);const _=m.value;return i(_)?a&&u&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=o(t.shape)),m=s(m,h),l?Jr([],_,m,h,d,e):m):r(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),m)}});function Dt(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!me(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>se(i,n,oe())))}),t)}const Vr=p("$ZodUnion",(e,t)=>{x.init(e,t),O(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),O(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),O(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),O(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>gt(s.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(r)return n(o,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Dt(c,o,e,s)):Dt(a,o,e,s)}}),Js=p("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Vr.init(e,t);const r=e._zod.parse;O(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const n=Ye(()=>{var i;const o=t.options,s=new Map;for(const a of o){const c=(i=a._zod.propValues)==null?void 0:i[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!Oe(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=n.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),o)}}),Vs=p("$ZodIntersection",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Ut(r,c,u)):Ut(r,s,i)}});function it(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(ye(e)&&ye(t)){const r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(const s of n){const i=it(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 r=[];for(let n=0;n<e.length;n++){const o=e[n],s=t[n],i=it(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ut(e,t,r){const n=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(a);for(const a of r.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(a);const s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&e.issues.push({...o,keys:s}),me(e))return e;const i=it(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Bs=p("$ZodRecord",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!ye(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[],i=t.keyType._zod.values;if(i){r.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const l=t.valueType._zod.run({value:o[u],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...ge(u,d.issues)),r.value[u]=d.value})):(l.issues.length&&r.issues.push(...ge(u,l.issues)),r.value[u]=l.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&xr.test(a)&&c.issues.length){const d=t.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>se(d,n,oe())),input:a,path:[a],inst:e});continue}const l=t.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...ge(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...ge(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}}),Ws=p("$ZodEnum",(e,t)=>{x.init(e,t);const r=Or(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>to.has(typeof o)).map(o=>typeof o=="string"?be(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),qs=p("$ZodLiteral",(e,t)=>{if(x.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?be(n):n?be(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Ys=p("$ZodTransform",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ve;return r.value=o,r}});function Lt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Br=p("$ZodOptional",(e,t)=>{x.init(e,t),e._zod.optin="optional",e._zod.optout="optional",O(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${gt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Lt(s,r.value)):Lt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Gs=p("$ZodExactOptional",(e,t)=>{Br.init(e,t),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Hs=p("$ZodNullable",(e,t)=>{x.init(e,t),O(e._zod,"optin",()=>t.innerType._zod.optin),O(e._zod,"optout",()=>t.innerType._zod.optout),O(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${gt(r.source)}|null)$`):void 0}),O(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Xs=p("$ZodDefault",(e,t)=>{x.init(e,t),e._zod.optin="optional",O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ft(s,t)):Ft(o,t)}});function Ft(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ks=p("$ZodPrefault",(e,t)=>{x.init(e,t),e._zod.optin="optional",O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Qs=p("$ZodNonOptional",(e,t)=>{x.init(e,t),O(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Jt(s,e)):Jt(o,e)}});function Jt(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 ea=p("$ZodCatch",(e,t)=>{x.init(e,t),O(e._zod,"optin",()=>t.innerType._zod.optin),O(e._zod,"optout",()=>t.innerType._zod.optout),O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>se(i,n,oe()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>se(s,n,oe()))},input:r.value}),r.issues=[]),r)}}),ta=p("$ZodPipe",(e,t)=>{x.init(e,t),O(e._zod,"values",()=>t.in._zod.values),O(e._zod,"optin",()=>t.in._zod.optin),O(e._zod,"optout",()=>t.out._zod.optout),O(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>xe(i,t.in,n)):xe(s,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>xe(s,t.out,n)):xe(o,t.out,n)}});function xe(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const ra=p("$ZodReadonly",(e,t)=>{x.init(e,t),O(e._zod,"propValues",()=>t.innerType._zod.propValues),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"optin",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optin}),O(e._zod,"optout",()=>{var r,n;return(n=(r=t.innerType)==null?void 0:r._zod)==null?void 0:n.optout}),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Vt):Vt(o)}});function Vt(e){return e.value=Object.freeze(e.value),e}const na=p("$ZodLazy",(e,t)=>{x.init(e,t),O(e._zod,"innerType",()=>t.getter()),O(e._zod,"pattern",()=>{var r,n;return(n=(r=e._zod.innerType)==null?void 0:r._zod)==null?void 0:n.pattern}),O(e._zod,"propValues",()=>{var r,n;return(n=(r=e._zod.innerType)==null?void 0:r._zod)==null?void 0:n.propValues}),O(e._zod,"optin",()=>{var r,n;return((n=(r=e._zod.innerType)==null?void 0:r._zod)==null?void 0:n.optin)??void 0}),O(e._zod,"optout",()=>{var r,n;return((n=(r=e._zod.innerType)==null?void 0:r._zod)==null?void 0:n.optout)??void 0}),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),oa=p("$ZodCustom",(e,t)=>{B.init(e,t),x.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Bt(s,r,n,e));Bt(o,r,n,e)}});function Bt(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Te(o))}}var Wt;class sa{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...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 aa(){return new sa}(Wt=globalThis).__zod_globalRegistry??(Wt.__zod_globalRegistry=aa());const Ie=globalThis.__zod_globalRegistry;function ia(e,t){return new e({type:"string",...y(t)})}function ua(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function qt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function ca(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function la(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function da(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function pa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function fa(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function ha(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function ma(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function ga(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function va(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function _a(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function ya(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function ba(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function wa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Ea(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function Ia(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function Sa(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function ka(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function za(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function Oa(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function Ta(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function Za(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function $a(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function Na(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function Aa(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function Pa(e,t){return new e({type:"number",checks:[],...y(t)})}function Ra(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function Ca(e,t){return new e({type:"boolean",...y(t)})}function xa(e,t){return new e({type:"null",...y(t)})}function ja(e){return new e({type:"unknown"})}function Ma(e,t){return new e({type:"never",...y(t)})}function Yt(e,t){return new Mr({check:"less_than",...y(t),value:e,inclusive:!1})}function Qe(e,t){return new Mr({check:"less_than",...y(t),value:e,inclusive:!0})}function Gt(e,t){return new Dr({check:"greater_than",...y(t),value:e,inclusive:!1})}function et(e,t){return new Dr({check:"greater_than",...y(t),value:e,inclusive:!0})}function Ht(e,t){return new Ho({check:"multiple_of",...y(t),value:e})}function Wr(e,t){return new Ko({check:"max_length",...y(t),maximum:e})}function Le(e,t){return new Qo({check:"min_length",...y(t),minimum:e})}function qr(e,t){return new es({check:"length_equals",...y(t),length:e})}function Da(e,t){return new ts({check:"string_format",format:"regex",...y(t),pattern:e})}function Ua(e){return new rs({check:"string_format",format:"lowercase",...y(e)})}function La(e){return new ns({check:"string_format",format:"uppercase",...y(e)})}function Fa(e,t){return new os({check:"string_format",format:"includes",...y(t),includes:e})}function Ja(e,t){return new ss({check:"string_format",format:"starts_with",...y(t),prefix:e})}function Va(e,t){return new as({check:"string_format",format:"ends_with",...y(t),suffix:e})}function we(e){return new is({check:"overwrite",tx:e})}function Ba(e){return we(t=>t.normalize(e))}function Wa(){return we(e=>e.trim())}function qa(){return we(e=>e.toLowerCase())}function Ya(){return we(e=>e.toUpperCase())}function Ga(){return we(e=>Qn(e))}function Ha(e,t,r){return new e({type:"array",element:t,...y(r)})}function Xa(e,t,r){const n=y(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Ka(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function Qa(e){const t=ei(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Te(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Te(o))}},e(r.value,r)));return t}function ei(e,t){const r=new B({check:"custom",...y(t)});return r._zod.check=e,r}function Fe(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Ie,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function P(e,t,r={path:[],schemaPath:[]}){var l,d;var n;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);const a=(d=(l=e._zod).toJSONSchema)==null?void 0:d.call(l);if(a)i.schema=a;else{const m={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,m);else{const _=i.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,_,m)}const h=e._zod.parent;h&&(i.ref||(i.ref=h),P(h,t,m),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&L(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Je(e,t){var i,a,c,u;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const l of e.seen.entries()){const d=(i=e.metadataRegistry.get(l[0]))==null?void 0:i.id;if(d){const m=n.get(d);if(m&&m!==l[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(d,l[0])}}const o=l=>{var v;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const b=(v=e.external.registry.get(l[0]))==null?void 0:v.id,E=e.external.uri??(f=>f);if(b)return{ref:E(b)};const S=l[1].defId??l[1].schema.id??`schema${e.counter++}`;return l[1].defId=S,{defId:S,ref:`${E("__shared")}#/${d}/${S}`}}if(l[1]===r)return{ref:"#"};const h=`#/${d}/`,_=l[1].schema.id??`__schema${e.counter++}`;return{defId:_,ref:h+_}},s=l=>{if(l[1].schema.$ref)return;const d=l[1],{ref:m,defId:h}=o(l);d.def={...d.schema},h&&(d.defId=h);const _=d.schema;for(const v in _)delete _[v];_.$ref=m};if(e.cycles==="throw")for(const l of e.seen.entries()){const d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${(a=d.cycle)==null?void 0:a.join("/")}/<root>
40
+
41
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of e.seen.entries()){const d=l[1];if(t===l[0]){s(l);continue}if(e.external){const h=(c=e.external.registry.get(l[0]))==null?void 0:c.id;if(t!==l[0]&&h){s(l);continue}}if((u=e.metadataRegistry.get(l[0]))==null?void 0:u.id){s(l);continue}if(d.cycle){s(l);continue}if(d.count>1&&e.reused==="ref"){s(l);continue}}}function Ve(e,t){var i,a,c;const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=u=>{const l=e.seen.get(u);if(l.ref===null)return;const d=l.def??l.schema,m={...d},h=l.ref;if(l.ref=null,h){n(h);const v=e.seen.get(h),b=v.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(b)):Object.assign(d,b),Object.assign(d,m),u._zod.parent===h)for(const S in d)S==="$ref"||S==="allOf"||S in m||delete d[S];if(b.$ref&&v.def)for(const S in d)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(d[S])===JSON.stringify(v.def[S])&&delete d[S]}const _=u._zod.parent;if(_&&_!==h){n(_);const v=e.seen.get(_);if(v!=null&&v.schema.$ref&&(d.$ref=v.schema.$ref,v.def))for(const b in d)b==="$ref"||b==="allOf"||b in v.def&&JSON.stringify(d[b])===JSON.stringify(v.def[b])&&delete d[b]}e.override({zodSchema:u,jsonSchema:d,path:l.path??[]})};for(const u of[...e.seen.entries()].reverse())n(u[0]);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,(i=e.external)!=null&&i.uri){const u=(a=e.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(u)}Object.assign(o,r.def??r.schema);const s=((c=e.external)==null?void 0:c.defs)??{};for(const u of e.seen.entries()){const l=u[1];l.def&&l.defId&&(s[l.defId]=l.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const u=JSON.parse(JSON.stringify(o));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Be(t,"input",e.processors),output:Be(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function L(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return L(n.element,r);if(n.type==="set")return L(n.valueType,r);if(n.type==="lazy")return L(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return L(n.innerType,r);if(n.type==="intersection")return L(n.left,r)||L(n.right,r);if(n.type==="record"||n.type==="map")return L(n.keyType,r)||L(n.valueType,r);if(n.type==="pipe")return L(n.in,r)||L(n.out,r);if(n.type==="object"){for(const o in n.shape)if(L(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(L(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(L(o,r))return!0;return!!(n.rest&&L(n.rest,r))}return!1}const ti=(e,t={})=>r=>{const n=Fe({...r,processors:t});return P(e,n),Je(n,e),Ve(n,e)},Be=(e,t,r={})=>n=>{const{libraryOptions:o,target:s}=n??{},i=Fe({...o??{},target:s,io:t,processors:r});return P(e,i),Je(i,e),Ve(i,e)},ri={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yr=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ri[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Gr=(e,t,r,n)=>{const o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof s=="number"&&(o.minimum=s,typeof l=="number"&&t.target!=="draft-04"&&(l>=s?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof i=="number"&&(o.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Hr=(e,t,r,n)=>{r.type="boolean"},ni=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},oi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Xr=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},si=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},ai=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Kr=(e,t,r,n)=>{r.not={}},ii=(e,t,r,n)=>{},Qr=(e,t,r,n)=>{},ui=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},en=(e,t,r,n)=>{const o=e._zod.def,s=Or(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},tn=(e,t,r,n)=>{const o=e._zod.def,s=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s},ci=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},li=(e,t,r,n)=>{const o=r,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=s.source},di=(e,t,r,n)=>{const o=r,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:a,mime:c}=e._zod.bag;i!==void 0&&(s.minLength=i),a!==void 0&&(s.maxLength=a),c?c.length===1?(s.contentMediaType=c[0],Object.assign(o,s)):(Object.assign(o,s),o.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(o,s)},pi=(e,t,r,n)=>{r.type="boolean"},rn=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},nn=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},hi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},mi=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},on=(e,t,r,n)=>{const o=r,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=P(s.element,t,{...n,path:[...n.path,"items"]})},sn=(e,t,r,n)=>{var u;const o=r,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const l in i)o.properties[l]=P(i[l],t,{...n,path:[...n.path,"properties",l]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(l=>{const d=s.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=P(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},an=(e,t,r,n)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>P(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},un=(e,t,r,n)=>{const o=e._zod.def,s=P(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=P(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c},gi=(e,t,r,n)=>{const o=r,s=e._zod.def;o.type="array";const i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((m,h)=>P(m,t,{...n,path:[...n.path,i,h]})),u=s.rest?P(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=c,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));const{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof d=="number"&&(o.maxItems=d)},cn=(e,t,r,n)=>{const o=r,s=e._zod.def;o.type="object";const i=s.keyType,a=i._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const l=P(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(const d of c)o.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=P(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=P(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const u=i._zod.values;if(u){const l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},ln=(e,t,r,n)=>{const o=e._zod.def,s=P(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},dn=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType},pn=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},fn=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},hn=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},mn=(e,t,r,n)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;P(s,t,n);const i=t.seen.get(e);i.ref=s},gn=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},vi=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType},wt=(e,t,r,n)=>{const o=e._zod.def;P(o.innerType,t,n);const s=t.seen.get(e);s.ref=o.innerType},vn=(e,t,r,n)=>{const o=e._zod.innerType;P(o,t,n);const s=t.seen.get(e);s.ref=o},Xt={string:Yr,number:Gr,boolean:Hr,bigint:ni,symbol:oi,null:Xr,undefined:si,void:ai,never:Kr,any:ii,unknown:Qr,date:ui,enum:en,literal:tn,nan:ci,template_literal:li,file:di,success:pi,custom:rn,function:fi,transform:nn,map:hi,set:mi,array:on,object:sn,union:an,intersection:un,tuple:gi,record:cn,nullable:ln,nonoptional:dn,default:pn,prefault:fn,catch:hn,pipe:mn,readonly:gn,promise:vi,optional:wt,lazy:vn};function _i(e,t){if("_idmap"in e){const n=e,o=Fe({...t,processors:Xt}),s={};for(const c of n._idmap.entries()){const[u,l]=c;P(l,o)}const i={},a={registry:n,uri:t==null?void 0:t.uri,defs:s};o.external=a;for(const c of n._idmap.entries()){const[u,l]=c;Je(o,l),i[u]=Ve(o,l)}if(Object.keys(s).length>0){const c=o.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:s}}return{schemas:i}}const r=Fe({...t,processors:Xt});return P(e,r),Je(r,e),Ve(r,e)}const yi=p("ZodISODateTime",(e,t)=>{ws.init(e,t),D.init(e,t)});function bi(e){return Za(yi,e)}const wi=p("ZodISODate",(e,t)=>{Es.init(e,t),D.init(e,t)});function Ei(e){return $a(wi,e)}const Ii=p("ZodISOTime",(e,t)=>{Is.init(e,t),D.init(e,t)});function Si(e){return Na(Ii,e)}const ki=p("ZodISODuration",(e,t)=>{Ss.init(e,t),D.init(e,t)});function zi(e){return Aa(ki,e)}const Oi=(e,t)=>{Nr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>fo(e,r)},flatten:{value:r=>po(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,at,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,at,2)}},isEmpty:{get(){return e.issues.length===0}}})},Y=p("ZodError",Oi,{Parent:Error}),Ti=_t(Y),Zi=yt(Y),$i=Ge(Y),_n=He(Y),Ni=go(Y),Ai=vo(Y),Pi=_o(Y),Ri=yo(Y),Ci=bo(Y),xi=wo(Y),ji=Eo(Y),Mi=Io(Y),j=p("ZodType",(e,t)=>(x.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Be(e,"input"),output:Be(e,"output")}}),e.toJSONSchema=ti(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(ae(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>ie(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Ti(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>$i(e,r,n),e.parseAsync=async(r,n)=>Zi(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>_n(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Ni(e,r,n),e.decode=(r,n)=>Ai(e,r,n),e.encodeAsync=async(r,n)=>Pi(e,r,n),e.decodeAsync=async(r,n)=>Ri(e,r,n),e.safeEncode=(r,n)=>Ci(e,r,n),e.safeDecode=(r,n)=>xi(e,r,n),e.safeEncodeAsync=async(r,n)=>ji(e,r,n),e.safeDecodeAsync=async(r,n)=>Mi(e,r,n),e.refine=(r,n)=>e.check(Ru(r,n)),e.superRefine=r=>e.check(Cu(r)),e.overwrite=r=>e.check(we(r)),e.optional=()=>er(e),e.exactOptional=()=>bu(e),e.nullable=()=>tr(e),e.nullish=()=>er(tr(e)),e.nonoptional=r=>zu(e,r),e.array=()=>Ee(e),e.or=r=>J([e,r]),e.and=r=>hu(e,r),e.transform=r=>rr(e,_u(r)),e.default=r=>Iu(e,r),e.prefault=r=>ku(e,r),e.catch=r=>Tu(e,r),e.pipe=r=>rr(e,r),e.readonly=()=>Nu(e),e.describe=r=>{const n=e.clone();return Ie.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Ie.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ie.get(e);const n=e.clone();return Ie.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),yn=p("_ZodString",(e,t)=>{bt.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Yr(e,n,o);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Da(...n)),e.includes=(...n)=>e.check(Fa(...n)),e.startsWith=(...n)=>e.check(Ja(...n)),e.endsWith=(...n)=>e.check(Va(...n)),e.min=(...n)=>e.check(Le(...n)),e.max=(...n)=>e.check(Wr(...n)),e.length=(...n)=>e.check(qr(...n)),e.nonempty=(...n)=>e.check(Le(1,...n)),e.lowercase=n=>e.check(Ua(n)),e.uppercase=n=>e.check(La(n)),e.trim=()=>e.check(Wa()),e.normalize=(...n)=>e.check(Ba(...n)),e.toLowerCase=()=>e.check(qa()),e.toUpperCase=()=>e.check(Ya()),e.slugify=()=>e.check(Ga())}),Di=p("ZodString",(e,t)=>{bt.init(e,t),yn.init(e,t),e.email=r=>e.check(ua(Ui,r)),e.url=r=>e.check(fa(Li,r)),e.jwt=r=>e.check(Ta(ru,r)),e.emoji=r=>e.check(ha(Fi,r)),e.guid=r=>e.check(qt(Kt,r)),e.uuid=r=>e.check(ca(je,r)),e.uuidv4=r=>e.check(la(je,r)),e.uuidv6=r=>e.check(da(je,r)),e.uuidv7=r=>e.check(pa(je,r)),e.nanoid=r=>e.check(ma(Ji,r)),e.guid=r=>e.check(qt(Kt,r)),e.cuid=r=>e.check(ga(Vi,r)),e.cuid2=r=>e.check(va(Bi,r)),e.ulid=r=>e.check(_a(Wi,r)),e.base64=r=>e.check(ka(Qi,r)),e.base64url=r=>e.check(za(eu,r)),e.xid=r=>e.check(ya(qi,r)),e.ksuid=r=>e.check(ba(Yi,r)),e.ipv4=r=>e.check(wa(Gi,r)),e.ipv6=r=>e.check(Ea(Hi,r)),e.cidrv4=r=>e.check(Ia(Xi,r)),e.cidrv6=r=>e.check(Sa(Ki,r)),e.e164=r=>e.check(Oa(tu,r)),e.datetime=r=>e.check(bi(r)),e.date=r=>e.check(Ei(r)),e.time=r=>e.check(Si(r)),e.duration=r=>e.check(zi(r))});function g(e){return ia(Di,e)}const D=p("ZodStringFormat",(e,t)=>{M.init(e,t),yn.init(e,t)}),Ui=p("ZodEmail",(e,t)=>{ps.init(e,t),D.init(e,t)}),Kt=p("ZodGUID",(e,t)=>{ls.init(e,t),D.init(e,t)}),je=p("ZodUUID",(e,t)=>{ds.init(e,t),D.init(e,t)}),Li=p("ZodURL",(e,t)=>{fs.init(e,t),D.init(e,t)}),Fi=p("ZodEmoji",(e,t)=>{hs.init(e,t),D.init(e,t)}),Ji=p("ZodNanoID",(e,t)=>{ms.init(e,t),D.init(e,t)}),Vi=p("ZodCUID",(e,t)=>{gs.init(e,t),D.init(e,t)}),Bi=p("ZodCUID2",(e,t)=>{vs.init(e,t),D.init(e,t)}),Wi=p("ZodULID",(e,t)=>{_s.init(e,t),D.init(e,t)}),qi=p("ZodXID",(e,t)=>{ys.init(e,t),D.init(e,t)}),Yi=p("ZodKSUID",(e,t)=>{bs.init(e,t),D.init(e,t)}),Gi=p("ZodIPv4",(e,t)=>{ks.init(e,t),D.init(e,t)}),Hi=p("ZodIPv6",(e,t)=>{zs.init(e,t),D.init(e,t)}),Xi=p("ZodCIDRv4",(e,t)=>{Os.init(e,t),D.init(e,t)}),Ki=p("ZodCIDRv6",(e,t)=>{Ts.init(e,t),D.init(e,t)}),Qi=p("ZodBase64",(e,t)=>{Zs.init(e,t),D.init(e,t)}),eu=p("ZodBase64URL",(e,t)=>{Ns.init(e,t),D.init(e,t)}),tu=p("ZodE164",(e,t)=>{As.init(e,t),D.init(e,t)}),ru=p("ZodJWT",(e,t)=>{Rs.init(e,t),D.init(e,t)}),bn=p("ZodNumber",(e,t)=>{Lr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Gr(e,n,o),e.gt=(n,o)=>e.check(Gt(n,o)),e.gte=(n,o)=>e.check(et(n,o)),e.min=(n,o)=>e.check(et(n,o)),e.lt=(n,o)=>e.check(Yt(n,o)),e.lte=(n,o)=>e.check(Qe(n,o)),e.max=(n,o)=>e.check(Qe(n,o)),e.int=n=>e.check(Qt(n)),e.safe=n=>e.check(Qt(n)),e.positive=n=>e.check(Gt(0,n)),e.nonnegative=n=>e.check(et(0,n)),e.negative=n=>e.check(Yt(0,n)),e.nonpositive=n=>e.check(Qe(0,n)),e.multipleOf=(n,o)=>e.check(Ht(n,o)),e.step=(n,o)=>e.check(Ht(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function nu(e){return Pa(bn,e)}const ou=p("ZodNumberFormat",(e,t)=>{Cs.init(e,t),bn.init(e,t)});function Qt(e){return Ra(ou,e)}const su=p("ZodBoolean",(e,t)=>{xs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hr(e,r,n)});function F(e){return Ca(su,e)}const au=p("ZodNull",(e,t)=>{js.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xr(e,r,n)});function iu(e){return xa(au,e)}const uu=p("ZodUnknown",(e,t)=>{Ms.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qr()});function K(){return ja(uu)}const cu=p("ZodNever",(e,t)=>{Ds.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kr(e,r,n)});function wn(e){return Ma(cu,e)}const lu=p("ZodArray",(e,t)=>{Us.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>on(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(Le(r,n)),e.nonempty=r=>e.check(Le(1,r)),e.max=(r,n)=>e.check(Wr(r,n)),e.length=(r,n)=>e.check(qr(r,n)),e.unwrap=()=>e.element});function Ee(e,t){return Ha(lu,e,t)}const En=p("ZodObject",(e,t)=>{Fs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sn(e,r,n,o),O(e,"shape",()=>t.shape),e.keyof=()=>Sn(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:K()}),e.loose=()=>e.clone({...e._zod.def,catchall:K()}),e.strict=()=>e.clone({...e._zod.def,catchall:wn()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ao(e,r),e.safeExtend=r=>io(e,r),e.merge=r=>uo(e,r),e.pick=r=>oo(e,r),e.omit=r=>so(e,r),e.partial=(...r)=>co(kn,e,r[0]),e.required=(...r)=>lo(zn,e,r[0])});function A(e,t){const r={type:"object",shape:e??{},...y(t)};return new En(r)}function R(e,t){return new En({type:"object",shape:e,catchall:wn(),...y(t)})}const In=p("ZodUnion",(e,t)=>{Vr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>an(e,r,n,o),e.options=t.options});function J(e,t){return new In({type:"union",options:e,...y(t)})}const du=p("ZodDiscriminatedUnion",(e,t)=>{In.init(e,t),Js.init(e,t)});function pu(e,t,r){return new du({type:"union",options:t,discriminator:e,...y(r)})}const fu=p("ZodIntersection",(e,t)=>{Vs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>un(e,r,n,o)});function hu(e,t){return new fu({type:"intersection",left:e,right:t})}const mu=p("ZodRecord",(e,t)=>{Bs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cn(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ze(e,t,r){return new mu({type:"record",keyType:e,valueType:t,...y(r)})}const ut=p("ZodEnum",(e,t)=>{Ws.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,o,s)=>en(e,n,o),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const s={};for(const i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ut({...t,checks:[],...y(o),entries:s})},e.exclude=(n,o)=>{const s={...t.entries};for(const i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ut({...t,checks:[],...y(o),entries:s})}});function Sn(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ut({type:"enum",entries:r,...y(t)})}const gu=p("ZodLiteral",(e,t)=>{qs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tn(e,r,n),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 w(e,t){return new gu({type:"literal",values:Array.isArray(e)?e:[e],...y(t)})}const vu=p("ZodTransform",(e,t)=>{Ys.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nn(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(Te(s,r.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Te(i))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function _u(e){return new vu({type:"transform",transform:e})}const kn=p("ZodOptional",(e,t)=>{Br.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function er(e){return new kn({type:"optional",innerType:e})}const yu=p("ZodExactOptional",(e,t)=>{Gs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function bu(e){return new yu({type:"optional",innerType:e})}const wu=p("ZodNullable",(e,t)=>{Hs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ln(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function tr(e){return new wu({type:"nullable",innerType:e})}const Eu=p("ZodDefault",(e,t)=>{Xs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Iu(e,t){return new Eu({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Zr(t)}})}const Su=p("ZodPrefault",(e,t)=>{Ks.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ku(e,t){return new Su({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Zr(t)}})}const zn=p("ZodNonOptional",(e,t)=>{Qs.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function zu(e,t){return new zn({type:"nonoptional",innerType:e,...y(t)})}const Ou=p("ZodCatch",(e,t)=>{ea.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Tu(e,t){return new Ou({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Zu=p("ZodPipe",(e,t)=>{ta.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mn(e,r,n,o),e.in=t.in,e.out=t.out});function rr(e,t){return new Zu({type:"pipe",in:e,out:t})}const $u=p("ZodReadonly",(e,t)=>{ra.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Nu(e){return new $u({type:"readonly",innerType:e})}const Au=p("ZodLazy",(e,t)=>{na.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vn(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function Pu(e){return new Au({type:"lazy",getter:e})}const Et=p("ZodCustom",(e,t)=>{oa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rn(e,r)});function On(e,t){return Xa(Et,e??(()=>!0),t)}function Ru(e,t={}){return Ka(Et,e,t)}function Cu(e){return Qa(e)}function We(e,t={}){const r=new Et({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...y(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var $e;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function r(o){throw new Error}e.assertNever=r,e.arrayToEnum=o=>{const s={};for(const i of o)s[i]=i;return s},e.getValidEnumValues=o=>{const s=e.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(const a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=o=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const s=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},e.find=(o,s)=>{for(const i of o)if(s(i))return i},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})($e||($e={}));var nr;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(nr||(nr={}));$e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);$e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class qe extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(s){return s.message},n={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,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(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(t){if(!(t instanceof qe))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r=Object.create(null),n=[];for(const o of this.issues)if(o.path.length>0){const s=o.path[0];r[s]=r[s]||[],r[s].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}qe.create=e=>new qe(e);var or;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(or||(or={}));var I;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(I||(I={}));class sr extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}function tt(e){}function xu(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=tt,onError:r=tt,onRetry:n=tt,onComment:o}=e;let s="",i=!0,a,c="",u="";function l(v){const b=i?v.replace(/^\xEF\xBB\xBF/,""):v,[E,S]=ju(`${s}${b}`);for(const f of E)d(f);s=S,i=!1}function d(v){if(v===""){h();return}if(v.startsWith(":")){o&&o(v.slice(v.startsWith(": ")?2:1));return}const b=v.indexOf(":");if(b!==-1){const E=v.slice(0,b),S=v[b+1]===" "?2:1,f=v.slice(b+S);m(E,f,v);return}m(v,"",v)}function m(v,b,E){switch(v){case"event":u=b;break;case"data":c=`${c}${b}
42
+ `;break;case"id":a=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?n(parseInt(b,10)):r(new sr(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:E}));break;default:r(new sr(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:b,line:E}));break}}function h(){c.length>0&&t({id:a,event:u||void 0,data:c.endsWith(`
43
+ `)?c.slice(0,-1):c}),a=void 0,c="",u=""}function _(v={}){s&&v.consume&&d(s),i=!0,a=void 0,c="",u="",s=""}return{feed:l,reset:_}}function ju(e){const t=[];let r="",n=0;for(;n<e.length;){const o=e.indexOf("\r",n),s=e.indexOf(`
44
+ `,n);let i=-1;if(o!==-1&&s!==-1?i=Math.min(o,s):o!==-1?o===e.length-1?i=-1:i=o:s!==-1&&(i=s),i===-1){r=e.slice(n);break}else{const a=e.slice(n,i);t.push(a),n=i+1,e[n-1]==="\r"&&e[n]===`
45
+ `&&n++}}return[t,r]}class Mu extends TransformStream{constructor({onError:t,onRetry:r,onComment:n}={}){let o;super({start(s){o=xu({onEvent:i=>{s.enqueue(i)},onError(i){t==="terminate"?s.error(i):typeof t=="function"&&t(i)},onRetry:r,onComment:n})},transform(s){o.feed(s)}})}}var Pe=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:n="-"}={})=>{const o=()=>{const s=r.length,i=new Array(t);for(let a=0;a<t;a++)i[a]=r[Math.random()*s|0];return i.join("")};if(e==null)return o;if(r.includes(n))throw new Gn({argument:"separator",message:`The separator "${n}" must not be part of the alphabet "${r}".`});return()=>`${e}${n}${o()}`},Du=Pe();function ar(e=globalThis){var t,r,n;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(n=(r=e.process)==null?void 0:r.versions)!=null&&n.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function ce(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,n)=>{t[n.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,n]of e)n!=null&&(t[r.toLowerCase()]=n)}return t}function ir(e,...t){const r=new Headers(ce(e)),n=r.get("user-agent")||"";return r.set("user-agent",[n,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var Uu=/"__proto__"\s*:/,Lu=/"constructor"\s*:/;function ur(e){const t=JSON.parse(e);return t===null||typeof t!="object"||Uu.test(e)===!1&&Lu.test(e)===!1?t:Fu(t)}function Fu(e){let t=[e];for(;t.length;){const r=t;t=[];for(const n of r){if(Object.prototype.hasOwnProperty.call(n,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(n,"constructor")&&Object.prototype.hasOwnProperty.call(n.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const o in n){const s=n[o];s&&typeof s=="object"&&t.push(s)}}}return e}function Ju(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return ur(e)}try{return ur(e)}finally{Error.stackTraceLimit=t}}function It(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:r}=e;if(r!=null)for(const n of Object.keys(r))r[n]=ue(r[n])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(ue):ue(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(ue)),e.allOf!=null&&(e.allOf=e.allOf.map(ue)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(ue));const{definitions:t}=e;if(t!=null)for(const r of Object.keys(t))t[r]=ue(t[r]);return e}function ue(e){return typeof e=="boolean"?e:It(e)}var Vu=Symbol("Let zodToJsonSchema decide on which parser to use"),cr={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Bu=e=>typeof e=="string"?{...cr,name:e}:{...cr,...e};function W(){return{}}function Wu(e,t){var r,n,o;const s={type:"array"};return(r=e.type)!=null&&r._def&&((o=(n=e.type)==null?void 0:n._def)==null?void 0:o.typeName)!==I.ZodAny&&(s.items=N(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(s.minItems=e.minLength.value),e.maxLength&&(s.maxItems=e.maxLength.value),e.exactLength&&(s.minItems=e.exactLength.value,s.maxItems=e.exactLength.value),s}function qu(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function Yu(){return{type:"boolean"}}function Tn(e,t){return N(e.type._def,t)}var Gu=(e,t)=>N(e.innerType._def,t);function Zn(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>Zn(e,t,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Hu(e)}}var Hu=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function Xu(e,t){return{...N(e.innerType._def,t),default:e.defaultValue()}}function Ku(e,t){return t.effectStrategy==="input"?N(e.schema._def,t):W()}function Qu(e){return{type:"string",enum:Array.from(e.values)}}var ec=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function tc(e,t){const r=[N(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),N(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=[];return r.forEach(o=>{if(ec(o))n.push(...o.allOf);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){const{additionalProperties:i,...a}=o;s=a}n.push(s)}}),n.length?{allOf:n}:void 0}function rc(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var rt=void 0,G={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(rt===void 0&&(rt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rt),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function $n(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value;break;case"email":switch(t.emailStrategy){case"format:email":H(r,"email",n.message,t);break;case"format:idn-email":H(r,"idn-email",n.message,t);break;case"pattern:zod":U(r,G.email,n.message,t);break}break;case"url":H(r,"uri",n.message,t);break;case"uuid":H(r,"uuid",n.message,t);break;case"regex":U(r,n.regex,n.message,t);break;case"cuid":U(r,G.cuid,n.message,t);break;case"cuid2":U(r,G.cuid2,n.message,t);break;case"startsWith":U(r,RegExp(`^${nt(n.value,t)}`),n.message,t);break;case"endsWith":U(r,RegExp(`${nt(n.value,t)}$`),n.message,t);break;case"datetime":H(r,"date-time",n.message,t);break;case"date":H(r,"date",n.message,t);break;case"time":H(r,"time",n.message,t);break;case"duration":H(r,"duration",n.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value;break;case"includes":{U(r,RegExp(nt(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&H(r,"ipv4",n.message,t),n.version!=="v4"&&H(r,"ipv6",n.message,t);break}case"base64url":U(r,G.base64url,n.message,t);break;case"jwt":U(r,G.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&U(r,G.ipv4Cidr,n.message,t),n.version!=="v4"&&U(r,G.ipv6Cidr,n.message,t);break}case"emoji":U(r,G.emoji(),n.message,t);break;case"ulid":{U(r,G.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{H(r,"binary",n.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{U(r,G.base64,n.message,t);break}}break}case"nanoid":U(r,G.nanoid,n.message,t)}return r}function nt(e,t){return t.patternStrategy==="escape"?oc(e):e}var nc=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function oc(e){let t="";for(let r=0;r<e.length;r++)nc.has(e[r])||(t+="\\"),t+=e[r];return t}function H(e,t,r,n){var o;e.format||(o=e.anyOf)!=null&&o.some(s=>s.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function U(e,t,r,n){var o;e.pattern||(o=e.allOf)!=null&&o.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:lr(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=lr(t,n)}function lr(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;const n={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},o=n.i?e.source.toLowerCase():e.source;let s="",i=!1,a=!1,c=!1;for(let u=0;u<o.length;u++){if(i){s+=o[u],i=!1;continue}if(n.i){if(a){if(o[u].match(/[a-z]/)){c?(s+=o[u],s+=`${o[u-2]}-${o[u]}`.toUpperCase(),c=!1):o[u+1]==="-"&&((r=o[u+2])!=null&&r.match(/[a-z]/))?(s+=o[u],c=!0):s+=`${o[u]}${o[u].toUpperCase()}`;continue}}else if(o[u].match(/[a-z]/)){s+=`[${o[u]}${o[u].toUpperCase()}]`;continue}}if(n.m){if(o[u]==="^"){s+=`(^|(?<=[\r
46
+ ]))`;continue}else if(o[u]==="$"){s+=`($|(?=[\r
47
+ ]))`;continue}}if(n.s&&o[u]==="."){s+=a?`${o[u]}\r
48
+ `:`[${o[u]}\r
49
+ ]`;continue}s+=o[u],o[u]==="\\"?i=!0:a&&o[u]==="]"?a=!1:!a&&o[u]==="["&&(a=!0)}try{new RegExp(s)}catch{return e.source}return s}function Nn(e,t){var r,n,o,s,i,a;const c={type:"object",additionalProperties:(r=N(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((n=e.keyType)==null?void 0:n._def.typeName)===I.ZodString&&((o=e.keyType._def.checks)!=null&&o.length)){const{type:u,...l}=$n(e.keyType._def,t);return{...c,propertyNames:l}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===I.ZodEnum)return{...c,propertyNames:{enum:e.keyType._def.values}};if(((i=e.keyType)==null?void 0:i._def.typeName)===I.ZodBranded&&e.keyType._def.type._def.typeName===I.ZodString&&((a=e.keyType._def.type._def.checks)!=null&&a.length)){const{type:u,...l}=Tn(e.keyType._def,t);return{...c,propertyNames:l}}}return c}function sc(e,t){if(t.mapStrategy==="record")return Nn(e,t);const r=N(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||W(),n=N(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||W();return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function ac(e){const t=e.values,n=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function ic(){return{not:W()}}function uc(){return{type:"null"}}var ct={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function cc(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in ct&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((o,s)=>{const i=ct[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){const n=r.reduce((o,s)=>{const i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];case"symbol":case"undefined":case"function":default:return o}},[]);if(n.length===r.length){const o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return lc(e,t)}var lc=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,o)=>N(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function dc(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ct[e.innerType._def.typeName],"null"]};const r=N(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function pc(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function fc(e,t){const r={type:"object",properties:{}},n=[],o=e.shape();for(const i in o){let a=o[i];if(a===void 0||a._def===void 0)continue;const c=mc(a),u=N(a._def,{...t,currentPath:[...t.currentPath,"properties",i],propertyPath:[...t.currentPath,"properties",i]});u!==void 0&&(r.properties[i]=u,c||n.push(i))}n.length&&(r.required=n);const s=hc(e,t);return s!==void 0&&(r.additionalProperties=s),r}function hc(e,t){if(e.catchall._def.typeName!=="ZodNever")return N(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function mc(e){try{return e.isOptional()}catch{return!0}}var gc=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return N(e.innerType._def,t);const n=N(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:W()},n]}:W()},vc=(e,t)=>{if(t.pipeStrategy==="input")return N(e.in._def,t);if(t.pipeStrategy==="output")return N(e.out._def,t);const r=N(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=N(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function _c(e,t){return N(e.type._def,t)}function yc(e,t){const n={type:"array",uniqueItems:!0,items:N(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function bc(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>N(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:N(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>N(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function wc(){return{not:W()}}function Ec(){return W()}var Ic=(e,t)=>N(e.innerType._def,t),Sc=(e,t,r)=>{switch(t){case I.ZodString:return $n(e,r);case I.ZodNumber:return pc(e);case I.ZodObject:return fc(e,r);case I.ZodBigInt:return qu(e);case I.ZodBoolean:return Yu();case I.ZodDate:return Zn(e,r);case I.ZodUndefined:return wc();case I.ZodNull:return uc();case I.ZodArray:return Wu(e,r);case I.ZodUnion:case I.ZodDiscriminatedUnion:return cc(e,r);case I.ZodIntersection:return tc(e,r);case I.ZodTuple:return bc(e,r);case I.ZodRecord:return Nn(e,r);case I.ZodLiteral:return rc(e);case I.ZodEnum:return Qu(e);case I.ZodNativeEnum:return ac(e);case I.ZodNullable:return dc(e,r);case I.ZodOptional:return gc(e,r);case I.ZodMap:return sc(e,r);case I.ZodSet:return yc(e,r);case I.ZodLazy:return()=>e.getter()._def;case I.ZodPromise:return _c(e,r);case I.ZodNaN:case I.ZodNever:return ic();case I.ZodEffects:return Ku(e,r);case I.ZodAny:return W();case I.ZodUnknown:return Ec();case I.ZodDefault:return Xu(e,r);case I.ZodBranded:return Tn(e,r);case I.ZodReadonly:return Ic(e,r);case I.ZodCatch:return Gu(e,r);case I.ZodPipeline:return vc(e,r);case I.ZodFunction:case I.ZodVoid:case I.ZodSymbol:return;default:return(n=>{})()}},kc=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function N(e,t,r=!1){var n;const o=t.seen.get(e);if(t.override){const c=(n=t.override)==null?void 0:n.call(t,e,t,o,r);if(c!==Vu)return c}if(o&&!r){const c=zc(o,t);if(c!==void 0)return c}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const i=Sc(e,e.typeName,t),a=typeof i=="function"?N(i(),t):i;if(a&&Oc(e,t,a),t.postProcess){const c=t.postProcess(a,e,t);return s.jsonSchema=a,c}return s.jsonSchema=a,a}var zc=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:kc(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)||t.$refStrategy==="seen"?W():void 0}},Oc=(e,t,r)=>(e.description&&(r.description=e.description),r),Tc=e=>{const t=Bu(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}},Zc=(e,t)=>{var r;const n=Tc(t);let o=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[l,d])=>{var m;return{...u,[l]:(m=N(d._def,{...n,currentPath:[...n.basePath,n.definitionPath,l]},!0))!=null?m:W()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,i=(r=N(e._def,s===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,s]},!1))!=null?r:W(),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(i.title=a);const c=s===void 0?o?{...i,[n.definitionPath]:o}:i:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,s].join("/"),[n.definitionPath]:{...o,[s]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},lt=Symbol.for("vercel.ai.schema");function $c(e){let t;return()=>(t==null&&(t=e()),t)}function Ke(e,{validate:t}={}){return{[lt]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function Nc(e){return typeof e=="object"&&e!==null&&lt in e&&e[lt]===!0&&"jsonSchema"in e&&"validate"in e}function St(e){return e==null?Ke({properties:{},additionalProperties:!1}):Nc(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?An(e):Ac(e):e()}function Ac(e){return Ke(()=>It(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const r=await e["~standard"].validate(t);return"value"in r?{success:!0,value:r.value}:{success:!1,error:new _e({value:t,cause:r.issues})}}})}function Pc(e,t){var r;const n=(r=void 0)!=null?r:!1;return Ke(()=>Zc(e,{$refStrategy:n?"root":"none"}),{validate:async o=>{const s=await e.safeParseAsync(o);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function Rc(e,t){var r;const n=(r=void 0)!=null?r:!1;return Ke(()=>It(_i(e,{target:"draft-7",io:"input",reused:n?"ref":"inline"})),{validate:async o=>{const s=await _n(e,o);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function Cc(e){return"_zod"in e}function An(e,t){return Cc(e)?Rc(e):Pc(e)}async function dr({value:e,schema:t,context:r}){const n=await Ne({value:e,schema:t,context:r});if(!n.success)throw _e.wrap({value:e,cause:n.error,context:r});return n.value}async function Ne({value:e,schema:t,context:r}){const n=St(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:_e.wrap({value:e,cause:o.error,context:r}),rawValue:e}}catch(o){return{success:!1,error:_e.wrap({value:e,cause:o,context:r}),rawValue:e}}}async function le({text:e,schema:t}){try{const r=Ju(e);return t==null?{success:!0,value:r,rawValue:r}:await Ne({value:r,schema:t})}catch(r){return{success:!1,error:At.isInstance(r)?r:new At({text:e,cause:r}),rawValue:void 0}}}function xc({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Mu).pipeThrough(new TransformStream({async transform({data:r},n){r!=="[DONE]"&&n.enqueue(await le({text:r,schema:t}))}}))}async function re(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var jc=Object.defineProperty,Mc=(e,t)=>{for(var r in t)jc(e,r,{get:t[r],enumerable:!0})},Pn="AI_NoObjectGeneratedError",Rn=`vercel.ai.error.${Pn}`,Dc=Symbol.for(Rn),Cn,ne=class extends Q{constructor({message:e="No object generated.",cause:t,text:r,response:n,usage:o,finishReason:s}){super({name:Pn,message:e,cause:t}),this[Cn]=!0,this.text=r,this.response=n,this.usage=o,this.finishReason=s}static isInstance(e){return Q.hasMarker(e,Rn)}};Cn=Dc;var xn="AI_UIMessageStreamError",jn=`vercel.ai.error.${xn}`,Uc=Symbol.for(jn),Mn,pe=class extends Q{constructor({chunkType:e,chunkId:t,message:r}){super({name:xn,message:r}),this[Mn]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Q.hasMarker(e,jn)}};Mn=Uc;var pr="6.0.97",Dn=J([g(),We(Uint8Array),We(ArrayBuffer),On(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]),Ae=Pu(()=>J([iu(),g(),nu(),F(),Ze(g(),Ae.optional()),Ee(Ae)])),z=Ze(g(),Ze(g(),Ae.optional())),Un=A({type:w("text"),text:g(),providerOptions:z.optional()}),Lc=A({type:w("image"),image:J([Dn,We(URL)]),mediaType:g().optional(),providerOptions:z.optional()}),Ln=A({type:w("file"),data:J([Dn,We(URL)]),filename:g().optional(),mediaType:g(),providerOptions:z.optional()}),Fc=A({type:w("reasoning"),text:g(),providerOptions:z.optional()}),Jc=A({type:w("tool-call"),toolCallId:g(),toolName:g(),input:K(),providerOptions:z.optional(),providerExecuted:F().optional()}),Vc=pu("type",[A({type:w("text"),value:g(),providerOptions:z.optional()}),A({type:w("json"),value:Ae,providerOptions:z.optional()}),A({type:w("execution-denied"),reason:g().optional(),providerOptions:z.optional()}),A({type:w("error-text"),value:g(),providerOptions:z.optional()}),A({type:w("error-json"),value:Ae,providerOptions:z.optional()}),A({type:w("content"),value:Ee(J([A({type:w("text"),text:g(),providerOptions:z.optional()}),A({type:w("media"),data:g(),mediaType:g()}),A({type:w("file-data"),data:g(),mediaType:g(),filename:g().optional(),providerOptions:z.optional()}),A({type:w("file-url"),url:g(),providerOptions:z.optional()}),A({type:w("file-id"),fileId:J([g(),Ze(g(),g())]),providerOptions:z.optional()}),A({type:w("image-data"),data:g(),mediaType:g(),providerOptions:z.optional()}),A({type:w("image-url"),url:g(),providerOptions:z.optional()}),A({type:w("image-file-id"),fileId:J([g(),Ze(g(),g())]),providerOptions:z.optional()}),A({type:w("custom"),providerOptions:z.optional()})]))})]),Fn=A({type:w("tool-result"),toolCallId:g(),toolName:g(),output:Vc,providerOptions:z.optional()}),Bc=A({type:w("tool-approval-request"),approvalId:g(),toolCallId:g()}),Wc=A({type:w("tool-approval-response"),approvalId:g(),approved:F(),reason:g().optional()}),qc=A({role:w("system"),content:g(),providerOptions:z.optional()}),Yc=A({role:w("user"),content:J([g(),Ee(J([Un,Lc,Ln]))]),providerOptions:z.optional()}),Gc=A({role:w("assistant"),content:J([g(),Ee(J([Un,Ln,Fc,Jc,Fn,Bc]))]),providerOptions:z.optional()}),Hc=A({role:w("tool"),content:Ee(J([Fn,Wc])),providerOptions:z.optional()});J([qc,Yc,Gc,Hc]);function Jn(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const o=t[n];if(o===void 0)continue;const s=n in e?e[n]:void 0,i=o!==null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);i&&a?r[n]=Jn(s,o):r[n]=o}return r}var Xc={};Mc(Xc,{array:()=>tl,choice:()=>rl,json:()=>nl,object:()=>el,text:()=>Qc});function Kc(e){const t=["ROOT"];let r=-1,n=null;function o(c,u,l){switch(c){case'"':{r=u,t.pop(),t.push(l),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,n=u,t.pop(),t.push(l),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(l),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=u,t.pop(),t.push(l),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(l),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(l),t.push("INSIDE_ARRAY_START");break}}}function s(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function i(c,u){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let c=0;c<e.length;c++){const u=e[c];switch(t[t.length-1]){case"ROOT":o(u,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=c,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{o(u,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(u,c);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=c;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=c}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=c,t.pop();break}default:{r=c,o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=c,t.pop();break}default:{r=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{o(u,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=c;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(u,c);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(n,c+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(u,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(u,c)):r=c;break}}}let a=e.slice(0,r+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{a+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const l=e.substring(n,e.length);"true".startsWith(l)?a+="true".slice(l.length):"false".startsWith(l)?a+="false".slice(l.length):"null".startsWith(l)&&(a+="null".slice(l.length))}}return a}async function Re(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await le({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await le({text:Kc(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Qc=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),el=({schema:e,name:t,description:r})=>{const n=St(e);return{name:"object",responseFormat:re(n.jsonSchema).then(o=>({type:"json",schema:o,...t!=null&&{name:t},...r!=null&&{description:r}})),async parseCompleteOutput({text:o},s){const i=await le({text:o});if(!i.success)throw new ne({message:"No object generated: could not parse the response.",cause:i.error,text:o,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=await Ne({value:i.value,schema:n});if(!a.success)throw new ne({message:"No object generated: response did not match schema.",cause:a.error,text:o,response:s.response,usage:s.usage,finishReason:s.finishReason});return a.value},async parsePartialOutput({text:o}){const s=await Re(o);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},tl=({element:e,name:t,description:r})=>{const n=St(e);return{name:"array",responseFormat:re(n.jsonSchema).then(o=>{const{$schema:s,...i}=o;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...r!=null&&{description:r}}}),async parseCompleteOutput({text:o},s){const i=await le({text:o});if(!i.success)throw new ne({message:"No object generated: could not parse the response.",cause:i.error,text:o,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=i.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))throw new ne({message:"No object generated: response did not match schema.",cause:new _e({value:a,cause:"response must be an object with an elements array"}),text:o,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const c of a.elements){const u=await Ne({value:c,schema:n});if(!u.success)throw new ne({message:"No object generated: response did not match schema.",cause:u.error,text:o,response:s.response,usage:s.usage,finishReason:s.finishReason})}return a.elements},async parsePartialOutput({text:o}){const s=await Re(o);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=s.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const a=s.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const u of a){const l=await Ne({value:u,schema:n});l.success&&c.push(l.value)}return{partial:c}}}},createElementStreamTransform(){let o=0;return new TransformStream({transform({partialOutput:s},i){if(s!=null)for(;o<s.length;o++)i.enqueue(s[o])}})}}},rl=({options:e,name:t,description:r})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...r!=null&&{description:r}}),async parseCompleteOutput({text:n},o){const s=await le({text:n});if(!s.success)throw new ne({message:"No object generated: could not parse the response.",cause:s.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=s.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!e.includes(i.result))throw new ne({message:"No object generated: response did not match schema.",cause:new _e({value:i,cause:"response must be an object that contains a choice value."}),text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.result},async parsePartialOutput({text:n}){const o=await Re(n);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=o.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const i=e.filter(a=>a.startsWith(s.result));return o.state==="successful-parse"?i.includes(s.result)?{partial:s.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),nl=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:r},n){const o=await le({text:r});if(!o.success)throw new ne({message:"No object generated: could not parse the response.",cause:o.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});return o.value},async parsePartialOutput({text:r}){const n=await Re(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return n.value===void 0?void 0:{partial:n.value}}},createElementStreamTransform(){}});Pe({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
50
+
51
+ `)},flush(e){e.enqueue(`data: [DONE]
52
+
53
+ `)}})}});var ol=$c(()=>An(J([R({type:w("text-start"),id:g(),providerMetadata:z.optional()}),R({type:w("text-delta"),id:g(),delta:g(),providerMetadata:z.optional()}),R({type:w("text-end"),id:g(),providerMetadata:z.optional()}),R({type:w("error"),errorText:g()}),R({type:w("tool-input-start"),toolCallId:g(),toolName:g(),providerExecuted:F().optional(),providerMetadata:z.optional(),dynamic:F().optional(),title:g().optional()}),R({type:w("tool-input-delta"),toolCallId:g(),inputTextDelta:g()}),R({type:w("tool-input-available"),toolCallId:g(),toolName:g(),input:K(),providerExecuted:F().optional(),providerMetadata:z.optional(),dynamic:F().optional(),title:g().optional()}),R({type:w("tool-input-error"),toolCallId:g(),toolName:g(),input:K(),providerExecuted:F().optional(),providerMetadata:z.optional(),dynamic:F().optional(),errorText:g(),title:g().optional()}),R({type:w("tool-approval-request"),approvalId:g(),toolCallId:g()}),R({type:w("tool-output-available"),toolCallId:g(),output:K(),providerExecuted:F().optional(),dynamic:F().optional(),preliminary:F().optional()}),R({type:w("tool-output-error"),toolCallId:g(),errorText:g(),providerExecuted:F().optional(),dynamic:F().optional()}),R({type:w("tool-output-denied"),toolCallId:g()}),R({type:w("reasoning-start"),id:g(),providerMetadata:z.optional()}),R({type:w("reasoning-delta"),id:g(),delta:g(),providerMetadata:z.optional()}),R({type:w("reasoning-end"),id:g(),providerMetadata:z.optional()}),R({type:w("source-url"),sourceId:g(),url:g(),title:g().optional(),providerMetadata:z.optional()}),R({type:w("source-document"),sourceId:g(),mediaType:g(),title:g(),filename:g().optional(),providerMetadata:z.optional()}),R({type:w("file"),url:g(),mediaType:g(),providerMetadata:z.optional()}),R({type:On(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:g().optional(),data:K(),transient:F().optional()}),R({type:w("start-step")}),R({type:w("finish-step")}),R({type:w("start"),messageId:g().optional(),messageMetadata:K().optional()}),R({type:w("finish"),finishReason:Sn(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:K().optional()}),R({type:w("abort"),reason:g().optional()}),R({type:w("message-metadata"),messageMetadata:K()})])));function sl(e){return e.type.startsWith("data-")}function dt(e){return e.type.startsWith("tool-")}function al(e){return e.type==="dynamic-tool"}function pt(e){return dt(e)||al(e)}function fr(e){return e.type.split("-").slice(1).join("-")}function il({lastMessage:e,messageId:t}){return{message:(e==null?void 0:e.role)==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function ul({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:n,onError:o,onToolCall:s,onData:i}){return e.pipeThrough(new TransformStream({async transform(a,c){await n(async({state:u,write:l})=>{var d,m,h,_;function v(f){const T=u.message.parts.filter(pt).find(k=>k.toolCallId===f);if(T==null)throw new pe({chunkType:"tool-invocation",chunkId:f,message:`No tool invocation found for tool call ID "${f}".`});return T}function b(f){var $;const T=u.message.parts.find(V=>dt(V)&&V.toolCallId===f.toolCallId),k=f,Z=T;T!=null?(T.state=f.state,Z.input=k.input,Z.output=k.output,Z.errorText=k.errorText,Z.rawInput=k.rawInput,Z.preliminary=k.preliminary,f.title!==void 0&&(Z.title=f.title),Z.providerExecuted=($=k.providerExecuted)!=null?$:T.providerExecuted,k.providerMetadata!=null&&(T.callProviderMetadata=k.providerMetadata)):u.message.parts.push({type:`tool-${f.toolName}`,toolCallId:f.toolCallId,state:f.state,title:f.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null?{callProviderMetadata:k.providerMetadata}:{}})}function E(f){var $,T;const k=u.message.parts.find(kt=>kt.type==="dynamic-tool"&&kt.toolCallId===f.toolCallId),Z=f,V=k;k!=null?(k.state=f.state,V.toolName=f.toolName,V.input=Z.input,V.output=Z.output,V.errorText=Z.errorText,V.rawInput=($=Z.rawInput)!=null?$:V.rawInput,V.preliminary=Z.preliminary,f.title!==void 0&&(V.title=f.title),V.providerExecuted=(T=Z.providerExecuted)!=null?T:k.providerExecuted,Z.providerMetadata!=null&&(k.callProviderMetadata=Z.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:f.toolName,toolCallId:f.toolCallId,state:f.state,input:Z.input,output:Z.output,errorText:Z.errorText,preliminary:Z.preliminary,providerExecuted:Z.providerExecuted,title:f.title,...Z.providerMetadata!=null?{callProviderMetadata:Z.providerMetadata}:{}})}async function S(f){if(f!=null){const $=u.message.metadata!=null?Jn(u.message.metadata,f):f;t!=null&&await dr({value:$,schema:t,context:{field:"message.metadata",entityId:u.message.id}}),u.message.metadata=$}}switch(a.type){case"text-start":{const f={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeTextParts[a.id]=f,u.message.parts.push(f),l();break}case"text-delta":{const f=u.activeTextParts[a.id];if(f==null)throw new pe({chunkType:"text-delta",chunkId:a.id,message:`Received text-delta for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});f.text+=a.delta,f.providerMetadata=(d=a.providerMetadata)!=null?d:f.providerMetadata,l();break}case"text-end":{const f=u.activeTextParts[a.id];if(f==null)throw new pe({chunkType:"text-end",chunkId:a.id,message:`Received text-end for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});f.state="done",f.providerMetadata=(m=a.providerMetadata)!=null?m:f.providerMetadata,delete u.activeTextParts[a.id],l();break}case"reasoning-start":{const f={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};u.activeReasoningParts[a.id]=f,u.message.parts.push(f),l();break}case"reasoning-delta":{const f=u.activeReasoningParts[a.id];if(f==null)throw new pe({chunkType:"reasoning-delta",chunkId:a.id,message:`Received reasoning-delta for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});f.text+=a.delta,f.providerMetadata=(h=a.providerMetadata)!=null?h:f.providerMetadata,l();break}case"reasoning-end":{const f=u.activeReasoningParts[a.id];if(f==null)throw new pe({chunkType:"reasoning-end",chunkId:a.id,message:`Received reasoning-end for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});f.providerMetadata=(_=a.providerMetadata)!=null?_:f.providerMetadata,f.state="done",delete u.activeReasoningParts[a.id],l();break}case"file":{u.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url}),l();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),l();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),l();break}case"tool-input-start":{const f=u.message.parts.filter(dt);u.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:f.length,dynamic:a.dynamic,title:a.title},a.dynamic?E({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}):b({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}),l();break}case"tool-input-delta":{const f=u.partialToolCalls[a.toolCallId];if(f==null)throw new pe({chunkType:"tool-input-delta",chunkId:a.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${a.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});f.text+=a.inputTextDelta;const{value:$}=await Re(f.text);f.dynamic?E({toolCallId:a.toolCallId,toolName:f.toolName,state:"input-streaming",input:$,title:f.title}):b({toolCallId:a.toolCallId,toolName:f.toolName,state:"input-streaming",input:$,title:f.title}),l();break}case"tool-input-available":{a.dynamic?E({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}):b({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}),l(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{a.dynamic?E({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):b({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),l();break}case"tool-approval-request":{const f=v(a.toolCallId);f.state="approval-requested",f.approval={id:a.approvalId},l();break}case"tool-output-denied":{const f=v(a.toolCallId);f.state="output-denied",l();break}case"tool-output-available":{const f=v(a.toolCallId);f.type==="dynamic-tool"?E({toolCallId:a.toolCallId,toolName:f.toolName,state:"output-available",input:f.input,output:a.output,preliminary:a.preliminary,providerExecuted:a.providerExecuted,title:f.title}):b({toolCallId:a.toolCallId,toolName:fr(f),state:"output-available",input:f.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary,title:f.title}),l();break}case"tool-output-error":{const f=v(a.toolCallId);f.type==="dynamic-tool"?E({toolCallId:a.toolCallId,toolName:f.toolName,state:"output-error",input:f.input,errorText:a.errorText,providerExecuted:a.providerExecuted,title:f.title}):b({toolCallId:a.toolCallId,toolName:fr(f),state:"output-error",input:f.input,rawInput:f.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted,title:f.title}),l();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{a.messageId!=null&&(u.message.id=a.messageId),await S(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&l();break}case"finish":{a.finishReason!=null&&(u.finishReason=a.finishReason),await S(a.messageMetadata),a.messageMetadata!=null&&l();break}case"message-metadata":{await S(a.messageMetadata),a.messageMetadata!=null&&l();break}case"error":{o==null||o(new Error(a.errorText));break}default:if(sl(a)){if((r==null?void 0:r[a.type])!=null){const T=u.message.parts.findIndex(Z=>"id"in Z&&"data"in Z&&Z.id===a.id&&Z.type===a.type),k=T>=0?T:u.message.parts.length;await dr({value:a.data,schema:r[a.type],context:{field:`message.parts[${k}].data`,entityName:a.type,entityId:a.id}})}const f=a;if(f.transient){i==null||i(f);break}const $=f.id!=null?u.message.parts.find(T=>f.type===T.type&&f.id===T.id):void 0;$!=null?$.data=f.data:u.message.parts.push(f),i==null||i(f),l()}}c.enqueue(a)})}}))}async function cl({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:n}=await r.read();if(n)break}}catch(n){t==null||t(n)}finally{r.releaseLock()}}Pe({prefix:"aitxt",size:24});Pe({prefix:"aiobj",size:24});var ll=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,r)=>{this.queue.push(async()=>{try{await e(),t()}catch(n){r(n)}}),this.processQueue()})}};Pe({prefix:"aiobj",size:24});async function dl(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:r,type:n}=t,o=await new Promise((s,i)=>{const a=new FileReader;a.onload=c=>{var u;s((u=c.target)==null?void 0:u.result)},a.onerror=c=>i(c),a.readAsDataURL(t)});return{type:"file",mediaType:n,filename:r,url:o}}))}var Vn=class{constructor({api:e="/api/chat",credentials:t,headers:r,body:n,fetch:o,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:i}){this.api=e,this.credentials=t,this.headers=r,this.body=n,this.fetch=o,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:e,...t}){var r,n,o,s,i;const a=await re(this.body),c=await re(this.headers),u=await re(this.credentials),l={...ce(c),...ce(t.headers)},d=await((r=this.prepareSendMessagesRequest)==null?void 0:r.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:l,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),m=(n=d==null?void 0:d.api)!=null?n:this.api,h=(d==null?void 0:d.headers)!==void 0?ce(d.headers):l,_=(d==null?void 0:d.body)!==void 0?d.body:{...a,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},v=(o=d==null?void 0:d.credentials)!=null?o:u,E=await((s=this.fetch)!=null?s:globalThis.fetch)(m,{method:"POST",headers:ir({"Content-Type":"application/json",...h},`ai-sdk/${pr}`,ar()),body:JSON.stringify(_),credentials:v,signal:e});if(!E.ok)throw new Error((i=await E.text())!=null?i:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(e){var t,r,n,o,s;const i=await re(this.body),a=await re(this.headers),c=await re(this.credentials),u={...ce(a),...ce(e.headers)},l=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...i,...e.body},headers:u,credentials:c,requestMetadata:e.metadata})),d=(r=l==null?void 0:l.api)!=null?r:`${this.api}/${e.chatId}/stream`,m=(l==null?void 0:l.headers)!==void 0?ce(l.headers):u,h=(n=l==null?void 0:l.credentials)!=null?n:c,v=await((o=this.fetch)!=null?o:globalThis.fetch)(d,{method:"GET",headers:ir(m,`ai-sdk/${pr}`,ar()),credentials:h});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},pl=class extends Vn{constructor(e={}){super(e)}processResponseStream(e){return xc({stream:e,schema:ol}).pipeThrough(new TransformStream({async transform(t,r){if(!t.success)throw t.error;r.enqueue(t.value)}}))}},fl=class{constructor({generateId:e=Du,id:t=e(),transport:r=new pl,messageMetadataSchema:n,dataPartSchemas:o,state:s,onError:i,onToolCall:a,onFinish:c,onData:u,sendAutomaticallyWhen:l}){this.activeResponse=void 0,this.jobExecutor=new ll,this.sendMessage=async(d,m)=>{var h,_,v,b;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...m});return}let E;if("text"in d||"files"in d?E={parts:[...Array.isArray(d.files)?d.files:await dl(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:E=d,d.messageId!=null){const S=this.state.messages.findIndex(f=>f.id===d.messageId);if(S===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[S].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,S+1),this.state.replaceMessage(S,{...E,id:d.messageId,role:(_=E.role)!=null?_:"user",metadata:d.metadata})}else this.state.pushMessage({...E,id:(v=E.id)!=null?v:this.generateId(),role:(b=E.role)!=null?b:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...m})},this.regenerate=async({messageId:d,...m}={})=>{const h=d==null?this.state.messages.length-1:this.state.messages.findIndex(_=>_.id===d);if(h===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...m})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:m,reason:h})=>this.jobExecutor.run(async()=>{const _=this.state.messages,v=_[_.length-1],b=E=>pt(E)&&E.state==="approval-requested"&&E.approval.id===d?{...E,state:"approval-responded",approval:{id:d,approved:m,reason:h}}:E;this.state.replaceMessage(_.length-1,{...v,parts:v.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(E=>{var S;E&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id})})}),this.addToolOutput=async({state:d="output-available",tool:m,toolCallId:h,output:_,errorText:v})=>this.jobExecutor.run(async()=>{const b=this.state.messages,E=b[b.length-1],S=f=>pt(f)&&f.toolCallId===h?{...f,state:d,output:_,errorText:v}:f;this.state.replaceMessage(b.length-1,{...E,parts:E.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(f=>{var $;f&&this.makeRequest({trigger:"submit-message",messageId:($=this.lastMessage)==null?void 0:$.id})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=r,this.generateId=e,this.messageMetadataSchema=n,this.dataPartSchemas=o,this.state=s,this.onError=i,this.onToolCall=a,this.onFinish=c,this.onData=u,this.sendAutomaticallyWhen=l}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:r,body:n,messageId:o}){var s,i,a;let c;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:r,body:n});if(h==null)return;c=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let l=!1,d=!1,m=!1;try{const h={state:il({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{l=!0}),this.activeResponse=h;let _;e==="resume-stream"?_=c:_=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:t,headers:r,body:n,trigger:e,messageId:o});const v=b=>this.jobExecutor.run(()=>b({state:h.state,write:()=>{var E;this.setStatus({status:"streaming"}),h.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await cl({stream:ul({stream:_,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:b=>{throw b}}),onError:b=>{throw b}}),this.setStatus({status:"ready"})}catch(h){if(l||h.name==="AbortError")return l=!0,this.setStatus({status:"ready"}),null;m=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:l,isDisconnect:d,isError:m,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch{}this.activeResponse=void 0}!m&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(a=this.lastMessage)==null?void 0:a.id,metadata:t,headers:r,body:n})}};function hl({stream:e}){return e.pipeThrough(new TransformStream({start(t){t.enqueue({type:"start"}),t.enqueue({type:"start-step"}),t.enqueue({type:"text-start",id:"text-1"})},async transform(t,r){r.enqueue({type:"text-delta",id:"text-1",delta:t})},async flush(t){t.enqueue({type:"text-end",id:"text-1"}),t.enqueue({type:"finish-step"}),t.enqueue({type:"finish"})}}))}var wl=class extends Vn{constructor(e={}){super(e)}processResponseStream(e){return hl({stream:e.pipeThrough(new TextDecoderStream)})}},ot,hr;function ml(){if(hr)return ot;hr=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let n,o=0;return function(...i){clearTimeout(n);const a=Date.now(),c=a-o,u=r-c;u<=0?(o=a,t.apply(this,i)):n=setTimeout(()=>{o=Date.now(),t.apply(this,i)},u)}}return ot=e,ot}var gl=ml();const vl=Wn(gl);var Bn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},C=(e,t,r)=>(Bn(e,t,"read from private field"),r?r.call(e):t.get(e)),X=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},te=(e,t,r,n)=>(Bn(e,t,"write to private field"),t.set(e,r),r);function _l(e,t){return t!=null?vl(e,t):e}var q,Me,De,Se,ke,ze,fe,ft,ht,yl=class{constructor(e=[]){X(this,q,void 0),X(this,Me,"ready"),X(this,De,void 0),X(this,Se,new Set),X(this,ke,new Set),X(this,ze,new Set),this.pushMessage=t=>{te(this,q,C(this,q).concat(t)),C(this,fe).call(this)},this.popMessage=()=>{te(this,q,C(this,q).slice(0,-1)),C(this,fe).call(this)},this.replaceMessage=(t,r)=>{te(this,q,[...C(this,q).slice(0,t),this.snapshot(r),...C(this,q).slice(t+1)]),C(this,fe).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{const n=r?_l(t,r):t;return C(this,Se).add(n),()=>{C(this,Se).delete(n)}},this["~registerStatusCallback"]=t=>(C(this,ke).add(t),()=>{C(this,ke).delete(t)}),this["~registerErrorCallback"]=t=>(C(this,ze).add(t),()=>{C(this,ze).delete(t)}),X(this,fe,()=>{C(this,Se).forEach(t=>t())}),X(this,ft,()=>{C(this,ke).forEach(t=>t())}),X(this,ht,()=>{C(this,ze).forEach(t=>t())}),te(this,q,e)}get status(){return C(this,Me)}set status(e){te(this,Me,e),C(this,ft).call(this)}get error(){return C(this,De)}set error(e){te(this,De,e),C(this,ht).call(this)}get messages(){return C(this,q)}set messages(e){te(this,q,[...e]),C(this,fe).call(this)}};q=new WeakMap;Me=new WeakMap;De=new WeakMap;Se=new WeakMap;ke=new WeakMap;ze=new WeakMap;fe=new WeakMap;ft=new WeakMap;ht=new WeakMap;var he,mr=class extends fl{constructor({messages:e,...t}){const r=new yl(e);super({...t,state:r}),X(this,he,void 0),this["~registerMessagesCallback"]=(n,o)=>C(this,he)["~registerMessagesCallback"](n,o),this["~registerStatusCallback"]=n=>C(this,he)["~registerStatusCallback"](n),this["~registerErrorCallback"]=n=>C(this,he)["~registerErrorCallback"](n),te(this,he,r)}};he=new WeakMap;function El({experimental_throttle:e,resume:t=!1,...r}={}){const n=ee.useRef("chat"in r?{}:{onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});"chat"in r||(n.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});const o={...r,onToolCall:m=>{var h,_;return(_=(h=n.current).onToolCall)==null?void 0:_.call(h,m)},onData:m=>{var h,_;return(_=(h=n.current).onData)==null?void 0:_.call(h,m)},onFinish:m=>{var h,_;return(_=(h=n.current).onFinish)==null?void 0:_.call(h,m)},onError:m=>{var h,_;return(_=(h=n.current).onError)==null?void 0:_.call(h,m)},sendAutomaticallyWhen:m=>{var h,_,v;return(v=(_=(h=n.current).sendAutomaticallyWhen)==null?void 0:_.call(h,m))!=null?v:!1}},s=ee.useRef("chat"in r?r.chat:new mr(o));("chat"in r&&r.chat!==s.current||"id"in r&&s.current.id!==r.id)&&(s.current="chat"in r?r.chat:new mr(o));const a=ee.useCallback(m=>s.current["~registerMessagesCallback"](m,e),[e,s.current.id]),c=ee.useSyncExternalStore(a,()=>s.current.messages,()=>s.current.messages),u=ee.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),l=ee.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=ee.useCallback(m=>{typeof m=="function"&&(m=m(s.current.messages)),s.current.messages=m},[s]);return ee.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:c,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:l,resumeStream:s.current.resumeStream,status:u,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}export{wl as T,El as u};