@arcgis/ai-components 5.1.0-next.99 → 5.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agent-utils/BaseAgent.d.ts +90 -0
- package/dist/agent-utils/BaseAgent.js +87 -0
- package/dist/agent-utils/FunctionAgent.d.ts +64 -0
- package/dist/agent-utils/FunctionAgent.js +98 -0
- package/dist/agent-utils/LLMAgent.d.ts +65 -0
- package/dist/agent-utils/LLMAgent.js +139 -0
- package/dist/agent-utils/WorkflowAgent.d.ts +44 -0
- package/dist/agent-utils/WorkflowAgent.js +70 -0
- package/dist/agent-utils/middlewares/humanInTheLoop.d.ts +152 -0
- package/dist/agent-utils/middlewares/humanInTheLoop.js +94 -0
- package/dist/agent-utils/middlewares/middleware.d.ts +25 -0
- package/dist/agent-utils/middlewares/middleware.js +44 -0
- package/dist/agent-utils/middlewares/trace.d.ts +25 -0
- package/dist/agent-utils/middlewares/trace.js +50 -0
- package/dist/agent-utils/middlewares/types.d.ts +123 -0
- package/dist/agent-utils/middlewares/types.js +2 -0
- package/dist/agent-utils/tools/FunctionTool.d.ts +127 -0
- package/dist/agent-utils/tools/FunctionTool.js +80 -0
- package/dist/agent-utils/types.d.ts +152 -0
- package/dist/agent-utils/workflows/BaseWorkflow.d.ts +87 -0
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +72 -0
- package/dist/agent-utils/workflows/ConditionalWorkflow.js +61 -0
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +58 -0
- package/dist/agent-utils/workflows/LoopWorkflow.js +56 -0
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +68 -0
- package/dist/agent-utils/workflows/ParallelWorkflow.js +129 -0
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +63 -0
- package/dist/agent-utils/workflows/RouterWorkflow.js +75 -0
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +56 -0
- package/dist/agent-utils/workflows/SequentialWorkflow.js +69 -0
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +74 -0
- package/dist/agent-utils/workflows/SwitchWorkflow.js +84 -0
- package/dist/assets/embeddings.worker-k9_Ou679.js +1 -0
- package/dist/cdn/{24MYCR6F.js → 23EQTPO3.js} +2 -2
- package/dist/cdn/{Z3DVGFEE.js → 2AXF774U.js} +2 -2
- package/dist/cdn/{UK6CP7BR.js → 3PKJWIC3.js} +2 -2
- package/dist/cdn/462JBSEV.js +422 -0
- package/dist/cdn/5QAHYX7Y.js +5 -0
- package/dist/cdn/{YVTKUITE.js → 5ZZGKP7N.js} +2 -2
- package/dist/cdn/{VHOF6SUZ.js → 6MAINSY5.js} +4 -3
- package/dist/cdn/6R6AY3D3.js +42 -0
- package/dist/cdn/{DMLSCJAM.js → 6YMR4QSD.js} +2 -2
- package/dist/cdn/{LXFCO34K.js → 7BCR6TUO.js} +2 -2
- package/dist/cdn/{EUNEQNYC.js → 7GH7VSB2.js} +1 -1
- package/dist/cdn/{YNJYG2RG.js → 7PLV4QH6.js} +2 -2
- package/dist/cdn/{JDL3HFFX.js → 7RCQFLPP.js} +2 -2
- package/dist/cdn/AMP6IALT.js +2 -0
- package/dist/cdn/{Y3AUHNRX.js → AO7BQHKC.js} +2 -2
- package/dist/cdn/{K6LVZHWM.js → AXDZBBNL.js} +2 -2
- package/dist/cdn/{WBRZZ4FB.js → DDLZOMUY.js} +2 -2
- package/dist/cdn/DHOVCT6R.js +2 -0
- package/dist/cdn/EF453FJ2.js +3 -0
- package/dist/cdn/{ESTSYVJP.js → F2AHA4GB.js} +2 -2
- package/dist/cdn/FB5DRKEB.js +14 -0
- package/dist/cdn/FX5JFRDL.js +2 -0
- package/dist/cdn/{CFT5BBC6.js → FX7UOGHP.js} +2 -2
- package/dist/cdn/{5PT7ZFXF.js → GM3QP65I.js} +2 -2
- package/dist/cdn/H7422XUG.js +2 -0
- package/dist/cdn/HB5A5R2E.js +2 -0
- package/dist/cdn/{LSGRWCAO.js → KMQ3SP4I.js} +2 -2
- package/dist/cdn/{7EXACS27.js → LBVX2JYG.js} +2 -2
- package/dist/cdn/{MZJGADGH.js → LQ6R5YRN.js} +2 -2
- package/dist/cdn/METXWS7V.js +166 -0
- package/dist/cdn/{3QC3BRZP.js → MH5RPXHM.js} +2 -2
- package/dist/cdn/N2VQD46V.js +106 -0
- package/dist/cdn/{54ATSQPS.js → NAUXSHIE.js} +18 -18
- package/dist/cdn/{SFREIREB.js → NE7E52YR.js} +2 -2
- package/dist/cdn/{2YEKZADB.js → NVI3I46B.js} +2 -2
- package/dist/cdn/{YGW7TUNX.js → OAVEHGB6.js} +1 -1
- package/dist/cdn/{DSEMD4M2.js → OH64RMOR.js} +3 -3
- package/dist/cdn/{PTGKT5P6.js → P6OPJQMC.js} +2 -2
- package/dist/cdn/QDO2AO53.js +36 -0
- package/dist/cdn/{TRDKA5Y6.js → QR54T33D.js} +2 -2
- package/dist/cdn/{457RLS3H.js → RVOAPUBN.js} +2 -2
- package/dist/cdn/{5JBT3YNY.js → SXDLXCIM.js} +2 -2
- package/dist/cdn/SZOVY2QU.js +2 -0
- package/dist/cdn/U3QQW6VA.js +16 -0
- package/dist/cdn/{G4SVCCJH.js → USMDJUFS.js} +2 -2
- package/dist/cdn/{Q5D5LJS5.js → V2P4AIGG.js} +2 -2
- package/dist/cdn/Y333DGV6.js +2 -0
- package/dist/cdn/Y67XAMT4.js +22 -0
- package/dist/cdn/{CFDTXKJ6.js → YIMNOUTF.js} +1 -1
- package/dist/cdn/ZS2TZ6BF.js +31 -0
- package/dist/cdn/{W5CHGOOR.js → ZTBA5PM7.js} +2 -2
- package/dist/cdn/assets/assistant/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/index.js +2 -2
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/BaseWorkflow.js +107 -0
- package/dist/chunks/adapter.js +2964 -0
- package/dist/chunks/arcgisKnowledgeGraph.js +174 -0
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +8 -0
- package/dist/chunks/arcgis_knowledge_current_map_context.js +8 -0
- package/dist/chunks/arcgis_knowledge_lucene_generation_prompt.js +101 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +48 -0
- package/dist/chunks/arcgis_knowledge_tool_prompt.js +34 -0
- package/dist/chunks/converterUtils.js +1 -1
- package/dist/chunks/dataExplorationGraph.js +289 -0
- package/dist/chunks/data_explore_filter_prompt.js +125 -0
- package/dist/chunks/data_explore_query_prompt.js +131 -0
- package/dist/chunks/embeddings.worker.js +25 -0
- package/dist/chunks/field_descriptions_prompt.js +112 -0
- package/dist/chunks/generateLayerDescriptions.js +413 -0
- package/dist/chunks/graph.js +86 -0
- package/dist/chunks/helpGraph.js +123 -0
- package/dist/chunks/help_prompt.js +57 -0
- package/dist/chunks/intent_prompt.js +124 -0
- package/dist/chunks/layerStylingGraph.js +189 -0
- package/dist/chunks/layer_descriptions_prompt.js +59 -0
- package/dist/chunks/layer_styling_prompt.js +72 -0
- package/dist/chunks/navigationGraph.js +266 -0
- package/dist/chunks/navigation_intent_prompt.js +46 -0
- package/dist/chunks/navigation_tool_prompt.js +39 -0
- package/dist/chunks/orchestrator.js +528 -0
- package/dist/chunks/runtime.js +2 -2
- package/dist/chunks/slottableRequestUtils.js +1 -1
- package/dist/chunks/state.js +71 -0
- package/dist/chunks/summarize_query_response_prompt.js +77 -0
- package/dist/chunks/toolCallResponse.js +29 -0
- package/dist/chunks/useT9n.js +1 -1
- package/dist/chunks/utils.js +47 -29
- package/dist/chunks/utils2.js +42 -7
- package/dist/chunks/utils3.js +16 -0
- package/dist/components/arcgis-assistant/customElement.d.ts +60 -8
- package/dist/components/arcgis-assistant/customElement.js +32 -24
- package/dist/components/arcgis-assistant/types.d.ts +1 -1
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +2 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +1 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +1 -1
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +25 -9
- package/dist/components/arcgis-assistant-help-agent/customElement.js +28 -9
- package/dist/components/arcgis-assistant-interrupt/customElement.js +8 -12
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +158 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +68 -0
- package/dist/components/arcgis-assistant-knowledge-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +28 -9
- package/dist/components/arcgis-assistant-message/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-feedback/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-log/customElement.js +1 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.js +24 -28
- package/dist/components/arcgis-assistant-message-text/customElement.js +1 -1
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +26 -8
- package/dist/components/arcgis-assistant-speech-input/customElement.js +1 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +1 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/loader.js +2 -1
- package/dist/types/lumina.d.ts +6 -1
- package/dist/types/preact.d.ts +7 -1
- package/dist/types/react.d.ts +8 -1
- package/dist/types/stencil.d.ts +6 -1
- package/dist/utils/index.d.ts +203 -9
- package/dist/utils/index.js +109 -11
- package/package.json +26 -11
- package/dist/cdn/4QVKWA2Z.js +0 -24
- package/dist/cdn/5L7OZ37N.js +0 -2
- package/dist/cdn/6ALN3KMA.js +0 -269
- package/dist/cdn/ARCP5UZY.js +0 -2
- package/dist/cdn/B4DEC7PH.js +0 -2
- package/dist/cdn/D7WNBUVK.js +0 -106
- package/dist/cdn/GER6EQYH.js +0 -2
- package/dist/cdn/KVH3PDVW.js +0 -2
- package/dist/cdn/O62HTIOD.js +0 -2
- package/dist/cdn/R5FWFRWW.js +0 -2
- package/dist/cdn/SZBOIYZZ.js +0 -2
- package/dist/cdn/WNDUCHXU.js +0 -2
- package/dist/cdn/YW52XJMM.js +0 -396
- package/dist/cdn/ZLO73NU6.js +0 -2
- package/dist/cdn/ZPNJGIAF.js +0 -2
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{a as vn,b as bn,c as pa}from"./YIMNOUTF.js";var cS=vn((q9,sS)=>{"use strict";sS.exports=function(e,t){if(typeof e!="string")throw new TypeError("Expected a string");return t=typeof t>"u"?"_":t,e.replace(/([a-z\d])([A-Z])/g,"$1"+t+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+t+"$2").toLowerCase()}});var hS=vn((X9,mh)=>{"use strict";var KR=/[\p{Lu}]/u,WR=/[\p{Ll}]/u,uS=/^[\p{Lu}](?![\p{Lu}])/gu,fS=/([\p{Alpha}\p{N}_]|$)/u,pS=/[_.\- ]+/,qR=new RegExp("^"+pS.source),lS=new RegExp(pS.source+fS.source,"gu"),dS=new RegExp("\\d+"+fS.source,"gu"),XR=(e,t,r)=>{let i=!1,n=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];i&&KR.test(s)?(e=e.slice(0,o)+"-"+e.slice(o),i=!1,a=n,n=!0,o++):n&&a&&WR.test(s)?(e=e.slice(0,o-1)+"-"+e.slice(o-1),a=n,n=!1,i=!0):(i=t(s)===s&&r(s)!==s,a=n,n=r(s)===s&&t(s)!==s)}return e},YR=(e,t)=>(uS.lastIndex=0,e.replace(uS,r=>t(r))),QR=(e,t)=>(lS.lastIndex=0,dS.lastIndex=0,e.replace(lS,(r,i)=>t(i)).replace(dS,r=>t(r))),mS=(e,t)=>{if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(a=>a.trim()).filter(a=>a.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),i=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return e.length===1?t.pascalCase?i(e):r(e):(e!==r(e)&&(e=XR(e,r,i)),e=e.replace(qR,""),t.preserveConsecutiveUppercase?e=YR(e,r):e=r(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),QR(e,i))};mh.exports=mS;mh.exports.default=mS});var W$=vn((_5,fg)=>{"use strict";var G4=Object.prototype.hasOwnProperty,Gt="~";function Pc(){}Object.create&&(Pc.prototype=Object.create(null),new Pc().__proto__||(Gt=!1));function H4(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function K$(e,t,r,i,n){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new H4(r,i||e,n),o=Gt?Gt+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],a]:e._events[o].push(a):(e._events[o]=a,e._eventsCount++),e}function ld(e,t){--e._eventsCount===0?e._events=new Pc:delete e._events[t]}function Ct(){this._events=new Pc,this._eventsCount=0}Ct.prototype.eventNames=function(){var t=[],r,i;if(this._eventsCount===0)return t;for(i in r=this._events)G4.call(r,i)&&t.push(Gt?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Ct.prototype.listeners=function(t){var r=Gt?Gt+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,o=new Array(a);n<a;n++)o[n]=i[n].fn;return o};Ct.prototype.listenerCount=function(t){var r=Gt?Gt+t:t,i=this._events[r];return i?i.fn?1:i.length:0};Ct.prototype.emit=function(t,r,i,n,a,o){var s=Gt?Gt+t:t;if(!this._events[s])return!1;var c=this._events[s],u=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,i),!0;case 4:return c.fn.call(c.context,r,i,n),!0;case 5:return c.fn.call(c.context,r,i,n,a),!0;case 6:return c.fn.call(c.context,r,i,n,a,o),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(t,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,i);break;case 4:c[d].fn.call(c[d].context,r,i,n);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[d].fn.apply(c[d].context,l)}}return!0};Ct.prototype.on=function(t,r,i){return K$(this,t,r,i,!1)};Ct.prototype.once=function(t,r,i){return K$(this,t,r,i,!0)};Ct.prototype.removeListener=function(t,r,i,n){var a=Gt?Gt+t:t;if(!this._events[a])return this;if(!r)return ld(this,a),this;var o=this._events[a];if(o.fn)o.fn===r&&(!n||o.once)&&(!i||o.context===i)&&ld(this,a);else{for(var s=0,c=[],u=o.length;s<u;s++)(o[s].fn!==r||n&&!o[s].once||i&&o[s].context!==i)&&c.push(o[s]);c.length?this._events[a]=c.length===1?c[0]:c:ld(this,a)}return this};Ct.prototype.removeAllListeners=function(t){var r;return t?(r=Gt?Gt+t:t,this._events[r]&&ld(this,r)):(this._events=new Pc,this._eventsCount=0),this};Ct.prototype.off=Ct.prototype.removeListener;Ct.prototype.addListener=Ct.prototype.on;Ct.prefixed=Gt;Ct.EventEmitter=Ct;typeof fg<"u"&&(fg.exports=Ct)});var X$=vn((y5,q$)=>{"use strict";q$.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(i=>{i(t())}).then(()=>r),r=>new Promise(i=>{i(t())}).then(()=>{throw r})))});var Q$=vn((v5,fd)=>{"use strict";var J4=X$(),dd=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Y$=(e,t,r)=>new Promise((i,n)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){i(e);return}let a=setTimeout(()=>{if(typeof r=="function"){try{i(r())}catch(c){n(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new dd(o);typeof e.cancel=="function"&&e.cancel(),n(s)},t);J4(e.then(i,n),()=>{clearTimeout(a)})});fd.exports=Y$;fd.exports.default=Y$;fd.exports.TimeoutError=dd});var eI=vn(pg=>{"use strict";Object.defineProperty(pg,"__esModule",{value:!0});function K4(e,t,r){let i=0,n=e.length;for(;n>0;){let a=n/2|0,o=i+a;r(e[o],t)<=0?(i=++o,n-=a+1):n=a}return i}pg.default=K4});var tI=vn(hg=>{"use strict";Object.defineProperty(hg,"__esModule",{value:!0});var W4=eI(),mg=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let i={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(i);return}let n=W4.default(this._queue,i,(a,o)=>o.priority-a.priority);this._queue.splice(n,0,i)}dequeue(){let t=this._queue.shift();return t?.run}filter(t){return this._queue.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this._queue.length}};hg.default=mg});var md=vn(_g=>{"use strict";Object.defineProperty(_g,"__esModule",{value:!0});var q4=W$(),rI=Q$(),X4=tI(),pd=()=>{},Y4=new rI.TimeoutError,gg=class extends q4{constructor(t){var r,i,n,a;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=pd,this._resolveIdle=pd,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:X4.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(n=t.interval)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||t.interval===0,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=t.throwOnTimeout===!0,this._isPaused=t.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=pd,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=pd,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let t=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-t;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),t&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,r={}){return new Promise((i,n)=>{let a=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?t():rI.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&n(Y4)});i(await o)}catch(o){n(o)}this._next()};this._queue.enqueue(a,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async i=>this.add(i,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(t=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),t()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(t=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),t()}})}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}};_g.default=gg});var PI=vn(($G,OI)=>{"use strict";var AI=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,CI=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`;function UM(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,i]of Object.entries(t)){for(let[n,a]of Object.entries(i))t[n]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},i[n]=t[n],e.set(a[0],a[1]);Object.defineProperty(t,r,{value:i,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi256=AI(),t.color.ansi16m=CI(),t.bgColor.ansi256=AI(10),t.bgColor.ansi16m=CI(10),Object.defineProperties(t,{rgbToAnsi256:{value:(r,i,n)=>r===i&&i===n?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:r=>{let i=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!i)return[0,0,0];let{colorString:n}=i.groups;n.length===3&&(n=n.split("").map(o=>o+o).join(""));let a=Number.parseInt(n,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1}}),t}Object.defineProperty(OI,"exports",{enumerable:!0,get:UM})});var KC=vn(gp=>{"use strict";gp.byteLength=HL;gp.toByteArray=KL;gp.fromByteArray=XL;var Ln=[],Lr=[],GL=typeof Uint8Array<"u"?Uint8Array:Array,lw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(po=0,HC=lw.length;po<HC;++po)Ln[po]=lw[po],Lr[lw.charCodeAt(po)]=po;var po,HC;Lr[45]=62;Lr[95]=63;function JC(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function HL(e){var t=JC(e),r=t[0],i=t[1];return(r+i)*3/4-i}function JL(e,t,r){return(t+r)*3/4-r}function KL(e){var t,r=JC(e),i=r[0],n=r[1],a=new GL(JL(e,i,n)),o=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)t=Lr[e.charCodeAt(c)]<<18|Lr[e.charCodeAt(c+1)]<<12|Lr[e.charCodeAt(c+2)]<<6|Lr[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return n===2&&(t=Lr[e.charCodeAt(c)]<<2|Lr[e.charCodeAt(c+1)]>>4,a[o++]=t&255),n===1&&(t=Lr[e.charCodeAt(c)]<<10|Lr[e.charCodeAt(c+1)]<<4|Lr[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function WL(e){return Ln[e>>18&63]+Ln[e>>12&63]+Ln[e>>6&63]+Ln[e&63]}function qL(e,t,r){for(var i,n=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),n.push(WL(i));return n.join("")}function XL(e){for(var t,r=e.length,i=r%3,n=[],a=16383,o=0,s=r-i;o<s;o+=a)n.push(qL(e,o,o+a>s?s:o+a));return i===1?(t=e[r-1],n.push(Ln[t>>2]+Ln[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],n.push(Ln[t>>10]+Ln[t>>4&63]+Ln[t<<2&63]+"=")),n.join("")}});var Fe="__start__",We="__end__",wn="__input__";var Eo="__error__",pl="__pregel_ns_writes",Er="__pregel_send",To="__pregel_call",Gr="__pregel_read",Hr="__pregel_checkpointer",Ao="__pregel_resuming",pc="__pregel_task_id",mc="__pregel_stream",SR="__pregel_resume_value",Co="__pregel_resume_map",rr="__pregel_scratchpad",ha="__pregel_previous",kR="__pregel_durability",ml="checkpoint_id",Tr="checkpoint_ns",W0="__pregel_node_finished",Ar="checkpoint_map",q0="__pregel_abort_signals",Be="__interrupt__",mr="__resume__",hc="__no_writes__",ki="__return__",ga="__previous__",st="langsmith:hidden";var qm="__self__",xn="__pregel_tasks",Cr="__pregel_push",hl="__pregel_pull",hr="00000000-0000-0000-0000-000000000000",X0=[st,wn,Be,mr,Eo,hc,Er,Gr,Hr,kR,mc,Ao,pc,To,SR,rr,ha,Ar,Tr,ml],Wm=Symbol.for("langgraph.command"),Y0=class{[Wm];constructor(e){this[Wm]=e}};function gl(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var ma=class{lg_name="Send";node;args;constructor(e,t){this.node=e,this.args=fc(t)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function ct(e){return e instanceof ma}var Io="__overwrite__",$R=class{lg_name="Overwrite";[Io];constructor(e){this[Io]=e}get value(){return this[Io]}toJSON(){return{[Io]:this[Io]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function _l(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[Io]]:[!1,void 0]}function Q0(e){return _l(e)[0]}function gc(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[Be])}var tr=class extends Y0{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(e){super(e),this.resume=e.resume,this.graph=e.graph,this.update=e.update,e.goto&&(this.goto=Array.isArray(e.goto)?fc(e.goto):[fc(e.goto)])}_updateAsTuples(){return this.update&&typeof this.update=="object"&&!Array.isArray(this.update)?Object.entries(this.update):Array.isArray(this.update)&&this.update.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string")?this.update:[["__root__",this.update]]}toJSON(){let e;return typeof this.goto=="string"?e=this.goto:ct(this.goto)?e=this.goto.toJSON():e=this.goto?.map(t=>typeof t=="string"?t:t.toJSON()),{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:e}}};function ft(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function fc(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let r;if(Array.isArray(e))r=[],t.set(e,r),e.forEach((i,n)=>{r[n]=fc(i,t)});else if(ft(e)&&!(e instanceof tr))r=new tr(e),t.set(e,r);else if(gl(e)&&!(e instanceof ma))r=new ma(e.node,e.args),t.set(e,r);else if(ft(e)||ct(e))r=e,t.set(e,r);else if("lc_serializable"in e&&e.lc_serializable)r=e,t.set(e,r);else{r={},t.set(e,r);for(let[i,n]of Object.entries(e))r[i]=fc(n,t)}return r}return e}var Jr=class extends Error{lc_error_code;constructor(e,t){let r=e??"";t?.lc_error_code&&(r=`${r}
|
|
3
|
+
|
|
4
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
|
|
5
|
+
`),super(r),this.lc_error_code=t?.lc_error_code}},Xm=class extends Jr{get is_bubble_up(){return!0}},Ym=class extends Jr{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},_a=class extends Jr{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},Wn=class extends Xm{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},yl=class extends Wn{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},vl=class extends Xm{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function Qm(e){return e!==void 0&&e.name===vl.unminifiable_name}function ya(e){return e!==void 0&&e.is_bubble_up===!0}function qn(e){return e!==void 0&&[Wn.unminifiable_name,yl.unminifiable_name].includes(e.name)}var bl=class extends Jr{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Ae=class extends Jr{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},_e=class extends Jr{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},IR=class extends Jr{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}},eh=class extends Jr{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},ER=class extends Jr{constructor(e,t){super(e,t),this.name="RemoteException"}static get unminifiable_name(){return"RemoteException"}},_c=class extends Jr{constructor(e,t){super(e,t),this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}},TR=()=>(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]===void 0&&(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]=new Set),globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]);var eS=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function AR(e){return typeof e=="string"&&eS.test(e)}var Oo=AR;function CR(e){if(!Oo(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var wl=CR;var xt=[];for(xl=0;xl<256;++xl)xt.push((xl+256).toString(16).slice(1));var xl;function Sn(e,t=0){return(xt[e[t+0]]+xt[e[t+1]]+xt[e[t+2]]+xt[e[t+3]]+"-"+xt[e[t+4]]+xt[e[t+5]]+"-"+xt[e[t+6]]+xt[e[t+7]]+"-"+xt[e[t+8]]+xt[e[t+9]]+"-"+xt[e[t+10]]+xt[e[t+11]]+xt[e[t+12]]+xt[e[t+13]]+xt[e[t+14]]+xt[e[t+15]]).toLowerCase()}var Sl,OR=new Uint8Array(16);function yc(){if(!Sl&&(Sl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Sl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sl(OR)}var th,kl,rh=0,nh=0;function PR(e,t,r){var i=t&&r||0,n=t||new Array(16);e=e||{};var a=e.node,o=e.clockseq;if(e._v6||(a||(a=th),o==null&&(o=kl)),a==null||o==null){var s=e.random||(e.rng||yc)();a==null&&(a=[s[0],s[1],s[2],s[3],s[4],s[5]],!th&&!e._v6&&(a[0]|=1,th=a)),o==null&&(o=(s[6]<<8|s[7])&16383,kl===void 0&&!e._v6&&(kl=o))}var c=e.msecs!==void 0?e.msecs:Date.now(),u=e.nsecs!==void 0?e.nsecs:nh+1,l=c-rh+(u-nh)/1e4;if(l<0&&e.clockseq===void 0&&(o=o+1&16383),(l<0||c>rh)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rh=c,nh=u,kl=o,c+=122192928e5;var d=((c&268435455)*1e4+u)%4294967296;n[i++]=d>>>24&255,n[i++]=d>>>16&255,n[i++]=d>>>8&255,n[i++]=d&255;var f=c/4294967296*1e4&268435455;n[i++]=f>>>8&255,n[i++]=f&255,n[i++]=f>>>24&15|16,n[i++]=f>>>16&255,n[i++]=o>>>8|128,n[i++]=o&255;for(var p=0;p<6;++p)n[i+p]=a[p];return t||Sn(n)}var tS=PR;function ih(e){var t=typeof e=="string"?wl(e):e,r=NR(t);return typeof e=="string"?Sn(r):r}function NR(e,t=!1){return Uint8Array.of((e[6]&15)<<4|e[7]>>4&15,(e[7]&15)<<4|(e[4]&240)>>4,(e[4]&15)<<4|(e[5]&240)>>4,(e[5]&15)<<4|(e[0]&240)>>4,(e[0]&15)<<4|(e[1]&240)>>4,(e[1]&15)<<4|(e[2]&240)>>4,96|e[2]&15,e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function RR(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var jR="6ba7b810-9dad-11d1-80b4-00c04fd430c8",MR="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ah(e,t,r){function i(n,a,o,s){var c;if(typeof n=="string"&&(n=RR(n)),typeof a=="string"&&(a=wl(a)),((c=a)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+n.length);if(u.set(a),u.set(n,a.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){s=s||0;for(var l=0;l<16;++l)o[s+l]=u[l];return o}return Sn(u)}try{i.name=e}catch{}return i.DNS=jR,i.URL=MR,i}var zR=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),oh={randomUUID:zR};function DR(e,t,r){if(oh.randomUUID&&!t&&!e)return oh.randomUUID();e=e||{};var i=e.random||(e.rng||yc)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(var n=0;n<16;++n)t[r+n]=i[n];return t}return Sn(i)}var $l=DR;function UR(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function sh(e,t){return e<<t|e>>>32-t}function LR(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var i=unescape(encodeURIComponent(e));e=[];for(var n=0;n<i.length;++n)e.push(i.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=new Array(o),c=0;c<o;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=e[c*64+l*4]<<24|e[c*64+l*4+1]<<16|e[c*64+l*4+2]<<8|e[c*64+l*4+3];s[c]=u}s[o-1][14]=(e.length-1)*8/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=sh(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var _=r[0],v=r[1],x=r[2],w=r[3],S=r[4],$=0;$<80;++$){var T=Math.floor($/20),F=sh(_,5)+UR(T,v,x,w)+S+t[T]+f[$]>>>0;S=w,w=x,x=sh(v,30)>>>0,v=_,_=F}r[0]=r[0]+_>>>0,r[1]=r[1]+v>>>0,r[2]=r[2]+x>>>0,r[3]=r[3]+w>>>0,r[4]=r[4]+S>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var rS=LR;var FR=ah("v5",80,rS),ch=FR;function nS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function iS(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?nS(Object(r),!0).forEach(function(i){BR(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nS(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function BR(e,t,r){return(t=ZR(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ZR(e){var t=VR(e,"string");return typeof t=="symbol"?t:t+""}function VR(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Il(e={},t,r=0){var i=tS(iS(iS({},e),{},{_v6:!0}),new Uint8Array(16));if(i=ih(i),t){for(var n=0;n<16;n++)t[r+n]=i[n];return t}return Sn(i)}function vc(e){return Il({clockseq:e})}function Xn(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(i=>parseInt(i,16));return ch(e,new Uint8Array(r))}var bc="__pregel_tasks",uh="__error__",va="__scheduled__",lh="__interrupt__",dh="__resume__";var aS="[...]",GR="[Circular]",El=[],Po=[];function HR(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function oS(e,t,r,i){typeof i>"u"&&(i=HR()),ph(e,"",0,[],void 0,0,i);var n;try{Po.length===0?n=JSON.stringify(e,t,r):n=JSON.stringify(e,JR(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;El.length!==0;){var a=El.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return n}function fh(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),El.push([i,r,t,n])):Po.push([t,r,e]):(i[r]=e,El.push([i,r,t]))}function ph(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){fh(GR,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){fh(aS,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){fh(aS,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)ph(e[s],s,s,i,e,a,o);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];ph(e[u],u,s,i,e,a,o)}}i.pop()}}function JR(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Po.length>0)for(var i=0;i<Po.length;i++){var n=Po[i];if(n[1]===t&&n[0]===r){r=n[2],Po.splice(i,1);break}}return e.call(this,t,r)}}var gS=pa(cS(),1),_S=pa(hS(),1);function yS(e,t){return t?.[e]||(0,gS.default)(e)}function vS(e,t){return t?.[e]||(0,_S.default)(e)}function Tl(e,t,r){let i={};for(let n in e)Object.hasOwn(e,n)&&(i[t(n,r)]=e[n]);return i}var bS="__lc_escaped__";function ej(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function tj(e){return{[bS]:e}}function hh(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function rj(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function nj(e){let t;return e!==null&&typeof e=="object"?"lc_id"in e&&Array.isArray(e.lc_id)?t=e.lc_id:t=[e.constructor?.name??"Object"]:t=[typeof e],{lc:1,type:"not_implemented",id:t}}function Al(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return nj(e);if(rj(e))return e;t.add(e);let r=e;if(ej(r))return t.delete(e),tj(r);let i={};for(let[n,a]of Object.entries(r))i[n]=Al(a,t);return t.delete(e),i}return Array.isArray(e)?e.map(r=>Al(r,t)):e}function Cl(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(hh(t))return t[bS];let r={};for(let[i,n]of Object.entries(t))r[i]=Cl(n);return r}return Array.isArray(e)?e.map(t=>Cl(t)):e}var wS=Object.defineProperty,E=(e,t)=>{let r={};for(var i in e)wS(r,i,{get:e[i],enumerable:!0});return t||wS(r,Symbol.toStringTag,{value:"Module"}),r};var SS=E({Serializable:()=>at,get_lc_unique_name:()=>No});function xS(e){return Array.isArray(e)?[...e]:{...e}}function ij(e,t){let r=xS(e);for(let[i,n]of Object.entries(t)){let[a,...o]=i.split(".").reverse(),s=r;for(let c of o.reverse()){if(s[c]===void 0)break;s[c]=xS(s[c]),s=s[c]}s[a]!==void 0&&(s[a]={lc:1,type:"secret",id:[n]})}return r}function No(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name=="function"&&(typeof t.lc_name!="function"||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var at=class kS{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,No(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...r){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([i])=>this.lc_serializable_keys?.includes(i))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof kS||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},i=Object.keys(this.lc_kwargs).reduce((s,c)=>(s[c]=c in this?this[c]:this.lc_kwargs[c],s),{});for(let s=Object.getPrototypeOf(this);s;s=Object.getPrototypeOf(s))Object.assign(t,Reflect.get(s,"lc_aliases",this)),Object.assign(r,Reflect.get(s,"lc_secrets",this)),Object.assign(i,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,u=i,[l,...d]=s.split(".").reverse();for(let f of d.reverse()){if(!(f in c)||c[f]===void 0)return;(!(f in u)||u[f]===void 0)&&(typeof c[f]=="object"&&c[f]!=null?u[f]={}:Array.isArray(c[f])&&(u[f]=[])),c=c[f],u=u[f]}l in c&&c[l]!==void 0&&(u[l]=u[l]||c[l])});let n={},a=new WeakSet;a.add(this);for(let[s,c]of Object.entries(i))n[s]=Al(c,a);let o=Tl(Object.keys(r).length?ij(n,r):n,yS,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var $S=E({getEnv:()=>CS,getEnvironmentVariable:()=>Ft,getRuntimeEnvironment:()=>_h,isBrowser:()=>IS,isDeno:()=>Ol,isJsDom:()=>TS,isNode:()=>AS,isWebWorker:()=>ES}),IS=()=>typeof window<"u"&&typeof window.document<"u",ES=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",TS=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),Ol=()=>typeof Deno<"u",AS=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!Ol(),CS=()=>{let e;return IS()?e="browser":AS()?e="node":ES()?e="webworker":TS()?e="jsdom":Ol()?e="deno":e="other",e},gh;function _h(){return gh===void 0&&(gh={library:"langchain-js",runtime:CS()}),gh}function Ft(e){try{return typeof process<"u"?process.env?.[e]:Ol()?Deno?.env.get(e):void 0}catch{return}}var OS=[];var PS=E({});var NS=E({});var Y="0123456789abcdef".split(""),aj=[-2147483648,8388608,32768,128],Kr=[24,16,8,0],Pl=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],gt=[];function Wr(e,t){t?(gt[0]=gt[16]=gt[1]=gt[2]=gt[3]=gt[4]=gt[5]=gt[6]=gt[7]=gt[8]=gt[9]=gt[10]=gt[11]=gt[12]=gt[13]=gt[14]=gt[15]=0,this.blocks=gt):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}Wr.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if(r!=="string"){if(r==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var i,n=0,a,o=e.length,s=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,this.block=s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)for(a=this.start;n<o&&a<64;++n)s[a>>>2]|=e[n]<<Kr[a++&3];else for(a=this.start;n<o&&a<64;++n)i=e.charCodeAt(n),i<128?s[a>>>2]|=i<<Kr[a++&3]:i<2048?(s[a>>>2]|=(192|i>>>6)<<Kr[a++&3],s[a>>>2]|=(128|i&63)<<Kr[a++&3]):i<55296||i>=57344?(s[a>>>2]|=(224|i>>>12)<<Kr[a++&3],s[a>>>2]|=(128|i>>>6&63)<<Kr[a++&3],s[a>>>2]|=(128|i&63)<<Kr[a++&3]):(i=65536+((i&1023)<<10|e.charCodeAt(++n)&1023),s[a>>>2]|=(240|i>>>18)<<Kr[a++&3],s[a>>>2]|=(128|i>>>12&63)<<Kr[a++&3],s[a>>>2]|=(128|i>>>6&63)<<Kr[a++&3],s[a>>>2]|=(128|i&63)<<Kr[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=s[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Wr.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=aj[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};Wr.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,u,l,d,f,p,m,_,v,x,w,S;for(u=16;u<64;++u)p=c[u-15],l=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,p=c[u-2],d=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(S=t&r,u=0;u<64;u+=4)this.first?(this.is224?(v=300032,p=c[0]-1413257819,s=p-150054599<<0,i=p+24177077<<0):(v=704751109,p=c[0]-210244248,s=p-1521486534<<0,i=p+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),v=e&t,f=v^e&r^S,_=n&a^~n&o,p=s+d+_+Pl[u]+c[u],m=l+f,s=i+p<<0,i=p+m<<0),l=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),x=i&e,f=x^i&t^v,_=o&s^~o&n,p=a+d+_+Pl[u+1]+c[u+1],m=l+f,o=r+p<<0,r=p+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=r&i,f=w^r&e^x,_=a&o^~a&s,p=n+d+_+Pl[u+2]+c[u+2],m=l+f,a=t+p<<0,t=p+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),S=t&r,f=S^t&i^w,_=a&o^~a&s,p=n+d+_+Pl[u+3]+c[u+3],m=l+f,n=e+p<<0,e=p+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+i<<0,this.h4=this.h4+n<<0,this.h5=this.h5+a<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};Wr.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=Y[e>>>28&15]+Y[e>>>24&15]+Y[e>>>20&15]+Y[e>>>16&15]+Y[e>>>12&15]+Y[e>>>8&15]+Y[e>>>4&15]+Y[e&15]+Y[t>>>28&15]+Y[t>>>24&15]+Y[t>>>20&15]+Y[t>>>16&15]+Y[t>>>12&15]+Y[t>>>8&15]+Y[t>>>4&15]+Y[t&15]+Y[r>>>28&15]+Y[r>>>24&15]+Y[r>>>20&15]+Y[r>>>16&15]+Y[r>>>12&15]+Y[r>>>8&15]+Y[r>>>4&15]+Y[r&15]+Y[i>>>28&15]+Y[i>>>24&15]+Y[i>>>20&15]+Y[i>>>16&15]+Y[i>>>12&15]+Y[i>>>8&15]+Y[i>>>4&15]+Y[i&15]+Y[n>>>28&15]+Y[n>>>24&15]+Y[n>>>20&15]+Y[n>>>16&15]+Y[n>>>12&15]+Y[n>>>8&15]+Y[n>>>4&15]+Y[n&15]+Y[a>>>28&15]+Y[a>>>24&15]+Y[a>>>20&15]+Y[a>>>16&15]+Y[a>>>12&15]+Y[a>>>8&15]+Y[a>>>4&15]+Y[a&15]+Y[o>>>28&15]+Y[o>>>24&15]+Y[o>>>20&15]+Y[o>>>16&15]+Y[o>>>12&15]+Y[o>>>8&15]+Y[o>>>4&15]+Y[o&15];return this.is224||(c+=Y[s>>>28&15]+Y[s>>>24&15]+Y[s>>>20&15]+Y[s>>>16&15]+Y[s>>>12&15]+Y[s>>>8&15]+Y[s>>>4&15]+Y[s&15]),c};Wr.prototype.toString=Wr.prototype.hex;Wr.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};Wr.prototype.array=Wr.prototype.digest;Wr.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};var Ro=(...e)=>new Wr(!1,!0).update(e.join("")).hex();var RS=E({sha256:()=>Ro});function jS(e){let t=Symbol.for(e);return{brand(r,i){let n=i?Symbol.for(`${e}.${i}`):t;class a extends r{[n]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&n in s&&s[n]===!0}}return Object.defineProperty(a,"name",{value:r.name}),a},sub(r){return jS(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var MS=jS("langchain");var zS=E({ContextOverflowError:()=>oj,LangChainError:()=>yh,ModelAbortError:()=>Rl,addLangChainErrorFields:()=>Yn,ns:()=>Nl});function Yn(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
6
|
+
|
|
7
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
8
|
+
`,e}var Nl=MS.sub("error"),yh=class extends Nl.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Rl=class extends Nl.brand(yh,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},oj=class DS extends Nl.brand(yh,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new DS(t.message);return r.cause=t,r}};function kn(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"&&"source_type"in e&&(e.source_type==="url"||e.source_type==="base64"||e.source_type==="text"||e.source_type==="id")}function jo(e){return kn(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Mo(e){return kn(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function US(e){return kn(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function jl(e){return kn(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function Ml(e){if(kn(e)){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url}};if(e.source_type==="base64"){if(!e.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function LS(e){let t=e.split(";")[0].split("/");if(t.length!==2)throw new Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let r=t[0].trim(),i=t[1].trim();if(r===""||i==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let n={};for(let a of e.split(";").slice(1)){let o=a.split("=");if(o.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=o[0].trim(),c=o[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);n[s]=c}return{type:r,subtype:i,parameters:n}}function wc({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),i;if(r){i=r[1].toLowerCase();let n=t?Uint8Array.from(atob(r[2]),a=>a.charCodeAt(0)):r[2];return{mime_type:i,data:n}}}function FS(e,t){if(e.type==="text"){if(!t.fromStandardTextBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type==="image"){if(!t.fromStandardImageBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type==="audio"){if(!t.fromStandardAudioBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type==="file"){if(!t.fromStandardFileBlock)throw new Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw new Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function H(e,t){return Q(e)&&e.type===t}function Q(e){return typeof e=="object"&&e!==null}function pt(e){return Array.isArray(e)}function P(e){return typeof e=="string"}function gr(e){return typeof e=="number"}function zl(e){return e instanceof Uint8Array}function vh(e){try{return JSON.parse(e)}catch{return}}var _r=e=>e();function sj(e){if(e.type==="char_location"&&P(e.document_title)&&gr(e.start_char_index)&&gr(e.end_char_index)&&P(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="page_location"&&P(e.document_title)&&gr(e.start_page_number)&&gr(e.end_page_number)&&P(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="content_block_location"&&P(e.document_title)&&gr(e.start_block_index)&&gr(e.end_block_index)&&P(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:i,citedText:n}}if(e.type==="web_search_result_location"&&P(e.url)&&P(e.title)&&P(e.encrypted_index)&&P(e.cited_text)){let{url:t,title:r,encrypted_index:i,cited_text:n,...a}=e;return{...a,type:"citation",source:"url",url:t,title:r,startIndex:Number(i),endIndex:Number(i),citedText:n}}if(e.type==="search_result_location"&&P(e.source)&&P(e.title)&&gr(e.start_block_index)&&gr(e.end_block_index)&&P(e.cited_text)){let{source:t,title:r,start_block_index:i,end_block_index:n,cited_text:a,...o}=e;return{...o,type:"citation",source:"search",url:t,title:r??void 0,startIndex:i,endIndex:n,citedText:a}}}function ZS(e){if(H(e,"document")&&Q(e.source)&&"type"in e.source){if(e.source.type==="base64"&&P(e.source.media_type)&&P(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&P(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&P(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&P(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(H(e,"image")&&Q(e.source)&&"type"in e.source){if(e.source.type==="base64"&&P(e.source.media_type)&&P(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&P(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&P(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function VS(e){function*t(){for(let r of e){let i=ZS(r);i?yield i:yield r}}return Array.from(t())}function BS(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"text")&&P(i.text)){let{text:n,citations:a,...o}=i;if(pt(a)&&a.length){let s=a.reduce((c,u)=>{let l=sj(u);return l?[...c,l]:c},[]);yield{...o,type:"text",text:n,annotations:s};continue}else{yield{...o,type:"text",text:n};continue}}else if(H(i,"thinking")&&P(i.thinking)){let{thinking:n,signature:a,...o}=i;yield{...o,type:"reasoning",reasoning:n,signature:a};continue}else if(H(i,"redacted_thinking")){yield{type:"non_standard",value:i};continue}else if(H(i,"tool_use")&&P(i.name)&&P(i.id)){yield{type:"tool_call",id:i.id,name:i.name,args:i.input};continue}else if(H(i,"input_json_delta")){if(cj(e)&&e.tool_call_chunks?.length){let n=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:n.id,name:n.name,args:n.args,index:n.index};continue}}else if(H(i,"server_tool_use")&&P(i.name)&&P(i.id)){let{name:n,id:a}=i;if(n==="web_search"){yield{id:a,type:"server_tool_call",name:"web_search",args:{query:_r(()=>{if(typeof i.input=="string")return i.input;if(Q(i.input)&&P(i.input.query))return i.input.query;if(P(i.partial_json)){let o=vh(i.partial_json);if(o?.query)return o.query}return""})}};continue}else if(i.name==="code_execution"){yield{id:a,type:"server_tool_call",name:"code_execution",args:{code:_r(()=>{if(typeof i.input=="string")return i.input;if(Q(i.input)&&P(i.input.code))return i.input.code;if(P(i.partial_json)){let o=vh(i.partial_json);if(o?.code)return o.code}return""})}};continue}}else if(H(i,"web_search_tool_result")&&P(i.tool_use_id)&&pt(i.content)){let{content:n,tool_use_id:a}=i;yield{type:"server_tool_call_result",name:"web_search",toolCallId:a,status:"success",output:{urls:n.reduce((o,s)=>H(s,"web_search_result")?[...o,s.url]:o,[])}};continue}else if(H(i,"code_execution_tool_result")&&P(i.tool_use_id)&&Q(i.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(H(i,"mcp_tool_use")){yield{id:i.id,type:"server_tool_call",name:"mcp_tool_use",args:i.input};continue}else if(H(i,"mcp_tool_result")&&P(i.tool_use_id)&&Q(i.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:i.tool_use_id,status:"success",output:i.content};continue}else if(H(i,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:i.input};continue}else if(H(i,"search_result")){yield{id:i.id,type:"non_standard",value:i};continue}else if(H(i,"tool_result")){yield{id:i.id,type:"non_standard",value:i};continue}else{let n=ZS(i);if(n){yield n;continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var GS={translateContent:BS,translateContentChunk:BS};function cj(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function uj(e){return jo(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Mo(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:jl(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function HS(e){return e.map(uj)}function JS(e){return!!(H(e,"image_url")&&Q(e.image_url)||H(e,"input_audio")&&Q(e.input_audio)||H(e,"file")&&Q(e.file))}function KS(e){if(H(e,"image_url")&&Q(e.image_url)&&P(e.image_url.url)){let t=wc({dataUrl:e.image_url.url});return t?{type:"image",mimeType:t.mime_type,data:t.data}:{type:"image",url:e.image_url.url}}else{if(H(e,"input_audio")&&Q(e.input_audio)&&P(e.input_audio.data)&&P(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(H(e,"file")&&Q(e.file)&&P(e.file.data)){let t=wc({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(P(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function lj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Dl(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function dj(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...Dl(e.content));for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}function Dl(e){let t=[];for(let r of e)JS(r)?t.push(KS(r)):t.push(r);return t}function fj(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:i,end_index:n}=e;return{type:"citation",url:t,title:r,startIndex:i,endIndex:n}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:i}=e;return{type:"citation",title:r,startIndex:i,endIndex:i,fileId:t}}return e}function WS(e){function*t(){Q(e.additional_kwargs?.reasoning)&&pt(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((i,n)=>Q(n)&&P(n.text)?`${i}${n.text}`:i,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r)if(H(i,"text")){let{text:n,annotations:a,phase:o,extras:s,...c}=i,u=Q(s)?{...s}:{};P(o)&&(u.phase=o);let l=Object.keys(u).length>0?{extras:u}:{};Array.isArray(a)?yield{...c,...l,type:"text",text:String(n),annotations:a.map(fj)}:yield{...c,...l,type:"text",text:String(n)}}for(let i of e.tool_calls??[])yield{type:"tool_call",id:i.id,name:i.name,args:i.args};if(Q(e.additional_kwargs)&&pt(e.additional_kwargs.tool_outputs))for(let i of e.additional_kwargs.tool_outputs){if(H(i,"web_search_call")){let n={};if(Q(i.action)&&P(i.action.query)&&(n.query=i.action.query),yield{id:i.id,type:"server_tool_call",name:"web_search",args:n},i.status==="completed"||i.status==="failed"){let a={};Q(i.action)&&(a.action=i.action),yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:a}}continue}else if(H(i,"file_search_call")){yield{id:i.id,type:"server_tool_call",name:"file_search",args:{queries:pt(i.queries)?i.queries:[]}},(i.status==="completed"||i.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":"error",output:pt(i.results)?{results:i.results}:{}});continue}else if(H(i,"computer_call")){yield{type:"non_standard",value:i};continue}else if(H(i,"code_interpreter_call")){if(P(i.code)&&(yield{id:i.id,type:"server_tool_call",name:"code_interpreter",args:{code:i.code}}),pt(i.outputs)){let n=_r(()=>{if(i.status!=="in_progress"){if(i.status==="completed")return 0;if(i.status==="incomplete")return 127;if(i.status!=="interpreting"&&i.status==="failed")return 1}});for(let a of i.outputs)if(H(a,"logs")){yield{type:"server_tool_call_result",toolCallId:i.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:n??0,stderr:[0,void 0].includes(n)?void 0:String(a.logs),stdout:[0,void 0].includes(n)?String(a.logs):void 0}};continue}}continue}else if(H(i,"mcp_call")){yield{id:i.id,type:"server_tool_call",name:"mcp_call",args:i.input};continue}else if(H(i,"mcp_list_tools")){yield{id:i.id,type:"server_tool_call",name:"mcp_list_tools",args:i.input};continue}else if(H(i,"mcp_approval_request")){yield{type:"non_standard",value:i};continue}else if(H(i,"tool_search_call")){let n={};Q(i.arguments)&&Object.assign(n,i.arguments);let a={};P(i.execution)&&(a.execution=i.execution),P(i.status)&&(a.status=i.status),P(i.call_id)&&(a.call_id=i.call_id),yield{id:P(i.id)?i.id:"",type:"server_tool_call",name:"tool_search",args:n,...Object.keys(a).length>0?{extras:a}:{}};continue}else if(H(i,"tool_search_output")){let n={name:"tool_search"};P(i.execution)&&(n.execution=i.execution),yield{type:"server_tool_call_result",toolCallId:P(i.id)?i.id:"",status:i.status==="completed"?"success":i.status==="failed"?"error":"success",output:{tools:pt(i.tools)?i.tools:[]},extras:n};continue}else if(H(i,"image_generation_call")){P(i.result)&&(yield{type:"image",mimeType:"image/png",data:i.result,id:P(i.id)?i.id:void 0,metadata:{status:P(i.status)?i.status:void 0}}),yield{type:"non_standard",value:i};continue}Q(i)&&(yield{type:"non_standard",value:i})}}return Array.from(t())}function pj(e){function*t(){yield*WS(e);for(let r of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:r.id,name:r.name,args:r.args}}return Array.from(t())}var qS={translateContent:e=>typeof e.content=="string"?lj(e):WS(e),translateContentChunk:e=>typeof e.content=="string"?dj(e):pj(e)};function Ul(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function XS(e,t="pretty"){return t==="pretty"?mj(e):JSON.stringify(e)}function mj(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,i=Math.floor((80-r.length)/2),n="=".repeat(i),a=r.length%2===0?n:`${n}=`;if(t.push(`${n}${r}${a}`),e.type==="ai"){let o=e;if(o.tool_calls&&o.tool_calls.length>0){t.push("Tool Calls:");for(let s of o.tool_calls){t.push(` ${s.name} (${s.id})`),t.push(` Call ID: ${s.id}`),t.push(" Args:");for(let[c,u]of Object.entries(s.args))t.push(` ${c}: ${typeof u=="object"?JSON.stringify(u):u}`)}}}if(e.type==="tool"){let o=e;o.name&&t.push(`Name: ${o.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
|
|
9
|
+
`)}var bh=Symbol.for("langchain.message");function YS(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function At(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>kn(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let r=YS(e);return $i(r,t)??[...r,...t]}else return t===""?e:Array.isArray(e)&&e.some(r=>kn(r))?[...e,{type:"file",source_type:"text",text:t}]:[...YS(e),{type:"text",text:t}]}function Ll(e,t){return e==="error"||t==="error"?"error":"success"}function hj(e,t){function r(i,n){if(typeof i!="object"||i===null||i===void 0)return i;if(n>=t)return Array.isArray(i)?"[Array]":"[Object]";if(Array.isArray(i))return i.map(o=>r(o,n+1));let a={};for(let o of Object.keys(i))a[o]=r(i[o],n+1);return a}return JSON.stringify(r(e,0),null,2)}var Me=class extends at{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[bh]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(e){let t=typeof e=="string"||Array.isArray(e)?{content:e}:e;t.additional_kwargs||(t.additional_kwargs={}),t.response_metadata||(t.response_metadata={}),super(t),this.name=t.name,t.content===void 0&&t.contentBlocks!==void 0?(this.content=t.contentBlocks,this.response_metadata={output_version:"v1",...t.response_metadata}):t.content!==void 0?(this.content=t.content??[],this.response_metadata=t.response_metadata):(this.content=[],this.response_metadata=t.response_metadata),this.additional_kwargs=t.additional_kwargs,this.id=t.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(e=>typeof e=="string"?e:e.type==="text"?e.text:"").join(""):""}get contentBlocks(){let e=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[HS,Dl,VS].reduce((t,r)=>r(t),e)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(e){return typeof e=="object"&&e!==null&&bh in e&&e[bh]===!0&&Ul(e)}_updateId(e){this.id=e,this.lc_kwargs.id=e}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](e){if(e===null)return this;let t=hj(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return XS(this,e)}};function tk(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var wh=["index","created","timestamp"];function He(e,t,r){let i=r?.ignoreKeys??wh;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let n={...e};for(let[a,o]of Object.entries(t))if(n[a]==null)n[a]=o;else{if(o==null)continue;if(typeof n[a]!=typeof o||Array.isArray(n[a])!==Array.isArray(o))throw new Error(`field[${a}] already exists in the message chunk, but with a different type.`);if(typeof n[a]=="string"){if(a==="type")continue;if(["id","name","output_version","model_provider"].includes(a))o&&(n[a]=o);else{if(i.includes(a))continue;n[a]+=o}}else if(typeof n[a]=="number"){if(i.includes(a))continue;n[a]=n[a]+o}else if(typeof n[a]=="object"&&!Array.isArray(n[a]))n[a]=He(n[a],o,r);else if(Array.isArray(n[a]))n[a]=$i(n[a],o,r);else{if(n[a]===o)continue;console.warn(`field[${a}] already exists in this message chunk and value has unsupported type.`)}}return n}function gj(e){return typeof e=="number"||typeof e=="string"}function QS(e){return typeof e!="object"||e===null||!("index"in e)?!1:gj(e.index)}function ek(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function _j(e,t){let r=QS(t),i=ek(t);return!r&&!i?-1:e.findIndex(n=>{let a=QS(n),o=ek(n);return r&&a?n.index!==t.index?!1:o&&i?n.id===t.id:!0:!r&&!a&&i&&o?n.id===t.id:!1})}function $i(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let i=[...e];for(let n of t){let a=_j(i,n);if(a!==-1)i[a]=He(i[a],n,r);else{if(typeof n=="object"&&n!==null&&"text"in n&&n.text==="")continue;i.push(n)}}return i}}}function Fl(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e??t;if(typeof e!=typeof t)throw new Error(`Cannot merge objects of different types.
|
|
10
|
+
Left ${typeof e}
|
|
11
|
+
Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return $i(e,t,r);if(typeof e=="object"&&typeof t=="object")return He(e,t,r);if(e===t)return e;throw new Error(`Can not merge objects of different types.
|
|
12
|
+
Left ${e}
|
|
13
|
+
Right ${t}`)}}var Bt=class rk extends Me{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===rk.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function Bl(e){return typeof e.role=="string"}function Je(e){return typeof e?._getType=="function"}function Qn(e){return Bt.isInstance(e)}var nk=E({ToolMessage:()=>Zt,ToolMessageChunk:()=>zo,defaultToolCallParser:()=>Sc,isDirectToolOutput:()=>xc,isToolMessage:()=>kc,isToolMessageChunk:()=>xh});function xc(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var Zt=class extends Me{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}lc_direct_tool_output=!0;type="tool";status;tool_call_id;metadata;artifact;constructor(e,t,r){let i=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(i),this.tool_call_id=i.tool_call_id,this.artifact=i.artifact,this.status=i.status,this.metadata=i.metadata}static isInstance(e){return super.isInstance(e)&&e.type==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},zo=class extends Bt{type="tool";tool_call_id;status;artifact;constructor(e){super(e),this.tool_call_id=e.tool_call_id,this.artifact=e.artifact,this.status=e.status}static lc_name(){return"ToolMessageChunk"}concat(e){let t=this.constructor;return new t({content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),artifact:Fl(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:Ll(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Sc(e){let t=[],r=[];for(let i of e)if(i.function){let n=i.function.name;try{let a=JSON.parse(i.function.arguments);t.push({name:n||"",args:a||{},id:i.id})}catch{r.push({name:n,args:i.function.arguments,id:i.id,error:"Malformed args."})}}else continue;return[t,r]}function kc(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function xh(e){return e._getType()==="tool"}function Ii(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function ik(e){return!!(e&&typeof e=="object"&&"toolCall"in e&&e.toolCall!=null&&typeof e.toolCall=="object"&&"id"in e.toolCall&&typeof e.toolCall.id=="string")}var Do=class extends Error{output;constructor(e,t){super(e),this.output=t}};function ba(e,t=$n){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let i=e.substring(r+3);i.startsWith(`json
|
|
14
|
+
`)?i=i.substring(5):i.startsWith("json")?i=i.substring(4):i.startsWith(`
|
|
15
|
+
`)&&(i=i.substring(1));let n=i.indexOf("```"),a=i;return n!==-1&&(a=i.substring(0,n)),t(a.trim())}function yj(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw new Error("Unexpected end of JSON input");let r=0;function i(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function n(){if(t[r]!=='"')throw new Error(`Expected '"' at position ${r}, got '${t[r]}'`);r+=1;let l="",d=!1;for(;r<t.length;){let f=t[r];if(d){if(f==="n")l+=`
|
|
16
|
+
`;else if(f==="t")l+=" ";else if(f==="r")l+="\r";else if(f==="\\")l+="\\";else if(f==='"')l+='"';else if(f==="b")l+="\b";else if(f==="f")l+="\f";else if(f==="/")l+="/";else if(f==="u"){let p=t.substring(r+1,r+5);if(/^[0-9A-Fa-f]{0,4}$/.test(p))p.length===4?l+=String.fromCharCode(Number.parseInt(p,16)):l+=`u${p}`,r+=p.length;else throw new Error(`Invalid unicode escape sequence '\\u${p}' at position ${r}`)}else throw new Error(`Invalid escape sequence '\\${f}' at position ${r}`);d=!1}else if(f==="\\")d=!0;else{if(f==='"')return r+=1,l;l+=f}r+=1}return d&&(l+="\\"),l}function a(){let l=r,d="";if(t[r]==="-"&&(d+="-",r+=1),r<t.length&&t[r]==="0"&&(d+="0",r+=1,t[r]>="0"&&t[r]<="9"))throw new Error(`Invalid number at position ${l}`);if(r<t.length&&t[r]>="1"&&t[r]<="9")for(;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&t[r]===".")for(d+=".",r+=1;r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(r<t.length&&(t[r]==="e"||t[r]==="E"))for(d+=t[r],r+=1,r<t.length&&(t[r]==="+"||t[r]==="-")&&(d+=t[r],r+=1);r<t.length&&t[r]>="0"&&t[r]<="9";)d+=t[r],r+=1;if(d==="-")return-0;let f=Number.parseFloat(d);if(Number.isNaN(f))throw r=l,new Error(`Invalid number '${d}' at position ${l}`);return f}function o(){if(i(),r>=t.length)throw new Error(`Unexpected end of input at position ${r}`);let l=t[r];if(l==="{")return c();if(l==="[")return s();if(l==='"')return n();if("null".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),null;if("true".startsWith(t.substring(r,r+4)))return r+=Math.min(4,t.length-r),!0;if("false".startsWith(t.substring(r,r+5)))return r+=Math.min(5,t.length-r),!1;if(l==="-"||l>="0"&&l<="9")return a();throw new Error(`Unexpected character '${l}' at position ${r}`)}function s(){if(t[r]!=="[")throw new Error(`Expected '[' at position ${r}, got '${t[r]}'`);let l=[];if(r+=1,i(),r>=t.length)return l;if(t[r]==="]")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length||(l.push(o()),i(),r>=t.length))return l;if(t[r]==="]")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or ']' at position ${r}, got '${t[r]}'`)}return l}function c(){if(t[r]!=="{")throw new Error(`Expected '{' at position ${r}, got '${t[r]}'`);let l={};if(r+=1,i(),r>=t.length)return l;if(t[r]==="}")return r+=1,l;for(;r<t.length;){if(i(),r>=t.length)return l;let d=n();if(i(),r>=t.length)return l;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,i(),r>=t.length||(l[d]=o(),i(),r>=t.length))return l;if(t[r]==="}")return r+=1,l;if(t[r]===","){r+=1;continue}throw new Error(`Expected ',' or '}' at position ${r}, got '${t[r]}'`)}return l}let u=o();if(i(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return u}function $n(e){try{return typeof e>"u"?null:yj(e)}catch{return null}}function Sh(e){switch(e){case"csv":return"text/csv";case"doc":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"docx":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"html":return"text/html";case"md":return"text/markdown";case"pdf":return"application/pdf";case"txt":return"text/plain";case"xls":return"application/vnd.ms-excel";case"xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"gif":return"image/gif";case"jpeg":return"image/jpeg";case"jpg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"flv":return"video/flv";case"mkv":return"video/mkv";case"mov":return"video/mov";case"mp4":return"video/mp4";case"mpeg":return"video/mpeg";case"mpg":return"video/mpg";case"three_gp":return"video/three_gp";case"webm":return"video/webm";case"wmv":return"video/wmv";default:return"application/octet-stream"}}function vj(e){if(Q(e.document)&&Q(e.document.source)){let t=Sh(Q(e.document)&&P(e.document.format)?e.document.format:"");if(Q(e.document.source)){if(Q(e.document.source.s3Location)&&P(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(zl(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(P(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(pt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,i)=>Q(i)&&P(i.text)?r+i.text:r,"")}}}return{type:"non_standard",value:e}}function bj(e){if(H(e,"image")&&Q(e.image)){let t=Sh(Q(e.image)&&P(e.image.format)?e.image.format:"");if(Q(e.image.source)){if(Q(e.image.source.s3Location)&&P(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(zl(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function wj(e){if(H(e,"video")&&Q(e.video)){let t=Sh(Q(e.video)&&P(e.video.format)?e.video.format:"");if(Q(e.video.source)){if(Q(e.video.source.s3Location)&&P(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(zl(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function ak(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"cache_point")){yield{type:"non_standard",value:i};continue}else if(H(i,"citations_content")&&Q(i.citationsContent)){yield{type:"text",text:pt(i.citationsContent.content)?i.citationsContent.content.reduce((n,a)=>Q(a)&&P(a.text)?n+a.text:n,""):"",annotations:pt(i.citationsContent.citations)?i.citationsContent.citations.reduce((n,a)=>{if(Q(a)){let o=pt(a.sourceContent)?a.sourceContent.reduce((c,u)=>Q(u)&&P(u.text)?c+u.text:c,""):"",s=_r(()=>{if(Q(a.location)){let c=a.location.documentChar||a.location.documentPage||a.location.documentChunk;if(Q(c))return{source:gr(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:gr(c.start)?c.start:void 0,endIndex:gr(c.end)?c.end:void 0}}return{}});n.push({type:"citation",citedText:o,...s})}return n},[]):[]};continue}else if(H(i,"document")&&Q(i.document)){yield vj(i);continue}else if(H(i,"guard_content")){yield{type:"non_standard",value:i};continue}else if(H(i,"image")&&Q(i.image)){yield bj(i);continue}else if(H(i,"reasoning_content")&&P(i.reasoningText)){yield{type:"reasoning",reasoning:i.reasoningText};continue}else if(H(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"tool_result")){yield{type:"non_standard",value:i};continue}else{if(H(i,"tool_call"))continue;if(H(i,"video")&&Q(i.video)){yield wj(i);continue}}yield{type:"non_standard",value:i}}}return Array.from(t())}var ok={translateContent:ak,translateContentChunk:ak};function sk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var ck={translateContent:sk,translateContentChunk:sk};function uk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"thinking")&&P(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(H(i,"inlineData")&&Q(i.inlineData)&&P(i.inlineData.mimeType)&&P(i.inlineData.data)){yield{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data};continue}else if(H(i,"functionCall")&&Q(i.functionCall)&&P(i.functionCall.name)&&Q(i.functionCall.args)){yield{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args};continue}else if(H(i,"functionResponse")){yield{type:"non_standard",value:i};continue}else if(H(i,"fileData")&&Q(i.fileData)&&P(i.fileData.mimeType)&&P(i.fileData.fileUri)){yield{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri};continue}else if(H(i,"executableCode")){yield{type:"non_standard",value:i};continue}else if(H(i,"codeExecutionResult")){yield{type:"non_standard",value:i};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var lk={translateContent:uk,translateContentChunk:uk};function dk(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let i of r){if(H(i,"reasoning")&&P(i.reasoning)){let n=_r(()=>{let a=r.indexOf(i);if(pt(e.additional_kwargs?.signatures)&&a>=0)return e.additional_kwargs.signatures.at(a)});P(n)?yield{type:"reasoning",reasoning:i.reasoning,signature:n}:yield{type:"reasoning",reasoning:i.reasoning};continue}else if(H(i,"thinking")&&P(i.thinking)){yield{type:"reasoning",reasoning:i.thinking,...i.signature?{signature:i.signature}:{}};continue}else if(H(i,"text")&&P(i.text)){yield{type:"text",text:i.text};continue}else if(H(i,"image_url")){if(P(i.image_url))if(i.image_url.startsWith("data:")){let n=i.image_url.match(/^data:([^;]+);base64,(.+)$/);n?yield{type:"image",data:n[2],mimeType:n[1]}:yield{type:"image",url:i.image_url}}else yield{type:"image",url:i.image_url};continue}else if(H(i,"media")&&P(i.mimeType)&&P(i.data)){yield{type:"file",mimeType:i.mimeType,data:i.data};continue}yield{type:"non_standard",value:i}}}return Array.from(t())}var fk={translateContent:dk,translateContentChunk:dk};function pk(e){let t=[],r=e.additional_kwargs?.reasoning;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let i=e.content,n=i.match(/<think>([\s\S]*?)<\/think>/);if(n){let a=n[1].trim();a.length>0&&t.push({type:"reasoning",reasoning:a}),i=i.replace(/<think>[\s\S]*?<\/think>/,"").trim()}i.length>0&&t.push({type:"text",text:i})}else for(let i of e.content)if(typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)){let n=i.text,a=n.match(/<think>([\s\S]*?)<\/think>/);if(a){let o=a[1].trim();o.length>0&&t.push({type:"reasoning",reasoning:o}),n=n.replace(/<think>[\s\S]*?<\/think>/,"").trim()}n.length>0&&t.push({type:"text",text:n})}for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var mk={translateContent:pk,translateContentChunk:pk};function hk(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var gk={translateContent:hk,translateContentChunk:hk};function _k(e){let t=[];if(Q(e.additional_kwargs?.reasoning)){let i=e.additional_kwargs.reasoning;if(pt(i.summary)){let n=i.summary.reduce((a,o)=>Q(o)&&P(o.text)?`${a}${o.text}`:a,"");n.length>0&&t.push({type:"reasoning",reasoning:n})}}let r=e.additional_kwargs?.reasoning_content;if(P(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let i of e.content)typeof i=="object"&&"type"in i&&i.type==="text"&&"text"in i&&P(i.text)&&t.push({type:"text",text:i.text});for(let i of e.tool_calls??[])t.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return t}var yk={translateContent:_k,translateContentChunk:_k};function vk(e){function*t(){let r=_r(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let i=e.additional_kwargs?.originalTextContentBlock;if(i?.thoughtSignature&&!e.content.some(n=>"thoughtSignature"in n)){let n=[...e.content];for(let a=n.length-1;a>=0;a--){let o=n[a];if(o.type==="text"&&!o.thought)return o.thoughtSignature=i.thoughtSignature,n}}return e.content}});for(let i of r){let n=_r(()=>H(i,"text")&&P(i.text)?{type:"text",text:i.text}:H(i,"inlineData")&&Q(i.inlineData)&&P(i.inlineData.mimeType)&&P(i.inlineData.data)?{type:"file",mimeType:i.inlineData.mimeType,data:i.inlineData.data}:H(i,"functionCall")&&Q(i.functionCall)&&P(i.functionCall.name)&&Q(i.functionCall.args)?{type:"tool_call",id:e.id,name:i.functionCall.name,args:i.functionCall.args}:H(i,"functionResponse")?{type:"non_standard",value:i}:H(i,"fileData")&&Q(i.fileData)&&P(i.fileData.mimeType)&&P(i.fileData.fileUri)?{type:"file",mimeType:i.fileData.mimeType,fileId:i.fileData.fileUri}:H(i,"executableCode")?{type:"non_standard",value:i}:H(i,"codeExecutionResult")?{type:"non_standard",value:i}:{type:"non_standard",value:i}),a=_r(()=>"thought"in i&&i.thought?{type:"reasoning",reasoning:n.type==="text"?n.text:"",reasoningContentBlock:n}:n),o={thought:i.thought,thoughtSignature:i.thoughtSignature,partMetadata:i.partMetadata,...a};for(let s in o)o[s]===void 0&&delete o[s];yield o}}return Array.from(t())}var bk={translateContent:vk,translateContentChunk:vk};globalThis.lc_block_translators_registry??=new Map([["anthropic",GS],["bedrock-converse",ok],["deepseek",ck],["google",bk],["google-genai",lk],["google-vertexai",fk],["groq",mk],["ollama",gk],["openai",qS],["xai",yk]]);function kh(e){return globalThis.lc_block_translators_registry.get(e)}function Zl(e,t){return He(e,t)??{}}function wk(e,t){let r={};return(e?.audio!==void 0||t?.audio!==void 0)&&(r.audio=(e?.audio??0)+(t?.audio??0)),(e?.image!==void 0||t?.image!==void 0)&&(r.image=(e?.image??0)+(t?.image??0)),(e?.video!==void 0||t?.video!==void 0)&&(r.video=(e?.video??0)+(t?.video??0)),(e?.document!==void 0||t?.document!==void 0)&&(r.document=(e?.document??0)+(t?.document??0)),(e?.text!==void 0||t?.text!==void 0)&&(r.text=(e?.text??0)+(t?.text??0)),r}function xj(e,t){let r={...wk(e,t)};return(e?.cache_read!==void 0||t?.cache_read!==void 0)&&(r.cache_read=(e?.cache_read??0)+(t?.cache_read??0)),(e?.cache_creation!==void 0||t?.cache_creation!==void 0)&&(r.cache_creation=(e?.cache_creation??0)+(t?.cache_creation??0)),r}function Sj(e,t){let r={...wk(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function Uo(e,t){return{input_tokens:(e?.input_tokens??0)+(t?.input_tokens??0),output_tokens:(e?.output_tokens??0)+(t?.output_tokens??0),total_tokens:(e?.total_tokens??0)+(t?.total_tokens??0),input_token_details:xj(e?.input_token_details,t?.input_token_details),output_token_details:Sj(e?.output_token_details,t?.output_token_details)}}var Ee=class extends Me{type="ai";tool_calls=[];invalid_tool_calls=[];usage_metadata;get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",usage_metadata:"usage_metadata"}}constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],additional_kwargs:{}};else{t=e;let r=t.additional_kwargs?.tool_calls,i=t.tool_calls;r!=null&&r.length>0&&(i===void 0||i.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
|
|
17
|
+
|
|
18
|
+
Please upgrade your packages to versions that set`,"message tool calls. e.g., `pnpm install @langchain/anthropic`,","pnpm install @langchain/openai`, etc."].join(" "));try{if(r!=null&&i===void 0){let[n,a]=Sc(r);t.tool_calls=n??[],t.invalid_tool_calls=a??[]}else t.tool_calls=t.tool_calls??[],t.invalid_tool_calls=t.invalid_tool_calls??[]}catch{t.tool_calls=[],t.invalid_tool_calls=[]}if(t.response_metadata!==void 0&&"output_version"in t.response_metadata&&t.response_metadata.output_version==="v1"&&(t.contentBlocks=t.content,t.content=void 0),t.contentBlocks!==void 0){t.tool_calls&&t.contentBlocks.push(...t.tool_calls.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})));let n=t.contentBlocks.filter(a=>a.type==="tool_call").filter(a=>!t.tool_calls?.some(o=>o.id===a.id&&o.name===a.name));n.length>0&&(t.tool_calls=n.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})))}}super(t),typeof t!="string"&&(this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=t.usage_metadata}static lc_name(){return"AIMessage"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=kh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls){let t=this.tool_calls.filter(r=>!e.some(i=>i.id===r.id&&i.name===r.name));e.push(...t.map(r=>({type:"tool_call",id:r.id,name:r.name,args:r.args})))}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};function Lo(e){return e._getType()==="ai"}function $c(e){return e._getType()==="ai"}var mt=class extends Bt{type="ai";tool_calls=[];invalid_tool_calls=[];tool_call_chunks=[];usage_metadata;constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0||e.tool_call_chunks.length===0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{let r=Vl(e.tool_call_chunks??[]);t={...e,tool_call_chunks:r.tool_call_chunks,tool_calls:r.tool_calls,invalid_tool_calls:r.invalid_tool_calls,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks",usage_metadata:"usage_metadata"}}static lc_name(){return"AIMessageChunk"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=kh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls&&typeof this.content!="string"){let t=this.content.filter(r=>r.type==="tool_call").map(r=>r.id);for(let r of this.tool_calls)r.id&&!t.includes(r.id)&&e.push({...r,type:"tool_call",id:r.id,name:r.name,args:r.args})}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){let t={content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:Zl(this.response_metadata,e.response_metadata),tool_call_chunks:[],tool_calls:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let i=$i(this.tool_call_chunks,e.tool_call_chunks);i!==void 0&&i.length>0&&(t.tool_call_chunks=i)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let i=$i(this.tool_calls,e.tool_calls);i!==void 0&&i.length>0&&(t.tool_calls=i)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=Uo(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};var qr=class xk extends Me{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return xk}constructor(t,r){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:r}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},wa=class extends Bt{static lc_name(){return"ChatMessageChunk"}type="generic";role;constructor(e,t){(typeof e=="string"||Array.isArray(e))&&(e={content:e,role:t}),super(e),this.role=e.role}concat(e){let t=this.constructor;return new t({content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}};function Sk(e){return e._getType()==="generic"}function kk(e){return e._getType()==="generic"}var xa=class extends Me{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Sa=class extends Bt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function $k(e){return e._getType()==="function"}function Ik(e){return e._getType()==="function"}var Ye=class extends Me{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},ka=class extends Bt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function Ek(e){return e.getType()==="human"}function Tk(e){return e.getType()==="human"}var Xr=class extends Me{type="remove";id;constructor(e){super({...e,content:[]}),this.id=e.id}get _printableFields(){return{...super._printableFields,id:this.id}}static isInstance(e){return super.isInstance(e)&&e.type==="remove"}};var Vt=class Gl extends Me{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Gl({content:At(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(Gl.isInstance(t))return new Gl({content:At(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},ei=class extends Bt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:At(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function Ak(e){return e._getType()==="system"}function Ck(e){return e._getType()==="system"}var Ok=e=>e();function kj(e){return Ii(e)?e:typeof e.id=="string"&&e.type==="function"&&typeof e.function=="object"&&e.function!==null&&"arguments"in e.function&&typeof e.function.arguments=="string"&&"name"in e.function&&typeof e.function.name=="string"?{id:e.id,args:JSON.parse(e.function.arguments),name:e.function.name,type:"tool_call"}:e}function $j(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function $h(e){let t,r;if($j(e)){let i=e.id.at(-1);i==="HumanMessage"||i==="HumanMessageChunk"?t="user":i==="AIMessage"||i==="AIMessageChunk"?t="assistant":i==="SystemMessage"||i==="SystemMessageChunk"?t="system":i==="FunctionMessage"||i==="FunctionMessageChunk"?t="function":i==="ToolMessage"||i==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:i,...n}=e;t=i,r=n}if(t==="human"||t==="user")return new Ye(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Ee(r);let a=i.map(kj);return new Ee({...n,tool_calls:a})}else{if(t==="system")return new Vt(r);if(t==="developer")return new Vt({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new Zt({...r,content:r.content,tool_call_id:r.tool_call_id,name:r.name});if(t==="remove"&&"id"in r&&typeof r.id=="string")return new Xr({...r,id:r.id});throw Yn(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
|
|
19
|
+
|
|
20
|
+
Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function St(e){if(typeof e=="string")return new Ye(e);if(Je(e))return e;if(Array.isArray(e)){let[t,r]=e;return $h({type:t,content:r})}else if(Bl(e)){let{role:t,...r}=e;return $h({...r,type:t})}else return $h(e)}function Ij(e){if(typeof e=="string")return e;switch(e.type){case"text":return e.text??"";case"text-plain":return e.text??"[text-plain file]";case"image":case"image_url":return"[image]";case"audio":case"input_audio":return"[audio]";case"video":return"[video]";case"file":return"[file]";case"reasoning":case"tool_call":case"tool_call_chunk":case"invalid_tool_call":case"server_tool_call":case"server_tool_call_chunk":case"server_tool_call_result":case"non_standard":return"";default:return e.type?`[${e.type}]`:""}}function Fo(e,t="Human",r="AI"){let i=[];for(let n of e){let a;if(n.type==="human")a=t;else if(n.type==="ai")a=r;else if(n.type==="system")a="System";else if(n.type==="tool")a="Tool";else if(n.type==="generic")a=n.role;else throw new Error(`Got unsupported message type: ${n.type}`);let o=n.name?`${n.name}, `:"",s=typeof n.content=="string"?n.content:Array.isArray(n.content)?n.content.map(Ij).filter(Boolean).join(""):"",c=`${a}: ${o}${s}`;if(n.type==="ai"){let u=n;u.tool_calls&&u.tool_calls.length>0?c+=JSON.stringify(u.tool_calls):u.additional_kwargs&&"function_call"in u.additional_kwargs&&(c+=JSON.stringify(u.additional_kwargs.function_call))}i.push(c)}return i.join(`
|
|
21
|
+
`)}function Ej(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function Ic(e){let t=Ej(e);switch(t.type){case"human":return new Ye(t.data);case"ai":return new Ee(t.data);case"system":return new Vt(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new xa(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new Zt(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new qr(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function Pk(e){return e.map(Ic)}function Nk(e){return e.map(t=>t.toDict())}function $a(e){let t=e._getType();if(t==="human")return new ka({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new mt({...r})}else{if(t==="system")return new ei({...e});if(t==="function")return new Sa({...e});if(qr.isInstance(e))return new wa({...e});throw new Error("Unknown message type.")}}function Vl(e){let t=e.reduce((n,a)=>{let o=n.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?n[o].push(a):n.push([a]),n},[]),r=[],i=[];for(let n of t){let a=null,o=n[0]?.name??"",s=n.map(l=>l.args||"").join("").trim(),c=s.length?s:"{}",u=n[0]?.id;try{if(a=$n(c),!u||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:o,args:a,id:u,type:"tool_call"})}catch{i.push({name:o,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var Rk=E({BaseCache:()=>Mk,InMemoryCache:()=>Ih,defaultHashKeyEncoder:()=>jk,deserializeStoredGeneration:()=>Tj,serializeGeneration:()=>Aj}),jk=(...e)=>Ro(e.join("_"));function Tj(e){return e.message!==void 0?{text:e.text,message:Ic(e.message)}:{text:e.text}}function Aj(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var Mk=class{keyEncoder=jk;makeDefaultKeyEncoder(e){this.keyEncoder=e}},Cj=new Map,Ih=class zk extends Mk{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new zk(Cj)}};var Dk=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Oj(e){return typeof e=="string"&&Dk.test(e)}var Ei=Oj;function Pj(e){if(!Ei(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Eh=Pj;var kt=[];for(let e=0;e<256;++e)kt.push((e+256).toString(16).slice(1));function Bo(e,t=0){return(kt[e[t+0]]+kt[e[t+1]]+kt[e[t+2]]+kt[e[t+3]]+"-"+kt[e[t+4]]+kt[e[t+5]]+"-"+kt[e[t+6]]+kt[e[t+7]]+"-"+kt[e[t+8]]+kt[e[t+9]]+"-"+kt[e[t+10]]+kt[e[t+11]]+kt[e[t+12]]+kt[e[t+13]]+kt[e[t+14]]+kt[e[t+15]]).toLowerCase()}var Th,Nj=new Uint8Array(16);function Zo(){if(!Th){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Th=crypto.getRandomValues.bind(crypto)}return Th(Nj)}function Rj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Uk="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Lk="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ah(e,t,r,i,n,a){let o=typeof r=="string"?Rj(r):r,s=typeof i=="string"?Eh(i):i;if(typeof i=="string"&&(i=Eh(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a=a||0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Bo(c)}var jj=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ch={randomUUID:jj};function Mj(e,t,r){if(Ch.randomUUID&&!t&&!e)return Ch.randomUUID();e=e||{};let i=e.random??e.rng?.()??Zo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Bo(i)}var Oh=Mj;function zj(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Ph(e,t){return e<<t|e>>>32-t}function Dj(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/Math.pow(2,32),o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Ph(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let _=Math.floor(m/20),v=Ph(u,5)+zj(_,l,d,f)+p+t[_]+c[m]>>>0;p=f,f=d,d=Ph(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Fk=Dj;function Nh(e,t,r,i){return Ah(80,Fk,e,t,r,i)}Nh.DNS=Uk;Nh.URL=Lk;var Hl=Nh;var Rh={};function Uj(e,t,r){let i;if(e)i=Bk(e.random??e.rng?.()??Zo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Zo();Lj(Rh,n,a),i=Bk(a,Rh.msecs,Rh.seq,t,r)}return t??Bo(i)}function Lj(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Bk(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Or=Uj;var Zk=E({BaseCallbackHandler:()=>Yr,callbackHandlerPrefersStreaming:()=>Ec,isBaseCallbackHandler:()=>jh}),Bj=class{};function Ec(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}var Yr=class extends Bj{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,No(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Ft("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return at.prototype.toJSON.call(this)}toJSONNotImplemented(){return at.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Yr{name=Or();constructor(){super(),Object.assign(this,e)}}return new t}},jh=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var Vk=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Zj(e){return typeof e=="string"&&Vk.test(e)}var Tc=Zj;function Vj(e){if(!Tc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Jl=Vj;var $t=[];for(let e=0;e<256;++e)$t.push((e+256).toString(16).slice(1));function Vo(e,t=0){return($t[e[t+0]]+$t[e[t+1]]+$t[e[t+2]]+$t[e[t+3]]+"-"+$t[e[t+4]]+$t[e[t+5]]+"-"+$t[e[t+6]]+$t[e[t+7]]+"-"+$t[e[t+8]]+$t[e[t+9]]+"-"+$t[e[t+10]]+$t[e[t+11]]+$t[e[t+12]]+$t[e[t+13]]+$t[e[t+14]]+$t[e[t+15]]).toLowerCase()}var Gj=new Uint8Array(16);function Go(){return crypto.getRandomValues(Gj)}function Hj(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Jj(e,t,r)}function Jj(e,t,r){e=e||{};let i=e.random??e.rng?.()??Go();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Vo(i)}var Ia=Hj;function Kj(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Mh(e,t){return e<<t|e>>>32-t}function Wj(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Mh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],f=r[3],p=r[4];for(let m=0;m<80;++m){let _=Math.floor(m/20),v=Mh(u,5)+Kj(_,l,d,f)+p+t[_]+c[m]>>>0;p=f,f=d,d=Mh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+p>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Gk=Wj;function qj(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var zh="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Dh="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Uh(e,t,r,i,n,a){let o=typeof r=="string"?qj(r):r,s=typeof i=="string"?Jl(i):i;if(typeof i=="string"&&(i=Jl(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Vo(c)}function Lh(e,t,r,i){return Uh(80,Gk,e,t,r,i)}Lh.DNS=zh;Lh.URL=Dh;var Fh=Lh;var Bh={};function Xj(e,t,r){let i;if(e)i=Hk(e.random??e.rng?.()??Go(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Go();Yj(Bh,n,a),i=Hk(a,Bh.msecs,Bh.seq,t,r)}return t??Vo(i)}function Yj(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Hk(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Ho=Xj;var Jk="gen_ai.operation.name",Kk="gen_ai.system",Zh="gen_ai.request.model",Wk="gen_ai.response.model",Vh="gen_ai.usage.input_tokens",Gh="gen_ai.usage.output_tokens",Hh="gen_ai.usage.total_tokens",qk="gen_ai.request.max_tokens",Xk="gen_ai.request.temperature",Yk="gen_ai.request.top_p",Qk="gen_ai.request.frequency_penalty",e$="gen_ai.request.presence_penalty",t$="gen_ai.response.finish_reasons",r$="gen_ai.prompt",n$="gen_ai.completion",i$="gen_ai.request.extra_query",a$="gen_ai.request.extra_body",o$="gen_ai.serialized.name",s$="gen_ai.serialized.signature",c$="gen_ai.serialized.doc",u$="gen_ai.response.id",l$="gen_ai.response.service_tier",d$="gen_ai.response.system_fingerprint",f$="gen_ai.usage.input_token_details",p$="gen_ai.usage.output_token_details",m$="langsmith.trace.session_id",h$="langsmith.trace.session_name",g$="langsmith.span.kind",_$="langsmith.trace.name",y$="langsmith.metadata",Jh="langsmith.span.tags";var v$="langsmith.request.streaming",b$="langsmith.request.headers";var Kh="langsmith.usage_metadata";var t4=(...e)=>fetch(...e),r4,w$=Symbol.for("ls:fetch_implementation");var x$=()=>globalThis[w$]===void 0?!0:r4??!1,S$=e=>async(...t)=>{if(e||Ze("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[w$]??t4)(...t);return(e||Ze("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Ac=()=>Ze("PROJECT")??_t("LANGCHAIN_SESSION")??"default";var k$={};function Ea(e){k$[e]||(console.warn(e),k$[e]=!0)}var N=e=>BigInt(e),T$=N("0x9E3779B1"),A$=N("0x85EBCA77"),n4=N("0xC2B2AE3D"),Ti=N("0x9E3779B185EBCA87"),Ta=N("0xC2B2AE3D27D4EB4F"),C$=N("0x165667B19E3779F9"),Yh=N("0x85EBCA77C2B2AE63"),i4=N("0x27D4EB2F165667C5"),a4=N("0x165667919E3779F9"),o4=N("0x9FB21C651E98DF25");function s4(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var In=s4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Ko=(N(1)<<N(128))-N(1),me=(N(1)<<N(64))-N(1),Xl=(N(1)<<N(32))-N(1),ti=64,O$=ti/8,c4=8,Kl=4;function ze(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Ve(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Jo(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function Wh(e,t=0){return e[t]}var u4=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),l4=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),d4=(e,t)=>(e&Xl)*(t&Xl)&me,Wo=e=>{if(!e)throw new Error("Assert failed")};function f4(e,t){return(e<<t|e>>N(32)-t)&Xl}function P$(e,t,r){for(let i=0;i<O$;i++){let n=Ve(t,i*8),a=n^Ve(r,i*8);e[i^1]+=n,e[i]+=d4(a,a>>N(32))}return e}function $$(e,t,r,i){for(let n=0;n<i;n++)P$(e,ze(t,n*ti),ze(r,n*8));return e}function p4(e,t){for(let r=0;r<O$;r++){let i=Ve(t,r*8),n=e[r];n=qh(n,N(47)),n^=i,n*=T$,e[r]=n&me}return e}function Wl(e,t){return N$(e[0]^Ve(t,0),e[1]^Ve(t,c4))}function I$(e,t,r){let i=r;return i+=Wl(e.slice(0),ze(t,0*Kl)),i+=Wl(e.slice(2),ze(t,4*Kl)),i+=Wl(e.slice(4),ze(t,8*Kl)),i+=Wl(e.slice(6),ze(t,12*Kl)),En(i&me)}function m4(e,t,r,i,n){let a=Math.floor((r.byteLength-ti)/8),o=ti*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=$$(e,ze(t,c*o),r,a),e=n(e,ze(r,r.byteLength-ti));{let c=Math.floor((t.byteLength-1-o*s)/ti);e=$$(e,ze(t,s*o),r,c),e=i(e,ze(t,t.byteLength-ti),ze(r,r.byteLength-ti-7))}return e}function h4(e,t,r){let i=new BigUint64Array([n4,Ti,Ta,C$,Yh,A$,i4,T$]);Wo(e.length>128),i=m4(i,e,t,P$,p4),Wo(i.length*8==64);{let n=I$(i,ze(t,11),N(e.byteLength)*Ti&me);return I$(i,ze(t,t.byteLength-ti-11),~(N(e.byteLength)*Ta)&me)<<N(64)|n}}function N$(e,t){let r=e*t&Ko;return r&me^r>>N(64)}function E$(e,t,r){return N$((Ve(e,0)^Ve(t,0)+r)&me,(Ve(e,8)^Ve(t,8)-r)&me)}function ql(e,t,r,i,n){let a=e&me,o=e>>N(64)&me;return a+=E$(t,i,n),a^=Ve(r,0)+Ve(r,8),a&=me,o+=E$(r,ze(i,16),n),o^=Ve(t,0)+Ve(t,8),o&=me,o<<N(64)|a}function En(e){return e^=e>>N(37),e*=a4,e&=me,e^=e>>N(32),e}function Yl(e){return e^=e>>N(33),e*=Ta,e&=me,e^=e>>N(29),e*=C$,e&=me,e^=e>>N(32),e}function g4(e,t,r){let i=e.byteLength;Wo(i>0&&i<=3);let n=N(Wh(e,i-1))|N(i<<8)|N(Wh(e,0)<<16)|N(Wh(e,i>>1)<<24),a=(N(Jo(t,0))^N(Jo(t,4)))+r,o=(n^a)&me,s=(N(Jo(t,8))^N(Jo(t,12)))-r,c=(f4(l4(n),N(13))^s)&me;return(Yl(c)&me)<<N(64)|Yl(o)}function qh(e,t){return e^e>>t}function _4(e,t,r){let i=e.byteLength;Wo(i>=4&&i<=8);{let n=Jo(e,0),a=Jo(e,i-4),o=N(n)|N(a)<<N(32),s=(Ve(t,16)^Ve(t,24))+r&me,u=(o^s)*(Ti+(N(i)<<N(2)))&Ko;return u+=(u&me)<<N(65),u&=Ko,u^=u>>N(67),qh(qh(u&me,N(35))*o4&me,N(28))|En(u>>N(64))<<N(64)}}function y4(e,t,r){let i=e.byteLength;Wo(i>=9&&i<=16);{let n=(Ve(t,32)^Ve(t,40))+r&me,a=(Ve(t,48)^Ve(t,56))-r&me,o=Ve(e),s=Ve(e,i-8),c=(o^s^n)*Ti,u=(c&me)+(N(i-1)<<N(54));c=c&(Ko^me)|u,s^=a,c+=s+(s&Xl)*(A$-N(1))<<N(64),c&=Ko,c^=u4(c>>N(64));let l=(c&me)*Ta;return l+=(c>>N(64))*Ta<<N(64),l&=Ko,En(l&me)|En(l>>N(64))<<N(64)}}function v4(e,t){let r=e.byteLength;return Wo(r<=16),r>8?y4(e,In,t):r>=4?_4(e,In,t):r>0?g4(e,In,t):Yl(t^Ve(In,64)^Ve(In,72))|Yl(t^Ve(In,80)^Ve(In,88))<<N(64)}function Xh(e){return~e+N(1)&me}function b4(e,t,r){let i=N(e.byteLength)*Ti&me,n=N(e.byteLength-1)/N(32);for(;n>=0;){let s=Number(n);i=ql(i,ze(e,16*s),ze(e,e.byteLength-16*(s+1)),ze(t,32*s),r),n--}let a=i+(i>>N(64))&me;a=En(a);let o=(i&me)*Ti+(i>>N(64))*Yh+(N(e.byteLength)-r&me)*Ta;return o&=me,o=Xh(En(o)),a|o<<N(64)}function w4(e,t,r){let i=N(e.byteLength)*Ti&me;for(let o=32;o<160;o+=32)i=ql(i,ze(e,o-32),ze(e,o-16),ze(t,o-32),r);i=En(i&me)|En(i>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)i=ql(i,ze(e,o-32),ze(e,o-16),ze(t,3+o-160),r);i=ql(i,ze(e,e.byteLength-16),ze(e,e.byteLength-32),ze(t,103),Xh(r));let n=i+(i>>N(64))&me;n=En(n);let a=(i&me)*Ti+(i>>N(64))*Yh+(N(e.byteLength)-r&me)*Ta;return a&=me,a=Xh(En(a)),n|a<<N(64)}function R$(e,t=N(0)){let r=e.byteLength;return r<=16?v4(e,t):r<=128?b4(e,In,t):r<=240?w4(e,In,t):h4(e,In,t)}function j$(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&me,n=e>>N(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var M$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function le(e,t){if(!M$.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Ql(e){let t=typeof e=="string"?Date.parse(e):e;return Ho({msecs:t,seq:0})}function x4(e){if(!M$.test(e))return null;let t=e[14];return parseInt(t,16)}function S4(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function k4(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var $4=new TextEncoder;function I4(e){let t=$4.encode(e),r=R$(t);return j$(r)}function Cc(e,t){let r=`${e}:${t}`,i=I4(r),n=new Uint8Array(16);if(x4(e)===7){let o=S4(e);n.set(o.slice(0,6),0)}else{let o=Date.now();n[0]=o/1099511627776&255,n[1]=o/4294967296&255,n[2]=o/16777216&255,n[3]=o/65536&255,n[4]=o/256&255,n[5]=o&255}return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),k4(n)}var Aa={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function z$(e){}async function ed(e,t){}async function D$(e){return[]}async function U$(e){return{size:0}}function qo(e){return!1}function td(e){return""}function E4(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var rd=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let i=Aa.dirname(t);qo(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw qo(n)&&void 0,a}}load(t){if(!qo(t))return 0;let r;try{let a=td(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:n};this.cache.set(a,s),i+=1}return i}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,i]of this.cache.entries())E4(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},nd=new rd;var id="0.6.3";var An,T4=()=>typeof window<"u"&&typeof window.document<"u",A4=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",C4=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),Z$=()=>typeof Deno<"u",O4=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!Z$(),Oc=()=>An||(typeof Bun<"u"?An="bun":T4()?An="browser":O4()?An="node":A4()?An="webworker":C4()?An="jsdom":Z$()?An="deno":An="other",An),Qh;function ad(){if(Qh===void 0){let e=Oc(),t=N4();Qh={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:id,...t}}return Qh}function tg(){let e=P4(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_CONFIG_FILE","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!i.toLowerCase().includes("key")&&!i.toLowerCase().includes("secret")&&!i.toLowerCase().includes("token")&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function P4(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function _t(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Ze(e){return _t(`LANGSMITH_${e}`)||_t(`LANGCHAIN_${e}`)}var eg;function N4(){if(eg!==void 0)return eg;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let i=_t(r);i!==void 0&&(t[r]=i)}return eg=t,t}function F$(){return _t("OTEL_ENABLED")==="true"||Ze("OTEL_ENABLED")==="true"}var B$=new Set(["langsmith","otel"]);function od(e){if(e!==void 0)return e;let t=Ze("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!B$.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...B$].sort().join(", ")}`);return F$()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return F$()?"otel":"langsmith"}var ig=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&od()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},ag=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new ig})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},og=class{active(){return{}}with(t,r){return r()}},rg=Symbol.for("ls:otel_trace"),ng=Symbol.for("ls:otel_context"),V$=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),R4=new ag,j4=new og,sg=class{getTraceInstance(){return globalThis[rg]??R4}getContextInstance(){return globalThis[ng]??j4}initializeGlobalInstances(t){globalThis[rg]===void 0&&(globalThis[rg]=t.trace),globalThis[ng]===void 0&&(globalThis[ng]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[V$]=t}getDefaultOTLPTracerComponents(){return globalThis[V$]??void 0}},cg=new sg;function sd(){return cg.getTraceInstance()}function G$(){return cg.getContextInstance()}function H$(){return cg.getDefaultOTLPTracerComponents()}var M4={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function z4(e){return M4[e]||e}function D4(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var cd=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&sd().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(g$,r.run_type);let s=z4(r.run_type||"chain");t.setAttribute(Jk,s)}"name"in r&&r.name&&t.setAttribute(_$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(m$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(h$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(Zh,n),r.extra?.metadata?.usage_metadata&&typeof r.extra.metadata.usage_metadata=="object"&&t.setAttribute(Kh,JSON.stringify(r.extra.metadata.usage_metadata)),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(Vh,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(Gh,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(Hh,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${y$}.${s}`,D4(c)?String(c):JSON.stringify(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(Jh,o.join(", ")):o&&t.setAttribute(Jh,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(o$,String(s.name)),s.signature&&t.setAttribute(s$,String(s.signature)),s.doc&&t.setAttribute(c$,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let a=n.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?i="anthropic":a.includes("bedrock")?i="aws.bedrock":a.includes("azure")&&a.includes("openai")?i="az.ai.openai":a.includes("azure")&&a.includes("inference")?i="az.ai.inference":a.includes("cohere")?i="cohere":a.includes("deepseek")?i="deepseek":a.includes("gemini")?i="gemini":a.includes("groq")?i="groq":a.includes("watson")||a.includes("ibm")?i="ibm.watsonx.ai":a.includes("mistral")?i="mistral_ai":a.includes("gpt")||a.includes("openai")?i="openai":a.includes("perplexity")||a.includes("sonar")?i="perplexity":a.includes("vertex")?i="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(i="xai")}t.setAttribute(Kk,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(qk,i.max_tokens),i.temperature!==void 0&&t.setAttribute(Xk,i.temperature),i.top_p!==void 0&&t.setAttribute(Yk,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(Qk,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute(e$,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(Zh,i.model),i.stream!==void 0&&t.setAttribute(v$,i.stream),i.extra_headers&&t.setAttribute(b$,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(i$,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(a$,JSON.stringify(i.extra_body))),t.setAttribute(r$,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(Vh,n[0]),t.setAttribute(Gh,n[1]),t.setAttribute(Hh,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(Wk,String(i.model)),i.id&&t.setAttribute(u$,i.id),i.choices&&Array.isArray(i.choices)){let a=i.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(t$,a.join(", "))}if(i.service_tier&&t.setAttribute(l$,i.service_tier),i.system_fingerprint&&t.setAttribute(d$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;t.setAttribute(Kh,JSON.stringify(a)),a.input_token_details&&t.setAttribute(f$,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(p$,JSON.stringify(a.output_token_details))}}t.setAttribute(n$,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let o of i){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let n=t.generations||[];if(!Array.isArray(n))return null;let a=Array.isArray(n[0])?n.flat():n;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var U4=Object.prototype.toString,L4=e=>U4.call(e)==="[object Error]",F4=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function ug(e){if(!(e&&L4(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:F4.has(r)}function B4(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function ud(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var lg=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function Z4(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function J$(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function V4({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof lg)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),J$(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=J$(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!ug(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=Z4(r,n),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let _=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",_),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",_),p()},f);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",_,{once:!0})}),n.signal?.throwIfAborted(),!0}async function dg(e,t={}){if(t={...t},B4(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,ud("factor",t.factor,{min:0,allowInfinity:!1}),ud("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),ud("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),ud("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await V4({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var hd=pa(md(),1),nI="default"in hd.default?hd.default.default:hd.default;var Q4=[408,425,429,500,502,503,504],Nc=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new nI({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let a=this.onFailedResponseHook,o=this.queue.add(()=>dg(()=>r(...i).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let u="response"in s?s.response:void 0;if(a&&await a(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!Q4.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function yg(e){return typeof e?._getType=="function"}function vg(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function _d(e){return`Invalid prompt identifier format: "${e}". Expected one of:
|
|
22
|
+
- "prompt-name" (for private prompts)
|
|
23
|
+
- "owner/prompt-name" (for prompts with explicit owner)
|
|
24
|
+
- "prompt-name:commit-hash" (with commit reference)
|
|
25
|
+
- "owner/prompt-name:commit-hash" (with owner and commit)`}var bg=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithConflictError",this.status=409}},wg=class extends Error{constructor(t){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="LangSmithNotFoundError",this.status=404}};function yd(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function iI(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function q(e,t,r){let i;if(e.ok){r&&(i=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(i="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{let s=new Error(`${e.status} ${e.statusText}`);throw s.status=e?.status,s}if(i===void 0)try{i=await e.text()}catch{i=""}let n=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${i}`;if(e.status===404)throw new wg(n);if(e.status===409)throw new bg(n);let a=new Error(n);throw a.status=e.status,a}var aI="ERR_CONFLICTING_ENDPOINTS",gd=class extends Error{constructor(){super("You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT and LANGSMITH_RUNS_ENDPOINTS."),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:aI}),this.name="ConflictingEndpointsError"}};function oI(e){return typeof e=="object"&&e!==null&&e.code===aI}function Ot(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(_d(e));let[t,r]=e.split(":"),i=r||"latest";if(t.includes("/")){let[n,a]=t.split("/",2);if(!n||!a)throw new Error(_d(e));return[n,a,i]}else{if(!t)throw new Error(_d(e));return["-",t,i]}}var vd="https://api.smith.langchain.com",eM="langsmith-cli",tM=6e4,rM=1e4;function nM(){let e=Oc();return e==="browser"||e==="webworker"}function iM(){let e=_t("LANGSMITH_CONFIG_FILE");if(e)return e;let t=_t("HOME")??_t("USERPROFILE");if(t)return Aa.join(t,".langsmith","config.json")}function aM(e){let t=_t("LANGSMITH_PROFILE");if(t)return t;if(e.current_profile)return e.current_profile;if(e.profiles?.default)return"default"}function oM(){if(nM())return;let e=iM();if(!(!e||!qo(e)))try{let t=JSON.parse(td(e)),r=aM(t),i=r?t.profiles?.[r]:void 0;return!r||!i?void 0:{configPath:e,config:t,profileName:r,profile:i}}catch{return}}function Pr(e){return e!=null&&e.trim()!==""}function Ai(e){return e?.trim().replace(/^["']|["']$/g,"")}function sM(e){let t=e.oauth;if(!t?.refresh_token)return!1;if(!t.access_token)return!0;if(!t.expires_at)return!1;let r=Date.parse(t.expires_at);return Number.isNaN(r)?!1:r<=Date.now()+tM}function cM(e){let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);let r="/api/v1";return t.endsWith(r)?t.slice(0,-r.length):t}function uM(e,t){e.oauth??={},t.access_token&&(e.oauth.access_token=t.access_token),t.refresh_token&&(e.oauth.refresh_token=t.refresh_token),typeof t.expires_in=="number"&&t.expires_in>0&&(e.oauth.expires_at=new Date(Date.now()+t.expires_in*1e3).toISOString())}function sI(e){return e.reason??new Error("The operation was aborted.")}async function lM(e,t){if(!t)return e;if(t.aborted)throw sI(t);let r,i=new Promise((n,a)=>{let o=()=>{a(sI(t))};t.addEventListener("abort",o,{once:!0}),r=()=>{t.removeEventListener("abort",o)}});try{return await Promise.race([e,i])}finally{r?.()}}function cI(){let e=oM(),t=e?.profile;if(!e||!t)return{};let r=Ai(t.api_key),i=Ai(t.oauth?.access_token),n=Ai(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:r,workspaceId:t.workspace_id,oauthAccessToken:i,oauthRefreshToken:n,profileAuth:r||i||n?new xg(e):void 0}}var xg=class{constructor(t){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"refreshPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedAuthorizationValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.rememberProfileAuthHeader(this.currentAuthHeader())}currentAuthHeader(){let t=dM(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,r){sM(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await lM(this.refreshPromise,r));let i=uI(this.state.profile);return this.rememberProfileAuthHeader(i),i}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}async refreshOAuthToken(t){let r=this.state.profile.oauth?.refresh_token;if(!r)return;let i=Ai(this.state.profile.api_url)??vd;try{let n=new URLSearchParams({grant_type:"refresh_token",client_id:eM,refresh_token:r}),a=await t(`${cM(i)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString(),signal:AbortSignal.timeout(rM)});if(!a.ok)return;let o=await a.json();if(!o.access_token)return;uM(this.state.profile,o),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await ed(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
|
|
26
|
+
`)}catch{return}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function dM(e){let t=Ai(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!Ai(e.oauth?.refresh_token))return uI(e)}function uI(e){let t=Ai(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let r=Ai(e.api_key);if(r)return{name:"x-api-key",value:r}}var lI="[...]",fM={result:"[Circular]"},wd=[],Xo=[],pM=new TextEncoder;function mM(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function bd(e){return pM.encode(e)}function dI(e){if(e&&typeof e=="object"&&e!==null){if(e instanceof Map)return Object.fromEntries(e);if(e instanceof Set)return Array.from(e);if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(e instanceof Error)return{name:e.name,message:e.message}}else if(typeof e=="bigint")return e.toString();return e}function hM(e){return function(t,r){if(e){let i=e.call(this,t,r);if(i!==void 0)return i}return dI(r)}}function fI(e){try{let n=function(l){let d=i(l);return d>r&&(r=d),d+2},a=function(l){return l===0?2:2+l*4},o=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"},s=function(l){return l===void 0||typeof l=="function"||typeof l=="symbol"?4:c(l)},c=function(l){if(l===null)return 4;if(l===void 0)return 0;let d=typeof l;if(d==="boolean")return 5;if(d==="number")return Number.isFinite(l)?l.toString().length:4;if(d==="bigint")return l.toString().length+2;if(d==="string")return n(l);if(d==="function"||d==="symbol")return 0;let f=l;if(f instanceof Date)return 26;if(f instanceof RegExp)return i(f.toString())+2;if(f instanceof Error){let m=f.name??"",_=f.message??"";return 22+i(m)+i(_)}if(typeof Buffer<"u"&&f instanceof Buffer)return 28+a(f.byteLength);if(ArrayBuffer.isView(f)){if(f instanceof DataView)return 2;let m=f.length??0,v=f instanceof Float32Array||f instanceof Float64Array?30:12;return 2+m*v}if(f instanceof ArrayBuffer)return 2;if(t.has(f))return 24;if(typeof f.toJSON=="function"){let m;try{m=f.toJSON("")}catch{return 16}t.add(f);let _=c(m);return t.delete(f),_}t.add(f);let p;if(Array.isArray(f)){p=2;let m=f.length;for(let _=0;_<m;_++)p+=s(f[_]),_<m-1&&(p+=1)}else if(f instanceof Map){p=2;let m=0;for(let[_,v]of f){if(o(v))continue;m>0&&(p+=1);let x=typeof _=="string"?_:String(_);p+=i(x)+3,p+=c(v),m++}}else if(f instanceof Set){p=2;let m=0;for(let _ of f)m>0&&(p+=1),p+=s(_),m++}else{p=2;let m=0,_=Object.keys(f);for(let v=0;v<_.length;v++){let x=_[v],w=f[x];o(w)||(m>0&&(p+=1),p+=i(x)+3,p+=c(w),m++)}}return t.delete(f),p},t=new Set,r=0,i=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?l=>Buffer.byteLength(l,"utf8"):l=>l.length;return{size:c(e),maxStringLen:r}}catch{return{size:Pt(e).length,maxStringLen:0}}}function Pt(e,t,r,i,n){try{let a=JSON.stringify(e,hM(r),i);return bd(a)}catch(a){if(!a.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
|
|
27
|
+
Context: ${t}`:""}`),bd("[Unserializable]");Ze("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
|
|
28
|
+
Context: ${t}`:""}`),typeof n>"u"&&(n=mM()),kg(e,"",0,[],void 0,0,n);let o;try{Xo.length===0?o=JSON.stringify(e,r,i):o=JSON.stringify(e,gM(r),i)}catch{return bd("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;wd.length!==0;){let s=wd.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return bd(o)}}function Sg(e,t,r,i){var n=Object.getOwnPropertyDescriptor(i,r);n.get!==void 0?n.configurable?(Object.defineProperty(i,r,{value:e}),wd.push([i,r,t,n])):Xo.push([t,r,e]):(i[r]=e,wd.push([i,r,t]))}function kg(e,t,r,i,n,a,o){a+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<i.length;s++)if(i[s]===e){Sg(fM,e,t,n);return}if(typeof o.depthLimit<"u"&&a>o.depthLimit){Sg(lI,e,t,n);return}if(typeof o.edgesLimit<"u"&&r+1>o.edgesLimit){Sg(lI,e,t,n);return}if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)kg(e[s],s,s,i,e,a,o);else{e=dI(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];kg(e[u],u,s,i,e,a,o)}}i.pop()}}function gM(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Xo.length>0)for(var i=0;i<Xo.length;i++){var n=Xo[i];if(n[1]===t&&n[0]===r){r=n[2],Xo.splice(i,1);break}}return e.call(this,t,r)}}var yM=`
|
|
29
|
+
const { parentPort } = require("worker_threads");
|
|
30
|
+
|
|
31
|
+
const CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
|
|
32
|
+
|
|
33
|
+
function serializeWellKnownTypes(val) {
|
|
34
|
+
if (val && typeof val === "object") {
|
|
35
|
+
if (val instanceof Map) return Object.fromEntries(val);
|
|
36
|
+
if (val instanceof Set) return Array.from(val);
|
|
37
|
+
if (val instanceof Date) return val.toISOString();
|
|
38
|
+
if (val instanceof RegExp) return val.toString();
|
|
39
|
+
if (val instanceof Error) return { name: val.name, message: val.message };
|
|
40
|
+
} else if (typeof val === "bigint") {
|
|
41
|
+
return val.toString();
|
|
42
|
+
}
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function defaultReplacer(_key, val) {
|
|
47
|
+
return serializeWellKnownTypes(val);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Decirculate in-place: replace circular refs with { result: "[Circular]" }
|
|
51
|
+
// then restore after stringify. Mirrors fast-safe-stringify's decirc().
|
|
52
|
+
const restoreStack = [];
|
|
53
|
+
function decirc(val, k, stack, parent) {
|
|
54
|
+
if (typeof val === "object" && val !== null) {
|
|
55
|
+
for (let i = 0; i < stack.length; i++) {
|
|
56
|
+
if (stack[i] === val) {
|
|
57
|
+
const orig = parent[k];
|
|
58
|
+
parent[k] = CIRCULAR_REPLACE_NODE;
|
|
59
|
+
restoreStack.push([parent, k, orig]);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
stack.push(val);
|
|
64
|
+
if (Array.isArray(val)) {
|
|
65
|
+
for (let i = 0; i < val.length; i++) decirc(val[i], i, stack, val);
|
|
66
|
+
} else {
|
|
67
|
+
const normalized = serializeWellKnownTypes(val);
|
|
68
|
+
// Only recurse into normalized if it's still an object (arrays/objects),
|
|
69
|
+
// else it was replaced with a primitive (e.g. Date -> string).
|
|
70
|
+
if (normalized === val) {
|
|
71
|
+
const keys = Object.keys(val);
|
|
72
|
+
for (let i = 0; i < keys.length; i++) decirc(val[keys[i]], keys[i], stack, val);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
stack.pop();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function serialize(obj) {
|
|
80
|
+
try {
|
|
81
|
+
return JSON.stringify(obj, defaultReplacer);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (!String(e && e.message).includes("Converting circular structure to JSON")) {
|
|
84
|
+
return "[Unserializable]";
|
|
85
|
+
}
|
|
86
|
+
decirc(obj, "", [], { "": obj });
|
|
87
|
+
try {
|
|
88
|
+
return JSON.stringify(obj, defaultReplacer);
|
|
89
|
+
} catch (_) {
|
|
90
|
+
return "[unable to serialize, circular reference is too complex to analyze]";
|
|
91
|
+
} finally {
|
|
92
|
+
while (restoreStack.length) {
|
|
93
|
+
const [p, k, v] = restoreStack.pop();
|
|
94
|
+
p[k] = v;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
parentPort.on("message", (msg) => {
|
|
101
|
+
const { id, op, payload } = msg;
|
|
102
|
+
try {
|
|
103
|
+
if (op === "serialize") {
|
|
104
|
+
const str = serialize(payload);
|
|
105
|
+
const buf = Buffer.from(str, "utf8");
|
|
106
|
+
// Slice into its own ArrayBuffer so we can transfer without dragging
|
|
107
|
+
// unrelated bytes from any shared pool buffer.
|
|
108
|
+
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
109
|
+
parentPort.postMessage({ id, bytes: ab, length: buf.byteLength }, [ab]);
|
|
110
|
+
} else if (op === "ping") {
|
|
111
|
+
parentPort.postMessage({ id });
|
|
112
|
+
} else {
|
|
113
|
+
parentPort.postMessage({ id, error: "unknown op: " + op });
|
|
114
|
+
}
|
|
115
|
+
} catch (e) {
|
|
116
|
+
parentPort.postMessage({ id, error: String((e && e.message) || e) });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
`,Ig=class{constructor(){Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startPromise",{enumerable:!0,configurable:!0,writable:!0,value:null})}async ensureStarted(){if(this.disabled)return!1;if(this.worker!==null)return!0;if(this.startPromise!==null)return this.startPromise;this.startPromise=this._start();try{return await this.startPromise}finally{this.startPromise=null}}async _start(){if(!!1||null===null)return this.disabled=!0,!1;try{let t=new null(yM,{eval:!0});return t.on("message",r=>{let i=this.pending.get(r.id);i&&(this.pending.delete(r.id),r.error?i.reject(new Error(r.error)):r.bytes&&typeof r.length=="number"?i.resolve(new Uint8Array(r.bytes,0,r.length)):i.reject(new Error("worker returned malformed message")))}),t.on("error",r=>{for(let[,i]of this.pending)i.reject(r);this.pending.clear(),this.disabled=!0,this.worker=null}),t.on("exit",r=>{for(let[,i]of this.pending)i.reject(new Error(`worker exited with code ${r}`));this.pending.clear(),this.worker=null}),t.unref(),this.worker=t,!0}catch{return this.disabled=!0,!1}}async serialize(t){if(!await this.ensureStarted())return null;let i=this.nextId++;return new Promise((n,a)=>{this.pending.set(i,{resolve:n,reject:a});try{this.worker.postMessage({id:i,op:"serialize",payload:t})}catch(o){this.pending.delete(i),a(o)}})}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null);for(let[,t]of this.pending)t.reject(new Error("worker terminated"));this.pending.clear()}},$g=null;function mI(){return $g===null&&($g=new Ig),$g}var vM=64*1024,bM=2048;function hI(e,t=vM,r=bM){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let i=[e],n=new Set,a=0;for(;i.length>0;){if(a++>=r)return!1;let o=i.pop();if(o==null)continue;let s=typeof o;if(s==="string"){if(o.length>=t)return!0;continue}if(s!=="object")continue;let c=o;if(n.has(c)||(n.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let l=c.length-1;l>=0;l--)i.push(c[l]);continue}if(c instanceof Map){for(let[,l]of c)i.push(l);continue}if(c instanceof Set){for(let l of c)i.push(l);continue}let u=Object.keys(c);for(let l=u.length-1;l>=0;l--)i.push(c[u[l]])}return!1}function wM(e,t){let[r]=Ot(e);if(r!=="-"&&!t)throw new Error("Pulling a public prompt by owner/name is disabled by default because prompts may contain untrusted serialized LangChain objects. If you trust this prompt, set `dangerouslyPullPublicPrompt: true` to acknowledge the risk.")}function gI(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function Rc(e){return{...e,start_time:gI(e.start_time),end_time:gI(e.end_time)}}function _I(e,t,r){if(r)return e;let i=ad(),n=t??tg(),a=e.extra??{},o=a.metadata;return e.extra={...a,runtime:{...i,...a?.runtime},metadata:{...n,...n.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??n.revision_id}:{},...o}},e}var xM=e=>{let t=e?.toString()??Ze("TRACING_SAMPLING_RATE");if(t===void 0)return;let r=parseFloat(t);if(r<0||r>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${r}`);return r},SM=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function kM(e){let t=[];for await(let r of e)t.push(r);return t}function xd(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var $M=async e=>{if(e?.status===429){let t=parseInt(e.headers.get("retry-after")??"10",10)*1e3;if(t>0)return await new Promise(r=>setTimeout(r,t)),!0}return!1};function yI(e){return typeof e=="number"?Number(e.toFixed(4)):e}var IM=24*1024*1024,bI=1024*1024*1024,EM=1e4,TM=100,Eg=class{constructor(t){Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"sizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"maxSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSizeBytes=t??bI}peek(){return this.items[0]}push(t){let r,i=new Promise(a=>{r=a}),n=fI(t.item).size;return this.sizeBytes+n>this.maxSizeBytes&&this.items.length>0?(console.warn(`AutoBatchQueue size limit (${this.maxSizeBytes} bytes) exceeded. Dropping run with id: ${t.item.id}. Current queue size: ${this.sizeBytes} bytes, attempted addition: ${n} bytes.`),r(),i):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:r,itemPromise:i,size:n}),this.sizeBytes+=n,i)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let i=[],n=0;for(;n+(this.peek()?.size??0)<t&&this.items.length>0&&i.length<r;){let a=this.items.shift();a&&(i.push(a),n+=a.size,this.sizeBytes-=a.size)}if(i.length===0&&this.items.length>0){let a=this.items.shift();i.push(a),n+=a.size,this.sizeBytes-=a.size}return[i.map(a=>({action:a.action,item:a.payload,otelContext:a.otelContext,apiKey:a.apiKey,apiUrl:a.apiUrl,size:a.size})),()=>i.forEach(a=>a.itemPromiseResolve())]}},Tn=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||S$(this.debug);return(async(r,i)=>{let n,a=this.getProfileManagedAuthorizationHeader(i);return this.apiKey!==void 0?n={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(i,a)||(n=await this.profileAuth?.getAuthHeader(t,i?.signal)),t(r,this.applyCurrentAuthHeaders(i,n,a))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let r=new Headers(t.headers).get("Authorization");if(Pr(r))return this.profileAuth.isProfileAuthorizationHeader(r??"")?r??void 0:void 0}isProfileManagedAuthorizationHeader(t,r){return t===r||this.profileAuth?.isProfileAuthorizationHeader(t)===!0}hasExplicitAuthHeader(t,r){if(!t?.headers)return!1;let i=new Headers(t.headers);if(Pr(i.get("x-api-key")))return!0;let n=i.get("Authorization");return Pr(n)?!this.isProfileManagedAuthorizationHeader(n??"",r):!1}applyCurrentAuthHeaders(t,r,i){if(!r)return t;let n=d=>{if(this.apiKey!==void 0&&r.name==="x-api-key")return d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value),d;if(r.name==="Authorization"){if(Pr(d.get("x-api-key")))return d;let p=d.get("Authorization");return Pr(p)&&!this.isProfileManagedAuthorizationHeader(p??"",i)||d.set("Authorization",r.value),d}let f=d.get("Authorization");return Pr(f)&&!this.isProfileManagedAuthorizationHeader(f??"",i)||(Pr(f)&&d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",r.value)),d};if(!t)return{headers:{[r.name]:r.value}};if(t.headers instanceof Headers)return{...t,headers:n(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:n(new Headers(t.headers))};let a={...t.headers??{}},o=d=>Object.keys(a).find(f=>f.toLowerCase()===d),s=d=>{let f=o(d);return f?a[f]:void 0},c=Pr(s("x-api-key")),u=s("authorization"),l=Pr(u)&&!this.isProfileManagedAuthorizationHeader(u??"",i);if(this.apiKey!==void 0&&r.name==="x-api-key"){let d=o("authorization");return d&&delete a[d],c||(a["x-api-key"]=r.value),{...t,headers:a}}if(r.name==="Authorization"){if(!c&&!l){let d=o("authorization");d&&d!=="Authorization"&&delete a[d],a.Authorization=r.value}return{...t,headers:a}}if(!l){let d=o("authorization");d&&delete a[d],c||(a["x-api-key"]=r.value)}return{...t,headers:a}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,r){if(this.manualFlushMode)return Pt(t,r);if(!hI(t))return Pt(t,r);if(this._serializeWorker===void 0&&(this._serializeWorker=mI()),this._serializeWorker===null)return Pt(t,r);try{let i=await this._serializeWorker.serialize(t);return i===null?(this._serializeWorker=null,Pt(t,r)):i}catch{return Pt(t,r)}}constructor(t={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitTracedRuntimeInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:_t("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_serializeWorker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingDrains",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tracingMode",{enumerable:!0,configurable:!0,writable:!0,value:"langsmith"}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_promptCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"profileAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value:Ze("DISABLE_RUN_COMPRESSION")==="true"}),Object.defineProperty(this,"failedTracesDir",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"failedTracesMaxBytes",{enumerable:!0,configurable:!0,writable:!0,value:100*1024*1024}),Object.defineProperty(this,"_customHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:_t("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();this.tracingSampleRate=xM(t.tracingSamplingRate),this.apiUrl=xd(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let i=xd(t.apiKey??r.apiKey);if(this.apiKey=Pr(i)?i:void 0,this.profileAuth=this.apiKey!==void 0?void 0:r.profileAuth,this.webUrl=xd(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=xd(t.workspaceId??r.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new Nc({...t.callerOptions??{},maxRetries:4,debug:t.debug??this.debug}),this.traceBatchConcurrency=t.traceBatchConcurrency??this.traceBatchConcurrency,this.traceBatchConcurrency<1)throw new Error("Trace batch concurrency must be positive.");this.debug=t.debug??this.debug,this.fetchImplementation=t.fetchImplementation,this.failedTracesDir=Ze("FAILED_TRACES_DIR")||void 0;let n=Ze("FAILED_TRACES_MAX_MB");if(n){let o=parseInt(n,10);Number.isFinite(o)&&o>0&&(this.failedTracesMaxBytes=o*1024*1024)}let a=t.maxIngestMemoryBytes??bI;this.batchIngestCaller=new Nc({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:a,...t.callerOptions??{},onFailedResponseHook:$M,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.hideMetadata=t.hideMetadata??r.hideMetadata,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new Eg(a),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=od(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new cd),this.cachedLSEnvVarsForMetadata=tg(),t.cache!==void 0&&t.disablePromptCache&&Ea("Both 'cache' and 'disablePromptCache' were provided. The 'cache' parameter is deprecated and will be removed in a future version. Using 'cache' parameter value."),t.cache!==void 0?(Ea("The 'cache' parameter is deprecated and will be removed in a future version. Use 'configureGlobalPromptCache()' to configure the global cache, or 'disablePromptCache: true' to disable caching for this client."),t.cache===!1?this._promptCache=void 0:t.cache===!0?this._promptCache=nd:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=nd),this._customHeaders=t.headers??{}}static getDefaultClientConfig(){let t=cI(),r=Ze("API_KEY"),i=Ze("ENDPOINT"),n=Ze("WORKSPACE_ID"),a=Pr(r),o=i??t.apiUrl??vd,s=n??t.workspaceId,c=Ze("HIDE_INPUTS")==="true",u=Ze("HIDE_OUTPUTS")==="true",l=Ze("HIDE_METADATA")==="true";return{apiUrl:o,apiKey:r,webUrl:void 0,hideInputs:c,hideOutputs:u,hideMetadata:l,workspaceId:s,oauthAccessToken:a?void 0:t.oauthAccessToken,oauthRefreshToken:a?void 0:t.oauthRefreshToken,profileAuth:a?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:SM(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("aws")?(this.webUrl="https://aws.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("apac")?(this.webUrl="https://apac.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${id}`,...this._customHeaders};if(this.apiKey!==void 0)t["x-api-key"]=`${this.apiKey}`;else{let r=this.profileAuth?.currentAuthHeader();r&&(t[r.name]=r.value)}return this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),t}get headers(){return this._customHeaders}set headers(t){this._customHeaders=t??{}}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}async processInputs(t){return this.hideInputs===!1?t:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(t):t}async processOutputs(t){return this.hideOutputs===!1?t:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(t):t}async processMetadata(t){return this.hideMetadata===!1?t:this.hideMetadata===!0?{}:typeof this.hideMetadata=="function"?this.hideMetadata(t):t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(r=>{if(r.name==="new_token"){let{kwargs:i,...n}=r;return n}return r})}async prepareRunCreateOrUpdateInputs(t){let r={...t};return r.inputs!==void 0&&(r.inputs=await this.processInputs(r.inputs)),r.outputs!==void 0&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events!==void 0&&(r.events=this._filterNewTokenEvents(r.events)),r}async _getResponse(t,r){let i=r?.toString()??"",n=`${this.apiUrl}${t}?${i}`;return await this.caller.call(async()=>{let o=await this._fetch(n,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(o,`fetch ${t}`),o})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,i){let n=Number(r.get("offset"))||0,a=Number(r.get("limit"))||100;for(;;){r.set("offset",String(n)),r.set("limit",String(a));let o=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let u=await this._fetch(o,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(u,`fetch ${t}`),u}),c=i?i(await s.json()):await s.json();if(c.length===0||(yield c,c.length<a))break;n+=c.length}}async*_getCursorPaginatedList(t,r=null,i="POST",n="runs"){let a=r?{...r}:{};for(;;){let o=JSON.stringify(a),c=await(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}${t}`,{method:i,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(l,`fetch ${t}`),l})).json();if(!c||!c[n])break;yield c[n];let u=c.cursors;if(!u||!u.next)break;a.cursor=u.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(t,r=!1){if(this.tracingSampleRate===void 0)return t;if(r){let i=[];for(let n of t)this.filteredPostUuids.has(n.trace_id)?n.id===n.trace_id&&this.filteredPostUuids.delete(n.trace_id):i.push(n);return i}else{let i=[];for(let n of t){let a=n.trace_id??n.id;this.filteredPostUuids.has(a)||(n.id===a?this._shouldSample()?i.push(n):this.filteredPostUuids.add(a):i.push(n))}return i}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??IM}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??TM}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let i=[];for(;this.autoBatchQueue.items.length>0;){let[n,a]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!n.length){a();break}let o=n.reduce((u,l)=>{let d=l.apiUrl??this.apiUrl,f=l.apiKey??this.apiKey,m=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl?"default":`${d}|${f}`;return u[m]||(u[m]=[]),u[m].push(l),u},{}),s=[];for(let[u,l]of Object.entries(o)){let d=this._processBatch(l,{apiUrl:u==="default"?void 0:u.split("|")[0],apiKey:u==="default"?void 0:u.split("|")[1]});s.push(d)}let c=Promise.all(s).finally(a);i.push(c)}return Promise.all(i)}static async _writeTraceToFallbackDir(t,r,i,n,a){try{let o=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:n,headers:i,body_base64:o.toString("base64")}),c=`trace_${Date.now()}_${Ia().slice(0,8)}.json`,u=Aa.join(t,c);if(e._fallbackDirsCreated.has(t)||(await z$(t),e._fallbackDirsCreated.add(t)),a!==void 0&&a>0)try{let d=(await D$(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await U$(Aa.join(t,p));f+=m}if(f>=a){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${a} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await ed(u,s),console.warn(`LangSmith trace upload failed; data saved to ${u} for later replay.`)}catch(o){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,o)}}async _processBatch(t,r){if(!t.length)return;let i=t.reduce((n,a)=>n+(a.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let n={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},a=await this._ensureServerInfo();if(!this._multipartDisabled&&(a?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&a?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(n,{...r,useGzip:s,sizeBytes:i})}catch(c){if(yd(c))this._multipartDisabled=!0,await this.batchIngestRuns(n,{...r,sizeBytes:i});else throw c}}else await this.batchIngestRuns(n,{...r,sizeBytes:i})}}catch(n){console.error("Error exporting batch:",n)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,i=[];for(let n of t)n.item.id&&n.otelContext&&(r.set(n.item.id,n.otelContext),n.action==="create"?i.push({operation:"post",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}):i.push({operation:"patch",id:n.item.id,trace_id:n.item.trace_id??n.item.id,run:n.item}));this.langSmithToOTELTranslator.exportBatch(i,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=_I(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let i=await this._getBatchSizeLimitBytes(),n=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>i||this.autoBatchQueue.items.length>n)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:i,batchSizeLimit:n}))},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(EM),...this.fetchOptions});return await q(i,"get server info"),i})).json();return this.debug&&console.log(`
|
|
120
|
+
=== LangSmith Server Configuration ===
|
|
121
|
+
`+JSON.stringify(r,null,2)+`
|
|
122
|
+
`),r}async _ensureServerInfo(){return this._getServerInfoPromise===void 0&&(this._getServerInfoPromise=(async()=>{if(this._serverInfo===void 0)try{this._serverInfo=await this._getServerInfo()}catch(t){console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${t.status??"Unspecified status code"} ${t.message}`)}return this._serverInfo??{}})()),this._getServerInfoPromise.then(t=>(this._serverInfo===void 0&&(this._getServerInfoPromise=void 0),t))}async _getSettings(){return this.settings||(this.settings=this._get("/settings")),await this.settings}async flush(){let t=await this._getBatchSizeLimitBytes(),r=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r})}_cloneCurrentOTELContext(){let t=sd(),r=G$();if(this.langSmithToOTELTranslator!==void 0){let i=t.getActiveSpan();if(i)return t.setSpan(r.active(),i)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let i={...this._mergedHeaders,"Content-Type":"application/json"},n=t.project_name;delete t.project_name;let a=await this.prepareRunCreateOrUpdateInputs({session_name:n,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&a.trace_id!==void 0&&a.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:a,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let o=_I(a,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(i["x-tenant-id"]=r.workspaceId);let s=Pt(o,`Creating run with id: ${o.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await q(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),a=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(n.length>0&&a.length>0){let c=n.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of a)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);n=Object.values(c),a=u}let o={post:n,patch:a};if(!o.post.length&&!o.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=o[u].reverse(),d=l.pop();for(;d!==void 0;)s[u].push(d),d=l.pop()}if(s.post.length>0||s.patch.length>0){let c=s.post.map(u=>u.id).concat(s.patch.map(u=>u.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(s,`Ingesting runs with ids: ${c}`),i)}}async _postBatchIngestRuns(t,r){let i={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(i["x-api-key"]=r.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let n=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:i,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await q(n,"batch create run",!0),n})}async multipartIngestRuns({runCreates:t,runUpdates:r},i){if(t===void 0&&r===void 0)return;let n={},a=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(n[f.id]=f.attachments),delete f.attachments,a.push(f)}let o=[];for(let d of r??[])o.push(await this.prepareRunCreateOrUpdateInputs(d));if(a.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when creating a run');if(o.find(d=>d.trace_id===void 0||d.dotted_order===void 0)!==void 0)throw new Error('Multipart ingest requires "trace_id" and "dotted_order" to be set when updating a run');if(a.length>0&&o.length>0){let d=a.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of o)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);a=Object.values(d),o=f}if(a.length===0&&o.length===0)return;let u=[],l=[];for(let[d,f]of[["post",a],["patch",o]])for(let p of f){let{inputs:m,outputs:_,events:v,extra:x,error:w,serialized:S,attachments:$,...T}=p,F={inputs:m,outputs:_,events:v,extra:x,error:w,serialized:S},A=await this._serializeBody(T,`Serializing for multipart ingestion of run with id: ${T.id}`);l.push({name:`${d}.${T.id}`,payload:new Blob([A],{type:`application/json; length=${A.length}`})});for(let[y,W]of Object.entries(F)){if(W===void 0)continue;let O=await this._serializeBody(W,`Serializing ${y} for multipart ingestion of run with id: ${T.id}`);l.push({name:`${d}.${T.id}.${y}`,payload:new Blob([O],{type:`application/json; length=${O.length}`})})}if(T.id!==void 0){let y=n[T.id];if(y){delete n[T.id];for(let[W,O]of Object.entries(y)){let B,de;if(Array.isArray(O)?[B,de]=O:(B=O.mimeType,de=O.data),W.includes(".")){console.warn(`Skipping attachment '${W}' for run ${T.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${T.id}.${W}`,payload:new Blob([de],{type:`${B}; length=${de.byteLength}`})})}}}u.push(`trace=${T.trace_id},id=${T.id}`)}await this._sendMultipartRequest(l,u.join("; "),i)}async _createNodeFetchBody(t,r){let i=[];for(let o of t)i.push(new Blob([`--${r}\r
|
|
123
|
+
`])),i.push(new Blob([`Content-Disposition: form-data; name="${o.name}"\r
|
|
124
|
+
`,`Content-Type: ${o.payload.type}\r
|
|
125
|
+
\r
|
|
126
|
+
`])),i.push(o.payload),i.push(new Blob([`\r
|
|
127
|
+
`]));return i.push(new Blob([`--${r}--\r
|
|
128
|
+
`])),await new Blob(i).arrayBuffer()}async _createMultipartStream(t,r){let i=new TextEncoder;return new ReadableStream({async start(a){let o=async s=>{typeof s=="string"?a.enqueue(i.encode(s)):a.enqueue(s)};for(let s of t){await o(`--${r}\r
|
|
129
|
+
`),await o(`Content-Disposition: form-data; name="${s.name}"\r
|
|
130
|
+
`),await o(`Content-Type: ${s.payload.type}\r
|
|
131
|
+
\r
|
|
132
|
+
`);let u=s.payload.stream().getReader();try{let l;for(;!(l=await u.read()).done;)a.enqueue(l.value)}finally{u.releaseLock()}await o(`\r
|
|
133
|
+
`)}await o(`--${r}--\r
|
|
134
|
+
`),a.close()}})}async _sendMultipartRequest(t,r,i){let n="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),a=()=>this._createNodeFetchBody(t,n),o=()=>this._createMultipartStream(t,n),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:i?.sizeBytes},async()=>{let u=await c(),l={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${n}`};i?.apiKey!==void 0&&(l["x-api-key"]=i.apiKey);let d=u;i?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let f=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(f,"Failed to send multipart request",!0),f});try{let c,u=!1;x$()&&!this.multipartStreamingDisabled&&Oc()!=="bun"?(u=!0,c=await s(o)):c=await s(a),(!this.multipartStreamingDisabled||u)&&c.status===422&&(i?.apiUrl??this.apiUrl)!==vd&&(console.warn(`Streaming multipart upload to ${i?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${r}".`),this.multipartStreamingDisabled=!0,c=await s(a))}catch(c){if(yd(c))throw c;if(console.warn(`${c.message.trim()}
|
|
135
|
+
|
|
136
|
+
Context: ${r}`),this.failedTracesDir){let u=await this._createNodeFetchBody(t,n).catch(()=>null);u&&await e._writeTraceToFallbackDir(this.failedTracesDir,u,{"Content-Type":`multipart/form-data; boundary=${n}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,i){le(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs)),r.extra!=null&&"metadata"in r.extra&&(r.extra={...r.extra,metadata:await this.processMetadata(r.extra.metadata)}),r.events&&(r.events=this._filterNewTokenEvents(r.events));let n={...r,id:t};if(!this._filterForSampling([n],!0).length)return;if(this.autoBatchTracing&&n.trace_id!==void 0&&n.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&n.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:n,otelContext:s,apiKey:i?.apiKey,apiUrl:i?.apiUrl}).catch(console.error);return}let a={...this._mergedHeaders,"Content-Type":"application/json"};i?.apiKey!==void 0&&(a["x-api-key"]=i.apiKey),i?.workspaceId!==void 0&&(a["x-tenant-id"]=i.workspaceId);let o=Pt(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${i?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:a,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){le(t);let i=Rc(await this._get(`/runs/${t}`));return r&&(i=await this._loadChildRuns(i)),i}async getRunUrl({runId:t,run:r,projectOpts:i}){if(r!==void 0){let n;r.session_id?n=r.session_id:i?.projectName?n=(await this.readProject({projectName:i?.projectName})).id:i?.projectId?n=i?.projectId:n=(await this.readProject({projectName:Ze("PROJECT")||"default"})).id;let a=await this._getTenantId();return`${this.getHostUrl()}/o/${a}/projects/p/${n}/r/${r.id}?poll=true`}else if(t!==void 0){let n=await this.readRun(t);if(!n.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${n.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await kM(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),i={},n={};r.sort((a,o)=>(a?.dotted_order??"").localeCompare(o?.dotted_order??""));for(let a of r){if(a.parent_run_id===null||a.parent_run_id===void 0)throw new Error(`Child run ${a.id} has no parent`);a.dotted_order?.startsWith(t.dotted_order??"")&&a.id!==t.id&&(a.parent_run_id in i||(i[a.parent_run_id]=[]),i[a.parent_run_id].push(a),n[a.id]=a)}t.child_runs=i[t.id]||[];for(let a in i)a!==t.id&&(n[a].child_runs=i[a]);return t}async*listRuns(t){let{projectId:r,projectName:i,parentRunId:n,traceId:a,referenceExampleId:o,startTime:s,executionOrder:c,isRoot:u,runType:l,error:d,id:f,query:p,filter:m,traceFilter:_,treeFilter:v,limit:x,select:w,order:S}=t,$=[];if(r&&($=Array.isArray(r)?r:[r]),i){let y=Array.isArray(i)?i:[i],W=await Promise.all(y.map(O=>this.readProject({projectName:O}).then(B=>B.id)));$.push(...W)}let T=["app_path","completion_cost","completion_tokens","dotted_order","end_time","error","events","extra","feedback_stats","first_token_time","id","inputs","name","outputs","parent_run_id","parent_run_ids","prompt_cost","prompt_tokens","reference_example_id","run_type","session_id","start_time","status","tags","total_cost","total_tokens","trace_id"],F={session:$.length?$:null,run_type:l,reference_example:o,query:p,filter:m,trace_filter:_,tree_filter:v,execution_order:c,parent_run:n,start_time:s?s.toISOString():null,error:d,id:f,limit:x,trace:a,select:w||T,is_root:u,order:S};F.select.includes("child_run_ids")&&Ea("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let A=0;for await(let y of this._getCursorPaginatedList("/runs/query",F)){let W=y.map(Rc);if(x){if(A>=x)break;if(W.length+A>x){yield*W.slice(0,x-A);break}A+=W.length,yield*W}else yield*W}}async*listGroupRuns(t){let{projectId:r,projectName:i,groupBy:n,filter:a,startTime:o,endTime:s,limit:c,offset:u}=t,d={session_id:r||(await this.readProject({projectName:i})).id,group_by:n,filter:a,start_time:o?o.toISOString():null,end_time:s?s.toISOString():null,limit:Number(c)||100},f=Number(u)||0,p="/runs/group",m=`${this.apiUrl}${p}`;for(;;){let _={...d,offset:f},v=Object.fromEntries(Object.entries(_).filter(([F,A])=>A!==void 0)),x=JSON.stringify(v),S=await(await this.caller.call(async()=>{let F=await this._fetch(m,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:x});return await q(F,`Failed to fetch ${p}`),F})).json(),{groups:$,total:T}=S;if($.length===0)break;for(let F of $)yield F;if(f+=$.length,f>=T)break}}async*readThread(t){let{threadId:r,projectId:i,projectName:n,isRoot:a=!0,limit:o,filter:s,order:c="asc"}=t;if(!i&&!n)throw new Error("threadId requires projectId or projectName");let u=`eq(thread_id, ${JSON.stringify(r)})`,l=s?`and(${u}, ${s})`:u;yield*this.listRuns({projectId:i??void 0,projectName:n??void 0,isRoot:a,limit:o,filter:l,order:c})}async listThreads(t){let{projectId:r,projectName:i,limit:n,offset:a=0,filter:o,startTime:s,isRoot:c=!0}=t;if(!r&&!i)throw new Error("Either projectId or projectName must be provided");if(r&&i)throw new Error("Provide exactly one of projectId or projectName");let u=r??(await this.readProject({projectName:i})).id,l=s??new Date(Date.now()-1440*60*1e3),f={session:[u],is_root:c,limit:100,order:"desc",select:["id","name","status","start_time","end_time","thread_id","trace_id","run_type","error","tags","session_id","parent_run_id","total_tokens","total_cost","dotted_order","reference_example_id","feedback_stats","app_path","completion_cost","completion_tokens","prompt_cost","prompt_tokens","first_token_time"],start_time:l.toISOString()};o!=null&&(f.filter=o);let p=new Map;for await(let x of this._getCursorPaginatedList("/runs/query",f))for(let w of x){let S=Rc(w),$=S.thread_id;if($){let T=p.get($)??[];T.push(S),p.set($,T)}}let m=[];for(let[x,w]of p.entries()){w.sort((A,y)=>{let W=A,O=y,B=W.start_time??"",de=O.start_time??"";if(B!==de)return B.localeCompare(de);let Le=W.dotted_order??"",Lt=O.dotted_order??"";return Le.localeCompare(Lt)});let $=[...w.map(A=>A.start_time).filter(Boolean)].sort(),T=$.length?$[0]:"",F=$.length?$[$.length-1]:"";m.push({thread_id:x,runs:w,count:w.length,filter:"",total_tokens:0,total_cost:null,min_start_time:T,max_start_time:F,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((x,w)=>{let S=x.max_start_time??"";return(w.max_start_time??"").localeCompare(S)});let _=a>0?m.slice(a):m;return n!==void 0?_.slice(0,n):_}async getRunStats({id:t,trace:r,parentRun:i,runType:n,projectNames:a,projectIds:o,referenceExampleIds:s,startTime:c,endTime:u,error:l,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:_,dataSourceType:v}){let x=o||[];a&&(x=[...o||[],...await Promise.all(a.map(A=>this.readProject({projectName:A}).then(y=>y.id)))]);let S=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:i,run_type:n,session:x,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:_,data_source_type:v}).filter(([A,y])=>y!==void 0)),$=JSON.stringify(S);return await(await this.caller.call(async()=>{let A=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:$});return await q(A,"get run stats"),A})).json()}async shareRun(t,{shareId:r}={}){let i={run_id:t,share_token:r||Ia()};le(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await q(s,"share run"),s})).json();if(o===null||!("share_token"in o))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${o.share_token}/r`}async unshareRun(t){le(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(r,"unshare run",!0),r})}async readRunSharedLink(t){le(t);let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"read run shared link"),n})).json();if(!(i===null||!("share_token"in i)))return`${this.getHostUrl()}/public/${i.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){let i=new URLSearchParams({share_token:t});if(r!==void 0)for(let o of r)i.append("id",o);return le(t),(await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/runs${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(o,"list shared runs"),o})).json()).map(Rc)}async readDatasetSharedSchema(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id),le(t);let n=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(a,"read dataset shared schema"),a})).json();return n.url=`${this.getHostUrl()}/public/${n.share_token}/d`,n}async shareDataset(t,r){if(!t&&!r)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:r})).id);let i={dataset_id:t};le(t);let n=JSON.stringify(i),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await q(s,"share dataset"),s})).json();return o.url=`${this.getHostUrl()}/public/${o.share_token}/d`,o}async unshareDataset(t){le(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(r,"unshare dataset",!0),r})}async readSharedDataset(t){return le(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"read shared dataset"),n})).json()}async listSharedExamples(t,r){let i={};r?.exampleIds&&(i.id=r.exampleIds);let n=new URLSearchParams;Object.entries(i).forEach(([s,c])=>{Array.isArray(c)?c.forEach(u=>n.append(s,u)):n.append(s,c)});let a=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${n.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(s,"list shared examples"),s}),o=await a.json();if(!a.ok)throw"detail"in o?new Error(`Failed to list shared examples.
|
|
137
|
+
Status: ${a.status}
|
|
138
|
+
Message: ${Array.isArray(o.detail)?o.detail.join(`
|
|
139
|
+
`):"Unspecified error"}`):new Error(`Failed to list shared examples: ${a.status} ${a.statusText}`);return o.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:i=null,upsert:n=!1,projectExtra:a=null,referenceDatasetId:o=null}){let s=n?"?upsert=true":"",c=`${this.apiUrl}/sessions${s}`,u=a||{};i&&(u.metadata=i);let l={name:t,extra:u,description:r};o!==null&&(l.reference_dataset_id=o);let d=JSON.stringify(l);return await(await this.caller.call(async()=>{let m=await this._fetch(c,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await q(m,"create project"),m})).json()}async updateProject(t,{name:r=null,description:i=null,metadata:n=null,projectExtra:a=null,endTime:o=null}){let s=`${this.apiUrl}/sessions/${t}`,c=a;n&&(c={...c||{},metadata:n});let u=JSON.stringify({name:r,extra:c,description:i,end_time:o?new Date(o).toISOString():null});return await(await this.caller.call(async()=>{let f=await this._fetch(s,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await q(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let i="/sessions",n=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)le(t),i+=`/${t}`;else if(r!==void 0)n.append("name",r);else throw new Error("Must provide projectName or projectId");let a=await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}?${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(o,"has project"),o});try{let o=await a.json();return a.ok?Array.isArray(o)?o.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:i}){let n="/sessions",a=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)le(t),n+=`/${t}`;else if(r!==void 0)a.append("name",r);else throw new Error("Must provide projectName or projectId");i!==void 0&&a.append("include_stats",i.toString());let o=await this._get(n,a),s;if(Array.isArray(o)){if(o.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=o[0]}else s=o;return s}async getProjectUrl({projectId:t,projectName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either projectName or projectId");let i=await this.readProject({projectId:t,projectName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/projects/p/${i.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let i=await this.readDataset({datasetId:t,datasetName:r}),n=await this._getTenantId();return`${this.getHostUrl()}/o/${n}/datasets/${i.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;let t=new URLSearchParams({limit:"1"});for await(let r of this._getPaginated("/sessions",t))return this._tenantId=r[0].tenant_id,r[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:t,name:r,nameContains:i,referenceDatasetId:n,referenceDatasetName:a,includeStats:o,datasetVersion:s,referenceFree:c,metadata:u}={}){let l=new URLSearchParams;if(t!==void 0)for(let d of t)l.append("id",d);if(r!==void 0&&l.append("name",r),i!==void 0&&l.append("name_contains",i),n!==void 0)l.append("reference_dataset",n);else if(a!==void 0){let d=await this.readDataset({datasetName:a});l.append("reference_dataset",d.id)}o!==void 0&&l.append("include_stats",o.toString()),s!==void 0&&l.append("dataset_version",s),c!==void 0&&l.append("reference_free",c.toString()),u!==void 0&&l.append("metadata",JSON.stringify(u));for await(let d of this._getPaginated("/sessions",l))yield*d}async deleteProject({projectId:t,projectName:r}){let i;if(t===void 0&&r===void 0)throw new Error("Must provide projectName or projectId");if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");t===void 0?i=(await this.readProject({projectName:r})).id:i=t,le(i),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/sessions/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,`delete session ${i} (${r})`,!0),n})}async uploadCsv({csvFile:t,fileName:r,inputKeys:i,outputKeys:n,description:a,dataType:o,name:s}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,r),i.forEach(p=>{u.append("input_keys",p)}),n.forEach(p=>{u.append("output_keys",p)}),a&&u.append("description",a),o&&u.append("data_type",o),s&&u.append("name",s),await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await q(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:i,inputsSchema:n,outputsSchema:a,metadata:o}={}){let s={name:t,description:r,extra:{source:"sdk",...o?{metadata:o}:{}}};i&&(s.data_type=i),n&&(s.inputs_schema_definition=n),a&&(s.outputs_schema_definition=a);let c=JSON.stringify(s);return await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await q(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let i="/datasets",n=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)le(t),i+=`/${t}`;else if(r)n.append("name",r);else throw new Error("Must provide datasetName or datasetId");let a=await this._get(i,n),o;if(Array.isArray(a)){if(a.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);o=a[0]}else o=a;return o}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(i){if(i instanceof Error&&i.message.toLocaleLowerCase().includes("not found"))return!1;throw i}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:i,toVersion:n}){let a=t;if(a===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(a!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");a===void 0&&(a=(await this.readDataset({datasetName:r})).id);let o=new URLSearchParams({from_version:typeof i=="string"?i:i.toISOString(),to_version:typeof n=="string"?n:n.toISOString()});return await this._get(`/datasets/${a}/versions/diff`,o)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let i="/datasets";if(t===void 0)if(r!==void 0)t=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${i}/${t}/openai_ft`)).text()).trim().split(`
|
|
140
|
+
`).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:i,datasetName:n,datasetNameContains:a,metadata:o}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(i!==void 0)for(let u of i)c.append("id",u);n!==void 0&&c.append("name",n),a!==void 0&&c.append("name_contains",a),o!==void 0&&c.append("metadata",JSON.stringify(o));for await(let u of this._getPaginated(s,c))yield*u}async updateDataset(t){let{datasetId:r,datasetName:i,...n}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:i})).id;le(a);let o=JSON.stringify(n);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:i,asOf:n,tag:a}=t;if(!r&&!i)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:i})).id;le(o);let s=JSON.stringify({as_of:typeof n=="string"?n:n.toISOString(),tag:a});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await q(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let i="/datasets",n=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(n=(await this.readDataset({datasetName:r})).id),n!==void 0)le(n),i+=`/${n}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let a=await this._fetch(this.apiUrl+i,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(a,`delete ${i}`,!0),a})}async createExample(t,r,i){if(vI(t)&&(r!==void 0||i!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let n=r?i?.datasetId:t.dataset_id,a=r?i?.datasetName:t.dataset_name;if(n===void 0&&a===void 0)throw new Error("Must provide either datasetName or datasetId");if(n!==void 0&&a!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");n===void 0&&(n=(await this.readDataset({datasetName:a})).id);let o=(r?i?.createdAt:t.created_at)||new Date,s;vI(t)?s=t:s={inputs:t,outputs:r,created_at:o?.toISOString(),id:i?.exampleId,metadata:i?.metadata,split:i?.split,source_run_id:i?.sourceRunId,use_source_run_io:i?.useSourceRunIO,use_source_run_attachments:i?.useSourceRunAttachments,attachments:i?.attachments};let c=await this._uploadExamplesMultipart(n,[s]);return await this.readExample(c.example_ids?.[0]??Ia())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let w=t,S=w[0].dataset_id,$=w[0].dataset_name;if(S===void 0&&$===void 0)throw new Error("Must provide either datasetName or datasetId");if(S!==void 0&&$!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");S===void 0&&(S=(await this.readDataset({datasetName:$})).id);let T=await this._uploadExamplesMultipart(S,w);return await Promise.all(T.example_ids.map(A=>this.readExample(A)))}let{inputs:r,outputs:i,metadata:n,splits:a,sourceRunIds:o,useSourceRunIOs:s,useSourceRunAttachments:c,attachments:u,exampleIds:l,datasetId:d,datasetName:f}=t;if(r===void 0)throw new Error("Must provide inputs when using legacy parameters");let p=d,m=f;if(p===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(p!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");p===void 0&&(p=(await this.readDataset({datasetName:m})).id);let _=r.map((w,S)=>({dataset_id:p,inputs:w,outputs:i?.[S],metadata:n?.[S],split:a?.[S],id:l?.[S],attachments:u?.[S],source_run_id:o?.[S],use_source_run_io:s?.[S],use_source_run_attachments:c?.[S]})),v=await this._uploadExamplesMultipart(p,_);return await Promise.all(v.example_ids.map(w=>this.readExample(w)))}async createLLMExample(t,r,i){return this.createExample({input:t},{output:r},i)}async createChatExample(t,r,i){let n=t.map(o=>yg(o)?vg(o):o),a=yg(r)?vg(r):r;return this.createExample({input:n},{output:a},i)}async readExample(t){le(t);let r=`/examples/${t}`,i=await this._get(r),{attachment_urls:n,...a}=i,o=a;return n&&(o.attachments=Object.entries(n).reduce((s,[c,u])=>(s[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},s),{})),o}async*listExamples({datasetId:t,datasetName:r,exampleIds:i,asOf:n,splits:a,inlineS3Urls:o,metadata:s,limit:c,offset:u,filter:l,includeAttachments:d}={}){let f;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)f=t;else if(r!==void 0)f=(await this.readDataset({datasetName:r})).id;else throw new Error("Must provide a datasetName or datasetId");let p=new URLSearchParams({dataset:f}),m=n?typeof n=="string"?n:n?.toISOString():void 0;m&&p.append("as_of",m);let _=o??!0;if(p.append("inline_s3_urls",_.toString()),i!==void 0)for(let x of i)p.append("id",x);if(a!==void 0)for(let x of a)p.append("splits",x);if(s!==void 0){let x=JSON.stringify(s);p.append("metadata",x)}c!==void 0&&p.append("limit",c.toString()),u!==void 0&&p.append("offset",u.toString()),l!==void 0&&p.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(x=>p.append("select",x));let v=0;for await(let x of this._getPaginated("/examples",p)){for(let w of x){let{attachment_urls:S,...$}=w,T=$;S&&(T.attachments=Object.entries(S).reduce((F,[A,y])=>(F[A.slice(11)]={presigned_url:y.presigned_url,mime_type:y.mime_type||void 0},F),{})),yield T,v++}if(c!==void 0&&v>=c)break}}async deleteExample(t){le(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,`delete ${r}`,!0),i})}async deleteExamples(t,r){if(t.forEach(i=>le(i)),r?.hardDelete){let i=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"hard delete examples",!0),n})}else{let i=new URLSearchParams;t.forEach(n=>i.append("example_ids",n)),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/examples?${i.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"delete examples",!0),n})}}async updateExample(t,r){let i;r?i=t:i=t.id,le(i);let n;r?n={id:i,...r}:n=t;let a;return n.dataset_id!==void 0?a=n.dataset_id:a=(await this.readExample(i)).dataset_id,this._updateExamplesMultipart(a,[n])}async updateExamples(t){let r;return t[0].dataset_id===void 0?r=(await this.readExample(t[0].id)).dataset_id:r=t[0].dataset_id,this._updateExamplesMultipart(r,t)}async readDatasetVersion({datasetId:t,datasetName:r,asOf:i,tag:n}){let a;if(t?a=t:a=(await this.readDataset({datasetName:r})).id,le(a),i&&n||!i&&!n)throw new Error("Exactly one of asOf and tag must be specified.");let o=new URLSearchParams;return i!==void 0&&o.append("as_of",typeof i=="string"?i:i.toISOString()),n!==void 0&&o.append("tag",n),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/version?${o.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:i}){let n;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?n=(await this.readDataset({datasetName:r})).id:n=t,le(n);let a=new URLSearchParams,o=i?typeof i=="string"?i:i?.toISOString():void 0;return o&&a.append("as_of",o),await this._get(`/datasets/${n}/splits`,a)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:i,exampleIds:n,remove:a=!1}){let o;if(t===void 0&&r===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?o=(await this.readDataset({datasetName:r})).id:o=t,le(o);let s={split_name:i,examples:n.map(u=>(le(u),u)),remove:a},c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${o}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await q(u,"update dataset splits",!0),u})}async createFeedback(t,r,{score:i,value:n,correction:a,comment:o,sourceInfo:s,feedbackSourceType:c="api",sourceRunId:u,feedbackId:l,feedbackConfig:d,projectId:f,comparativeExperimentId:p,sessionId:m,startTime:_}){if(!t&&!f)throw new Error("One of runId or projectId must be provided");if(t&&f)throw new Error("Only one of runId or projectId can be provided");let v={type:c??"api",metadata:s??{}};u!==void 0&&v?.metadata!==void 0&&!v.metadata.__run&&(v.metadata.__run={run_id:u}),v?.metadata!==void 0&&v.metadata.__run?.run_id!==void 0&&le(v.metadata.__run.run_id);let x={id:l??Ho(),run_id:t,key:r,score:yI(i),value:n,correction:a,comment:o,feedback_source:v,comparative_experiment_id:p,feedbackConfig:d,session_id:m??f,start_time:_},w=JSON.stringify(x),S=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let $=await this._fetch(S,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await q($,"create feedback",!0),$}),x}async updateFeedback(t,{score:r,value:i,correction:n,comment:a}){let o={};r!=null&&(o.score=yI(r)),i!=null&&(o.value=i),n!=null&&(o.correction=n),a!=null&&(o.comment=a),le(t);let s=JSON.stringify(o);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await q(c,"update feedback",!0),c})}async readFeedback(t){le(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){le(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let i=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,`delete ${r}`,!0),i})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:i}={}){let n=new URLSearchParams;if(t)for(let a of t)le(a),n.append("run",a);if(r)for(let a of r)n.append("key",a);if(i)for(let a of i)n.append("source",a);for await(let a of this._getPaginated("/feedback",n))yield*a}async createPresignedFeedbackToken(t,r,{expiration:i,feedbackConfig:n}={}){let a={run_id:t,feedback_key:r,feedback_config:n};i?typeof i=="string"?a.expires_at=i:(i?.hours||i?.minutes||i?.days)&&(a.expires_in=i):a.expires_in={hours:3};let o=JSON.stringify(a);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:i,createdAt:n,description:a,metadata:o,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(i||(i=(await this.readProject({projectId:r[0]})).reference_dataset_id),!i==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:i,description:a,created_at:(n??new Date)?.toISOString(),extra:{}};o&&(c.extra.metadata=o);let u=JSON.stringify(c);return(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await q(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){le(t);let r=new URLSearchParams({run_id:t});for await(let i of this._getPaginated("/feedback/tokens",r))yield*i}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,i){let n=this._selectEvalResults(t),a=[];for(let o of n){let s=i||{};o.evaluatorInfo&&(s={...o.evaluatorInfo,...s});let c=null;o.targetRunId?c=o.targetRunId:r&&(c=r.id),a.push(await this.createFeedback(c,o.key,{score:o.score,value:o.value,comment:o.comment,correction:o.correction,sourceInfo:s,sourceRunId:o.sourceRunId,feedbackConfig:o.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id,startTime:r?.start_time}))}return[n,a]}async logEvaluationFeedback(t,r,i){let[n]=await this._logEvaluationFeedback(t,r,i);return n}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:i,isLowerScoreBetter:n=!1}=t,a={feedback_key:r,feedback_config:i,is_lower_score_better:n};return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await q(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:i,limit:n}=t,a=new URLSearchParams;r&&r.forEach(s=>{a.append("key",s)}),i&&a.append("name_contains",i),a.append("limit",(n!==void 0?Math.min(n,100):100).toString());let o=0;for await(let s of this._getPaginated("/feedback-configs",a))if(yield*s,o+=s.length,n!==void 0&&o>=n)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:i,isLowerScoreBetter:n}=r,a={feedback_key:t};return i!==void 0&&(a.feedback_config=i),n!==void 0&&(a.is_lower_score_better=n),(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await q(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,"delete feedback config",!0),i})}async*listAnnotationQueues(t={}){let{queueIds:r,name:i,nameContains:n,limit:a}=t,o=new URLSearchParams;r&&r.forEach((c,u)=>{le(c,`queueIds[${u}]`),o.append("ids",c)}),i&&o.append("name",i),n&&o.append("name_contains",n),o.append("limit",(a!==void 0?Math.min(a,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",o))if(yield*c,s++,a!==void 0&&s>=a)break}async createAnnotationQueue(t){let{name:r,description:i,queueId:n,rubricInstructions:a,rubricItems:o}=t,s={name:r,description:i,id:n||Ia(),rubric_instructions:a,rubric_items:o},c=JSON.stringify(Object.fromEntries(Object.entries(s).filter(([l,d])=>d!==void 0)));return(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await q(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,"read annotation queue"),i})).json()}async updateAnnotationQueue(t,r){let{name:i,description:n,rubricInstructions:a,rubricItems:o}=r,s={};i!==void 0&&(s.name=i),n!==void 0&&(s.description=n),a!==void 0&&(s.rubric_instructions=a),o!==void 0&&(s.rubric_items=o);let c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await q(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let i=JSON.stringify(r.map((n,a)=>le(n,`runIds[${a}]`).toString()));await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}/runs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await q(n,"add runs to annotation queue",!0),n})}async getRunFromAnnotationQueue(t,r){let i=`/annotation-queues/${le(t,"queueId")}/run`,a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${i}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(o,"get run from annotation queue"),o})).json();return Rc(a)}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}/runs/${le(r,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,"delete run from annotation queue",!0),i})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${le(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,"get size from annotation queue"),i})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let i=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
|
|
141
|
+
|
|
142
|
+
Current tenant: ${i.tenant_handle}
|
|
143
|
+
|
|
144
|
+
Requested tenant: ${r}`)}async _getLatestCommitHash(t){let i=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"get latest commit hash"),n})).json();if(i.commits.length!==0)return i.commits[0].commit_hash}async _likeOrUnlikePrompt(t,r){let[i,n,a]=Ot(t),o=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${i}/${n}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,i,n]=Ot(t);if(await this._currentTenantIsOwner(r)){let a=await this._getSettings();return n!=="latest"?`${this.getHostUrl()}/prompts/${i}/${n.substring(0,8)}?organizationId=${a.id}`:`${this.getHostUrl()}/prompts/${i}?organizationId=${a.id}`}else return n!=="latest"?`${this.getHostUrl()}/hub/${r}/${i}/${n.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${i}`}async promptExists(t){return!!await this.getPrompt(t)}async likePrompt(t){return this._likeOrUnlikePrompt(t,!0)}async unlikePrompt(t){return this._likeOrUnlikePrompt(t,!1)}async*listCommits(t){let[r,i,n]=Ot(t);for await(let a of this._getPaginated(`/commits/${r}/${i}/`,new URLSearchParams,o=>o.commits))yield*a}async*listPrompts(t){let r=new URLSearchParams;r.append("sort_field",t?.sortField??"updated_at"),r.append("sort_direction","desc"),r.append("is_archived",(!!t?.isArchived).toString()),t?.isPublic!==void 0&&r.append("is_public",t.isPublic.toString()),t?.query&&r.append("query",t.query);for await(let i of this._getPaginated("/repos",r,n=>n.repos))yield*i}async getPrompt(t){let[r,i,n]=Ot(t),o=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await q(s,"get prompt"),s)}))?.json();return o?.repo?o.repo:null}async createPrompt(t,r){let i=await this._getSettings();if(r?.isPublic&&!i.tenant_handle)throw new Error(`Cannot create a public prompt without first
|
|
145
|
+
|
|
146
|
+
creating a LangChain Hub handle.
|
|
147
|
+
You can add a handle by creating a public prompt at:
|
|
148
|
+
|
|
149
|
+
https://smith.langchain.com/prompts`);let[n,a,o]=Ot(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("create a prompt",n);let s={repo_handle:a,...r?.description&&{description:r.description},...r?.readme&&{readme:r.readme},...r?.tags&&{tags:r.tags},is_public:!!r?.isPublic},c=JSON.stringify(s),u=await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await q(d,"create prompt"),d}),{repo:l}=await u.json();return l}async createCommit(t,r,i){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,a,o]=Ot(t),s=i?.parentCommitHash==="latest"||!i?.parentCommitHash?await this._getLatestCommitHash(`${n}/${a}`):i?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s,...i?.description!==void 0&&{description:i.description}},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}/commits/${n}/${a}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await q(f,"create commit"),f})).json();return this._getPromptUrl(`${n}/${a}${d.commit_hash?`:${d.commit_hash}`:""}`)}async updateExamplesMultipart(t,r=[]){return this._updateExamplesMultipart(t,r)}async _updateExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let o of r){let s=o.id,c={...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split}},u=Pt(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(i.append(s,l),o.inputs){let d=Pt(o.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.inputs`,f)}if(o.outputs){let d=Pt(o.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.outputs`,f)}if(o.attachments)for(let[d,f]of Object.entries(o.attachments)){let p,m;Array.isArray(f)?[p,m]=f:(p=f.mimeType,m=f.data);let _=new Blob([m],{type:`${p}; length=${m.byteLength}`});i.append(`${s}.attachment.${d}`,_)}if(o.attachments_operations){let d=Pt(o.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});i.append(`${s}.attachments_operations`,f)}}let n=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${n}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await q(o,"update examples"),o})).json()}async uploadExamplesMultipart(t,r=[]){return this._uploadExamplesMultipart(t,r)}async _uploadExamplesMultipart(t,r=[]){if(!await this._getDatasetExamplesMultiPartSupport())throw new Error("Your LangSmith deployment does not allow using the multipart examples endpoint, please upgrade your deployment to the latest version.");let i=new FormData;for(let a of r){let o=(a.id??Ia()).toString(),s={created_at:a.created_at,...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split},...a.source_run_id&&{source_run_id:a.source_run_id},...a.use_source_run_io&&{use_source_run_io:a.use_source_run_io},...a.use_source_run_attachments&&{use_source_run_attachments:a.use_source_run_attachments}},c=Pt(s,`Serializing body for uploaded example with id: ${o}`),u=new Blob([c],{type:"application/json"});if(i.append(o,u),a.inputs){let l=Pt(a.inputs,`Serializing inputs for uploaded example with id: ${o}`),d=new Blob([l],{type:"application/json"});i.append(`${o}.inputs`,d)}if(a.outputs){let l=Pt(a.outputs,`Serializing outputs for uploaded example with id: ${o}`),d=new Blob([l],{type:"application/json"});i.append(`${o}.outputs`,d)}if(a.attachments)for(let[l,d]of Object.entries(a.attachments)){let f,p;Array.isArray(d)?[f,p]=d:(f=d.mimeType,p=d.data);let m=new Blob([p],{type:`${f}; length=${p.byteLength}`});i.append(`${o}.attachment.${l}`,m)}}return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await q(a,"upload examples"),a})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,n]=Ot(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("update a prompt",i);let a={};if(r?.description!==void 0&&(a.description=r.description),r?.readme!==void 0&&(a.readme=r.readme),r?.tags!==void 0&&(a.tags=r.tags),r?.isPublic!==void 0&&(a.is_public=r.isPublic),r?.isArchived!==void 0&&(a.is_archived=r.isArchived),Object.keys(a).length===0)throw new Error("No valid update options provided");let o=JSON.stringify(a);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${i}/${n}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await q(c,"update prompt"),c})).json()}async deletePrompt(t){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[r,i,n]=Ot(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(o,"delete prompt"),o})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[i,n,a]=Ot(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${i}/${n}/${a}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(c,"pull prompt commit"),c})).json();return{owner:i,repo:n,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples,hub_model_config:s.model_config,hub_model_provider:s.model_provider}}async pullPromptCommit(t,r){wM(t,r?.dangerouslyPullPublicPrompt);let i=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let n=this._getPromptCacheKey(t,r?.includeModel),a=this._promptCache.get(n,i);if(a)return a;let o=await i();return this._promptCache.set(n,o,i),o}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let i=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache,dangerouslyPullPublicPrompt:r?.dangerouslyPullPublicPrompt});return JSON.stringify(i.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&Object.keys(r).some(n=>n!=="object")&&await this.updatePrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}):await this.createPrompt(t,{description:r?.description,readme:r?.readme,tags:r?.tags,isPublic:r?.isPublic}),r?.object?await this.createCommit(t,r?.object,{parentCommitHash:r?.parentCommitHash,description:r?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[r,i]=Ot(t);return this._repoExists(r,i)}async skillExists(t){let[r,i]=Ot(t);return this._repoExists(r,i)}async pullAgent(t,r){return await this._pullDirectory(t,"agent",r?.version)}async pullSkill(t,r){return await this._pullDirectory(t,"skill",r?.version)}async pushAgent(t,r){return this._pushDirectory(t,"agent",r)}async pushSkill(t,r){return this._pushDirectory(t,"skill",r)}async deleteAgent(t){return this._deleteDirectory(t)}async deleteSkill(t){return this._deleteDirectory(t)}async*listAgents(t){yield*this._listReposByType("agent",t)}async*listSkills(t){yield*this._listReposByType("skill",t)}async*_listReposByType(t,r){let i=new URLSearchParams;i.append("repo_type",t),i.append("is_archived",(!!r?.isArchived).toString()),r?.isPublic!==void 0&&i.append("is_public",r.isPublic.toString()),r?.query&&i.append("query",r.query);for await(let n of this._getPaginated("/repos",i,a=>a.repos))yield*n}async _pullDirectory(t,r,i){let[n,a,o]=Ot(t),s=i??(o!=="latest"?o:void 0),c=new URL(`${this.apiUrl}/v1/platform/hub/repos/${n}/${a}/directories`);return c.searchParams.set("repo_type",r),s&&c.searchParams.set("commit",s),await(await this.caller.call(async()=>{let l=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(l,"pull directory"),l})).json()}async _pushDirectory(t,r,i){if(i.parentCommit!==void 0&&(i.parentCommit.length<8||i.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[n,a]=Ot(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError(`push ${r}`,n);if(await this._repoExists(n,a))(i.description!==void 0||i.readme!==void 0||i.tags!==void 0||i.isPublic!==void 0)&&await this._updateRepoMetadata(n,a,i);else{let d=/^[a-z][a-z0-9-_]*$/;if(!d.test(a))throw new Error(`Invalid repo_handle ${JSON.stringify(a)}: must match ${d}`);await this._createRepo(a,r,i)}let o={files:i.files};i.parentCommit&&(o.parent_commit=i.parentCommit);let u=(await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${n}/${a}/directories/commits`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await q(d,`push ${r}`),d})).json()).commit.commit_hash,l=n;return n==="-"&&(l=(await this._getSettings()).tenant_handle||n),`${this.getHostUrl()}/hub/${l}/${a}:${u.slice(0,8)}`}async _deleteDirectory(t){let[r,i]=Ot(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete",r);await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${r}/${i}/directories`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(n,"delete directory"),n})}async _repoExists(t,r){try{return await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await q(i,"check repo exists"),i}),!0}catch(i){if(yd(i))return!1;throw i}}async _createRepo(t,r,i){let n={repo_handle:t,repo_type:r,is_public:!!i.isPublic};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags);try{await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await q(a,`create ${r}`),a})}catch(a){if(iI(a))return;throw a}}async _updateRepoMetadata(t,r,i){let n={};i.description!==void 0&&(n.description=i.description),i.readme!==void 0&&(n.readme=i.readme),i.tags!==void 0&&(n.tags=i.tags),i.isPublic!==void 0&&(n.is_public=i.isPublic),Object.keys(n).length!==0&&await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${t}/${r}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(n)});return await q(a,"update repo metadata"),a})}async clonePublicDataset(t,r={}){let{sourceApiUrl:i=this.apiUrl,datasetName:n}=r,[a,o]=this.parseTokenOrUrl(t,i),s=new e({apiUrl:a,apiKey:"placeholder"}),c=await s.readSharedDataset(o),u=n||c.name;try{if(await this.hasDataset({datasetId:u})){console.log(`Dataset ${u} already exists in your tenant. Skipping.`);return}}catch{}let l=await s.listSharedExamples(o),d=await this.createDataset(u,{description:c.description,dataType:c.data_type||"kv",inputsSchema:c.inputs_schema_definition??void 0,outputsSchema:c.outputs_schema_definition??void 0});try{await this.createExamples({inputs:l.map(f=>f.inputs),outputs:l.flatMap(f=>f.outputs?[f.outputs]:[]),datasetId:d.id})}catch(f){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),f}}parseTokenOrUrl(t,r,i=2,n="dataset"){try{return le(t),[r,t]}catch{}try{let o=new URL(t).pathname.split("/").filter(s=>s!=="");if(o.length>=i){let s=o[o.length-i];return[r,s]}else throw new Error(`Invalid public ${n} URL: ${t}`)}catch{throw new Error(`Invalid public ${n} URL or token: ${t}`)}}cleanup(){this._promptCache&&this._promptCache.stop()}async awaitPendingTraceBatches(){if(this.manualFlushMode)return console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches."),Promise.resolve();for(await new Promise(t=>setTimeout(t,1));this._pendingDrains.size>0;)await Promise.all([...this._pendingDrains]);await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await H$()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}toString(){let t=[`apiUrl=${JSON.stringify(this.apiUrl)}`];return this.webUrl!==void 0&&t.push(`webUrl=${JSON.stringify(this.webUrl)}`),this.workspaceId!==void 0&&t.push(`workspaceId=${JSON.stringify(this.workspaceId)}`),`[LangSmithClient ${t.join(" ")}]`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};Object.defineProperty(Tn,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function vI(e){return"dataset_id"in e||"dataset_name"in e}var wI=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>Ze(r)==="true");var Cn=Symbol.for("lc:context_variables");var Sd=Symbol.for("langsmith:replica_trace_roots");function Tg(e,t){if(Cn in e)return e[Cn][t]}function xI(e,t,r){let i=Cn in e?e[Cn]:{};i[t]=r,e[Cn]=i}var jc=36,AM="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function SI(e){let r=Object.keys(e).sort().map(i=>`${i}:${e[i]??""}`).join("|");return Fh(r,AM)}function CM(e){return e.replace(/[-:.]/g,"")}function $I(e,t=1){let r=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${r}Z`}function Ag(e,t,r=1){let i=$I(e,r);return{dottedOrder:CM(i)+t,microsecondPrecisionDatestring:i}}var OM=new Set(["projectName","updates","reroot"]);function PM(e){let t={};for(let r of Object.keys(e))OM.has(r)&&(t[r]=e[r]);return t}var kd=class e{constructor(t,r,i,n){Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.metadata=t,this.tags=r,this.project_name=i,this.replicas=n}static fromHeader(t){let r=t.split(","),i={},n=[],a,o;for(let s of r){let[c,u]=s.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?i=JSON.parse(l):c==="langsmith-tags"?n=l.split(","):c==="langsmith-project"?a=l:c==="langsmith-replicas"&&(o=JSON.parse(l).map(f=>Array.isArray(f)?f:PM(f)))}return new e(i,n,a,o)}toHeader(){let t=[];return this.metadata&&Object.keys(this.metadata).length>0&&t.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`),this.tags&&this.tags.length>0&&t.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`),this.project_name&&t.push(`langsmith-project=${encodeURIComponent(this.project_name)}`),t.join(",")}},Qr=class e{constructor(t){if(Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"run_type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"project_name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parent_run_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_runs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"end_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extra",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"error",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"serialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reference_example_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"trace_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"dotted_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"child_execution_order",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"attachments",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"replicas",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"distributedParentId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_serialized_start_time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_awaitInputsOnPost",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),II(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:i,...n}=t,a=n.client??e.getSharedClient(),o={...i,...n?.extra?.metadata};if(n.extra={...n.extra,metadata:o},"id"in n&&n.id==null&&delete n.id,Object.assign(this,{...r,...n,client:a}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=$I(this.start_time,this.execution_order)),this.id||(this.id=Ql(this._serialized_start_time??this.start_time)),this.trace_id||(this.parent_run?this.trace_id=this.parent_run.trace_id??this.id:this.trace_id=this.id),this.replicas=MM(this.replicas),!this.dotted_order){let{dottedOrder:s}=Ag(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+s:this.dotted_order=s}}set metadata(t){this.extra={...this.extra,metadata:{...this.extra?.metadata,...t}}}get metadata(){return this.extra?.metadata}static getDefaultConfig(){let t=Date.now();return{run_type:"chain",project_name:Ac(),child_runs:[],api_url:_t("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:_t("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new Tn),e.sharedClient}createChild(t){let r=this.child_execution_order+1,i=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),n=t.replicas??i,a=new e({...t,parent_run:this,project_name:this.project_name,replicas:n,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),o=this.extra?.metadata??{},s=a.extra?.metadata??{};Object.keys(o).length>0&&(a.extra={...a.extra,metadata:{...o,...s}}),Cn in this&&(a[Cn]=this[Cn]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(RM(u)){let f={...u},p=NM(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:a.id}),p.handlers?.find(EI)?.updateFromRunTree?.(a),f.callbacks=p),a.extra[c]=f}let l=new Set,d=this;for(;d!=null&&!l.has(d.id);)l.add(d.id),d.child_execution_order=Math.max(d.child_execution_order,r),d=d.parent_run;return this.child_runs.push(a),a}async end(t,r,i=Date.now(),n){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??i,n&&Object.keys(n).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...n}}:{metadata:n})}_convertToCreate(t,r,i=!0){let n=t.extra??{};if(n?.runtime?.library===void 0&&(n.runtime||(n.runtime={}),r))for(let[s,c]of Object.entries(r))n.runtime[s]||(n.runtime[s]=c);let a=t.parent_run?.id??t.parent_run_id,o;return i?o=[]:o=t.child_runs.map(s=>this._convertToCreate(s,r,i)),{id:t.id,name:t.name,start_time:t._serialized_start_time??t.start_time,end_time:t.end_time,run_type:t.run_type,reference_example_id:t.reference_example_id,extra:n,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:o,parent_run_id:a,trace_id:t.trace_id,dotted_order:t.dotted_order,tags:t.tags,attachments:t.attachments,events:t.events}}_sliceParentId(t,r){if(r.dotted_order){let i=r.dotted_order.split("."),n=null;for(let a=0;a<i.length;a++)if(i[a].slice(-jc)===t){n=a;break}if(n!==null){let a=i.slice(n+1);r.dotted_order=a.join("."),a.length>0?r.trace_id=a[0].slice(-jc):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let i=Tg(this,Sd)??{};i[t]=r,xI(this,Sd,i);for(let n of this.child_runs)n._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,runtimeEnv:i,excludeChildRuns:n=!0,reroot:a=!1,distributedParentId:o,apiUrl:s,apiKey:c,workspaceId:u}=t,l=this._convertToCreate(this,i,n);if(r===this.project_name)return{...l,session_name:r};if(a){if(o)this._sliceParentId(o,l);else if(l.parent_run_id=void 0,l.dotted_order){let w=l.dotted_order.split(".");w.length>0&&(l.dotted_order=w[w.length-1],l.trace_id=l.id)}let x=SI({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});this._setReplicaTraceRoot(x,l.id)}let d;if(!a){let x=Tg(this,Sd)??{},w=SI({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});if(d=x[w],d&&(l.trace_id=d,l.dotted_order)){let S=l.dotted_order.split("."),$=null;for(let T=0;T<S.length;T++)if(S[T].slice(-jc)===d){$=T;break}if($!==null){let T=S.slice($);l.dotted_order=T.join(".")}}}let f=l.id,p=Cc(f,r),m;l.trace_id?m=Cc(l.trace_id,r):m=p;let _;l.parent_run_id&&(_=Cc(l.parent_run_id,r));let v;return l.dotted_order&&(v=l.dotted_order.split(".").map(S=>{let $=S.slice(-jc),T=Cc($,r);return S.slice(0,-jc)+T}).join(".")),{...l,id:p,trace_id:m,parent_run_id:_,dotted_order:v,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=ad();if(this.replicas&&this.replicas.length>0)for(let{projectName:i,apiKey:n,apiUrl:a,workspaceId:o,reroot:s,client:c}of this.replicas){let u=this._remapForProject({projectName:i??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:a,apiKey:n,workspaceId:o});await(c??this.client).createRun(u,{apiKey:n,apiUrl:a,workspaceId:o})}else{let i=this._convertToCreate(this,r,t);await this.client.createRun(i)}if(!t){Ea("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let i of this.child_runs)await i.postRun(!1)}this.child_runs=[]}catch(r){console.error(`Error in postRun for run ${this.id}:`,r)}}async patchRun(t){if(this.replicas&&this.replicas.length>0)for(let{projectName:r,apiKey:i,apiUrl:n,workspaceId:a,updates:o,reroot:s,client:c}of this.replicas){let u=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:n,apiKey:i,workspaceId:a}),l={id:u.id,name:u.name,run_type:u.run_type,start_time:u.start_time,outputs:u.outputs,error:u.error,parent_run_id:u.parent_run_id,session_name:u.session_name,reference_example_id:u.reference_example_id,end_time:u.end_time,dotted_order:u.dotted_order,trace_id:u.trace_id,events:u.events,tags:u.tags,extra:u.extra,attachments:this.attachments,...o};t?.excludeInputs||(l.inputs=u.inputs),await(c??this.client).updateRun(u.id,l,{apiKey:i,apiUrl:n,workspaceId:a})}else try{let r={name:this.name,run_type:this.run_type,start_time:this._serialized_start_time??this.start_time,end_time:this.end_time,error:this.error,outputs:this.outputs,parent_run_id:this.parent_run?.id??this.parent_run_id,reference_example_id:this.reference_example_id,extra:this.extra,events:this.events,dotted_order:this.dotted_order,trace_id:this.trace_id,tags:this.tags,attachments:this.attachments,session_name:this.project_name};t?.excludeInputs||(r.inputs=this.inputs),await this.client.updateRun(this.id,r)}catch(r){console.error(`Error in patchRun for run ${this.id}`,r)}this.child_runs=[]}toJSON(){return this._convertToCreate(this,void 0,!1)}addEvent(t){this.events||(this.events=[]),typeof t=="string"?this.events.push({name:"event",time:new Date().toISOString(),message:t}):this.events.push({...t,time:t.time??new Date().toISOString()})}static fromRunnableConfig(t,r){let i=t?.callbacks,n,a,o,s=wI();if(i){let u=i?.getParentRunId?.()??"",l=i?.handlers?.find(d=>d?.name=="langchain_tracer");n=l?.getRun?.(u),a=l?.projectName,o=l?.client,s=s||!!l}return n?new e({name:n.name,id:n.id,trace_id:n.trace_id,dotted_order:n.dotted_order,client:o,tracingEnabled:s,project_name:a,tags:[...new Set((n?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...n?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:o,tracingEnabled:s,project_name:a})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let i="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,n=i["langsmith-trace"];if(!n||typeof n!="string")return;let a=n.trim(),o=a.split(".").map(l=>{let[d,f]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=o[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:o.at(-1)?.uuid,trace_id:s,dotted_order:a};if(i.baggage&&typeof i.baggage=="string"){let l=kd.fromHeader(i.baggage);c.metadata=l.metadata,c.tags=l.tags,c.project_name=l.project_name,c.replicas=l.replicas}let u=new e(c);return u.distributedParentId=u.id,u}toHeaders(t){let r={"langsmith-trace":this.dotted_order,baggage:new kd(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[i,n]of Object.entries(r))t.set(i,n);return r}};Object.defineProperty(Qr,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function II(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function EI(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function kI(e){return Array.isArray(e)&&e.some(t=>EI(t))}function NM(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function RM(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(kI(t?.handlers)||kI(t))}function jM(){let e=_t("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let i of t){if(typeof i!="object"||i===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof i}`);continue}if(typeof i.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_url}`);continue}if(typeof i.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof i.api_key}`);continue}r.push({apiUrl:i.api_url.replace(/\/$/,""),apiKey:i.api_key})}return r}else if(typeof t=="object"&&t!==null){zM(t);let r=[];for(let[i,n]of Object.entries(t)){let a=i.replace(/\/$/,"");if(typeof n=="string")r.push({apiUrl:a,apiKey:n});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${i}: expected string, got ${typeof n}`);continue}}return r}else return console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof t}`),[]}catch(t){if(oI(t))throw t;return console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS \u2013 must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey"),[]}}function MM(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):jM()}function zM(e){if(Object.keys(e).length>0&&Ze("ENDPOINT"))throw new gd}var TI=E({BaseTracer:()=>It,isBaseTracer:()=>Ca}),DM=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function Og(e,t){if(e)return new Qr({...e,start_time:e._serialized_start_time??e.start_time,parent_run:Og(t),child_runs:e.child_runs.map(r=>Og(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:_h()},tracingEnabled:!1})}function Cg(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Ca(e){return typeof e._addRunToRunMap=="function"}var It=class extends Yr{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?DM(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
|
|
150
|
+
|
|
151
|
+
${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=Ag(new Date(e.start_time).getTime(),e.id,e.execution_order),i={...e},n=this.getRunById(i.parent_run_id);if(i.parent_run_id!==void 0?n?(this._addChildRun(n,i),n.child_execution_order=Math.max(n.child_execution_order,i.child_execution_order),i.trace_id=n.trace_id,n.dotted_order!==void 0&&(i.dotted_order=[n.dotted_order,t].join("."),i._serialized_start_time=r)):i.parent_run_id=void 0:(i.trace_id=i.id,i.dotted_order=t,i._serialized_start_time=r),this.usesRunTreeMap){let a=Og(i,n);a!==void 0&&this.runTreeMap.set(i.id,a)}else this.runMap.set(i.id,i);return i}async _endTrace(e){let t=e.parent_run_id!==void 0&&this.getRunById(e.parent_run_id);t?t.child_execution_order=Math.max(t.child_execution_order,e.child_execution_order):await this.persistRun(e),await this.onRunUpdate?.(e),this.usesRunTreeMap?this.runTreeMap.delete(e.id):this.runMap.delete(e.id)}_getExecutionOrder(e){let t=e!==void 0&&this.getRunById(e);return t?t.child_execution_order+1:1}_createRunForLLMStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),u=Date.now(),l=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{prompts:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:a||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,i,n,a,o,s){let c=this._getExecutionOrder(i),u=Date.now(),l=o?{...n,metadata:o}:n,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:u,serialized:e,events:[{name:"start",time:new Date(u).toISOString()}],inputs:{messages:t},execution_order:c,child_runs:[],child_execution_order:c,run_type:"llm",extra:l??{},tags:a||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.outputs=e,a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMEnd?.(a),await this._endTrace(a),a}async handleLLMError(e,t,r,i,n){let a=this.getRunById(t);if(!a||a?.run_type!=="llm")throw new Error("No LLM run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),a.extra={...a.extra,...n},await this.onLLMError?.(a),await this._endTrace(a),a}_createRunForChainStart(e,t,r,i,n,a,o,s,c){let u=this._getExecutionOrder(i),l=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:i,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:t,execution_order:u,child_execution_order:u,run_type:o??"chain",child_runs:[],extra:a?{...c,metadata:a}:{...c},tags:n||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,i,n,a,o,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,i,n,a,o,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.outputs=Cg(e,"output"),a.events.push({name:"end",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Cg(n.inputs,"input")),await this.onChainEnd?.(a),await this._endTrace(a),a}async handleChainError(e,t,r,i,n){let a=this.getRunById(t);if(!a)throw new Error("No chain run to end.");return a.end_time=Date.now(),a.error=this.stringifyError(e),a.events.push({name:"error",time:new Date(a.end_time).toISOString()}),n?.inputs!==void 0&&(a.inputs=Cg(n.inputs,"input")),await this.onChainError?.(a),await this._endTrace(a),a}_createRunForToolStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{input:t},execution_order:s,child_execution_order:s,run_type:"tool",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onToolStart?.(s),s}async handleToolEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.outputs={output:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onToolEnd?.(r),await this._endTrace(r),r}async handleToolError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="tool")throw new Error("No tool run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onToolError?.(r),await this._endTrace(r),r}async handleAgentAction(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="chain")return;let i=r;i.actions=i.actions||[],i.actions.push(e),i.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(r)}async handleAgentEnd(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(r))}_createRunForRetrieverStart(e,t,r,i,n,a,o){let s=this._getExecutionOrder(i),c=Date.now(),u={id:r,name:o??e.id[e.id.length-1],parent_run_id:i,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{query:t},execution_order:s,child_execution_order:s,run_type:"retriever",child_runs:[],extra:a?{metadata:a}:{},tags:n||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,i,n,a,o){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,i,n,a,o);return await this.onRunCreate?.(s),await this.onRetrieverStart?.(s),s}async handleRetrieverEnd(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.outputs={documents:e},r.events.push({name:"end",time:new Date(r.end_time).toISOString()}),await this.onRetrieverEnd?.(r),await this._endTrace(r),r}async handleRetrieverError(e,t){let r=this.getRunById(t);if(!r||r?.run_type!=="retriever")throw new Error("No retriever run to end");return r.end_time=Date.now(),r.error=this.stringifyError(e),r.events.push({name:"error",time:new Date(r.end_time).toISOString()}),await this.onRetrieverError?.(r),await this._endTrace(r),r}async handleText(e,t){let r=this.getRunById(t);!r||r?.run_type!=="chain"||(r.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(r))}async handleLLMNewToken(e,t,r,i,n,a){let o=this.getRunById(r);if(!o||o?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return o.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:a?.chunk}}),await this.onLLMNewToken?.(o,e,{chunk:a?.chunk}),o}};var Pg=pa(PI(),1),RI=E({ConsoleCallbackHandler:()=>$d});function Ht(e,t){return`${e.open}${t}${e.close}`}function Nr(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function NI(e){return typeof e=="string"?e.trim():e==null?e:Nr(e,e.toString())}function Ci(e){if(!e.end_time)return"";let t=e.end_time-e.start_time;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`}var{color:nr}=Pg.default,$d=class extends It{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let i=this.runMap.get(r.parent_run_id);if(i)t.push(i),r=i;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,i,n)=>{let a=`${r.execution_order}:${r.run_type}:${r.name}`;return i===n.length-1?Ht(Pg.default.bold,a):a}).join(" > ");return Ht(nr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Nr(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.cyan,"[chain/end]")} [${t}] [${Ci(e)}] Exiting Chain run with output: ${Nr(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.red,"[chain/error]")} [${t}] [${Ci(e)}] Chain run errored with error: ${Nr(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(i=>i.trim())}:e.inputs;console.log(`${Ht(nr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Nr(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.cyan,"[llm/end]")} [${t}] [${Ci(e)}] Exiting LLM run with output: ${Nr(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.red,"[llm/error]")} [${t}] [${Ci(e)}] LLM run errored with error: ${Nr(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${NI(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.cyan,"[tool/end]")} [${t}] [${Ci(e)}] Exiting Tool run with output: "${NI(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.red,"[tool/error]")} [${t}] [${Ci(e)}] Tool run errored with error: ${Nr(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Nr(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.cyan,"[retriever/end]")} [${t}] [${Ci(e)}] Exiting Retriever run with output: ${Nr(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${Ht(nr.red,"[retriever/error]")} [${t}] [${Ci(e)}] Retriever run errored with error: ${Nr(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${Ht(nr.blue,"[agent/action]")} [${r}] Agent selected action: ${Nr(t.actions[t.actions.length-1],"[action]")}`)}};var Ng,Id=()=>(Ng===void 0&&(Ng=new Tn(Ft("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),Ng);var jg=class{getStore(){}run(t,r){return r()}},Rg=Symbol.for("ls:tracing_async_local_storage"),LM=new jg,Mg=class{getInstance(){return globalThis[Rg]??LM}initializeGlobalInstance(t){globalThis[Rg]===void 0&&(globalThis[Rg]=t)}},FM=new Mg;function jI(e=!1){let t=FM.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
|
|
152
|
+
|
|
153
|
+
Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function Ed(e){return typeof e=="function"&&"langsmith:traceable"in e}var MI=E({LangChainTracer:()=>Td});function BM(e){let t;for(let r of e)for(let i of r)Ee.isInstance(i.message)&&i.message.usage_metadata!==void 0&&(t=Uo(t,i.message.usage_metadata));return t}var Td=class zI extends It{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;constructor(t={}){super(t);let{exampleId:r,projectName:i,client:n,replicas:a}=t;this.projectName=i??Ac(),this.replicas=a,this.exampleId=r,this.client=n??Id();let o=zI.getTraceableRunTree();o&&this.updateFromRunTree(o)}async persistRun(t){}async onRunCreate(t){t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){let r=this.getRunTreeWithTracingConfig(t.id);t.extra?.lc_defers_inputs?await r?.postRun():await r?.patchRun()}onLLMEnd(t){let r=t.outputs;if(r?.generations){let i=BM(r.generations);if(i!==void 0){t.extra=t.extra??{};let n=t.extra.metadata??{};n.usage_metadata=i,t.extra.metadata=n}}}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,i=new Set;for(;r.parent_run&&!(i.has(r.id)||(i.add(r.id),!r.parent_run));)r=r.parent_run;i.clear();let n=[r];for(;n.length>0;){let a=n.shift();!a||i.has(a.id)||(i.add(a.id),this.runTreeMap.set(a.id,a),a.child_runs&&n.push(...a.child_runs))}this.client=t.client??this.client,this.replicas=t.replicas??this.replicas,this.projectName=t.project_name??this.projectName,this.exampleId=t.reference_example_id??this.exampleId}getRunTreeWithTracingConfig(t){let r=this.runTreeMap.get(t);if(r)return new Qr({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return jI(!0)}catch{return}}};var DI=Symbol.for("ls:tracing_async_local_storage"),Oi=Symbol.for("lc:context_variables"),UI=e=>{globalThis[DI]=e},Pi=()=>globalThis[DI];var Ad=pa(md(),1),Oa;function ZM(){return new("default"in Ad.default?Ad.default.default:Ad.default)({autoStart:!0,concurrency:1})}function VM(){return typeof Oa>"u"&&(Oa=ZM()),Oa}async function qe(e,t){if(t===!0){let r=Pi();r!==void 0?await r.run(void 0,async()=>e()):await e()}else Oa=VM(),Oa.add(async()=>{let r=Pi();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function LI(){let e=Id();await Promise.allSettled([typeof Oa<"u"?Oa.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var FI=E({awaitAllCallbacks:()=>LI,consumeCallback:()=>qe});var BI=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>Ft(t)==="true");function zg(e){let t=Pi();if(t!==void 0)return t.getStore()?.[Oi]?.[e]}var GM=Symbol("lc:configure_hooks"),ZI=()=>zg(GM)||[];var VI=E({BaseCallbackManager:()=>GI,BaseRunManager:()=>zc,CallbackManager:()=>ot,CallbackManagerForChainRun:()=>JI,CallbackManagerForLLMRun:()=>Dg,CallbackManagerForRetrieverRun:()=>HI,CallbackManagerForToolRun:()=>KI,ensureHandler:()=>Yo,parseCallbackConfigArg:()=>Pa});function Pa(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var GI=class{setHandler(e){return this.setHandlers([e])}},zc=class{constructor(e,t,r,i,n,a,o,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=i,this.inheritableTags=n,this.metadata=a,this.inheritableMetadata=o,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>qe(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleCustomEvent(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{try{await a.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},HI=class extends zc{getChild(e){let t=new ot(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleRetrieverEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw r}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${r}`),t.raiseError)throw e}},t.awaitHandlers)))}},Dg=class extends zc{async handleLLMNewToken(e,t,r,i,n,a){await Promise.all(this.handlers.map(o=>qe(async()=>{if(!o.ignoreLLM)try{await o.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,a)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMNewToken: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}async handleLLMError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleLLMEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreLLM)try{await a.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}},JI=class extends zc{getChild(e){let t=new ot(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleChainError(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreChain)try{await a.handleChainError?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainError: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleChainEnd(e,t,r,i,n){await Promise.all(this.handlers.map(a=>qe(async()=>{if(!a.ignoreChain)try{await a.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,n)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleChainEnd: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},KI=class extends zc{getChild(e){let t=new ot(this.runId);return t.setHandlers(this.inheritableHandlers),t.addTags(this.inheritableTags),t.addMetadata(this.inheritableMetadata),e&&t.addTags([e],!1),t}async handleToolError(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEvent(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if(t.raiseError)throw r}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>qe(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(r){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${r}`),t.raiseError)throw r}},t.awaitHandlers)))}},ot=class Mc extends GI{handlers=[];inheritableHandlers=[];tags=[];inheritableTags=[];metadata={};inheritableMetadata={};name="callback_manager";_parentRunId;constructor(t,r){super(),this.handlers=r?.handlers??this.handlers,this.inheritableHandlers=r?.inheritableHandlers??this.inheritableHandlers,this.tags=r?.tags??this.tags,this.inheritableTags=r?.inheritableTags??this.inheritableTags,this.metadata=r?.metadata??this.metadata,this.inheritableMetadata=r?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=t}getParentRunId(){return this._parentRunId}async handleLLMStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:Or();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ca(f)&&f._createRunForLLMStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),qe(async()=>{try{await f.handleLLMStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c)}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new Dg(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,i=void 0,n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&i?i:Or();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return Ca(f)&&f._createRunForChatModelStart(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c),qe(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[u],d,this._parentRunId,a,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=Fo(u);await f.handleLLMStart?.(t,[p],d,this._parentRunId,a,this.tags,this.metadata,c)}}catch(p){if((f.raiseError?console.error:console.warn)(`Error in handler ${f.constructor.name}, handleLLMStart: ${p}`),f.raiseError)throw p}},f.awaitHandlers)})),new Dg(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,i=Or(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return Ca(l)&&l._createRunForChainStart(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u),qe(async()=>{try{await l.handleChainStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,n,s,u)}catch(d){if((l.raiseError?console.error:console.warn)(`Error in handler ${l.constructor.name}, handleChainStart: ${d}`),l.raiseError)throw d}},l.awaitHandlers)})),new JI(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,i=Or(),n=void 0,a=void 0,o=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Ca(u)&&u._createRunForToolStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),qe(async()=>{try{await u.handleToolStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s,c)}catch(l){if((u.raiseError?console.error:console.warn)(`Error in handler ${u.constructor.name}, handleToolStart: ${l}`),u.raiseError)throw l}},u.awaitHandlers)})),new KI(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,i=Or(),n=void 0,a=void 0,o=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return Ca(c)&&c._createRunForRetrieverStart(t,r,i,this._parentRunId,this.tags,this.metadata,s),qe(async()=>{try{await c.handleRetrieverStart?.(t,r,i,this._parentRunId,this.tags,this.metadata,s)}catch(u){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${u}`),c.raiseError)throw u}},c.awaitHandlers)})),new HI(i,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,i,n,a){await Promise.all(this.handlers.map(o=>qe(async()=>{if(!o.ignoreCustomEvent)try{await o.handleCustomEvent?.(t,r,i,this.tags,this.metadata)}catch(s){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${s}`),o.raiseError)throw s}},o.awaitHandlers)))}addHandler(t,r=!0){this.handlers.push(t),r&&this.inheritableHandlers.push(t)}removeHandler(t){this.handlers=this.handlers.filter(r=>r!==t),this.inheritableHandlers=this.inheritableHandlers.filter(r=>r!==t)}setHandlers(t,r=!0){this.handlers=[],this.inheritableHandlers=[];for(let i of t)this.addHandler(i,r)}addTags(t,r=!0){this.removeTags(t),this.tags.push(...t),r&&this.inheritableTags.push(...t)}removeTags(t){this.tags=this.tags.filter(r=>!t.includes(r)),this.inheritableTags=this.inheritableTags.filter(r=>!t.includes(r))}addMetadata(t,r=!0){this.metadata={...this.metadata,...t},r&&(this.inheritableMetadata={...this.inheritableMetadata,...t})}removeMetadata(t){for(let r of Object.keys(t))delete this.metadata[r],delete this.inheritableMetadata[r]}copy(t=[],r=!0){let i=new Mc(this._parentRunId);for(let n of this.handlers){let a=this.inheritableHandlers.includes(n);i.addHandler(n,a)}for(let n of this.tags){let a=this.inheritableTags.includes(n);i.addTags([n],a)}for(let n of Object.keys(this.metadata)){let a=Object.keys(this.inheritableMetadata).includes(n);i.addMetadata({[n]:this.metadata[n]},a)}for(let n of t)i.handlers.filter(a=>a.name==="console_callback_handler").some(a=>a.name===n.name)||i.addHandler(n,r);return i}static fromHandlers(t){class r extends Yr{name=Or();constructor(){super(),Object.assign(this,t)}}let i=new this;return i.addHandler(new r),i}static configure(t,r,i,n,a,o,s){return this._configureSync(t,r,i,n,a,o,s)}static _configureSync(t,r,i,n,a,o,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new Mc,c.setHandlers(t?.map(Yo)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(Yo):r?.handlers,!1));let u=Ft("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=Td.getTraceableRunTree(),d=l?.tracingEnabled??BI();if(l?.tracingEnabled===!1&&c){let p=c.handlers.filter(m=>m.name==="langchain_tracer");for(let m of p)c.removeHandler(m)}let f=d||(Ft("LANGCHAIN_TRACING")??!1);if(u||f){if(c||(c=new Mc),u&&!c.handlers.some(p=>p.name===$d.prototype.name)){let p=new $d;c.addHandler(p,!0)}if(f&&!c.handlers.some(p=>p.name==="langchain_tracer")&&d){let p=new Td;c.addHandler(p,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(p=>p.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:p,inheritable:m=!0,handlerClass:_,envVar:v}of ZI()){let x=v&&Ft(v)==="true"&&_,w,S=p!==void 0?zg(p):void 0;S&&jh(S)?w=S:x&&(w=new _({})),w!==void 0&&(c||(c=new Mc),c.handlers.some($=>$.name===w.name)||c.addHandler(w,m))}return(i||n)&&c&&(c.addTags(i??[]),c.addTags(n??[],!1)),(a||o)&&c&&(c.addMetadata(a??{}),c.addMetadata(o??{},!1)),c}};function Yo(e){return"name"in e?e:Yr.fromMethods(e)}var Ug=class{getStore(){}run(e,t){return t()}enterWith(e){}},HM=new Ug,WI=Symbol.for("lc:child_config"),JM=class{getInstance(){return Pi()??HM}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[WI]}runWithConfig(e,t,r){let i=ot._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),n=this.getInstance(),a=n.getStore(),o=i?.getParentRunId(),s=i?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return s&&o?c=s.getRunTreeWithTracingConfig(o):r||(c=new Qr({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[WI]:e}),a!==void 0&&a[Oi]!==void 0&&(c===void 0&&(c={}),c[Oi]=a[Oi]),n.run(c,t)}initializeGlobalInstance(e){Pi()===void 0&&UI(e)}},$e=new JM;var qI=E({AsyncLocalStorageProviderSingleton:()=>$e,MockAsyncLocalStorage:()=>Ug,_CONTEXT_VARIABLES_KEY:()=>Oi});async function yt(e){return ot._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function vt(...e){let t={};for(let r of e.filter(i=>!!i))for(let i of Object.keys(r))if(i==="metadata")t[i]={...t[i],...r[i]};else if(i==="tags"){let n=t[i]??[];t[i]=[...new Set(n.concat(r[i]??[]))]}else if(i==="configurable")t[i]={...t[i],...r[i]};else if(i==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(i==="signal")t.signal===void 0?t.signal=r.signal:r.signal!==void 0&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,r.signal]):t.signal=r.signal);else if(i==="callbacks"){let n=t.callbacks,a=r.callbacks;if(Array.isArray(a))if(!n)t.callbacks=a;else if(Array.isArray(n))t.callbacks=n.concat(a);else{let o=n.copy();for(let s of a)o.addHandler(Yo(s),!0);t.callbacks=o}else if(a)if(!n)t.callbacks=a;else if(Array.isArray(n)){let o=a.copy();for(let s of n)o.addHandler(Yo(s),!0);t.callbacks=o}else t.callbacks=new ot(a._parentRunId,{handlers:n.handlers.concat(a.handlers),inheritableHandlers:n.inheritableHandlers.concat(a.inheritableHandlers),tags:Array.from(new Set(n.tags.concat(a.tags))),inheritableTags:Array.from(new Set(n.inheritableTags.concat(a.inheritableTags))),metadata:{...n.metadata,...a.metadata}})}else{let n=i;t[n]=r[n]??t[n]}return t}var KM=new Set(["string","number","boolean"]);function ye(e){let t=$e.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:i,runName:n,...a}=t;r=Object.entries(a).reduce((o,[s,c])=>(c!==void 0&&(o[s]=c),o),r)}if(e&&(r=Object.entries(e).reduce((i,[n,a])=>(a!==void 0&&(i[n]=a),i),r)),r?.configurable)for(let i of Object.keys(r.configurable))KM.has(typeof r.configurable[i])&&!r.metadata?.[i]&&(r.metadata||(r.metadata={}),r.metadata[i]=r.configurable[i]);if(r.timeout!==void 0){if(r.timeout<=0)throw new Error("Timeout must be a positive number");let i=r.timeout,n=AbortSignal.timeout(i);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=i),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,n])):r.signal=n,delete r.timeout}return r}function Se(e={},{callbacks:t,maxConcurrency:r,recursionLimit:i,runName:n,configurable:a,runId:o}={}){let s=ye(e);return t!==void 0&&(delete s.runName,s.callbacks=t),i!==void 0&&(s.recursionLimit=i),r!==void 0&&(s.maxConcurrency=r),n!==void 0&&(s.runName=n),a!==void 0&&(s.configurable={...s.configurable,...a}),o!==void 0&&delete s.runId,s}function ir(e){if(e)return{configurable:e.configurable,recursionLimit:e.recursionLimit,callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,maxConcurrency:e.maxConcurrency,timeout:e.timeout,signal:e.signal,store:e.store}}async function yr(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(i=>{if(!t?.aborted)throw i}),new Promise((i,n)=>{r=()=>{n(Ni(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&n(Ni(t))})]).finally(()=>t.removeEventListener("abort",r))}function Ni(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var XI=E({AsyncGeneratorWithSetup:()=>Ri,IterableReadableStream:()=>ut,atee:()=>Cd,concat:()=>vr,pipeGeneratorWithSetup:()=>Fg}),ut=class Lg extends ReadableStream{reader;ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{let t=await this.reader.read();return t.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:t.value}}catch(t){throw this.reader.releaseLock(),t}}async return(){if(this.ensureReader(),this.locked){let t=this.reader.cancel();this.reader.releaseLock(),await t}return{done:!0,value:void 0}}async throw(t){if(this.ensureReader(),this.locked){let r=this.reader.cancel();this.reader.releaseLock(),await r}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let r=t.getReader();return new Lg({start(i){return n();function n(){return r.read().then(({done:a,value:o})=>{if(a){i.close();return}return i.enqueue(o),n()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Lg({async pull(r){let{value:i,done:n}=await t.next();n&&r.close(),r.enqueue(i)},async cancel(r){await t.return(r)}})}};function Cd(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(n){for(;;)if(n.length===0){let a=await e.next();for(let o of r)o.push(a)}else{if(n[0].done)return;yield n.shift().value}})}function vr(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string")return e+t;if(typeof e=="number"&&typeof t=="number")return e+t;if("concat"in e&&typeof e.concat=="function")return e.concat(t);if(typeof e=="object"&&typeof t=="object"){let r={...e};for(let[i,n]of Object.entries(t))i in r&&!Array.isArray(r[i])?r[i]=vr(r[i],n):r[i]=n;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Ri=class{generator;setup;config;signal;firstResult;firstResultUsed=!1;constructor(e){this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise((t,r)=>{$e.runWithConfig(ir(e.config),async()=>{this.firstResult=this.signal?yr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(i=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?$e.runWithConfig(ir(this.config),this.signal?async()=>yr(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}};async function Fg(e,t,r,i,...n){let a=new Ri({generator:t,startSetup:r,signal:i}),o=await a.setup;return{output:e(a,o,...n),setup:o}}var WM=Object.prototype.hasOwnProperty;function Pd(e,t){return WM.call(e,t)}function Nd(e){if(Array.isArray(e)){let r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=""+i;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)Pd(e,r)&&t.push(r);return t}function br(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Rd(e){let t=0,r=e.length,i;for(;t<r;){if(i=e.charCodeAt(t),i>=48&&i<=57){t++;continue}return!1}return!0}function Na(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function QI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Od(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,i=e.length;r<i;r++)if(Od(e[r]))return!0}else if(typeof e=="object"){let r=Nd(e),i=r.length;for(var t=0;t<i;t++)if(Od(e[r[t]]))return!0}}return!1}function YI(e,t){let r=[e];for(let i in t){let n=typeof t[i]=="object"?JSON.stringify(t[i],null,2):t[i];typeof n<"u"&&r.push(`${i}: ${n}`)}return r.join(`
|
|
154
|
+
`)}var eE=class extends Error{constructor(e,t,r,i,n){super(YI(e,{name:t,index:r,operation:i,tree:n})),this.name=t,this.index=r,this.operation=i,this.tree=n,Object.setPrototypeOf(this,new.target.prototype),this.message=YI(e,{name:t,index:r,operation:i,tree:n})}};var tE=E({JsonPatchError:()=>Qe,_areEquals:()=>Dc,applyOperation:()=>Ra,applyPatch:()=>ji,applyReducer:()=>YM,deepClone:()=>qM,getValueByPointer:()=>jd,validate:()=>rE,validator:()=>Md}),Qe=eE,qM=br,Qo={add:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return delete e[t],{newDocument:r,removed:i}},replace:function(e,t,r){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:function(e,t,r){let i=jd(r,this.path);i&&(i=br(i));let n=Ra(r,{op:"remove",path:this.from}).removed;return Ra(r,{op:"add",path:this.path,value:n}),{newDocument:r,removed:i}},copy:function(e,t,r){let i=jd(r,this.from);return Ra(r,{op:"add",path:this.path,value:br(i)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Dc(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},XM={add:function(e,t,r){return Rd(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){return{newDocument:r,removed:e.splice(t,1)[0]}},replace:function(e,t,r){var i=e[t];return e[t]=this.value,{newDocument:r,removed:i}},move:Qo.move,copy:Qo.copy,test:Qo.test,_get:Qo._get};function jd(e,t){if(t=="")return e;var r={op:"_get",path:t};return Ra(e,r),r.value}function Ra(e,t,r=!1,i=!0,n=!0,a=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):Md(t,0)),t.path===""){let o={newDocument:e};if(t.op==="add")return o.newDocument=t.value,o;if(t.op==="replace")return o.newDocument=t.value,o.removed=e,o;if(t.op==="move"||t.op==="copy")return o.newDocument=jd(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=Dc(e,t.value),o.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o.newDocument=e,o}else{if(t.op==="remove")return o.removed=e,o.newDocument=null,o;if(t.op==="_get")return t.value=e,o;if(r)throw new Qe("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else{i||(e=br(e));let o=(t.path||"").split("/"),s=e,c=1,u=o.length,l,d,f;for(typeof r=="function"?f=r:f=Md;;){if(d=o[c],d&&d.indexOf("~")!=-1&&(d=QI(d)),n&&(d=="__proto__"||d=="prototype"&&c>0&&o[c-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&l===void 0&&(s[d]===void 0?l=o.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&f(t,0,e,l)),c++,Array.isArray(s)){if(d==="-")d=s.length;else{if(r&&!Rd(d))throw new Qe("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,t,e);Rd(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new Qe("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);let p=XM[t.op].call(t,s,d,e);if(p.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}}else if(c>=u){let p=Qo[t.op].call(t,s,d,e);if(p.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return p}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new Qe("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function ji(e,t,r,i=!0,n=!0){if(r&&!Array.isArray(t))throw new Qe("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");i||(e=br(e));let a=new Array(t.length);for(let o=0,s=t.length;o<s;o++)a[o]=Ra(e,t[o],r,!0,n,o),e=a[o].newDocument;return a.newDocument=e,a}function YM(e,t,r){let i=Ra(e,t);if(i.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return i.newDocument}function Md(e,t,r,i){if(typeof e!="object"||e===null||Array.isArray(e))throw new Qe("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(Qo[e.op]){if(typeof e.path!="string")throw new Qe("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new Qe('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new Qe("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new Qe("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Od(e.value))throw new Qe("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var n=e.path.split("/").length,a=i.split("/").length;if(n!==a+1&&n!==a)throw new Qe("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==i)throw new Qe("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var o=rE([{op:"_get",path:e.from,value:void 0}],r);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new Qe("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new Qe("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function rE(e,t,r){try{if(!Array.isArray(e))throw new Qe("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)ji(br(t),br(e),r||!0);else{r=r||Md;for(var i=0;i<e.length;i++)r(e[i],i,t,void 0)}}catch(n){if(n instanceof Qe)return n;throw n}}function Dc(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),i=Array.isArray(t),n,a,o;if(r&&i){if(a=e.length,a!=t.length)return!1;for(n=a;n--!==0;)if(!Dc(e[n],t[n]))return!1;return!0}if(r!=i)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(n=a;n--!==0;)if(!t.hasOwnProperty(s[n]))return!1;for(n=a;n--!==0;)if(o=s[n],!Dc(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function nE(e,t,r,i,n){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=Nd(t),o=Nd(e),s=!1,c=o.length-1;c>=0;c--){var u=o[c],l=e[u];if(Pd(t,u)&&!(t[u]===void 0&&l!==void 0&&Array.isArray(t)===!1)){var d=t[u];typeof l=="object"&&l!=null&&typeof d=="object"&&d!=null&&Array.isArray(l)===Array.isArray(d)?nE(l,d,r,i+"/"+Na(u),n):l!==d&&(n&&r.push({op:"test",path:i+"/"+Na(u),value:br(l)}),r.push({op:"replace",path:i+"/"+Na(u),value:br(d)}))}else Array.isArray(e)===Array.isArray(t)?(n&&r.push({op:"test",path:i+"/"+Na(u),value:br(l)}),r.push({op:"remove",path:i+"/"+Na(u)}),s=!0):(n&&r.push({op:"test",path:i,value:e}),r.push({op:"replace",path:i,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var u=a[c];!Pd(e,u)&&t[u]!==void 0&&r.push({op:"add",path:i+"/"+Na(u),value:br(t[u])})}}}function Mi(e,t,r=!1){var i=[];return nE(e,t,i,"",r),i}({...tE});var oE=E({LogStreamCallbackHandler:()=>Dd,RunLog:()=>zd,RunLogPatch:()=>On,isLogStreamHandler:()=>Zg}),On=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=ji({},t);return new zd({ops:t,state:r[r.length-1].newDocument})}},zd=class Bg extends On{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),i=ji(this.state,t.ops);return new Bg({ops:r,state:i[i.length-1].newDocument})}static fromRunLogPatch(t){let r=ji({},t.ops);return new Bg({ops:t.ops,state:r[r.length-1].newDocument})}},Zg=e=>e.name==="log_stream_tracer";async function iE(e,t){if(t==="original")throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");let{inputs:r}=e;if(["retriever","llm","prompt"].includes(e.run_type))return r;if(!(Object.keys(r).length===1&&r?.input===""))return r.input}async function aE(e,t){let{outputs:r}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?r:r!==void 0&&Object.keys(r).length===1&&r?.output!==void 0?r.output:r}function QM(e){return e!==void 0&&e.message!==void 0}var Dd=class extends It{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;_schemaFormat="original";rootId;keyMapByRunId={};counterMapByRunName={};transformStream;writer;receiveStream;name="log_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=ut.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let i=this.keyMapByRunId[e];i&&await this.writer.write(new On({ops:[{op:"add",path:`/logs/${i}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new On({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;this.counterMapByRunName[e.name]===void 0&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;let t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=t===1?e.name:`${e.name}:${t}`;let r={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};this._schemaFormat==="streaming_events"&&(r.inputs=await iE(e,this._schemaFormat)),await this.writer.write(new On({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:r}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let r=[];this._schemaFormat==="streaming_events"&&r.push({op:"replace",path:`/logs/${t}/inputs`,value:await iE(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await aE(e,this._schemaFormat)}),e.end_time!==void 0&&r.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let i=new On({ops:r});await this.writer.write(i)}finally{if(e.id===this.rootId){let t=new On({ops:[{op:"replace",path:"/final_output",value:await aE(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let i=this.keyMapByRunId[e.id];if(i===void 0)return;let n=e.inputs.messages!==void 0,a;n?QM(r?.chunk)?a=r?.chunk:a=new mt({id:`run-${e.id}`,content:t}):a=t;let o=new On({ops:[{op:"add",path:`/logs/${i}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${i}/streamed_output/-`,value:a}]});await this.writer.write(o)}};var sE=E({ChatGenerationChunk:()=>zi,GenerationChunk:()=>ri,RUN_KEY:()=>ja}),ja="__run",ri=class cE{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new cE({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},zi=class uE extends ri{message;constructor(t){super(t),this.message=t.message}concat(t){return new uE({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var ez=Object.prototype.toString,tz=e=>ez.call(e)==="[object Error]",rz=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function lE(e){if(!(e&&tz(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:r}=e;return t==="Load failed"?r===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:rz.has(t)}function nz(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function Ud(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var iz=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}};function az(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function dE(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function oz({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof iz)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),dE(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=dE(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!lE(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=az(r,n),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let _=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",_),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",_),p()},f);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",_,{once:!0})}),n.signal?.throwIfAborted(),!0}async function Uc(e,t={}){if(t={...t},nz(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,Ud("factor",t.factor,{min:0,allowInfinity:!1}),Ud("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ud("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ud("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await oz({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Ld=pa(md(),1),fE=E({AsyncCaller:()=>ni}),sz=[400,401,402,403,404,405,406,407,409],cz=e=>{if(typeof e!="object"||e===null)return;if("message"in e&&typeof e.message=="string"&&(e.message.startsWith("Cancel")||e.message.startsWith("AbortError"))||"name"in e&&typeof e.name=="string"&&e.name==="AbortError"||"code"in e&&typeof e.code=="string"&&e.code==="ECONNABORTED")throw e;let t="response"in e&&typeof e.response=="object"&&e.response!==null&&"status"in e.response&&typeof e.response.status=="number"?e.response.status:void 0,r="status"in e&&typeof e.status=="number"?e.status:void 0,i=t??r;if(i&&sz.includes(+i))throw e;if(("error"in e&&typeof e.error=="object"&&e.error!==null&&"code"in e.error&&typeof e.error.code=="string"?e.error.code:void 0)==="insufficient_quota"){let n=new Error("message"in e&&typeof e.message=="string"?e.message:"Insufficient quota");throw n.name="InsufficientQuotaError",n}},ni=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??cz,this.queue=new("default"in Ld.default?Ld.default.default:Ld.default)({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>Uc(()=>e(...t).catch(r=>{throw r instanceof Error?r:new Error(r)}),{onFailedAttempt:({error:r})=>this.onFailedAttempt?.(r),retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...r){if(e.signal){let i;return Promise.race([this.call(t,...r),new Promise((n,a)=>{i=()=>{a(Ni(e.signal))},e.signal?.addEventListener("abort",i,{once:!0})})]).finally(()=>{e.signal&&i&&e.signal.removeEventListener("abort",i)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var pE=E({isSerializableSchema:()=>Ma,isStandardJsonSchema:()=>Fd,isStandardSchema:()=>mE});function mE(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function Fd(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Ma(e){return mE(e)&&Fd(e)}var oi={};bn(oi,{$ZodAny:()=>Ny,$ZodArray:()=>My,$ZodAsyncError:()=>en,$ZodBase64:()=>Sy,$ZodBase64URL:()=>ky,$ZodBigInt:()=>cf,$ZodBigIntFormat:()=>Ay,$ZodBoolean:()=>Yc,$ZodCIDRv4:()=>by,$ZodCIDRv6:()=>wy,$ZodCUID:()=>cy,$ZodCUID2:()=>uy,$ZodCatch:()=>ev,$ZodCheck:()=>je,$ZodCheckBigIntFormat:()=>D_,$ZodCheckEndsWith:()=>q_,$ZodCheckGreaterThan:()=>tf,$ZodCheckIncludes:()=>K_,$ZodCheckLengthEquals:()=>V_,$ZodCheckLessThan:()=>ef,$ZodCheckLowerCase:()=>H_,$ZodCheckMaxLength:()=>B_,$ZodCheckMaxSize:()=>U_,$ZodCheckMimeType:()=>Y_,$ZodCheckMinLength:()=>Z_,$ZodCheckMinSize:()=>L_,$ZodCheckMultipleOf:()=>M_,$ZodCheckNumberFormat:()=>z_,$ZodCheckOverwrite:()=>Q_,$ZodCheckProperty:()=>X_,$ZodCheckRegex:()=>G_,$ZodCheckSizeEquals:()=>F_,$ZodCheckStartsWith:()=>W_,$ZodCheckStringFormat:()=>ss,$ZodCheckUpperCase:()=>J_,$ZodCodec:()=>ru,$ZodCustom:()=>cv,$ZodCustomStringFormat:()=>Ey,$ZodDate:()=>jy,$ZodDefault:()=>qy,$ZodDiscriminatedUnion:()=>Uy,$ZodE164:()=>$y,$ZodEmail:()=>iy,$ZodEmoji:()=>oy,$ZodEncodeError:()=>Di,$ZodEnum:()=>Vy,$ZodError:()=>Hc,$ZodExactOptional:()=>Ky,$ZodFile:()=>Hy,$ZodFunction:()=>av,$ZodGUID:()=>ry,$ZodIPv4:()=>_y,$ZodIPv6:()=>yy,$ZodISODate:()=>my,$ZodISODateTime:()=>py,$ZodISODuration:()=>gy,$ZodISOTime:()=>hy,$ZodIntersection:()=>Ly,$ZodJWT:()=>Iy,$ZodKSUID:()=>fy,$ZodLazy:()=>sv,$ZodLiteral:()=>Gy,$ZodMAC:()=>vy,$ZodMap:()=>By,$ZodNaN:()=>tv,$ZodNanoID:()=>sy,$ZodNever:()=>eu,$ZodNonOptional:()=>Yy,$ZodNull:()=>Py,$ZodNullable:()=>Wy,$ZodNumber:()=>sf,$ZodNumberFormat:()=>Ty,$ZodObject:()=>GE,$ZodObjectJIT:()=>zy,$ZodOptional:()=>Ba,$ZodPipe:()=>lf,$ZodPrefault:()=>Xy,$ZodPreprocess:()=>rv,$ZodPromise:()=>ov,$ZodReadonly:()=>nv,$ZodRealError:()=>or,$ZodRecord:()=>Fy,$ZodRegistry:()=>mf,$ZodSet:()=>Zy,$ZodString:()=>Fa,$ZodStringFormat:()=>Pe,$ZodSuccess:()=>Qy,$ZodSymbol:()=>Cy,$ZodTemplateLiteral:()=>iv,$ZodTransform:()=>Jy,$ZodTuple:()=>uf,$ZodType:()=>ce,$ZodULID:()=>ly,$ZodURL:()=>ay,$ZodUUID:()=>ny,$ZodUndefined:()=>Oy,$ZodUnion:()=>tu,$ZodUnknown:()=>Qc,$ZodVoid:()=>Ry,$ZodXID:()=>dy,$ZodXor:()=>Dy,$brand:()=>Gg,$constructor:()=>b,$input:()=>lv,$output:()=>uv,Doc:()=>Xc,JSONSchema:()=>JT,JSONSchemaGenerator:()=>Vf,NEVER:()=>Vg,TimePrecision:()=>mv,_any:()=>jv,_array:()=>Lv,_base64:()=>Pf,_base64url:()=>Nf,_bigint:()=>Tv,_boolean:()=>Iv,_catch:()=>OU,_check:()=>HT,_cidrv4:()=>Cf,_cidrv6:()=>Of,_coercedBigint:()=>Av,_coercedBoolean:()=>Ev,_coercedDate:()=>Dv,_coercedNumber:()=>bv,_coercedString:()=>fv,_cuid:()=>Sf,_cuid2:()=>kf,_custom:()=>Bv,_date:()=>zv,_decode:()=>Gd,_decodeAsync:()=>Jd,_default:()=>TU,_discriminatedUnion:()=>gU,_e164:()=>Rf,_email:()=>gf,_emoji:()=>wf,_encode:()=>Vd,_encodeAsync:()=>Hd,_endsWith:()=>ms,_enum:()=>xU,_file:()=>Fv,_float32:()=>xv,_float64:()=>Sv,_gt:()=>Nn,_gte:()=>Kt,_guid:()=>au,_includes:()=>fs,_int:()=>wv,_int32:()=>kv,_int64:()=>Cv,_intersection:()=>_U,_ipv4:()=>Tf,_ipv6:()=>Af,_isoDate:()=>gv,_isoDateTime:()=>hv,_isoDuration:()=>yv,_isoTime:()=>_v,_jwt:()=>jf,_ksuid:()=>Ef,_lazy:()=>jU,_length:()=>Ga,_literal:()=>kU,_lowercase:()=>ls,_lt:()=>Pn,_lte:()=>xr,_mac:()=>pv,_map:()=>bU,_max:()=>xr,_maxLength:()=>Va,_maxSize:()=>Gi,_mime:()=>hs,_min:()=>Kt,_minLength:()=>ai,_minSize:()=>Rn,_multipleOf:()=>Vi,_nan:()=>Uv,_nanoid:()=>xf,_nativeEnum:()=>SU,_negative:()=>zf,_never:()=>cu,_nonnegative:()=>Uf,_nonoptional:()=>AU,_nonpositive:()=>Df,_normalize:()=>gs,_null:()=>Rv,_nullable:()=>EU,_number:()=>vv,_optional:()=>IU,_overwrite:()=>tn,_parse:()=>ns,_parseAsync:()=>is,_pipe:()=>PU,_positive:()=>Mf,_promise:()=>MU,_property:()=>Lf,_readonly:()=>NU,_record:()=>vU,_refine:()=>Zv,_regex:()=>us,_safeDecode:()=>Wd,_safeDecodeAsync:()=>Xd,_safeEncode:()=>Kd,_safeEncodeAsync:()=>qd,_safeParse:()=>as,_safeParseAsync:()=>os,_set:()=>wU,_size:()=>Za,_slugify:()=>bs,_startsWith:()=>ps,_string:()=>dv,_stringFormat:()=>ws,_stringbool:()=>Jv,_success:()=>CU,_superRefine:()=>Vv,_symbol:()=>Pv,_templateLiteral:()=>RU,_toLowerCase:()=>ys,_toUpperCase:()=>vs,_transform:()=>$U,_trim:()=>_s,_tuple:()=>yU,_uint32:()=>$v,_uint64:()=>Ov,_ulid:()=>$f,_undefined:()=>Nv,_union:()=>mU,_unknown:()=>su,_uppercase:()=>ds,_url:()=>ou,_uuid:()=>_f,_uuidv4:()=>yf,_uuidv6:()=>vf,_uuidv7:()=>bf,_void:()=>Mv,_xid:()=>If,_xor:()=>hU,clone:()=>Ge,config:()=>et,createStandardJSONSchemaMethod:()=>xs,createToJSONSchemaMethod:()=>Kv,decode:()=>Mz,decodeAsync:()=>Dz,describe:()=>Gv,encode:()=>jz,encodeAsync:()=>zz,extractDefs:()=>Ji,finalize:()=>Ki,flattenError:()=>Jc,formatError:()=>Kc,globalConfig:()=>za,globalRegistry:()=>Te,initializeContext:()=>Hi,isValidBase64:()=>xy,isValidBase64URL:()=>FE,isValidJWT:()=>BE,locales:()=>iu,meta:()=>Hv,parse:()=>Zi,parseAsync:()=>Ua,prettifyError:()=>i_,process:()=>Ce,regexes:()=>wr,registry:()=>hf,safeDecode:()=>Lz,safeDecodeAsync:()=>Bz,safeEncode:()=>Uz,safeEncodeAsync:()=>Fz,safeParse:()=>a_,safeParseAsync:()=>o_,toDotPath:()=>bE,toJSONSchema:()=>Ha,treeifyError:()=>n_,util:()=>M,version:()=>ey});var hE,Vg=Object.freeze({status:"aborted"});function b(e,t,r){function i(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=o.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let f=l[d];f in s||(s[f]=u[f].bind(s))}}let n=r?.Parent??Object;class a extends n{}Object.defineProperty(a,"name",{value:e});function o(s){var c;let u=r?.Parent?new a:this;i(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Gg=Symbol("zod_brand"),en=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Di=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(hE=globalThis).__zod_globalConfig??(hE.__zod_globalConfig={});var za=globalThis.__zod_globalConfig;function et(e){return e&&Object.assign(za,e),za}var M={};bn(M,{BIGINT_FORMAT_RANGES:()=>t_,Class:()=>Jg,NUMBER_FORMAT_RANGES:()=>e_,aborted:()=>Bi,allowsEval:()=>qg,assert:()=>pz,assertEqual:()=>uz,assertIs:()=>dz,assertNever:()=>fz,assertNotEqual:()=>lz,assignProp:()=>Li,base64ToUint8Array:()=>_E,base64urlToUint8Array:()=>Cz,cached:()=>ts,captureStackTrace:()=>Zd,cleanEnum:()=>Az,cleanRegex:()=>Bc,clone:()=>Ge,cloneDef:()=>hz,createTransparentProxy:()=>wz,defineLazy:()=>ve,esc:()=>Bd,escapeRegex:()=>Rr,explicitlyAborted:()=>r_,extend:()=>kz,finalizeIssue:()=>Jt,floatSafeRemainder:()=>Kg,getElementAtPath:()=>gz,getEnumValues:()=>Fc,getLengthableOrigin:()=>Gc,getParsedType:()=>bz,getSizableOrigin:()=>Vc,hexToUint8Array:()=>Pz,isObject:()=>Da,isPlainObject:()=>Fi,issue:()=>rs,joinValues:()=>I,jsonStringifyReplacer:()=>es,merge:()=>Iz,mergeDefs:()=>ii,normalizeParams:()=>U,nullish:()=>Ui,numKeys:()=>vz,objectClone:()=>mz,omit:()=>Sz,optionalKeys:()=>Qg,parsedType:()=>j,partial:()=>Ez,pick:()=>xz,prefixIssues:()=>ar,primitiveTypes:()=>Yg,promiseAllObject:()=>_z,propertyKeyTypes:()=>Zc,randomString:()=>yz,required:()=>Tz,safeExtend:()=>$z,shallowClone:()=>Xg,slugify:()=>Wg,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>yE,uint8ArrayToBase64url:()=>Oz,uint8ArrayToHex:()=>Nz,unwrapMessage:()=>Lc});function uz(e){return e}function lz(e){return e}function dz(e){}function fz(e){throw new Error("Unexpected value in exhaustive check")}function pz(e){}function Fc(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function I(e,t="|"){return e.map(r=>R(r)).join(t)}function es(e,t){return typeof t=="bigint"?t.toString():t}function ts(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ui(e){return e==null}function Bc(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Kg(e,t){let r=e/t,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var gE=Symbol("evaluating");function ve(e,t,r){let i;Object.defineProperty(e,t,{get(){if(i!==gE)return i===void 0&&(i=gE,i=r()),i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function mz(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Li(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ii(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function hz(e){return ii(e._zod.def)}function gz(e,t){return t?t.reduce((r,i)=>r?.[i],e):e}function _z(e){let t=Object.keys(e),r=t.map(i=>e[i]);return Promise.all(r).then(i=>{let n={};for(let a=0;a<t.length;a++)n[t[a]]=i[a];return n})}function yz(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<e;i++)r+=t[Math.floor(Math.random()*t.length)];return r}function Bd(e){return JSON.stringify(e)}function Wg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Zd="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Da(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var qg=ts(()=>{if(za.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Fi(e){if(Da(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Da(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Xg(e){return Fi(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function vz(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var bz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Zc=new Set(["string","number","symbol"]),Yg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Rr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function U(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function wz(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,a){return t??(t=e()),Reflect.set(t,i,n,a)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function R(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Qg(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var e_={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]},t_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function xz(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let a=ii(e._zod.def,{get shape(){let o={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=r.shape[s])}return Li(this,"shape",o),o},checks:[]});return Ge(e,a)}function Sz(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let a=ii(e._zod.def,{get shape(){let o={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return Li(this,"shape",o),o},checks:[]});return Ge(e,a)}function kz(e,t){if(!Fi(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let a=e._zod.def.shape;for(let o in t)if(Object.getOwnPropertyDescriptor(a,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=ii(e._zod.def,{get shape(){let a={...e._zod.def.shape,...t};return Li(this,"shape",a),a}});return Ge(e,n)}function $z(e,t){if(!Fi(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ii(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Li(this,"shape",i),i}});return Ge(e,r)}function Iz(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=ii(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return Li(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ge(e,r)}function Ez(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let o=ii(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Li(this,"shape",c),c},checks:[]});return Ge(t,o)}function Tz(e,t,r){let i=ii(t._zod.def,{get shape(){let n=t._zod.def.shape,a={...n};if(r)for(let o in r){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(a[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)a[o]=new e({type:"nonoptional",innerType:n[o]});return Li(this,"shape",a),a}});return Ge(t,i)}function Bi(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function r_(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ar(e,t){return t.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Lc(e){return typeof e=="string"?e:e?.message}function Jt(e,t,r){let i=e.message?e.message:Lc(e.inst?._zod.def?.error?.(e))??Lc(t?.error?.(e))??Lc(r.customError?.(e))??Lc(r.localeError?.(e))??"Invalid input",{inst:n,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=i,t?.reportInput&&(s.input=o),s}function Vc(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Gc(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function j(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function rs(...e){let[t,r,i]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:i}:{...t}}function Az(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function _E(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function yE(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Cz(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return _E(t+r)}function Oz(e){return yE(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Pz(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function Nz(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Jg=class{constructor(...t){}};var vE=(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,es,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Hc=b("$ZodError",vE),or=b("$ZodError",vE,{Parent:Error});function Jc(e,t=r=>r.message){let r={},i=[];for(let n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):i.push(t(n));return{formErrors:i,fieldErrors:r}}function Kc(e,t=r=>r.message){let r={_errors:[]},i=(n,a=[])=>{for(let o of n.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s},[...a,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...a,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...a,...o.path]);else{let s=[...a,...o.path];if(s.length===0)r._errors.push(t(o));else{let c=r,u=0;for(;u<s.length;){let l=s[u];u===s.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return i(e),r}function n_(e,t=r=>r.message){let r={errors:[]},i=(n,a=[])=>{var o,s;for(let c of n.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u},[...a,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...a,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...a,...c.path]);else{let u=[...a,...c.path];if(u.length===0){r.errors.push(t(c));continue}let l=r,d=0;for(;d<u.length;){let f=u[d],p=d===u.length-1;typeof f=="string"?(l.properties??(l.properties={}),(o=l.properties)[f]??(o[f]={errors:[]}),l=l.properties[f]):(l.items??(l.items=[]),(s=l.items)[f]??(s[f]={errors:[]}),l=l.items[f]),p&&l.errors.push(t(c)),d++}}};return i(e),r}function bE(e){let t=[],r=e.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function i_(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${bE(i.path)}`);return t.join(`
|
|
155
|
+
`)}var ns=e=>(t,r,i,n)=>{let a=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new en;if(o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>Jt(c,a,et())));throw Zd(s,n?.callee),s}return o.value},Zi=ns(or),is=e=>async(t,r,i,n)=>{let a=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let s=new(n?.Err??e)(o.issues.map(c=>Jt(c,a,et())));throw Zd(s,n?.callee),s}return o.value},Ua=is(or),as=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new en;return a.issues.length?{success:!1,error:new(e??Hc)(a.issues.map(o=>Jt(o,n,et())))}:{success:!0,data:a.value}},a_=as(or),os=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(o=>Jt(o,n,et())))}:{success:!0,data:a.value}},o_=os(or),Vd=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return ns(e)(t,r,n)},jz=Vd(or),Gd=e=>(t,r,i)=>ns(e)(t,r,i),Mz=Gd(or),Hd=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return is(e)(t,r,n)},zz=Hd(or),Jd=e=>async(t,r,i)=>is(e)(t,r,i),Dz=Jd(or),Kd=e=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return as(e)(t,r,n)},Uz=Kd(or),Wd=e=>(t,r,i)=>as(e)(t,r,i),Lz=Wd(or),qd=e=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return os(e)(t,r,n)},Fz=qd(or),Xd=e=>async(t,r,i)=>os(e)(t,r,i),Bz=Xd(or);var wr={};bn(wr,{base64:()=>x_,base64url:()=>Yd,bigint:()=>A_,boolean:()=>O_,browserEmail:()=>qz,cidrv4:()=>b_,cidrv6:()=>w_,cuid:()=>s_,cuid2:()=>c_,date:()=>$_,datetime:()=>E_,domain:()=>Qz,duration:()=>p_,e164:()=>k_,email:()=>h_,emoji:()=>g_,extendedDuration:()=>Zz,guid:()=>m_,hex:()=>eD,hostname:()=>Yz,html5Email:()=>Jz,httpProtocol:()=>S_,idnEmail:()=>Wz,integer:()=>C_,ipv4:()=>__,ipv6:()=>y_,ksuid:()=>d_,lowercase:()=>R_,mac:()=>v_,md5_base64:()=>rD,md5_base64url:()=>nD,md5_hex:()=>tD,nanoid:()=>f_,null:()=>P_,number:()=>Qd,rfc5322Email:()=>Kz,sha1_base64:()=>aD,sha1_base64url:()=>oD,sha1_hex:()=>iD,sha256_base64:()=>cD,sha256_base64url:()=>uD,sha256_hex:()=>sD,sha384_base64:()=>dD,sha384_base64url:()=>fD,sha384_hex:()=>lD,sha512_base64:()=>mD,sha512_base64url:()=>hD,sha512_hex:()=>pD,string:()=>T_,time:()=>I_,ulid:()=>u_,undefined:()=>N_,unicodeEmail:()=>wE,uppercase:()=>j_,uuid:()=>La,uuid4:()=>Vz,uuid6:()=>Gz,uuid7:()=>Hz,xid:()=>l_});var s_=/^[cC][0-9a-z]{6,}$/,c_=/^[0-9a-z]+$/,u_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,l_=/^[0-9a-vA-V]{20}$/,d_=/^[A-Za-z0-9]{27}$/,f_=/^[a-zA-Z0-9_-]{21}$/,p_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zz=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,m_=/^([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})$/,La=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)$/,Vz=La(4),Gz=La(6),Hz=La(7),h_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Kz=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,wE=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Wz=wE,qz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Xz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function g_(){return new RegExp(Xz,"u")}var __=/^(?:(?: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])$/,y_=/^(([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}|:))$/,v_=e=>{let t=Rr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},b_=/^((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])$/,w_=/^(([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])$/,x_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yd=/^[A-Za-z0-9_-]*$/,Yz=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Qz=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,S_=/^https?$/,k_=/^\+[1-9]\d{6,14}$/,xE="(?:(?:\\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])))",$_=new RegExp(`^${xE}$`);function SE(e){let 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 I_(e){return new RegExp(`^${SE(e)}$`)}function E_(e){let t=SE({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${r.join("|")})`;return new RegExp(`^${xE}T(?:${i})$`)}var T_=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},A_=/^-?\d+n?$/,C_=/^-?\d+$/,Qd=/^-?\d+(?:\.\d+)?$/,O_=/^(?:true|false)$/i,P_=/^null$/i;var N_=/^undefined$/i;var R_=/^[^A-Z]*$/,j_=/^[^a-z]*$/,eD=/^[0-9a-fA-F]*$/;function Wc(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function qc(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var tD=/^[0-9a-fA-F]{32}$/,rD=Wc(22,"=="),nD=qc(22),iD=/^[0-9a-fA-F]{40}$/,aD=Wc(27,"="),oD=qc(27),sD=/^[0-9a-fA-F]{64}$/,cD=Wc(43,"="),uD=qc(43),lD=/^[0-9a-fA-F]{96}$/,dD=Wc(64,""),fD=qc(64),pD=/^[0-9a-fA-F]{128}$/,mD=Wc(86,"=="),hD=qc(86);var je=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),$E={number:"number",bigint:"bigint",object:"date"},ef=b("$ZodCheckLessThan",(e,t)=>{je.init(e,t);let r=$E[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tf=b("$ZodCheckGreaterThan",(e,t)=>{je.init(e,t);let r=$E[typeof t.value];e._zod.onattach.push(i=>{let n=i._zod.bag,a=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),M_=b("$ZodCheckMultipleOf",(e,t)=>{je.init(e,t),e._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.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):Kg(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})}}),z_=b("$ZodCheckNumberFormat",(e,t)=>{je.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=e_[t.format];e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,s.minimum=n,s.maximum=a,r&&(s.pattern=C_)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),D_=b("$ZodCheckBigIntFormat",(e,t)=>{je.init(e,t);let[r,i]=t_[t.format];e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,a.minimum=r,a.maximum=i}),e._zod.check=n=>{let a=n.value;a<r&&n.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>i&&n.issues.push({origin:"bigint",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),U_=b("$ZodCheckMaxSize",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;n.size<=t.maximum||i.issues.push({origin:Vc(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),L_=b("$ZodCheckMinSize",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;n.size>=t.minimum||i.issues.push({origin:Vc(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),F_=b("$ZodCheckSizeEquals",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.size!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=i=>{let n=i.value,a=n.size;if(a===t.size)return;let o=a>t.size;i.issues.push({origin:Vc(n),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),B_=b("$ZodCheckMaxLength",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let n=i.value;if(n.length<=t.maximum)return;let o=Gc(n);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Z_=b("$ZodCheckMinLength",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let n=i.value;if(n.length>=t.minimum)return;let o=Gc(n);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),V_=b("$ZodCheckLengthEquals",(e,t)=>{var r;je.init(e,t),(r=e._zod.def).when??(r.when=i=>{let n=i.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push(i=>{let n=i._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=i=>{let n=i.value,a=n.length;if(a===t.length)return;let o=Gc(n),s=a>t.length;i.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ss=b("$ZodCheckStringFormat",(e,t)=>{var r,i;je.init(e,t),e._zod.onattach.push(n=>{let a=n._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),G_=b("$ZodCheckRegex",(e,t)=>{ss.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})}}),H_=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=R_),ss.init(e,t)}),J_=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=j_),ss.init(e,t)}),K_=b("$ZodCheckIncludes",(e,t)=>{je.init(e,t);let r=Rr(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push(n=>{let a=n._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(i)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),W_=b("$ZodCheckStartsWith",(e,t)=>{je.init(e,t);let r=new RegExp(`^${Rr(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),q_=b("$ZodCheckEndsWith",(e,t)=>{je.init(e,t);let r=new RegExp(`.*${Rr(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(i=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function kE(e,t,r){e.issues.length&&t.issues.push(...ar(r,e.issues))}var X_=b("$ZodCheckProperty",(e,t)=>{je.init(e,t),e._zod.check=r=>{let i=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>kE(n,r,t.property));kE(i,r,t.property)}}),Y_=b("$ZodCheckMimeType",(e,t)=>{je.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(i=>{i._zod.bag.mime=t.mime}),e._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),Q_=b("$ZodCheckOverwrite",(e,t)=>{je.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Xc=class{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}let i=t.split(`
|
|
156
|
+
`).filter(o=>o),n=Math.min(...i.map(o=>o.length-o.trimStart().length)),a=i.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(let o of a)this.content.push(o)}compile(){let t=Function,r=this?.args,n=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...r,n.join(`
|
|
157
|
+
`))}};var ey={major:4,minor:4,patch:3};var ce=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ey;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let n of i)for(let a of n._zod.onattach)a(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(o,s,c)=>{let u=Bi(o),l;for(let d of s){if(d._zod.def.when){if(r_(o)||!d._zod.def.when(o))continue}else if(u)continue;let f=o.issues.length,p=d._zod.check(o);if(p instanceof Promise&&c?.async===!1)throw new en;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await p,o.issues.length!==f&&(u||(u=Bi(o,f)))});else{if(o.issues.length===f)continue;u||(u=Bi(o,f))}}return l?l.then(()=>o):o},a=(o,s,c)=>{if(Bi(o))return o.aborted=!0,o;let u=n(s,i,c);if(u instanceof Promise){if(c.async===!1)throw new en;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if(s.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>a(l,o,s)):a(u,o,s)}let c=e._zod.parse(o,s);if(c instanceof Promise){if(s.async===!1)throw new en;return c.then(u=>n(u,i,s))}return n(c,i,s)}}ve(e,"~standard",()=>({validate:n=>{try{let a=a_(e,n);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return o_(e,n).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),Fa=b("$ZodString",(e,t)=>{ce.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??T_(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Pe=b("$ZodStringFormat",(e,t)=>{ss.init(e,t),Fa.init(e,t)}),ry=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=m_),Pe.init(e,t)}),ny=b("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=La(i))}else t.pattern??(t.pattern=La());Pe.init(e,t)}),iy=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=h_),Pe.init(e,t)}),ay=b("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===S_.source&&!/^https?:\/\//i.test(i)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let n=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.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(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.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=n.href:r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),oy=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=g_()),Pe.init(e,t)}),sy=b("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=f_),Pe.init(e,t)}),cy=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=s_),Pe.init(e,t)}),uy=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=c_),Pe.init(e,t)}),ly=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=u_),Pe.init(e,t)}),dy=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=l_),Pe.init(e,t)}),fy=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=d_),Pe.init(e,t)}),py=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=E_(t)),Pe.init(e,t)}),my=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$_),Pe.init(e,t)}),hy=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=I_(t)),Pe.init(e,t)}),gy=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=p_),Pe.init(e,t)}),_y=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=__),Pe.init(e,t),e._zod.bag.format="ipv4"}),yy=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=y_),Pe.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})}}}),vy=b("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=v_(t.delimiter)),Pe.init(e,t),e._zod.bag.format="mac"}),by=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=b_),Pe.init(e,t)}),wy=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=w_),Pe.init(e,t),e._zod.check=r=>{let i=r.value.split("/");try{if(i.length!==2)throw new Error;let[n,a]=i;if(!a)throw new Error;let o=Number(a);if(`${o}`!==a)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function xy(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Sy=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=x_),Pe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{xy(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function FE(e){if(!Yd.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return xy(r)}var ky=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yd),Pe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{FE(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),$y=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=k_),Pe.init(e,t)});function BE(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Iy=b("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{BE(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ey=b("$ZodCustomStringFormat",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),sf=b("$ZodNumber",(e,t)=>{ce.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qd,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),Ty=b("$ZodNumberFormat",(e,t)=>{z_.init(e,t),sf.init(e,t)}),Yc=b("$ZodBoolean",(e,t)=>{ce.init(e,t),e._zod.pattern=O_,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),cf=b("$ZodBigInt",(e,t)=>{ce.init(e,t),e._zod.pattern=A_,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Ay=b("$ZodBigIntFormat",(e,t)=>{D_.init(e,t),cf.init(e,t)}),Cy=b("$ZodSymbol",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Oy=b("$ZodUndefined",(e,t)=>{ce.init(e,t),e._zod.pattern=N_,e._zod.values=new Set([void 0]),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),Py=b("$ZodNull",(e,t)=>{ce.init(e,t),e._zod.pattern=P_,e._zod.values=new Set([null]),e._zod.parse=(r,i)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Ny=b("$ZodAny",(e,t)=>{ce.init(e,t),e._zod.parse=r=>r}),Qc=b("$ZodUnknown",(e,t)=>{ce.init(e,t),e._zod.parse=r=>r}),eu=b("$ZodNever",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Ry=b("$ZodVoid",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),jy=b("$ZodDate",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,a=n instanceof Date;return a&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...a?{received:"Invalid Date"}:{},inst:e}),r}});function EE(e,t,r){e.issues.length&&t.issues.push(...ar(r,e.issues)),t.value[r]=e.value}var My=b("$ZodArray",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let a=[];for(let o=0;o<n.length;o++){let s=n[o],c=t.element._zod.run({value:s,issues:[]},i);c instanceof Promise?a.push(c.then(u=>EE(u,r,o))):EE(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function of(e,t,r,i,n,a){let o=r in i;if(e.issues.length){if(n&&a&&!o)return;t.issues.push(...ar(r,e.issues))}if(!o&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?o&&(t.value[r]=void 0):t.value[r]=e.value}function ZE(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let r=Qg(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function VE(e,t,r,i,n,a){let o=[],s=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let f in t){if(f==="__proto__"||s.has(f))continue;if(u==="never"){o.push(f);continue}let p=c.run({value:t[f],issues:[]},i);p instanceof Promise?e.push(p.then(m=>of(m,r,f,t,l,d))):of(p,r,f,t,l,d)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}var GE=b("$ZodObject",(e,t)=>{if(ce.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let i=ts(()=>ZE(t));ve(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let n=Da,a=t.catchall,o;e._zod.parse=(s,c)=>{o??(o=i.value);let u=s.value;if(!n(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=o.shape;for(let f of o.keys){let p=d[f],m=p._zod.optin==="optional",_=p._zod.optout==="optional",v=p._zod.run({value:u[f],issues:[]},c);v instanceof Promise?l.push(v.then(x=>of(x,s,f,u,m,_))):of(v,s,f,u,m,_)}return a?VE(l,u,s,c,i.value,e):l.length?Promise.all(l).then(()=>s):s}}),zy=b("$ZodObjectJIT",(e,t)=>{GE.init(e,t);let r=e._zod.parse,i=ts(()=>ZE(t)),n=f=>{let p=new Xc(["shape","payload","ctx"]),m=i.value,_=S=>{let $=Bd(S);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};p.write("const input = payload.value;");let v=Object.create(null),x=0;for(let S of m.keys)v[S]=`key_${x++}`;p.write("const newResult = {};");for(let S of m.keys){let $=v[S],T=Bd(S),F=f[S],A=F?._zod?.optin==="optional",y=F?._zod?.optout==="optional";p.write(`const ${$} = ${_(S)};`),A&&y?p.write(`
|
|
158
|
+
if (${$}.issues.length) {
|
|
159
|
+
if (${T} in input) {
|
|
160
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
161
|
+
...iss,
|
|
162
|
+
path: iss.path ? [${T}, ...iss.path] : [${T}]
|
|
163
|
+
})));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (${$}.value === undefined) {
|
|
168
|
+
if (${T} in input) {
|
|
169
|
+
newResult[${T}] = undefined;
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
newResult[${T}] = ${$}.value;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
`):A?p.write(`
|
|
176
|
+
if (${$}.issues.length) {
|
|
177
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
178
|
+
...iss,
|
|
179
|
+
path: iss.path ? [${T}, ...iss.path] : [${T}]
|
|
180
|
+
})));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (${$}.value === undefined) {
|
|
184
|
+
if (${T} in input) {
|
|
185
|
+
newResult[${T}] = undefined;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
newResult[${T}] = ${$}.value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
`):p.write(`
|
|
192
|
+
const ${$}_present = ${T} in input;
|
|
193
|
+
if (${$}.issues.length) {
|
|
194
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
195
|
+
...iss,
|
|
196
|
+
path: iss.path ? [${T}, ...iss.path] : [${T}]
|
|
197
|
+
})));
|
|
198
|
+
}
|
|
199
|
+
if (!${$}_present && !${$}.issues.length) {
|
|
200
|
+
payload.issues.push({
|
|
201
|
+
code: "invalid_type",
|
|
202
|
+
expected: "nonoptional",
|
|
203
|
+
input: undefined,
|
|
204
|
+
path: [${T}]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (${$}_present) {
|
|
209
|
+
if (${$}.value === undefined) {
|
|
210
|
+
newResult[${T}] = undefined;
|
|
211
|
+
} else {
|
|
212
|
+
newResult[${T}] = ${$}.value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let w=p.compile();return(S,$)=>w(f,S,$)},a,o=Da,s=!za.jitless,u=s&&qg.value,l=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=i.value);let m=f.value;return o(m)?s&&u&&p?.async===!1&&p.jitless!==!0?(a||(a=n(t.shape)),f=a(f,p),l?VE([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function TE(e,t,r,i){for(let a of e)if(a.issues.length===0)return t.value=a.value,t;let n=e.filter(a=>!Bi(a));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>Jt(o,i,et())))}),t)}var tu=b("$ZodUnion",(e,t)=>{ce.init(e,t),ve(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ve(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ve(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ve(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${i.map(n=>Bc(n.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(s=>TE(s,i,e,n)):TE(o,i,e,n)}});function AE(e,t,r,i){let n=e.filter(a=>a.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(a=>a.issues.map(o=>Jt(o,i,et())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Dy=b("$ZodXor",(e,t)=>{tu.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},n);c instanceof Promise?(o.push(c),a=!0):o.push(c)}return a?Promise.all(o).then(s=>AE(s,i,e,n)):AE(o,i,e,n)}}),Uy=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,tu.init(e,t);let r=e._zod.parse;ve(e._zod,"propValues",()=>{let n={};for(let a of t.options){let o=a._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let[s,c]of Object.entries(o)){n[s]||(n[s]=new Set);for(let u of c)n[s].add(u)}}return n});let i=ts(()=>{let n=t.options,a=new Map;for(let o of n){let s=o._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let c of s){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,o)}}return a});e._zod.parse=(n,a)=>{let o=n.value;if(!Da(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(n,a):t.unionFallback||a.direction==="backward"?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),n)}}),Ly=b("$ZodIntersection",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value,a=t.left._zod.run({value:n,issues:[]},i),o=t.right._zod.run({value:n,issues:[]},i);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([c,u])=>CE(r,c,u)):CE(r,a,o)}});function ty(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(Fi(e)&&Fi(t)){let r=Object.keys(t),i=Object.keys(e).filter(a=>r.indexOf(a)!==-1),n={...e,...t};for(let a of i){let o=ty(e[a],t[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};n[a]=o.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<e.length;i++){let n=e[i],a=t[i],o=ty(n,a);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function CE(e,t,r){let i=new Map,n;for(let s of t.issues)if(s.code==="unrecognized_keys"){n??(n=s);for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else e.issues.push(s);let a=[...i].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(a.length&&n&&e.issues.push({...n,keys:a}),Bi(e))return e;let o=ty(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var uf=b("$ZodTuple",(e,t)=>{ce.init(e,t);let r=t.items;e._zod.parse=(i,n)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let o=[],s=OE(r,"optin"),c=OE(r,"optout");if(!t.rest){if(a.length<s)return i.issues.push({code:"too_small",minimum:s,inclusive:!0,input:a,inst:e,origin:"array"}),i;a.length>r.length&&i.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=new Array(r.length);for(let l=0;l<r.length;l++){let d=r[l]._zod.run({value:a[l],issues:[]},n);d instanceof Promise?o.push(d.then(f=>{u[l]=f})):u[l]=d}if(t.rest){let l=r.length-1,d=a.slice(r.length);for(let f of d){l++;let p=t.rest._zod.run({value:f,issues:[]},n);p instanceof Promise?o.push(p.then(m=>PE(m,i,l))):PE(p,i,l)}}return o.length?Promise.all(o).then(()=>NE(u,i,r,a,c)):NE(u,i,r,a,c)}});function OE(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function PE(e,t,r){e.issues.length&&t.issues.push(...ar(r,e.issues)),t.value[r]=e.value}function NE(e,t,r,i,n){for(let a=0;a<r.length;a++){let o=e[a],s=a<i.length;if(o.issues.length){if(!s&&a>=n){t.value.length=a;break}t.issues.push(...ar(a,o.issues))}t.value[a]=o.value}for(let a=t.value.length-1;a>=i.length&&(r[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}var Fy=b("$ZodRecord",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Fi(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let a=[],o=t.keyType._zod.values;if(o){r.value={};let s=new Set;for(let u of o)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Jt(p,i,et())),input:u,path:[u],inst:e});continue}let d=l.value,f=t.valueType._zod.run({value:n[u],issues:[]},i);f instanceof Promise?a.push(f.then(p=>{p.issues.length&&r.issues.push(...ar(u,p.issues)),r.value[d]=p.value})):(f.issues.length&&r.issues.push(...ar(u,f.issues)),r.value[d]=f.value)}let c;for(let u in n)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(n)){if(s==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Qd.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},i);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[s]=n[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Jt(d,i,et())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:n[s],issues:[]},i);l instanceof Promise?a.push(l.then(d=>{d.issues.length&&r.issues.push(...ar(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...ar(s,l.issues)),r.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>r):r}}),By=b("$ZodMap",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let a=[];r.value=new Map;for(let[o,s]of n){let c=t.keyType._zod.run({value:o,issues:[]},i),u=t.valueType._zod.run({value:s,issues:[]},i);c instanceof Promise||u instanceof Promise?a.push(Promise.all([c,u]).then(([l,d])=>{RE(l,d,r,o,n,e,i)})):RE(c,u,r,o,n,e,i)}return a.length?Promise.all(a).then(()=>r):r}});function RE(e,t,r,i,n,a,o){e.issues.length&&(Zc.has(typeof i)?r.issues.push(...ar(i,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:a,issues:e.issues.map(s=>Jt(s,o,et()))})),t.issues.length&&(Zc.has(typeof i)?r.issues.push(...ar(i,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:a,key:i,issues:t.issues.map(s=>Jt(s,o,et()))})),r.value.set(e.value,t.value)}var Zy=b("$ZodSet",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let a=[];r.value=new Set;for(let o of n){let s=t.valueType._zod.run({value:o,issues:[]},i);s instanceof Promise?a.push(s.then(c=>jE(c,r))):jE(s,r)}return a.length?Promise.all(a).then(()=>r):r}});function jE(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Vy=b("$ZodEnum",(e,t)=>{ce.init(e,t);let r=Fc(t.entries),i=new Set(r);e._zod.values=i,e._zod.pattern=new RegExp(`^(${r.filter(n=>Zc.has(typeof n)).map(n=>typeof n=="string"?Rr(n):n.toString()).join("|")})$`),e._zod.parse=(n,a)=>{let o=n.value;return i.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Gy=b("$ZodLiteral",(e,t)=>{if(ce.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Rr(i):i?Rr(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),Hy=b("$ZodFile",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Jy=b("$ZodTransform",(e,t)=>{ce.init(e,t),e._zod.optin="optional",e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Di(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(o=>(r.value=o,r.fallback=!0,r));if(n instanceof Promise)throw new en;return r.value=n,r.fallback=!0,r}});function ME(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ba=b("$ZodOptional",(e,t)=>{ce.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ve(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Bc(r.source)})?$`):void 0}),e._zod.parse=(r,i)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,a=t.innerType._zod.run(r,i);return a instanceof Promise?a.then(o=>ME(o,n)):ME(a,n)}return r.value===void 0?r:t.innerType._zod.run(r,i)}}),Ky=b("$ZodExactOptional",(e,t)=>{Ba.init(e,t),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,i)=>t.innerType._zod.run(r,i)}),Wy=b("$ZodNullable",(e,t)=>{ce.init(e,t),ve(e._zod,"optin",()=>t.innerType._zod.optin),ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Bc(r.source)}|null)$`):void 0}),ve(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,i)=>r.value===null?r:t.innerType._zod.run(r,i)}),qy=b("$ZodDefault",(e,t)=>{ce.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>zE(a,t)):zE(n,t)}});function zE(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Xy=b("$ZodPrefault",(e,t)=>{ce.init(e,t),e._zod.optin="optional",ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,i))}),Yy=b("$ZodNonOptional",(e,t)=>{ce.init(e,t),ve(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>DE(a,e)):DE(n,e)}});function DE(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Qy=b("$ZodSuccess",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Di("ZodSuccess");let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),ev=b("$ZodCatch",(e,t)=>{ce.init(e,t),e._zod.optin="optional",ve(e._zod,"optout",()=>t.innerType._zod.optout),ve(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(a=>(r.value=a.value,a.issues.length&&(r.value=t.catchValue({...r,error:{issues:a.issues.map(o=>Jt(o,i,et()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(a=>Jt(a,i,et()))},input:r.value}),r.issues=[],r.fallback=!0),r)}}),tv=b("$ZodNaN",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),lf=b("$ZodPipe",(e,t)=>{ce.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if(i.direction==="backward"){let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>rf(o,t.in,i)):rf(a,t.in,i)}let n=t.in._zod.run(r,i);return n instanceof Promise?n.then(a=>rf(a,t.out,i)):rf(n,t.out,i)}});function rf(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var ru=b("$ZodCodec",(e,t)=>{ce.init(e,t),ve(e._zod,"values",()=>t.in._zod.values),ve(e._zod,"optin",()=>t.in._zod.optin),ve(e._zod,"optout",()=>t.out._zod.optout),ve(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let a=t.in._zod.run(r,i);return a instanceof Promise?a.then(o=>nf(o,t,i)):nf(a,t,i)}else{let a=t.out._zod.run(r,i);return a instanceof Promise?a.then(o=>nf(o,t,i)):nf(a,t,i)}}});function nf(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(a=>af(e,a,t.out,r)):af(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(a=>af(e,a,t.in,r)):af(e,n,t.in,r)}}function af(e,t,r,i){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},i)}var rv=b("$ZodPreprocess",(e,t)=>{lf.init(e,t)}),nv=b("$ZodReadonly",(e,t)=>{ce.init(e,t),ve(e._zod,"propValues",()=>t.innerType._zod.propValues),ve(e._zod,"values",()=>t.innerType._zod.values),ve(e._zod,"optin",()=>t.innerType?._zod?.optin),ve(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,i)=>{if(i.direction==="backward")return t.innerType._zod.run(r,i);let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(UE):UE(n)}});function UE(e){return e.value=Object.freeze(e.value),e}var iv=b("$ZodTemplateLiteral",(e,t)=>{ce.init(e,t);let r=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let n=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let a=n.startsWith("^")?1:0,o=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(a,o))}else if(i===null||Yg.has(typeof i))r.push(Rr(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(i,n)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),av=b("$ZodFunction",(e,t)=>(ce.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...i){let n=e._def.input?Zi(e._def.input,i):i,a=Reflect.apply(r,this,n);return e._def.output?Zi(e._def.output,a):a}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let n=e._def.input?await Ua(e._def.input,i):i,a=await Reflect.apply(r,this,n);return e._def.output?await Ua(e._def.output,a):a}},e._zod.parse=(r,i)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let i=e.constructor;return Array.isArray(r[0])?new i({type:"function",input:new uf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new i({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:r})},e)),ov=b("$ZodPromise",(e,t)=>{ce.init(e,t),e._zod.parse=(r,i)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},i))}),sv=b("$ZodLazy",(e,t)=>{ce.init(e,t),ve(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),ve(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ve(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ve(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ve(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,i)=>e._zod.innerType._zod.run(r,i)}),cv=b("$ZodCustom",(e,t)=>{je.init(e,t),ce.init(e,t),e._zod.parse=(r,i)=>r,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(a=>LE(a,r,i,e));LE(n,r,i,e)}});function LE(e,t,r,i){if(!e){let n={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(n.params=i._zod.def.params),t.issues.push(rs(n))}}var iu={};bn(iu,{ar:()=>HE,az:()=>JE,be:()=>WE,bg:()=>qE,ca:()=>XE,cs:()=>YE,da:()=>QE,de:()=>eT,el:()=>tT,en:()=>df,eo:()=>rT,es:()=>nT,fa:()=>iT,fi:()=>aT,fr:()=>oT,frCA:()=>sT,he:()=>cT,hr:()=>uT,hu:()=>lT,hy:()=>fT,id:()=>pT,is:()=>mT,it:()=>hT,ja:()=>gT,ka:()=>_T,kh:()=>yT,km:()=>ff,ko:()=>vT,lt:()=>wT,mk:()=>xT,ms:()=>ST,nl:()=>kT,no:()=>$T,ota:()=>IT,pl:()=>TT,ps:()=>ET,pt:()=>AT,ro:()=>CT,ru:()=>PT,sl:()=>NT,sv:()=>RT,ta:()=>jT,th:()=>MT,tr:()=>zT,ua:()=>DT,uk:()=>pf,ur:()=>UT,uz:()=>LT,vi:()=>FT,yo:()=>VT,zhCN:()=>BT,zhTW:()=>ZT});var _D=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${a}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return n.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${R(n.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()} ${o.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`:a.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${a.suffix}"`:a.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${a.includes}"`:a.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${a.pattern}`:`${r[a.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function HE(){return{localeError:_D()}}var yD=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${a}, daxil olan ${s}`}case"invalid_value":return n.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${R(n.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()} ${o.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${a.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:a.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${a.suffix}" il\u0259 bitm\u0259lidir`:a.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${a.includes}" daxil olmal\u0131d\u0131r`:a.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${a.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[a.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function JE(){return{localeError:yD()}}function KE(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var vD=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${a}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${R(n.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=KE(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=KE(s,o.unit.one,o.unit.few,o.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${o.verb} ${a}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function WE(){return{localeError:vD()}}var bD=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${R(n.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;if(a.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${a.prefix}"`;if(a.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${a.suffix}"`;if(a.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${a.includes}"`;if(a.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${a.pattern}`;let o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return a.format==="emoji"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="datetime"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="date"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),a.format==="time"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),a.format==="duration"&&(o="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${o} ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function qE(){return{localeError:bD()}}var wD=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${a}, s'ha rebut ${s}`}case"invalid_value":return n.values.length===1?`Valor inv\xE0lid: s'esperava ${R(n.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${I(n.values," o ")}`;case"too_big":{let a=n.inclusive?"com a m\xE0xim":"menys de",o=t(n.origin);return o?`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${a} ${n.maximum.toString()} ${o.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"com a m\xEDnim":"m\xE9s de",o=t(n.origin);return o?`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${a} ${n.minimum.toString()} ${o.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${a.prefix}"`:a.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${a.suffix}"`:a.format==="includes"?`Format inv\xE0lid: ha d'incloure "${a.includes}"`:a.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${a.pattern}`:`Format inv\xE0lid per a ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};function XE(){return{localeError:wD()}}var xD=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${a}, obdr\u017Eeno ${s}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${R(n.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.maximum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${a}${n.minimum.toString()} ${o.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${a.prefix}"`:a.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${a.suffix}"`:a.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${a.includes}"`:a.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${a.pattern}`:`Neplatn\xFD form\xE1t ${r[a.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function YE(){return{localeError:xD()}}var SD=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldigt input: forventede instanceof ${n.expected}, fik ${s}`:`Ugyldigt input: forventede ${a}, fik ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig v\xE6rdi: forventede ${R(n.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For stor: forventede ${s??"value"} ${o.verb} ${a} ${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`For lille: forventede ${s} ${o.verb} ${a} ${n.minimum.toString()} ${o.unit}`:`For lille: forventede ${s} havde ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: skal starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: skal ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: skal indeholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};function QE(){return{localeError:SD()}}var kD=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${a}, erhalten ${s}`}case"invalid_value":return n.values.length===1?`Ung\xFCltige Eingabe: erwartet ${R(n.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ${o.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${a}${n.maximum.toString()} ist`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ${o.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${a}${n.minimum.toString()} ist`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ung\xFCltiger String: muss mit "${a.prefix}" beginnen`:a.format==="ends_with"?`Ung\xFCltiger String: muss mit "${a.suffix}" enden`:a.format==="includes"?`Ung\xFCltiger String: muss "${a.includes}" enthalten`:a.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${a.pattern} entsprechen`:`Ung\xFCltig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};function eT(){return{localeError:kD()}}var $D=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return typeof n.expected=="string"&&/^[A-Z]/.test(n.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${a}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return n.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${R(n.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.maximum.toString()} ${o.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${a}${n.minimum.toString()} ${o.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${a.prefix}"`:a.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${a.suffix}"`:a.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${a.includes}"`:a.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${a.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function tT(){return{localeError:$D()}}var ID=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return`Invalid input: expected ${a}, received ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`Invalid option: expected one of ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${a}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${a}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(o=>`'${o}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function df(){return{localeError:ID()}}var ED=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${a}, ricevi\u011Dis ${s}`}case"invalid_value":return n.values.length===1?`Nevalida enigo: atendi\u011Dis ${R(n.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()} ${o.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${a}${n.minimum.toString()} ${o.unit}`:`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${a.prefix}"`:a.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${a.suffix}"`:a.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${a.includes}"`:a.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${a.pattern}`:`Nevalida ${r[a.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};function rT(){return{localeError:ED()}}var TD=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${a}, recibido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: se esperaba ${R(n.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${a}${n.minimum.toString()} ${o.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${a.prefix}"`:a.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${a.suffix}"`:a.format==="includes"?`Cadena inv\xE1lida: debe incluir "${a.includes}"`:a.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${a.pattern}`:`Inv\xE1lido ${r[a.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};function nT(){return{localeError:TD()}}var AD=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${a} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return n.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${R(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${I(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:a.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${a.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:a.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${a.includes}" \u0628\u0627\u0634\u062F`:a.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${a.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[a.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function iT(){return{localeError:AD()}}var CD=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${a}, oli ${s}`}case"invalid_value":return n.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${R(n.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Liian suuri: ${o.subject} t\xE4ytyy olla ${a}${n.maximum.toString()} ${o.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Liian pieni: ${o.subject} t\xE4ytyy olla ${a}${n.minimum.toString()} ${o.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${a.prefix}"`:a.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${a.suffix}"`:a.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${a.includes}"`:a.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${a.pattern}`:`Virheellinen ${r[a.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function aT(){return{localeError:CD()}}var OD=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : instanceof ${n.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${a} attendu, ${s} re\xE7u`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : ${R(n.values[0])} attendu`:`Option invalide : une valeur parmi ${I(n.values,"|")} attendue`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Trop grand : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Trop petit : ${i[n.origin]??"valeur"} doit ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : ${i[n.origin]??"valeur"} doit \xEAtre ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function oT(){return{localeError:OD()}}var PD=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${a}, re\xE7u ${s}`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : attendu ${R(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u2264":"<",o=t(n.origin);return o?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${a}${n.maximum.toString()} ${o.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u2265":">",o=t(n.origin);return o?`Trop petit : attendu que ${n.origin} ait ${a}${n.minimum.toString()} ${o.unit}`:`Trop petit : attendu que ${n.origin} soit ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${a.prefix}"`:a.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${a.suffix}"`:a.format==="includes"?`Cha\xEEne invalide : doit inclure "${a.includes}"`:a.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${a.pattern}`:`${r[a.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${I(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function sT(){return{localeError:PD()}}var ND=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=u=>u?e[u]:void 0,i=u=>{let l=r(u);return l?l.label:u??e.unknown.label},n=u=>`\u05D4${i(u)}`,a=u=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",o=u=>u?t[u]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return u=>{switch(u.code){case"invalid_type":{let l=u.expected,d=c[l??""]??i(l),f=j(u.input),p=c[f]??e[f]?.label??f;return/^[A-Z]/.test(u.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${p}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${R(u.values[0])}`;let l=u.values.map(p=>R(p));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l[0]} \u05D0\u05D5 ${l[1]}`;let d=l[l.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${l.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let l=o(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",_=u.inclusive?`${u.maximum} ${l?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${l?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${_}`.trim()}let f=u.inclusive?"<=":"<",p=a(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{let l=o(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${l?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${l?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let m=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}`}if(u.origin==="array"||u.origin==="set"){let m=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let v=(u.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${v}`}let _=u.inclusive?`${u.minimum} ${l?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${l?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${_}`.trim()}let f=u.inclusive?">=":">",p=a(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{let l=u;if(l.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${l.prefix}"`;if(l.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${l.suffix}"`;if(l.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${l.includes}"`;if(l.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${l.pattern}`;let d=s[l.format],f=d?.label??l.format,m=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${f} \u05DC\u05D0 ${m}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function cT(){return{localeError:ND()}}var RD=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${a}, a primljeno je ${s}`}case"invalid_value":return n.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${R(n.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${a}${n.maximum.toString()} ${o.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=i[n.origin]??n.origin;return o?`Premalo: o\u010Dekivano da ${s} ima ${a}${n.minimum.toString()} ${o.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${a.prefix}"`:a.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${a.suffix}"`:a.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${a.includes}"`:a.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${a.pattern}`:`Neispravna ${r[a.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[n.origin]??n.origin}`;default:return"Neispravan unos"}}};function uT(){return{localeError:RD()}}var jD=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${a}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return n.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${R(n.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${a}${n.maximum.toString()} ${o.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${a}${n.minimum.toString()} ${o.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xC9rv\xE9nytelen string: "${a.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:a.format==="ends_with"?`\xC9rv\xE9nytelen string: "${a.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:a.format==="includes"?`\xC9rv\xE9nytelen string: "${a.includes}" \xE9rt\xE9ket kell tartalmaznia`:a.format==="regex"?`\xC9rv\xE9nytelen string: ${a.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[a.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function lT(){return{localeError:jD()}}function dT(e,t,r){return Math.abs(e)===1?t:r}function cs(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var MD=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${a}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return n.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${R(n.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=dT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cs(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cs(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=dT(s,o.unit.one,o.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cs(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${a}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${cs(n.origin)} \u056C\u056B\u0576\u056B ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${a.prefix}"-\u0578\u057E`:a.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${a.suffix}"-\u0578\u057E`:a.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${a.includes}"`:a.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${a.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[a.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${I(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${cs(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${cs(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function fT(){return{localeError:MD()}}var zD=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${R(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: diharapkan ${n.origin} memiliki ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak valid: harus dimulai dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak valid: harus berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak valid: harus menyertakan "${a.includes}"`:a.format==="regex"?`String tidak valid: harus sesuai pola ${a.pattern}`:`${r[a.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function pT(){return{localeError:zD()}}var DD=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${a}`}case"invalid_value":return n.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${R(n.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${a}${n.maximum.toString()} ${o.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${a}${n.minimum.toString()} ${o.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${a.prefix}"`:a.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${a.suffix}"`:a.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${a.includes}"`:a.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${a.pattern}`:`Rangt ${r[a.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${I(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};function mT(){return{localeError:DD()}}var UD=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input non valido: atteso instanceof ${n.expected}, ricevuto ${s}`:`Input non valido: atteso ${a}, ricevuto ${s}`}case"invalid_value":return n.values.length===1?`Input non valido: atteso ${R(n.values[0])}`:`Opzione non valida: atteso uno tra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Troppo grande: ${n.origin??"valore"} deve avere ${a}${n.maximum.toString()} ${o.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Troppo piccolo: ${n.origin} deve avere ${a}${n.minimum.toString()} ${o.unit}`:`Troppo piccolo: ${n.origin} deve essere ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Stringa non valida: deve iniziare con "${a.prefix}"`:a.format==="ends_with"?`Stringa non valida: deve terminare con "${a.suffix}"`:a.format==="includes"?`Stringa non valida: deve includere "${a.includes}"`:a.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${a.pattern}`:`Input non valido: ${r[a.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${I(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function hT(){return{localeError:UD()}}var LD=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${a}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return n.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${R(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${I(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let a=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",o=t(n.origin);return o?`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${o.unit??"\u8981\u7D20"}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let a=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",o=t(n.origin);return o?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${o.unit}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${a}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${a.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:a.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${a.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function gT(){return{localeError:LD()}}var FD=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${a}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return n.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${R(n.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${I(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.prefix}"-\u10D8\u10D7`:a.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${a.suffix}"-\u10D8\u10D7`:a.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${a.includes}"-\u10E1`:a.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${a.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function _T(){return{localeError:FD()}}var BD=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${a} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return n.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${R(n.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()} ${o.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()} ${o.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${a.prefix}"`:a.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${a.suffix}"`:a.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${a.includes}"`:a.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${a.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function ff(){return{localeError:BD()}}function yT(){return ff()}var ZD=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${a}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return n.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${R(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${I(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let a=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",o=a==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${a}${o}`}case"too_small":{let a=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",o=a==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(n.origin),c=s?.unit??"\uC694\uC18C";return s?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${a}${o}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${a}${o}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:a.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${a.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:a.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${a.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[a.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function vT(){return{localeError:ZD()}}var nu=e=>e.charAt(0).toUpperCase()+e.slice(1);function bT(e){let t=Math.abs(e),r=t%10,i=t%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var VD=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,a,o,s){let c=e[n]??null;return c===null?c:{unit:c.unit[a],verb:c.verb[s][o?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${n.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${a}`}case"invalid_value":return n.values.length===1?`Privalo b\u016Bti ${R(n.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${I(n.values,"|")} pasirinkim\u0173`;case"too_big":{let a=i[n.origin]??n.origin,o=t(n.origin,bT(Number(n.maximum)),n.inclusive??!1,"smaller");if(o?.verb)return`${nu(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.maximum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${nu(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.maximum.toString()} ${o?.unit}`}case"too_small":{let a=i[n.origin]??n.origin,o=t(n.origin,bT(Number(n.minimum)),n.inclusive??!1,"bigger");if(o?.verb)return`${nu(a??n.origin??"reik\u0161m\u0117")} ${o.verb} ${n.minimum.toString()} ${o.unit??"element\u0173"}`;let s=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${nu(a??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${n.minimum.toString()} ${o?.unit}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${a.prefix}"`:a.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${a.suffix}"`:a.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${a.includes}"`:a.format==="regex"?`Eilut\u0117 privalo atitikti ${a.pattern}`:`Neteisingas ${r[a.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${I(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let a=i[n.origin]??n.origin;return`${nu(a??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function wT(){return{localeError:VD()}}var GD=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${a}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${R(n.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${a}${n.minimum.toString()} ${o.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${a.pattern}`:`Invalid ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function xT(){return{localeError:GD()}}var HD=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${s}`:`Input tidak sah: dijangka ${a}, diterima ${s}`}case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${R(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Terlalu besar: dijangka ${n.origin??"nilai"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Terlalu kecil: dijangka ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`String tidak sah: mesti bermula dengan "${a.prefix}"`:a.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${a.suffix}"`:a.format==="includes"?`String tidak sah: mesti mengandungi "${a.includes}"`:a.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${a.pattern}`:`${r[a.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function ST(){return{localeError:HD()}}var JD=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${a}, ontving ${s}`}case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${R(n.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin),s=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";return o?`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} ${o.unit??"elementen"} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin??"waarde"} ${a}${n.maximum.toString()} is`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin),s=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";return o?`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Te ${s}: verwacht dat ${n.origin} ${a}${n.minimum.toString()} is`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ongeldige tekst: moet met "${a.prefix}" beginnen`:a.format==="ends_with"?`Ongeldige tekst: moet op "${a.suffix}" eindigen`:a.format==="includes"?`Ongeldige tekst: moet "${a.includes}" bevatten`:a.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${a.pattern}`:`Ongeldig: ${r[a.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function kT(){return{localeError:JD()}}var KD=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventet instanceof ${n.expected}, fikk ${s}`:`Ugyldig input: forventet ${a}, fikk ${s}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${R(n.values[0])}`:`Ugyldig valg: forventet en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()} ${o.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()} ${o.unit}`:`For lite(n): forventet ${n.origin} til \xE5 ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${a.prefix}"`:a.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${a.suffix}"`:a.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${a.includes}"`:a.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${a.pattern}`:`Ugyldig ${r[a.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function $T(){return{localeError:KD()}}var WD=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`F\xE2sit giren: umulan ${R(n.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} ${o.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${a}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} ${o.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${a}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let a=n;return a.format==="starts_with"?`F\xE2sit metin: "${a.prefix}" ile ba\u015Flamal\u0131.`:a.format==="ends_with"?`F\xE2sit metin: "${a.suffix}" ile bitmeli.`:a.format==="includes"?`F\xE2sit metin: "${a.includes}" ihtiv\xE2 etmeli.`:a.format==="regex"?`F\xE2sit metin: ${a.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[a.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function IT(){return{localeError:WD()}}var qD=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${a} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return n.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${R(n.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${I(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${a}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} ${o.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${a}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:a.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${a.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:a.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${a.includes}" \u0648\u0644\u0631\u064A`:a.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${a.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[a.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${I(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function ET(){return{localeError:qD()}}var XD=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${a}, otrzymano ${s}`}case"invalid_value":return n.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${R(n.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.maximum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${a}${n.minimum.toString()} ${o.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${a.prefix}"`:a.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${a.suffix}"`:a.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${a.includes}"`:a.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${a.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[a.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function TT(){return{localeError:XD()}}var YD=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Tipo inv\xE1lido: esperado instanceof ${n.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${a}, recebido ${s}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: esperado ${R(n.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${a}${n.maximum.toString()} ${o.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Muito pequeno: esperado que ${n.origin} tivesse ${a}${n.minimum.toString()} ${o.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`${r[a.format]??n.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${I(n.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${n.origin}`;default:return"Campo inv\xE1lido"}}};function AT(){return{localeError:YD()}}var QD=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return`Intrare invalid\u0103: a\u0219teptat ${a}, primit ${s}`}case"invalid_value":return n.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${R(n.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Prea mic: a\u0219teptat ca ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${a.prefix}"`:a.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${a.suffix}"`:a.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${a.includes}"`:a.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${a.pattern}`:`Format invalid: ${r[a.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${I(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};function CT(){return{localeError:QD()}}function OT(e,t,r,i){let n=Math.abs(e),a=n%10,o=n%100;return o>=11&&o<=19?i:a===1?t:a>=2&&a<=4?r:i}var eU=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${a}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${R(n.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);if(o){let s=Number(n.maximum),c=OT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);if(o){let s=Number(n.minimum),c=OT(s,o.unit.one,o.unit.few,o.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${a}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function PT(){return{localeError:eU()}}var tU=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${a}, prejeto ${s}`}case"invalid_value":return n.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${R(n.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${a}${n.maximum.toString()} ${o.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${a}${n.minimum.toString()} ${o.unit}`:`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${a.prefix}"`:a.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${a.suffix}"`:a.format==="includes"?`Neveljaven niz: mora vsebovati "${a.includes}"`:a.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${a.pattern}`:`Neveljaven ${r[a.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function NT(){return{localeError:tU()}}var rU=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${a}, fick ${s}`}case"invalid_value":return n.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${R(n.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()} ${o.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()} ${o.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${a.prefix}"`:a.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${a.suffix}"`:a.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${a.includes}"`:a.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${a.pattern}"`:`Ogiltig(t) ${r[a.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function RT(){return{localeError:rU()}}var nU=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return n.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R(n.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${I(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} ${o.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${a}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} ${o.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${a}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${a.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:a.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${a.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function jT(){return{localeError:nU()}}var iU=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${a} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return n.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${R(n.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()} ${o.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",o=t(n.origin);return o?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()} ${o.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${a} ${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${a.prefix}"`:a.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${a.suffix}"`:a.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${a.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:a.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${a.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[a.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${I(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function MT(){return{localeError:iU()}}var aU=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${a}, al\u0131nan ${s}`}case"invalid_value":return n.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${R(n.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()} ${o.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Ge\xE7ersiz metin: "${a.prefix}" ile ba\u015Flamal\u0131`:a.format==="ends_with"?`Ge\xE7ersiz metin: "${a.suffix}" ile bitmeli`:a.format==="includes"?`Ge\xE7ersiz metin: "${a.includes}" i\xE7ermeli`:a.format==="regex"?`Ge\xE7ersiz metin: ${a.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[a.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function zT(){return{localeError:aU()}}var oU=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${a}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${R(n.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${a.prefix}"`:a.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${a.suffix}"`:a.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${a.includes}"`:a.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${a.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${I(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function pf(){return{localeError:oU()}}function DT(){return pf()}var sU=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${a} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return n.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${R(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${a}${n.maximum.toString()} ${o.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${a}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${a}${n.minimum.toString()} ${o.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${a}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${a.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:a.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${a.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${I(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function UT(){return{localeError:sU()}}var cU=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${a}, qabul qilingan ${s}`}case"invalid_value":return n.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${R(n.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()} ${o.unit} ${o.verb}`:`Juda katta: kutilgan ${n.origin??"qiymat"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()} ${o.unit} ${o.verb}`:`Juda kichik: kutilgan ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${a.prefix}" bilan boshlanishi kerak`:a.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${a.suffix}" bilan tugashi kerak`:a.format==="includes"?`Noto\u2018g\u2018ri satr: "${a.includes}" ni o\u2018z ichiga olishi kerak`:a.format==="regex"?`Noto\u2018g\u2018ri satr: ${a.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[a.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function LT(){return{localeError:cU()}}var uU=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${a}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return n.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${R(n.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${o.verb} ${a}${n.maximum.toString()} ${o.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${o.verb} ${a}${n.minimum.toString()} ${o.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${a.prefix}"`:a.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${a.suffix}"`:a.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${a.includes}"`:a.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${a.pattern}`:`${r[a.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function FT(){return{localeError:uU()}}var lU=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${a}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return n.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${R(n.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()} ${o.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()} ${o.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.prefix}" \u5F00\u5934`:a.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${a.suffix}" \u7ED3\u5C3E`:a.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${a.pattern}`:`\u65E0\u6548${r[a.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function BT(){return{localeError:lU()}}var dU=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${a}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return n.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${R(n.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()} ${o.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${a}${n.maximum.toString()}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()} ${o.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${a}${n.minimum.toString()}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.prefix}" \u958B\u982D`:a.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${a.suffix}" \u7D50\u5C3E`:a.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${a.includes}"`:a.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${a.pattern}`:`\u7121\u6548\u7684 ${r[a.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${I(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function ZT(){return{localeError:dU()}}var fU=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return n=>{switch(n.code){case"invalid_type":{let a=i[n.expected]??n.expected,o=j(n.input),s=i[o]??o;return/^[A-Z]/.test(n.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${a}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return n.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${R(n.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${I(n.values,"|")}`;case"too_big":{let a=n.inclusive?"<=":"<",o=t(n.origin);return o?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${o.verb} ${a}${n.maximum} ${o.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.maximum}`}case"too_small":{let a=n.inclusive?">=":">",o=t(n.origin);return o?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${o.verb} ${a}${n.minimum} ${o.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${a}${n.minimum}`}case"invalid_format":{let a=n;return a.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${a.prefix}"`:a.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${a.suffix}"`:a.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${a.includes}"`:a.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${a.pattern}`:`A\u1E63\xEC\u1E63e: ${r[a.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${I(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function VT(){return{localeError:fU()}}var GT,uv=Symbol("ZodOutput"),lv=Symbol("ZodInput"),mf=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let i=r[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let 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){let r=t._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let n={...i,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function hf(){return new mf}(GT=globalThis).__zod_globalRegistry??(GT.__zod_globalRegistry=hf());var Te=globalThis.__zod_globalRegistry;function dv(e,t){return new e({type:"string",...U(t)})}function fv(e,t){return new e({type:"string",coerce:!0,...U(t)})}function gf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...U(t)})}function au(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...U(t)})}function _f(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...U(t)})}function yf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(t)})}function vf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(t)})}function bf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(t)})}function ou(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function wf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...U(t)})}function xf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(t)})}function Sf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...U(t)})}function kf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(t)})}function $f(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...U(t)})}function If(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...U(t)})}function Ef(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(t)})}function Tf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(t)})}function Af(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(t)})}function pv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...U(t)})}function Cf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(t)})}function Of(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(t)})}function Pf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...U(t)})}function Nf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...U(t)})}function Rf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...U(t)})}function jf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...U(t)})}var mv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function hv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(t)})}function gv(e,t){return new e({type:"string",format:"date",check:"string_format",...U(t)})}function _v(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...U(t)})}function yv(e,t){return new e({type:"string",format:"duration",check:"string_format",...U(t)})}function vv(e,t){return new e({type:"number",checks:[],...U(t)})}function bv(e,t){return new e({type:"number",coerce:!0,checks:[],...U(t)})}function wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function xv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...U(t)})}function Sv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...U(t)})}function kv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...U(t)})}function $v(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...U(t)})}function Iv(e,t){return new e({type:"boolean",...U(t)})}function Ev(e,t){return new e({type:"boolean",coerce:!0,...U(t)})}function Tv(e,t){return new e({type:"bigint",...U(t)})}function Av(e,t){return new e({type:"bigint",coerce:!0,...U(t)})}function Cv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...U(t)})}function Ov(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...U(t)})}function Pv(e,t){return new e({type:"symbol",...U(t)})}function Nv(e,t){return new e({type:"undefined",...U(t)})}function Rv(e,t){return new e({type:"null",...U(t)})}function jv(e){return new e({type:"any"})}function su(e){return new e({type:"unknown"})}function cu(e,t){return new e({type:"never",...U(t)})}function Mv(e,t){return new e({type:"void",...U(t)})}function zv(e,t){return new e({type:"date",...U(t)})}function Dv(e,t){return new e({type:"date",coerce:!0,...U(t)})}function Uv(e,t){return new e({type:"nan",...U(t)})}function Pn(e,t){return new ef({check:"less_than",...U(t),value:e,inclusive:!1})}function xr(e,t){return new ef({check:"less_than",...U(t),value:e,inclusive:!0})}function Nn(e,t){return new tf({check:"greater_than",...U(t),value:e,inclusive:!1})}function Kt(e,t){return new tf({check:"greater_than",...U(t),value:e,inclusive:!0})}function Mf(e){return Nn(0,e)}function zf(e){return Pn(0,e)}function Df(e){return xr(0,e)}function Uf(e){return Kt(0,e)}function Vi(e,t){return new M_({check:"multiple_of",...U(t),value:e})}function Gi(e,t){return new U_({check:"max_size",...U(t),maximum:e})}function Rn(e,t){return new L_({check:"min_size",...U(t),minimum:e})}function Za(e,t){return new F_({check:"size_equals",...U(t),size:e})}function Va(e,t){return new B_({check:"max_length",...U(t),maximum:e})}function ai(e,t){return new Z_({check:"min_length",...U(t),minimum:e})}function Ga(e,t){return new V_({check:"length_equals",...U(t),length:e})}function us(e,t){return new G_({check:"string_format",format:"regex",...U(t),pattern:e})}function ls(e){return new H_({check:"string_format",format:"lowercase",...U(e)})}function ds(e){return new J_({check:"string_format",format:"uppercase",...U(e)})}function fs(e,t){return new K_({check:"string_format",format:"includes",...U(t),includes:e})}function ps(e,t){return new W_({check:"string_format",format:"starts_with",...U(t),prefix:e})}function ms(e,t){return new q_({check:"string_format",format:"ends_with",...U(t),suffix:e})}function Lf(e,t,r){return new X_({check:"property",property:e,schema:t,...U(r)})}function hs(e,t){return new Y_({check:"mime_type",mime:e,...U(t)})}function tn(e){return new Q_({check:"overwrite",tx:e})}function gs(e){return tn(t=>t.normalize(e))}function _s(){return tn(e=>e.trim())}function ys(){return tn(e=>e.toLowerCase())}function vs(){return tn(e=>e.toUpperCase())}function bs(){return tn(e=>Wg(e))}function Lv(e,t,r){return new e({type:"array",element:t,...U(r)})}function mU(e,t,r){return new e({type:"union",options:t,...U(r)})}function hU(e,t,r){return new e({type:"union",options:t,inclusive:!1,...U(r)})}function gU(e,t,r,i){return new e({type:"union",options:r,discriminator:t,...U(i)})}function _U(e,t,r){return new e({type:"intersection",left:t,right:r})}function yU(e,t,r,i){let n=r instanceof ce,a=n?i:r,o=n?r:null;return new e({type:"tuple",items:t,rest:o,...U(a)})}function vU(e,t,r,i){return new e({type:"record",keyType:t,valueType:r,...U(i)})}function bU(e,t,r,i){return new e({type:"map",keyType:t,valueType:r,...U(i)})}function wU(e,t,r){return new e({type:"set",valueType:t,...U(r)})}function xU(e,t,r){let i=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:i,...U(r)})}function SU(e,t,r){return new e({type:"enum",entries:t,...U(r)})}function kU(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...U(r)})}function Fv(e,t){return new e({type:"file",...U(t)})}function $U(e,t){return new e({type:"transform",transform:t})}function IU(e,t){return new e({type:"optional",innerType:t})}function EU(e,t){return new e({type:"nullable",innerType:t})}function TU(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Xg(r)}})}function AU(e,t,r){return new e({type:"nonoptional",innerType:t,...U(r)})}function CU(e,t){return new e({type:"success",innerType:t})}function OU(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function PU(e,t,r){return new e({type:"pipe",in:t,out:r})}function NU(e,t){return new e({type:"readonly",innerType:t})}function RU(e,t,r){return new e({type:"template_literal",parts:t,...U(r)})}function jU(e,t){return new e({type:"lazy",getter:t})}function MU(e,t){return new e({type:"promise",innerType:t})}function Bv(e,t,r){let i=U(r);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function Zv(e,t,r){return new e({type:"custom",check:"custom",fn:t,...U(r)})}function Vv(e,t){let r=HT(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(rs(n,i.value,r._zod.def));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=i.value),a.inst??(a.inst=r),a.continue??(a.continue=!r._zod.def.abort),i.issues.push(rs(a))}},e(i.value,i)),t);return r}function HT(e,t){let r=new je({check:"custom",...U(t)});return r._zod.check=e,r}function Gv(e){let t=new je({check:"describe"});return t._zod.onattach=[r=>{let i=Te.get(r)??{};Te.add(r,{...i,description:e})}],t._zod.check=()=>{},t}function Hv(e){let t=new je({check:"meta"});return t._zod.onattach=[r=>{let i=Te.get(r)??{};Te.add(r,{...i,...e})}],t._zod.check=()=>{},t}function Jv(e,t){let r=U(t),i=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));let a=new Set(i),o=new Set(n),s=e.Codec??ru,c=e.Boolean??Yc,u=e.String??Fa,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),f=new s({type:"pipe",in:l,out:d,transform:((p,m)=>{let _=p;return r.case!=="sensitive"&&(_=_.toLowerCase()),a.has(_)?!0:o.has(_)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...a,...o],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?i[0]||"true":n[0]||"false"),error:r.error});return f}function ws(e,t,r,i={}){let n=U(i),a={...U(i),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(a.pattern=r),new e(a)}function Hi(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Te,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ce(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,l);else{let f=o.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(o.ref||(o.ref=d),Ce(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io==="input"&&Wt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ji(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of e.seen.entries()){let s=e.metadataRegistry.get(o[0])?.id;if(s){let c=i.get(s);if(c&&c!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,o[0])}}let n=o=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(o[1]===r)return{ref:"#"};let u=`#/${s}/`,l=o[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},a=o=>{if(o[1].schema.$ref)return;let s=o[1],{ref:c,defId:u}=n(o);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
217
|
+
|
|
218
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){a(o);continue}if(e.external){let u=e.external.registry.get(o[0])?.id;if(t!==o[0]&&u){a(o);continue}}if(e.metadataRegistry.get(o[0])?.id){a(o);continue}if(s.cycle){a(o);continue}if(s.count>1&&e.reused==="ref"){a(o);continue}}}function Ki(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),s._zod.parent===d)for(let v in u)v==="$ref"||v==="allOf"||v in l||delete u[v];if(m.$ref&&p.def)for(let v in u)v==="$ref"||v==="allOf"||v in p.def&&JSON.stringify(u[v])===JSON.stringify(p.def[v])&&delete u[v]}let f=s._zod.parent;if(f&&f!==d){i(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Object.assign(n,r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&n.id===a&&delete n.id;let o=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,o[c.defId]=c.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:xs(t,"input",e.processors),output:xs(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Wt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Wt(i.element,r);if(i.type==="set")return Wt(i.valueType,r);if(i.type==="lazy")return Wt(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Wt(i.innerType,r);if(i.type==="intersection")return Wt(i.left,r)||Wt(i.right,r);if(i.type==="record"||i.type==="map")return Wt(i.keyType,r)||Wt(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Wt(i.in,r)||Wt(i.out,r);if(i.type==="object"){for(let n in i.shape)if(Wt(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(Wt(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(Wt(n,r))return!0;return!!(i.rest&&Wt(i.rest,r))}return!1}var Kv=(e,t={})=>r=>{let i=Hi({...r,processors:t});return Ce(e,i),Ji(i,e),Ki(i,e)},xs=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=Hi({...n??{},target:a,io:t,processors:r});return Ce(e,o),Ji(o,e),Ki(o,e)};var zU={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Wv=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof a=="number"&&(n.minLength=a),typeof o=="number"&&(n.maxLength=o),s&&(n.format=zU[s]??s,n.format===""&&delete n.format,s==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?n.pattern=l[0].source:l.length>1&&(n.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},qv=(e,t,r,i)=>{let n=r,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let d=typeof l=="number"&&l>=(a??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof a=="number"&&(n.minimum=a),f?p?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof o=="number"&&(n.maximum=o),typeof c=="number"&&(n.multipleOf=c)},Xv=(e,t,r,i)=>{r.type="boolean"},Yv=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Qv=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},eb=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},tb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},rb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},nb=(e,t,r,i)=>{r.not={}},ib=(e,t,r,i)=>{},ab=(e,t,r,i)=>{},ob=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},sb=(e,t,r,i)=>{let n=e._zod.def,a=Fc(n.entries);a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),r.enum=a},cb=(e,t,r,i)=>{let n=e._zod.def,a=[];for(let o of n.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let o=a[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else a.every(o=>typeof o=="number")&&(r.type="number"),a.every(o=>typeof o=="string")&&(r.type="string"),a.every(o=>typeof o=="boolean")&&(r.type="boolean"),a.every(o=>o===null)&&(r.type="null"),r.enum=a},ub=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},lb=(e,t,r,i)=>{let n=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=a.source},db=(e,t,r,i)=>{let n=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(n,a)):(Object.assign(n,a),n.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(n,a)},fb=(e,t,r,i)=>{r.type="boolean"},pb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},mb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},hb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gb=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},_b=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},yb=(e,t,r,i)=>{let n=r,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(n.minItems=o),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=Ce(a.element,t,{...i,path:[...i.path,"items"]})},vb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object",n.properties={};let o=a.shape;for(let u in o)n.properties[u]=Ce(o[u],t,{...i,path:[...i.path,"properties",u]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(u=>{let l=a.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(n.required=Array.from(c)),a.catchall?._zod.def.type==="never"?n.additionalProperties=!1:a.catchall?a.catchall&&(n.additionalProperties=Ce(a.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Bf=(e,t,r,i)=>{let n=e._zod.def,a=n.inclusive===!1,o=n.options.map((s,c)=>Ce(s,t,{...i,path:[...i.path,a?"oneOf":"anyOf",c]}));a?r.oneOf=o:r.anyOf=o},bb=(e,t,r,i)=>{let n=e._zod.def,a=Ce(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=Ce(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=c},wb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((f,p)=>Ce(f,t,{...i,path:[...i.path,o,p]})),u=a.rest?Ce(a.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=c,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:c},u&&n.items.anyOf.push(u),n.minItems=c.length,u||(n.maxItems=c.length)):(n.items=c,u&&(n.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(n.minItems=l),typeof d=="number"&&(n.maxItems=d)},xb=(e,t,r,i)=>{let n=r,a=e._zod.def;n.type="object";let o=a.keyType,c=o._zod.bag?.patterns;if(a.mode==="loose"&&c&&c.size>0){let l=Ce(a.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=Ce(a.keyType,t,{...i,path:[...i.path,"propertyNames"]})),n.additionalProperties=Ce(a.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let u=o._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l)}},Sb=(e,t,r,i)=>{let n=e._zod.def,a=Ce(n.innerType,t,i),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},kb=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},$b=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Ib=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Eb=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=o},Tb=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?a?n.out:n.in:n.out;Ce(o,t,i);let s=t.seen.get(e);s.ref=o},Ab=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType,r.readOnly=!0},Cb=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Zf=(e,t,r,i)=>{let n=e._zod.def;Ce(n.innerType,t,i);let a=t.seen.get(e);a.ref=n.innerType},Ob=(e,t,r,i)=>{let n=e._zod.innerType;Ce(n,t,i);let a=t.seen.get(e);a.ref=n},Ff={string:Wv,number:qv,boolean:Xv,bigint:Yv,symbol:Qv,null:eb,undefined:tb,void:rb,never:nb,any:ib,unknown:ab,date:ob,enum:sb,literal:cb,nan:ub,template_literal:lb,file:db,success:fb,custom:pb,function:mb,transform:hb,map:gb,set:_b,array:yb,object:vb,union:Bf,intersection:bb,tuple:wb,record:xb,nullable:Sb,nonoptional:kb,default:$b,prefault:Ib,catch:Eb,pipe:Tb,readonly:Ab,promise:Cb,optional:Zf,lazy:Ob};function Ha(e,t){if("_idmap"in e){let i=e,n=Hi({...t,processors:Ff}),a={};for(let c of i._idmap.entries()){let[u,l]=c;Ce(l,n)}let o={},s={registry:i,uri:t?.uri,defs:a};n.external=s;for(let c of i._idmap.entries()){let[u,l]=c;Ji(n,l),o[u]=Ki(n,l)}if(Object.keys(a).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:a}}return{schemas:o}}let r=Hi({...t,processors:Ff});return Ce(e,r),Ji(r,e),Ki(r,e)}var Vf=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Hi({processors:Ff,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Ce(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Ji(this.ctx,t);let i=Ki(this.ctx,t),{"~standard":n,...a}=i;return a}};var JT={};function De(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let r=t._zod;return typeof r=="object"&&r!==null&&"def"in r}function tt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let r=t._def;return typeof r=="object"&&r!=null&&"typeName"in r}function KT(e){return De(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),tt(e)}function sr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(De(e)||tt(e))}function Pb(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodLiteral"}function Nb(e){return De(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="literal":!1}function WT(e){return!!(Pb(e)||Nb(e))}async function Hf(e,t){if(De(e))try{return{success:!0,data:await Ua(e,t)}}catch(r){return{success:!1,error:r}}if(tt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function Wi(e,t){if(De(e))return await Ua(e,t);if(tt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function qT(e,t){if(De(e))try{return{success:!0,data:Zi(e,t)}}catch(r){return{success:!1,error:r}}if(tt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function ks(e,t){if(De(e))return Zi(e,t);if(tt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function si(e){if(De(e))return Te.get(e)?.description;if(tt(e)||"description"in e&&typeof e.description=="string")return e.description}function XT(e){if(!sr(e))return!1;if(tt(e)){let t=e._def;if(t.typeName==="ZodObject"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(De(e)){let t=e._zod.def;if(t.type==="object"){let r=e;return!r.shape||Object.keys(r.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function $s(e){return sr(e)?tt(e)?e._def.typeName==="ZodString":De(e)?e._zod.def.type==="string":!1:!1}function uu(e){return typeof e=="object"&&e!==null&&"_def"in e&&typeof e._def=="object"&&e._def!==null&&"typeName"in e._def&&e._def.typeName==="ZodObject"}function jr(e){return De(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="object":!1}function lu(e){return De(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="array":!1}function Rb(e){return De(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="optional":!1}function jb(e){return De(e)?typeof e=="object"&&e!==null&&"_zod"in e&&typeof e._zod=="object"&&e._zod!==null&&"def"in e._zod&&typeof e._zod.def=="object"&&e._zod.def!==null&&"type"in e._zod.def&&e._zod.def.type==="nullable":!1}function qt(e){return!!(uu(e)||jr(e))}function Ka(e){if(tt(e))return e.shape;if(De(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Jf(e,t){if(tt(e))return e.extend(t);if(De(e))return M.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Is(e){if(tt(e))return e.partial();if(De(e))return M.partial(Ba,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ss(e,t=!1){if(uu(e))return e.strict();if(jr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(jr(o))r[a]=Ss(o,t);else if(lu(o)){let c=o._zod.def.element;jr(c)&&(c=Ss(c,t)),r[a]=Ge(o,{...o._zod.def,element:c})}else r[a]=o;let s=Te.get(o);s&&Te.add(r[a],s)}let i=Ge(e,{...e._zod.def,shape:r,catchall:cu(eu)}),n=Te.get(e);return n&&Te.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Gf(e,t=!1){if(uu(e))return e.passthrough();if(jr(e)){let r=e._zod.def.shape;if(t)for(let[a,o]of Object.entries(e._zod.def.shape)){if(jr(o))r[a]=Gf(o,t);else if(lu(o)){let c=o._zod.def.element;jr(c)&&(c=Gf(c,t)),r[a]=Ge(o,{...o._zod.def,element:c})}else r[a]=o;let s=Te.get(o);s&&Te.add(r[a],s)}let i=Ge(e,{...e._zod.def,shape:r,catchall:su(Qc)}),n=Te.get(e);return n&&Te.add(i,n),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Kf(e){if(tt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(De(e))try{let t=Zi(e,void 0);return()=>t}catch{return}}function UU(e){return tt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function LU(e){return De(e)&&e._zod.def.type==="pipe"}function Ja(e,t,r){let i=r.get(e);if(i!==void 0)return i;if(tt(e))return UU(e)?Ja(e._def.schema,t,r):e;if(De(e)){let n=e;if(LU(e)&&(n=Ja(e._zod.def.in,t,r)),t){if(jr(n)){let o={};for(let[s,c]of Object.entries(n._zod.def.shape))o[s]=Ja(c,t,r);n=Ge(n,{...n._zod.def,shape:o})}else if(lu(n)){let o=Ja(n._zod.def.element,t,r);n=Ge(n,{...n._zod.def,element:o})}else if(Rb(n)){let o=Ja(n._zod.def.innerType,t,r);n=Ge(n,{...n._zod.def,innerType:o})}else if(jb(n)){let o=Ja(n._zod.def.innerType,t,r);n=Ge(n,{...n._zod.def,innerType:o})}}let a=Te.get(e);return a&&Te.add(n,a),r.set(e,n),n}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Wf(e,t=!1){return Ja(e,t,new WeakMap)}function YT(e,t){if(tt(e)){let r=Ka(e),i={};for(let[n,a]of Object.entries(r))t(n,a)?i[n]=a.optional():i[n]=a;return e.extend(i)}if(De(e)){let r=Ka(e),i={...e._zod.def.shape};for(let[o,s]of Object.entries(r))t(o,s)&&(i[o]=new Ba({type:"optional",innerType:s}));let n=Ge(e,{...e._zod.def,shape:i}),a=Te.get(e);return a&&Te.add(n,a),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function qf(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var eA=Symbol("Let zodToJsonSchema decide on which parser to use"),QT={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},tA=e=>typeof e=="string"?{...QT,name:e}:{...QT,...e};var rA=e=>{let t=tA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,i],jsonSchema:void 0}]))}};var Xf=(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 Ke(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Xf(t,e.currentPath):t.join("/")}}function Mb(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ie(e,t,r,i,n){e[t]=r,Mb(e,t,i,n)}var bt={};bn(bt,{BRAND:()=>f2,DIRTY:()=>Wa,EMPTY_PATH:()=>VU,INVALID:()=>ne,NEVER:()=>q2,OK:()=>Nt,ParseStatus:()=>Et,Schema:()=>he,ZodAny:()=>Yi,ZodArray:()=>di,ZodBigInt:()=>Xa,ZodBoolean:()=>Ya,ZodBranded:()=>fu,ZodCatch:()=>uo,ZodDate:()=>Qa,ZodDefault:()=>co,ZodDiscriminatedUnion:()=>ep,ZodEffects:()=>Dr,ZodEnum:()=>oo,ZodError:()=>cr,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>rp,ZodIntersection:()=>no,ZodIssueCode:()=>z,ZodLazy:()=>io,ZodLiteral:()=>ao,ZodMap:()=>Ps,ZodNaN:()=>Rs,ZodNativeEnum:()=>so,ZodNever:()=>rn,ZodNull:()=>to,ZodNullable:()=>zn,ZodNumber:()=>qa,ZodObject:()=>ur,ZodOptional:()=>Mr,ZodParsedType:()=>K,ZodPipeline:()=>pu,ZodPromise:()=>Qi,ZodReadonly:()=>lo,ZodRecord:()=>tp,ZodSchema:()=>he,ZodSet:()=>Ns,ZodString:()=>Xi,ZodSymbol:()=>Cs,ZodTransformer:()=>Dr,ZodTuple:()=>Mn,ZodType:()=>he,ZodUndefined:()=>eo,ZodUnion:()=>ro,ZodUnknown:()=>li,ZodVoid:()=>Os,addIssueToContext:()=>Z,any:()=>w2,array:()=>$2,bigint:()=>g2,boolean:()=>pA,coerce:()=>W2,custom:()=>lA,date:()=>_2,datetimeRegex:()=>cA,defaultErrorMap:()=>ci,discriminatedUnion:()=>A2,effect:()=>F2,enum:()=>D2,function:()=>j2,getErrorMap:()=>Es,getParsedType:()=>jn,instanceof:()=>m2,intersection:()=>C2,isAborted:()=>Yf,isAsync:()=>Ts,isDirty:()=>Qf,isValid:()=>qi,late:()=>p2,lazy:()=>M2,literal:()=>z2,makeIssue:()=>du,map:()=>N2,nan:()=>h2,nativeEnum:()=>U2,never:()=>S2,null:()=>b2,nullable:()=>Z2,number:()=>fA,object:()=>I2,objectUtil:()=>zb,oboolean:()=>K2,onumber:()=>J2,optional:()=>B2,ostring:()=>H2,pipeline:()=>G2,preprocess:()=>V2,promise:()=>L2,quotelessJson:()=>FU,record:()=>P2,set:()=>R2,setErrorMap:()=>ZU,strictObject:()=>E2,string:()=>dA,symbol:()=>y2,transformer:()=>F2,tuple:()=>O2,undefined:()=>v2,union:()=>T2,unknown:()=>x2,util:()=>ke,void:()=>k2});var ke;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let a={};for(let o of n)a[o]=o;return a},e.getValidEnumValues=n=>{let a=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),o={};for(let s of a)o[s]=n[s];return e.objectValues(o)},e.objectValues=n=>e.objectKeys(n).map(function(a){return n[a]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},e.find=(n,a)=>{for(let o of n)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=i,e.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(ke||(ke={}));var zb;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(zb||(zb={}));var K=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jn=e=>{switch(typeof e){case"undefined":return K.undefined;case"string":return K.string;case"number":return Number.isNaN(e)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":return Array.isArray(e)?K.array:e===null?K.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?K.promise:typeof Map<"u"&&e instanceof Map?K.map:typeof Set<"u"&&e instanceof Set?K.set:typeof Date<"u"&&e instanceof Date?K.date:K.object;default:return K.unknown}};var z=ke.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"]),FU=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),cr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(a){return a.message},i={_errors:[]},n=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)i._errors.push(r(o));else{let s=i,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(o))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return n(this),i}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];r[a]=r[a]||[],r[a].push(t(n))}else i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};cr.create=e=>new cr(e);var BU=(e,t)=>{let r;switch(e.code){case z.invalid_type:e.received===K.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ke.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:r=`Unrecognized key(s) in object: ${ke.joinValues(e.keys,", ")}`;break;case z.invalid_union:r="Invalid input";break;case z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ke.joinValues(e.options)}`;break;case z.invalid_enum_value:r=`Invalid enum value. Expected ${ke.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:r="Invalid function arguments";break;case z.invalid_return_type:r="Invalid function return type";break;case z.invalid_date:r="Invalid date";break;case z.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ke.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case z.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case z.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case z.custom:r="Invalid input";break;case z.invalid_intersection_types:r="Intersection results could not be merged";break;case z.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:r="Number must be finite";break;default:r=t.defaultError,ke.assertNever(e)}return{message:r}},ci=BU;var nA=ci;function ZU(e){nA=e}function Es(){return nA}var du=e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let s="",c=i.filter(u=>!!u).slice().reverse();for(let u of c)s=u(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}},VU=[];function Z(e,t){let r=Es(),i=du({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===ci?void 0:ci].filter(n=>!!n)});e.common.issues.push(i)}var Et=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let i=[];for(let n of r){if(n.status==="aborted")return ne;n.status==="dirty"&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let n of r){let a=await n.key,o=await n.value;i.push({key:a,value:o})}return e.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return ne;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(i[a.value]=o.value)}return{status:t.value,value:i}}},ne=Object.freeze({status:"aborted"}),Wa=e=>({status:"dirty",value:e}),Nt=e=>({status:"valid",value:e}),Yf=e=>e.status==="aborted",Qf=e=>e.status==="dirty",qi=e=>e.status==="valid",Ts=e=>typeof Promise<"u"&&e instanceof Promise;var ee;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ee||(ee={}));var zr=class{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},iA=(e,t)=>{if(qi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new cr(e.common.issues);return this._error=r,this._error}}};function fe(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,s)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??i??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:n}}var he=class{get description(){return this._def.description}_getType(t){return jn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:jn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Et,ctx:{common:t.parent.common,data:t.data,parsedType:jn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ts(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jn(t)},n=this._parseSync({data:t,path:i.path,parent:i});return iA(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jn(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return qi(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>qi(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jn(t)},n=this._parse({data:t,path:i.path,parent:i}),a=await(Ts(n)?n:Promise.resolve(n));return iA(i,a)}refine(t,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{let o=t(n),s=()=>a.addIssue({code:z.custom,...i(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((i,n)=>t(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(t){return new Dr({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Mr.create(this,this._def)}nullable(){return zn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return di.create(this)}promise(){return Qi.create(this,this._def)}or(t){return ro.create([this,t],this._def)}and(t){return no.create(this,t,this._def)}transform(t){return new Dr({...fe(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new co({...fe(this._def),innerType:this,defaultValue:r,typeName:D.ZodDefault})}brand(){return new fu({typeName:D.ZodBranded,type:this,...fe(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new uo({...fe(this._def),innerType:this,catchValue:r,typeName:D.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return pu.create(this,t)}readonly(){return lo.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},GU=/^c[^\s-]{8,}$/i,HU=/^[0-9a-z]+$/,JU=/^[0-9A-HJKMNP-TV-Z]{26}$/i,KU=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,WU=/^[a-z0-9_-]{21}$/i,qU=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,XU=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,YU=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,QU="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Db,e2=/^(?:(?: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])$/,t2=/^(?:(?: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])$/,r2=/^(([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]))$/,n2=/^(([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])$/,i2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,a2=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,oA="((\\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])))",o2=new RegExp(`^${oA}$`);function sA(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function s2(e){return new RegExp(`^${sA(e)}$`)}function cA(e){let t=`${oA}T${sA(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function c2(e,t){return!!((t==="v4"||!t)&&e2.test(e)||(t==="v6"||!t)&&r2.test(e))}function u2(e,t){if(!qU.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function l2(e,t){return!!((t==="v4"||!t)&&t2.test(e)||(t==="v6"||!t)&&n2.test(e))}var Xi=class e extends he{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==K.string){let a=this._getOrReturnCtx(t);return Z(a,{code:z.invalid_type,expected:K.string,received:a.parsedType}),ne}let i=new Et,n;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="max")t.data.length>a.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),i.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(n=this._getOrReturnCtx(t,n),o?Z(n,{code:z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Z(n,{code:z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),i.dirty())}else if(a.kind==="email")YU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"email",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="emoji")Db||(Db=new RegExp(QU,"u")),Db.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"emoji",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="uuid")KU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"uuid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="nanoid")WU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"nanoid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid")GU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cuid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="cuid2")HU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cuid2",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="ulid")JU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"ulid",code:z.invalid_string,message:a.message}),i.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),Z(n,{validation:"url",code:z.invalid_string,message:a.message}),i.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"regex",code:z.invalid_string,message:a.message}),i.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),i.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:{startsWith:a.value},message:a.message}),i.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:{endsWith:a.value},message:a.message}),i.dirty()):a.kind==="datetime"?cA(a).test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:"datetime",message:a.message}),i.dirty()):a.kind==="date"?o2.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:"date",message:a.message}),i.dirty()):a.kind==="time"?s2(a).test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{code:z.invalid_string,validation:"time",message:a.message}),i.dirty()):a.kind==="duration"?XU.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"duration",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="ip"?c2(t.data,a.version)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"ip",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="jwt"?u2(t.data,a.alg)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"jwt",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="cidr"?l2(t.data,a.version)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"cidr",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="base64"?i2.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"base64",code:z.invalid_string,message:a.message}),i.dirty()):a.kind==="base64url"?a2.test(t.data)||(n=this._getOrReturnCtx(t,n),Z(n,{validation:"base64url",code:z.invalid_string,message:a.message}),i.dirty()):ke.assertNever(a);return{status:i.value,value:t.data}}_regex(t,r,i){return this.refinement(n=>t.test(n),{validation:r,code:z.invalid_string,...ee.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ee.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ee.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ee.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ee.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ee.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ee.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ee.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ee.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ee.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ee.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ee.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ee.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ee.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...ee.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...ee.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ee.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ee.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ee.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ee.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ee.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ee.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ee.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ee.errToObj(r)})}nonempty(t){return this.min(1,ee.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Xi.create=e=>new Xi({checks:[],typeName:D.ZodString,coerce:e?.coerce??!1,...fe(e)});function d2(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i,a=Number.parseInt(e.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return a%o/10**n}var qa=class e extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==K.number){let a=this._getOrReturnCtx(t);return Z(a,{code:z.invalid_type,expected:K.number,received:a.parsedType}),ne}let i,n=new Et;for(let a of this._def.checks)a.kind==="int"?ke.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:z.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?d2(t.data,a.value)!==0&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),Z(i,{code:z.not_finite,message:a.message}),n.dirty()):ke.assertNever(a);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ee.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ee.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ee.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ee.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ee.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ee.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ee.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ee.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ee.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ee.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ke.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(r)&&Number.isFinite(t)}};qa.create=e=>new qa({checks:[],typeName:D.ZodNumber,coerce:e?.coerce||!1,...fe(e)});var Xa=class e extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==K.bigint)return this._getInvalidInput(t);let i,n=new Et;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),Z(i,{code:z.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):ke.assertNever(a);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Z(r,{code:z.invalid_type,expected:K.bigint,received:r.parsedType}),ne}gte(t,r){return this.setLimit("min",t,!0,ee.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ee.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ee.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ee.toString(r))}setLimit(t,r,i,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:ee.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ee.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ee.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ee.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ee.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ee.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Xa.create=e=>new Xa({checks:[],typeName:D.ZodBigInt,coerce:e?.coerce??!1,...fe(e)});var Ya=class extends he{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==K.boolean){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.boolean,received:i.parsedType}),ne}return Nt(t.data)}};Ya.create=e=>new Ya({typeName:D.ZodBoolean,coerce:e?.coerce||!1,...fe(e)});var Qa=class e extends he{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==K.date){let a=this._getOrReturnCtx(t);return Z(a,{code:z.invalid_type,expected:K.date,received:a.parsedType}),ne}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return Z(a,{code:z.invalid_date}),ne}let i=new Et,n;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:z.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),i.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(n=this._getOrReturnCtx(t,n),Z(n,{code:z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),i.dirty()):ke.assertNever(a);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:ee.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ee.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Qa.create=e=>new Qa({checks:[],coerce:e?.coerce||!1,typeName:D.ZodDate,...fe(e)});var Cs=class extends he{_parse(t){if(this._getType(t)!==K.symbol){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.symbol,received:i.parsedType}),ne}return Nt(t.data)}};Cs.create=e=>new Cs({typeName:D.ZodSymbol,...fe(e)});var eo=class extends he{_parse(t){if(this._getType(t)!==K.undefined){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.undefined,received:i.parsedType}),ne}return Nt(t.data)}};eo.create=e=>new eo({typeName:D.ZodUndefined,...fe(e)});var to=class extends he{_parse(t){if(this._getType(t)!==K.null){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.null,received:i.parsedType}),ne}return Nt(t.data)}};to.create=e=>new to({typeName:D.ZodNull,...fe(e)});var Yi=class extends he{constructor(){super(...arguments),this._any=!0}_parse(t){return Nt(t.data)}};Yi.create=e=>new Yi({typeName:D.ZodAny,...fe(e)});var li=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Nt(t.data)}};li.create=e=>new li({typeName:D.ZodUnknown,...fe(e)});var rn=class extends he{_parse(t){let r=this._getOrReturnCtx(t);return Z(r,{code:z.invalid_type,expected:K.never,received:r.parsedType}),ne}};rn.create=e=>new rn({typeName:D.ZodNever,...fe(e)});var Os=class extends he{_parse(t){if(this._getType(t)!==K.undefined){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.void,received:i.parsedType}),ne}return Nt(t.data)}};Os.create=e=>new Os({typeName:D.ZodVoid,...fe(e)});var di=class e extends he{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==K.array)return Z(r,{code:z.invalid_type,expected:K.array,received:r.parsedType}),ne;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(o||s)&&(Z(r,{code:o?z.too_big:z.too_small,minimum:s?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(Z(r,{code:z.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(Z(r,{code:z.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>n.type._parseAsync(new zr(r,o,r.path,s)))).then(o=>Et.mergeArray(i,o));let a=[...r.data].map((o,s)=>n.type._parseSync(new zr(r,o,r.path,s)));return Et.mergeArray(i,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:ee.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:ee.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:ee.toString(r)}})}nonempty(t){return this.min(1,t)}};di.create=(e,t)=>new di({type:e,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...fe(t)});function As(e){if(e instanceof ur){let t={};for(let r in e.shape){let i=e.shape[r];t[r]=Mr.create(As(i))}return new ur({...e._def,shape:()=>t})}else return e instanceof di?new di({...e._def,type:As(e.element)}):e instanceof Mr?Mr.create(As(e.unwrap())):e instanceof zn?zn.create(As(e.unwrap())):e instanceof Mn?Mn.create(e.items.map(t=>As(t))):e}var ur=class e extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ke.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==K.object){let u=this._getOrReturnCtx(t);return Z(u,{code:z.invalid_type,expected:K.object,received:u.parsedType}),ne}let{status:i,ctx:n}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof rn&&this._def.unknownKeys==="strip"))for(let u in n.data)o.includes(u)||s.push(u);let c=[];for(let u of o){let l=a[u],d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new zr(n,d,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof rn){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(Z(n,{code:z.unrecognized_keys,keys:s}),i.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new zr(n,d,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>Et.mergeObjectSync(i,u)):Et.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(t){return ee.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:ee.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:D.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let i of ke.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let i of ke.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new e({...this._def,shape:()=>r})}deepPartial(){return As(this)}partial(t){let r={};for(let i of ke.objectKeys(this.shape)){let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let i of ke.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let a=this.shape[i];for(;a instanceof Mr;)a=a._def.innerType;r[i]=a}return new e({...this._def,shape:()=>r})}keyof(){return uA(ke.objectKeys(this.shape))}};ur.create=(e,t)=>new ur({shape:()=>e,unknownKeys:"strip",catchall:rn.create(),typeName:D.ZodObject,...fe(t)});ur.strictCreate=(e,t)=>new ur({shape:()=>e,unknownKeys:"strict",catchall:rn.create(),typeName:D.ZodObject,...fe(t)});ur.lazycreate=(e,t)=>new ur({shape:e,unknownKeys:"strip",catchall:rn.create(),typeName:D.ZodObject,...fe(t)});var ro=class extends he{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;function n(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new cr(s.ctx.common.issues));return Z(r,{code:z.invalid_union,unionErrors:o}),ne}if(r.common.async)return Promise.all(i.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let a,o=[];for(let c of i){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new cr(c));return Z(r,{code:z.invalid_union,unionErrors:s}),ne}}get options(){return this._def.options}};ro.create=(e,t)=>new ro({options:e,typeName:D.ZodUnion,...fe(t)});var ui=e=>e instanceof io?ui(e.schema):e instanceof Dr?ui(e.innerType()):e instanceof ao?[e.value]:e instanceof oo?e.options:e instanceof so?ke.objectValues(e.enum):e instanceof co?ui(e._def.innerType):e instanceof eo?[void 0]:e instanceof to?[null]:e instanceof Mr?[void 0,...ui(e.unwrap())]:e instanceof zn?[null,...ui(e.unwrap())]:e instanceof fu||e instanceof lo?ui(e.unwrap()):e instanceof uo?ui(e._def.innerType):[],ep=class e extends he{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.object)return Z(r,{code:z.invalid_type,expected:K.object,received:r.parsedType}),ne;let i=this.discriminator,n=r.data[i],a=this.optionsMap.get(n);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(Z(r,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),ne)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let a of r){let o=ui(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,a)}}return new e({typeName:D.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...fe(i)})}};function Ub(e,t){let r=jn(e),i=jn(t);if(e===t)return{valid:!0,data:e};if(r===K.object&&i===K.object){let n=ke.objectKeys(t),a=ke.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=Ub(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(r===K.array&&i===K.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=Ub(o,s);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===K.date&&i===K.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var no=class extends he{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(a,o)=>{if(Yf(a)||Yf(o))return ne;let s=Ub(a.value,o.value);return s.valid?((Qf(a)||Qf(o))&&r.dirty(),{status:r.value,value:s.data}):(Z(i,{code:z.invalid_intersection_types}),ne)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};no.create=(e,t,r)=>new no({left:e,right:t,typeName:D.ZodIntersection,...fe(r)});var Mn=class e extends he{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==K.array)return Z(i,{code:z.invalid_type,expected:K.array,received:i.parsedType}),ne;if(i.data.length<this._def.items.length)return Z(i,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ne;!this._def.rest&&i.data.length>this._def.items.length&&(Z(i,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...i.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new zr(i,o,i.path,s)):null}).filter(o=>!!o);return i.common.async?Promise.all(a).then(o=>Et.mergeArray(r,o)):Et.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Mn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mn({items:e,typeName:D.ZodTuple,rest:null,...fe(t)})};var tp=class e extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==K.object)return Z(i,{code:z.invalid_type,expected:K.object,received:i.parsedType}),ne;let n=[],a=this._def.keyType,o=this._def.valueType;for(let s in i.data)n.push({key:a._parse(new zr(i,s,i.path,s)),value:o._parse(new zr(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?Et.mergeObjectAsync(r,n):Et.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return r instanceof he?new e({keyType:t,valueType:r,typeName:D.ZodRecord,...fe(i)}):new e({keyType:Xi.create(),valueType:t,typeName:D.ZodRecord,...fe(r)})}},Ps=class extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==K.map)return Z(i,{code:z.invalid_type,expected:K.map,received:i.parsedType}),ne;let n=this._def.keyType,a=this._def.valueType,o=[...i.data.entries()].map(([s,c],u)=>({key:n._parse(new zr(i,s,i.path,[u,"key"])),value:a._parse(new zr(i,c,i.path,[u,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return ne;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return ne;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Ps.create=(e,t,r)=>new Ps({valueType:t,keyType:e,typeName:D.ZodMap,...fe(r)});var Ns=class e extends he{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==K.set)return Z(i,{code:z.invalid_type,expected:K.set,received:i.parsedType}),ne;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(Z(i,{code:z.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(Z(i,{code:z.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let a=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return ne;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...i.data.values()].map((c,u)=>a._parse(new zr(i,c,i.path,u)));return i.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:ee.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:ee.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Ns.create=(e,t)=>new Ns({valueType:e,minSize:null,maxSize:null,typeName:D.ZodSet,...fe(t)});var rp=class e extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.function)return Z(r,{code:z.invalid_type,expected:K.function,received:r.parsedType}),ne;function i(s,c){return du({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Es(),ci].filter(u=>!!u),issueData:{code:z.invalid_arguments,argumentsError:c}})}function n(s,c){return du({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Es(),ci].filter(u=>!!u),issueData:{code:z.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Qi){let s=this;return Nt(async function(...c){let u=new cr([]),l=await s._def.args.parseAsync(c,a).catch(p=>{throw u.addIssue(i(c,p)),u}),d=await Reflect.apply(o,this,l);return await s._def.returns._def.type.parseAsync(d,a).catch(p=>{throw u.addIssue(n(d,p)),u})})}else{let s=this;return Nt(function(...c){let u=s._def.args.safeParse(c,a);if(!u.success)throw new cr([i(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=s._def.returns.safeParse(l,a);if(!d.success)throw new cr([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Mn.create(t).rest(li.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,i){return new e({args:t||Mn.create([]).rest(li.create()),returns:r||li.create(),typeName:D.ZodFunction,...fe(i)})}},io=class extends he{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};io.create=(e,t)=>new io({getter:e,typeName:D.ZodLazy,...fe(t)});var ao=class extends he{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Z(r,{received:r.data,code:z.invalid_literal,expected:this._def.value}),ne}return{status:"valid",value:t.data}}get value(){return this._def.value}};ao.create=(e,t)=>new ao({value:e,typeName:D.ZodLiteral,...fe(t)});function uA(e,t){return new oo({values:e,typeName:D.ZodEnum,...fe(t)})}var oo=class e extends he{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),i=this._def.values;return Z(r,{expected:ke.joinValues(i),received:r.parsedType,code:z.invalid_type}),ne}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return Z(r,{received:r.data,code:z.invalid_enum_value,options:i}),ne}return Nt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(i=>!t.includes(i)),{...this._def,...r})}};oo.create=uA;var so=class extends he{_parse(t){let r=ke.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==K.string&&i.parsedType!==K.number){let n=ke.objectValues(r);return Z(i,{expected:ke.joinValues(n),received:i.parsedType,code:z.invalid_type}),ne}if(this._cache||(this._cache=new Set(ke.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=ke.objectValues(r);return Z(i,{received:i.data,code:z.invalid_enum_value,options:n}),ne}return Nt(t.data)}get enum(){return this._def.values}};so.create=(e,t)=>new so({values:e,typeName:D.ZodNativeEnum,...fe(t)});var Qi=class extends he{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==K.promise&&r.common.async===!1)return Z(r,{code:z.invalid_type,expected:K.promise,received:r.parsedType}),ne;let i=r.parsedType===K.promise?r.data:Promise.resolve(r.data);return Nt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Qi.create=(e,t)=>new Qi({type:e,typeName:D.ZodPromise,...fe(t)});var Dr=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:o=>{Z(i,o),o.fatal?r.abort():r.dirty()},get path(){return i.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let o=n.transform(i.data,a);if(i.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return ne;let c=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return c.status==="aborted"?ne:c.status==="dirty"?Wa(c.value):r.value==="dirty"?Wa(c.value):c});{if(r.value==="aborted")return ne;let s=this._def.schema._parseSync({data:o,path:i.path,parent:i});return s.status==="aborted"?ne:s.status==="dirty"?Wa(s.value):r.value==="dirty"?Wa(s.value):s}}if(n.type==="refinement"){let o=s=>{let c=n.refinement(s,a);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?ne:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?ne:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!qi(o))return ne;let s=n.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>qi(o)?Promise.resolve(n.transform(o.value,a)).then(s=>({status:r.value,value:s})):ne);ke.assertNever(n)}};Dr.create=(e,t,r)=>new Dr({schema:e,typeName:D.ZodEffects,effect:t,...fe(r)});Dr.createWithPreprocess=(e,t,r)=>new Dr({schema:t,effect:{type:"preprocess",transform:e},typeName:D.ZodEffects,...fe(r)});var Mr=class extends he{_parse(t){return this._getType(t)===K.undefined?Nt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Mr.create=(e,t)=>new Mr({innerType:e,typeName:D.ZodOptional,...fe(t)});var zn=class extends he{_parse(t){return this._getType(t)===K.null?Nt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};zn.create=(e,t)=>new zn({innerType:e,typeName:D.ZodNullable,...fe(t)});var co=class extends he{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===K.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};co.create=(e,t)=>new co({innerType:e,typeName:D.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...fe(t)});var uo=class extends he{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Ts(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new cr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new cr(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};uo.create=(e,t)=>new uo({innerType:e,typeName:D.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...fe(t)});var Rs=class extends he{_parse(t){if(this._getType(t)!==K.nan){let i=this._getOrReturnCtx(t);return Z(i,{code:z.invalid_type,expected:K.nan,received:i.parsedType}),ne}return{status:"valid",value:t.data}}};Rs.create=e=>new Rs({typeName:D.ZodNaN,...fe(e)});var f2=Symbol("zod_brand"),fu=class extends he{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},pu=class e extends he{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?ne:a.status==="dirty"?(r.dirty(),Wa(a.value)):this._def.out._parseAsync({data:a.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?ne:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(t,r){return new e({in:t,out:r,typeName:D.ZodPipeline})}},lo=class extends he{_parse(t){let r=this._def.innerType._parse(t),i=n=>(qi(n)&&(n.value=Object.freeze(n.value)),n);return Ts(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};lo.create=(e,t)=>new lo({innerType:e,typeName:D.ZodReadonly,...fe(t)});function aA(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function lA(e,t={},r){return e?Yi.create().superRefine((i,n)=>{let a=e(i);if(a instanceof Promise)return a.then(o=>{if(!o){let s=aA(t,i),c=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=aA(t,i),s=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:s})}}):Yi.create()}var p2={object:ur.lazycreate},D;(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"})(D||(D={}));var m2=(e,t={message:`Input not instance of ${e.name}`})=>lA(r=>r instanceof e,t),dA=Xi.create,fA=qa.create,h2=Rs.create,g2=Xa.create,pA=Ya.create,_2=Qa.create,y2=Cs.create,v2=eo.create,b2=to.create,w2=Yi.create,x2=li.create,S2=rn.create,k2=Os.create,$2=di.create,I2=ur.create,E2=ur.strictCreate,T2=ro.create,A2=ep.create,C2=no.create,O2=Mn.create,P2=tp.create,N2=Ps.create,R2=Ns.create,j2=rp.create,M2=io.create,z2=ao.create,D2=oo.create,U2=so.create,L2=Qi.create,F2=Dr.create,B2=Mr.create,Z2=zn.create,V2=Dr.createWithPreprocess,G2=pu.create,H2=()=>dA().optional(),J2=()=>fA().optional(),K2=()=>pA().optional(),W2={string:(e=>Xi.create({...e,coerce:!0})),number:(e=>qa.create({...e,coerce:!0})),boolean:(e=>Ya.create({...e,coerce:!0})),bigint:(e=>Xa.create({...e,coerce:!0})),date:(e=>Qa.create({...e,coerce:!0}))};var q2=ne;function mA(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==D.ZodAny&&(r.items=ie(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ie(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ie(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ie(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ie(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function hA(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"min":t.target==="jsonSchema7"?i.inclusive?Ie(r,"minimum",i.value,i.message,t):Ie(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ie(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ie(r,"maximum",i.value,i.message,t):Ie(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ie(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ie(r,"multipleOf",i.value,i.message,t);break}return r}function gA(){return{type:"boolean"}}function np(e,t){return ie(e.type._def,t)}var _A=(e,t)=>ie(e.innerType._def,t);function Lb(e,t,r){let i=r??t.dateStrategy;if(Array.isArray(i))return{anyOf:i.map(n=>Lb(e,t,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return X2(e,t)}}var X2=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let i of e.checks)switch(i.kind){case"min":Ie(r,"minimum",i.value,i.message,t);break;case"max":Ie(r,"maximum",i.value,i.message,t);break}return r};function yA(e,t){return{...ie(e.innerType._def,t),default:e.defaultValue()}}function vA(e,t){return t.effectStrategy==="input"?ie(e.schema._def,t):Ke(t)}function bA(e){return{type:"string",enum:Array.from(e.values)}}var Y2=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function wA(e,t){let r=[ie(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ie(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),i=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(a=>{if(Y2(a))n.push(...a.allOf),a.unevaluatedProperties===void 0&&(i=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:s,...c}=a;o=c}else i=void 0;n.push(o)}}),n.length?{allOf:n,...i}:void 0}function xA(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var Fb,nn={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:()=>(Fb===void 0&&(Fb=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Fb),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 ip(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Ie(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":an(r,"email",i.message,t);break;case"format:idn-email":an(r,"idn-email",i.message,t);break;case"pattern:zod":Xt(r,nn.email,i.message,t);break}break;case"url":an(r,"uri",i.message,t);break;case"uuid":an(r,"uuid",i.message,t);break;case"regex":Xt(r,i.regex,i.message,t);break;case"cuid":Xt(r,nn.cuid,i.message,t);break;case"cuid2":Xt(r,nn.cuid2,i.message,t);break;case"startsWith":Xt(r,RegExp(`^${Bb(i.value,t)}`),i.message,t);break;case"endsWith":Xt(r,RegExp(`${Bb(i.value,t)}$`),i.message,t);break;case"datetime":an(r,"date-time",i.message,t);break;case"date":an(r,"date",i.message,t);break;case"time":an(r,"time",i.message,t);break;case"duration":an(r,"duration",i.message,t);break;case"length":Ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Ie(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":Xt(r,RegExp(Bb(i.value,t)),i.message,t);break;case"ip":i.version!=="v6"&&an(r,"ipv4",i.message,t),i.version!=="v4"&&an(r,"ipv6",i.message,t);break;case"base64url":Xt(r,nn.base64url,i.message,t);break;case"jwt":Xt(r,nn.jwt,i.message,t);break;case"cidr":i.version!=="v6"&&Xt(r,nn.ipv4Cidr,i.message,t),i.version!=="v4"&&Xt(r,nn.ipv6Cidr,i.message,t);break;case"emoji":Xt(r,nn.emoji(),i.message,t);break;case"ulid":Xt(r,nn.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":an(r,"binary",i.message,t);break;case"contentEncoding:base64":Ie(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":Xt(r,nn.base64,i.message,t);break}break;case"nanoid":Xt(r,nn.nanoid,i.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Bb(e,t){return t.patternStrategy==="escape"?eL(e):e}var Q2=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function eL(e){let t="";for(let r=0;r<e.length;r++)Q2.has(e[r])||(t+="\\"),t+=e[r];return t}function an(e,t,r,i){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):Ie(e,"format",t,r,i)}function Xt(e,t,r,i){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:SA(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Ie(e,"pattern",SA(t,i),r,i)}function SA(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",a=!1,o=!1,s=!1;for(let c=0;c<i.length;c++){if(a){n+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){s?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),s=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],s=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
|
|
219
|
+
]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
|
|
220
|
+
]))`;continue}}if(r.s&&i[c]==="."){n+=o?`${i[c]}\r
|
|
221
|
+
`:`[${i[c]}\r
|
|
222
|
+
]`;continue}n+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function ap(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===D.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((i,n)=>({...i,[n]:ie(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??Ke(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:ie(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===D.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=ip(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===D.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===D.ZodBranded&&e.keyType._def.type._def.typeName===D.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=np(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function kA(e,t){return t.mapStrategy==="record"?ap(e,t):{type:"array",maxItems:125,items:{type:"array",items:[ie(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ke(t),ie(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ke(t)],minItems:2,maxItems:2}}}function $A(e){let t=e.values,r=Object.keys(e.values).filter(n=>typeof t[t[n]]!="number").map(n=>t[n]),i=Array.from(new Set(r.map(n=>typeof n)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function IA(e){return e.target==="openAi"?void 0:{not:Ke({...e,currentPath:[...e.currentPath,"not"]})}}function EA(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var mu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function AA(e,t){if(t.target==="openApi3")return TA(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(i=>i._def.typeName in mu&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,a)=>{let o=mu[a._def.typeName];return o&&!n.includes(o)?[...n,o]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...n,o];case"bigint":return[...n,"integer"];case"object":return a._def.value===null?[...n,"null"]:n;default:return n}},[]);if(i.length===r.length){let n=i.filter((a,o,s)=>s.indexOf(a)===o);return{type:n.length>1?n:n[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(a=>!i.includes(a))],[])};return TA(e,t)}var TA=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((i,n)=>ie(i._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!t.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0};function CA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:mu[e.innerType._def.typeName],nullable:!0}:{type:[mu[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let i=ie(e.innerType._def,{...t,currentPath:[...t.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=ie(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function OA(e,t){let r={type:"number"};if(!e.checks)return r;for(let i of e.checks)switch(i.kind){case"int":r.type="integer",Mb(r,"type",i.message,t);break;case"min":t.target==="jsonSchema7"?i.inclusive?Ie(r,"minimum",i.value,i.message,t):Ie(r,"exclusiveMinimum",i.value,i.message,t):(i.inclusive||(r.exclusiveMinimum=!0),Ie(r,"minimum",i.value,i.message,t));break;case"max":t.target==="jsonSchema7"?i.inclusive?Ie(r,"maximum",i.value,i.message,t):Ie(r,"exclusiveMaximum",i.value,i.message,t):(i.inclusive||(r.exclusiveMaximum=!0),Ie(r,"maximum",i.value,i.message,t));break;case"multipleOf":Ie(r,"multipleOf",i.value,i.message,t);break}return r}function PA(e,t){let r=t.target==="openAi",i={type:"object",properties:{}},n=[],a=e.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let u=rL(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=ie(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(i.properties[s]=l,u||n.push(s))}n.length&&(i.required=n);let o=tL(e,t);return o!==void 0&&(i.additionalProperties=o),i}function tL(e,t){if(e.catchall._def.typeName!=="ZodNever")return ie(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 rL(e){try{return e.isOptional()}catch{return!0}}var NA=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return ie(e.innerType._def,t);let r=ie(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ke(t)},r]}:Ke(t)};var RA=(e,t)=>{if(t.pipeStrategy==="input")return ie(e.in._def,t);if(t.pipeStrategy==="output")return ie(e.out._def,t);let r=ie(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,ie(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(i=>i!==void 0)}};function jA(e,t){return ie(e.type._def,t)}function MA(e,t){let r={type:"array",uniqueItems:!0,items:ie(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ie(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ie(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function zA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,i)=>ie(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:ie(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,i)=>ie(r._def,{...t,currentPath:[...t.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}function DA(e){return{not:Ke(e)}}function UA(e){return Ke(e)}var LA=(e,t)=>ie(e.innerType._def,t);var FA=(e,t,r)=>{switch(t){case D.ZodString:return ip(e,r);case D.ZodNumber:return OA(e,r);case D.ZodObject:return PA(e,r);case D.ZodBigInt:return hA(e,r);case D.ZodBoolean:return gA();case D.ZodDate:return Lb(e,r);case D.ZodUndefined:return DA(r);case D.ZodNull:return EA(r);case D.ZodArray:return mA(e,r);case D.ZodUnion:case D.ZodDiscriminatedUnion:return AA(e,r);case D.ZodIntersection:return wA(e,r);case D.ZodTuple:return zA(e,r);case D.ZodRecord:return ap(e,r);case D.ZodLiteral:return xA(e,r);case D.ZodEnum:return bA(e);case D.ZodNativeEnum:return $A(e);case D.ZodNullable:return CA(e,r);case D.ZodOptional:return NA(e,r);case D.ZodMap:return kA(e,r);case D.ZodSet:return MA(e,r);case D.ZodLazy:return()=>e.getter()._def;case D.ZodPromise:return jA(e,r);case D.ZodNaN:case D.ZodNever:return IA(r);case D.ZodEffects:return vA(e,r);case D.ZodAny:return Ke(r);case D.ZodUnknown:return UA(r);case D.ZodDefault:return yA(e,r);case D.ZodBranded:return np(e,r);case D.ZodReadonly:return LA(e,r);case D.ZodCatch:return _A(e,r);case D.ZodPipeline:return RA(e,r);case D.ZodFunction:case D.ZodVoid:case D.ZodSymbol:return;default:return(i=>{})(t)}};function ie(e,t,r=!1){let i=t.seen.get(e);if(t.override){let s=t.override?.(e,t,i,r);if(s!==eA)return s}if(i&&!r){let s=nL(i,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=FA(e,e.typeName,t),o=typeof a=="function"?ie(a(),t):a;if(o&&iL(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var nL=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Xf(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,i)=>t.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ke(t)):t.$refStrategy==="seen"?Ke(t):void 0}},iL=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var BA=(e,t)=>{let r=rA(t),i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:ie(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ke(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=ie(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??Ke(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function Dn(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let i=e.length;if(i!==t.length)return!1;for(let n=0;n<i;n++)if(!Dn(e[n],t[n]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let o of i)if(!Dn(e[o],t[o]))return!1;return!0}return e===t}function Sr(e){return encodeURI(aL(e))}function aL(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var oL={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},sL={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},cL={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},uL=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function on(e,t=Object.create(null),r=uL,i=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let a=e.$id||e.id;if(a){let o=new URL(a,r.href);o.hash.length>1?t[o.href]=e:(o.hash="",i===""?r=o:on(e,t,r))}}else if(e!==!0&&e!==!1)return t;let n=r.href+(i?"#"+i:"");if(t[n]!==void 0)throw new Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&e.__absolute_ref__===void 0){let a=new URL(e.$ref,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:a.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let a=new URL(e.$recursiveRef,r.href);a.hash=a.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:a.href})}if(e.$anchor){let a=new URL("#"+e.$anchor,r.href);t[a.href]=e}for(let a in e){if(cL[a])continue;let o=`${i}/${Sr(a)}`,s=e[a];if(Array.isArray(s)){if(oL[a]){let c=s.length;for(let u=0;u<c;u++)on(s[u],t,r,`${o}/${u}`)}}else if(sL[a])for(let c in s)on(s[c],t,r,`${o}/${Sr(c)}`);else on(s,t,r,o)}return t}var lL=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,dL=[0,31,28,31,30,31,30,31,31,30,31,30,31],fL=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,pL=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,mL=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,hL=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,gL=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,_L=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,yL=/^(?:\/(?:[^~/]|~0|~1)*)*$/,vL=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,bL=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,wL=e=>{if(e[0]==='"')return!1;let[t,r,...i]=e.split("@");return!t||!r||i.length!==0||t.length>64||r.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:r.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},xL=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,SL=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,kL=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Un(e){return e.test.bind(e)}var Zb={date:ZA,time:VA.bind(void 0,!1),"date-time":EL,duration:kL,uri:CL,"uri-reference":Un(mL),"uri-template":Un(hL),url:Un(gL),email:wL,hostname:Un(pL),ipv4:Un(xL),ipv6:Un(SL),regex:PL,uuid:Un(_L),"json-pointer":Un(yL),"json-pointer-uri-fragment":Un(vL),"relative-json-pointer":Un(bL)};function $L(e){return e%4===0&&(e%100!==0||e%400===0)}function ZA(e){let t=e.match(lL);if(!t)return!1;let r=+t[1],i=+t[2],n=+t[3];return i>=1&&i<=12&&n>=1&&n<=(i==2&&$L(r)?29:dL[i])}function VA(e,t){let r=t.match(fL);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||i==23&&n==59&&a==60)&&(!e||o)}var IL=/t|\s/i;function EL(e){let t=e.split(IL);return t.length==2&&ZA(t[0])&&VA(!0,t[1])}var TL=/\/|:/,AL=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function CL(e){return TL.test(e)&&AL.test(e)}var OL=/[^\\]\\Z/;function PL(e){if(OL.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var GA;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(GA||(GA={}));function HA(e){let t=0,r=e.length,i=0,n;for(;i<r;)t++,n=e.charCodeAt(i++),n>=55296&&n<=56319&&i<r&&(n=e.charCodeAt(i),(n&64512)==56320&&i++);return t}function Ue(e,t,r="2019-09",i=on(t),n=!0,a=null,o="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};let u=typeof e,l;switch(u){case"boolean":case"number":case"string":l=u;break;case"object":e===null?l="null":Array.isArray(e)?l="array":l="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:_,enum:v,required:x,not:w,anyOf:S,allOf:$,oneOf:T,if:F,then:A,else:y,format:W,properties:O,patternProperties:B,additionalProperties:de,unevaluatedProperties:Le,minProperties:Lt,maxProperties:_n,propertyNames:we,dependentRequired:la,dependentSchemas:Jn,dependencies:da,prefixItems:Zr,items:Kn,additionalItems:uc,unevaluatedItems:lc,contains:dc,minContains:Vr,maxContains:g,minItems:h,maxItems:C,uniqueItems:k,minimum:xe,maximum:Oe,exclusiveMinimum:dt,exclusiveMaximum:nt,multipleOf:Tt,minLength:Ir,maxLength:it,pattern:yn,__absolute_ref__:$o,__absolute_recursive_ref__:fl}=t,J=[];if(p===!0&&a===null&&(a=t),f==="#"){let ae=a===null?i[fl]:a,te=`${s}/$recursiveRef`,ue=Ue(e,a===null?t:a,r,i,n,ae,o,te,c);ue.valid||J.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:te,error:"A subschema had errors."},...ue.errors)}if(d!==void 0){let te=i[$o||d];if(te===void 0){let G=`Unresolved $ref "${d}".`;throw $o&&$o!==d&&(G+=` Absolute URI "${$o}".`),G+=`
|
|
223
|
+
Known schemas:
|
|
224
|
+
- ${Object.keys(i).join(`
|
|
225
|
+
- `)}`,new Error(G)}let ue=`${s}/$ref`,X=Ue(e,te,r,i,n,a,o,ue,c);if(X.valid||J.push({instanceLocation:o,keyword:"$ref",keywordLocation:ue,error:"A subschema had errors."},...X.errors),r==="4"||r==="7")return{valid:J.length===0,errors:J}}if(Array.isArray(m)){let ae=m.length,te=!1;for(let ue=0;ue<ae;ue++)if(l===m[ue]||m[ue]==="integer"&&l==="number"&&e%1===0&&e===e){te=!0;break}te||J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&J.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(_!==void 0&&(l==="object"||l==="array"?Dn(e,_)||J.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(_)}.`}):e!==_&&J.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(_)}.`})),v!==void 0&&(l==="object"||l==="array"?v.some(ae=>Dn(e,ae))||J.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(ae=>e===ae)||J.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),w!==void 0){let ae=`${s}/not`;Ue(e,w,r,i,n,a,o,ae).valid&&J.push({instanceLocation:o,keyword:"not",keywordLocation:ae,error:'Instance matched "not" schema.'})}let fa=[];if(S!==void 0){let ae=`${s}/anyOf`,te=J.length,ue=!1;for(let X=0;X<S.length;X++){let G=S[X],se=Object.create(c),oe=Ue(e,G,r,i,n,p===!0?a:null,o,`${ae}/${X}`,se);J.push(...oe.errors),ue=ue||oe.valid,oe.valid&&fa.push(se)}ue?J.length=te:J.splice(te,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:ae,error:"Instance does not match any subschemas."})}if($!==void 0){let ae=`${s}/allOf`,te=J.length,ue=!0;for(let X=0;X<$.length;X++){let G=$[X],se=Object.create(c),oe=Ue(e,G,r,i,n,p===!0?a:null,o,`${ae}/${X}`,se);J.push(...oe.errors),ue=ue&&oe.valid,oe.valid&&fa.push(se)}ue?J.length=te:J.splice(te,0,{instanceLocation:o,keyword:"allOf",keywordLocation:ae,error:"Instance does not match every subschema."})}if(T!==void 0){let ae=`${s}/oneOf`,te=J.length,ue=T.filter((X,G)=>{let se=Object.create(c),oe=Ue(e,X,r,i,n,p===!0?a:null,o,`${ae}/${G}`,se);return J.push(...oe.errors),oe.valid&&fa.push(se),oe.valid}).length;ue===1?J.length=te:J.splice(te,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:ae,error:`Instance does not match exactly one subschema (${ue} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...fa),F!==void 0){let ae=`${s}/if`;if(Ue(e,F,r,i,n,a,o,ae,c).valid){if(A!==void 0){let ue=Ue(e,A,r,i,n,a,o,`${s}/then`,c);ue.valid||J.push({instanceLocation:o,keyword:"if",keywordLocation:ae,error:'Instance does not match "then" schema.'},...ue.errors)}}else if(y!==void 0){let ue=Ue(e,y,r,i,n,a,o,`${s}/else`,c);ue.valid||J.push({instanceLocation:o,keyword:"if",keywordLocation:ae,error:'Instance does not match "else" schema.'},...ue.errors)}}if(l==="object"){if(x!==void 0)for(let X of x)X in e||J.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${X}".`});let ae=Object.keys(e);if(Lt!==void 0&&ae.length<Lt&&J.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${Lt} properties.`}),_n!==void 0&&ae.length>_n&&J.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${_n} properties.`}),we!==void 0){let X=`${s}/propertyNames`;for(let G in e){let se=`${o}/${Sr(G)}`,oe=Ue(G,we,r,i,n,a,se,X);oe.valid||J.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:X,error:`Property name "${G}" does not match schema.`},...oe.errors)}}if(la!==void 0){let X=`${s}/dependantRequired`;for(let G in la)if(G in e){let se=la[G];for(let oe of se)oe in e||J.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:X,error:`Instance has "${G}" but does not have "${oe}".`})}}if(Jn!==void 0)for(let X in Jn){let G=`${s}/dependentSchemas`;if(X in e){let se=Ue(e,Jn[X],r,i,n,a,o,`${G}/${Sr(X)}`,c);se.valid||J.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:G,error:`Instance has "${X}" but does not match dependant schema.`},...se.errors)}}if(da!==void 0){let X=`${s}/dependencies`;for(let G in da)if(G in e){let se=da[G];if(Array.isArray(se))for(let oe of se)oe in e||J.push({instanceLocation:o,keyword:"dependencies",keywordLocation:X,error:`Instance has "${G}" but does not have "${oe}".`});else{let oe=Ue(e,se,r,i,n,a,o,`${X}/${Sr(G)}`);oe.valid||J.push({instanceLocation:o,keyword:"dependencies",keywordLocation:X,error:`Instance has "${G}" but does not match dependant schema.`},...oe.errors)}}}let te=Object.create(null),ue=!1;if(O!==void 0){let X=`${s}/properties`;for(let G in O){if(!(G in e))continue;let se=`${o}/${Sr(G)}`,oe=Ue(e[G],O[G],r,i,n,a,se,`${X}/${Sr(G)}`);if(oe.valid)c[G]=te[G]=!0;else if(ue=n,J.push({instanceLocation:o,keyword:"properties",keywordLocation:X,error:`Property "${G}" does not match schema.`},...oe.errors),ue)break}}if(!ue&&B!==void 0){let X=`${s}/patternProperties`;for(let G in B){let se=new RegExp(G,"u"),oe=B[G];for(let er in e){if(!se.test(er))continue;let J0=`${o}/${Sr(er)}`,K0=Ue(e[er],oe,r,i,n,a,J0,`${X}/${Sr(G)}`);K0.valid?c[er]=te[er]=!0:(ue=n,J.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:X,error:`Property "${er}" matches pattern "${G}" but does not match associated schema.`},...K0.errors))}}}if(!ue&&de!==void 0){let X=`${s}/additionalProperties`;for(let G in e){if(te[G])continue;let se=`${o}/${Sr(G)}`,oe=Ue(e[G],de,r,i,n,a,se,X);oe.valid?c[G]=!0:(ue=n,J.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:X,error:`Property "${G}" does not match additional properties schema.`},...oe.errors))}}else if(!ue&&Le!==void 0){let X=`${s}/unevaluatedProperties`;for(let G in e)if(!c[G]){let se=`${o}/${Sr(G)}`,oe=Ue(e[G],Le,r,i,n,a,se,X);oe.valid?c[G]=!0:J.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:X,error:`Property "${G}" does not match unevaluated properties schema.`},...oe.errors)}}}else if(l==="array"){C!==void 0&&e.length>C&&J.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${C}).`}),h!==void 0&&e.length<h&&J.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${h}).`});let ae=e.length,te=0,ue=!1;if(Zr!==void 0){let X=`${s}/prefixItems`,G=Math.min(Zr.length,ae);for(;te<G;te++){let se=Ue(e[te],Zr[te],r,i,n,a,`${o}/${te}`,`${X}/${te}`);if(c[te]=!0,!se.valid&&(ue=n,J.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:X,error:"Items did not match schema."},...se.errors),ue))break}}if(Kn!==void 0){let X=`${s}/items`;if(Array.isArray(Kn)){let G=Math.min(Kn.length,ae);for(;te<G;te++){let se=Ue(e[te],Kn[te],r,i,n,a,`${o}/${te}`,`${X}/${te}`);if(c[te]=!0,!se.valid&&(ue=n,J.push({instanceLocation:o,keyword:"items",keywordLocation:X,error:"Items did not match schema."},...se.errors),ue))break}}else for(;te<ae;te++){let G=Ue(e[te],Kn,r,i,n,a,`${o}/${te}`,X);if(c[te]=!0,!G.valid&&(ue=n,J.push({instanceLocation:o,keyword:"items",keywordLocation:X,error:"Items did not match schema."},...G.errors),ue))break}if(!ue&&uc!==void 0){let G=`${s}/additionalItems`;for(;te<ae;te++){let se=Ue(e[te],uc,r,i,n,a,`${o}/${te}`,G);c[te]=!0,se.valid||(ue=n,J.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:G,error:"Items did not match additional items schema."},...se.errors))}}}if(dc!==void 0)if(ae===0&&Vr===void 0)J.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Vr!==void 0&&ae<Vr)J.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${ae}) than minContains (${Vr}).`});else{let X=`${s}/contains`,G=J.length,se=0;for(let oe=0;oe<ae;oe++){let er=Ue(e[oe],dc,r,i,n,a,`${o}/${oe}`,X);er.valid?(c[oe]=!0,se++):J.push(...er.errors)}se>=(Vr||0)&&(J.length=G),Vr===void 0&&g===void 0&&se===0?J.splice(G,0,{instanceLocation:o,keyword:"contains",keywordLocation:X,error:"Array does not contain item matching schema."}):Vr!==void 0&&se<Vr?J.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Vr} items matching schema. Only ${se} items were found.`}):g!==void 0&&se>g&&J.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${g} items matching schema. ${se} items were found.`})}if(!ue&&lc!==void 0){let X=`${s}/unevaluatedItems`;for(te;te<ae;te++){if(c[te])continue;let G=Ue(e[te],lc,r,i,n,a,`${o}/${te}`,X);c[te]=!0,G.valid||J.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:X,error:"Items did not match unevaluated items schema."},...G.errors)}}if(k)for(let X=0;X<ae;X++){let G=e[X],se=typeof G=="object"&&G!==null;for(let oe=0;oe<ae;oe++){if(X===oe)continue;let er=e[oe];(G===er||se&&(typeof er=="object"&&er!==null)&&Dn(G,er))&&(J.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${X} and ${oe}.`}),X=Number.MAX_SAFE_INTEGER,oe=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(xe!==void 0&&(dt===!0&&e<=xe||e<xe)&&J.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${dt?"or equal to ":""} ${xe}.`}),Oe!==void 0&&(nt===!0&&e>=Oe||e>Oe)&&J.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${nt?"or equal to ":""} ${Oe}.`})):(xe!==void 0&&e<xe&&J.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${xe}.`}),Oe!==void 0&&e>Oe&&J.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Oe}.`}),dt!==void 0&&e<=dt&&J.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${dt}.`}),nt!==void 0&&e>=nt&&J.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${nt}.`})),Tt!==void 0){let ae=e%Tt;Math.abs(0-ae)>=11920929e-14&&Math.abs(Tt-ae)>=11920929e-14&&J.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Tt}.`})}}else if(l==="string"){let ae=Ir===void 0&&it===void 0?0:HA(e);Ir!==void 0&&ae<Ir&&J.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${ae} < ${Ir}).`}),it!==void 0&&ae>it&&J.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${ae} > ${it}).`}),yn!==void 0&&!new RegExp(yn,"u").test(e)&&J.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),W!==void 0&&Zb[W]&&!Zb[W](e)&&J.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${W}".`})}return{valid:J.length===0,errors:J}}var op=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=on(t)}validate(t){return Ue(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),on(t,this.lookup)}};var KA=E({Validator:()=>op,deepCompareStrict:()=>Dn,toJsonSchema:()=>ht,validatesOnlyStrings:()=>js}),JA=new WeakMap;function ht(e,t){let r=!t&&e!=null&&typeof e=="object";if(r){let n=JA.get(e);if(n)return n}let i;if(Fd(e)&&!De(e))i=e["~standard"].jsonSchema.input({target:"draft-07"});else if(De(e)){let n=Wf(e,!0);jr(n)?i=Ha(Ss(n,!0),t):i=Ha(e,t)}else tt(e)?i=BA(e):i=e;return r&&i!=null&&typeof i=="object"&&JA.set(e,i),i}function js(e){if(!e||typeof e!="object"||Object.keys(e).length===0||Array.isArray(e))return!1;if("type"in e)return typeof e.type=="string"?e.type==="string":Array.isArray(e.type)?e.type.every(t=>t==="string"):!1;if("enum"in e)return Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every(t=>typeof t=="string");if("const"in e)return typeof e.const=="string";if("allOf"in e&&Array.isArray(e.allOf))return e.allOf.some(t=>js(t));if("anyOf"in e&&Array.isArray(e.anyOf)||"oneOf"in e&&Array.isArray(e.oneOf)){let t="anyOf"in e?e.anyOf:e.oneOf;return t.length>0&&t.every(r=>js(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=on(e);return r[t]?js(r[t]):!1}return!1}function hu(e){return e?e.lc_runnable:!1}var WA=class{includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;constructor(e){this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let r=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,i=e.tags??[];return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(t)),this.includeTags!==void 0&&(r=r||i.some(n=>this.includeTags?.includes(n))),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(r=r&&i.every(n=>!this.excludeTags?.includes(n))),r}},qA=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function Vb(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var NL=["*","_","`"];function RL(e){let t="";for(let[r,i]of Object.entries(e))t+=` classDef ${r} ${i};
|
|
226
|
+
`;return t}function XA(e,t,r){let{firstNode:i,lastNode:n,nodeColors:a,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},u=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
|
|
227
|
+
graph TD;
|
|
228
|
+
`:`graph TD;
|
|
229
|
+
`;if(o){let m="default",_={[m]:"{0}({1})"};i!==void 0&&(_[i]="{0}([{1}]):::first"),n!==void 0&&(_[n]="{0}([{1}]):::last");for(let[v,x]of Object.entries(e)){let w=x.name.split(":").pop()??"",S=NL.some(T=>w.startsWith(T)&&w.endsWith(T))?`<p>${w}</p>`:w;Object.keys(x.metadata??{}).length&&(S+=`<hr/><small><em>${Object.entries(x.metadata??{}).map(([T,F])=>`${T} = ${F}`).join(`
|
|
230
|
+
`)}</em></small>`);let $=(_[v]??_[m]).replace("{0}",Vb(v)).replace("{1}",S);u+=` ${$}
|
|
231
|
+
`}}let l={};for(let m of t){let _=m.source.split(":"),v=m.target.split(":"),x=_.filter((w,S)=>w===v[S]).join(":");l[x]||(l[x]=[]),l[x].push(m)}let d=new Set;function f(m){return[...m].sort((_,v)=>_.split(":").length-v.split(":").length)}function p(m,_){let v=m.length===1&&m[0].source===m[0].target;if(_&&!v){let w=_.split(":").pop();if(d.has(_))throw new Error(`Found duplicate subgraph '${w}' at '${_} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(_),u+=` subgraph ${w}
|
|
232
|
+
`}let x=f(Object.keys(l).filter(w=>w.startsWith(`${_}:`)&&w!==_&&w.split(":").length===_.split(":").length+1));for(let w of x)p(l[w],w);for(let w of m){let{source:S,target:$,data:T,conditional:F}=w,A="";if(T!==void 0){let y=T,W=y.split(" ");W.length>c&&(y=Array.from({length:Math.ceil(W.length/c)},(O,B)=>W.slice(B*c,(B+1)*c).join(" ")).join(" <br> ")),A=F?` -. ${y} .-> `:` -- ${y} --> `}else A=F?" -.-> ":" --> ";u+=` ${Vb(S)}${A}${Vb($)};
|
|
233
|
+
`}_&&!v&&(u+=` end
|
|
234
|
+
`)}p(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&p(l[m],m);return o&&(u+=RL(a??{})),u}async function YA(e,t){let r=t?.backgroundColor??"white",i=t?.imageType??"png",n=qA(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let a=`https://mermaid.ink/img/${n}?bgColor=${r}&type=${i}`,o=await fetch(a);if(!o.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${o.status}`,`Status text: ${o.statusText}`].join(`
|
|
235
|
+
`));return await o.blob()}var tC=E({Graph:()=>fo});function jL(e,t){if(e!==void 0&&!Ei(e))return e;if(hu(t))try{let r=t.getName();return r=r.startsWith("Runnable")?r.slice(8):r,r}catch{return t.getName()}else return t.name??"UnknownSchema"}function ML(e){return hu(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...ht(e.data.schema),title:e.data.name}}}var fo=class rC{nodes={};edges=[];constructor(t){this.nodes=t?.nodes??this.nodes,this.edges=t?.edges??this.edges}toJSON(){let t={};return Object.values(this.nodes).forEach((r,i)=>{t[r.id]=Ei(r.id)?i:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...ML(r)})),edges:this.edges.map(r=>{let i={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(i.data=r.data),typeof r.conditional<"u"&&(i.conditional=r.conditional),i})}}addNode(t,r,i){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let n=r??Oh(),a={id:n,data:t,name:jL(r,t),metadata:i};return this.nodes[n]=a,a}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,i,n){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[r.id]===void 0)throw new Error(`Target node ${r.id} not in graph`);let a={source:t.id,target:r.id,data:i,conditional:n};return this.edges.push(a),a}firstNode(){return QA(this)}lastNode(){return eC(this)}extend(t,r=""){let i=r;Object.values(t.nodes).map(c=>c.id).every(Ei)&&(i="");let n=c=>i?`${i}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[n(c)]={...u,id:n(c)}});let a=t.edges.map(c=>({...c,source:n(c.source),target:n(c.target)}));this.edges=[...this.edges,...a];let o=t.firstNode(),s=t.lastNode();return[o?{id:n(o.id),data:o.data}:void 0,s?{id:n(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&QA(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&eC(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(n=>[n.id,n.name])),r=new Map;Object.values(t).forEach(n=>{r.set(n,(r.get(n)||0)+1)});let i=n=>{let a=t[n];return Ei(n)&&r.get(a)===1?a:n};return new rC({nodes:Object.fromEntries(Object.entries(this.nodes).map(([n,a])=>[i(n),{...a,id:i(n)}])),edges:this.edges.map(n=>({...n,source:i(n.source),target:i(n.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:i,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:a}=t??{},o=this.reid(),s=o.firstNode(),c=o.lastNode();return XA(o.nodes,o.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:i,nodeColors:n,wrapLabelNWords:a})}async drawMermaidPng(t){return YA(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function QA(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.source)).map(n=>n.target)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function eC(e,t=[]){let r=new Set(e.edges.filter(n=>!t.includes(n.target)).map(n=>n.source)),i=[];for(let n of Object.values(e.nodes))!t.includes(n.id)&&!r.has(n.id)&&i.push(n);return i.length===1?i[0]:void 0}function sp({name:e,serialized:t}){return e!==void 0?e:t?.name!==void 0?t.name:t?.id!==void 0&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}var nC=e=>e.name==="event_stream_tracer",iC=class extends It{autoClose=!0;includeNames;includeTypes;includeTags;excludeNames;excludeTypes;excludeTags;runInfoMap=new Map;tappedPromises=new Map;transformStream;writer;receiveStream;readableStreamClosed=!1;name="event_stream_tracer";lc_prefer_streaming=!0;constructor(e){super({_awaitHandler:!0,...e}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream({flush:()=>{this.readableStreamClosed=!0}}),this.writer=this.transformStream.writable.getWriter(),this.receiveStream=ut.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],r=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(r=r||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(r=r||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(r=r||t.find(i=>this.includeTags?.includes(i))!==void 0),this.excludeNames!==void 0&&(r=r&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(r=r&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(r=r&&t.every(i=>!this.excludeTags?.includes(i))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let i=this.runInfoMap.get(e);if(i===void 0){yield r.value;return}function n(o,s){return o==="llm"&&typeof s=="string"?new ri({text:s}):s}let a=this.tappedPromises.get(e);if(a===void 0){let o;a=new Promise(s=>{o=s}),this.tappedPromises.set(e,a);try{let s={event:`on_${i.runType}_stream`,run_id:e,name:i.name,tags:i.tags,metadata:i.metadata,data:{}};await this.send({...s,data:{chunk:n(i.runType,r.value)}},i),yield r.value;for await(let c of t)i.runType!=="tool"&&i.runType!=="retriever"&&await this.send({...s,data:{chunk:n(i.runType,c)}},i),yield c}finally{o?.()}}else{yield r.value;for await(let o of t)yield o}}async send(e,t){this.readableStreamClosed||this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){let r=this.tappedPromises.get(e.run_id);r!==void 0?r.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=sp(e),r=e.inputs.messages!==void 0?"chat_model":"llm",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,i);let n=`on_${r}_start`;await this.send({event:n,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onLLMNewToken(e,t,r){let i=this.runInfoMap.get(e.id),n,a;if(i===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(i.runType==="chat_model")a="on_chat_model_stream",r?.chunk===void 0?n=new mt({content:t,id:`run-${e.id}`}):n=r.chunk.message;else if(i.runType==="llm")a="on_llm_stream",r?.chunk===void 0?n=new ri({text:t}):n=r.chunk;else throw new Error(`Unexpected run type ${i.runType}`);await this.send({event:a,data:{chunk:n},run_id:e.id,name:i.name,tags:i.tags,metadata:i.metadata},i)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let r;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let i=e.outputs?.generations,n;if(t.runType==="chat_model"){for(let a of i??[]){if(n!==void 0)break;n=a[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")n={generations:i?.map(a=>a.map(o=>({text:o.text,generationInfo:o.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},r="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:r,data:{output:n,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=sp(e),r=e.run_type??"chain",i={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},n={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(n={},i.inputs={}):e.inputs.input!==void 0?(n.input=e.inputs.input,i.inputs=e.inputs.input):(n.input=e.inputs,i.inputs=e.inputs),this.runInfoMap.set(e.id,i),await this.send({event:`on_${r}_start`,data:n,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},i)}async onChainEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);let r=`on_${e.run_type}_end`,i=e.inputs??t.inputs??{},n={output:e.outputs?.output??e.outputs,input:i};i.input&&Object.keys(i).length===1&&(n.input=i.input,t.inputs=i.input),await this.sendEndEvent({event:r,data:n,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=sp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,r),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},r)}async onToolEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);let r=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:r,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onToolError(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(t.inputs===void 0)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);await this.sendEndEvent({event:"on_tool_error",data:{input:t.inputs,error:e.error},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){let t=sp(e),r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,r),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onRetrieverEnd(e){let t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),t===void 0)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,r){let i=this.runInfoMap.get(r);if(i===void 0)throw new Error(`handleCustomEvent: Run ID ${r} not found in run map.`);await this.send({event:"on_custom_event",run_id:r,name:e,tags:i.tags,metadata:i.metadata,data:t},i)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var Gb=class extends It{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:i}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=i}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}};function aC(e){let t=new TextEncoder,r=new ReadableStream({async start(i){for await(let n of e)i.enqueue(t.encode(`event: data
|
|
236
|
+
data: ${JSON.stringify(n)}
|
|
237
|
+
|
|
238
|
+
`));i.enqueue(t.encode(`event: end
|
|
239
|
+
|
|
240
|
+
`)),i.close()}});return ut.fromReadableStream(r)}function Hb(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var oC=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function cp(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function Jb(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function sC(e,t){try{let r=await e.next();for(;!r.done;)await t?.(r.value),r=await e.next();return r.value}finally{await e.return?.(void 0)}}function*Kb(e,t){for(;;){let{value:r,done:i}=$e.runWithConfig(ir(e),t.next.bind(t),!0);if(i)break;yield r}}async function*up(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:i,done:n}=await $e.runWithConfig(ir(e),r.next.bind(t),!0);if(n)break;yield i}}function lt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var re=class extends at{lc_runnable=!0;name;getName(e){let t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}withRetry(e){return new dp({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Ur({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new Wb({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(ye);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let r=Object.fromEntries(Object.entries(e).filter(([i])=>i!=="runId"));return Array.from({length:t},(i,n)=>ye(n===0?e:r))}return Array.from({length:t},()=>ye(e))}async batch(e,t,r){let i=this._getOptionsList(t??{},e.length),n=new ni({maxConcurrency:i[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:o=>{throw o}}),a=e.map((o,s)=>n.call(async()=>{try{return await this.invoke(o,i[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(a)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=ye(t),i=new Ri({generator:this._streamIterator(e,r),config:r});return await i.setup,ut.fromAsyncGenerator(i)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=ye(e):t=ye({callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});let r={...e};return delete r.callbacks,delete r.tags,delete r.metadata,delete r.runName,delete r.configurable,delete r.recursionLimit,delete r.maxConcurrency,delete r.runId,delete r.timeout,delete r.signal,[t,r]}async _callWithConfig(e,t,r){let i=ye(r),n=await(await yt(i))?.handleChainStart(this.toJSON(),lt(t,"input"),i.runId,i?.runType,void 0,void 0,i?.runName??this.getName());delete i.runId;let a;try{a=await yr(e.call(this,t,i,n),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(lt(a,"output")),a}async _batchWithConfig(e,t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(yt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),lt(t[u],"input"),n[u].runId,n[u].runType,void 0,void 0,n[u].runName??this.getName());return delete n[u].runId,l})),s;try{s=await yr(e.call(this,t,n,o,i),n?.[0]?.signal)}catch(c){throw await Promise.all(o.map(u=>u?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(lt(s,"output")))),s}_concatOutputChunks(e,t){return vr(e,t)}async*_transformStreamWithConfig(e,t,r){let i,n=!0,a,o=!0,s=ye(r),c=await yt(s),u=this;async function*l(){for await(let f of e){if(n)if(i===void 0)i=f;else try{i=u._concatOutputChunks(i,f)}catch{i=void 0,n=!1}yield f}}let d;try{let f=await Fg(t.bind(this),l(),async()=>c?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName(),void 0,{lc_defers_inputs:!0}),s.signal,s);delete s.runId,d=f.setup;let p=d?.handlers.find(nC),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let _=d?.handlers.find(Zg);_!==void 0&&d!==void 0&&(m=_.tapOutputIterable(d.runId,m));for await(let v of m)if(yield v,o)if(a===void 0)a=v;else try{a=this._concatOutputChunks(a,v)}catch{a=void 0,o=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:lt(i,"input")}),f}await d?.handleChainEnd(a??{},void 0,void 0,void 0,{inputs:lt(i,"input")})}getGraph(e){let t=new fo,r=t.addNode({name:`${this.getName()}Input`,schema:bt.any()}),i=t.addNode(this),n=t.addNode({name:`${this.getName()}Output`,schema:bt.any()});return t.addEdge(r,i),t.addEdge(i,n),t}pipe(e){return new kr({first:this,last:Xe(e)})}pick(e){return this.pipe(new qb(e))}assign(e){return this.pipe(new _u(new ea({steps:e})))}async*transform(e,t){let r;for await(let i of e)r===void 0?r=i:r=this._concatOutputChunks(r,i);yield*this._streamIterator(r,ye(t))}async*streamLog(e,t,r){let i=new Dd({...r,autoClose:!1,_schemaFormat:"original"}),n=ye(t);yield*this._streamLog(e,i,n)}async*_streamLog(e,t,r){let{callbacks:i}=r;if(i===void 0)r.callbacks=[t];else if(Array.isArray(i))r.callbacks=i.concat([t]);else{let s=i.copy();s.addHandler(t,!0),r.callbacks=s}let n=this.stream(e,r);async function a(){try{let s=await n;for await(let c of s){let u=new On({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let o=a();try{for await(let s of t)yield s}finally{await o}}streamEvents(e,t,r){let i;if(t.version==="v1")i=this._streamEventsV1(e,t,r);else if(t.version==="v2")i=this._streamEventsV2(e,t,r);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?aC(i):ut.fromAsyncGenerator(i)}async*_streamEventsV2(e,t,r){let i=new iC({...r,autoClose:!1}),n=ye(t),a=n.runId??Or();n.runId=a;let o=n.callbacks;if(o===void 0)n.callbacks=[i];else if(Array.isArray(o))n.callbacks=o.concat(i);else{let p=o.copy();p.addHandler(i,!0),n.callbacks=p}let s=new AbortController,c=this;async function u(){let p;try{if(n.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,n.signal]);else{let v=new AbortController;n.signal.addEventListener("abort",()=>v.abort(),{once:!0}),s.signal.addEventListener("abort",()=>v.abort(),{once:!0}),p=v.signal}else p=s.signal;let m=await c.stream(e,{...n,signal:p}),_=i.tapOutputIterable(a,m);for await(let v of _)if(s.signal.aborted)break}finally{await i.finish()}}let l=u(),d=!1,f;try{for await(let p of i){if(!d){p.data.input=e,d=!0,f=p.run_id,yield p;continue}p.run_id===f&&p.event.endsWith("_end")&&p.data?.input&&delete p.data.input,yield p}}finally{s.abort(),await l}}async*_streamEventsV1(e,t,r){let i,n=!1,a=ye(t),o=a.tags??[],s=a.metadata??{},c=a.runName??this.getName(),u=new Dd({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new WA({...r}),d=this._streamLog(e,u,a);for await(let p of d){if(i?i=i.concat(p):i=zd.fromRunLogPatch(p),i.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!n){n=!0;let x={...i.state},w={run_id:x.id,event:`on_${x.type}_start`,name:c,tags:o,metadata:s,data:{input:e}};l.includeEvent(w,x.type)&&(yield w)}let m=p.ops.filter(x=>x.path.startsWith("/logs/")).map(x=>x.path.split("/")[2]),_=[...new Set(m)];for(let x of _){let w,S={},$=i.state.logs[x];if($.end_time===void 0?$.streamed_output.length>0?w="stream":w="start":w="end",w==="start")$.inputs!==void 0&&(S.input=$.inputs);else if(w==="end")$.inputs!==void 0&&(S.input=$.inputs),S.output=$.final_output;else if(w==="stream"){let T=$.streamed_output.length;if(T!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${T} instead. Encountered in: "${$.name}"`);S={chunk:$.streamed_output[0]},$.streamed_output=[]}yield{event:`on_${$.type}_${w}`,name:$.name,run_id:$.id,tags:$.tags,metadata:$.metadata,data:S}}let{state:v}=i;if(v.streamed_output.length>0){let x=v.streamed_output.length;if(x!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${x} instead. Encountered in: "${v.name}"`);let w={chunk:v.streamed_output[0]};v.streamed_output=[];let S={event:`on_${v.type}_stream`,run_id:v.id,tags:o,metadata:s,name:c,data:w};l.includeEvent(S,v.type)&&(yield S)}}let f=i?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:o,metadata:s,data:{output:f.final_output}};l.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return hu(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Ur({bound:this,config:{},configFactories:[i=>({callbacks:[new Gb({config:i,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return UL(this,e)}},Ur=class cC extends re{static lc_name(){return"RunnableBinding"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;bound;config;kwargs;configFactories;constructor(t){super(t),this.bound=t.bound,this.kwargs=t.kwargs,this.config=t.config,this.configFactories=t.configFactories}getName(t){return this.bound.getName(t)}async _mergeConfig(...t){let r=vt(this.config,...t);return vt(r,...this.configFactories?await Promise.all(this.configFactories.map(async i=>await i(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new dp({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,r){return this.bound.invoke(t,await this._mergeConfig(r,this.kwargs))}async batch(t,r,i){let n=Array.isArray(r)?await Promise.all(r.map(async a=>this._mergeConfig(ye(a),this.kwargs))):await this._mergeConfig(ye(r),this.kwargs);return this.bound.batch(t,n,i)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(ye(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(ye(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(ye(r),this.kwargs))}streamEvents(t,r,i){let n=this,a=async function*(){yield*n.bound.streamEvents(t,{...await n._mergeConfig(ye(r),n.kwargs),version:r.version},i)};return ut.fromAsyncGenerator(a())}static isRunnableBinding(t){return t.bound&&re.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:i}){return new cC({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new Gb({config:n,onStart:t,onEnd:r,onError:i})]})]})}},uC=class lC extends re{static lc_name(){return"RunnableEach"}lc_serializable=!0;lc_namespace=["langchain_core","runnables"];bound;constructor(t){super(t),this.bound=t.bound}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async _invoke(t,r,i){return this.bound.batch(t,Se(r,{callbacks:i?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:i}){return new lC({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:i})})}},dp=class extends Ur{static lc_name(){return"RunnableRetry"}lc_namespace=["langchain_core","runnables"];maxAttemptNumber=3;onFailedAttempt=()=>{};constructor(e){super(e),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,r){let i=e>1?`retry:attempt:${e}`:void 0;return Se(t,{callbacks:r?.getChild(i)})}async _invoke(e,t,r){return Uc(i=>super.invoke(e,this._patchConfigForRetry(i,t,r)),{onFailedAttempt:({error:i})=>this.onFailedAttempt(i,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,r,i){let n={};try{await Uc(async a=>{let o=e.map((d,f)=>f).filter(d=>n[d.toString()]===void 0||n[d.toString()]instanceof Error),s=o.map(d=>e[d]),c=o.map(d=>this._patchConfigForRetry(a,t?.[d],r?.[d])),u=await super.batch(s,c,{...i,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let f=u[d],p=o[d];f instanceof Error&&l===void 0&&(l=f,l.input=s[d]),n[p.toString()]=f}if(l)throw l;return u},{onFailedAttempt:({error:a})=>this.onFailedAttempt(a,a.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(a){if(i?.returnExceptions!==!0)throw a}return Object.keys(n).sort((a,o)=>parseInt(a,10)-parseInt(o,10)).map(a=>n[parseInt(a,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},kr=class gu extends re{static lc_name(){return"RunnableSequence"}first;middle=[];last;omitSequenceTags=!1;lc_serializable=!0;lc_namespace=["langchain_core","runnables"];constructor(t){super(t),this.first=t.first,this.middle=t.middle??this.middle,this.last=t.last,this.name=t.name,this.omitSequenceTags=t.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(t,r){let i=ye(r),n=await(await yt(i))?.handleChainStart(this.toJSON(),lt(t,"input"),i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a=t,o;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)a=await yr(s[c].invoke(a,Se(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),i.signal);if(i.signal?.aborted)throw Ni(i.signal);o=await this.last.invoke(a,Se(i,{callbacks:n?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await n?.handleChainError(s),s}return await n?.handleChainEnd(lt(o,"output")),o}async batch(t,r,i){let n=this._getOptionsList(r??{},t.length),a=await Promise.all(n.map(yt)),o=await Promise.all(a.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),lt(t[u],"input"),n[u].runId,void 0,void 0,void 0,n[u].runName);return delete n[u].runId,l})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await yr(this.steps[c].batch(s,o.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Se(n[l],{callbacks:d})}),i),n[0]?.signal)}catch(c){throw await Promise.all(o.map(u=>u?.handleChainError(c))),c}return await Promise.all(o.map(c=>c?.handleChainEnd(lt(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let i=await yt(r),{runId:n,...a}=r??{},o=await i?.handleChainStart(this.toJSON(),lt(t,"input"),n,void 0,void 0,void 0,a?.runName),s=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=s[0].transform(l(),Se(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Se(a,{callbacks:o?.getChild(this.omitSequenceTags?void 0:`seq:step:${f+1}`)}));for await(let f of d)if(r?.signal?.throwIfAborted(),yield f,c)if(u===void 0)u=f;else try{u=this._concatOutputChunks(u,f)}catch{u=void 0,c=!1}}catch(d){throw await o?.handleChainError(d),d}await o?.handleChainEnd(lt(u,"output"))}getGraph(t){let r=new fo,i=null;return this.steps.forEach((n,a)=>{let o=n.getGraph(t);a!==0&&o.trimFirstNode(),a!==this.steps.length-1&&o.trimLastNode(),r.extend(o);let s=o.firstNode();if(!s)throw new Error(`Runnable ${n} has no first node`);i&&r.addEdge(i,s),i=o.lastNode()}),r}pipe(t){return gu.isRunnableSequence(t)?new gu({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new gu({first:this.first,middle:[...this.middle,this.last],last:Xe(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&re.isRunnable(t)}static from([t,...r],i){let n={};return typeof i=="string"?n.name=i:i!==void 0&&(n=i),new gu({...n,first:Xe(t),middle:r.slice(0,-1).map(Xe),last:Xe(r[r.length-1])})}},ea=class dC extends re{static lc_name(){return"RunnableMap"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;steps;getStepsKeys(){return Object.keys(this.steps)}constructor(t){super(t),this.steps={};for(let[r,i]of Object.entries(t.steps))this.steps[r]=Xe(i)}static from(t){return new dC({steps:t})}async invoke(t,r){let i=ye(r),n=await(await yt(i))?.handleChainStart(this.toJSON(),{input:t},i.runId,void 0,void 0,void 0,i?.runName);delete i.runId;let a={};try{let o=Object.entries(this.steps).map(async([s,c])=>{a[s]=await c.invoke(t,Se(i,{callbacks:n?.getChild(`map:key:${s}`)}))});await yr(Promise.all(o),i.signal)}catch(o){throw await n?.handleChainError(o),o}return await n?.handleChainEnd(a),a}async*_transform(t,r,i){let n={...this.steps},a=Cd(t,Object.keys(n).length),o=new Map(Object.entries(n).map(([s,c],u)=>{let l=c.transform(a[u],Se(i,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,l.next().then(d=>({key:s,gen:l,result:d}))]}));for(;o.size;){let{key:s,result:c,gen:u}=await yr(Promise.race(o.values()),i?.signal);o.delete(s),c.done||(yield{[s]:c.value},o.set(s,u.next().then(l=>({key:s,gen:u,result:l}))))}}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=ye(r),a=new Ri({generator:this.transform(i(),n),config:n});return await a.setup,ut.fromAsyncGenerator(a)}},zL=class fC extends re{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!Ed(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,r){let[i]=this._getOptionsList(r??{},1),n=await yt(i);return yr(this.func(Se(i,{callbacks:n}),t),i?.signal)}async*_streamIterator(t,r){let[i]=this._getOptionsList(r??{},1),n=await this.invoke(t,r);if(cp(n)){for await(let a of n)i?.signal?.throwIfAborted(),yield a;return}if(oC(n)){for(;;){i?.signal?.throwIfAborted();let a=n.next();if(a.done)break;yield a.value}return}yield n}static from(t){return new fC({func:t})}};function DL(e){if(Ed(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var Rt=class pC extends re{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(Ed(t.func))return zL.from(t.func);super(t),DL(t.func),this.func=t.func}static from(t){return new pC({func:t})}async _invoke(t,r,i){return new Promise((n,a)=>{let o=Se(r,{callbacks:i?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});$e.runWithConfig(ir(o),async()=>{try{let s=await this.func(t,{...o});if(s&&re.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...o,recursionLimit:(o.recursionLimit??25)-1})}else if(cp(s)){let c;for await(let u of up(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}else if(Hb(s)){let c;for(let u of Kb(o,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}n(s)}catch(s){a(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,i){let n;for await(let s of t)if(n===void 0)n=s;else try{n=this._concatOutputChunks(n,s)}catch{n=s}let a=Se(i,{callbacks:r?.getChild(),recursionLimit:(i?.recursionLimit??25)-1}),o=await new Promise((s,c)=>{$e.runWithConfig(ir(a),async()=>{try{s(await this.func(n,{...a,config:a}))}catch(u){c(u)}})});if(o&&re.isRunnable(o)){if(i?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await o.stream(n,a);for await(let c of s)yield c}else if(cp(o))for await(let s of up(a,o))i?.signal?.throwIfAborted(),yield s;else if(Hb(o))for(let s of Kb(a,o))i?.signal?.throwIfAborted(),yield s;else yield o}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*i(){yield t}let n=ye(r),a=new Ri({generator:this.transform(i(),n),config:n});return await a.setup,ut.fromAsyncGenerator(a)}},mC=class extends ea{},Wb=class extends re{static lc_name(){return"RunnableWithFallbacks"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnable;fallbacks;constructor(e){super(e),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(let e of this.fallbacks)yield e}async invoke(e,t){let r=ye(t),i=await yt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),lt(e,"input"),n,void 0,void 0,void 0,a?.runName),s=Se(a,{callbacks:o?.getChild()});return await $e.runWithConfig(s,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,s);return await o?.handleChainEnd(lt(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await o?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=ye(t),i=await yt(r),{runId:n,...a}=r,o=await i?.handleChainStart(this.toJSON(),lt(e,"input"),n,void 0,void 0,void 0,a?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=Se(a,{callbacks:o?.getChild()});try{c=up(d,await l.stream(e,d));break}catch(f){s===void 0&&(s=f)}}if(c===void 0){let l=s??new Error("No error stored at end of fallback.");throw await o?.handleChainError(l),l}let u;try{for await(let l of c){yield l;try{u=u===void 0?u:this._concatOutputChunks(u,l)}catch{u=void 0}}}catch(l){throw await o?.handleChainError(l),l}await o?.handleChainEnd(lt(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let i=this._getOptionsList(t??{},e.length),n=await Promise.all(i.map(s=>yt(s))),a=await Promise.all(n.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),lt(e[c],"input"),i[c].runId,void 0,void 0,void 0,i[c].runName);return delete i[c].runId,u})),o;for(let s of this.runnables()){i[0].signal?.throwIfAborted();try{let c=await s.batch(e,a.map((u,l)=>Se(i[l],{callbacks:u?.getChild()})),r);return await Promise.all(a.map((u,l)=>u?.handleChainEnd(lt(c[l],"output")))),c}catch(c){o===void 0&&(o=c)}}throw o?(await Promise.all(a.map(s=>s?.handleChainError(o))),o):new Error("No error stored at end of fallbacks.")}};function Xe(e){if(typeof e=="function")return new Rt({func:e});if(re.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,i]of Object.entries(e))t[r]=Xe(i);return new ea({steps:t})}else throw new Error(`Expected a Runnable, function or object.
|
|
241
|
+
Instead got an unsupported type.`)}var _u=class extends re{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof ea&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let r=await this.mapper.invoke(e,t);return{...e,...r}}async*_transform(e,t,r){let i=this.mapper.getStepsKeys(),[n,a]=Cd(e),o=this.mapper.transform(a,Se(r,{callbacks:t?.getChild()})),s=o.next();for await(let c of n){if(typeof c!="object"||Array.isArray(c))throw new Error(`RunnableAssign can only be used with objects as input, got ${typeof c}`);let u=Object.fromEntries(Object.entries(c).filter(([l])=>!i.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await s).value;for await(let c of o)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=ye(t),n=new Ri({generator:this.transform(r(),i),config:i});return await n.setup,ut.fromAsyncGenerator(n)}},qb=class extends re{static lc_name(){return"RunnablePick"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;keys;constructor(e){(typeof e=="string"||Array.isArray(e))&&(e={keys:e}),super(e),this.keys=e.keys}async _pick(e){if(typeof this.keys=="string")return e[this.keys];{let t=this.keys.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0);return t.length===0?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(let t of e){let r=await this._pick(t);r!==void 0&&(yield r)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let i=ye(t),n=new Ri({generator:this.transform(r(),i),config:i});return await n.setup,ut.fromAsyncGenerator(n)}},lp=class extends Ur{name;description;schema;constructor(e){let t=kr.from([Rt.from(async r=>{let i;if(Ii(r))try{i=await Wi(this.schema,r.args)}catch{throw new Do("Received tool input did not match expected schema",JSON.stringify(r.args))}else i=r;return i}).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name});super({bound:t,config:e.config??{}}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}};function UL(e,t){let r=t.name??e.getName(),i=t.description??si(t.schema);return $s(t.schema)?new lp({name:r,description:i,schema:bt.object({input:bt.string()}).transform(n=>n.input),bound:e}):new lp({name:r,description:i,schema:t.schema,bound:e})}var fp=(e,t)=>{let r=[...new Set(t?.map(n=>{if(typeof n=="string")return n;let a=new n({});if(!("getType"in a)||typeof a.getType!="function")throw new Error("Invalid type provided.");return a.getType()}))],i=e.getType();return r.some(n=>n===i)};function vC(e,t){return Array.isArray(e)?hC(e,t):Rt.from(r=>hC(r,e))}function hC(e,t={}){let{includeNames:r,excludeNames:i,includeTypes:n,excludeTypes:a,includeIds:o,excludeIds:s}=t,c=[];for(let u of e)if(!(i&&u.name&&i.includes(u.name))){{if(a&&fp(u,a))continue;if(s&&u.id&&s.includes(u.id))continue}n||o||r?(r&&u.name&&r.some(l=>l===u.name)||n&&fp(u,n)||o&&u.id&&o.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function bC(e){return Array.isArray(e)?gC(e):Rt.from(gC)}function gC(e){if(!e.length)return[];let t=[];for(let r of e){let i=r,n=t.pop();if(!n)t.push(i);else if(i.getType()==="tool"||i.getType()!==n.getType())t.push(n,i);else{let a=$a(n),o=$a(i),s=a.concat(o);typeof a.content=="string"&&typeof o.content=="string"&&(s.content=`${a.content}
|
|
242
|
+
${o.content}`),t.push(FL(s))}}return t}function wC(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return _C(r,t)}else{let r=e;return Rt.from(i=>_C(i,r)).withConfig({runName:"trim_messages"})}}async function _C(e,t){let{maxTokens:r,tokenCounter:i,strategy:n="last",allowPartial:a=!1,endOn:o,startOn:s,includeSystem:c=!1,textSplitter:u}=t;if(s&&n==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&n==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in i?l=async f=>(await Promise.all(f.map(p=>i.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):l=async f=>i(f);let d=Yb;if(u&&("splitText"in u?d=u.splitText:d=async f=>u(f)),n==="first")return xC(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:a?"first":void 0,endOn:o});if(n==="last")return LL(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:a,includeSystem:c,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${n}'. Must be one of 'first' or 'last'.`)}async function xC(e,t){let{maxTokens:r,tokenCounter:i,textSplitter:n,partialStrategy:a,endOn:o}=t,s=[...e],c=0;for(let u=0;u<s.length;u+=1)if(await i(u>0?s.slice(0,-u):s)<=r){c=s.length-u;break}if(c<s.length&&a){let u=!1;if(Array.isArray(s[c].content)){let l=s[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,f=a==="last"?[...l.content].reverse():l.content;for(let p=1;p<=d;p+=1){let m=a==="first"?f.slice(0,p):f.slice(-p),_=Object.fromEntries(Object.entries(l).filter(([w])=>w!=="type"&&!w.startsWith("lc_"))),v=Xb(l.getType(),{..._,content:m}),x=[...s.slice(0,c),v];if(await i(x)<=r)s=x,c+=1,u=!0;else break}u&&a==="last"&&(l.content=[...f].reverse())}if(!u){let l=s[c],d;if(Array.isArray(l.content)&&l.content.some(f=>typeof f=="string"||f.type==="text")?d=l.content.find(f=>f.type==="text"&&f.text)?.text:typeof l.content=="string"&&(d=l.content),d){let f=await n(d),p=f.length;a==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),l.content=f.join(""),await i([...s.slice(0,c),l])<=r){a==="last"&&(l.content=[...f].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(o){let u=Array.isArray(o)?o:[o];for(;c>0&&!fp(s[c-1],u);)c-=1}return s.slice(0,c)}async function LL(e,t){let{allowPartial:r=!1,includeSystem:i=!1,endOn:n,startOn:a,...o}=t,s=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return Xb(l.getType(),d,Qn(l))});if(n){let l=Array.isArray(n)?n:[n];for(;s.length>0&&!fp(s[s.length-1],l);)s=s.slice(0,-1)}let c=i&&s[0]?.getType()==="system",u=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return u=await xC(u,{...o,partialStrategy:r?"last":void 0,endOn:a}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var yC={human:{message:Ye,messageChunk:ka},ai:{message:Ee,messageChunk:mt},system:{message:Vt,messageChunk:ei},developer:{message:Vt,messageChunk:ei},tool:{message:Zt,messageChunk:zo},function:{message:xa,messageChunk:Sa},generic:{message:qr,messageChunk:wa},remove:{message:Xr,messageChunk:Xr}};function Xb(e,t,r){let i,n;switch(e){case"human":r?i=new ka(t):n=new Ye(t);break;case"ai":if(r){let a={...t};"tool_calls"in a&&(a={...a,tool_call_chunks:a.tool_calls?.map(o=>({...o,type:"tool_call_chunk",index:void 0,args:JSON.stringify(o.args)}))}),i=new mt(a)}else n=new Ee(t);break;case"system":r?i=new ei(t):n=new Vt(t);break;case"developer":r?i=new ei({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):n=new Vt({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?i=new zo(t):n=new Zt(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)i=new Sa(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new xa(t)}break;case"generic":if("role"in t)r?i=new wa(t):n=new qr(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(r&&i)return i;if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function FL(e){let t=e.getType(),r,i=Object.fromEntries(Object.entries(e).filter(([n])=>!["type","tool_call_chunks"].includes(n)&&!n.startsWith("lc_")));if(t in yC&&(r=Xb(t,i)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(yC)}`);return r}function Yb(e){let t=e.split(`
|
|
243
|
+
`);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
|
|
244
|
+
`),t[t.length-1]])}var SC=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var kC=["image","video","audio","text-plain","file"];var $C=["text","reasoning",...SC,...kC];var IC=E({AIMessage:()=>Ee,AIMessageChunk:()=>mt,BaseMessage:()=>Me,BaseMessageChunk:()=>Bt,ChatMessage:()=>qr,ChatMessageChunk:()=>wa,DEFAULT_MERGE_IGNORE_KEYS:()=>wh,FunctionMessage:()=>xa,FunctionMessageChunk:()=>Sa,HumanMessage:()=>Ye,HumanMessageChunk:()=>ka,KNOWN_BLOCK_TYPES:()=>$C,RemoveMessage:()=>Xr,SystemMessage:()=>Vt,SystemMessageChunk:()=>ei,ToolMessage:()=>Zt,ToolMessageChunk:()=>zo,_isMessageFieldWithRole:()=>Bl,_mergeDicts:()=>He,_mergeLists:()=>$i,_mergeObj:()=>Fl,_mergeStatus:()=>Ll,coerceMessageLikeToMessage:()=>St,collapseToolCallChunks:()=>Vl,convertToChunk:()=>$a,convertToOpenAIImageBlock:()=>Ml,convertToProviderContentBlock:()=>FS,defaultTextSplitter:()=>Yb,defaultToolCallParser:()=>Sc,filterMessages:()=>vC,getBufferString:()=>Fo,iife:()=>Ok,isAIMessage:()=>Lo,isAIMessageChunk:()=>$c,isBase64ContentBlock:()=>Mo,isBaseMessage:()=>Je,isBaseMessageChunk:()=>Qn,isChatMessage:()=>Sk,isChatMessageChunk:()=>kk,isDataContentBlock:()=>kn,isDirectToolOutput:()=>xc,isFunctionMessage:()=>$k,isFunctionMessageChunk:()=>Ik,isHumanMessage:()=>Ek,isHumanMessageChunk:()=>Tk,isIDContentBlock:()=>jl,isMessage:()=>Ul,isOpenAIToolCallArray:()=>tk,isPlainTextContentBlock:()=>US,isSystemMessage:()=>Ak,isSystemMessageChunk:()=>Ck,isToolMessage:()=>kc,isToolMessageChunk:()=>xh,isURLContentBlock:()=>jo,mapChatMessagesToStoredMessages:()=>Nk,mapStoredMessageToChatMessage:()=>Ic,mapStoredMessagesToChatMessages:()=>Pk,mergeContent:()=>At,mergeMessageRuns:()=>bC,mergeResponseMetadata:()=>Zl,mergeUsageMetadata:()=>Uo,parseBase64DataUrl:()=>wc,parseMimeType:()=>LS,trimMessages:()=>wC});var EC=E({BaseChatMessageHistory:()=>Qb,BaseListChatMessageHistory:()=>pp,InMemoryChatMessageHistory:()=>BL}),Qb=class extends at{async addMessages(e){for(let t of e)await this.addMessage(t)}},pp=class extends at{addUserMessage(e){return this.addMessage(new Ye(e))}addAIMessage(e){return this.addMessage(new Ee(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},BL=class extends pp{lc_namespace=["langchain","stores","message","in_memory"];messages=[];constructor(e){super(...arguments),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}};var $r=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var ew=class extends re{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},TC=class extends ew{async transformDocuments(e){let t=[];for(let r of e){let i=await this._transformDocument(r);t.push(i)}return t}};var AC=E({BaseDocumentTransformer:()=>ew,Document:()=>$r,MappingDocumentTransformer:()=>TC});var CC=E({BaseDocumentLoader:()=>tw}),tw=class{};var OC=E({LangSmithLoader:()=>ZL}),ZL=class extends tw{datasetId;datasetName;exampleIds;asOf;splits;inlineS3Urls;offset;limit;metadata;filter;contentKey;formatContent;client;constructor(e){if(super(),e.client&&e.clientConfig)throw new Error("client and clientConfig cannot both be provided.");this.client=e.client??new Tn(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??VL,this.datasetId=e.datasetId,this.datasetName=e.datasetName,this.exampleIds=e.exampleIds,this.asOf=e.asOf,this.splits=e.splits,this.inlineS3Urls=e.inlineS3Urls,this.offset=e.offset,this.limit=e.limit,this.metadata=e.metadata,this.filter=e.filter}async load(){let e=[];for await(let t of this.client.listExamples({datasetId:this.datasetId,datasetName:this.datasetName,exampleIds:this.exampleIds,asOf:this.asOf,splits:this.splits,inlineS3Urls:this.inlineS3Urls,offset:this.offset,limit:this.limit,metadata:this.metadata,filter:this.filter})){let r=t.inputs;for(let a of this.contentKey)r=r[a];let i=this.formatContent(r),n=t;["created_at","modified_at"].forEach(a=>{a in n&&typeof n[a]=="object"&&(n[a]=n[a].toString())}),e.push({pageContent:i,metadata:n})}return e}};function VL(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var PC=E({Embeddings:()=>mp}),mp=class{caller;constructor(e){this.caller=new ni(e??{})}};var Ms=class extends at{lc_namespace=["langchain_core","example_selectors","base"]};var rw=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},NC=class extends rw{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,r]of this.conditionals)if(t(e))return r;return this.defaultPrompt}};function RC(e){return e._modelType()==="base_llm"}function jC(e){return e._modelType()==="base_chat_model"}function MC(e){return e.split(/\n| /).length}var zC=class DC extends Ms{examples=[];examplePrompt;getTextLength=MC;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??MC}async addExample(t){this.examples.push(t);let r=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(r))}async calculateExampleTextLengths(t,r){if(t.length>0)return t;let{examples:i,examplePrompt:n}=r;return(await Promise.all(i.map(a=>n.format(a)))).map(a=>this.getTextLength(a))}async selectExamples(t){let r=Object.values(t).join(" "),i=this.maxLength-this.getTextLength(r),n=0,a=[];for(;i>0&&n<this.examples.length;){let o=i-this.exampleTextLengths[n];if(o<0)break;a.push(this.examples[n]),i=o,n+=1}return a}static async fromExamples(t,r){let i=new DC(r);return await Promise.all(t.map(n=>i.addExample(n))),i}};function nw(e){return Object.keys(e).sort().map(t=>e[t])}var UC=class LC extends Ms{vectorStoreRetriever;exampleKeys;inputKeys;constructor(t){if(super(t),this.exampleKeys=t.exampleKeys,this.inputKeys=t.inputKeys,t.vectorStore!==void 0)this.vectorStoreRetriever=t.vectorStore.asRetriever({k:t.k??4,filter:t.filter});else if(t.vectorStoreRetriever)this.vectorStoreRetriever=t.vectorStoreRetriever;else throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".')}async addExample(t){let r=nw((this.inputKeys??Object.keys(t)).reduce((i,n)=>({...i,[n]:t[n]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new $r({pageContent:r,metadata:t})])}async selectExamples(t){let r=nw((this.inputKeys??Object.keys(t)).reduce((n,a)=>({...n,[a]:t[a]}),{})).join(" "),i=(await this.vectorStoreRetriever.invoke(r)).map(n=>n.metadata);return this.exampleKeys?i.map(n=>this.exampleKeys.reduce((a,o)=>({...a,[o]:n[o]}),{})):i}static async fromExamples(t,r,i,n={}){let a=n.inputKeys??null,o=t.map(s=>nw(a?a.reduce((c,u)=>({...c,[u]:s[u]}),{}):s).join(" "));return new LC({vectorStore:await i.fromTexts(o,t,r,n),k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}};var FC=E({BaseExampleSelector:()=>Ms,BasePromptSelector:()=>rw,ConditionalPromptSelector:()=>NC,LengthBasedExampleSelector:()=>zC,SemanticSimilarityExampleSelector:()=>UC,isChatModel:()=>jC,isLLM:()=>RC});var yu="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",BC=class extends at{lc_namespace=["langchain","recordmanagers"]};var iw=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Ro;constructor(e){this.uid=e.uid,this.pageContent=e.pageContent,this.metadata=e.metadata}makeDefaultKeyEncoder(e){this.keyEncoder=e}calculateHashes(){let e=["hash_","content_hash","metadata_hash"];for(let r of e)if(r in this.metadata)throw new Error(`Metadata cannot contain key ${r} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let r=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=r}catch(r){throw new Error(`Failed to hash metadata: ${r}. Please use a dict that can be serialized using json.`)}this.hash_=this._hashStringToUUID(this.contentHash+this.metadataHash),this.uid||(this.uid=this.hash_)}toDocument(){return new $r({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let r=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return r.calculateHashes(),r}_hashStringToUUID(e){return Hl(this.keyEncoder(e),yu)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return Hl(this.keyEncoder(t),yu)}};function aw(e,t){let r=[],i=[];return t.forEach(n=>{i.push(n),i.length>=e&&(r.push(i),i=[])}),i.length>0&&r.push(i),r}function ow(e){let t=new Set,r=[];for(let i of e){if(!i.hash_)throw new Error("Hashed document does not have a hash");t.has(i.hash_)||(t.add(i.hash_),r.push(i))}return r}function sw(e){if(e===null)return t=>null;if(typeof e=="string")return t=>t.metadata[e];if(typeof e=="function")return e;throw new Error(`sourceIdKey should be null, a string or a function, got ${typeof e}`)}var cw=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function ZC(e){let{docsSource:t,recordManager:r,vectorStore:i,options:n}=e,{batchSize:a=100,cleanup:o,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=n??{};if(o==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=cw(t)?await t.load():t,d=sw(s??null),f=await r.getTime(),p=0,m=0,_=0,v=0,x=aw(a??100,l);for(let w of x){let S=ow(w.map(O=>iw.fromDocument(O))),$=S.map(O=>d(O));o==="incremental"&&S.forEach((O,B)=>{if($[B]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let T=await r.exists(S.map(O=>O.uid)),F=[],A=[],y=[],W=new Set;if(S.forEach((O,B)=>{if(T[B])if(u)W.add(O.uid);else{y.push(O.uid);return}F.push(O.uid),A.push(O.toDocument())}),y.length>0&&(await r.update(y,{timeAtLeast:f}),v+=y.length),A.length>0&&(await i.addDocuments(A,{ids:F}),p+=A.length-W.size,_+=W.size),await r.update(S.map(O=>O.uid),{timeAtLeast:f,groupIds:$}),o==="incremental"){$.forEach(B=>{if(!B)throw new Error("Source id cannot be null")});let O=await r.listKeys({before:f,groupIds:$});O.length>0&&(await i.delete({ids:O}),await r.deleteKeys(O),m+=O.length)}}if(o==="full"){let w=await r.listKeys({before:f,limit:c});for(;w.length>0;)await i.delete({ids:w}),await r.deleteKeys(w),m+=w.length,w=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:_,numSkipped:v}}var VC=E({RecordManager:()=>BC,UUIDV5_NAMESPACE:()=>yu,_HashedDocument:()=>iw,_batch:()=>aw,_deduplicateInOrder:()=>ow,_getSourceIdAssigner:()=>sw,_isBaseDocumentLoader:()=>cw,index:()=>ZC});var GC=E({BasePromptValue:()=>hp,ChatPromptValue:()=>bu,ImagePromptValue:()=>uw,StringPromptValue:()=>vu}),hp=class extends at{},vu=class extends hp{static lc_name(){return"StringPromptValue"}lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;value;constructor(e){super({value:e}),this.value=e}toString(){return this.value}toChatMessages(){return[new Ye(this.value)]}},bu=class extends hp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ChatPromptValue"}messages;constructor(e){Array.isArray(e)&&(e={messages:e}),super(e),this.messages=e.messages}toString(){return Fo(this.messages)}toChatMessages(){return this.messages}},uw=class extends hp{lc_namespace=["langchain_core","prompt_values"];lc_serializable=!0;static lc_name(){return"ImagePromptValue"}imageUrl;value;constructor(e){"imageUrl"in e||(e={imageUrl:e}),super(e),this.imageUrl=e.imageUrl}toString(){return this.imageUrl.url}toChatMessages(){return[new Ye({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var WC=pa(KC(),1),YL=Object.defineProperty,QL=(e,t,r)=>t in e?YL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,e6=(e,t,r)=>(QL(e,typeof t!="symbol"?t+"":t,r),r);function t6(e,t){let r=Array.from({length:e.length},(i,n)=>({start:n,end:n+1}));for(;r.length>1;){let i=null;for(let n=0;n<r.length-1;n++){let a=e.slice(r[n].start,r[n+1].end),o=t.get(a.join(","));o!=null&&(i==null||o<i[0])&&(i=[o,n])}if(i!=null){let n=i[1];r[n]={start:r[n].start,end:r[n+1].end},r.splice(n+1,1)}else break}return r}function r6(e,t){return e.length===1?[t.get(e.join(","))]:t6(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function n6(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var dw=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(e,t){this.patStr=e.pat_str;let r=e.bpe_ranks.split(`
|
|
245
|
+
`).filter(Boolean).reduce((i,n)=>{let[a,o,...s]=n.split(" "),c=Number.parseInt(o,10);return s.forEach((u,l)=>i[u]=c+l),i},{});for(let[i,n]of Object.entries(r)){let a=WC.default.toByteArray(i);this.rankMap.set(a.join(","),n),this.textMap.set(n,a)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((i,[n,a])=>(i[a]=this.textEncoder.encode(n),i),{})}encode(e,t=[],r="all"){let i=new RegExp(this.patStr,"ug"),n=dw.specialTokenRegex(Object.keys(this.specialTokens)),a=[],o=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!o.has(u)):r);if(s.size>0){let u=dw.specialTokenRegex([...s]),l=e.match(u);if(l!=null)throw new Error(`The text contains a special token that is not allowed: ${l[0]}`)}let c=0;for(;;){let u=null,l=c;for(;n.lastIndex=l,u=n.exec(e),!(u==null||o.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let p of e.substring(c,d).matchAll(i)){let m=this.textEncoder.encode(p[0]),_=this.rankMap.get(m.join(","));if(_!=null){a.push(_);continue}a.push(...r6(m,this.rankMap))}if(u==null)break;let f=this.specialTokens[u[0]];a.push(f),c=u.index+u[0].length}return a}decode(e){let t=[],r=0;for(let a=0;a<e.length;++a){let o=e[a],s=this.textMap.get(o)??this.inverseSpecialTokens[o];s!=null&&(t.push(s),r+=s.length)}let i=new Uint8Array(r),n=0;for(let a of t)i.set(a,n),n+=a.length;return this.textDecoder.decode(i)}},_p=dw;e6(_p,"specialTokenRegex",e=>new RegExp(e.map(t=>n6(t)).join("|"),"g"));function fw(e){switch(e){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var qC=E({encodingForModel:()=>vp,getEncoding:()=>XC}),yp={},i6=new ni({});async function XC(e){return e in yp||(yp[e]=i6.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new _p(t)).catch(t=>{throw delete yp[e],t})),await yp[e]}async function vp(e){return XC(fw(e))}var YC=E({BaseLangChain:()=>wp,BaseLanguageModel:()=>wu,calculateMaxTokens:()=>s6,getEmbeddingContextSize:()=>a6,getModelContextSize:()=>QC,getModelNameForTiktoken:()=>bp,isOpenAITool:()=>o6}),bp=e=>e.startsWith("gpt-5")?"gpt-5":e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,a6=e=>e==="text-embedding-ada-002"?8191:2046,QC=e=>{switch(bp(e)){case"gpt-5":case"gpt-5-turbo":case"gpt-5-turbo-preview":return 4e5;case"gpt-4o":case"gpt-4o-mini":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":return 128e3;case"gpt-4-turbo":case"gpt-4-turbo-preview":case"gpt-4-turbo-2024-04-09":case"gpt-4-0125-preview":case"gpt-4-1106-preview":return 128e3;case"gpt-4-32k":case"gpt-4-32k-0314":case"gpt-4-32k-0613":return 32768;case"gpt-4":case"gpt-4-0314":case"gpt-4-0613":return 8192;case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-16k-0613":return 16384;case"gpt-3.5-turbo":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-1106":case"gpt-3.5-turbo-0125":return 4096;case"text-davinci-003":case"text-davinci-002":return 4097;case"text-davinci-001":return 2049;case"text-curie-001":case"text-babbage-001":case"text-ada-001":return 2048;case"code-davinci-002":case"code-davinci-001":return 8e3;case"code-cushman-001":return 2048;case"claude-3-5-sonnet-20241022":case"claude-3-5-sonnet-20240620":case"claude-3-opus-20240229":case"claude-3-sonnet-20240229":case"claude-3-haiku-20240307":case"claude-2.1":return 2e5;case"claude-2.0":case"claude-instant-1.2":return 1e5;case"gemini-1.5-pro":case"gemini-1.5-pro-latest":case"gemini-1.5-flash":case"gemini-1.5-flash-latest":return 1e6;case"gemini-pro":case"gemini-pro-vision":return 32768;default:return 4097}};function o6(e){return typeof e!="object"||!e?!1:!!("type"in e&&e.type==="function"&&"function"in e&&typeof e.function=="object"&&e.function&&"name"in e.function&&"parameters"in e.function)}var s6=async({prompt:e,modelName:t})=>{let r;try{r=(await vp(bp(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),r=Math.ceil(e.length/4)}return QC(t)-r},c6=()=>!1,wp=class extends re{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??c6(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.39")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},wu=class extends wp{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:i,...n}=r;super({callbacks:e??t,...n}),typeof i=="object"?this.cache=i:i?this.cache=Ih.global():this.cache=void 0,this.caller=new ni(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(i=>typeof i=="string"?i:i.type==="text"&&"text"in i?i.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await vp("modelName"in this?bp(this.modelName):"gpt2")}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(i){console.warn("Failed to calculate number of tokens, falling back to approximate count",i)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new vu(e):Array.isArray(e)?new bu(e.map(St)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([i,n])=>n!==void 0).map(([i,n])=>`${i}:${JSON.stringify(n)}`).sort().join(",")}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}get profile(){return{}}};var fi=class extends re{static lc_name(){return"RunnablePassthrough"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;func;constructor(e){super(e),e&&(this.func=e.func)}async invoke(e,t){let r=ye(t);return this.func&&await this.func(e,r),this._callWithConfig(i=>Promise.resolve(i),e,r)}async*transform(e,t){let r=ye(t),i,n=!0;for await(let a of this._transformStreamWithConfig(e,o=>o,r))if(yield a,n)if(i===void 0)i=a;else try{i=vr(i,a)}catch{i=void 0,n=!1}this.func&&i!==void 0&&await this.func(i,r)}static assign(e){return new _u(new ea({steps:e}))}};var eO=class extends re{static lc_name(){return"RouterRunnable"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;runnables;constructor(e){super(e),this.runnables=e.runnables}async invoke(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.invoke(i,ye(t))}async batch(e,t,r){let i=e.map(l=>l.key),n=e.map(l=>l.input);if(i.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let a=i.map(l=>this.runnables[l]),o=this._getOptionsList(t??{},e.length),s=o[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,u=[];for(let l=0;l<n.length;l+=c){let d=n.slice(l,l+c).map((p,m)=>a[m].invoke(p,o[m])),f=await Promise.all(d);u.push(f)}return u.flat()}async stream(e,t){let{key:r,input:i}=e,n=this.runnables[r];if(n===void 0)throw new Error(`No runnable associated with key "${r}".`);return n.stream(i,t)}};var tO=class extends re{static lc_name(){return"RunnableBranch"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;default;branches;constructor(e){super(e),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");let t=e.slice(0,-1).map(([i,n])=>[Xe(i),Xe(n)]),r=Xe(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let i;for(let n=0;n<this.branches.length;n+=1){let[a,o]=this.branches[n];if(await a.invoke(e,Se(t,{callbacks:r?.getChild(`condition:${n+1}`)}))){i=await o.invoke(e,Se(t,{callbacks:r?.getChild(`branch:${n+1}`)}));break}}return i||(i=await this.default.invoke(e,Se(t,{callbacks:r?.getChild("branch:default")}))),i}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await yt(t))?.handleChainStart(this.toJSON(),lt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),i,n=!0,a;try{for(let o=0;o<this.branches.length;o+=1){let[s,c]=this.branches[o];if(await s.invoke(e,Se(t,{callbacks:r?.getChild(`condition:${o+1}`)}))){a=await c.stream(e,Se(t,{callbacks:r?.getChild(`branch:${o+1}`)}));for await(let u of a)if(yield u,n)if(i===void 0)i=u;else try{i=vr(i,u)}catch{i=void 0,n=!1}break}}if(a===void 0){a=await this.default.stream(e,Se(t,{callbacks:r?.getChild("branch:default")}));for await(let o of a)if(yield o,n)if(i===void 0)i=o;else try{i=vr(i,o)}catch{i=void 0,n=!1}}}catch(o){throw await r?.handleChainError(o),o}await r?.handleChainEnd(i??{})}};var rO=class extends Ur{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=Rt.from((a,o)=>this._enterHistory(a,o??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=fi.assign({[r]:t}).withConfig({runName:"insertHistory"}));let i=t.pipe(e.runnable.withListeners({onEnd:(a,o)=>this._exitHistory(a,o??{})})).withConfig({runName:"RunnableWithMessageHistory"}),n=e.config??{};super({...e,config:n,bound:i}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if(typeof e=="object"&&!Array.isArray(e)&&!Je(e)){let r;this.inputMessagesKey?r=this.inputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="input",Array.isArray(e[r])&&Array.isArray(e[r][0])?t=e[r][0]:t=e[r]}else t=e;if(typeof t=="string")return[new Ye(t)];if(Array.isArray(t))return t;if(Je(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
246
|
+
Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!Je(e)&&typeof e!="string"){let r;this.outputMessagesKey!==void 0?r=this.outputMessagesKey:Object.keys(e).length===1?r=Object.keys(e)[0]:r="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[r]}else t=e;if(typeof t=="string")return[new Ee(t)];if(Array.isArray(t))return t;if(Je(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){let r=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?r.concat(this._getInputMessages(e)):r}async _exitHistory(e,t){let r=t.configurable?.messageHistory,i;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?i=e.inputs[0]:i=e.inputs;let n=this._getInputMessages(i);if(this.historyMessagesKey===void 0){let s=await r.getMessages();n=n.slice(s.length)}let a=e.outputs;if(!a)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let o=this._getOutputMessages(a);await r.addMessages([...n,...o])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let i={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
247
|
+
eg. chain.invoke(${JSON.stringify(i)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var nO=E({RouterRunnable:()=>eO,Runnable:()=>re,RunnableAssign:()=>_u,RunnableBinding:()=>Ur,RunnableBranch:()=>tO,RunnableEach:()=>uC,RunnableLambda:()=>Rt,RunnableMap:()=>ea,RunnableParallel:()=>mC,RunnablePassthrough:()=>fi,RunnablePick:()=>qb,RunnableRetry:()=>dp,RunnableSequence:()=>kr,RunnableToolLike:()=>lp,RunnableWithFallbacks:()=>Wb,RunnableWithMessageHistory:()=>rO,_coerceToRunnable:()=>Xe,ensureConfig:()=>ye,getCallbackManagerForConfig:()=>yt,mergeConfigs:()=>vt,patchConfig:()=>Se,pickRunnableConfigKeys:()=>ir,raceWithSignal:()=>yr});var iO=E({applyPatch:()=>ji,compare:()=>Mi});var zs=class extends re{parseResultWithPrompt(e,t,r){return this.parseResult(e,r)}_baseMessageToString(e){return typeof e.content=="string"?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return typeof e=="string"?this._callWithConfig(async(r,i)=>this.parseResult([{text:r}],i?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,i)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],i?.callbacks),e,{...t,runType:"parser"})}},sn=class extends zs{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,r){return this.parse(e,r)}_type(){throw new Error("_type not implemented")}},jt=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,i=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=i,i&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Yn(this,"OUTPUT_PARSING_FAILURE")}};var pi=class extends sn{async*_transform(e){for await(let t of e)typeof t=="string"?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}},Fn=class extends pi{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let i of e){if(typeof i!="string"&&typeof i.content!="string")throw new Error("Cannot handle non-string output.");let n;if(Qn(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new zi({message:i,text:i.content})}else if(Je(i)){if(typeof i.content!="string")throw new Error("Cannot handle non-string message output.");n=new zi({message:$a(i),text:i.content})}else n=new ri({text:i});r===void 0?r=n:r=r.concat(n);let a=await this.parsePartialResult([r]);a!=null&&!Dn(a,t)&&(this.diff?yield this._diff(t,a):yield a,t=a)}}getFormatInstructions(){return""}};var aO=class extends pi{static lc_name(){return"BytesOutputParser"}lc_namespace=["langchain_core","output_parsers","bytes"];lc_serializable=!0;textEncoder=new TextEncoder;parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}};var Ds=class extends pi{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let i=[...t.matchAll(this.re)];if(i.length>1){let n=0;for(let a of i.slice(0,-1))yield[a[1]],n+=(a.index??0)+a[0].length;t=t.slice(n)}}else{let i=await this.parse(t);if(i.length>1){for(let n of i.slice(0,-1))yield[n];t=i[i.length-1]}}for(let r of await this.parse(t))yield[r]}},oO=class extends Ds{static lc_name(){return"CommaSeparatedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;async parse(e){try{return e.trim().split(",").map(t=>t.trim())}catch{throw new jt(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},sO=class extends Ds{lc_namespace=["langchain_core","output_parsers","list"];length;separator;constructor({length:e,separator:t}){super(...arguments),this.length=e,this.separator=t||","}async parse(e){try{let t=e.trim().split(this.separator).map(r=>r.trim());if(this.length!==void 0&&t.length!==this.length)throw new jt(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===jt.prototype?t:new jt(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${this.length===void 0?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},cO=class extends Ds{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
248
|
+
|
|
249
|
+
1. foo
|
|
250
|
+
|
|
251
|
+
2. bar
|
|
252
|
+
|
|
253
|
+
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},uO=class extends Ds{static lc_name(){return"NumberedListOutputParser"}lc_namespace=["langchain_core","output_parsers","list"];lc_serializable=!0;getFormatInstructions(){return`Your response should be a numbered list with each item on a new line. For example:
|
|
254
|
+
|
|
255
|
+
1. foo
|
|
256
|
+
|
|
257
|
+
2. bar
|
|
258
|
+
|
|
259
|
+
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var lO=class extends pi{static lc_name(){return"StrOutputParser"}lc_namespace=["langchain_core","output_parsers","string"];lc_serializable=!0;parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;case"reasoning":case"thinking":case"redacted_thinking":return"";default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce((t,r)=>t+this._messageContentToString(r),"")}};var xp=class extends Fn{static lc_name(){return"JsonOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_concatOutputChunks(e,t){return this.diff?super._concatOutputChunks(e,t):t}_diff(e,t){if(t)return e?Mi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return ba(e[0].text)}async parse(e){return ba(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var Sp=class extends sn{static lc_name(){return"StandardSchemaOutputParser"}lc_namespace=["langchain","output_parsers","standard_schema"];schema;constructor(e){super(),this.schema=e}static fromSerializableSchema(e){return new this(e)}async parse(e){try{let t=ba(e,JSON.parse),r=await this.schema["~standard"].validate(t);if(r.issues)throw new Error(`Validation failed: ${JSON.stringify(r.issues)}`);return r.value}catch(t){throw new jt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}getFormatInstructions(){return""}};var xu=class extends sn{static lc_name(){return"StructuredOutputParser"}lc_namespace=["langchain","output_parsers","structured"];toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),this.schema=e}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=bt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,bt.string().describe(i)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
260
|
+
|
|
261
|
+
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
262
|
+
|
|
263
|
+
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
264
|
+
would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
|
|
265
|
+
Thus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
|
|
266
|
+
|
|
267
|
+
Your output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!
|
|
268
|
+
|
|
269
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
270
|
+
\`\`\`json
|
|
271
|
+
${JSON.stringify(ht(this.schema))}
|
|
272
|
+
\`\`\`
|
|
273
|
+
`}async parse(e){try{let t=e.trim(),r=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(i,n)=>`"${n.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await Wi(this.schema,JSON.parse(r))}catch(t){throw new jt(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}},pw=class extends xu{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){let t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:
|
|
274
|
+
\`\`\`json
|
|
275
|
+
${this._schemaToInstruction(ht(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
|
|
276
|
+
\`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let i=!1,n;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(i=!0,r.type.splice(s,1)),n=r.type.join(" | ")}else n=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
|
|
277
|
+
${Object.entries(r.properties).map(([c,u])=>{let l=r.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
|
|
278
|
+
`)}
|
|
279
|
+
${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
|
|
280
|
+
${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
|
|
281
|
+
${" ".repeat(t-2)}] ${s}`}let a=i?" (nullable)":"",o=r.description?` // ${r.description}`:"";return`${n}${o}${a}`}if("anyOf"in r)return r.anyOf.map(i=>this._schemaToInstruction(i,t)).join(`
|
|
282
|
+
${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=bt.object(Object.fromEntries(Object.entries(e).map(([r,i])=>[r,bt.string().describe(i)])));return new this(t)}},dO=class extends sn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new pw(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new jt(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var u6=function(){let e={};e.parser=function(g,h){return new r(g,h)},e.SAXParser=r,e.SAXStream=u,e.createStream=c,e.MAX_BUFFER_LENGTH=65536;let t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(g,h){if(!(this instanceof r))return new r(g,h);var C=this;n(C),C.q=C.c="",C.bufferCheckPosition=e.MAX_BUFFER_LENGTH,C.opt=h||{},C.opt.lowercase=C.opt.lowercase||C.opt.lowercasetags,C.looseCase=C.opt.lowercase?"toLowerCase":"toUpperCase",C.tags=[],C.closed=C.closedRoot=C.sawRoot=!1,C.tag=C.error=null,C.strict=!!g,C.noscript=!!(g||C.opt.noscript),C.state=y.BEGIN,C.strictEntities=C.opt.strictEntities,C.ENTITIES=C.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),C.attribList=[],C.opt.xmlns&&(C.ns=Object.create(m)),C.trackPosition=C.opt.position!==!1,C.trackPosition&&(C.position=C.line=C.column=0),O(C,"onready")}Object.create||(Object.create=function(g){function h(){}return h.prototype=g,new h}),Object.keys||(Object.keys=function(g){var h=[];for(var C in g)g.hasOwnProperty(C)&&h.push(C);return h});function i(g){for(var h=Math.max(e.MAX_BUFFER_LENGTH,10),C=0,k=0,xe=t.length;k<xe;k++){var Oe=g[t[k]].length;if(Oe>h)switch(t[k]){case"textNode":de(g);break;case"cdata":B(g,"oncdata",g.cdata),g.cdata="";break;case"script":B(g,"onscript",g.script),g.script="";break;default:Lt(g,"Max buffer length exceeded: "+t[k])}C=Math.max(C,Oe)}g.bufferCheckPosition=e.MAX_BUFFER_LENGTH-C+g.position}function n(g){for(var h=0,C=t.length;h<C;h++)g[t[h]]=""}function a(g){de(g),g.cdata!==""&&(B(g,"oncdata",g.cdata),g.cdata=""),g.script!==""&&(B(g,"onscript",g.script),g.script="")}r.prototype={end:function(){_n(this)},write:Vr,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o=ReadableStream;o||(o=function(){});var s=e.EVENTS.filter(function(g){return g!=="error"&&g!=="end"});function c(g,h){return new u(g,h)}function u(g,h){if(!(this instanceof u))return new u(g,h);o.apply(this),this._parser=new r(g,h),this.writable=!0,this.readable=!0;var C=this;this._parser.onend=function(){C.emit("end")},this._parser.onerror=function(k){C.emit("error",k),C._parser.error=null},this._decoder=null,s.forEach(function(k){Object.defineProperty(C,"on"+k,{get:function(){return C._parser["on"+k]},set:function(xe){if(!xe)return C.removeAllListeners(k),C._parser["on"+k]=xe,xe;C.on(k,xe)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(o.prototype,{constructor:{value:u}}),u.prototype.write=function(g){return this._parser.write(g.toString()),this.emit("data",g),!0},u.prototype.end=function(g){return g&&g.length&&this.write(g),this._parser.end(),!0},u.prototype.on=function(g,h){var C=this;return!C._parser["on"+g]&&s.indexOf(g)!==-1&&(C._parser["on"+g]=function(){var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);k.splice(0,0,g),C.emit.apply(C,k)}),o.prototype.on.call(C,g,h)};var l="[CDATA[",d="DOCTYPE",f="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",m={xml:f,xmlns:p},_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,x=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function S(g){return g===" "||g===`
|
|
283
|
+
`||g==="\r"||g===" "}function $(g){return g==='"'||g==="'"}function T(g){return g===">"||S(g)}function F(g,h){return g.test(h)}function A(g,h){return!F(g,h)}var y=0;e.STATE={BEGIN:y++,BEGIN_WHITESPACE:y++,TEXT:y++,TEXT_ENTITY:y++,OPEN_WAKA:y++,SGML_DECL:y++,SGML_DECL_QUOTED:y++,DOCTYPE:y++,DOCTYPE_QUOTED:y++,DOCTYPE_DTD:y++,DOCTYPE_DTD_QUOTED:y++,COMMENT_STARTING:y++,COMMENT:y++,COMMENT_ENDING:y++,COMMENT_ENDED:y++,CDATA:y++,CDATA_ENDING:y++,CDATA_ENDING_2:y++,PROC_INST:y++,PROC_INST_BODY:y++,PROC_INST_ENDING:y++,OPEN_TAG:y++,OPEN_TAG_SLASH:y++,ATTRIB:y++,ATTRIB_NAME:y++,ATTRIB_NAME_SAW_WHITE:y++,ATTRIB_VALUE:y++,ATTRIB_VALUE_QUOTED:y++,ATTRIB_VALUE_CLOSED:y++,ATTRIB_VALUE_UNQUOTED:y++,ATTRIB_VALUE_ENTITY_Q:y++,ATTRIB_VALUE_ENTITY_U:y++,CLOSE_TAG:y++,CLOSE_TAG_SAW_WHITE:y++,SCRIPT:y++,SCRIPT_ENDING:y++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(g){var h=e.ENTITIES[g],C=typeof h=="number"?String.fromCharCode(h):h;e.ENTITIES[g]=C});for(var W in e.STATE)e.STATE[e.STATE[W]]=W;y=e.STATE;function O(g,h,C){g[h]&&g[h](C)}function B(g,h,C){g.textNode&&de(g),O(g,h,C)}function de(g){g.textNode=Le(g.opt,g.textNode),g.textNode&&O(g,"ontext",g.textNode),g.textNode=""}function Le(g,h){return g.trim&&(h=h.trim()),g.normalize&&(h=h.replace(/\s+/g," ")),h}function Lt(g,h){return de(g),g.trackPosition&&(h+=`
|
|
284
|
+
Line: `+g.line+`
|
|
285
|
+
Column: `+g.column+`
|
|
286
|
+
Char: `+g.c),h=new Error(h),g.error=h,O(g,"onerror",h),g}function _n(g){return g.sawRoot&&!g.closedRoot&&we(g,"Unclosed root tag"),g.state!==y.BEGIN&&g.state!==y.BEGIN_WHITESPACE&&g.state!==y.TEXT&&Lt(g,"Unexpected end"),de(g),g.c="",g.closed=!0,O(g,"onend"),r.call(g,g.strict,g.opt),g}function we(g,h){if(typeof g!="object"||!(g instanceof r))throw new Error("bad call to strictFail");g.strict&&Lt(g,h)}function la(g){g.strict||(g.tagName=g.tagName[g.looseCase]());var h=g.tags[g.tags.length-1]||g,C=g.tag={name:g.tagName,attributes:{}};g.opt.xmlns&&(C.ns=h.ns),g.attribList.length=0,B(g,"onopentagstart",C)}function Jn(g,h){var C=g.indexOf(":")<0?["",g]:g.split(":"),k=C[0],xe=C[1];return h&&g==="xmlns"&&(k="xmlns",xe=""),{prefix:k,local:xe}}function da(g){if(g.strict||(g.attribName=g.attribName[g.looseCase]()),g.attribList.indexOf(g.attribName)!==-1||g.tag.attributes.hasOwnProperty(g.attribName)){g.attribName=g.attribValue="";return}if(g.opt.xmlns){var h=Jn(g.attribName,!0),C=h.prefix,k=h.local;if(C==="xmlns")if(k==="xml"&&g.attribValue!==f)we(g,"xml: prefix must be bound to "+f+`
|
|
287
|
+
Actual: `+g.attribValue);else if(k==="xmlns"&&g.attribValue!==p)we(g,"xmlns: prefix must be bound to "+p+`
|
|
288
|
+
Actual: `+g.attribValue);else{var xe=g.tag,Oe=g.tags[g.tags.length-1]||g;xe.ns===Oe.ns&&(xe.ns=Object.create(Oe.ns)),xe.ns[k]=g.attribValue}g.attribList.push([g.attribName,g.attribValue])}else g.tag.attributes[g.attribName]=g.attribValue,B(g,"onattribute",{name:g.attribName,value:g.attribValue});g.attribName=g.attribValue=""}function Zr(g,h){if(g.opt.xmlns){var C=g.tag,k=Jn(g.tagName);C.prefix=k.prefix,C.local=k.local,C.uri=C.ns[k.prefix]||"",C.prefix&&!C.uri&&(we(g,"Unbound namespace prefix: "+JSON.stringify(g.tagName)),C.uri=k.prefix);var xe=g.tags[g.tags.length-1]||g;C.ns&&xe.ns!==C.ns&&Object.keys(C.ns).forEach(function(fa){B(g,"onopennamespace",{prefix:fa,uri:C.ns[fa]})});for(var Oe=0,dt=g.attribList.length;Oe<dt;Oe++){var nt=g.attribList[Oe],Tt=nt[0],Ir=nt[1],it=Jn(Tt,!0),yn=it.prefix,$o=it.local,fl=yn===""?"":C.ns[yn]||"",J={name:Tt,value:Ir,prefix:yn,local:$o,uri:fl};yn&&yn!=="xmlns"&&!fl&&(we(g,"Unbound namespace prefix: "+JSON.stringify(yn)),J.uri=yn),g.tag.attributes[Tt]=J,B(g,"onattribute",J)}g.attribList.length=0}g.tag.isSelfClosing=!!h,g.sawRoot=!0,g.tags.push(g.tag),B(g,"onopentag",g.tag),h||(!g.noscript&&g.tagName.toLowerCase()==="script"?g.state=y.SCRIPT:g.state=y.TEXT,g.tag=null,g.tagName=""),g.attribName=g.attribValue="",g.attribList.length=0}function Kn(g){if(!g.tagName){we(g,"Weird empty close tag."),g.textNode+="</>",g.state=y.TEXT;return}if(g.script){if(g.tagName!=="script"){g.script+="</"+g.tagName+">",g.tagName="",g.state=y.SCRIPT;return}B(g,"onscript",g.script),g.script=""}var h=g.tags.length,C=g.tagName;g.strict||(C=C[g.looseCase]());for(var k=C;h--&&g.tags[h].name!==k;)we(g,"Unexpected close tag");if(h<0){we(g,"Unmatched closing tag: "+g.tagName),g.textNode+="</"+g.tagName+">",g.state=y.TEXT;return}g.tagName=C;for(var xe=g.tags.length;xe-- >h;){var Oe=g.tag=g.tags.pop();g.tagName=g.tag.name,B(g,"onclosetag",g.tagName);var dt={};for(var nt in Oe.ns)dt[nt]=Oe.ns[nt];var Tt=g.tags[g.tags.length-1]||g;g.opt.xmlns&&Oe.ns!==Tt.ns&&Object.keys(Oe.ns).forEach(function(Ir){var it=Oe.ns[Ir];B(g,"onclosenamespace",{prefix:Ir,uri:it})})}h===0&&(g.closedRoot=!0),g.tagName=g.attribValue=g.attribName="",g.attribList.length=0,g.state=y.TEXT}function uc(g){var h=g.entity,C=h.toLowerCase(),k,xe="";return g.ENTITIES[h]?g.ENTITIES[h]:g.ENTITIES[C]?g.ENTITIES[C]:(h=C,h.charAt(0)==="#"&&(h.charAt(1)==="x"?(h=h.slice(2),k=parseInt(h,16),xe=k.toString(16)):(h=h.slice(1),k=parseInt(h,10),xe=k.toString(10))),h=h.replace(/^0+/,""),isNaN(k)||xe.toLowerCase()!==h?(we(g,"Invalid character entity"),"&"+g.entity+";"):String.fromCodePoint(k))}function lc(g,h){h==="<"?(g.state=y.OPEN_WAKA,g.startTagPosition=g.position):S(h)||(we(g,"Non-whitespace before first tag."),g.textNode=h,g.state=y.TEXT)}function dc(g,h){var C="";return h<g.length&&(C=g.charAt(h)),C}function Vr(g){var h=this;if(this.error)throw this.error;if(h.closed)return Lt(h,"Cannot write after close. Assign an onready handler.");if(g===null)return _n(h);typeof g=="object"&&(g=g.toString());for(var C=0,k="";k=dc(g,C++),h.c=k,!!k;)switch(h.trackPosition&&(h.position++,k===`
|
|
289
|
+
`?(h.line++,h.column=0):h.column++),h.state){case y.BEGIN:if(h.state=y.BEGIN_WHITESPACE,k==="\uFEFF")continue;lc(h,k);continue;case y.BEGIN_WHITESPACE:lc(h,k);continue;case y.TEXT:if(h.sawRoot&&!h.closedRoot){for(var xe=C-1;k&&k!=="<"&&k!=="&";)k=dc(g,C++),k&&h.trackPosition&&(h.position++,k===`
|
|
290
|
+
`?(h.line++,h.column=0):h.column++);h.textNode+=g.substring(xe,C-1)}k==="<"&&!(h.sawRoot&&h.closedRoot&&!h.strict)?(h.state=y.OPEN_WAKA,h.startTagPosition=h.position):(!S(k)&&(!h.sawRoot||h.closedRoot)&&we(h,"Text data outside of root node."),k==="&"?h.state=y.TEXT_ENTITY:h.textNode+=k);continue;case y.SCRIPT:k==="<"?h.state=y.SCRIPT_ENDING:h.script+=k;continue;case y.SCRIPT_ENDING:k==="/"?h.state=y.CLOSE_TAG:(h.script+="<"+k,h.state=y.SCRIPT);continue;case y.OPEN_WAKA:if(k==="!")h.state=y.SGML_DECL,h.sgmlDecl="";else if(!S(k))if(F(_,k))h.state=y.OPEN_TAG,h.tagName=k;else if(k==="/")h.state=y.CLOSE_TAG,h.tagName="";else if(k==="?")h.state=y.PROC_INST,h.procInstName=h.procInstBody="";else{if(we(h,"Unencoded <"),h.startTagPosition+1<h.position){var Oe=h.position-h.startTagPosition;k=new Array(Oe).join(" ")+k}h.textNode+="<"+k,h.state=y.TEXT}continue;case y.SGML_DECL:(h.sgmlDecl+k).toUpperCase()===l?(B(h,"onopencdata"),h.state=y.CDATA,h.sgmlDecl="",h.cdata=""):h.sgmlDecl+k==="--"?(h.state=y.COMMENT,h.comment="",h.sgmlDecl=""):(h.sgmlDecl+k).toUpperCase()===d?(h.state=y.DOCTYPE,(h.doctype||h.sawRoot)&&we(h,"Inappropriately located doctype declaration"),h.doctype="",h.sgmlDecl=""):k===">"?(B(h,"onsgmldeclaration",h.sgmlDecl),h.sgmlDecl="",h.state=y.TEXT):($(k)&&(h.state=y.SGML_DECL_QUOTED),h.sgmlDecl+=k);continue;case y.SGML_DECL_QUOTED:k===h.q&&(h.state=y.SGML_DECL,h.q=""),h.sgmlDecl+=k;continue;case y.DOCTYPE:k===">"?(h.state=y.TEXT,B(h,"ondoctype",h.doctype),h.doctype=!0):(h.doctype+=k,k==="["?h.state=y.DOCTYPE_DTD:$(k)&&(h.state=y.DOCTYPE_QUOTED,h.q=k));continue;case y.DOCTYPE_QUOTED:h.doctype+=k,k===h.q&&(h.q="",h.state=y.DOCTYPE);continue;case y.DOCTYPE_DTD:h.doctype+=k,k==="]"?h.state=y.DOCTYPE:$(k)&&(h.state=y.DOCTYPE_DTD_QUOTED,h.q=k);continue;case y.DOCTYPE_DTD_QUOTED:h.doctype+=k,k===h.q&&(h.state=y.DOCTYPE_DTD,h.q="");continue;case y.COMMENT:k==="-"?h.state=y.COMMENT_ENDING:h.comment+=k;continue;case y.COMMENT_ENDING:k==="-"?(h.state=y.COMMENT_ENDED,h.comment=Le(h.opt,h.comment),h.comment&&B(h,"oncomment",h.comment),h.comment=""):(h.comment+="-"+k,h.state=y.COMMENT);continue;case y.COMMENT_ENDED:k!==">"?(we(h,"Malformed comment"),h.comment+="--"+k,h.state=y.COMMENT):h.state=y.TEXT;continue;case y.CDATA:k==="]"?h.state=y.CDATA_ENDING:h.cdata+=k;continue;case y.CDATA_ENDING:k==="]"?h.state=y.CDATA_ENDING_2:(h.cdata+="]"+k,h.state=y.CDATA);continue;case y.CDATA_ENDING_2:k===">"?(h.cdata&&B(h,"oncdata",h.cdata),B(h,"onclosecdata"),h.cdata="",h.state=y.TEXT):k==="]"?h.cdata+="]":(h.cdata+="]]"+k,h.state=y.CDATA);continue;case y.PROC_INST:k==="?"?h.state=y.PROC_INST_ENDING:S(k)?h.state=y.PROC_INST_BODY:h.procInstName+=k;continue;case y.PROC_INST_BODY:if(!h.procInstBody&&S(k))continue;k==="?"?h.state=y.PROC_INST_ENDING:h.procInstBody+=k;continue;case y.PROC_INST_ENDING:k===">"?(B(h,"onprocessinginstruction",{name:h.procInstName,body:h.procInstBody}),h.procInstName=h.procInstBody="",h.state=y.TEXT):(h.procInstBody+="?"+k,h.state=y.PROC_INST_BODY);continue;case y.OPEN_TAG:F(v,k)?h.tagName+=k:(la(h),k===">"?Zr(h):k==="/"?h.state=y.OPEN_TAG_SLASH:(S(k)||we(h,"Invalid character in tag name"),h.state=y.ATTRIB));continue;case y.OPEN_TAG_SLASH:k===">"?(Zr(h,!0),Kn(h)):(we(h,"Forward-slash in opening tag not followed by >"),h.state=y.ATTRIB);continue;case y.ATTRIB:if(S(k))continue;k===">"?Zr(h):k==="/"?h.state=y.OPEN_TAG_SLASH:F(_,k)?(h.attribName=k,h.attribValue="",h.state=y.ATTRIB_NAME):we(h,"Invalid attribute name");continue;case y.ATTRIB_NAME:k==="="?h.state=y.ATTRIB_VALUE:k===">"?(we(h,"Attribute without value"),h.attribValue=h.attribName,da(h),Zr(h)):S(k)?h.state=y.ATTRIB_NAME_SAW_WHITE:F(v,k)?h.attribName+=k:we(h,"Invalid attribute name");continue;case y.ATTRIB_NAME_SAW_WHITE:if(k==="=")h.state=y.ATTRIB_VALUE;else{if(S(k))continue;we(h,"Attribute without value"),h.tag.attributes[h.attribName]="",h.attribValue="",B(h,"onattribute",{name:h.attribName,value:""}),h.attribName="",k===">"?Zr(h):F(_,k)?(h.attribName=k,h.state=y.ATTRIB_NAME):(we(h,"Invalid attribute name"),h.state=y.ATTRIB)}continue;case y.ATTRIB_VALUE:if(S(k))continue;$(k)?(h.q=k,h.state=y.ATTRIB_VALUE_QUOTED):(we(h,"Unquoted attribute value"),h.state=y.ATTRIB_VALUE_UNQUOTED,h.attribValue=k);continue;case y.ATTRIB_VALUE_QUOTED:if(k!==h.q){k==="&"?h.state=y.ATTRIB_VALUE_ENTITY_Q:h.attribValue+=k;continue}da(h),h.q="",h.state=y.ATTRIB_VALUE_CLOSED;continue;case y.ATTRIB_VALUE_CLOSED:S(k)?h.state=y.ATTRIB:k===">"?Zr(h):k==="/"?h.state=y.OPEN_TAG_SLASH:F(_,k)?(we(h,"No whitespace between attributes"),h.attribName=k,h.attribValue="",h.state=y.ATTRIB_NAME):we(h,"Invalid attribute name");continue;case y.ATTRIB_VALUE_UNQUOTED:if(!T(k)){k==="&"?h.state=y.ATTRIB_VALUE_ENTITY_U:h.attribValue+=k;continue}da(h),k===">"?Zr(h):h.state=y.ATTRIB;continue;case y.CLOSE_TAG:if(h.tagName)k===">"?Kn(h):F(v,k)?h.tagName+=k:h.script?(h.script+="</"+h.tagName,h.tagName="",h.state=y.SCRIPT):(S(k)||we(h,"Invalid tagname in closing tag"),h.state=y.CLOSE_TAG_SAW_WHITE);else{if(S(k))continue;A(_,k)?h.script?(h.script+="</"+k,h.state=y.SCRIPT):we(h,"Invalid tagname in closing tag."):h.tagName=k}continue;case y.CLOSE_TAG_SAW_WHITE:if(S(k))continue;k===">"?Kn(h):we(h,"Invalid characters in closing tag");continue;case y.TEXT_ENTITY:case y.ATTRIB_VALUE_ENTITY_Q:case y.ATTRIB_VALUE_ENTITY_U:var dt,nt;switch(h.state){case y.TEXT_ENTITY:dt=y.TEXT,nt="textNode";break;case y.ATTRIB_VALUE_ENTITY_Q:dt=y.ATTRIB_VALUE_QUOTED,nt="attribValue";break;case y.ATTRIB_VALUE_ENTITY_U:dt=y.ATTRIB_VALUE_UNQUOTED,nt="attribValue";break}if(k===";")if(h.opt.unparsedEntities){var Tt=uc(h);h.entity="",h.state=dt,h.write(Tt)}else h[nt]+=uc(h),h.entity="",h.state=dt;else F(h.entity.length?w:x,k)?h.entity+=k:(we(h,"Invalid character in entity name"),h[nt]+="&"+h.entity+k,h.entity="",h.state=dt);continue;default:throw new Error(h,"Unknown state: "+h.state)}return h.position>=h.bufferCheckPosition&&i(h),h}return String.fromCodePoint||(function(){var g=String.fromCharCode,h=Math.floor,C=function(){var k=16384,xe=[],Oe,dt,nt=-1,Tt=arguments.length;if(!Tt)return"";for(var Ir="";++nt<Tt;){var it=Number(arguments[nt]);if(!isFinite(it)||it<0||it>1114111||h(it)!==it)throw RangeError("Invalid code point: "+it);it<=65535?xe.push(it):(it-=65536,Oe=(it>>10)+55296,dt=it%1024+56320,xe.push(Oe,dt)),(nt+1===Tt||xe.length>k)&&(Ir+=g.apply(null,xe),xe.length=0)}return Ir};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:C,configurable:!0,writable:!0}):String.fromCodePoint=C})(),e},fO=u6();var kp=`The output should be formatted as a XML file.
|
|
291
|
+
1. Output should conform to the tags below.
|
|
292
|
+
2. If tags are not given, make them on your own.
|
|
293
|
+
3. Remember to always open and close all the tags.
|
|
294
|
+
|
|
295
|
+
As an example, for the tags ["foo", "bar", "baz"]:
|
|
296
|
+
1. String "<foo>
|
|
297
|
+
<bar>
|
|
298
|
+
<baz></baz>
|
|
299
|
+
</bar>
|
|
300
|
+
</foo>" is a well-formatted instance of the schema.
|
|
301
|
+
2. String "<foo>
|
|
302
|
+
<bar>
|
|
303
|
+
</foo>" is a badly-formatted instance.
|
|
304
|
+
3. String "<foo>
|
|
305
|
+
<tag>
|
|
306
|
+
</tag>
|
|
307
|
+
</foo>" is a badly-formatted instance.
|
|
308
|
+
|
|
309
|
+
Here are the output tags:
|
|
310
|
+
\`\`\`
|
|
311
|
+
{tags}
|
|
312
|
+
\`\`\``,pO=class extends Fn{tags;constructor(e){super(e),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}lc_namespace=["langchain_core","output_parsers"];lc_serializable=!0;_diff(e,t){if(t)return e?Mi(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return $p(e[0].text)}async parse(e){return $p(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?kp.replace("{tags}",this.tags?.join(", ")??""):kp}},l6=e=>e.split(`
|
|
313
|
+
`).map(t=>t.replace(/^\s+/,"")).join(`
|
|
314
|
+
`).trim(),mO=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(mO),t):(t[e.name]=e.text??void 0,t)};function $p(e){let t=l6(e),r=fO.parser(!0),i={},n=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};n.length>0?n[n.length-1].children.push(c):i=c,s.isSelfClosing||n.push(c)},r.onclosetag=()=>{if(n.length>0){let s=n.pop();n.length===0&&s&&(i=s)}},r.ontext=s=>{if(n.length>0){let c=n[n.length-1];c.text+=s}},r.onattribute=s=>{if(n.length>0){let c=n[n.length-1];c.attributes[s.name]=s.value}};let a=/```(xml)?(.*)```/s.exec(t),o=a?a[2]:t;return r.write(o).close(),i&&i.name==="?xml"&&(i=i.children[0]),mO(i)}var hO=E({AsymmetricStructuredOutputParser:()=>dO,BaseCumulativeTransformOutputParser:()=>Fn,BaseLLMOutputParser:()=>zs,BaseOutputParser:()=>sn,BaseTransformOutputParser:()=>pi,BytesOutputParser:()=>aO,CommaSeparatedListOutputParser:()=>oO,CustomListOutputParser:()=>sO,JsonMarkdownStructuredOutputParser:()=>pw,JsonOutputParser:()=>xp,ListOutputParser:()=>Ds,MarkdownListOutputParser:()=>uO,NumberedListOutputParser:()=>cO,OutputParserException:()=>jt,StandardSchemaOutputParser:()=>Sp,StringOutputParser:()=>lO,StructuredOutputParser:()=>xu,XMLOutputParser:()=>pO,XML_FORMAT_INSTRUCTIONS:()=>kp,parseJsonMarkdown:()=>ba,parsePartialJson:()=>$n,parseXMLMarkdown:()=>$p});var gO=E({extendInteropZodObject:()=>Jf,getInteropZodDefaultGetter:()=>Kf,getInteropZodObjectShape:()=>Ka,getSchemaDescription:()=>si,interopParse:()=>ks,interopParseAsync:()=>Wi,interopSafeParse:()=>qT,interopSafeParseAsync:()=>Hf,interopZodObjectMakeFieldsOptional:()=>YT,interopZodObjectPartial:()=>Is,interopZodObjectPassthrough:()=>Gf,interopZodObjectStrict:()=>Ss,interopZodTransformInputSchema:()=>Wf,isInteropZodError:()=>qf,isInteropZodLiteral:()=>WT,isInteropZodObject:()=>qt,isInteropZodSchema:()=>sr,isShapelessZodSchema:()=>XT,isSimpleStringZodSchema:()=>$s,isZodArrayV4:()=>lu,isZodLiteralV3:()=>Pb,isZodLiteralV4:()=>Nb,isZodNullableV4:()=>jb,isZodObjectV3:()=>uu,isZodObjectV4:()=>jr,isZodOptionalV4:()=>Rb,isZodSchema:()=>KT,isZodSchemaV3:()=>tt,isZodSchemaV4:()=>De});function mw(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=$n(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(n){throw new jt([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${n.message}`].join(`
|
|
315
|
+
`))}let i={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(i.id=e.id),i}function _O(e){if(e.id===void 0)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function yO(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var hw=class extends Fn{static lc_name(){return"JsonOutputToolsParser"}returnId=!1;lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let r=e[0].message,i;if(Lo(r)&&r.tool_calls?.length?i=r.tool_calls.map(a=>{let{id:o,...s}=a;return this.returnId?{id:o,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(i=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(a=>mw(a,{returnId:this.returnId,partial:t}))),!i)return[];let n=[];for(let a of i)if(a!==void 0){let o={type:a.name,args:a.args,id:a.id};n.push(o)}return n}},Ip=class extends hw{static lc_name(){return"JsonOutputKeyToolsParser"}lc_namespace=["langchain","output_parsers","openai_tools"];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,"zodSchema"in e&&(this.zodSchema=e.zodSchema),"serializableSchema"in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let r=await this.serializableSchema["~standard"].validate(e);if(r.issues)throw new jt(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(r.issues)}`,JSON.stringify(e,null,2));return r.value}if(this.zodSchema===void 0)return e;let t=await Hf(this.zodSchema,e);if(t.success)return t.data;throw new jt(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(i=>i.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(i=>i.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(i=>this._validateResult(i)))}};var vO=E({assembleStructuredOutputPipeline:()=>gw,createContentParser:()=>d6,createFunctionCallingParser:()=>f6});function d6(e){return sr(e)?xu.fromZodSchema(e):Ma(e)?Sp.fromSerializableSchema(e):new xp}function f6(e,t,r){let i=r??Ip;return sr(e)?new i({returnSingle:!0,keyName:t,zodSchema:e}):Ma(e)?new i({returnSingle:!0,keyName:t,serializableSchema:e}):new i({returnSingle:!0,keyName:t})}function gw(e,t,r,i){if(!r){let c=e.pipe(t);return i?c.withConfig({runName:i}):c}let n=fi.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),a=fi.assign({parsed:()=>null}),o=n.withFallbacks({fallbacks:[a]}),s=kr.from([{raw:e},o]);return i?s.withConfig({runName:i}):s}var bO=e=>e();function Ep(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var wO=E({BaseChatModel:()=>ta,SimpleChatModel:()=>p6});function _w(e){let t=[];for(let r of e){let i=r;if(Array.isArray(r.content))for(let n=0;n<r.content.length;n++){let a=r.content[n];(jo(a)||Mo(a))&&i===r&&(i=new r.constructor({...i,content:[...r.content.slice(0,n),Ml(a),...r.content.slice(n+1)]}))}t.push(i)}return t}var ta=class mo extends wu{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=bO(()=>{let r=t.outputVersion??Ft("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async invoke(t,r){let i=mo._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}async*_streamIterator(t,r){if(this._streamResponseChunks===mo.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let i=mo._convertInputToPromptValue(t).toChatMessages(),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o={...n.metadata,...this.getLsParamsWithDefaults(a)},s=await ot.configure(n.callbacks,this.callbacks,n.tags,this.tags,o,this.metadata,{verbose:this.verbose}),c={options:a,invocation_params:this?.invocationParams(a),batch_size:1},u=a.outputVersion??this.outputVersion,l=await s?.handleChatModelStart(this.toJSON(),[_w(i)],n.runId,void 0,c,void 0,void 0,n.runName),d,f;try{for await(let p of this._streamResponseChunks(i,a,l?.[0])){if(a.signal?.throwIfAborted(),p.message.id==null){let m=l?.at(0)?.runId;m!=null&&p.message._updateId(`run-${m}`)}p.message.response_metadata={...p.generationInfo,...p.message.response_metadata},u==="v1"?yield Ep(p.message):yield p.message,d?d=d.concat(p):d=p,$c(p.message)&&p.message.usage_metadata!==void 0&&(f={tokenUsage:{promptTokens:p.message.usage_metadata.input_tokens,completionTokens:p.message.usage_metadata.output_tokens,totalTokens:p.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(p){throw await Promise.all((l??[]).map(m=>m?.handleLLMError(p))),p}await Promise.all((l??[]).map(p=>p?.handleLLMEnd({generations:[[d]],llmOutput:f})))}}getLsParams(t){let r=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:r}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,r,i,n){let a=t.map(d=>d.map(St)),o;if(n!==void 0&&n.length===a.length)o=n;else{let d={...i.metadata,...this.getLsParamsWithDefaults(r)},f=await ot.configure(i.callbacks,this.callbacks,i.tags,this.tags,d,this.metadata,{verbose:this.verbose}),p={options:r,invocation_params:this?.invocationParams(r),batch_size:1};o=await f?.handleChatModelStart(this.toJSON(),a.map(_w),i.runId,void 0,p,void 0,void 0,i.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[];if(o?.[0].handlers.find(Ec)&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==mo.prototype._streamResponseChunks)try{let d=await this._streamResponseChunks(a[0],r,o?.[0]),f,p;for await(let m of d){if(r.signal?.aborted){let _=f?.message;throw new Rl("Model invocation was aborted.",_)}if(m.message.id==null){let _=o?.at(0)?.runId;_!=null&&m.message._updateId(`run-${_}`)}f===void 0?f=m:f=vr(f,m),$c(m.message)&&m.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}if(r.signal?.aborted){let m=f?.message;throw new Rl("Model invocation was aborted.",m)}if(f===void 0)throw new Error("Received empty response from chat model call.");c.push([f]),await o?.[0].handleLLMEnd({generations:c,llmOutput:p})}catch(d){throw await o?.[0].handleLLMError(d),d}else{let d=await Promise.allSettled(a.map(async(f,p)=>{let m=await this._generate(f,{...r,promptIndex:p},o?.[p]);if(s==="v1")for(let _ of m.generations)_.message=Ep(_.message);return m}));await Promise.all(d.map(async(f,p)=>{if(f.status==="fulfilled"){let m=f.value;for(let _ of m.generations){if(_.message.id==null){let v=o?.at(0)?.runId;v!=null&&_.message._updateId(`run-${v}`)}_.message.response_metadata={..._.generationInfo,..._.message.response_metadata}}return m.generations.length===1&&(m.generations[0].message.response_metadata={...m.llmOutput,...m.generations[0].message.response_metadata}),c[p]=m.generations,u[p]=m.llmOutput,o?.[p]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await o?.[p]?.handleLLMError(f.reason),Promise.reject(f.reason)}))}let l={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(l,ja,{value:o?{runIds:o?.map(d=>d.runId)}:void 0,configurable:!0}),l}async _generateCached({messages:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a}){let o=t.map(v=>v.map(St)),s={...a.metadata,...this.getLsParamsWithDefaults(n)},c=await ot.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose}),u={options:n,invocation_params:this?.invocationParams(n),batch_size:1},l=await c?.handleChatModelStart(this.toJSON(),o.map(_w),a.runId,void 0,u,void 0,void 0,a.runName),d=[],f=(await Promise.allSettled(o.map(async(v,x)=>{let w=mo._convertInputToPromptValue(v).toString(),S=await r.lookup(w,i);return S==null&&d.push(x),S}))).map((v,x)=>({result:v,runManager:l?.[x]})).filter(({result:v})=>v.status==="fulfilled"&&v.value!=null||v.status==="rejected"),p=n.outputVersion??this.outputVersion,m=[];await Promise.all(f.map(async({result:v,runManager:x},w)=>{if(v.status==="fulfilled"){let S=v.value;return m[w]=S.map($=>("message"in $&&Je($.message)&&Lo($.message)&&($.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},p==="v1"&&($.message=Ep($.message))),$.generationInfo={...$.generationInfo,tokenUsage:{}},$)),S.length&&await x?.handleLLMNewToken(S[0].text),x?.handleLLMEnd({generations:[S]},void 0,void 0,void 0,{cached:!0})}else return await x?.handleLLMError(v.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(v.reason)}));let _={generations:m,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(_,ja,{value:l?{runIds:l?.map(v=>v.runId)}:void 0,configurable:!0}),_}async generate(t,r,i){let n;Array.isArray(r)?n={stop:r}:n=r;let a=t.map(m=>m.map(St)),[o,s]=this._separateRunnableConfigFromCallOptionsCompat(n);if(o.callbacks=o.callbacks??i,!this.cache)return this._generateUncached(a,s,o);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(s),{generations:l,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:a,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:o}),p={};if(d.length>0){let m=await this._generateUncached(d.map(_=>a[_]),s,o,f!==void 0?d.map(_=>f?.[_]):void 0);await Promise.all(m.generations.map(async(_,v)=>{let x=d[v];l[x]=_;let w=mo._convertInputToPromptValue(a[x]).toString();return c.update(w,u,_)})),p=m.llmOutput??{}}return{generations:l,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,i){let n=t.map(a=>a.toChatMessages());return this.generate(n,r,i)}withStructuredOutput(t,r){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(r?.strict)throw new Error('"strict" mode is not supported for this model by default.');let i=t,n=r?.name,a=si(i)??"A function available to call.",o=r?.method,s=r?.includeRaw;if(o==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=n??"extract";!sr(i)&&!Ma(i)&&"name"in i&&(c=i.name);let u=sr(i)||Ma(i)?ht(i):i,l=[{type:"function",function:{name:c,description:a,parameters:u}}];return gw(this.bindTools(l),Rt.from(d=>{if(!mt.isInstance(d))throw new Error("Input is not an AIMessageChunk.");if(!d.tool_calls||d.tool_calls.length===0)throw new Error("No tool calls found in the response.");let f=d.tool_calls.find(p=>p.name===c);if(!f)throw new Error(`No tool call found with name ${c}.`);return f.args}),s,s?"StructuredOutputRunnable":"StructuredOutput")}},p6=class extends ta{async _generate(e,t,r){let i=new Ee(await this._call(e,t,r));if(typeof i.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}};var xO=E({BaseLLM:()=>SO,LLM:()=>Tp}),SO=class Su extends wu{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let i=Su._convertInputToPromptValue(t);return(await this.generatePrompt([i],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,i){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,i]=super._separateRunnableConfigFromCallOptions(t);return i.signal=r.signal,[r,i]}async*_streamIterator(t,r){if(this._streamResponseChunks===Su.prototype._streamResponseChunks)yield this.invoke(t,r);else{let i=Su._convertInputToPromptValue(t),[n,a]=this._separateRunnableConfigFromCallOptionsCompat(r),o=await ot.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose}),s={options:a,invocation_params:this?.invocationParams(a),batch_size:1},c=await o?.handleLLMStart(this.toJSON(),[i.toString()],n.runId,void 0,s,void 0,void 0,n.runName),u=new ri({text:""});try{for await(let l of this._streamResponseChunks(i.toString(),a,c?.[0]))u?u=u.concat(l):u=l,typeof l.text=="string"&&(yield l.text)}catch(l){throw await Promise.all((c??[]).map(d=>d?.handleLLMError(l))),l}await Promise.all((c??[]).map(l=>l?.handleLLMEnd({generations:[[u]]})))}}async generatePrompt(t,r,i){let n=t.map(a=>a.toString());return this.generate(n,r,i)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let i=0;i<t.generations.length;i+=1){let n=t.generations[i];if(i===0)r.push({generations:[n],llmOutput:t.llmOutput});else{let a=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[n],llmOutput:a})}}return r}async _generateUncached(t,r,i,n){let a;if(n!==void 0&&n.length===t.length)a=n;else{let u=await ot.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose}),l={options:r,invocation_params:this?.invocationParams(r),batch_size:t.length};a=await u?.handleLLMStart(this.toJSON(),t,i.runId,void 0,l,void 0,void 0,i?.runName)}let o=!!a?.[0].handlers.find(Ec),s;if(o&&t.length===1&&this._streamResponseChunks!==Su.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,a?.[0]),l;for await(let d of u)l===void 0?l=d:l=vr(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[l]],llmOutput:{}},await a?.[0].handleLLMEnd(s)}catch(u){throw await a?.[0].handleLLMError(u),u}else{try{s=await this._generate(t,r,a?.[0])}catch(l){throw await Promise.all((a??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(s);await Promise.all((a??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=a?.map(u=>u.runId)||void 0;return Object.defineProperty(s,ja,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:i,parsedOptions:n,handledOptions:a,runId:o}){let s=await ot.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),c={options:n,invocation_params:this?.invocationParams(n),batch_size:t.length},u=await s?.handleLLMStart(this.toJSON(),t,o,void 0,c,void 0,void 0,a?.runName),l=[],d=(await Promise.allSettled(t.map(async(m,_)=>{let v=await r.lookup(m,i);return v==null&&l.push(_),v}))).map((m,_)=>({result:m,runManager:u?.[_]})).filter(({result:m})=>m.status==="fulfilled"&&m.value!=null||m.status==="rejected"),f=[];await Promise.all(d.map(async({result:m,runManager:_},v)=>{if(m.status==="fulfilled"){let x=m.value;return f[v]=x.map(w=>(w.generationInfo={...w.generationInfo,tokenUsage:{}},w)),x.length&&await _?.handleLLMNewToken(x[0].text),_?.handleLLMEnd({generations:[x]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(m.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(m.reason)}));let p={generations:f,missingPromptIndices:l,startedRunManagers:u};return Object.defineProperty(p,ja,{value:u?{runIds:u?.map(m=>m.runId)}:void 0,configurable:!0}),p}async generate(t,r,i){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let n;Array.isArray(r)?n={stop:r}:n=r;let[a,o]=this._separateRunnableConfigFromCallOptionsCompat(n);if(a.callbacks=a.callbacks??i,!this.cache)return this._generateUncached(t,o,a);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(o),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:o,handledOptions:a,runId:a.runId}),f={};if(l.length>0){let p=await this._generateUncached(l.map(m=>t[m]),o,a,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,_)=>{let v=l[_];return u[v]=m,s.update(t[v],c,m)})),f=p.llmOutput??{}}return{generations:u,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},Tp=class extends SO{async _generate(e,t,r){return{generations:await Promise.all(e.map((i,n)=>this._call(i,{...t,promptIndex:n},r).then(a=>[{text:a}])))}}};var kO=E({});var $O=E({BaseMemory:()=>m6,getInputValue:()=>h6,getOutputValue:()=>g6,getPromptInputKey:()=>_6}),m6=class{},IO=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},h6=(e,t)=>{let r=IO(e,t);if(!r)throw new Error(`input values have ${Object.keys(e).length} keys, you must specify an input key or pass only 1 key as input`);return r},g6=(e,t)=>{let r=IO(e,t);if(!r&&r!=="")throw new Error(`output values have ${Object.keys(e).length} keys, you must specify an output key or pass only 1 key as output`);return r};function _6(e,t){let r=Object.keys(e).filter(i=>!t.includes(i)&&i!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var yw=class extends zs{static lc_name(){return"OutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;argsOnly=!0;constructor(e){super(),this.argsOnly=e?.argsOnly??this.argsOnly}async parseResult(e){if("message"in e[0]){let t=e[0].message.additional_kwargs.function_call;if(!t)throw new Error(`No function_call in message ${JSON.stringify(e)}`);if(!t.arguments)throw new Error(`No arguments in function_call ${JSON.stringify(e)}`);return this.argsOnly?t.arguments:JSON.stringify(t)}else throw new Error(`No message in generations ${JSON.stringify(e)}`)}},vw=class extends Fn{static lc_name(){return"JsonOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser;argsOnly=!0;constructor(e){super(e),this.argsOnly=e?.argsOnly??this.argsOnly,this.outputParser=new yw(e)}_diff(e,t){if(t)return Mi(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,i=r.additional_kwargs.function_call;if(i)return this.argsOnly?$n(i.arguments):{...i,arguments:$n(i.arguments)}}async parseResult(e){let t=await this.outputParser.parseResult(e);if(!t)throw new Error(`No result from "OutputFunctionsParser" ${JSON.stringify(e)}`);return this.parse(t)}async parse(e){let t=JSON.parse(e);return this.argsOnly||(t.arguments=JSON.parse(t.arguments)),t}getFormatInstructions(){return""}},EO=class extends zs{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new vw;attrName;get lc_aliases(){return{attrName:"key_name"}}constructor(e){super(e),this.attrName=e.attrName}async parseResult(e){return(await this.outputParser.parseResult(e))[this.attrName]}};var TO=E({JsonKeyOutputFunctionsParser:()=>EO,JsonOutputFunctionsParser:()=>vw,OutputFunctionsParser:()=>yw});var AO=E({JsonOutputKeyToolsParser:()=>Ip,JsonOutputToolsParser:()=>hw,convertLangChainToolCallToOpenAI:()=>_O,makeInvalidToolCall:()=>yO,parseToolCall:()=>mw});var Bn=class extends re{lc_serializable=!0;lc_namespace=["langchain_core","prompts",this._getPromptType()];get lc_attributes(){return{partialVariables:void 0}}inputVariables;outputParser;partialVariables;metadata;tags;constructor(e){super(e);let{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){let t=this.partialVariables??{},r={};for(let[i,n]of Object.entries(t))typeof n=="string"?r[i]=n:r[i]=await n();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},i=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(n=>this.formatPromptValue(n),e,{...t,tags:i,metadata:r,runType:"prompt"})}};var mi=class extends Bn{async formatPromptValue(e){return new vu(await this.format(e))}};var y6=Object.prototype.toString,Ls=Array.isArray||function(t){return y6.call(t)==="[object Array]"};function ww(e){return typeof e=="function"}function v6(e){return Ls(e)?"array":typeof e}function bw(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function CO(e,t){return e!=null&&typeof e=="object"&&t in e}function b6(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var w6=RegExp.prototype.test;function x6(e,t){return w6.call(e,t)}var S6=/\S/;function k6(e){return!x6(S6,e)}var $6={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function I6(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return $6[r]})}var E6=/\s*/,T6=/\s+/,OO=/\s*=/,A6=/\s*\}/,C6=/#|\^|\/|>|\{|&|=|!/;function O6(e,t){if(!e)return[];var r=!1,i=[],n=[],a=[],o=!1,s=!1,c="",u=0;function l(){if(o&&!s)for(;a.length;)delete n[a.pop()];else a=[];o=!1,s=!1}var d,f,p;function m(y){if(typeof y=="string"&&(y=y.split(T6,2)),!Ls(y)||y.length!==2)throw new Error("Invalid tags: "+y);d=new RegExp(bw(y[0])+"\\s*"),f=new RegExp("\\s*"+bw(y[1])),p=new RegExp("\\s*"+bw("}"+y[1]))}m(t||Fr.tags);for(var _=new $u(e),v,x,w,S,$,T;!_.eos();){if(v=_.pos,w=_.scanUntil(d),w)for(var F=0,A=w.length;F<A;++F)S=w.charAt(F),k6(S)?(a.push(n.length),c+=S):(s=!0,r=!0,c+=" "),n.push(["text",S,v,v+1]),v+=1,S===`
|
|
316
|
+
`&&(l(),c="",u=0,r=!1);if(!_.scan(d))break;if(o=!0,x=_.scan(C6)||"name",_.scan(E6),x==="="?(w=_.scanUntil(OO),_.scan(OO),_.scanUntil(f)):x==="{"?(w=_.scanUntil(p),_.scan(A6),_.scanUntil(f),x="&"):w=_.scanUntil(f),!_.scan(f))throw new Error("Unclosed tag at "+_.pos);if(x==">"?$=[x,w,v,_.pos,c,u,r]:$=[x,w,v,_.pos],u++,n.push($),x==="#"||x==="^")i.push($);else if(x==="/"){if(T=i.pop(),!T)throw new Error('Unopened section "'+w+'" at '+v);if(T[1]!==w)throw new Error('Unclosed section "'+T[1]+'" at '+v)}else x==="name"||x==="{"||x==="&"?s=!0:x==="="&&m(w)}if(l(),T=i.pop(),T)throw new Error('Unclosed section "'+T[1]+'" at '+_.pos);return N6(P6(n))}function P6(e){for(var t=[],r,i,n=0,a=e.length;n<a;++n)r=e[n],r&&(r[0]==="text"&&i&&i[0]==="text"?(i[1]+=r[1],i[3]=r[3]):(t.push(r),i=r));return t}function N6(e){for(var t=[],r=t,i=[],n,a,o=0,s=e.length;o<s;++o)switch(n=e[o],n[0]){case"#":case"^":r.push(n),i.push(n),r=n[4]=[];break;case"/":a=i.pop(),a[5]=n[2],r=i.length>0?i[i.length-1][4]:t;break;default:r.push(n)}return t}function $u(e){this.string=e,this.tail=e,this.pos=0}$u.prototype.eos=function(){return this.tail===""};$u.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};$u.prototype.scanUntil=function(t){var r=this.tail.search(t),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function Us(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Us.prototype.push=function(t){return new Us(t,this)};Us.prototype.lookup=function(t){var r=this.cache,i;if(r.hasOwnProperty(t))i=r[t];else{for(var n=this,a,o,s,c=!1;n;){if(t.indexOf(".")>0)for(a=n.view,o=t.split("."),s=0;a!=null&&s<o.length;)s===o.length-1&&(c=CO(a,o[s])||b6(a,o[s])),a=a[o[s++]];else a=n.view[t],c=CO(n.view,t);if(c){i=a;break}n=n.parent}r[t]=i}return ww(i)&&(i=i.call(this.view)),i};function Yt(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}Yt.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};Yt.prototype.parse=function(t,r){var i=this.templateCache,n=t+":"+(r||Fr.tags).join(":"),a=typeof i<"u",o=a?i.get(n):void 0;return o==null&&(o=O6(t,r),a&&i.set(n,o)),o};Yt.prototype.render=function(t,r,i,n){var a=this.getConfigTags(n),o=this.parse(t,a),s=r instanceof Us?r:new Us(r,void 0);return this.renderTokens(o,s,i,t,n)};Yt.prototype.renderTokens=function(t,r,i,n,a){for(var o="",s,c,u,l=0,d=t.length;l<d;++l)u=void 0,s=t[l],c=s[0],c==="#"?u=this.renderSection(s,r,i,n,a):c==="^"?u=this.renderInverted(s,r,i,n,a):c===">"?u=this.renderPartial(s,r,i,a):c==="&"?u=this.unescapedValue(s,r):c==="name"?u=this.escapedValue(s,r,a):c==="text"&&(u=this.rawValue(s)),u!==void 0&&(o+=u);return o};Yt.prototype.renderSection=function(t,r,i,n,a){var o=this,s="",c=r.lookup(t[1]);function u(f){return o.render(f,r,i,a)}if(c){if(Ls(c))for(var l=0,d=c.length;l<d;++l)s+=this.renderTokens(t[4],r.push(c[l]),i,n,a);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),i,n,a);else if(ww(c)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,n.slice(t[3],t[5]),u),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,i,n,a);return s}};Yt.prototype.renderInverted=function(t,r,i,n,a){var o=r.lookup(t[1]);if(!o||Ls(o)&&o.length===0)return this.renderTokens(t[4],r,i,n,a)};Yt.prototype.indentPartial=function(t,r,i){for(var n=r.replace(/[^ \t]/g,""),a=t.split(`
|
|
317
|
+
`),o=0;o<a.length;o++)a[o].length&&(o>0||!i)&&(a[o]=n+a[o]);return a.join(`
|
|
318
|
+
`)};Yt.prototype.renderPartial=function(t,r,i,n){if(i){var a=this.getConfigTags(n),o=ww(i)?i(t[1]):i[t[1]];if(o!=null){var s=t[6],c=t[5],u=t[4],l=o;c==0&&u&&(l=this.indentPartial(o,u,s));var d=this.parse(l,a);return this.renderTokens(d,r,i,l,n)}}};Yt.prototype.unescapedValue=function(t,r){var i=r.lookup(t[1]);if(i!=null)return i};Yt.prototype.escapedValue=function(t,r,i){var n=this.getConfigEscape(i)||Fr.escape,a=r.lookup(t[1]);if(a!=null)return typeof a=="number"&&n===Fr.escape?String(a):n(a)};Yt.prototype.rawValue=function(t){return t[1]};Yt.prototype.getConfigTags=function(t){return Ls(t)?t:t&&typeof t=="object"?t.tags:void 0};Yt.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Ls(t))return t.escape};var Fr={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){ku.templateCache=e},get templateCache(){return ku.templateCache}},ku=new Yt;Fr.clearCache=function(){return ku.clearCache()};Fr.parse=function(t,r){return ku.parse(t,r)};Fr.render=function(t,r,i,n){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+v6(t)+'" was given as the first argument for mustache#render(template, view, partials)');return ku.render(t,r,i,n)};Fr.escape=I6;Fr.Scanner=$u;Fr.Context=Us;Fr.Writer=Yt;var Ap=Fr;function PO(){Ap.escape=e=>e}var ho=e=>{let t=e.split(""),r=[],i=(a,o)=>{for(let s=o;s<t.length;s+=1)if(a.includes(t[s]))return s;return-1},n=0;for(;n<t.length;)if(t[n]==="{"&&n+1<t.length&&t[n+1]==="{")r.push({type:"literal",text:"{"}),n+=2;else if(t[n]==="}"&&n+1<t.length&&t[n+1]==="}")r.push({type:"literal",text:"}"}),n+=2;else if(t[n]==="{"){let a=i("}",n);if(a<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(n+1,a).join("")}),n=a+1}else{if(t[n]==="}")throw new Error("Single '}' in template.");{let a=i("{}",n),o=(a<0?t.slice(n):t.slice(n,a)).join("");r.push({type:"literal",text:o}),n=a<0?t.length:a}}return r},NO=(e,t=[])=>{let r=[];for(let i of e)if(i[0]==="name"){let n=i[1].includes(".")?i[1].split(".")[0]:i[1];r.push({type:"variable",name:n})}else if(["#","&","^",">"].includes(i[0])){if(r.push({type:"variable",name:i[1]}),i[0]==="#"&&i.length>4&&Array.isArray(i[4])){let n=[...t,i[1]],a=NO(i[4],n);r.push(...a)}}else r.push({type:"literal",text:i[1]});return r},Fs=e=>(PO(),NO(Ap.parse(e))),xw=(e,t)=>ho(e).reduce((r,i)=>{if(i.type==="variable"){if(i.name in t)return r+(typeof t[i.name]=="string"?t[i.name]:JSON.stringify(t[i.name]));throw new Error(`(f-string) Missing value for input ${i.name}`)}return r+i.text},""),Sw=(e,t)=>(PO(),Ap.render(e,t)),Iu={"f-string":xw,mustache:Sw},kw={"f-string":ho,mustache:Fs},Mt=(e,t,r)=>{try{return Iu[t](e,r)}catch(i){throw Yn(i,"INVALID_PROMPT_INPUT")}},go=(e,t)=>kw[t](e),hi=(e,t,r)=>{if(!(t in Iu))throw new Error(`Invalid template format. Got \`${t}\`;
|
|
319
|
+
should be one of ${Object.keys(Iu)}`);try{let i=Object.fromEntries(r.map(n=>[n,"foo"]));Array.isArray(e)?e.forEach(n=>{if(n.type==="text"&&"text"in n&&typeof n.text=="string")Mt(n.text,t,i);else if(n.type==="image_url"){if(typeof n.image_url=="string")Mt(n.image_url,t,i);else if(typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"){let a=n.image_url.url;Mt(a,t,i)}}else throw new Error(`Invalid message template received. ${JSON.stringify(n,null,2)}`)}):Mt(e,t,i)}catch(i){throw new Error(`Invalid prompt schema: ${i.message}`)}};var cn=class Eu extends mi{static lc_name(){return"PromptTemplate"}template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){if(this.templateFormat==="mustache")throw new Error("Mustache templates cannot be validated.");let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),hi(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return Mt(this.template,this.templateFormat,r)}static fromExamples(t,r,i,n=`
|
|
320
|
+
|
|
321
|
+
`,a=""){return new Eu({inputVariables:i,template:[a,...t,r].join(n)})}static fromTemplate(t,r){let{templateFormat:i="f-string",...n}=r??{},a=new Set;return go(t,i).forEach(o=>{o.type==="variable"&&a.add(o.name)}),new Eu({inputVariables:[...a],templateFormat:i,template:t,...n})}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Eu({...this,inputVariables:r,partialVariables:i})}serialize(){if(this.outputParser!==void 0)throw new Error("Cannot serialize a prompt template with an output parser");return{_type:this._getPromptType(),input_variables:this.inputVariables,template:this.template,template_format:this.templateFormat}}static async deserialize(t){if(!t.template)throw new Error("Prompt template must have a template");return new Eu({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var Bs=class RO extends Bn{static lc_name(){return"ImagePromptTemplate"}lc_namespace=["langchain_core","prompts","image"];template;templateFormat="f-string";validateTemplate=!0;additionalContentFields;constructor(t){if(super(t),this.template=t.template,this.templateFormat=t.templateFormat??this.templateFormat,this.validateTemplate=t.validateTemplate??this.validateTemplate,this.additionalContentFields=t.additionalContentFields,this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),hi([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new RO({...this,inputVariables:r,partialVariables:i})}async format(t){let r={};for(let[o,s]of Object.entries(this.template))typeof s=="string"?r[o]=Mt(s,this.templateFormat,t):r[o]=s;let i=t.url||r.url,n=t.detail||r.detail;if(!i)throw new Error("Must provide either an image URL.");if(typeof i!="string")throw new Error("url must be a string.");let a={url:i};return n&&(a.detail=n),a}async formatPromptValue(t){return new uw(await this.format(t))}};var Tu=class extends re{lc_namespace=["langchain_core","prompts","dict"];lc_serializable=!0;template;templateFormat;inputVariables;static lc_name(){return"DictPromptTemplate"}constructor(e){let t=e.templateFormat??"f-string",r=$w(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return Iw(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function $w(e,t){let r=[];for(let i of Object.values(e))if(typeof i=="string")go(i,t).forEach(n=>{n.type==="variable"&&r.push(n.name)});else if(Array.isArray(i))for(let n of i)typeof n=="string"?go(n,t).forEach(a=>{a.type==="variable"&&r.push(a.name)}):typeof n=="object"&&r.push(...$w(n,t));else typeof i=="object"&&i!==null&&r.push(...$w(i,t));return Array.from(new Set(r))}function Iw(e,t,r){let i={};for(let[n,a]of Object.entries(e))if(typeof a=="string")i[n]=Mt(a,r,t);else if(Array.isArray(a)){let o=[];for(let s of a)typeof s=="string"?o.push(Mt(s,r,t)):typeof s=="object"&&o.push(Iw(s,t,r));i[n]=o}else typeof a=="object"&&a!==null?i[n]=Iw(a,t,r):i[n]=a;return i}var Au=class extends re{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},Op=class extends Au{static lc_name(){return"MessagesPlaceholder"}variableName;optional;constructor(e){typeof e=="string"&&(e={variableName:e}),super(e),this.variableName=e.variableName,this.optional=e.optional??!1}get inputVariables(){return[this.variableName]}async formatMessages(e){let t=e[this.variableName];if(this.optional&&!t)return[];if(!t){let i=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw i.name="InputFormatError",i}let r;try{Array.isArray(t)?r=t.map(St):r=[St(t)]}catch(i){let n=typeof t=="string"?t:JSON.stringify(t,null,2),a=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${n}`,`Additional message: ${i.message}`].join(`
|
|
322
|
+
|
|
323
|
+
`));throw a.name="InputFormatError",a.lc_error_code=i.lc_error_code,a}return r}},Ew=class extends Au{prompt;constructor(e){"prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt}get inputVariables(){return this.prompt.inputVariables}async formatMessages(e){return[await this.format(e)]}},Cu=class extends Bn{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new bu(await this.formatMessages(e))}},Tw=class extends Ew{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new qr(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(cn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function R6(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function j6(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:"image_url"in e&&(typeof e.image_url=="string"||typeof e.image_url=="object"&&e.image_url!==null&&"url"in e.image_url&&typeof e.image_url.url=="string")}var Aw=class extends Au{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;inputVariables=[];additionalOptions={};prompt;messageClass;static _messageClass(){throw new Error("Can not invoke _messageClass from inside _StringImageMessagePromptTemplate")}chatMessageClass;constructor(e,t){if("prompt"in e||(e={prompt:e}),super(e),this.prompt=e.prompt,Array.isArray(this.prompt)){let r=[];this.prompt.forEach(i=>{"inputVariables"in i&&(r=r.concat(i.inputVariables))}),this.inputVariables=r}else this.inputVariables=this.prompt.inputVariables;this.additionalOptions=t??this.additionalOptions}createMessage(e){let t=this.constructor;if(t._messageClass())return new(t._messageClass())({content:e});if(t.chatMessageClass){let r=t.chatMessageClass();return new r({content:e,role:this.getRoleFromMessageClass(r.lc_name())})}else throw new Error("No message class defined")}getRoleFromMessageClass(e){switch(e){case"HumanMessage":return"human";case"AIMessage":return"ai";case"SystemMessage":return"system";case"ChatMessage":return"chat";default:throw new Error("Invalid message class name")}}static fromTemplate(e,t){if(typeof e=="string")return new this(cn.fromTemplate(e,t));let r=[];for(let i of e)if(typeof i=="string")r.push(cn.fromTemplate(i,t));else if(i!==null)if(R6(i)){let n="";typeof i.text=="string"&&(n=i.text??"");let a={...t,additionalContentFields:i};r.push(cn.fromTemplate(n,a))}else if(j6(i)){let n=i.image_url??"",a,o=[];if(typeof n=="string"){let s;t?.templateFormat==="mustache"?s=Fs(n):s=ho(n);let c=s.flatMap(u=>u.type==="variable"?[u.name]:[]);if((c?.length??0)>0){if(c.length>1)throw new Error(`Only one format variable allowed per image template.
|
|
324
|
+
Got: ${c}
|
|
325
|
+
From: ${n}`);o=[c[0]]}else o=[];n={url:n},a=new Bs({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else if(typeof n=="object"){if("url"in n){let s;t?.templateFormat==="mustache"?s=Fs(n.url):s=ho(n.url),o=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else o=[];a=new Bs({template:n,inputVariables:o,templateFormat:t?.templateFormat,additionalContentFields:i})}else throw new Error("Invalid image template");r.push(a)}else typeof i=="object"&&r.push(new Tu({template:i,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof mi){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let i={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let n of r.inputVariables)i||(i={[n]:e[n]}),i={...i,[n]:e[n]};if(r instanceof mi){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),n!==""&&t.push({...a,type:"text",text:n})}else if(r instanceof Bs){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,type:"image_url",image_url:n})}else if(r instanceof Tu){let n=await r.format(i),a;"additionalContentFields"in r&&(a=r.additionalContentFields),t.push({...a,...n})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},Pp=class extends Aw{static _messageClass(){return Ye}static lc_name(){return"HumanMessagePromptTemplate"}},Cw=class extends Aw{static _messageClass(){return Ee}static lc_name(){return"AIMessagePromptTemplate"}},Ow=class extends Aw{static _messageClass(){return Vt}static lc_name(){return"SystemMessagePromptTemplate"}};function M6(e){return typeof e.formatMessages=="function"}function z6(e,t){if(M6(e)||Je(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let n=e[1];if(t?.templateFormat==="mustache"&&typeof n=="string"&&n.slice(0,2)==="{{"&&n.slice(-2)==="}}")return new Op({variableName:n.slice(2,-2),optional:!0});if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")return new Op({variableName:n.slice(1,-1),optional:!0});throw new Error(`Invalid placeholder template for format ${t?.templateFormat??'"f-string"'}: "${e[1]}". Expected a variable name surrounded by ${t?.templateFormat==="mustache"?"double":"single"} curly braces.`)}let r=St(e),i;if(typeof r.content=="string"?i=r.content:i=r.content.map(n=>"text"in n?{...n,text:n.text}:"image_url"in n?{...n,image_url:n.image_url}:n),r._getType()==="human")return Pp.fromTemplate(i,t);if(r._getType()==="ai")return Cw.fromTemplate(i,t);if(r._getType()==="system")return Ow.fromTemplate(i,t);if(qr.isInstance(r))return Tw.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function D6(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Zs=class Cp extends Cu{static lc_name(){return"ChatPromptTemplate"}get lc_aliases(){return{promptMessages:"messages"}}promptMessages;validateTemplate=!0;templateFormat="f-string";constructor(t){if(super(t),t.templateFormat==="mustache"&&t.validateTemplate===void 0&&(this.validateTemplate=!1),Object.assign(this,t),this.validateTemplate){let r=new Set;for(let s of this.promptMessages)if(!(s instanceof Me))for(let c of s.inputVariables)r.add(c);let i=this.inputVariables,n=new Set(this.partialVariables?i.concat(Object.keys(this.partialVariables)):i),a=new Set([...n].filter(s=>!r.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` are not used in any of the prompt messages.`);let o=new Set([...r].filter(s=>!n.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are used in prompt messages but not in the prompt template.`)}}_getPromptType(){return"chat"}async _parseImagePrompts(t,r){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async i=>{if(i.type!=="image_url")return i;let n="";typeof i.image_url=="string"?n=i.image_url:typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"&&(n=i.image_url.url);let a=await cn.fromTemplate(n,{templateFormat:this.templateFormat}).format(r);return typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url?i.image_url.url=a:i.image_url=a,i}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=[];for(let n of this.promptMessages)if(n instanceof Me)i.push(await this._parseImagePrompts(n,r));else{let a;this.templateFormat==="mustache"?a={...r}:a=n.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(D6(n)&&n.optional))throw Yn(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let o=await n.formatMessages(a);i=i.concat(o)}return i}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Cp({...this,inputVariables:r,partialVariables:i})}static fromTemplate(t,r){let i=new Pp({prompt:cn.fromTemplate(t,r)});return this.fromMessages([i])}static fromMessages(t,r){let i=t.reduce((o,s)=>o.concat(s instanceof Cp?s.promptMessages:[z6(s,r)]),[]),n=t.reduce((o,s)=>s instanceof Cp?Object.assign(o,s.partialVariables):o,Object.create(null)),a=new Set;for(let o of i)if(!(o instanceof Me))for(let s of o.inputVariables)s in n||a.add(s);return new this({...r,inputVariables:[...a],promptMessages:i,partialVariables:n,templateFormat:r?.templateFormat})}};var jO=class Pw extends mi{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
326
|
+
|
|
327
|
+
`;prefix="";templateFormat="f-string";validateTemplate=!0;constructor(t){if(super(t),Object.assign(this,t),this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),hi(this.prefix+this.suffix,this.templateFormat,r)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new Pw({...this,inputVariables:r,partialVariables:i})}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=await Promise.all(i.map(a=>this.examplePrompt.format(a)));return Mt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(this.outputParser!==void 0)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(t){let{example_prompt:r}=t;if(!r)throw new Error("Missing example prompt");let i=await cn.deserialize(r),n;if(Array.isArray(t.examples))n=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new Pw({inputVariables:t.input_variables,examplePrompt:i,examples:n,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},MO=class zO extends Cu{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
328
|
+
|
|
329
|
+
`;prefix="";templateFormat="f-string";validateTemplate=!0;_getPromptType(){return"few_shot_chat"}static lc_name(){return"FewShotChatMessagePromptTemplate"}constructor(t){if(super(t),this.examples=t.examples,this.examplePrompt=t.examplePrompt,this.exampleSeparator=t.exampleSeparator??`
|
|
330
|
+
|
|
331
|
+
`,this.exampleSelector=t.exampleSelector,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.templateFormat=t.templateFormat??"f-string",this.validateTemplate=t.validateTemplate??!0,this.examples!==void 0&&this.exampleSelector!==void 0)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(this.examples===void 0&&this.exampleSelector===void 0)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let r=this.inputVariables;this.partialVariables&&(r=r.concat(Object.keys(this.partialVariables))),hi(this.prefix+this.suffix,this.templateFormat,r)}}async getExamples(t){if(this.examples!==void 0)return this.examples;if(this.exampleSelector!==void 0)return this.exampleSelector.selectExamples(t);throw new Error("One of 'examples' and 'example_selector' should be provided")}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r);i=i.map(a=>{let o={};return this.examplePrompt.inputVariables.forEach(s=>{o[s]=a[s]}),o});let n=[];for(let a of i){let o=await this.examplePrompt.formatMessages(a);n.push(...o)}return n}async format(t){let r=await this.mergePartialAndUserVariables(t),i=await this.getExamples(r),n=(await Promise.all(i.map(a=>this.examplePrompt.formatMessages(a)))).flat().map(a=>a.content);return Mt([this.prefix,...n,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(n=>!(n in t)),i={...this.partialVariables??{},...t};return new zO({...this,inputVariables:r,partialVariables:i})}};var DO=class Np extends Bn{static lc_name(){return"PipelinePromptTemplate"}pipelinePrompts;finalPrompt;constructor(t){super({...t,inputVariables:[]}),this.pipelinePrompts=t.pipelinePrompts,this.finalPrompt=t.finalPrompt,this.inputVariables=this.computeInputValues()}computeInputValues(){let t=this.pipelinePrompts.map(i=>i.name),r=this.pipelinePrompts.map(i=>i.prompt.inputVariables.filter(n=>!t.includes(n))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((i,n)=>(i[n]=t[n],i),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:i,prompt:n}of this.pipelinePrompts){let a=Np.extractRequiredInputValues(r,n.inputVariables);n instanceof Zs?r[i]=await n.formatMessages(a):r[i]=await n.format(a)}return Np.extractRequiredInputValues(r,this.finalPrompt.inputVariables)}async formatPromptValue(t){return this.finalPrompt.formatPromptValue(await this.formatPipelinePrompts(t))}async format(t){return this.finalPrompt.format(await this.formatPipelinePrompts(t))}async partial(t){let r={...this};return r.inputVariables=this.inputVariables.filter(i=>!(i in t)),r.partialVariables={...this.partialVariables??{},...t},new Np(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function UO(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function U6(e){return typeof e=="object"&&e!=null&&"lc_id"in e&&Array.isArray(e.lc_id)&&e.lc_id.join("/")==="langchain_core/runnables/RunnableBinding"}var LO=class FO extends Zs{schema;method;lc_namespace=["langchain_core","prompts","structured"];get lc_aliases(){return{...super.lc_aliases,schema:"schema_"}}constructor(t){super(t),this.schema=t.schema,this.method=t.method}pipe(t){if(UO(t))return super.pipe(t.withStructuredOutput(this.schema));if(U6(t)&&UO(t.bound))return super.pipe(new Ur({bound:t.bound.withStructuredOutput(this.schema,...this.method?[{method:this.method}]:[]),kwargs:t.kwargs??{},config:t.config,configFactories:t.configFactories}));throw new Error('Structured prompts need to be piped to a language model that supports the "withStructuredOutput()" method.')}static fromMessagesAndSchema(t,r,i){return FO.fromMessages(t,{schema:r,method:i})}};var BO=E({AIMessagePromptTemplate:()=>Cw,BaseChatPromptTemplate:()=>Cu,BaseMessagePromptTemplate:()=>Au,BaseMessageStringPromptTemplate:()=>Ew,BasePromptTemplate:()=>Bn,BaseStringPromptTemplate:()=>mi,ChatMessagePromptTemplate:()=>Tw,ChatPromptTemplate:()=>Zs,DEFAULT_FORMATTER_MAPPING:()=>Iu,DEFAULT_PARSER_MAPPING:()=>kw,DictPromptTemplate:()=>Tu,FewShotChatMessagePromptTemplate:()=>MO,FewShotPromptTemplate:()=>jO,HumanMessagePromptTemplate:()=>Pp,ImagePromptTemplate:()=>Bs,MessagesPlaceholder:()=>Op,PipelinePromptTemplate:()=>DO,PromptTemplate:()=>cn,StructuredPrompt:()=>LO,SystemMessagePromptTemplate:()=>Ow,checkValidTemplate:()=>hi,interpolateFString:()=>xw,interpolateMustache:()=>Sw,parseFString:()=>ho,parseMustache:()=>Fs,parseTemplate:()=>go,renderTemplate:()=>Mt});var ZO=E({BaseDocumentCompressor:()=>L6}),L6=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var VO=E({BaseRetriever:()=>Ou}),Ou=class extends re{callbacks;tags;metadata;verbose;constructor(e){super(e),this.callbacks=e?.callbacks,this.tags=e?.tags??[],this.metadata=e?.metadata??{},this.verbose=e?.verbose??!1}_getRelevantDocuments(e,t){throw new Error("Not implemented!")}async invoke(e,t){let r=ye(Pa(t)),i=await(await ot.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,r.runId,void 0,void 0,void 0,r.runName);try{let n=await this._getRelevantDocuments(e,i);return await i?.handleRetrieverEnd(n),n}catch(n){throw await i?.handleRetrieverError(n),n}}};var GO=E({BaseStore:()=>HO,InMemoryStore:()=>F6}),HO=class extends at{},F6=class extends HO{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,r]of e)this.store[t]=r}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let r of t)(e===void 0||r.startsWith(e))&&(yield r)}};var un={and:"and",or:"or",not:"not"},be={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},Rp=class{},jp=class{accept(e){if(this.exprName==="Operation")return e.visitOperation(this);if(this.exprName==="Comparison")return e.visitComparison(this);if(this.exprName==="StructuredQuery")return e.visitStructuredQuery(this);throw new Error("Unknown Expression type")}},Mp=class extends jp{},JO=class extends Mp{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},KO=class extends Mp{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},WO=class extends jp{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function Nw(e){return e&&typeof e=="object"&&!Array.isArray(e)}function lr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:Nw(e)&&Object.keys(e).length===0:!0}function Rw(e){if(typeof e=="number")return e%1===0;if(typeof e=="string"){let t=parseInt(e,10);return!Number.isNaN(t)&&t%1===0&&t.toString()===e}return!1}function jw(e){if(typeof e=="number")return e%1!==0;if(typeof e=="string"){let t=parseFloat(e);return!Number.isNaN(t)&&t%1!==0&&t.toString()===e}return!1}function Mw(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function zw(e){return typeof e=="boolean"}function Vs(e){let t;if(Mw(e))t=e;else if(Rw(e))t=parseInt(e,10);else if(jw(e))t=parseFloat(e);else if(zw(e))t=!!e;else throw new Error("Unsupported value type");return t}var Pu=class extends Rp{},qO=class extends Pu{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[un.and,un.or],this.allowedComparators=e?.allowedComparators??[be.eq,be.ne,be.gt,be.gte,be.lt,be.lte]}formatFunction(e){if(e in be){if(this.allowedComparators.length>0&&this.allowedComparators.indexOf(e)===-1)throw new Error(`Comparator ${e} not allowed. Allowed comparators: ${this.allowedComparators.join(", ")}`)}else if(e in un){if(this.allowedOperators.length>0&&this.allowedOperators.indexOf(e)===-1)throw new Error(`Operator ${e} not allowed. Allowed operators: ${this.allowedOperators.join(", ")}`)}else throw new Error("Unknown comparator or operator");return`$${e}`}visitOperation(e){let t=e.args?.map(r=>r.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:Vs(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",i=!1){if(!(lr(e)&&lr(t))){if(lr(e)||r==="replace")return lr(t)?void 0:t;if(lr(t))return i?e:r==="and"?void 0:e;if(r==="and")return{$and:[e,t]};if(r==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}};var XO=class extends Pu{allowedOperators=[un.and,un.or];allowedComparators=[be.eq,be.ne,be.gt,be.gte,be.lt,be.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[be.eq,be.ne,be.gt,be.gte,be.lt,be.lte];case"number":return[be.eq,be.ne,be.gt,be.gte,be.lt,be.lte];case"boolean":return[be.eq,be.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case be.eq:return(t,r)=>t===r;case be.ne:return(t,r)=>t!==r;case be.gt:return(t,r)=>t>r;case be.gte:return(t,r)=>t>=r;case be.lt:return(t,r)=>t<r;case be.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case un.and:return(t,r)=>t&&r;case un.or:return(t,r)=>t||r;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:r}=e;if(this.allowedOperators.includes(t)){let i=this.getOperatorFunction(t);return n=>r?r.reduce((a,o)=>{let s=o.accept(this);if(typeof s=="function")return i(a,s(n));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:r,value:i}=e,n=[be.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof i).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof i}`);let a=this.getComparatorFunction(t);return o=>{let s=o.metadata[r];return s===void 0?!!n.includes(t):a(s,Vs(i))}}else throw new Error("Comparator not allowed")}visitStructuredQuery(e){if(!e.filter)return{};let t=e.filter?.accept(this);if(typeof t!="function")throw new Error("Structured query filter is not a function");return{filter:t}}mergeFilters(e,t,r="and"){if(!(lr(e)&&lr(t))){if(lr(e)||r==="replace")return lr(t)?void 0:t;if(lr(t))return r==="and"?void 0:e;if(r==="and")return i=>e(i)&&t(i);if(r==="or")return i=>e(i)||t(i);throw new Error("Unknown merge type")}}};var YO=E({BaseTranslator:()=>Pu,BasicTranslator:()=>qO,Comparators:()=>be,Comparison:()=>JO,Expression:()=>jp,FilterDirective:()=>Mp,FunctionalTranslator:()=>XO,Operation:()=>KO,Operators:()=>un,StructuredQuery:()=>WO,Visitor:()=>Rp,castValue:()=>Vs,isBoolean:()=>zw,isFilterEmpty:()=>lr,isFloat:()=>jw,isInt:()=>Rw,isObject:()=>Nw,isString:()=>Mw});function Nu(e){return Me.isInstance(e)?e.constructor.name||e.type:typeof e}function zp(e,t){return function(r,i){let{isNot:n,utils:a}=this;if(!t(r))return{pass:!1,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
332
|
+
|
|
333
|
+
Expected: ${n?"not ":""}${e}
|
|
334
|
+
Received: ${Nu(r)}`,actual:Nu(r),expected:e};if(i===void 0)return{pass:!0,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
335
|
+
|
|
336
|
+
Expected: not ${e}
|
|
337
|
+
Received: ${e}`};let o=r;return typeof i=="string"?{pass:o.content===i,message:()=>`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
338
|
+
|
|
339
|
+
Expected: ${e} with content ${a.printExpected(i)}
|
|
340
|
+
Received: ${e} with content ${a.printReceived(o.content)}`,actual:o.content,expected:i}:{pass:Object.entries(i).every(([s,c])=>this.equals(o[s],c)),message:()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return`${a.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
341
|
+
|
|
342
|
+
Expected: ${e} matching ${a.printExpected(i)}
|
|
343
|
+
Received: ${e} with ${a.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(i))s[c]=o[c];return s})(),expected:i}}}var Dw=zp("HumanMessage",Ye.isInstance),Uw=zp("AIMessage",Ee.isInstance),Lw=zp("SystemMessage",Vt.isInstance),Fw=zp("ToolMessage",Zt.isInstance);function Bw(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
344
|
+
|
|
345
|
+
Expected: AIMessage
|
|
346
|
+
Received: ${Nu(e)}`};let n=e.tool_calls??[];if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
347
|
+
|
|
348
|
+
Expected ${r?"not ":""}${t.length} tool call(s), received ${n.length}`,actual:n.length,expected:t.length};let a=t.filter(o=>!n.some(s=>Object.entries(o).every(([c,u])=>this.equals(s[c],u))));return a.length>0?{pass:!1,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
349
|
+
|
|
350
|
+
Could not find matching tool call(s) for:
|
|
351
|
+
${i.printExpected(a)}
|
|
352
|
+
Received tool calls: ${i.printReceived(n.map(o=>({name:o.name,id:o.id,args:o.args})))}`,actual:n.map(o=>({name:o.name,id:o.id,args:o.args})),expected:t}:{pass:!0,message:()=>`${i.matcherHint("toHaveToolCalls")}
|
|
353
|
+
|
|
354
|
+
Expected AIMessage not to have matching tool calls`}}function Zw(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolCallCount")}
|
|
355
|
+
|
|
356
|
+
Expected: AIMessage
|
|
357
|
+
Received: ${Nu(e)}`};let n=e.tool_calls?.length??0;return{pass:n===t,message:()=>`${i.matcherHint("toHaveToolCallCount")}
|
|
358
|
+
|
|
359
|
+
Expected ${r?"not ":""}${t} tool call(s)
|
|
360
|
+
Received: ${n}`,actual:n,expected:t}}function Vw(e,t){let{isNot:r,utils:i}=this;if(!Ee.isInstance(e))return{pass:!1,message:()=>`${i.matcherHint("toContainToolCall")}
|
|
361
|
+
|
|
362
|
+
Expected: AIMessage
|
|
363
|
+
Received: ${Nu(e)}`};let n=e.tool_calls??[];return{pass:n.some(a=>Object.entries(t).every(([o,s])=>this.equals(a[o],s))),message:()=>`${i.matcherHint("toContainToolCall")}
|
|
364
|
+
|
|
365
|
+
Expected AIMessage ${r?"not ":""}to contain a tool call matching ${i.printExpected(t)}
|
|
366
|
+
Received tool calls: ${i.printReceived(n.map(a=>({name:a.name,id:a.id})))}`,actual:n.map(a=>({name:a.name,id:a.id})),expected:t}}function Gw(e,t){let{isNot:r,utils:i}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
367
|
+
|
|
368
|
+
Expected an array of messages
|
|
369
|
+
Received: ${typeof e}`};let n=e.filter(Zt.isInstance);if(n.length!==t.length)return{pass:!1,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
370
|
+
|
|
371
|
+
Expected ${r?"not ":""}${t.length} tool message(s), found ${n.length}`,actual:n.length,expected:t.length};for(let a=0;a<t.length;a++)if(!Object.entries(t[a]).every(([o,s])=>this.equals(n[a][o],s)))return{pass:!1,message:()=>{let o={};for(let s of Object.keys(t[a]))o[s]=n[a][s];return`${i.matcherHint("toHaveToolMessages")}
|
|
372
|
+
|
|
373
|
+
Tool message at index ${a} did not match:
|
|
374
|
+
Expected: ${i.printExpected(t[a])}
|
|
375
|
+
Received: ${i.printReceived(o)}`},actual:n[a],expected:t[a]};return{pass:!0,message:()=>`${i.matcherHint("toHaveToolMessages")}
|
|
376
|
+
|
|
377
|
+
Expected messages not to contain matching tool messages`}}function Hw(e,t){let{isNot:r,utils:i}=this,n=e?.__interrupt__;if(!(Array.isArray(n)&&n.length>0))return{pass:!1,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
378
|
+
|
|
379
|
+
Expected result ${r?"not ":""}to have been interrupted
|
|
380
|
+
Received __interrupt__: ${i.printReceived(n)}`};if(t===void 0)return{pass:!0,message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
381
|
+
|
|
382
|
+
Expected result not to have been interrupted
|
|
383
|
+
Received ${n.length} interrupt(s)`};let a=n[0]?.value;return{pass:this.equals(a,t),message:()=>`${i.matcherHint("toHaveBeenInterrupted")}
|
|
384
|
+
|
|
385
|
+
Expected interrupt value: ${i.printExpected(t)}
|
|
386
|
+
Received interrupt value: ${i.printReceived(a)}`,actual:a,expected:t}}function Jw(e,t){let{isNot:r,utils:i}=this,n=e?.structuredResponse;return n===void 0?{pass:!1,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
387
|
+
|
|
388
|
+
Expected result ${r?"not ":""}to have a structured response
|
|
389
|
+
Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
390
|
+
|
|
391
|
+
Expected result not to have a structured response`}:{pass:Object.entries(t).every(([a,o])=>this.equals(n[a],o)),message:()=>`${i.matcherHint("toHaveStructuredResponse")}
|
|
392
|
+
|
|
393
|
+
Expected structured response: ${i.printExpected(t)}
|
|
394
|
+
Received structured response: ${i.printReceived(n)}`,actual:n,expected:t}}var QO={toBeHumanMessage:Dw,toBeAIMessage:Uw,toBeSystemMessage:Lw,toBeToolMessage:Fw,toHaveToolCalls:Bw,toHaveToolCallCount:Zw,toContainToolCall:Vw,toHaveToolMessages:Gw,toHaveBeenInterrupted:Hw,toHaveStructuredResponse:Jw};function B6(e){return e.map(t=>t.text).filter(Boolean).join("-")}var e1=0;function Z6(){return e1+=1,`fake_tc_${e1}`}var Kw=class t1 extends ta{queue=[];_alwaysThrowError;_structuredResponseValue;_tools=[];_callIndex=0;_calls=[];get calls(){return this._calls}get callCount(){return this._calls.length}constructor(){super({})}_llmType(){return"fake-model-builder"}_combineLLMOutput(){return[]}respond(t){return typeof t=="function"?this.queue.push({kind:"factory",factory:t}):Me.isInstance(t)?this.queue.push({kind:"message",message:t}):this.queue.push({kind:"error",error:t}),this}respondWithTools(t){return this.queue.push({kind:"toolCalls",toolCalls:t.map(r=>({name:r.name,args:r.args,id:r.id??Z6(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let r=[...this._tools,...t],i=new t1;return i.queue=this.queue,i._alwaysThrowError=this._alwaysThrowError,i._structuredResponseValue=this._structuredResponseValue,i._tools=r,i._calls=this._calls,i._callIndex=this._callIndex,i.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:i}=this;return Rt.from(async()=>i)}async _generate(t,r,i){this._calls.push({messages:[...t],options:r});let n=this._callIndex;if(this._callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let a=this.queue[n];if(!a)throw new Error(`FakeModel: no response queued for invocation ${n} (${this.queue.length} total queued).`);if(a.kind==="error")throw a.error;if(a.kind==="factory"){let s=a.factory(t);if(!Me.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(a.kind==="message")return{generations:[{text:"",message:a.message}]};let o=B6(t);return{generations:[{text:o,message:new Ee({content:o,id:n.toString(),tool_calls:a.toolCalls.length>0?a.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function r1(){return new Kw}var n1=E({FakeBuiltModel:()=>Kw,fakeModel:()=>r1,langchainMatchers:()=>QO,toBeAIMessage:()=>Uw,toBeHumanMessage:()=>Dw,toBeSystemMessage:()=>Lw,toBeToolMessage:()=>Fw,toContainToolCall:()=>Vw,toHaveBeenInterrupted:()=>Hw,toHaveStructuredResponse:()=>Jw,toHaveToolCallCount:()=>Zw,toHaveToolCalls:()=>Bw,toHaveToolMessages:()=>Gw});function Ru(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function ju(e){return e!==void 0&&re.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function Mu(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(sr(e.schema)||e.schema!=null&&typeof e.schema=="object"&&"type"in e.schema&&typeof e.schema.type=="string"&&["null","boolean","object","array","number","string"].includes(e.schema.type))}function zu(e){return Mu(e)||ju(e)||Ru(e)}var Br={};bn(Br,{$brand:()=>Gg,$input:()=>lv,$output:()=>uv,NEVER:()=>Vg,TimePrecision:()=>mv,ZodAny:()=>yx,ZodArray:()=>xx,ZodBase64:()=>im,ZodBase64URL:()=>am,ZodBigInt:()=>Ys,ZodBigIntFormat:()=>cm,ZodBoolean:()=>Xs,ZodCIDRv4:()=>rm,ZodCIDRv6:()=>nm,ZodCUID:()=>Wp,ZodCUID2:()=>qp,ZodCatch:()=>Vx,ZodCodec:()=>qu,ZodCustom:()=>Xu,ZodCustomStringFormat:()=>Ws,ZodDate:()=>Gu,ZodDefault:()=>Dx,ZodDiscriminatedUnion:()=>kx,ZodE164:()=>om,ZodEmail:()=>Hp,ZodEmoji:()=>Jp,ZodEnum:()=>Js,ZodError:()=>V6,ZodExactOptional:()=>jx,ZodFile:()=>Nx,ZodFirstPartyTypeKind:()=>n0,ZodFunction:()=>e0,ZodGUID:()=>Lu,ZodIPv4:()=>em,ZodIPv6:()=>tm,ZodISODate:()=>Lp,ZodISODateTime:()=>Up,ZodISODuration:()=>Bp,ZodISOTime:()=>Fp,ZodIntersection:()=>$x,ZodIssueCode:()=>H6,ZodJWT:()=>sm,ZodKSUID:()=>Qp,ZodLazy:()=>Xx,ZodLiteral:()=>Px,ZodMAC:()=>dx,ZodMap:()=>Cx,ZodNaN:()=>Hx,ZodNanoID:()=>Kp,ZodNever:()=>bx,ZodNonOptional:()=>mm,ZodNull:()=>gx,ZodNullable:()=>zx,ZodNumber:()=>qs,ZodNumberFormat:()=>yo,ZodObject:()=>Ju,ZodOptional:()=>pm,ZodPipe:()=>Wu,ZodPrefault:()=>Lx,ZodPreprocess:()=>Jx,ZodPromise:()=>Qx,ZodReadonly:()=>Kx,ZodRealError:()=>dr,ZodRecord:()=>Hs,ZodSet:()=>Ox,ZodString:()=>Ks,ZodStringFormat:()=>Ne,ZodSuccess:()=>Zx,ZodSymbol:()=>mx,ZodTemplateLiteral:()=>qx,ZodTransform:()=>Rx,ZodTuple:()=>Ex,ZodType:()=>pe,ZodULID:()=>Xp,ZodURL:()=>Vu,ZodUUID:()=>Zn,ZodUndefined:()=>hx,ZodUnion:()=>Ku,ZodUnknown:()=>vx,ZodVoid:()=>wx,ZodXID:()=>Yp,ZodXor:()=>Sx,_ZodString:()=>Gp,_default:()=>Ux,_function:()=>fP,any:()=>Z1,array:()=>Hu,base64:()=>I1,base64url:()=>E1,bigint:()=>D1,boolean:()=>px,catch:()=>Gx,check:()=>pP,cidrv4:()=>k1,cidrv6:()=>$1,clone:()=>Ge,codec:()=>cP,coerce:()=>i0,config:()=>et,core:()=>oi,cuid:()=>g1,cuid2:()=>_1,custom:()=>mP,date:()=>G1,decode:()=>ix,decodeAsync:()=>ox,describe:()=>hP,discriminatedUnion:()=>X1,e164:()=>T1,email:()=>o1,emoji:()=>m1,encode:()=>nx,encodeAsync:()=>ax,endsWith:()=>ms,enum:()=>dm,exactOptional:()=>Mx,file:()=>iP,flattenError:()=>Jc,float32:()=>R1,float64:()=>j1,formatError:()=>Kc,fromJSONSchema:()=>xP,function:()=>fP,getErrorMap:()=>K6,globalRegistry:()=>Te,gt:()=>Nn,gte:()=>Kt,guid:()=>s1,hash:()=>N1,hex:()=>P1,hostname:()=>O1,httpUrl:()=>p1,includes:()=>fs,instanceof:()=>_P,int:()=>Zp,int32:()=>M1,int64:()=>U1,intersection:()=>Ix,invertCodec:()=>uP,ipv4:()=>w1,ipv6:()=>S1,iso:()=>Gs,json:()=>vP,jwt:()=>A1,keyof:()=>H1,ksuid:()=>b1,lazy:()=>Yx,length:()=>Ga,literal:()=>nP,locales:()=>iu,looseObject:()=>W1,looseRecord:()=>Q1,lowercase:()=>ls,lt:()=>Pn,lte:()=>xr,mac:()=>x1,map:()=>eP,maxLength:()=>Va,maxSize:()=>Gi,meta:()=>gP,mime:()=>hs,minLength:()=>ai,minSize:()=>Rn,multipleOf:()=>Vi,nan:()=>sP,nanoid:()=>h1,nativeEnum:()=>rP,negative:()=>zf,never:()=>um,nonnegative:()=>Uf,nonoptional:()=>Bx,nonpositive:()=>Df,normalize:()=>gs,null:()=>_x,nullable:()=>Bu,nullish:()=>aP,number:()=>fx,object:()=>J1,optional:()=>Fu,overwrite:()=>tn,parse:()=>Qw,parseAsync:()=>ex,partialRecord:()=>Y1,pipe:()=>Vp,positive:()=>Mf,prefault:()=>Fx,preprocess:()=>bP,prettifyError:()=>i_,promise:()=>dP,property:()=>Lf,readonly:()=>Wx,record:()=>Ax,refine:()=>t0,regex:()=>us,regexes:()=>wr,registry:()=>hf,safeDecode:()=>cx,safeDecodeAsync:()=>lx,safeEncode:()=>sx,safeEncodeAsync:()=>ux,safeParse:()=>tx,safeParseAsync:()=>rx,set:()=>tP,setErrorMap:()=>J6,size:()=>Za,slugify:()=>bs,startsWith:()=>ps,strictObject:()=>K1,string:()=>Uu,stringFormat:()=>C1,stringbool:()=>yP,success:()=>oP,superRefine:()=>r0,symbol:()=>F1,templateLiteral:()=>lP,toJSONSchema:()=>Ha,toLowerCase:()=>ys,toUpperCase:()=>vs,transform:()=>fm,treeifyError:()=>n_,trim:()=>_s,tuple:()=>Tx,uint32:()=>z1,uint64:()=>L1,ulid:()=>y1,undefined:()=>B1,union:()=>lm,unknown:()=>_o,uppercase:()=>ds,url:()=>f1,util:()=>M,uuid:()=>c1,uuidv4:()=>u1,uuidv6:()=>l1,uuidv7:()=>d1,void:()=>V1,xid:()=>v1,xor:()=>q1});var Du={};bn(Du,{ZodAny:()=>yx,ZodArray:()=>xx,ZodBase64:()=>im,ZodBase64URL:()=>am,ZodBigInt:()=>Ys,ZodBigIntFormat:()=>cm,ZodBoolean:()=>Xs,ZodCIDRv4:()=>rm,ZodCIDRv6:()=>nm,ZodCUID:()=>Wp,ZodCUID2:()=>qp,ZodCatch:()=>Vx,ZodCodec:()=>qu,ZodCustom:()=>Xu,ZodCustomStringFormat:()=>Ws,ZodDate:()=>Gu,ZodDefault:()=>Dx,ZodDiscriminatedUnion:()=>kx,ZodE164:()=>om,ZodEmail:()=>Hp,ZodEmoji:()=>Jp,ZodEnum:()=>Js,ZodExactOptional:()=>jx,ZodFile:()=>Nx,ZodFunction:()=>e0,ZodGUID:()=>Lu,ZodIPv4:()=>em,ZodIPv6:()=>tm,ZodIntersection:()=>$x,ZodJWT:()=>sm,ZodKSUID:()=>Qp,ZodLazy:()=>Xx,ZodLiteral:()=>Px,ZodMAC:()=>dx,ZodMap:()=>Cx,ZodNaN:()=>Hx,ZodNanoID:()=>Kp,ZodNever:()=>bx,ZodNonOptional:()=>mm,ZodNull:()=>gx,ZodNullable:()=>zx,ZodNumber:()=>qs,ZodNumberFormat:()=>yo,ZodObject:()=>Ju,ZodOptional:()=>pm,ZodPipe:()=>Wu,ZodPrefault:()=>Lx,ZodPreprocess:()=>Jx,ZodPromise:()=>Qx,ZodReadonly:()=>Kx,ZodRecord:()=>Hs,ZodSet:()=>Ox,ZodString:()=>Ks,ZodStringFormat:()=>Ne,ZodSuccess:()=>Zx,ZodSymbol:()=>mx,ZodTemplateLiteral:()=>qx,ZodTransform:()=>Rx,ZodTuple:()=>Ex,ZodType:()=>pe,ZodULID:()=>Xp,ZodURL:()=>Vu,ZodUUID:()=>Zn,ZodUndefined:()=>hx,ZodUnion:()=>Ku,ZodUnknown:()=>vx,ZodVoid:()=>wx,ZodXID:()=>Yp,ZodXor:()=>Sx,_ZodString:()=>Gp,_default:()=>Ux,_function:()=>fP,any:()=>Z1,array:()=>Hu,base64:()=>I1,base64url:()=>E1,bigint:()=>D1,boolean:()=>px,catch:()=>Gx,check:()=>pP,cidrv4:()=>k1,cidrv6:()=>$1,codec:()=>cP,cuid:()=>g1,cuid2:()=>_1,custom:()=>mP,date:()=>G1,describe:()=>hP,discriminatedUnion:()=>X1,e164:()=>T1,email:()=>o1,emoji:()=>m1,enum:()=>dm,exactOptional:()=>Mx,file:()=>iP,float32:()=>R1,float64:()=>j1,function:()=>fP,guid:()=>s1,hash:()=>N1,hex:()=>P1,hostname:()=>O1,httpUrl:()=>p1,instanceof:()=>_P,int:()=>Zp,int32:()=>M1,int64:()=>U1,intersection:()=>Ix,invertCodec:()=>uP,ipv4:()=>w1,ipv6:()=>S1,json:()=>vP,jwt:()=>A1,keyof:()=>H1,ksuid:()=>b1,lazy:()=>Yx,literal:()=>nP,looseObject:()=>W1,looseRecord:()=>Q1,mac:()=>x1,map:()=>eP,meta:()=>gP,nan:()=>sP,nanoid:()=>h1,nativeEnum:()=>rP,never:()=>um,nonoptional:()=>Bx,null:()=>_x,nullable:()=>Bu,nullish:()=>aP,number:()=>fx,object:()=>J1,optional:()=>Fu,partialRecord:()=>Y1,pipe:()=>Vp,prefault:()=>Fx,preprocess:()=>bP,promise:()=>dP,readonly:()=>Wx,record:()=>Ax,refine:()=>t0,set:()=>tP,strictObject:()=>K1,string:()=>Uu,stringFormat:()=>C1,stringbool:()=>yP,success:()=>oP,superRefine:()=>r0,symbol:()=>F1,templateLiteral:()=>lP,transform:()=>fm,tuple:()=>Tx,uint32:()=>z1,uint64:()=>L1,ulid:()=>y1,undefined:()=>B1,union:()=>lm,unknown:()=>_o,url:()=>f1,uuid:()=>c1,uuidv4:()=>u1,uuidv6:()=>l1,uuidv7:()=>d1,void:()=>V1,xid:()=>v1,xor:()=>q1});var Dp={};bn(Dp,{endsWith:()=>ms,gt:()=>Nn,gte:()=>Kt,includes:()=>fs,length:()=>Ga,lowercase:()=>ls,lt:()=>Pn,lte:()=>xr,maxLength:()=>Va,maxSize:()=>Gi,mime:()=>hs,minLength:()=>ai,minSize:()=>Rn,multipleOf:()=>Vi,negative:()=>zf,nonnegative:()=>Uf,nonpositive:()=>Df,normalize:()=>gs,overwrite:()=>tn,positive:()=>Mf,property:()=>Lf,regex:()=>us,size:()=>Za,slugify:()=>bs,startsWith:()=>ps,toLowerCase:()=>ys,toUpperCase:()=>vs,trim:()=>_s,uppercase:()=>ds});var Gs={};bn(Gs,{ZodISODate:()=>Lp,ZodISODateTime:()=>Up,ZodISODuration:()=>Bp,ZodISOTime:()=>Fp,date:()=>qw,datetime:()=>Ww,duration:()=>Yw,time:()=>Xw});var Up=b("ZodISODateTime",(e,t)=>{py.init(e,t),Ne.init(e,t)});function Ww(e){return hv(Up,e)}var Lp=b("ZodISODate",(e,t)=>{my.init(e,t),Ne.init(e,t)});function qw(e){return gv(Lp,e)}var Fp=b("ZodISOTime",(e,t)=>{hy.init(e,t),Ne.init(e,t)});function Xw(e){return _v(Fp,e)}var Bp=b("ZodISODuration",(e,t)=>{gy.init(e,t),Ne.init(e,t)});function Yw(e){return yv(Bp,e)}var i1=(e,t)=>{Hc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Kc(e,r)},flatten:{value:r=>Jc(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,es,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,es,2)}},isEmpty:{get(){return e.issues.length===0}}})},V6=b("ZodError",i1),dr=b("ZodError",i1,{Parent:Error});var Qw=ns(dr),ex=is(dr),tx=as(dr),rx=os(dr),nx=Vd(dr),ix=Gd(dr),ax=Hd(dr),ox=Jd(dr),sx=Kd(dr),cx=Wd(dr),ux=qd(dr),lx=Xd(dr);var a1=new WeakMap;function Zu(e,t,r){let i=Object.getPrototypeOf(e),n=a1.get(i);if(n||(n=new Set,a1.set(i,n)),!n.has(t)){n.add(t);for(let a in r){let o=r[a];Object.defineProperty(i,a,{configurable:!0,enumerable:!1,get(){let s=o.bind(this);return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var pe=b("ZodType",(e,t)=>(ce.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:xs(e,"input"),output:xs(e,"output")}}),e.toJSONSchema=Kv(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,i)=>Qw(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>tx(e,r,i),e.parseAsync=async(r,i)=>ex(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>rx(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>nx(e,r,i),e.decode=(r,i)=>ix(e,r,i),e.encodeAsync=async(r,i)=>ax(e,r,i),e.decodeAsync=async(r,i)=>ox(e,r,i),e.safeEncode=(r,i)=>sx(e,r,i),e.safeDecode=(r,i)=>cx(e,r,i),e.safeEncodeAsync=async(r,i)=>ux(e,r,i),e.safeDecodeAsync=async(r,i)=>lx(e,r,i),Zu(e,"ZodType",{check(...r){let i=this.def;return this.clone(M.mergeDefs(i,{checks:[...i.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,i){return Ge(this,r,i)},brand(){return this},register(r,i){return r.add(this,i),this},refine(r,i){return this.check(t0(r,i))},superRefine(r,i){return this.check(r0(r,i))},overwrite(r){return this.check(tn(r))},optional(){return Fu(this)},exactOptional(){return Mx(this)},nullable(){return Bu(this)},nullish(){return Fu(Bu(this))},nonoptional(r){return Bx(this,r)},array(){return Hu(this)},or(r){return lm([this,r])},and(r){return Ix(this,r)},transform(r){return Vp(this,fm(r))},default(r){return Ux(this,r)},prefault(r){return Fx(this,r)},catch(r){return Gx(this,r)},pipe(r){return Vp(this,r)},readonly(){return Wx(this)},describe(r){let i=this.clone();return Te.add(i,{description:r}),i},meta(...r){if(r.length===0)return Te.get(this);let i=this.clone();return Te.add(i,r[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Te.get(e)?.description},configurable:!0}),e)),Gp=b("_ZodString",(e,t)=>{Fa.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Wv(e,i,n,a);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Zu(e,"_ZodString",{regex(...i){return this.check(us(...i))},includes(...i){return this.check(fs(...i))},startsWith(...i){return this.check(ps(...i))},endsWith(...i){return this.check(ms(...i))},min(...i){return this.check(ai(...i))},max(...i){return this.check(Va(...i))},length(...i){return this.check(Ga(...i))},nonempty(...i){return this.check(ai(1,...i))},lowercase(i){return this.check(ls(i))},uppercase(i){return this.check(ds(i))},trim(){return this.check(_s())},normalize(...i){return this.check(gs(...i))},toLowerCase(){return this.check(ys())},toUpperCase(){return this.check(vs())},slugify(){return this.check(bs())}})}),Ks=b("ZodString",(e,t)=>{Fa.init(e,t),Gp.init(e,t),e.email=r=>e.check(gf(Hp,r)),e.url=r=>e.check(ou(Vu,r)),e.jwt=r=>e.check(jf(sm,r)),e.emoji=r=>e.check(wf(Jp,r)),e.guid=r=>e.check(au(Lu,r)),e.uuid=r=>e.check(_f(Zn,r)),e.uuidv4=r=>e.check(yf(Zn,r)),e.uuidv6=r=>e.check(vf(Zn,r)),e.uuidv7=r=>e.check(bf(Zn,r)),e.nanoid=r=>e.check(xf(Kp,r)),e.guid=r=>e.check(au(Lu,r)),e.cuid=r=>e.check(Sf(Wp,r)),e.cuid2=r=>e.check(kf(qp,r)),e.ulid=r=>e.check($f(Xp,r)),e.base64=r=>e.check(Pf(im,r)),e.base64url=r=>e.check(Nf(am,r)),e.xid=r=>e.check(If(Yp,r)),e.ksuid=r=>e.check(Ef(Qp,r)),e.ipv4=r=>e.check(Tf(em,r)),e.ipv6=r=>e.check(Af(tm,r)),e.cidrv4=r=>e.check(Cf(rm,r)),e.cidrv6=r=>e.check(Of(nm,r)),e.e164=r=>e.check(Rf(om,r)),e.datetime=r=>e.check(Ww(r)),e.date=r=>e.check(qw(r)),e.time=r=>e.check(Xw(r)),e.duration=r=>e.check(Yw(r))});function Uu(e){return dv(Ks,e)}var Ne=b("ZodStringFormat",(e,t)=>{Pe.init(e,t),Gp.init(e,t)}),Hp=b("ZodEmail",(e,t)=>{iy.init(e,t),Ne.init(e,t)});function o1(e){return gf(Hp,e)}var Lu=b("ZodGUID",(e,t)=>{ry.init(e,t),Ne.init(e,t)});function s1(e){return au(Lu,e)}var Zn=b("ZodUUID",(e,t)=>{ny.init(e,t),Ne.init(e,t)});function c1(e){return _f(Zn,e)}function u1(e){return yf(Zn,e)}function l1(e){return vf(Zn,e)}function d1(e){return bf(Zn,e)}var Vu=b("ZodURL",(e,t)=>{ay.init(e,t),Ne.init(e,t)});function f1(e){return ou(Vu,e)}function p1(e){return ou(Vu,{protocol:wr.httpProtocol,hostname:wr.domain,...M.normalizeParams(e)})}var Jp=b("ZodEmoji",(e,t)=>{oy.init(e,t),Ne.init(e,t)});function m1(e){return wf(Jp,e)}var Kp=b("ZodNanoID",(e,t)=>{sy.init(e,t),Ne.init(e,t)});function h1(e){return xf(Kp,e)}var Wp=b("ZodCUID",(e,t)=>{cy.init(e,t),Ne.init(e,t)});function g1(e){return Sf(Wp,e)}var qp=b("ZodCUID2",(e,t)=>{uy.init(e,t),Ne.init(e,t)});function _1(e){return kf(qp,e)}var Xp=b("ZodULID",(e,t)=>{ly.init(e,t),Ne.init(e,t)});function y1(e){return $f(Xp,e)}var Yp=b("ZodXID",(e,t)=>{dy.init(e,t),Ne.init(e,t)});function v1(e){return If(Yp,e)}var Qp=b("ZodKSUID",(e,t)=>{fy.init(e,t),Ne.init(e,t)});function b1(e){return Ef(Qp,e)}var em=b("ZodIPv4",(e,t)=>{_y.init(e,t),Ne.init(e,t)});function w1(e){return Tf(em,e)}var dx=b("ZodMAC",(e,t)=>{vy.init(e,t),Ne.init(e,t)});function x1(e){return pv(dx,e)}var tm=b("ZodIPv6",(e,t)=>{yy.init(e,t),Ne.init(e,t)});function S1(e){return Af(tm,e)}var rm=b("ZodCIDRv4",(e,t)=>{by.init(e,t),Ne.init(e,t)});function k1(e){return Cf(rm,e)}var nm=b("ZodCIDRv6",(e,t)=>{wy.init(e,t),Ne.init(e,t)});function $1(e){return Of(nm,e)}var im=b("ZodBase64",(e,t)=>{Sy.init(e,t),Ne.init(e,t)});function I1(e){return Pf(im,e)}var am=b("ZodBase64URL",(e,t)=>{ky.init(e,t),Ne.init(e,t)});function E1(e){return Nf(am,e)}var om=b("ZodE164",(e,t)=>{$y.init(e,t),Ne.init(e,t)});function T1(e){return Rf(om,e)}var sm=b("ZodJWT",(e,t)=>{Iy.init(e,t),Ne.init(e,t)});function A1(e){return jf(sm,e)}var Ws=b("ZodCustomStringFormat",(e,t)=>{Ey.init(e,t),Ne.init(e,t)});function C1(e,t,r={}){return ws(Ws,e,t,r)}function O1(e){return ws(Ws,"hostname",wr.hostname,e)}function P1(e){return ws(Ws,"hex",wr.hex,e)}function N1(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=wr[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return ws(Ws,i,n,t)}var qs=b("ZodNumber",(e,t)=>{sf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(i,n,a)=>qv(e,i,n,a),Zu(e,"ZodNumber",{gt(i,n){return this.check(Nn(i,n))},gte(i,n){return this.check(Kt(i,n))},min(i,n){return this.check(Kt(i,n))},lt(i,n){return this.check(Pn(i,n))},lte(i,n){return this.check(xr(i,n))},max(i,n){return this.check(xr(i,n))},int(i){return this.check(Zp(i))},safe(i){return this.check(Zp(i))},positive(i){return this.check(Nn(0,i))},nonnegative(i){return this.check(Kt(0,i))},negative(i){return this.check(Pn(0,i))},nonpositive(i){return this.check(xr(0,i))},multipleOf(i,n){return this.check(Vi(i,n))},step(i,n){return this.check(Vi(i,n))},finite(){return this}});let 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 fx(e){return vv(qs,e)}var yo=b("ZodNumberFormat",(e,t)=>{Ty.init(e,t),qs.init(e,t)});function Zp(e){return wv(yo,e)}function R1(e){return xv(yo,e)}function j1(e){return Sv(yo,e)}function M1(e){return kv(yo,e)}function z1(e){return $v(yo,e)}var Xs=b("ZodBoolean",(e,t)=>{Yc.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Xv(e,r,i,n)});function px(e){return Iv(Xs,e)}var Ys=b("ZodBigInt",(e,t)=>{cf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(i,n,a)=>Yv(e,i,n,a),e.gte=(i,n)=>e.check(Kt(i,n)),e.min=(i,n)=>e.check(Kt(i,n)),e.gt=(i,n)=>e.check(Nn(i,n)),e.gte=(i,n)=>e.check(Kt(i,n)),e.min=(i,n)=>e.check(Kt(i,n)),e.lt=(i,n)=>e.check(Pn(i,n)),e.lte=(i,n)=>e.check(xr(i,n)),e.max=(i,n)=>e.check(xr(i,n)),e.positive=i=>e.check(Nn(BigInt(0),i)),e.negative=i=>e.check(Pn(BigInt(0),i)),e.nonpositive=i=>e.check(xr(BigInt(0),i)),e.nonnegative=i=>e.check(Kt(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(Vi(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function D1(e){return Tv(Ys,e)}var cm=b("ZodBigIntFormat",(e,t)=>{Ay.init(e,t),Ys.init(e,t)});function U1(e){return Cv(cm,e)}function L1(e){return Ov(cm,e)}var mx=b("ZodSymbol",(e,t)=>{Cy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Qv(e,r,i,n)});function F1(e){return Pv(mx,e)}var hx=b("ZodUndefined",(e,t)=>{Oy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>tb(e,r,i,n)});function B1(e){return Nv(hx,e)}var gx=b("ZodNull",(e,t)=>{Py.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>eb(e,r,i,n)});function _x(e){return Rv(gx,e)}var yx=b("ZodAny",(e,t)=>{Ny.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ib(e,r,i,n)});function Z1(){return jv(yx)}var vx=b("ZodUnknown",(e,t)=>{Qc.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ab(e,r,i,n)});function _o(){return su(vx)}var bx=b("ZodNever",(e,t)=>{eu.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>nb(e,r,i,n)});function um(e){return cu(bx,e)}var wx=b("ZodVoid",(e,t)=>{Ry.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>rb(e,r,i,n)});function V1(e){return Mv(wx,e)}var Gu=b("ZodDate",(e,t)=>{jy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(i,n,a)=>ob(e,i,n,a),e.min=(i,n)=>e.check(Kt(i,n)),e.max=(i,n)=>e.check(xr(i,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function G1(e){return zv(Gu,e)}var xx=b("ZodArray",(e,t)=>{My.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>yb(e,r,i,n),e.element=t.element,Zu(e,"ZodArray",{min(r,i){return this.check(ai(r,i))},nonempty(r){return this.check(ai(1,r))},max(r,i){return this.check(Va(r,i))},length(r,i){return this.check(Ga(r,i))},unwrap(){return this.element}})});function Hu(e,t){return Lv(xx,e,t)}function H1(e){let t=e._zod.def.shape;return dm(Object.keys(t))}var Ju=b("ZodObject",(e,t)=>{zy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>vb(e,r,i,n),M.defineLazy(e,"shape",()=>t.shape),Zu(e,"ZodObject",{keyof(){return dm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:_o()})},loose(){return this.clone({...this._zod.def,catchall:_o()})},strict(){return this.clone({...this._zod.def,catchall:um()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return M.extend(this,r)},safeExtend(r){return M.safeExtend(this,r)},merge(r){return M.merge(this,r)},pick(r){return M.pick(this,r)},omit(r){return M.omit(this,r)},partial(...r){return M.partial(pm,this,r[0])},required(...r){return M.required(mm,this,r[0])}})});function J1(e,t){let r={type:"object",shape:e??{},...M.normalizeParams(t)};return new Ju(r)}function K1(e,t){return new Ju({type:"object",shape:e,catchall:um(),...M.normalizeParams(t)})}function W1(e,t){return new Ju({type:"object",shape:e,catchall:_o(),...M.normalizeParams(t)})}var Ku=b("ZodUnion",(e,t)=>{tu.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Bf(e,r,i,n),e.options=t.options});function lm(e,t){return new Ku({type:"union",options:e,...M.normalizeParams(t)})}var Sx=b("ZodXor",(e,t)=>{Ku.init(e,t),Dy.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Bf(e,r,i,n),e.options=t.options});function q1(e,t){return new Sx({type:"union",options:e,inclusive:!1,...M.normalizeParams(t)})}var kx=b("ZodDiscriminatedUnion",(e,t)=>{Ku.init(e,t),Uy.init(e,t)});function X1(e,t,r){return new kx({type:"union",options:t,discriminator:e,...M.normalizeParams(r)})}var $x=b("ZodIntersection",(e,t)=>{Ly.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>bb(e,r,i,n)});function Ix(e,t){return new $x({type:"intersection",left:e,right:t})}var Ex=b("ZodTuple",(e,t)=>{uf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wb(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Tx(e,t,r){let i=t instanceof ce,n=i?r:t,a=i?t:null;return new Ex({type:"tuple",items:e,rest:a,...M.normalizeParams(n)})}var Hs=b("ZodRecord",(e,t)=>{Fy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>xb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function Ax(e,t,r){return!t||!t._zod?new Hs({type:"record",keyType:Uu(),valueType:e,...M.normalizeParams(t)}):new Hs({type:"record",keyType:e,valueType:t,...M.normalizeParams(r)})}function Y1(e,t,r){let i=Ge(e);return i._zod.values=void 0,new Hs({type:"record",keyType:i,valueType:t,...M.normalizeParams(r)})}function Q1(e,t,r){return new Hs({type:"record",keyType:e,valueType:t,mode:"loose",...M.normalizeParams(r)})}var Cx=b("ZodMap",(e,t)=>{By.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>gb(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Rn(...r)),e.nonempty=r=>e.check(Rn(1,r)),e.max=(...r)=>e.check(Gi(...r)),e.size=(...r)=>e.check(Za(...r))});function eP(e,t,r){return new Cx({type:"map",keyType:e,valueType:t,...M.normalizeParams(r)})}var Ox=b("ZodSet",(e,t)=>{Zy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>_b(e,r,i,n),e.min=(...r)=>e.check(Rn(...r)),e.nonempty=r=>e.check(Rn(1,r)),e.max=(...r)=>e.check(Gi(...r)),e.size=(...r)=>e.check(Za(...r))});function tP(e,t){return new Ox({type:"set",valueType:e,...M.normalizeParams(t)})}var Js=b("ZodEnum",(e,t)=>{Vy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(i,n,a)=>sb(e,i,n,a),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let a={};for(let o of i)if(r.has(o))a[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Js({...t,checks:[],...M.normalizeParams(n),entries:a})},e.exclude=(i,n)=>{let a={...t.entries};for(let o of i)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new Js({...t,checks:[],...M.normalizeParams(n),entries:a})}});function dm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Js({type:"enum",entries:r,...M.normalizeParams(t)})}function rP(e,t){return new Js({type:"enum",entries:e,...M.normalizeParams(t)})}var Px=b("ZodLiteral",(e,t)=>{Gy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cb(e,r,i,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 nP(e,t){return new Px({type:"literal",values:Array.isArray(e)?e:[e],...M.normalizeParams(t)})}var Nx=b("ZodFile",(e,t)=>{Hy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>db(e,r,i,n),e.min=(r,i)=>e.check(Rn(r,i)),e.max=(r,i)=>e.check(Gi(r,i)),e.mime=(r,i)=>e.check(hs(Array.isArray(r)?r:[r],i))});function iP(e){return Fv(Nx,e)}var Rx=b("ZodTransform",(e,t)=>{Jy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>hb(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Di(e.constructor.name);r.addIssue=a=>{if(typeof a=="string")r.issues.push(M.issue(a,r.value,t));else{let o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),r.issues.push(M.issue(o))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(a=>(r.value=a,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function fm(e){return new Rx({type:"transform",transform:e})}var pm=b("ZodOptional",(e,t)=>{Ba.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Zf(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Fu(e){return new pm({type:"optional",innerType:e})}var jx=b("ZodExactOptional",(e,t)=>{Ky.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Zf(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Mx(e){return new jx({type:"optional",innerType:e})}var zx=b("ZodNullable",(e,t)=>{Wy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Sb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Bu(e){return new zx({type:"nullable",innerType:e})}function aP(e){return Fu(Bu(e))}var Dx=b("ZodDefault",(e,t)=>{qy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$b(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ux(e,t){return new Dx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():M.shallowClone(t)}})}var Lx=b("ZodPrefault",(e,t)=>{Xy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ib(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Fx(e,t){return new Lx({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():M.shallowClone(t)}})}var mm=b("ZodNonOptional",(e,t)=>{Yy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>kb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Bx(e,t){return new mm({type:"nonoptional",innerType:e,...M.normalizeParams(t)})}var Zx=b("ZodSuccess",(e,t)=>{Qy.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>fb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function oP(e){return new Zx({type:"success",innerType:e})}var Vx=b("ZodCatch",(e,t)=>{ev.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gx(e,t){return new Vx({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Hx=b("ZodNaN",(e,t)=>{tv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ub(e,r,i,n)});function sP(e){return Uv(Hx,e)}var Wu=b("ZodPipe",(e,t)=>{lf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tb(e,r,i,n),e.in=t.in,e.out=t.out});function Vp(e,t){return new Wu({type:"pipe",in:e,out:t})}var qu=b("ZodCodec",(e,t)=>{Wu.init(e,t),ru.init(e,t)});function cP(e,t,r){return new qu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function uP(e){let t=e._zod.def;return new qu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Jx=b("ZodPreprocess",(e,t)=>{Wu.init(e,t),rv.init(e,t)}),Kx=b("ZodReadonly",(e,t)=>{nv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ab(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Wx(e){return new Kx({type:"readonly",innerType:e})}var qx=b("ZodTemplateLiteral",(e,t)=>{iv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lb(e,r,i,n)});function lP(e,t){return new qx({type:"template_literal",parts:e,...M.normalizeParams(t)})}var Xx=b("ZodLazy",(e,t)=>{sv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ob(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function Yx(e){return new Xx({type:"lazy",getter:e})}var Qx=b("ZodPromise",(e,t)=>{ov.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cb(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function dP(e){return new Qx({type:"promise",innerType:e})}var e0=b("ZodFunction",(e,t)=>{av.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>mb(e,r,i,n)});function fP(e){return new e0({type:"function",input:Array.isArray(e?.input)?Tx(e?.input):e?.input??Hu(_o()),output:e?.output??_o()})}var Xu=b("ZodCustom",(e,t)=>{cv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pb(e,r,i,n)});function pP(e){let t=new je({check:"custom"});return t._zod.check=e,t}function mP(e,t){return Bv(Xu,e??(()=>!0),t)}function t0(e,t={}){return Zv(Xu,e,t)}function r0(e,t){return Vv(e,t)}var hP=Gv,gP=Hv;function _P(e,t={}){let r=new Xu({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...M.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var yP=(...e)=>Jv({Codec:qu,Boolean:Xs,String:Ks},...e);function vP(e){let t=Yx(()=>lm([Uu(e),fx(),px(),_x(),Hu(t),Ax(Uu(),t)]));return t}function bP(e,t){return new Jx({type:"pipe",in:fm(e),out:t})}var H6={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function J6(e){et({customError:e})}function K6(){return et().customError}var n0;n0||(n0={});var V={...Du,...Dp,iso:Gs},W6=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function q6(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function X6(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function wP(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return V.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let a=X6(n,t),o=zt(a,t);return t.refs.set(n,o),t.processing.delete(n),o}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return V.null();if(n.length===0)return V.never();if(n.length===1)return V.literal(n[0]);if(n.every(o=>typeof o=="string"))return V.enum(n);let a=n.map(o=>V.literal(o));return a.length<2?a[0]:V.union([a[0],a[1],...a.slice(2)])}if(e.const!==void 0)return V.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(a=>{let o={...e,type:a};return wP(o,t)});return n.length===0?V.never():n.length===1?n[0]:V.union(n)}if(!r)return V.any();let i;switch(r){case"string":{let n=V.string();if(e.format){let a=e.format;a==="email"?n=n.check(V.email()):a==="uri"||a==="uri-reference"?n=n.check(V.url()):a==="uuid"||a==="guid"?n=n.check(V.uuid()):a==="date-time"?n=n.check(V.iso.datetime()):a==="date"?n=n.check(V.iso.date()):a==="time"?n=n.check(V.iso.time()):a==="duration"?n=n.check(V.iso.duration()):a==="ipv4"?n=n.check(V.ipv4()):a==="ipv6"?n=n.check(V.ipv6()):a==="mac"?n=n.check(V.mac()):a==="cidr"?n=n.check(V.cidrv4()):a==="cidr-v6"?n=n.check(V.cidrv6()):a==="base64"?n=n.check(V.base64()):a==="base64url"?n=n.check(V.base64url()):a==="e164"?n=n.check(V.e164()):a==="jwt"?n=n.check(V.jwt()):a==="emoji"?n=n.check(V.emoji()):a==="nanoid"?n=n.check(V.nanoid()):a==="cuid"?n=n.check(V.cuid()):a==="cuid2"?n=n.check(V.cuid2()):a==="ulid"?n=n.check(V.ulid()):a==="xid"?n=n.check(V.xid()):a==="ksuid"&&(n=n.check(V.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=V.boolean();break}case"null":{i=V.null();break}case"object":{let n={},a=e.properties||{},o=new Set(e.required||[]);for(let[c,u]of Object.entries(a)){let l=zt(u,t);n[c]=o.has(c)?l:l.optional()}if(e.propertyNames){let c=zt(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?zt(e.additionalProperties,t):V.any();if(Object.keys(n).length===0){i=V.record(c,u);break}let l=V.object(n).passthrough(),d=V.looseRecord(c,u);i=V.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let p=zt(c[f],t),m=V.string().regex(new RegExp(f));l.push(V.looseRecord(m,p))}let d=[];if(Object.keys(n).length>0&&d.push(V.object(n).passthrough()),d.push(...l),d.length===0)i=V.object({}).passthrough();else if(d.length===1)i=d[0];else{let f=V.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=V.intersection(f,d[p]);i=f}break}let s=V.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(zt(e.additionalProperties,t)):i=s.passthrough();break}case"array":{let n=e.prefixItems,a=e.items;if(n&&Array.isArray(n)){let o=n.map(c=>zt(c,t)),s=a&&typeof a=="object"&&!Array.isArray(a)?zt(a,t):void 0;s?i=V.tuple(o).rest(s):i=V.tuple(o),typeof e.minItems=="number"&&(i=i.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(V.maxLength(e.maxItems)))}else if(Array.isArray(a)){let o=a.map(c=>zt(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?zt(e.additionalItems,t):void 0;s?i=V.tuple(o).rest(s):i=V.tuple(o),typeof e.minItems=="number"&&(i=i.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(V.maxLength(e.maxItems)))}else if(a!==void 0){let o=zt(a,t),s=V.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=V.array(V.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function zt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r=wP(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>zt(u,t)),c=V.union(s);r=i?V.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>zt(u,t)),c=V.xor(s);r=i?V.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:V.any();else{let s=i?r:zt(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=V.intersection(s,zt(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=V.nullable(r)),e.readOnly===!0&&(r=V.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},a=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of a)s in e&&(n[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(n[s]=e[s]);for(let s of Object.keys(e))W6.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function xP(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=q6(r,t?.defaultTarget),n=r.$defs||r.definitions||{},a={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Te};return zt(r,a)}var i0={};bn(i0,{bigint:()=>tF,boolean:()=>eF,date:()=>rF,number:()=>Q6,string:()=>Y6});function Y6(e){return fv(Ks,e)}function Q6(e){return bv(qs,e)}function eF(e){return Ev(Xs,e)}function tF(e){return Av(Ys,e)}function rF(e){return Dv(Gu,e)}et(df());var SP=E({BaseToolkit:()=>nF,DynamicStructuredTool:()=>IP,DynamicTool:()=>$P,StructuredTool:()=>Yu,Tool:()=>kP,ToolInputParsingException:()=>Do,isLangChainTool:()=>zu,isRunnableToolLike:()=>ju,isStructuredTool:()=>Ru,isStructuredToolParams:()=>Mu,tool:()=>iF}),Yu=class extends wp{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return["langchain","tools"]}responseFormat="content";defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let r,i=ye(vt(this.defaultConfig,t));return Ii(e)?(r=e.args,i={...i,toolCall:e}):r=e,this.call(r,i)}async call(e,t,r){let i=Ii(e)?e.args:e,n;if(sr(this.schema))try{n=await Wi(this.schema,i)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
395
|
+
Details: ${p.message}`),qf(p)&&(m=`${m}
|
|
396
|
+
|
|
397
|
+
${Br.prettifyError(p)}`),new Do(m,JSON.stringify(e))}else{let p=Ue(i,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
398
|
+
Details: ${p.errors.map(_=>`${_.keywordLocation}: ${_.error}`).join(`
|
|
399
|
+
`)}`),new Do(m,JSON.stringify(e))}n=i}let a=Pa(t),o=ot.configure(a.callbacks,this.callbacks,a.tags||r,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Ii(e)&&(s=e.id),!s&&ik(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let u;try{let p=await this._call(n,c,a);u=Jb(p)?await sC(p,async m=>{try{await c?.handleToolEvent(m)}catch(_){await c?.handleToolError(_)}}):p}catch(p){throw await c?.handleToolError(p),p}let l,d;if(this.responseFormat==="content_and_artifact")if(Array.isArray(u)&&u.length===2)[l,d]=u;else throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.
|
|
400
|
+
Result: ${JSON.stringify(u)}`);else l=u;let f=aF({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},kP=class extends Yu{schema=bt.object({input:bt.string().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let r=typeof e=="string"||e==null?{input:e}:e;return super.call(r,t)}},$P=class extends kP{static lc_name(){return"DynamicTool"}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let r=Pa(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},IP=class extends Yu{static lc_name(){return"DynamicStructuredTool"}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,r){let i=Pa(t);return i.runName===void 0&&(i.runName=this.name),super.call(e,i,r)}_call(e,t,r){return this.func(e,t,r)}},nF=class{getTools(){return this.tools}};function iF(e,t){let r=$s(t.schema),i=js(t.schema);if(!t.schema||r||i)return new $P({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(o,s,c)=>new Promise((u,l)=>{let d=Se(c,{callbacks:s?.getChild()});$e.runWithConfig(ir(d),async()=>{try{u(e(o,d))}catch(f){l(f)}})})});let n=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new IP({...t,description:a,schema:n,func:async(o,s,c)=>new Promise((u,l)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),l(Ni(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Se(c,{callbacks:s?.getChild()});$e.runWithConfig(ir(p),async()=>{try{let m=await e(o,p);if(Jb(m)){u(m);return}if(c?.signal?.aborted){f();return}f(),u(m)}catch(m){f(),l(m)}})})})}function aF(e){let{content:t,artifact:r,toolCallId:i,metadata:n}=e;return i&&!xc(t)?typeof t=="string"||Array.isArray(t)&&t.every(a=>typeof a=="object")?new Zt({status:"success",content:t,artifact:r,tool_call_id:i,name:e.name,metadata:n}):new Zt({status:"success",content:oF(t),artifact:r,tool_call_id:i,name:e.name,metadata:n}):t}function oF(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var EP=E({RunCollectorCallbackHandler:()=>sF}),sF=class extends It{name="run_collector";exampleId;tracedRuns;constructor({exampleId:e}={}){super({_awaitHandler:!0}),this.exampleId=e,this.tracedRuns=[]}async persistRun(e){let t={...e};t.reference_example_id=this.exampleId,this.tracedRuns.push(t)}};var TP=E({});var AP=E({chunkArray:()=>cF}),cF=(e,t)=>e.reduce((r,i,n)=>{let a=Math.floor(n/t);return r[a]=(r[a]||[]).concat([i]),r},[]);var CP=E({context:()=>uF});function uF(e,...t){let r=e.raw,i="";for(let n=0;n<r.length;n++){let a=r[n].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(i+=a,n<t.length){let o=lF(t[n],i);i+=typeof o=="string"?o:JSON.stringify(o)}}return i=dF(i),i=i.trim(),i=i.replace(/\\n/g,`
|
|
401
|
+
`),i}function lF(e,t){if(typeof e!="string"||!e.includes(`
|
|
402
|
+
`))return e;let r=t.slice(t.lastIndexOf(`
|
|
403
|
+
`)+1).match(/^(\s+)/);if(r){let i=r[1];return e.replace(/\n/g,`
|
|
404
|
+
${i}`)}return e}function dF(e){let t=e.split(`
|
|
405
|
+
`),r=null;for(let i of t){let n=i.match(/^(\s+)\S+/);if(n){let a=n[1].length;r===null?r=a:r=Math.min(r,a)}}return r===null?e:t.map(i=>i[0]===" "||i[0]===" "?i.slice(r):i).join(`
|
|
406
|
+
`)}var OP=E({EventStreamContentType:()=>fF,convertEventStreamToIterableReadableDataStream:()=>mF,getBytes:()=>PP,getLines:()=>NP,getMessages:()=>RP}),fF="text/event-stream";async function PP(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let i=await r.read();if(i.done){t(new Uint8Array,!0);break}t(i.value)}}else try{for await(let r of e)t(new Uint8Array(r));t(new Uint8Array,!0)}catch(r){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${r.message}`].join(`
|
|
407
|
+
`))}}var Qs=(function(e){return e[e.NewLine=10]="NewLine",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.Colon=58]="Colon",e})(Qs||{});function NP(e){let t,r,i,n=!1;return function(o,s){if(s){e(o,0,!0);return}t===void 0?(t=o,r=0,i=-1):t=pF(t,o);let c=t.length,u=0;for(;r<c;){n&&(t[r]===Qs.NewLine&&(u=++r),n=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case Qs.Colon:i===-1&&(i=r-u);break;case Qs.CarriageReturn:n=!0;case Qs.NewLine:l=r;break}if(l===-1)break;e(t.subarray(u,l),i),u=r,i=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function RP(e,t,r){let i=a0(),n=new TextDecoder;return function(o,s,c){if(c){hF(i)||(e?.(i),i=a0());return}if(o.length===0)e?.(i),i=a0();else if(s>0){let u=n.decode(o.subarray(0,s)),l=s+(o[s+1]===Qs.Space?2:1),d=n.decode(o.subarray(l));switch(u){case"data":i.data=i.data?i.data+`
|
|
408
|
+
`+d:d;break;case"event":i.event=d;break;case"id":t?.(i.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(i.retry=f);break}}}}}function pF(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function a0(){return{data:"",event:"",id:"",retry:void 0}}function mF(e,t){let r=new ReadableStream({async start(i){let n=RP(o=>{if(o.event==="error")throw new Error(o.data??"Unspecified event streaming error.");o.event==="metadata"?t?.(o):o.data&&i.enqueue(o.data)});await PP(e,NP((o,s,c)=>{n(o,s,c),c&&i.close()}))}});return ut.fromReadableStream(r)}function hF(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var jP=E({});var MP=E({convertToOpenAIFunction:()=>zP,convertToOpenAITool:()=>gF,isLangChainTool:()=>zu,isRunnableToolLike:()=>ju,isStructuredTool:()=>Ru,isStructuredToolParams:()=>Mu});function zP(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:ht(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function gF(e,t){let r=typeof t=="number"?void 0:t,i;return zu(e)?i={type:"function",function:zP(e)}:i=e,r?.strict!==void 0&&(i.function.strict=r.strict),i}function hm(e,t){let r=0,i=0,n=0;for(let a=0;a<e.length;a++)r+=e[a]*t[a],i+=e[a]*e[a],n+=t[a]*t[a];return r/(Math.sqrt(i)*Math.sqrt(n))}function DP(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}function _F(e,t){let r=0;for(let i=0;i<e.length;i++)r+=(e[i]-t[i])*(e[i]-t[i]);return r}function UP(e,t){return Math.sqrt(_F(e,t))}var LP=E({cosineSimilarity:()=>o0,euclideanDistance:()=>bF,innerProduct:()=>vF,matrixFunc:()=>gm,maximalMarginalRelevance:()=>wF,normalize:()=>yF});function gm(e,t,r){if(e.length===0||e[0].length===0||t.length===0||t[0].length===0)return[[]];if(e[0].length!==t[0].length)throw new Error(`Number of columns in X and Y must be the same. X has shape ${[e.length,e[0].length]} and Y has shape ${[t.length,t[0].length]}.`);return e.map(i=>t.map(n=>r(i,n)).map(n=>Number.isNaN(n)?0:n))}function yF(e,t=!1){let r=xF(e);return e.map(i=>i.map(n=>t?1-n/r:n/r))}function o0(e,t){return gm(e,t,hm)}function vF(e,t){return gm(e,t,DP)}function bF(e,t){return gm(e,t,UP)}function wF(e,t,r=.5,i=4){if(Math.min(i,t.length)<=0)return[];let n=o0(Array.isArray(e[0])?e:[e],t)[0],a=FP(n).maxIndex,o=[t[a]],s=[a];for(;s.length<Math.min(i,t.length);){let c=-1/0,u=-1,l=o0(t,o);n.forEach((d,f)=>{if(s.includes(f))return;let p=Math.max(...l[f]),m=r*d-(1-r)*p;m>c&&(c=m,u=f)}),o.push(t[u]),s.push(u)}return s}function FP(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let i=1;i<e.length;i+=1)e[i]>t&&(r=i,t=e[i]);return{maxIndex:r,maxValue:t}}function xF(e){return e.reduce((t,r)=>Math.max(t,FP(r).maxValue),0)}var BP=E({isCloudMetadata:()=>s0,isLocalhost:()=>c0,isPrivateIp:()=>JP,isSafeUrl:()=>CF,isSameOrigin:()=>OF,validateSafeUrl:()=>KP}),SF=["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8","169.254.0.0/16","0.0.0.0/8","::1/128","fc00::/7","fe80::/10","ff00::/8"],kF=["169.254.169.254","169.254.170.2","100.100.100.200"],$F=["metadata.google.internal","metadata","instance-data"],IF=["localhost","localhost.localdomain"],EF=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function ZP(e){return EF.test(e)}function _m(e){return HP(e)!==null}function VP(e){return ZP(e)||_m(e)}function GP(e){if(ZP(e))return e.split(".").map(t=>parseInt(t,10));if(_m(e)){let t=HP(e);if(!t)return null;let r=t.split(":"),i=[];for(let n of r)i.push(parseInt(n,16));return i}return null}function HP(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let i=t.split("::");if(i.length>2)return null;let[n,a]=i,o=n?n.split(":"):[],s=a?a.split(":"):[],c=8-(o.length+s.length);if(c<0)return null;let u=Array(c).fill("0");t=[...o,...u,...s].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let i of r)if(i.length===0||i.length>4||!/^[0-9a-fA-F]+$/.test(i))return null;return r.map(i=>i.padStart(4,"0").toLowerCase()).join(":")}function TF(e){let[t,r]=e.split("/");if(!t||!r)return null;let i=GP(t);if(!i)return null;let n=parseInt(r,10);if(isNaN(n))return null;let a=_m(t);return a&&n>128||!a&&n>32?null:{addr:i,prefixLen:n,isIpv6:a}}function AF(e,t){let r=GP(e);if(!r)return!1;let i=TF(t);if(!i)return!1;let n=_m(e);if(n!==i.isIpv6)return!1;let{addr:a,prefixLen:o}=i;if(n)for(let s=0;s<Math.ceil(o/16);s++){let c=65535<<16-Math.min(16,o-s*16)&65535;if((r[s]&c)!==(a[s]&c))return!1}else for(let s=0;s<Math.ceil(o/8);s++){let c=255<<8-Math.min(8,o-s*8)&255;if((r[s]&c)!==(a[s]&c))return!1}return!0}function JP(e){if(!VP(e))return!1;for(let t of SF)if(AF(e,t))return!0;return!1}function s0(e,t){if(kF.includes(t||""))return!0;let r=e.toLowerCase();return!!$F.includes(r)}function c0(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let r=e.toLowerCase();return!!IF.includes(r)}function KP(e,t){let r=t?.allowPrivate??!1,i=t?.allowHttp??!1;try{let n;try{n=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let a=n.hostname;if(!a)throw new Error("URL missing hostname.");if(s0(a))throw new Error(`URL points to cloud metadata endpoint: ${a}`);if(c0(a)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}let o=n.protocol;if(o!=="http:"&&o!=="https:")throw new Error(`Invalid URL scheme: ${o}. Only http and https are allowed.`);if(o==="http:"&&!i)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(VP(a)){let s=a;if(c0(a,s)){if(!r)throw new Error(`URL points to localhost: ${a}`);return e}if(s0(a,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${a})`);if(JP(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${a}). Set allowPrivate: true to allow.`);return e}return e}catch(n){throw n&&typeof n=="object"&&"message"in n?n:new Error(`URL validation failed: ${n}`)}}function CF(e,t){try{return KP(e,t),!0}catch{return!1}}function OF(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var WP=E({SaveableVectorStore:()=>PF,VectorStore:()=>vm,VectorStoreRetriever:()=>ym}),ym=class extends Ou{static lc_name(){return"VectorStoreRetriever"}get lc_namespace(){return["langchain_core","vectorstores"]}vectorStore;k=4;searchType="similarity";searchKwargs;filter;_vectorstoreType(){return this.vectorStore._vectorstoreType()}constructor(e){super(e),this.vectorStore=e.vectorStore,this.k=e.k??this.k,this.searchType=e.searchType??this.searchType,this.filter=e.filter,e.searchType==="mmr"&&(this.searchKwargs=e.searchKwargs)}async _getRelevantDocuments(e,t){if(this.searchType==="mmr"){if(typeof this.vectorStore.maxMarginalRelevanceSearch!="function")throw new Error(`The vector store backing this retriever, ${this._vectorstoreType()} does not support max marginal relevance search.`);return this.vectorStore.maxMarginalRelevanceSearch(e,{k:this.k,filter:this.filter,...this.searchKwargs},t?.getChild("vectorstore"))}return this.vectorStore.similaritySearch(e,this.k,this.filter,t?.getChild("vectorstore"))}async addDocuments(e,t){return this.vectorStore.addDocuments(e,t)}},vm=class extends at{lc_namespace=["langchain","vectorstores",this._vectorstoreType()];embeddings;constructor(e,t){super(t),this.embeddings=e}async delete(e){throw new Error("Not implemented.")}async similaritySearch(e,t=4,r=void 0,i=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(n=>n[0])}async similaritySearchWithScore(e,t=4,r=void 0,i=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,i){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,r,i,n,a){if(typeof e=="number")return new ym({vectorStore:this,k:e,filter:t,tags:[...i??[],this._vectorstoreType()],metadata:n,verbose:a,callbacks:r});{let o={vectorStore:this,k:e?.k,filter:e?.filter,tags:[...e?.tags??[],this._vectorstoreType()],metadata:e?.metadata,verbose:e?.verbose,callbacks:e?.callbacks,searchType:e?.searchType};return e?.searchType==="mmr"?new ym({...o,searchKwargs:e.searchKwargs}):new ym({...o})}}},PF=class extends vm{static load(e,t){throw new Error("Not implemented")}};var qP=class extends ta{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new Ee(t.stop[0]),text:t.stop[0]}]};let i=e.map(n=>typeof n.content=="string"?n.content:JSON.stringify(n.content,null,2)).join(`
|
|
409
|
+
`);return await r?.handleLLMNewToken(i),{generations:[{message:new Ee(i),text:i}],llmOutput:{}}}},XP=class YP extends ta{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:i=[],toolStyle:n="openai",thrownErrorString:a,...o}){super(o),this.sleep=t,this.responses=r,this.chunks=i,this.toolStyle=n,this.thrownErrorString=a}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:ht(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:ht(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:ht(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:ht(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new YP({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return a.tools=r,a.withConfig({tools:n})}async _generate(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Ee({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,i){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let o of this.chunks){let s=new zi({message:new mt({content:o.content,tool_calls:o.tool_calls,additional_kwargs:o.additional_kwargs??{}}),text:o.content?.toString()??""});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let n=this.responses?.[0]??new Ee(typeof t[0].content=="string"?t[0].content:""),a=typeof n.content=="string"?n.content:"";for(let o of a){await new Promise(c=>setTimeout(c,this.sleep));let s=new zi({message:new mt({content:o}),text:o});if(r.signal?.aborted)break;yield s,await i?.handleLLMNewToken(o,void 0,void 0,void 0,void 0,{chunk:s})}}},QP=class eN extends ta{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:r,sleep:i,emitCustomEvent:n,generationInfo:a}=t;this.responses=r,this.sleep=i,this.emitCustomEvent=n??this.emitCustomEvent,this.generationInfo=a}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,i){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let n=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(n)],llmOutput:{}}}}_formatGeneration(t){return{message:new Ee(t),text:t}}async*_streamResponseChunks(t,r,i){let n=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await i?.handleCustomEvent("some_test_event",{someval:!0});let a=[...n];for(let o=0;o<a.length;o++){let s=a[o],c=o===a.length-1;if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);let u=this._createResponseChunk(s,c?this.generationInfo:void 0);if(r.signal?.aborted)break;yield u,i?.handleLLMNewToken(s)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,r){return new zi({message:new mt({content:t}),text:t,generationInfo:r})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let r=[...this.tools,...t],i=r.map(o=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:o.name,description:o.description,parameters:ht(o.schema)}};case"anthropic":return{name:o.name,description:o.description,input_schema:ht(o.schema)};case"bedrock":return{toolSpec:{name:o.name,description:o.description,inputSchema:ht(o.schema)}};case"google":return{name:o.name,description:o.description,parameters:ht(o.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),n=this.toolStyle==="google"?[{functionDeclarations:i}]:i,a=new eN({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return a.tools=r,a.toolStyle=this.toolStyle,a.i=this.i,a.withConfig({tools:n})}withStructuredOutput(t,r){return Rt.from(async i=>{let n=await this.invoke(i);if(n.tool_calls?.[0]?.args)return n.tool_calls[0].args;if(typeof n.content=="string")return JSON.parse(n.content);throw new Error("No structured output found")})}};var tN=class extends mp{vectorSize;constructor(e){super(e??{}),this.vectorSize=e?.vectorSize??4}async embedDocuments(e){return Promise.all(e.map(t=>this.embedQuery(t)))}async embedQuery(e){let t=e;t=t.toLowerCase().replaceAll(/[^a-z ]/g,"");let r=t.length%this.vectorSize,i=r===0?0:this.vectorSize-r,n=t.length+i;t=t.padEnd(n," ");let a=t.length/this.vectorSize,o=[];for(let s=0;s<t.length;s+=a)o.push(t.slice(s,s+a));return o.map(s=>{let c=0;for(let u=0;u<s.length;u+=1)c+=s===" "?0:s.charCodeAt(u);return c%26/26})}},rN=class extends mp{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}};var nN=class extends Tp{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.response??e;return await r?.handleLLMNewToken(i),i}},iN=class extends Tp{sleep=50;responses;thrownErrorString;constructor(e){super(e),this.sleep=e.sleep??this.sleep,this.responses=e.responses,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let t=this.responses?.[0];return this.responses=this.responses?.slice(1),t??e}async*_streamResponseChunks(e,t,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let i=this.responses?.[0];this.responses=this.responses?.slice(1);for(let n of i??e)await new Promise(a=>setTimeout(a,this.sleep)),yield{text:n,generationInfo:{}},await r?.handleLLMNewToken(n)}};var aN=class extends Qb{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async addUserMessage(e){this.messages.push(new Ye(e))}async addAIMessage(e){this.messages.push(new Ee(e))}async clear(){this.messages=[]}},oN=class extends pp{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},sN=class extends It{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var cN=class extends sn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var uN=class extends Ou{lc_namespace=["test","fake"];output=[new $r({pageContent:"foo"}),new $r({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var lN=class extends re{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var dN=class extends Yu{name;description;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.schema=e.schema}async _call(e,t){return JSON.stringify(e)}};var fN=class extends It{runPromiseResolver;runPromise;name="single_run_extractor";constructor(){super(),this.runPromise=new Promise(e=>{this.runPromiseResolver=e})}async persistRun(e){this.runPromiseResolver(e)}async extract(){return this.runPromise}};var pN=class mN extends vm{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...i}={}){super(t,i),this.similarity=r??hm}async addDocuments(t){let r=t.map(({pageContent:i})=>i);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let i=t.map((n,a)=>({content:r[a].pageContent,embedding:n,metadata:r[a].metadata}));this.memoryVectors=this.memoryVectors.concat(i)}async similaritySearchVectorWithScore(t,r,i){let n=o=>i?i(new $r({metadata:o.metadata,pageContent:o.content})):!0,a=this.memoryVectors.filter(n);return a.map((o,s)=>({similarity:this.similarity(t,o.embedding),index:s})).sort((o,s)=>o.similarity>s.similarity?-1:0).slice(0,r).map(o=>[new $r({metadata:a[o.index].metadata,pageContent:a[o.index].content}),o.similarity])}static async fromTexts(t,r,i,n){let a=[];for(let o=0;o<t.length;o+=1){let s=Array.isArray(r)?r[o]:r,c=new $r({pageContent:t[o],metadata:s});a.push(c)}return mN.fromDocuments(a,i,n)}static async fromDocuments(t,r,i){let n=new this(r,i);return await n.addDocuments(t),n}static async fromExistingIndex(t,r){return new this(t,r)}};var hN=E({FakeChatMessageHistory:()=>aN,FakeChatModel:()=>qP,FakeEmbeddings:()=>rN,FakeLLM:()=>nN,FakeListChatMessageHistory:()=>oN,FakeListChatModel:()=>QP,FakeRetriever:()=>uN,FakeRunnable:()=>lN,FakeSplitIntoListParser:()=>cN,FakeStreamingChatModel:()=>XP,FakeStreamingLLM:()=>iN,FakeTool:()=>dN,FakeTracer:()=>sN,FakeVectorStore:()=>pN,SingleRunExtractor:()=>fN,SyntheticEmbeddings:()=>tN});var gN=E({agents:()=>NS,caches:()=>Rk,callbacks__base:()=>Zk,callbacks__manager:()=>VI,callbacks__promises:()=>FI,chat_history:()=>EC,document_loaders__base:()=>CC,document_loaders__langsmith:()=>OC,documents:()=>AC,embeddings:()=>PC,errors:()=>zS,example_selectors:()=>FC,index:()=>PS,indexing:()=>VC,language_models__base:()=>YC,language_models__chat_models:()=>wO,language_models__llms:()=>xO,language_models__profile:()=>kO,language_models__structured_output:()=>vO,load__serializable:()=>SS,memory:()=>$O,messages:()=>IC,messages__tool:()=>nk,output_parsers:()=>hO,output_parsers__openai_functions:()=>TO,output_parsers__openai_tools:()=>AO,outputs:()=>sE,prompt_values:()=>GC,prompts:()=>BO,retrievers:()=>VO,retrievers__document_compressors:()=>ZO,runnables:()=>nO,runnables__graph:()=>tC,singletons:()=>qI,stores:()=>GO,structured_query:()=>YO,testing:()=>n1,tools:()=>SP,tracers__base:()=>TI,tracers__console:()=>RI,tracers__log_stream:()=>oE,tracers__run_collector:()=>EP,tracers__tracer_langchain:()=>MI,types__stream:()=>TP,utils__async_caller:()=>fE,utils__chunk_array:()=>AP,utils__context:()=>CP,utils__env:()=>$S,utils__event_source_parse:()=>OP,utils__format:()=>jP,utils__function_calling:()=>MP,utils__hash:()=>RS,utils__json_patch:()=>iO,utils__json_schema:()=>KA,utils__math:()=>LP,utils__ssrf:()=>BP,utils__standard_schema:()=>pE,utils__stream:()=>XI,utils__testing:()=>hN,utils__tiktoken:()=>qC,utils__types:()=>gO,vectorstores:()=>WP});var NF=50;function RF(e){let t={};for(let r=e;r&&r.prototype;r=Object.getPrototypeOf(r))Object.assign(t,Reflect.get(r.prototype,"lc_aliases"));return Object.entries(t).reduce((r,[i,n])=>(r[n]=i,r),{})}async function bm(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:i,secretsMap:n,secretsFromEnv:a,path:o,depth:s,maxDepth:c}=this,u=o.join(".");if(s>c)throw new Error(`Maximum recursion depth (${c}) exceeded during deserialization. This may indicate a malicious payload or you may need to increase maxDepth.`);if(typeof e!="object"||e==null)return e;if(Array.isArray(e))return Promise.all(e.map((f,p)=>bm.call({...this,path:[...o,`${p}`],depth:s+1},f)));let l=e;if(hh(l))return Cl(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[f]=l.id;if(f in n)return n[f];if(a){let p=Ft(f);if(p)return p}throw new Error(`Missing secret "${f}" at ${u}`)}if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="not_implemented"){let f=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${f}`)}if("lc"in l&&"type"in l&&"id"in l&&"kwargs"in l&&l.lc===1&&l.type==="constructor"){let f=l,p=JSON.stringify(f),[m,..._]=f.id.slice().reverse(),v=_.reverse(),x={langchain_core:gN,langchain:i},w=null,S=[v.join("/")];v[0]==="langchain_community"&&S.push(["langchain",...v.slice(1)].join("/"));let $=S.find(A=>A in t);if(OS.concat(r).includes(v.join("/"))||$)if($!==void 0)w=await t[$];else throw new Error(`Missing key "${v.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let A;if(v[0]==="langchain"||v[0]==="langchain_core")A=x[v[0]],v.shift();else throw new Error(`Invalid namespace: ${u} -> ${p}`);if(v.length===0)throw new Error(`Invalid namespace: ${u} -> ${p}`);let y;do{if(y=v.join("__"),y in A)break;v.pop()}while(v.length>0);y in A&&(w=A[y])}if(typeof w!="object"||w===null)throw new Error(`Invalid namespace: ${u} -> ${p}`);let T=w[m]??Object.values(w).find(A=>typeof A=="function"&&No(A)===m);if(typeof T!="function")throw new Error(`Invalid identifer: ${u} -> ${p}`);let F=new T(Tl(await bm.call({...this,path:[...o,"kwargs"],depth:s+1},f.kwargs),vS,RF(T)));return Object.defineProperty(F.constructor,"name",{value:m}),F}let d={};for(let[f,p]of Object.entries(l))d[f]=await bm.call({...this,path:[...o,f],depth:s+1},p);return d}async function _N(e,t){let r=JSON.parse(e),i={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??NF};return bm.call(i,r)}function jF(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function u0(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>u0(t)));{let t={};for(let[r,i]of Object.entries(e))t[r]=await u0(i);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let r=t.id[t.id.length-1],i;switch(r){case"Set":i=Set;break;case"Map":i=Map;break;case"RegExp":i=RegExp;break;case"Error":i=Error;break;case"Uint8Array":i=Uint8Array;break;default:return t}return t.method?i[t.method](...t.args||[]):new i(...t.args||[])}catch{return t}else if(jF(t))return _N(JSON.stringify(t));return t}}return e}function wm(e,t,r,i){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:i??{}}}function MF(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Set||e instanceof Map?wm(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?wm(RegExp,void 0,[e.source,e.flags]):e instanceof Error?wm(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args}:e instanceof Uint8Array?wm(Uint8Array,"from",[Array.from(e)]):e}var xm=class{_dumps(e){return new TextEncoder().encode(oS(e,(t,r)=>MF(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return u0(JSON.parse(e))}async loadsTyped(e,t){if(e==="bytes")return typeof t=="string"?new TextEncoder().encode(t):t;if(e==="json")return this._loads(typeof t=="string"?t:new TextDecoder().decode(t));throw new Error(`Unknown serialization type: ${e}`)}};function l0(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=l0(e[r]));return t}function ec(){return{v:4,id:vc(-2),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function ln(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:l0(e.versions_seen)}}var Sm=class{serde=new xm;constructor(e){this.serde=e||this.serde}async get(e){let t=await this.getTuple(e);return t?t.checkpoint:void 0}getNextVersion(e){if(typeof e=="string")throw new Error("Please override this method to use string versions.");return e!==void 0&&typeof e=="number"?e+1:1}};function km(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Qu(...e){return e.reduce((t,r,i)=>i===0?r:km(t,r)>=0?t:r)}var el={[uh]:-1,[va]:-2,[lh]:-3,[dh]:-4};function d0(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}function tl(e,t,r){return JSON.stringify([e,t,r])}function zF(e){let[t,r,i]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:i}}var yN=class extends Sm{storage={};writes={};constructor(e){super(e)}async _migratePendingSends(e,t,r,i){let n=e,a=tl(t,r,i),o=await Promise.all(Object.values(this.writes[a]??{}).filter(([s,c])=>c===bc).map(async([s,c,u])=>await this.serde.loadsTyped("json",u)));n.channel_values??={},n.channel_values[bc]=o,n.channel_versions??={},n.channel_versions[bc]=Object.keys(n.channel_versions).length>0?Qu(...Object.values(n.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",i=d0(e);if(i){let n=this.storage[t]?.[r]?.[i];if(n!==void 0){let[a,o,s]=n,c=tl(t,r,i),u=await this.serde.loadsTyped("json",a);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:e,checkpoint:u,metadata:await this.serde.loadsTyped("json",o),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let n=this.storage[t]?.[r];if(n!==void 0){i=Object.keys(n).sort((f,p)=>p.localeCompare(f))[0];let[a,o,s]=n[i],c=tl(t,r,i),u=await this.serde.loadsTyped("json",a);u.v<4&&s!==void 0&&await this._migratePendingSends(u,t,r,s);let l=await Promise.all(Object.values(this.writes[c]||{}).map(async([f,p,m])=>[f,p,await this.serde.loadsTyped("json",m)])),d={config:{configurable:{thread_id:t,checkpoint_id:i,checkpoint_ns:r}},checkpoint:u,metadata:await this.serde.loadsTyped("json",o),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}}async*list(e,t){let{before:r,limit:i,filter:n}=t??{},a=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),o=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of a)for(let u of Object.keys(this.storage[c]??{})){if(o!==void 0&&u!==o)continue;let l=this.storage[c]?.[u]??{},d=Object.entries(l).sort((f,p)=>p[0].localeCompare(f[0]));for(let[f,[p,m,_]]of d){if(s&&f!==s||r&&r.configurable?.checkpoint_id&&f>=r.configurable.checkpoint_id)continue;let v=await this.serde.loadsTyped("json",m);if(n&&!Object.entries(n).every(([F,A])=>v[F]===A))continue;if(i!==void 0){if(i<=0)break;i-=1}let x=tl(c,u,f),w=Object.values(this.writes[x]||{}),S=await Promise.all(w.map(async([F,A,y])=>[F,A,await this.serde.loadsTyped("json",y)])),$=await this.serde.loadsTyped("json",p);$.v<4&&_!==void 0&&await this._migratePendingSends($,c,u,_);let T={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:f}},checkpoint:$,metadata:v,pendingWrites:S};_!==void 0&&(T.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:_}}),yield T}}}async put(e,t,r){let i=ln(t),n=e.configurable?.thread_id,a=e.configurable?.checkpoint_ns??"";if(n===void 0)throw new Error('Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property.');this.storage[n]||(this.storage[n]={}),this.storage[n][a]||(this.storage[n][a]={});let[[,o],[,s]]=await Promise.all([this.serde.dumpsTyped(i),this.serde.dumpsTyped(r)]);return this.storage[n][a][t.id]=[o,s,e.configurable?.checkpoint_id],{configurable:{thread_id:n,checkpoint_ns:a,checkpoint_id:t.id}}}async putWrites(e,t,r){let i=e.configurable?.thread_id,n=e.configurable?.checkpoint_ns,a=e.configurable?.checkpoint_id;if(i===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property');if(a===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');let o=tl(i,n,a),s=this.writes[o];this.writes[o]===void 0&&(this.writes[o]={}),await Promise.all(t.map(async([c,u],l)=>{let[,d]=await this.serde.dumpsTyped(u),f=[r,el[c]||l],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[o][p]=[r,c,d])}))}async deleteThread(e){delete this.storage[e];for(let t of Object.keys(this.writes))zF(t).threadId===e&&delete this.writes[t]}};var tc=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function DF(e){if(e.length===0)throw new tc("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new tc(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new tc(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new tc(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new tc(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var rc=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:i=10,offset:n=0,query:a}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:i,offset:n,query:a}]))[0]}async put(e,t,r,i){DF(e),await this.batch([{namespace:e,key:t,value:r,index:i}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:i,limit:n=100,offset:a=0}=e,o=[];return t&&o.push({matchType:"prefix",path:t}),r&&o.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:o.length?o:void 0,maxDepth:i,limit:n,offset:a}]))[0]}start(){}stop(){}};var UF=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,$m=class extends rc{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=UF(e)}get isRunning(){return this.running}async batch(e){throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.")}async get(e,t){return this.enqueueOperation({namespace:e,key:t})}async search(e,t){let{filter:r,limit:i=10,offset:n=0,query:a}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:i,offset:n,query:a})}async put(e,t,r){return this.enqueueOperation({namespace:e,key:t,value:r})}async delete(e,t){return this.enqueueOperation({namespace:e,key:t,value:null})}start(){this.running||(this.running=!0,this.processingTask=this.processBatchQueue())}async stop(){this.running=!1,this.processingTask&&await this.processingTask}enqueueOperation(e){return new Promise((t,r)=>{let i=this.nextKey;this.nextKey+=1,this.queue.set(i,{operation:e,resolve:t,reject:r})})}async processBatchQueue(){for(;this.running;){if(await new Promise(t=>{setTimeout(t,0)}),this.queue.size===0)continue;let e=new Map(this.queue);this.queue.clear();try{let t=Array.from(e.values()).map(({operation:i})=>i),r=await this.store.batch(t);e.forEach(({resolve:i},n)=>{i(r[Array.from(e.keys()).indexOf(n)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};function rl(e){if(!e)return[];let t=[],r=[],i=0;for(;i<e.length;){let n=e[i];if(n==="["){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["["];for(i+=1;i<e.length&&a>0;)e[i]==="["?a+=1:e[i]==="]"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else if(n==="{"){r.length&&(t.push(r.join("")),r=[]);let a=1,o=["{"];for(i+=1;i<e.length&&a>0;)e[i]==="{"?a+=1:e[i]==="}"&&(a-=1),o.push(e[i]),i+=1;t.push(o.join(""));continue}else n==="."?r.length&&(t.push(r.join("")),r=[]):r.push(n);i+=1}return r.length&&t.push(r.join("")),t}function LF(e){return typeof e=="object"&&e!==null&&Object.keys(e).every(t=>t==="$eq"||t==="$ne"||t==="$gt"||t==="$gte"||t==="$lt"||t==="$lte"||t==="$in"||t==="$nin")}function vN(e,t){return LF(t)?Object.keys(t).filter(r=>r.startsWith("$")).every(r=>{let i=t[r];switch(r){case"$eq":return e===i;case"$ne":return e!==i;case"$gt":return Number(e)>Number(i);case"$gte":return Number(e)>=Number(i);case"$lt":return Number(e)<Number(i);case"$lte":return Number(e)<=Number(i);case"$in":return Array.isArray(i)?i.includes(e):!1;case"$nin":return Array.isArray(i)?!i.includes(e):!0;default:return!1}}):e===t}function bN(e,t){if(!t||t==="$")return[JSON.stringify(e,null,2)];let r=Array.isArray(t)?t:rl(t);function i(n,a,o){if(o>=a.length)return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?[String(n)]:n==null?[]:Array.isArray(n)||typeof n=="object"?[JSON.stringify(n,null,2)]:[];let s=a[o],c=[];if(o===0&&s==="$"&&c.push(JSON.stringify(n,null,2)),s.startsWith("[")&&s.endsWith("]")){if(!Array.isArray(n))return[];let u=s.slice(1,-1);if(u==="*")for(let l of n)c.push(...i(l,a,o+1));else try{let l=parseInt(u,10);l<0&&(l=n.length+l),l>=0&&l<n.length&&c.push(...i(n[l],a,o+1))}catch{return[]}}else if(s.startsWith("{")&&s.endsWith("}")){if(typeof n!="object"||n===null)return[];let u=s.slice(1,-1).split(",").map(l=>l.trim());for(let l of u){let d=rl(l);if(d.length){let f=n;for(let p of d)if(f&&typeof f=="object"&&p in f)f=f[p];else{f=void 0;break}f!==void 0&&(typeof f=="string"||typeof f=="number"||typeof f=="boolean"?c.push(String(f)):(Array.isArray(f)||typeof f=="object")&&c.push(JSON.stringify(f,null,2)))}}}else if(s==="*"){if(Array.isArray(n))for(let u of n)c.push(...i(u,a,o+1));else if(typeof n=="object"&&n!==null)for(let u of Object.values(n))c.push(...i(u,a,o+1))}else typeof n=="object"&&n!==null&&s in n&&c.push(...i(n[s],a,o+1));return c}return i(e,r,0)}var wN=class extends rc{data=new Map;vectors=new Map;_indexConfig;constructor(e){super(),e?.index&&(this._indexConfig={...e.index,__tokenizedFields:(e.index.fields??["$"]).map(t=>[t,t==="$"?[t]:rl(t)])})}async batch(e){let t=[],r=new Map,i=new Map;for(let n=0;n<e.length;n+=1){let a=e[n];if("key"in a&&"namespace"in a&&!("value"in a))t.push(this.getOperation(a));else if("namespacePrefix"in a){let o=this.filterItems(a);i.set(n,[a,o]),t.push(null)}else if("value"in a){let o=`${a.namespace.join(":")}:${a.key}`;r.set(o,a),t.push(null)}else"matchConditions"in a&&t.push(this.listNamespacesOperation(a))}if(i.size>0)if(this._indexConfig?.embeddings){let n=new Set;for(let[s]of i.values())s.query&&n.add(s.query);let a=n.size>0?await Promise.all(Array.from(n).map(s=>this._indexConfig.embeddings.embedQuery(s))):[],o=Object.fromEntries(Array.from(n).map((s,c)=>[s,a[c]]));for(let[s,[c,u]]of i.entries())if(c.query&&o[c.query]){let l=o[c.query];t[s]=this.scoreResults(u,l,c.offset??0,c.limit??10)}else t[s]=this.paginateResults(u.map(l=>({...l,score:void 0})),c.offset??0,c.limit??10)}else for(let[n,[a,o]]of i.entries())t[n]=this.paginateResults(o.map(s=>({...s,score:void 0})),a.offset??0,a.limit??10);if(r.size>0&&this._indexConfig?.embeddings){let n=this.extractTexts(Array.from(r.values()));if(Object.keys(n).length>0){let a=await this._indexConfig.embeddings.embedDocuments(Object.keys(n));this.insertVectors(n,a)}}for(let n of r.values())this.putOperation(n);return t}getOperation(e){let t=e.namespace.join(":");return this.data.get(t)?.get(e.key)??null}putOperation(e){let t=e.namespace.join(":");this.data.has(t)||this.data.set(t,new Map);let r=this.data.get(t);if(e.value===null)r.delete(e.key);else{let i=new Date;if(r.has(e.key)){let n=r.get(e.key);n.value=e.value,n.updatedAt=i}else r.set(e.key,{value:e.value,key:e.key,namespace:e.namespace,createdAt:i,updatedAt:i})}}listNamespacesOperation(e){let t=Array.from(this.data.keys()).map(r=>r.split(":"));return e.matchConditions&&e.matchConditions.length>0&&(t=t.filter(r=>e.matchConditions.every(i=>this.doesMatch(i,r)))),e.maxDepth!==void 0&&(t=Array.from(new Set(t.map(r=>r.slice(0,e.maxDepth).join(":")))).map(r=>r.split(":"))),t.sort((r,i)=>r.join(":").localeCompare(i.join(":"))),t.slice(e.offset??0,(e.offset??0)+(e.limit??t.length))}doesMatch(e,t){let{matchType:r,path:i}=e;if(r==="prefix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[a];return n==="*"||o===n});if(r==="suffix")return i.length>t.length?!1:i.every((n,a)=>{let o=t[t.length-i.length+a];return n==="*"||o===n});throw new Error(`Unsupported match type: ${r}`)}filterItems(e){let t=[];for(let[i,n]of this.data.entries())i.startsWith(e.namespacePrefix.join(":"))&&t.push(...n.values());let r=t;return e.filter&&(r=t.filter(i=>Object.entries(e.filter).every(([n,a])=>vN(i.value[n],a)))),r}scoreResults(e,t,r=0,i=10){let n=[],a=[],o=[];for(let l of e){let d=this.getVectors(l);if(d.length)for(let f of d)n.push(l),a.push(f);else o.push(l)}let s=this.cosineSimilarity(t,a).map((l,d)=>[l,n[d]]).sort((l,d)=>d[0]-l[0]),c=new Set,u=[];for(let[l,d]of s){let f=`${d.namespace.join(":")}:${d.key}`;if(c.has(f))continue;let p=c.size;if(p>=r+i)break;if(p<r){c.add(f);continue}c.add(f),u.push([l,d])}if(o.length&&u.length<i)for(let l of o.slice(0,i-u.length)){let d=`${l.namespace.join(":")}:${l.key}`;c.has(d)||(c.add(d),u.push([void 0,l]))}return u.map(([l,d])=>({...d,score:l}))}paginateResults(e,t,r){return e.slice(t,t+r)}extractTexts(e){if(!e.length||!this._indexConfig)return{};let t={};for(let r of e)if(r.value!==null&&r.index!==!1){let i=r.index===null||r.index===void 0?this._indexConfig.__tokenizedFields??[]:r.index.map(n=>[n,rl(n)]);for(let[n,a]of i){let o=bN(r.value,a);o.length&&(o.length>1?o.forEach((s,c)=>{t[s]||(t[s]=[]),t[s].push([r.namespace,r.key,`${n}.${c}`])}):(t[o[0]]||(t[o[0]]=[]),t[o[0]].push([r.namespace,r.key,n])))}}return t}insertVectors(e,t){for(let[r,i]of Object.entries(e)){let n=t.shift();if(!n)throw new Error(`No embedding found for text: ${r}`);for(let[a,o,s]of i){let c=a.join(":");this.vectors.has(c)||this.vectors.set(c,new Map);let u=this.vectors.get(c);u.has(o)||u.set(o,new Map),u.get(o).set(s,n)}}}getVectors(e){let t=e.namespace.join(":"),r=e.key;if(!this.vectors.has(t))return[];let i=this.vectors.get(t);if(!i.has(r))return[];let n=i.get(r),a=Array.from(n.values());return a.length?a:[]}cosineSimilarity(e,t){if(!t.length)return[];let r=t.map(a=>a.reduce((o,s,c)=>o+s*e[c],0)),i=Math.sqrt(e.reduce((a,o)=>a+o*o,0)),n=t.map(a=>Math.sqrt(a.reduce((o,s)=>o+s*s,0)));return r.map((a,o)=>{let s=n[o];return i&&s?a/(i*s):0})}get indexConfig(){return this._indexConfig}};var Im=class{serde=new xm;constructor(e){this.serde=e||this.serde}};function p0(e){return e!=null&&e.lg_is_channel===!0}var wt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Ae.unminifiable_name)return!1;throw e}}equals(e){return this===e}},f0=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function nl(e){if(e[f0]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=e[r];p0(i)&&(t[r]=i)}return Object.assign(t,{[f0]:!0}),t}function ra(e,t){let r=nl(e),i={};for(let n in r){if(!Object.prototype.hasOwnProperty.call(r,n))continue;let a=t.channel_values[n];i[n]=r[n].fromCheckpoint(a)}return Object.assign(i,{[f0]:!0}),i}function dn(e,t,r,i){let n;if(t===void 0)n=e.channel_values;else{n={};for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))try{n[a]=t[a].checkpoint()}catch(o){if(o.name!==Ae.unminifiable_name)throw o}}return{v:4,id:i?.id??vc(r),ts:new Date().toISOString(),channel_values:n,channel_versions:e.channel_versions,versions_seen:e.versions_seen}}var FF=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",gi=class xN extends wt{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,r){super(),this.operator=t,this.initialValueFactory=r,this.value=r?.()}fromCheckpoint(t){let r=new xN(this.operator,this.initialValueFactory);return typeof t<"u"&&(r.value=t),r}update(t){let r=t;if(!r.length)return!1;if(this.value===void 0){let n=r[0],[a,o]=_l(n);a?this.value=o:this.value=n,r=r.slice(1)}let i=!1;for(let n of r)if(Q0(n)){if(i)throw new _e("Can receive only one Overwrite value per step.");let[,a]=_l(n);this.value=a,i=!0;continue}else!i&&this.value!==void 0&&(this.value=this.operator(this.value,n));return!0}get(){if(this.value===void 0)throw new Ae;return this.value}checkpoint(){if(this.value===void 0)throw new Ae;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:FF(t)?this.operator===t.operator:!1}};var fn=class SN extends wt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new SN(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new _e("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ae;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ae;return this.value[0]}isAvailable(){return this.value.length!==0}},m0=class kN extends wt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new kN;if(typeof t<"u"){let[i,n]=t;r.value=[i],r.finished=n}return r}update(t){return t.length===0?!1:(this.finished=!1,this.value=[t[t.length-1]],!0)}get(){if(this.value.length===0||!this.finished)throw new Ae;return this.value[0]}checkpoint(){if(this.value.length!==0)return[this.value[0],this.finished]}consume(){return this.finished?(this.finished=!1,this.value=[],!0):!1}finish(){return!this.finished&&this.value.length>0?(this.finished=!0,!0):!1}isAvailable(){return this.value.length!==0&&this.finished}};var Em=class{lc_graph_name="AnnotationRoot";spec;constructor(e){this.spec=e}static isInstance(e){return typeof e=="object"&&e!==null&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"}},il=function(e){return e?Tm(e):new fn};il.Root=e=>new Em(e);function Tm(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new gi(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new gi(e.value,e.default):new fn}var BF=["tags","metadata","callbacks","configurable"],ZF=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","executionInfo","serverInfo"],VF=25;function nc(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:VF,configurable:{}},r=$e.getRunnableConfig();if(r!==void 0){for(let[i,n]of Object.entries(r))if(n!==void 0)if(BF.includes(i)){let a;Array.isArray(n)?a=[...n]:typeof n=="object"?i==="callbacks"&&"copy"in n&&typeof n.copy=="function"?a=n.copy():a={...n}:a=n,t[i]=a}else t[i]=n}for(let i of e)if(i!==void 0)for(let[n,a]of Object.entries(i))a!==void 0&&ZF.includes(n)&&(t[n]=a);for(let[i,n]of Object.entries(t.configurable))t.metadata=t.metadata??{},!i.startsWith("__")&&(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&!(i in t.metadata)&&(t.metadata[i]=n);return t}function GF(e){let t=e??$e.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getStore` in such environment, pass the `config` from the node function directly."].join(`
|
|
410
|
+
`));return t?.store}function HF(e){let t=e??$e.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getWriter` in such environment, pass the `config` from the node function directly."].join(`
|
|
411
|
+
`));return t?.writer||t?.configurable?.writer}function h0(){return $e.getRunnableConfig()}function JF(e){let t=e??$e.getRunnableConfig();if(t===void 0)throw new Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
|
|
412
|
+
`));if(t.configurable?.__pregel_scratchpad?.currentTaskInput===void 0)throw new Error("BUG: internal scratchpad not initialized.");return t.configurable[rr].currentTaskInput}function Am(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function $N(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var L=e=>BigInt(e),Re=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),AN=L("0x9E3779B1"),CN=L("0x85EBCA77"),KF=L("0xC2B2AE3D"),na=L("0x9E3779B185EBCA87"),vo=L("0xC2B2AE3D27D4EB4F"),ON=L("0x165667B19E3779F9"),y0=L("0x85EBCA77C2B2AE63"),WF=L("0x27D4EB2F165667C5"),qF=L("0x165667919E3779F9"),XF=L("0x9FB21C651E98DF25"),YF=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,i=new Uint8Array(r),n=0,a=0;for(;a<r;){let o=e.slice(n,n+=2);i[a]=Number.parseInt(o,16),a+=1}return Re(i)},Vn=YF("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),ic=(L(1)<<L(128))-L(1),ge=(L(1)<<L(64))-L(1),Nm=(L(1)<<L(32))-L(1),_i=64,PN=_i/8,QF=8,Cm=4;function ac(e){if(!e)throw new Error("Assert failed")}function eB(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function tB(e){let t=e;return t=(t&L(65535))<<L(16)|(t&L(4294901760))>>L(16),t=(t&L(16711935))<<L(8)|(t&L(4278255360))>>L(8),t}function rB(e,t){return(e&Nm)*(t&Nm)&ge}function nB(e,t){return(e<<t|e>>L(32)-t)&Nm}function NN(e,t,r){for(let i=0;i<PN;i+=1){let n=t.getBigUint64(i*8,!0),a=n^r.getBigUint64(i*8,!0);e[i^1]+=n,e[i]+=rB(a,a>>L(32))}return e}function IN(e,t,r,i){for(let n=0;n<i;n+=1)NN(e,Re(t,n*_i),Re(r,n*8));return e}function iB(e,t){for(let r=0;r<PN;r+=1){let i=t.getBigUint64(r*8,!0),n=e[r];n=g0(n,L(47)),n^=i,n*=AN,e[r]=n&ge}return e}function Om(e,t){return RN(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(QF,!0))}function EN(e,t,r){let i=r;return i+=Om(e.slice(0),Re(t,0*Cm)),i+=Om(e.slice(2),Re(t,4*Cm)),i+=Om(e.slice(4),Re(t,8*Cm)),i+=Om(e.slice(6),Re(t,12*Cm)),Gn(i&ge)}function aB(e,t,r,i,n){let a=e,o=Math.floor((r.byteLength-_i)/8),s=_i*o,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)a=IN(a,Re(t,u*s),r,o),a=n(a,Re(r,r.byteLength-_i));{let u=Math.floor((t.byteLength-1-s*c)/_i);a=IN(a,Re(t,c*s),r,u),a=i(a,Re(t,t.byteLength-_i),Re(r,r.byteLength-_i-7))}return a}function oB(e,t){let r=new BigUint64Array([KF,na,vo,ON,y0,CN,WF,AN]);ac(e.byteLength>128),r=aB(r,e,t,NN,iB),ac(r.length*8===64);{let i=EN(r,Re(t,11),L(e.byteLength)*na&ge);return EN(r,Re(t,t.byteLength-_i-11),~(L(e.byteLength)*vo)&ge)<<L(64)|i}}function RN(e,t){let r=e*t⁣return r&ge^r>>L(64)}function TN(e,t,r){return RN((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&ge,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&ge)}function Pm(e,t,r,i,n){let a=e&ge,o=e>>L(64)≥return a+=TN(t,i,n),a^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),a&=ge,o+=TN(r,Re(i,16),n),o^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),o&=ge,o<<L(64)|a}function Gn(e){let t=e;return t^=t>>L(37),t*=qF,t&=ge,t^=t>>L(32),t}function Rm(e){let t=e;return t^=t>>L(33),t*=vo,t&=ge,t^=t>>L(29),t*=ON,t&=ge,t^=t>>L(32),t}function sB(e,t,r){let i=e.byteLength;ac(i>0&&i<=3);let n=L(e.getUint8(i-1))|L(i<<8)|L(e.getUint8(0)<<16)|L(e.getUint8(i>>1)<<24),a=(n^(L(t.getUint32(0,!0))^L(t.getUint32(4,!0)))+r)&ge,o=(L(t.getUint32(8,!0))^L(t.getUint32(12,!0)))-r;return(Rm((nB(tB(n),L(13))^o)&ge)&ge)<<L(64)|Rm(a)}function g0(e,t){return e^e>>t}function cB(e,t,r){let i=e.byteLength;ac(i>=4&&i<=8);{let n=e.getUint32(0,!0),a=e.getUint32(i-4,!0),o=((L(n)|L(a)<<L(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&ge)*(na+(L(i)<<L(2)))⁣return o+=(o&ge)<<L(65),o&=ic,o^=o>>L(67),g0(g0(o&ge,L(35))*XF&ge,L(28))|Gn(o>>L(64))<<L(64)}}function uB(e,t,r){let i=e.byteLength;ac(i>=9&&i<=16);{let n=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&ge,a=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&ge,o=e.getBigUint64(0,!0),s=e.getBigUint64(i-8,!0),c=(o^s^n)*na,u=(c&ge)+(L(i-1)<<L(54));c=c&(ic^ge)|u,s^=a,c+=s+(s&Nm)*(CN-L(1))<<L(64),c&=ic,c^=eB(c>>L(64));let l=(c&ge)*vo;return l+=(c>>L(64))*vo<<L(64),l&=ic,Gn(l&ge)|Gn(l>>L(64))<<L(64)}}function lB(e,t){let r=e.byteLength;return ac(r<=16),r>8?uB(e,Vn,t):r>=4?cB(e,Vn,t):r>0?sB(e,Vn,t):Rm(t^Vn.getBigUint64(64,!0)^Vn.getBigUint64(72,!0))|Rm(t^Vn.getBigUint64(80,!0)^Vn.getBigUint64(88,!0))<<L(64)}function _0(e){return~e+L(1)&ge}function dB(e,t,r){let i=L(e.byteLength)*na&ge,n=L(e.byteLength-1)/L(32);for(;n>=0;){let s=Number(n);i=Pm(i,Re(e,16*s),Re(e,e.byteLength-16*(s+1)),Re(t,32*s),r),n-=L(1)}let a=i+(i>>L(64))≥a=Gn(a);let o=(i&ge)*na+(i>>L(64))*y0+(L(e.byteLength)-r&ge)*vo;return o&=ge,o=_0(Gn(o)),a|o<<L(64)}function fB(e,t,r){let i=L(e.byteLength)*na≥for(let o=32;o<160;o+=32)i=Pm(i,Re(e,o-32),Re(e,o-16),Re(t,o-32),r);i=Gn(i&ge)|Gn(i>>L(64))<<L(64);for(let o=160;o<=e.byteLength;o+=32)i=Pm(i,Re(e,o-32),Re(e,o-16),Re(t,3+o-160),r);i=Pm(i,Re(e,e.byteLength-16),Re(e,e.byteLength-32),Re(t,103),_0(r));let n=i+(i>>L(64))≥n=Gn(n);let a=(i&ge)*na+(i>>L(64))*y0+(L(e.byteLength)-r&ge)*vo;return a&=ge,a=_0(Gn(a)),n|a<<L(64)}function yi(e,t=L(0)){let r=new TextEncoder,i=Re(typeof e=="string"?r.encode(e):e),n=i.byteLength,a=o=>o.toString(16).padStart(32,"0");return n<=16?a(lB(i,t)):n<=128?a(dB(i,Vn,t)):n<=240?a(fB(i,Vn,t)):a(oB(i,Vn))}function jm(e){return/^[0-9a-f]{32}$/.test(e)}function v0(e){let t=$e.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");if(!r.__pregel_checkpointer)throw new _a("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=r[rr];i.interruptCounter+=1;let n=i.interruptCounter;if(i.resume.length>0&&n<i.resume.length)return r[Er]?.([[mr,i.resume]]),i.resume[n];if(i.nullResume!==void 0){if(i.resume.length!==n)throw new Error(`Resume length mismatch: ${i.resume.length} !== ${n}`);let o=i.consumeNullResume();return i.resume.push(o),r[Er]?.([[mr,i.resume]]),o}let a=r[Tr]?.split("|");throw new Wn([{id:a?yi(a.join("|")):void 0,value:e}])}var Dt=class extends re{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.trace=e.trace??this.trace,this.recurse=e.recurse??this.recurse}async _tracedInvoke(e,t,r){return new Promise((i,n)=>{let a=Se(t,{callbacks:r?.getChild()});$e.runWithConfig(a,async()=>{try{i(await this.func(e,a))}catch(o){n(o)}})})}async invoke(e,t){let r,i=nc(t),n=vt(this.config,i);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,n):r=await $e.runWithConfig(n,async()=>this.func(e,n)),re.isRunnable(r)&&this.recurse?await $e.runWithConfig(n,async()=>r.invoke(e,n)):r}};function*vi(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function pn(e){let t=[];for await(let r of await e)t.push(r);return t}function bo(e){let t=[];for(let r of e)t.push(r);return t}function wo(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function b0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function w0(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function pB(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var fr={[Symbol.for("LG_PASSTHROUGH")]:!0};function Mm(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var x0=Symbol("IS_WRITER"),rt=class k0 extends Dt{writes;constructor(t,r){let i=`ChannelWrite<${t.map(n=>ct(n)?n.node:"channel"in n?n.channel:"...").join(",")}>`;super({writes:t,name:i,tags:r,trace:!1,func:async(n,a)=>this._write(n,a??{})}),this.writes=t}async _write(t,r){let i=this.writes.map(n=>S0(n)&&Mm(n.value)?{mapper:n.mapper,value:t}:zm(n)&&Mm(n.value)?{channel:n.channel,value:t,skipNone:n.skipNone,mapper:n.mapper}:n);return await k0.doWrite(r,i),t}static async doWrite(t,r){for(let a of r){if(zm(a)){if(a.channel==="__pregel_tasks")throw new _e("Cannot write to the reserved channel TASKS");if(Mm(a.value))throw new _e("PASSTHROUGH value must be replaced")}if(S0(a)&&Mm(a.value))throw new _e("PASSTHROUGH value must be replaced")}let i=[];for(let a of r)if(ct(a))i.push([xn,a]);else if(S0(a)){let o=await a.mapper.invoke(a.value,t);o!=null&&o.length>0&&i.push(...o)}else if(zm(a)){let o=a.mapper!==void 0?await a.mapper.invoke(a.value,t):a.value;if(pB(o)||a.skipNone&&o===void 0)continue;i.push([a.channel,o])}else throw new Error(`Invalid write entry: ${JSON.stringify(a)}`);let n=t.configurable?.[Er];n(i)}static isWriter(t){return t instanceof k0||x0 in t&&!!t[x0]}static registerWriter(t){return Object.defineProperty(t,x0,{value:!0})}};function zm(e){return e!==void 0&&typeof e.channel=="string"}function S0(e){return e!==void 0&&!zm(e)&&re.isRunnable(e.mapper)}var jN=class MN extends Dt{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,i=!1){super({trace:!1,func:(n,a)=>MN.doRead(a,this.channel,this.fresh,this.mapper)}),this.fresh=i,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,i,n){let a=t.configurable?.[Gr];if(!a)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return n?n(a(r,i)):a(r,i)}},oc=new fi,mn=class al extends Ur{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=oc;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor(t){let{channels:r,triggers:i,mapper:n,writers:a,bound:o,kwargs:s,metadata:c,retryPolicy:u,cachePolicy:l,tags:d,subgraphs:f,ends:p}=t,m=[...t.config?.tags?t.config.tags:[],...d??[]];super({...t,bound:t.bound??oc,config:{...t.config?t.config:{},tags:m}}),this.channels=r,this.triggers=i,this.mapper=n,this.writers=a??this.writers,this.bound=o??this.bound,this.kwargs=s??this.kwargs,this.metadata=c??this.metadata,this.tags=m,this.retryPolicy=u,this.cachePolicy=l,this.subgraphs=f,this.ends=p}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof rt&&t[t.length-2]instanceof rt;){let r=t.slice(-2),i=r[0].writes.concat(r[1].writes);t[t.length-2]=new rt(i,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===oc&&t.length===0))return this.bound===oc&&t.length===1?t[0]:this.bound===oc?new kr({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new kr({first:this.bound,middle:t.slice(0,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):this.bound}join(t){if(!Array.isArray(t))throw new Error("channels must be a list");if(typeof this.channels!="object")throw new Error("all channels must be named when using .join()");return new al({channels:{...this.channels,...Object.fromEntries(t.map(r=>[r,r]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}pipe(t){return rt.isWriter(t)?new al({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,t],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):this.bound===oc?new al({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:Xe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):new al({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}};function mB(e){return"steps"in e&&Array.isArray(e.steps)}function ol(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function Dm(e){let t=[e];for(let r of t){if(ol(r))return r;mB(r)&&t.push(...r.steps)}}function xo(e,t,r=!0,i=!1){try{return e[t].get()}catch(n){if(n.name===Ae.unminifiable_name){if(i)return n;if(r)return null}throw n}}function hn(e,t,r=!0){if(Array.isArray(t)){let i={};for(let n of t)try{i[n]=xo(e,n,!r)}catch(a){if(a.name===Ae.unminifiable_name)continue}return i}else return xo(e,t)}function*zN(e,t){if(e.graph===tr.PARENT)throw new _e("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let i of r)if(ct(i))yield[hr,xn,i];else if(typeof i=="string")yield[hr,`branch:to:${i}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof i}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(jm))for(let[r,i]of Object.entries(e.resume)){let n=t.filter(a=>a[0]===r&&a[1]==="__resume__").map(a=>a[2]).slice(0,1)??[];n.push(i),yield[r,mr,n]}else yield[hr,mr,e.resume];if(e.update){if(typeof e.update!="object"||!e.update)throw new Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(e.update))for(let[r,i]of e.update)yield[hr,r,i];else for(let[r,i]of Object.entries(e.update))yield[hr,r,i]}}function*Um(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let r in t)e.includes(r)&&(yield[r,t[r]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*Lm(e,t,r){Array.isArray(e)?(t===!0||t.find(([i,n])=>e.includes(i)))&&(yield hn(r,e)):(t===!0||t.some(([i,n])=>i===e))&&(yield xo(r,e))}function*DN(e,t,r){let i=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!i.length)return;let n;i.some(([s])=>s.writes.some(([c,u])=>c==="__return__"))?n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===ki).map(([c,u])=>[s.name,u])):Array.isArray(e)?n=i.flatMap(([s])=>{let{writes:c}=s,u={};for(let[l]of c)e.includes(l)&&(u[l]=(u[l]||0)+1);return Object.values(u).some(l=>l>1)?c.filter(([l])=>e.includes(l)).map(([l,d])=>[s.name,{[l]:d}]):[[s.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):n=i.flatMap(([s])=>s.writes.filter(([c,u])=>c===e).map(([c,u])=>[s.name,u]));let a={};for(let[s,c]of n)s in a||(a[s]=[]),a[s].push(c);let o={};for(let s in a)if(a[s].length===1){let[c]=a[s];o[s]=c}else o[s]=a[s];r&&(o.__metadata__={cached:r}),yield o}function Fm(e){let t=typeof e[Fe];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let i=typeof e[r];if(i==="number")return 0;if(i==="string")return"";break}}function sc(e,t){if(Object.keys(e).length>0){let r=Fm(t);return Object.fromEntries(Object.entries(t).filter(([i,n])=>n>(e[i]??r)))}else return t}function UN(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function pr(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function ia(e,t){let r=t?.parents??{};return Object.keys(r).length>0?pr(e,{[Ar]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function cc(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let r=new AbortController,i=()=>{let a=t.find(o=>o.aborted)?.reason;r.abort(a),t.forEach(o=>o.removeEventListener("abort",i))};t.forEach(a=>a.addEventListener("abort",i,{once:!0}));let n=t.find(a=>a.aborted);return n&&r.abort(n.reason),{signal:r.signal,dispose:()=>{t.forEach(a=>a.removeEventListener("abort",i))}}}var LN=(e,t)=>{if(!(!e&&!t))return e?t?Array.isArray(e)&&Array.isArray(t)?[...e,...t]:Array.isArray(e)?[...e,t]:Array.isArray(t)?[e,...t]:[e,t]:e:t};var FN=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:i,cache:n,callbacks:a}){this.func=e,this.name=t,this.input=r,this.retry=i,this.cache=n,this.callbacks=a}};function BN(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function ZN(e,t){return new kr({name:e,first:new Dt({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new rt([{channel:ki,value:fr}],[st])})}function VN(e,t){return new Dt({func:(r,i)=>t(r,i),name:e,trace:!1,recurse:!1})}function GN({func:e,name:t,cache:r,retry:i},...n){let a=$e.getRunnableConfig();if(typeof a.configurable?.__pregel_call=="function")return a.configurable[To](e,t,n,{retry:i,cache:r,callbacks:a.callbacks});throw new Error("Async local storage not initialized. Please call initializeAsyncLocalStorageSingleton() before using this function.")}var HN=e=>e!==void 0?e+1:1;function hB(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function gB(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=Qu(t,e[r]));return t}function cl(e,t,r){let i=Fm(e.channel_versions),n=e.versions_seen.__interrupt__??{},a=!1;if((e.channel_versions.__start__??i)>(n.__start__??i))a=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(n[s]??i)){a=!0;break}let o=r.some(s=>t==="*"?!s.config?.tags?.includes(st):t.includes(s.name));return a&&o}function sl(e,t,r,i,n=!1){let a=new Set;if(Array.isArray(i))a=new Set(i.filter(s=>r.writes.some(([c,u])=>c===s)));else{for(let[s]of r.writes)if(s===i){a=new Set([s]);break}a=a||new Set}let o;if(n&&a.size>0){let s=Object.fromEntries(Object.entries(t).filter(([l,d])=>a.has(l))),c=dn(e,s,-1),u=ra(s,c);Qt(ln(c),u,[r],void 0,void 0),o=hn({...t,...u},i)}else o=hn(t,i);return o}function $0(e,t,r){for(let[i,n]of r)if(["__pregel_push","__pregel_tasks"].includes(i)&&n!=null){if(!ct(n))throw new _e(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(n)}`);if(!(n.node in t))throw new _e(`Invalid node name "${n.node}" in Send packet`)}e(r)}var _B=new Set([hc,Cr,mr,Be,ki,Eo]);function Qt(e,t,r,i,n){r.sort((f,p)=>{let m=f.path?.slice(0,3)||[],_=p.path?.slice(0,3)||[];for(let v=0;v<Math.min(m.length,_.length);v+=1){if(m[v]<_[v])return-1;if(m[v]>_[v])return 1}return m.length-_.length});let a=r.some(f=>f.triggers.length>0),o=nl(t);for(let f of r){e.versions_seen[f.name]??={};for(let p of f.triggers)p in e.channel_versions&&(e.versions_seen[f.name][p]=e.channel_versions[p])}let s=gB(e.channel_versions),c=new Set(r.flatMap(f=>f.triggers).filter(f=>!X0.includes(f))),u=!1;for(let f of c)f in o&&o[f].consume()&&i!==void 0&&(e.channel_versions[f]=i(s),u=!0);let l={};for(let f of r)for(let[p,m]of f.writes)_B.has(p)||p in o&&(l[p]??=[],l[p].push(m));s!=null&&i!=null&&(s=u?i(s):s);let d=new Set;for(let[f,p]of Object.entries(l))if(f in o){let m=o[f],_;try{_=m.update(p)}catch(v){if(v.name===_e.unminifiable_name){let x=new _e(`Invalid update for channel "${f}" with values ${JSON.stringify(p)}: ${v.message}`);throw x.lc_error_code=v.lc_error_code,x}else throw v}_&&i!==void 0&&(e.channel_versions[f]=i(s),m.isAvailable()&&d.add(f))}if(a)for(let f in o){if(!Object.prototype.hasOwnProperty.call(o,f))continue;let p=o[f];p.isAvailable()&&!d.has(f)&&p.update([])&&i!==void 0&&(e.channel_versions[f]=i(s),p.isAvailable()&&d.add(f))}if(a&&!hB(d,n))for(let f in o){if(!Object.prototype.hasOwnProperty.call(o,f))continue;let p=o[f];p.finish()&&i!==void 0&&(e.channel_versions[f]=i(s),p.isAvailable()&&d.add(f))}return d}function*yB(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let i=new Set;for(let n of r.updatedChannels){let a=r.triggerToNodes[n];for(let o of a??[])i.add(o)}yield*[...i].sort();return}if(!(()=>{for(let i in e.channel_versions)if(e.channel_versions[i]!==null)return!1;return!0})())for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(yield i)}function aa(e,t,r,i,n,a,o){let s={},c=i[xn];if(c?.isAvailable()){let u=c.get().length;for(let l=0;l<u;l+=1){let d=Bm([Cr,l],e,t,r,i,n,a,o);d!==void 0&&(s[d.id]=d)}}for(let u of yB(e,r,o)){let l=Bm([hl,u],e,t,r,i,n,a,o);l!==void 0&&(s[l.id]=l)}return s}function Bm(e,t,r,i,n,a,o,s){let{step:c,checkpointer:u,manager:l}=s,d=a.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&BN(e[e.length-1])){let p=e[e.length-1],m=ZN(p.name,p.func),_=[Cr],v=f===""?p.name:`${f}|${p.name}`,x=Xn(JSON.stringify([v,c.toString(),p.name,Cr,e[1],e[2]]),t.id),w=`${v}:${x}`,S=[...e.slice(0,3),!0],$={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:_,langgraph_path:S,langgraph_checkpoint_ns:w};if(o){let T=[],F={checkpointId:t.id,checkpointNs:w,taskId:x,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p.name,input:p.input,proc:m,writes:T,config:{...Se(vt(a,{metadata:$,store:s.store??a.store}),{runName:p.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pc]:x,[Er]:A=>$0(y=>T.push(...y),i,A),[Gr]:(A,y=!1)=>sl(t,n,{name:p.name,writes:T,triggers:_,path:S},A,y),[Hr]:u??d.__pregel_checkpointer,[Ar]:{...d[Ar],[f]:t.id},[rr]:I0({pendingWrites:r??[],taskId:x,currentTaskInput:p.input,resumeMap:a.configurable?.[Co],namespaceHash:yi(w)}),[ha]:t.channel_values[ga],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:F},triggers:_,retry_policy:p.retry,cache_key:p.cache?{key:yi((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[pl,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:x,path:S,writers:[]}}else return{id:x,name:p.name,interrupts:[],path:S}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!n.__pregel_tasks?.isAvailable())return;let m=n[xn].get();if(p<0||p>=m.length)return;let _=gl(m[p])&&!ct(m[p])?new ma(m[p].node,m[p].args):m[p];if(!gl(_)){console.warn(`Ignoring invalid packet ${JSON.stringify(_)} in pending sends.`);return}if(!(_.node in i)){console.warn(`Ignoring unknown node name ${_.node} in pending sends.`);return}let v=[Cr],x=f===""?_.node:`${f}|${_.node}`,w=Xn(JSON.stringify([x,c.toString(),_.node,Cr,p.toString()]),t.id),S=`${x}:${w}`,$={langgraph_step:c,langgraph_node:_.node,langgraph_triggers:v,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:S};if(o){let T=i[_.node],F=T.getNode();if(F!==void 0){T.metadata!==void 0&&($={...$,...T.metadata});let A=[],y={checkpointId:t.id,checkpointNs:S,taskId:w,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:_.node,input:_.args,proc:F,subgraphs:T.subgraphs,writes:A,config:{...Se(vt(a,{metadata:$,tags:T.tags,store:s.store??a.store}),{runName:_.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pc]:w,[Er]:W=>$0(O=>A.push(...O),i,W),[Gr]:(W,O=!1)=>sl(t,n,{name:_.node,writes:A,triggers:v,path:e},W,O),[Hr]:u??d.__pregel_checkpointer,[Ar]:{...d[Ar],[f]:t.id},[rr]:I0({pendingWrites:r??[],taskId:w,currentTaskInput:_.args,resumeMap:a.configurable?.[Co],namespaceHash:yi(S)}),[ha]:t.channel_values[ga],checkpoint_id:void 0,checkpoint_ns:S}}),executionInfo:y},triggers:v,retry_policy:T.retryPolicy,cache_key:T.cachePolicy?{key:yi((T.cachePolicy.keyFunc??JSON.stringify)([_.args])),ns:[pl,T.name??"__dynamic__",_.node],ttl:T.cachePolicy.ttl}:void 0,id:w,path:e,writers:T.getWriters()}}}else return{id:w,name:_.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=i[p];if(m===void 0)return;if(r?.length){let w=f===""?p:`${f}|${p}`,S=Xn(JSON.stringify([w,c.toString(),p,hl,p]),t.id);if(r.some($=>$[0]===S&&$[1]!=="__error__"))return}let _=Fm(t.channel_versions);if(_===void 0)return;let v=t.versions_seen[p]??{},x=m.triggers.find(w=>n[w].isAvailable()?(t.channel_versions[w]??_)>(v[w]??_):!1);if(x!==void 0){let w=vB(m,n,o);if(w===void 0)return;let S=f===""?p:`${f}|${p}`,$=Xn(JSON.stringify([S,c.toString(),p,hl,[x]]),t.id),T=`${S}:${$}`,F={langgraph_step:c,langgraph_node:p,langgraph_triggers:[x],langgraph_path:e,langgraph_checkpoint_ns:T};if(o){let A=m.getNode();if(A!==void 0){m.metadata!==void 0&&(F={...F,...m.metadata});let y=[],W={checkpointId:t.id,checkpointNs:T,taskId:$,threadId:d.thread_id,runId:a.runId!=null?String(a.runId):void 0,nodeAttempt:1};return{name:p,input:w,proc:A,subgraphs:m.subgraphs,writes:y,config:{...Se(vt(a,{metadata:F,tags:m.tags,store:s.store??a.store}),{runName:p,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pc]:$,[Er]:O=>$0(B=>{y.push(...B)},i,O),[Gr]:(O,B=!1)=>sl(t,n,{name:p,writes:y,triggers:[x],path:e},O,B),[Hr]:u??d.__pregel_checkpointer,[Ar]:{...d[Ar],[f]:t.id},[rr]:I0({pendingWrites:r??[],taskId:$,currentTaskInput:w,resumeMap:a.configurable?.[Co],namespaceHash:yi(T)}),[ha]:t.channel_values[ga],checkpoint_id:void 0,checkpoint_ns:T}}),executionInfo:W},triggers:[x],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:yi((m.cachePolicy.keyFunc??JSON.stringify)([w])),ns:[pl,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:$,path:e,writers:m.getWriters()}}}else return{id:$,name:p,interrupts:[],path:e}}}}function vB(e,t,r){let i;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){i={};for(let[n,a]of Object.entries(e.channels))if(e.triggers.includes(a))try{i[n]=xo(t,a,!1)}catch(o){if(o.name===Ae.unminifiable_name)return;throw o}else if(a in t)try{i[n]=xo(t,a,!1)}catch(o){if(o.name===Ae.unminifiable_name)continue;throw o}}else if(Array.isArray(e.channels)){let n=!1;for(let a of e.channels)try{i=xo(t,a,!1),n=!0;break}catch(o){if(o.name===Ae.unminifiable_name)continue;throw o}if(!n)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(i=e.mapper(i)),i}function JN(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[i,n]of Object.entries(e.args)){let a=t[i];(!a||a.lc_graph_name!=="UntrackedValue")&&(r[i]=n)}return new ma(e.node,r)}function I0({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:i,namespaceHash:n}){let a=e.find(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__")?.[2],o={callCounter:0,interruptCounter:-1,resume:(()=>{let s=e.filter(([c,u])=>c===t&&u==="__resume__").flatMap(([c,u,l])=>l);if(i!=null&&n in i){let c=i[n];s.push(c)}return s})(),nullResume:a,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(o.nullResume)return delete o.nullResume,e.splice(e.findIndex(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__"),1),a}};return o}var ul={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},ll=(e,t)=>`${e.start}${t}${e.end}`;function*E0(e){for(let{id:t,name:r,input:i,config:n,triggers:a,writes:o}of e)n?.tags?.includes("langsmith:hidden")||(yield{id:t,name:r,input:i,triggers:a,interrupts:o.filter(([s,c])=>s===t&&c==="__interrupt__").map(([,s])=>s)})}function bB(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function KN(e){let t={};for(let[r,i]of e){let n=String(r);if(n in t){let a=bB(t[n])?t[n].$writes:[t[n]];a.push(i),t[n]={$writes:a}}else t[n]=i}return t}function*WN(e,t){for(let[{id:r,name:i,config:n},a]of e)n?.tags?.includes("langsmith:hidden")||(yield{id:r,name:i,result:KN(a.filter(([o])=>Array.isArray(t)?t.includes(o):o===t)),interrupts:a.filter(o=>o[0]===Be).map(o=>o[1])})}function*qN(e,t,r,i,n,a,o,s){function c(d){let f={};return d.callbacks!=null&&(f.callbacks=d.callbacks),d.configurable!=null&&(f.configurable=d.configurable),d.maxConcurrency!=null&&(f.max_concurrency=d.maxConcurrency),d.metadata!=null&&(f.metadata=d.metadata),d.recursionLimit!=null&&(f.recursion_limit=d.recursionLimit),d.runId!=null&&(f.run_id=d.runId),d.runName!=null&&(f.run_name=d.runName),d.tags!=null&&(f.tags=d.tags),f}let u=e.configurable?.checkpoint_ns,l={};for(let d of n){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(Dm))continue;let f=`${d.name}:${d.id}`;u&&(f=`${u}|${f}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:f}}}yield{config:c(e),values:hn(t,r),metadata:i,next:n.map(d=>d.name),tasks:T0(n,a,l,s),parentConfig:o?c(o):void 0}}function T0(e,t,r,i){return e.map(n=>{let a=t.find(([u,l])=>u===n.id&&l==="__error__")?.[2],o=t.filter(([u,l])=>u===n.id&&l==="__interrupt__").map(([,,u])=>u),s=(()=>{if(a||o.length||!t.length)return;let u=t.findIndex(([l,d])=>l===n.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof i=="string")return t.find(([l,d])=>l===n.id&&d===i)?.[2];if(Array.isArray(i)){let l=t.filter(([d,f])=>d===n.id&&i.includes(f)).map(([,d,f])=>[d,f]);return l.length?KN(l):void 0}})();if(a)return{id:n.id,name:n.name,path:n.path,error:a,interrupts:o,result:s};let c=r?.[n.id];return{id:n.id,name:n.name,path:n.path,interrupts:o,...c!==void 0?{state:c}:{},result:s}})}function XN(e,t,r){console.log([`${ll(ul.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
|
|
413
|
+
`,JSON.stringify(hn(t,r),null,2)].join(""))}function Zm(e,t){let r=t.length;console.log([`${ll(ul.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
|
|
414
|
+
`,t.map(i=>`- ${ll(ul.green,String(i.name))} -> ${JSON.stringify(i.input,null,2)}`).join(`
|
|
415
|
+
`)].join(""))}function YN(e,t,r){let i={};for(let[n,a]of t)r.includes(n)&&(i[n]||(i[n]=[]),i[n].push(a));console.log([`${ll(ul.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(i).length} channel${Object.keys(i).length!==1?"s":""}:\x1B[0m
|
|
416
|
+
`,Object.entries(i).map(([n,a])=>`- ${ll(ul.yellow,n)} -> ${a.map(o=>JSON.stringify(o)).join(", ")}`).join(`
|
|
417
|
+
`)].join(""))}var C0=class extends ut{_abortController;_innerReader;constructor(e,t){let r=e.getReader(),i=t??new AbortController;super({start(n){return a();function a(){return r.read().then(({done:o,value:s})=>{if(o){n.close();return}return n.enqueue(s),a()})}}}),this._abortController=i,this._innerReader=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},Vm=class extends ut{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(i=>{t=i});super({start:i=>{t(i)}}),r.then(i=>{this.controller=i}),this.passthroughFn=e.passthroughFn,this.modes=e.modes}push(e){this.passthroughFn?.(e),this.controller.enqueue(e)}close(){try{this.controller.close()}catch{}finally{this._closed=!0}}error(e){this.controller.error(e)}},tR=class extends Yr{name="StreamToolsHandler";streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,i,n,a,o,s){if(!a||n&&n.includes("langsmith:hidden"))return;let c=a.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:s,toolName:o??"unknown",input:t};this.runs[r]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.toolName,input:t}])}handleToolEvent(e,t){let r=this.runs[t];r&&this.streamFn([r.ns,"tools",{event:"on_tool_event",toolCallId:r.toolCallId,name:r.toolName,data:e}])}handleToolEnd(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_end",toolCallId:r.toolCallId,name:r.toolName,output:e}])}handleToolError(e,t){let r=this.runs[t];delete this.runs[t],r&&this.streamFn([r.ns,"tools",{event:"on_tool_error",toolCallId:r.toolCallId,name:r.toolName,error:e}])}};function wB(e){return JSON.stringify(e,function(t,r){let i=this[t];if(i!=null&&typeof i=="object"&&"toDict"in i&&typeof i.toDict=="function"){let{type:n,data:a}=i.toDict();return{...a,type:n}}return r})}function xB(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function O0(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function A0(e){return!O0(e)||!e.configurable.thread_id?null:{thread_id:e.configurable.thread_id,checkpoint_ns:e.configurable.checkpoint_ns||"",checkpoint_id:e.configurable.checkpoint_id||null,checkpoint_map:e.configurable.checkpoint_map||null}}function QN(e){if(O0(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([i])=>!i.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function eR(e){let t={...e,checkpoint:A0(e.config),parent_checkpoint:A0(e.parentConfig),config:QN(e.config),parent_config:QN(e.parentConfig),tasks:e.tasks.map(r=>{if(O0(r.state)){let i=A0(r.state);if(i!=null){let n={...r,checkpoint:i};return delete n.state,n}}return r})};return delete t.parentConfig,t}function rR(e){let t=new TextEncoder;return new ReadableStream({async start(r){let i=n=>{r.enqueue(t.encode(`event: ${n.event}
|
|
418
|
+
data: ${wB(n.data)}
|
|
419
|
+
|
|
420
|
+
`))};try{for await(let n of e){let[a,o,s]=n,c=s;if(o==="debug"){let u=s;u.type==="checkpoint"&&(c={...u,payload:eR(u.payload)})}o==="checkpoints"&&(c=eR(s)),i({event:a?.length?`${o}|${a.join("|")}`:o,data:c})}}catch(n){i({event:"error",data:xB(n)})}r.close()}})}var Gm=Symbol.for("INPUT_DONE"),P0=Symbol.for("INPUT_RESUMING"),SB=25;function kB(...e){return new Vm({passthroughFn:t=>{for(let r of e)r.modes.has(t[1])&&r.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var $B=class extends Im{cache;queue=Promise.resolve();constructor(e){super(),this.cache=e}async get(e){return this.enqueueOperation("get",e)}async set(e){return this.enqueueOperation("set",e)}async clear(e){return this.enqueueOperation("clear",e)}async stop(){await this.queue}enqueueOperation(e,...t){let r=this.queue.then(()=>this.cache[e](...t));return this.queue=r.then(()=>{},()=>{}),r}},nR=class iR{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";tasks={};stream;checkpointerPromises=new Set;isNested;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let r=t.then(i=>(this.checkpointerPromises.delete(r),i),i=>{throw i});this.checkpointerPromises.add(r)}store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let t=!1;if("__start__"in this.checkpoint.channel_versions)t=!0;else for(let s in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,s)){t=!0;break}let r=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,i=this.input===null||this.input===void 0,n=ft(this.input)&&this.input.resume!=null,a=this.input===P0,o=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return t&&(r||i||n||a||o)}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=HN,this.checkpoint=t.checkpoint,this.checkpointMetadata=t.checkpointMetadata,this.checkpointPreviousVersions=t.checkpointPreviousVersions,this.channels=t.channels,this.checkpointPendingWrites=t.checkpointPendingWrites,this.step=t.step,this.stop=t.stop,this.config=t.config,this.checkpointConfig=t.checkpointConfig,this.isNested=t.isNested,this.manager=t.manager,this.outputKeys=t.outputKeys,this.streamKeys=t.streamKeys,this.nodes=t.nodes,this.skipDoneTasks=t.skipDoneTasks,this.store=t.store,this.cache=t.cache?new $B(t.cache):void 0,this.stream=t.stream,this.checkpointNamespace=t.checkpointNamespace,this.prevCheckpointConfig=t.prevCheckpointConfig,this.interruptAfter=t.interruptAfter,this.interruptBefore=t.interruptBefore,this.durability=t.durability,this.debug=t.debug,this.triggerToNodes=t.triggerToNodes}static async initialize(t){let{config:r,stream:i}=t;i!==void 0&&r.configurable?.__pregel_stream!==void 0&&(i=kB(i,r.configurable[mc]));let n=r.configurable?!("checkpoint_id"in r.configurable):!0,a=r.configurable?.[rr];r.configurable&&a&&(a.subgraphCounter>0&&(r=pr(r,{[Tr]:[r.configurable[Tr],a.subgraphCounter.toString()].join("|")})),a.subgraphCounter+=1);let o=Gr in(r.configurable??{});!o&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=pr(r,{checkpoint_ns:"",checkpoint_id:void 0}));let s=r;r.configurable?.checkpoint_map!==void 0&&r.configurable?.checkpoint_map?.[r.configurable?.checkpoint_ns]&&(s=pr(r,{checkpoint_id:r.configurable[Ar][r.configurable?.checkpoint_ns]}));let c=r.configurable?.checkpoint_ns?.split("|")??[],u=await t.checkpointer?.getTuple(s)??{config:r,checkpoint:ec(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};s={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let l=u.parentConfig,d=ln(u.checkpoint),f={...u.metadata},p=u.pendingWrites??[],m=ra(t.channelSpecs,d),_=(f.step??0)+1,v=_+(r.recursionLimit??SB)+1,x={...d.channel_versions},w=t.store?new $m(t.store):void 0;return w&&await w.start(),new iR({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:d,checkpointMetadata:f,checkpointConfig:s,prevCheckpointConfig:l,checkpointNamespace:c,channels:m,isNested:o,manager:t.manager,skipDoneTasks:n,step:_,stop:v,checkpointPreviousVersions:x,checkpointPendingWrites:p,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:i,store:w,cache:t.cache,interruptAfter:t.interruptAfter,interruptBefore:t.interruptBefore,durability:t.durability,debug:t.debug,triggerToNodes:t.triggerToNodes})}_checkpointerPutAfterPrevious(t){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>this.checkpointer?.put(t.config,t.checkpoint,t.metadata,t.newVersions)),this._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,r){let i=r;if(i.length===0)return;i.every(([c])=>c in el)&&(i=Array.from(new Map(i.map(c=>[c[0],c])).values()));let n=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){n=!0;break}let a=i;n&&(a=i.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&ct(u)?[c,JN(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of a)this.checkpointPendingWrites.push([t,c,u]);let o=pr(this.checkpointConfig,{[Tr]:this.config.configurable?.checkpoint_ns??"",[ml]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(o,a,t)),this.tasks&&this._outputWrites(t,i),!r.length||!this.cache||!this.tasks)return;let s=this.tasks[t];s==null||s.cache_key==null||r[0][0]==="__error__"||r[0][0]==="__interrupt__"||this.cache.set([{key:[s.cache_key.ns,s.cache_key.key],value:s.writes,ttl:s.cache_key.ttl}])}_outputWrites(t,r,i=!1){let n=this.tasks[t];if(n!==void 0){if(n.config!==void 0&&(n.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(n.path?.[0]==="__pregel_push"&&n.path?.[n.path.length-1]===!0)return;let a=r.filter(o=>o[0]===Be).flatMap(o=>o[1]);this._emit([["updates",{[Be]:a}],["values",{[Be]:a}]])}else r[0][0]!=="__error__"&&this._emit(bo(vi(DN(this.outputKeys,[[n,r]],i),"updates")));i||this._emit(bo(vi(WN([[n,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([o,s])=>`ns:${o.join(",")}|key:${s}`,i=[],n={};for(let o of Object.values(this.tasks))o.cache_key!=null&&!o.writes.length&&(i.push([o.cache_key.ns,o.cache_key.key]),n[r([o.cache_key.ns,o.cache_key.key])]=o);if(i.length===0)return[];let a=await this.cache.get(i);for(let{key:o,value:s}of a){let c=n[r(o)];c!=null&&(c.writes.push(...s),t.push({task:c,result:s}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:r=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![Gm,P0].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new Wn;if(Object.values(this.tasks).every(n=>n.writes.length>0)){let n=Object.values(this.tasks).flatMap(o=>o.writes);this.updatedChannels=Qt(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let a=await pn(vi(Lm(this.outputKeys,n,this.channels),"values"));if(this._emit(a),this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),cl(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new Wn;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[Ao]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=aa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels}),this.checkpointer&&this._emit(await pn(vi(qN(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,Object.values(this.tasks),this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints"))),Object.values(this.tasks).length===0)return this.status="done",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[n,a,o]of this.checkpointPendingWrites){if(a==="__error__"||a==="__interrupt__"||a==="__resume__")continue;let s=Object.values(this.tasks).find(c=>c.id===n);s&&s.writes.push([a,o])}for(let n of Object.values(this.tasks))n.writes.length>0&&this._outputWrites(n.id,n.writes,!0)}if(Object.values(this.tasks).every(n=>n.writes.length>0))return this.tick({inputKeys:r});if(cl(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new Wn;let i=await pn(vi(E0(Object.values(this.tasks)),"tasks"));return this._emit(i),!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(i=>!i.includes(":")))&&(this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=hn(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(i=>i.writes.length>0)&&(this.updatedChannels=Qt(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emit(bo(vi(Lm(this.outputKeys,Object.values(this.tasks).flatMap(i=>i.writes),this.channels),"values")))),qn(t)&&!t.interrupts.length&&this._emit([["updates",{[Be]:[]}],["values",{[Be]:[]}]])),r}async acceptPush(t,r,i){if(this.interruptAfter?.length>0&&cl(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let n=Bm([Cr,t.path??[],r,t.id,i],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,t.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!n)return;if(this.interruptBefore?.length>0&&cl(this.checkpoint,this.interruptBefore,[n])){this.toInterrupt.push(n);return}this._emit(bo(vi(E0([n]),"tasks"))),this.debug&&Zm(this.step,[n]),this.tasks[n.id]=n,this.skipDoneTasks&&this._matchWrites({[n.id]:n});let a=await this._matchCachedWrites();for(let{task:o}of a)this._outputWrites(o.id,o.writes,!0);return n}_suppressInterrupt(t){return qn(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,i=r?.[rr];if(i&&i.nullResume!==void 0&&this.putWrites(hr,[[mr,i.nullResume]]),ft(this.input)){let o=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(jm)&&(this.config.configurable??={},this.config.configurable[Co]=this.input.resume),o&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let s={};for(let[c,u,l]of zN(this.input,this.checkpointPendingWrites))s[c]??=[],s[c].push([u,l]);if(Object.keys(s).length===0)throw new bl("Received empty Command input");for(let[c,u]of Object.entries(s))this.putWrites(c,u)}let n=(this.checkpointPendingWrites??[]).filter(o=>o[0]===hr).map(o=>o.slice(1));n.length>0&&Qt(this.checkpoint,this.channels,[{name:wn,writes:n,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let a=ft(this.input)&&n.length>0;if(this.isResuming||a){for(let s in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,s)&&this.checkpoint.channel_versions[s]!==void 0){let c=this.checkpoint.channel_versions[s];this.checkpoint.versions_seen[Be]={...this.checkpoint.versions_seen[Be],[s]:c}}let o=await pn(vi(Lm(this.outputKeys,!0,this.channels),"values"));this._emit(o)}if(this.isResuming)this.input=P0;else if(a)await this._putCheckpoint({source:"input"}),this.input=Gm;else{let o=await pn(Um(t,this.input));if(o.length>0){let s=aa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=Qt(this.checkpoint,this.channels,Object.values(s).concat([{name:wn,writes:o,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=Gm}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=Gm;else throw new bl(`Received no input writes for ${JSON.stringify(t,null,2)}`)}this.isNested||(this.config=pr(this.config,{[Ao]:this.isResuming}))}_emit(t){for(let[r,i]of t)if(this.stream.modes.has(r)&&this.stream.push([this.checkpointNamespace,r,i]),(r==="checkpoints"||r==="tasks")&&this.stream.modes.has("debug")){let n=r==="checkpoints"?this.step-1:this.step,a=new Date().toISOString(),o=r==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([this.checkpointNamespace,"debug",{step:n,type:o,timestamp:a,payload:i}])}}_putCheckpoint(t){let r=this.checkpointMetadata===t,i=this.checkpointer!=null&&(this.durability!=="exit"||r),n=a=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=pr(this.checkpointConfig,{[Tr]:this.config.configurable?.checkpoint_ns??""});let o={...this.checkpoint.channel_versions},s=sc(this.checkpointPreviousVersions,o);this.checkpointPreviousVersions=o,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:ln(a),metadata:{...this.checkpointMetadata},newVersions:s}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}};r||(this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}),this.checkpoint=dn(this.checkpoint,i?this.channels:void 0,this.step,r?{id:this.checkpoint.id}:void 0),i&&n(this.checkpoint),r||(this.step+=1)}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=pr(this.checkpointConfig,{[Tr]:this.config.configurable?.checkpoint_ns??"",[ml]:this.checkpoint.id}),r={};for(let[i,n,a]of this.checkpointPendingWrites)r[i]??=[],r[i].push([n,a]);for(let[i,n]of Object.entries(r))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,n,i))}_matchWrites(t){for(let[r,i,n]of this.checkpointPendingWrites){if(i==="__error__"||i==="__interrupt__"||i==="__resume__")continue;let a=Object.values(t).find(o=>o.id===r);a&&a.writes.push([i,n])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function IB(e){return Je(e?.message)}var aR=class extends Yr{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,i=!1){if(i&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let n=t.id;r!=null&&(kc(t)?n??=`run-${r}-tool-${t.tool_call_id}`:((n==null||n===`run-${r}`)&&(n=this.stableMessageIdMap[r]??n??`run-${r}`),this.stableMessageIdMap[r]??=n)),n!==t.id&&(t.id=n,t.lc_kwargs.id=n),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,i,n,a,o,s){o&&(!a||!a.includes("langsmith:nostream")&&!a.includes("nostream"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:a,name:s,...o}])}handleLLMNewToken(e,t,r,i,n,a){let o=a?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(IB(o)?this._emit(this.metadatas[r],o.message,r):this._emit(this.metadatas[r],new mt({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];Je(r?.message)&&this._emit(this.metadatas[t],r?.message,t,!0),delete this.emittedChatModelRunIds[t]}delete this.metadatas[t],delete this.stableMessageIdMap[t]}}handleLLMError(e,t){delete this.metadatas[t]}handleChainStart(e,t,r,i,n,a,o,s){if(a!==void 0&&s===a.langgraph_node&&(n===void 0||!n.includes("langsmith:hidden"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:n,name:s,...a}],typeof t=="object")){for(let c of Object.values(t))if((Je(c)||Qn(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(Je(u)||Qn(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let r=this.metadatas[t];if(delete this.metadatas[t],r!==void 0){if(Je(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let i of e)Je(i)&&this._emit(r,i,t,!0);else if(e!=null&&typeof e=="object"){for(let i of Object.values(e))if(Je(i))this._emit(r,i,t,!0);else if(Array.isArray(i))for(let n of i)Je(n)&&this._emit(r,n,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};var EB=[400,401,402,403,404,405,406,407,409],TB=e=>{if(e.message.startsWith("Cancel")||e.message.startsWith("AbortError")||e.name==="AbortError"||e.name==="GraphValueError"||e?.code==="ECONNABORTED")return!1;let t=e?.response?.status??e?.status;return!(t&&EB.includes(+t)||e?.error?.code==="insufficient_quota")};async function N0(e,t,r,i){let n=e.retry_policy??t,a=n!==void 0?n.initialInterval??500:0,o=0,s,c,u=e.config??{};r&&(u=pr(u,r)),u={...u,signal:i};let l=Date.now();for(u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeFirstAttemptTime:l});!i?.aborted;){e.writes.splice(0,e.writes.length),s=void 0;try{c=await e.proc.invoke(e.input,u);break}catch(d){if(s=d,s.pregelTaskId=e.id,Qm(s)){let m=u?.configurable?.checkpoint_ns,_=s.command;if(_.graph===m){for(let v of e.writers)await v.invoke(_,u);s=void 0;break}else if(_.graph===tr.PARENT){let v=$N(m);s.command=new tr({...s.command,graph:v})}}if(ya(s)||n===void 0||(o+=1,o>=(n.maxAttempts??3))||!(n.retryOn??TB)(s))break;a=Math.min(n.maxInterval??128e3,a*(n.backoffFactor??2));let f=n.jitter?Math.floor(a+Math.random()*1e3):a;await new Promise(m=>setTimeout(m,f));let p=s.name??s.constructor.unminifiable_name??s.constructor.name;(n?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${a.toFixed(2)}ms (attempt ${o}) after ${p}: ${s}`),u=pr(u,{[Ao]:!0}),u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeAttempt:o+1,nodeFirstAttemptTime:l})}}return{task:e,result:c,error:s,signalAborted:i?.aborted}}var R0=Symbol.for("promiseAdded");function AB(){let e={next:()=>{},wait:Promise.resolve(R0)};function t(r){e.next=()=>{e.wait=new Promise(t),r(R0)}}return e.wait=new Promise(t),e}var oR=class{nodeFinished;loop;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:i,maxConcurrency:n}=e,a=new Set,o,s=new AbortController,c=s.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks).filter(m=>m.writes.length===0),{signals:d,disposeCombinedSignal:f}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),p=this._executeTasksWithRetry(l,{signals:d,retryPolicy:r,maxConcurrency:n});for await(let{task:m,error:_,signalAborted:v}of p)this._commit(m,_),qn(_)||ya(_)&&!qn(o)?o=_:_&&(a.size===0||!v)&&(s.abort(),a.add(_));if(f?.(),i?.(this.loop.step,Object.values(this.loop.tasks).map(m=>m.writes).flat()),a.size===1)throw Array.from(a)[0];if(a.size>1)throw new AggregateError(Array.from(a),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(qn(o)||ya(o)&&this.loop.isNested)throw o}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let i=this.loop.config.configurable?.__pregel_abort_signals??{},n=i.externalAbortSignal??r,a=t??i.timeoutAbortSignal,{signal:o,dispose:s}=cc(n,a,e),c={externalAbortSignal:n,timeoutAbortSignal:a,composedAbortSignal:o};return this.loop.config=pr(this.loop.config,{[q0]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:i,signals:n}=t??{},a=AB(),o={},s={executingTasksMap:o,barrier:a,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(n?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=cc(n?.externalAbortSignal,n?.timeoutAbortSignal),d=l.signal?new Promise((f,p)=>{u=()=>p(new Error("Abort")),l.signal?.addEventListener("abort",u,{once:!0})}):void 0;for(;(c===0||Object.keys(o).length>0)&&e.length;){for(;Object.values(o).length<(i??e.length)&&c<e.length;c+=1){let p=e[c];o[p.id]=N0(p,r,{[To]:sR?.bind(s,this,p)},n?.composedAbortSignal).catch(m=>({task:p,error:m,signalAborted:n?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(o),...d?[d]:[],a.wait]);f!==R0&&(yield f,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete o[f.task.id])}}_commit(e,t){if(t!==void 0)if(qn(t)){if(t.interrupts.length){let r=t.interrupts.map(n=>[Be,n]),i=e.writes.filter(n=>n[0]===mr);i.length&&r.push(...i),this.loop.putWrites(e.id,r)}}else ya(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):this.loop.putWrites(e.id,[[Eo,{message:t.message,name:t.name}]]);else this.nodeFinished&&(e.config?.tags==null||!e.config.tags.includes("langsmith:hidden"))&&this.nodeFinished(String(e.name)),e.writes.length===0&&e.writes.push([hc,null]),this.loop.putWrites(e.id,e.writes)}};async function sR(e,t,r,i,n,a={}){let o=t.config?.configurable?.[rr];if(!o)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=o.callCounter;o.callCounter+=1;let c=new FN({func:r,name:i,input:n,cache:a.cache,retry:a.retry,callbacks:a.callbacks}),u=await this.scheduleTask(t,s,c);if(!u)return;let l=this.executingTasksMap[u.id];if(l!==void 0)return l;if(u.writes.length>0){let d=u.writes.filter(([p])=>p===ki),f=u.writes.filter(([p])=>p===Eo);if(d.length>0){if(d.length===1)return Promise.resolve(d[0][1]);throw new Error(`BUG: multiple returns found for task ${u.name}__${u.id}`)}if(f.length>0){if(f.length===1){let p=f[0][1],m=p instanceof Error?p:new Error(String(p));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${u.name}__${u.id}`)}return}else{let d=N0(u,a.retry,{[To]:sR.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:f,error:p})=>p?Promise.reject(p):f)}}var bi=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function cR({nodes:e,channels:t,inputChannels:r,outputChannels:i,streamChannels:n,interruptAfterNodes:a,interruptBeforeNodes:o}){if(!t)throw new bi("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new bi(`"Node name ${Be} is reserved"`);if(l.constructor===mn)l.triggers.forEach(d=>s.add(d));else throw new bi(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new bi(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new bi(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new bi(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(i)?i.forEach(u=>c.add(u)):c.add(i),n&&!Array.isArray(n)?c.add(n):Array.isArray(n)&&n.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new bi(`Output channel '${String(u)}' not in channels`);if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new bi(`Node ${String(u)} not in nodes`)}if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new bi(`Node ${String(u)} not in nodes`)}}function j0(e,t){if(Array.isArray(e)){for(let r of e)if(!(r in t))throw new Error(`Key ${String(r)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}var M0=class uR extends wt{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor(t){super(),this.unique=t?.unique??this.unique,this.accumulate=t?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint(t){let r=new uR({unique:this.unique,accumulate:this.accumulate});return typeof t<"u"&&(r.seen=new Set(t[0]),r.values=t[1]),r}update(t){let r=!1;this.accumulate||(r=this.values.length>0,this.values=[]);let i=t.flat();if(i.length>0)if(this.unique)for(let n of i)this.seen.has(n)||(r=!0,this.seen.add(n),this.values.push(n));else r=!0,this.values.push(...i);return r}get(){if(this.values.length===0)throw new Ae;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};var lR=class{static subscribeTo(e,t){let{key:r,tags:i}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&r!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let n;return typeof e=="string"?r?n={[r]:e}:n=[e]:n=Object.fromEntries(e.map(a=>[a,a])),new mn({channels:n,triggers:Array.isArray(e)?e:[e],tags:i})}static writeTo(e,t){let r=[];for(let i of e)r.push({channel:i,value:fr,skipNone:!1});for(let[i,n]of Object.entries(t??{}))re.isRunnable(n)||typeof n=="function"?r.push({channel:i,value:fr,skipNone:!0,mapper:Xe(n)}):r.push({channel:i,value:n,skipNone:!1});return new rt(r)}},CB=class extends re{lc_namespace=["langgraph","pregel"];invoke(e,t){throw new Error("Not implemented")}withConfig(e){return super.withConfig(e)}stream(e,t){return super.stream(e,t)}},Hm=class extends CB{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;triggerToNodes={};constructor(e){super(e);let{streamMode:t}=e;if(t!=null&&!Array.isArray(t)&&(t=[t]),this.nodes=e.nodes,this.channels=e.channels,"__pregel_tasks"in this.channels&&"lc_graph_name"in this.channels.__pregel_tasks&&this.channels.__pregel_tasks.lc_graph_name!=="Topic")throw new Error(`Channel '${xn}' is reserved and cannot be used in the graph.`);this.channels[xn]=new M0({accumulate:!1}),this.autoValidate=e.autoValidate??this.autoValidate,this.streamMode=t??this.streamMode,this.inputChannels=e.inputChannels,this.outputChannels=e.outputChannels,this.streamChannels=e.streamChannels??this.streamChannels,this.interruptAfter=e.interruptAfter,this.interruptBefore=e.interruptBefore,this.stepTimeout=e.stepTimeout??this.stepTimeout,this.debug=e.debug??this.debug,this.checkpointer=e.checkpointer,this.retryPolicy=e.retryPolicy,this.config=e.config,this.store=e.store,this.cache=e.cache,this.name=e.name,this.triggerToNodes=e.triggerToNodes??this.triggerToNodes,this.userInterrupt=e.userInterrupt,this.autoValidate&&this.validate()}withConfig(e){let t=vt(this.config,e);return new this.constructor({...this,config:t})}validate(){cR({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[e,t]of Object.entries(this.nodes))for(let r of t.triggers)this.triggerToNodes[r]??=[],this.triggerToNodes[r].push(e);return this}get streamChannelsList(){return Array.isArray(this.streamChannels)?this.streamChannels:this.streamChannels?[this.streamChannels]:Object.keys(this.channels)}get streamChannelsAsIs(){return this.streamChannels?this.streamChannels:Object.keys(this.channels)}async getGraphAsync(e){return this.getGraph(e)}*getSubgraphs(e,t){for(let[r,i]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let n=i.subgraphs?.length?i.subgraphs:[i.bound];for(let a of n){let o=Dm(a);if(o!==void 0){if(r===e){yield[r,o];return}if(e===void 0&&(yield[r,o]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,u]of o.getSubgraphs(s,t))yield[`${r}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:r,applyPendingWrites:i=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let n=ra(this.channels,t.checkpoint);if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([f,p])=>f===hr).map(([f,p,m])=>[String(p),m]);d.length>0&&Qt(t.checkpoint,n,[{name:wn,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let a=Object.values(aa(t.checkpoint,t.pendingWrites,this.nodes,n,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),o=await pn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of a){let f=o.find(([m])=>m===d.name);if(!f)continue;let p=`${String(d.name)}:${d.id}`;if(s&&(p=`${s}|${p}`),r===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}};c[d.id]=m}else{let m={configurable:{[Hr]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},_=f[1];c[d.id]=await _.getState(m,{subgraphs:!0})}}if(i&&t.pendingWrites?.length){let d=Object.fromEntries(a.map(p=>[p.id,p]));for(let[p,m,_]of t.pendingWrites)["__error__","__interrupt__",va].includes(m)||p in d&&d[p].writes.push([String(m),_]);let f=a.filter(p=>p.writes.length>0);f.length>0&&Qt(t.checkpoint,n,f,void 0,this.triggerToNodes)}let u=t?.metadata;u&&t?.config?.configurable?.thread_id&&(u={...u,thread_id:t.config.configurable.thread_id});let l=a.filter(d=>d.writes.length===0).map(d=>d.name);return{values:hn(n,this.streamChannelsAsIs),next:l,tasks:T0(a,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:ia(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new _a("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Am(i);for await(let[s,c]of this.getSubgraphsAsync(o,!0))if(s===o)return await c.getState(wo(e,{[Hr]:r}),{subgraphs:t?.subgraphs})}let n=vt(this.config,e),a=await r.getTuple(e);return await this._prepareStateSnapshot({config:n,saved:a,subgraphCheckpointer:t?.subgraphs?r:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new _a("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Am(i);for await(let[o,s]of this.getSubgraphsAsync(a,!0))if(o===a){yield*s.getStateHistory(wo(e,{[Hr]:r}),t);return}}let n=vt(this.config,e,{configurable:{checkpoint_ns:i}});for await(let a of r.list(n,t))yield this._prepareStateSnapshot({config:a.config,saved:a})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new _a("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(o=>o.updates.length===0))throw new Error("No updates provided");let i=e.configurable?.checkpoint_ns??"";if(i!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Am(i);for await(let[,s]of this.getSubgraphsAsync(o,!0))return await s.bulkUpdateState(wo(e,{[Hr]:r}),t);throw new Error(`Subgraph "${o}" not found`)}let n=async(o,s)=>{let c=this.config?vt(this.config,o):o,u=await r.getTuple(c),l=u!==void 0?ln(u.checkpoint):ec(),d={...u?.checkpoint.channel_versions},f=u?.metadata?.step??-1,p=wo(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(p=wo(c,u.config.configurable),m={...u.metadata,...m});let{values:_,asNode:v}=s[0];if(_==null&&v===void 0){if(s.length>1)throw new _e("Cannot create empty checkpoint with multiple updates");return ia(await r.put(p,dn(l,void 0,f),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let x=ra(this.channels,l);if(_===null&&v==="__end__"){if(s.length>1)throw new _e("Cannot apply multiple updates when clearing state");if(u){let A=aa(l,u.pendingWrites||[],this.nodes,x,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),y=(u.pendingWrites||[]).filter(W=>W[0]===hr).map(W=>W.slice(1));y.length>0&&Qt(l,x,[{name:wn,writes:y,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[W,O,B]of u.pendingWrites||[])["__error__","__interrupt__",va].includes(O)||W in A&&A[W].writes.push([O,B]);Qt(l,x,Object.values(A),r.getNextVersion.bind(r),this.triggerToNodes)}return ia(await r.put(p,dn(l,x,f),{...m,source:"update",step:f+1,parents:u?.metadata?.parents??{}},sc(d,l.channel_versions)),u?u.metadata:void 0)}if(v==="__copy__"){if(s.length>1)throw new _e("Cannot copy checkpoint with multiple updates");if(u==null)throw new _e("Cannot copy a non-existent checkpoint");let A=O=>!Array.isArray(O)||O.length===0?!1:O.every(B=>Array.isArray(B)&&B.length===2),y=dn(l,void 0,f),W=await r.put(u.parentConfig??wo(u.config,{checkpoint_id:void 0}),y,{source:"fork",step:f+1,parents:u.metadata?.parents??{}},{});if(A(_)){let O=aa(y,u.pendingWrites,this.nodes,x,W,!1,{step:f+2}),B=Object.values(O).reduce((Le,{name:Lt,id:_n})=>(Le[Lt]??=[],Le[Lt].push({id:_n}),Le),{}),de=_.reduce((Le,Lt)=>{let[_n,we]=Lt;Le[we]??=[];let la=Le[we].length,Jn=B[we]?.[la]?.id;return Le[we].push({values:_n,asNode:we,taskId:Jn}),Le},{});return n(ia(W,u.metadata),Object.values(de).flat())}return ia(W,u.metadata)}if(v==="__input__"){if(s.length>1)throw new _e("Cannot apply multiple updates when updating as input");let A=await pn(Um(this.inputChannels,_));if(A.length===0)throw new _e(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);Qt(l,x,[{name:wn,writes:A,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let y=u?.metadata?.step!=null?u.metadata.step+1:-1,W=await r.put(p,dn(l,x,y),{source:"input",step:y,parents:u?.metadata?.parents??{}},sc(d,l.channel_versions));return await r.putWrites(W,A,Xn(wn,l.id)),ia(W,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let A=aa(l,u.pendingWrites,this.nodes,x,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),y=(u.pendingWrites??[]).filter(O=>O[0]===hr).map(O=>O.slice(1));y.length>0&&Qt(u.checkpoint,x,[{name:wn,writes:y,triggers:[]}],void 0,this.triggerToNodes);for(let[O,B,de]of u.pendingWrites)["__error__","__interrupt__",va].includes(B)||A[O]===void 0||A[O].writes.push([B,de]);let W=Object.values(A).filter(O=>O.writes.length>0);W.length>0&&Qt(l,x,W,void 0,this.triggerToNodes)}let w=Object.values(l.versions_seen).map(A=>Object.values(A)).flat().find(A=>!!A),S=[];if(s.length===1){let{values:A,asNode:y,taskId:W}=s[0];if(y===void 0&&Object.keys(this.nodes).length===1)[y]=Object.keys(this.nodes);else if(y===void 0&&w===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(y=this.inputChannels);else if(y===void 0){let O=Object.entries(l.versions_seen).map(([B,de])=>Object.values(de).map(Le=>[Le,B])).flat().filter(([B,de])=>de!==Be).sort(([B],[de])=>km(B,de));O&&(O.length===1?y=O[0][1]:O[O.length-1][0]!==O[O.length-2][0]&&(y=O[O.length-1][1]))}if(y===void 0)throw new _e('Ambiguous update, specify "asNode"');S.push({values:A,asNode:y,taskId:W})}else for(let{asNode:A,values:y,taskId:W}of s){if(A==null)throw new _e('"asNode" is required when applying multiple updates');S.push({values:y,asNode:A,taskId:W})}let $=[];for(let{asNode:A,values:y,taskId:W}of S){if(this.nodes[A]===void 0)throw new _e(`Node "${A.toString()}" does not exist`);let O=this.nodes[A].getWriters();if(!O.length)throw new _e(`No writers found for node "${A.toString()}"`);$.push({name:A,input:y,proc:O.length>1?kr.from(O,{omitSequenceTags:!0}):O[0],writes:[],triggers:[Be],id:W??Xn("__interrupt__",l.id),writers:[]})}for(let A of $)await A.proc.invoke(A.input,Se({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[Er]:y=>A.writes.push(...y),[Gr]:(y,W=!1)=>sl(l,x,A,y,W)}}));for(let A of $){let y=A.writes.filter(W=>W[0]!==Cr);u!==void 0&&y.length>0&&await r.putWrites(p,y,A.id)}Qt(l,x,$,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let T=sc(d,l.channel_versions),F=await r.put(p,dn(l,x,f+1),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},T);for(let A of $){let y=A.writes.filter(W=>W[0]===Cr);y.length>0&&await r.putWrites(F,y,A.id)}return ia(F,u?u.metadata:void 0)},a=e;for(let{updates:o}of t)a=await n(a,o);return a}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:i,outputKeys:n,interruptAfter:a,interruptBefore:o,...s}=e,c=!0,u=t!==void 0?t:this.debug,l=n;l===void 0?l=this.streamChannelsAsIs:j0(l,this.channels);let d=i;d===void 0?d=this.inputChannels:j0(d,this.channels);let f=o??this.interruptBefore??[],p=a??this.interruptAfter??[],m;r!==void 0?(m=Array.isArray(r)?r:[r],c=typeof r=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let _;if(this.checkpointer===!1)_=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)_=e.configurable[Hr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");_=this.checkpointer}let v=e.store??this.store,x=e.cache??this.cache;if(e.durability!=null&&e.checkpointDuring!=null)throw new Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let w=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),S=e.durability??w??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,s,f,p,_,v,c,x,S]}async stream(e,t){let r=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,signal:cc(t?.signal,r.signal).signal},n=await super.stream(e,i);return new C0(t?.encoding==="text/event-stream"?rR(n):n,r)}streamEvents(e,t,r){let i=new AbortController,n={recursionLimit:this.config?.recursionLimit,...t,callbacks:LN(this.config?.callbacks,t?.callbacks),signal:cc(t?.signal,i.signal).signal};return new C0(super.streamEvents(e,n,r),i)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let r="version"in(t??{})?void 0:t?.encoding??void 0,i=t?.subgraphs,n=nc(this.config,t);if(n.recursionLimit===void 0||n.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&n.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let a=await this._validateInput(e),{runId:o,...s}=n,[c,u,,l,d,f,p,m,_,v,x,w]=this._defaults(s);d.metadata={ls_integration:"langgraph",...d.metadata},typeof d.context<"u"?d.context=await this._validateContext(d.context):d.configurable=await this._validateContext(d.configurable);let S=new Vm({modes:new Set(u)});if(this.checkpointer===!0){d.configurable??={};let O=d.configurable.checkpoint_ns??"";d.configurable[Tr]=O.split("|").map(B=>B.split(":")[0]).join("|")}if(u.includes("messages")){let O=new aR(de=>S.push(de)),{callbacks:B}=d;if(B===void 0)d.callbacks=[O];else if(Array.isArray(B))d.callbacks=B.concat(O);else{let de=B.copy();de.addHandler(O,!0),d.callbacks=de}}if(u.includes("tools")){let O=new tR(de=>S.push(de)),{callbacks:B}=d;if(B===void 0)d.callbacks=[O];else if(Array.isArray(B))d.callbacks=B.concat(O);else{let de=B.copy();de.addHandler(O,!0),d.callbacks=de}}d.writer??=O=>{if(!u.includes("custom"))return;let B=h0()?.configurable?.[Tr]?.split("|").slice(0,-1);S.push([B??[],"custom",O])},d.interrupt??=this.userInterrupt??v0,d.serverInfo==null&&(d.serverInfo=OB(d));let $=await(await yt(d))?.handleChainStart(this.toJSON(),UN(e,"input"),o,void 0,void 0,void 0,d?.runName??this.getName()),T=nl(this.channels),F,A,W=(async()=>{try{F=await nR.initialize({input:a,config:d,checkpointer:m,nodes:this.nodes,channelSpecs:T,outputKeys:l,streamKeys:this.streamChannelsAsIs,store:_,cache:x,stream:S,interruptAfter:p,interruptBefore:f,manager:$,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:w});let O=new oR({loop:F,nodeFinished:d.configurable?.[W0]});t?.subgraphs&&(F.config.configurable={...F.config.configurable,[mc]:F.stream}),await this._runLoop({loop:F,runner:O,debug:c,config:d}),w==="sync"&&await Promise.all(F?.checkpointerPromises??[])}catch(O){A=O}finally{try{F&&(await F.store?.stop(),await F.cache?.stop()),await Promise.all(F?.checkpointerPromises??[])}catch(O){A=A??O}A?S.error(A):S.close()}})();try{for await(let O of S){if(O===void 0)throw new Error("Data structure error.");let[B,de,Le]=O;if(u.includes(de)){if(r==="text/event-stream"){i?yield[B,de,Le]:yield[null,de,Le];continue}i&&!v?yield[B,de,Le]:v?i?yield[B,Le]:yield Le:yield[de,Le]}}}catch(O){throw await $?.handleChainError(A),O}finally{await W}await $?.handleChainEnd(F?.output??{},o,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",i={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},n=[],a=await this.stream(e,i),o=[],s;for await(let c of a)r==="values"?gc(c)?o.push(c[Be]):s=c:n.push(c);if(r==="values"){if(o.length>0){let c=o.flat(1);if(s==null)return{[Be]:c};if(typeof s=="object")return{...s,[Be]:c}}return s}return n}async _runLoop(e){let{loop:t,runner:r,debug:i,config:n}=e,a;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:o}of await t._matchCachedWrites())t._outputWrites(o.id,o.writes,!0);i&&XN(t.checkpointMetadata.step,t.channels,this.streamChannelsList),i&&Zm(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(o,s)=>{i&&YN(o,s,this.streamChannelsList)},maxConcurrency:n.maxConcurrency,signal:n.signal})}if(t.status==="out_of_steps")throw new Ym([`Recursion limit of ${n.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(o){if(a=o,!await t.finishAndHandleError(a))throw o}finally{a===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function OB(e){let t=e.metadata??{},r=e.configurable??{},i=t.assistant_id,n=t.graph_id,a=r.langgraph_auth_user,o;if(a!=null&&typeof a=="object"&&"identity"in a&&(o=a),i!=null||n!=null||o!=null)return{assistantId:i!=null?String(i):"",graphId:n!=null?String(n):"",user:o}}var gn=class dR extends wt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new dR(this.guard);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0){let r=this.value.length>0;return this.value=[],r}if(t.length!==1&&this.guard)throw new _e("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ae;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ae;return this.value[0]}isAvailable(){return this.value.length!==0}};var z0=class{path;ends;constructor(e){re.isRunnable(e.path)?this.path=e.path:this.path=Xe(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return rt.registerWriter(new Dt({name:"<branch_run>",trace:!1,func:async(r,i)=>{try{return await this._route(r,i,e,t)}catch(n){throw n.name===yl.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
421
|
+
NodeInterrupt should only be thrown inside a node, not in edge conditions.`),n}}}))}async _route(e,t,r,i){let n=await this.path.invoke(i?i(t):e,t);Array.isArray(n)||(n=[n]);let a;if(this.ends?a=n.map(o=>ct(o)?o:this.ends[o]):a=n,a.some(o=>!o))throw new Error("Branch condition returned unknown or null destination");if(a.filter(ct).some(o=>o.node==="__end__"))throw new _e("Cannot send a packet to the END node");return await r(a,t)??e}},D0=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(e){this.compiled&&console.warn(e)}get allEdges(){return this.edges}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){for(let s of["|",":"])if(i.includes(s))throw new Error(`"${s}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__")throw new Error(`Node \`${i}\` is reserved.`);let o=Xe(n);this.nodes[i]={runnable:o,metadata:a?.metadata,subgraphs:ol(o)?[o]:a?.subgraphs,ends:a?.ends}}return this}addEdge(e,t){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),e==="__end__")throw new Error("END cannot be a start node");if(t==="__start__")throw new Error("START cannot be an end node");if(Array.from(this.edges).some(([r])=>r===e)&&!("channels"in this))throw new Error(`Already found path for ${e}. For multiple edges, use StateGraph.`);return this.edges.add([e,t]),this}addConditionalEdges(e,t,r){let i=typeof e=="object"?e:{source:e,path:t,pathMap:r};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),re.isRunnable(i.path)||(i.path=Xe(i.path));let n=i.path.getName()==="RunnableLambda"?"condition":i.path.getName();if(this.branches[i.source]&&this.branches[i.source][n])throw new Error(`Condition \`${n}\` already present for node \`${e}\``);return this.branches[i.source]??={},this.branches[i.source][n]=new z0(i),this}setEntryPoint(e){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Fe,e)}setFinishPoint(e){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(e,We)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let n=new U0({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Fe]:new gn,[We]:new gn},inputChannels:Fe,outputChannels:We,streamChannels:[],streamMode:"values",name:i});for(let[a,o]of Object.entries(this.nodes))n.attachNode(a,o);for(let[a,o]of this.edges)n.attachEdge(a,o);for(let[a,o]of Object.entries(this.branches))for(let[s,c]of Object.entries(o))n.attachBranch(a,s,c);return n.validate()}validate(e){let t=new Set([...this.allEdges].map(([i,n])=>i));for(let[i]of Object.entries(this.branches))t.add(i);for(let i of t)if(i!=="__start__"&&!(i in this.nodes))throw new Error(`Found edge starting at unknown node \`${i}\``);let r=new Set([...this.allEdges].map(([i,n])=>n));for(let[i,n]of Object.entries(this.branches))for(let a of Object.values(n))if(a.ends!=null)for(let o of Object.values(a.ends))r.add(o);else{r.add(We);for(let o of Object.keys(this.nodes))o!==i&&r.add(o)}for(let i of Object.values(this.nodes))for(let n of i.ends??[])r.add(n);for(let i of Object.keys(this.nodes))if(!r.has(i))throw new eh([`Node \`${i}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
|
|
422
|
+
`),{lc_error_code:"UNREACHABLE_NODE"});for(let i of r)if(i!=="__end__"&&!(i in this.nodes))throw new Error(`Found edge ending at unknown node \`${i}\``);if(e){for(let i of e)if(!(i in this.nodes))throw new Error(`Interrupt node \`${i}\` is not present`)}this.compiled=!0}},U0=class extends Hm{builder;constructor({builder:e,...t}){super(t),this.builder=e}attachNode(e,t){this.channels[e]=new gn,this.nodes[e]=new mn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new rt([{channel:e,value:fr}],[st])),this.streamChannels.push(e)}attachEdge(e,t){if(t==="__end__"){if(e==="__start__")throw new Error("Cannot have an edge from START to END");this.nodes[e].writers.push(new rt([{channel:We,value:fr}],[st]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Fe]=lR.subscribeTo(Fe,{tags:[st]})),this.nodes[e].pipe(r.run(n=>new rt(n.map(a=>ct(a)?a:{channel:a==="__end__"?We:`branch:${e}:${t}:${a}`,value:fr}),[st])));let i=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let n of i)if(n!=="__end__"){let a=`branch:${e}:${t}:${n}`;this.channels[a]=new gn,this.nodes[n].triggers.push(a),this.nodes[n].channels.push(a)}}async getGraphAsync(e){let t=e?.xray,r=new fo,i={[Fe]:r.addNode({schema:Br.any()},Fe)},n={},a={};t&&(a=Object.fromEntries((await pn(this.getSubgraphsAsync())).filter(c=>fR(c[1]))));function o(c,u,l,d=!1){if(u==="__end__"&&n.__end__===void 0&&(n[We]=r.addNode({schema:Br.any()},We)),i[c]!==void 0){if(n[u]===void 0)throw new Error(`End node ${u} not found!`);return r.addEdge(i[c],n[u],l!==u?l:void 0,d)}}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Ut(c),d=u.runnable,f=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?f.__interrupt="before,after":this.interruptBefore?.includes(c)?f.__interrupt="before":this.interruptAfter?.includes(c)&&(f.__interrupt="after"),t){let p=typeof t=="number"?t-1:t,m=a[c]!==void 0?await a[c].getGraphAsync({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let x=function(S){return S?S.lc_runnable:!1},w=function(S,$){if(S!==void 0&&!Oo(S))return S;if(x($))try{let T=$.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,v]=r.extend(m,l);if(_===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);v!==void 0&&(i[l]={name:w(v.id,v.data),...v}),n[l]={name:w(_.id,_.data),..._}}else{let _=r.addNode(d,l,f);i[l]=_,n[l]=_}}else{let p=r.addNode(d,l,f);i[l]=p,n[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Ut(c),Ut(u));for(let[c,u]of Object.entries(this.builder.branches)){let l={...Object.fromEntries(Object.keys(this.builder.nodes).filter(d=>d!==c).map(d=>[Ut(d),Ut(d)])),[We]:We};for(let d of Object.values(u)){let f;d.ends!==void 0?f=d.ends:f=l;for(let[p,m]of Object.entries(f))o(Ut(c),Ut(m),p,!0)}}for(let[c,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let l of u.ends)o(Ut(c),Ut(l),void 0,!0);return r}getGraph(e){let t=e?.xray,r=new fo,i={[Fe]:r.addNode({schema:Br.any()},Fe)},n={},a={};t&&(a=Object.fromEntries(bo(this.getSubgraphs()).filter(c=>fR(c[1]))));function o(c,u,l,d=!1){return u==="__end__"&&n.__end__===void 0&&(n[We]=r.addNode({schema:Br.any()},We)),r.addEdge(i[c],n[u],l!==u?l:void 0,d)}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Ut(c),d=u.runnable,f=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?f.__interrupt="before,after":this.interruptBefore?.includes(c)?f.__interrupt="before":this.interruptAfter?.includes(c)&&(f.__interrupt="after"),t){let p=typeof t=="number"?t-1:t,m=a[c]!==void 0?a[c].getGraph({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let x=function(S){return S?S.lc_runnable:!1},w=function(S,$){if(S!==void 0&&!Oo(S))return S;if(x($))try{let T=$.getName();return T=T.startsWith("Runnable")?T.slice(8):T,T}catch{return $.getName()}else return $.name??"UnknownSchema"},[_,v]=r.extend(m,l);if(_===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);v!==void 0&&(i[l]={name:w(v.id,v.data),...v}),n[l]={name:w(_.id,_.data),..._}}else{let _=r.addNode(d,l,f);i[l]=_,n[l]=_}}else{let p=r.addNode(d,l,f);i[l]=p,n[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)o(Ut(c),Ut(u));for(let[c,u]of Object.entries(this.builder.branches)){let l={...Object.fromEntries(Object.keys(this.builder.nodes).filter(d=>d!==c).map(d=>[Ut(d),Ut(d)])),[We]:We};for(let d of Object.values(u)){let f;d.ends!==void 0?f=d.ends:f=l;for(let[p,m]of Object.entries(f))o(Ut(c),Ut(m),p,!0)}}return r}};function fR(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Ut(e){return e==="subgraph"?`"${e}"`:e}function wi(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function L0(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function PB(e){return wi(e)&&L0(e)}function oa(e){if(L0(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function sa(e){if(e!=null&&wi(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let r=t;if(!r.issues){let i=r.value;return()=>i}}}catch{}}var F0=Symbol.for("langgraph.channel.missing"),Jm=class pR extends wt{lc_graph_name="UntrackedValue";guard;_value=F0;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new pR({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new _e("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=t[t.length-1],!0}get(){if(this._value===F0)throw new Ae;return this._value}checkpoint(){}isAvailable(){return this._value!==F0}};var ca=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),B0=class mR extends wt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new mR(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let i of t)if(this.names.has(i))this.seen.has(i)||(this.seen.add(i),r=!0);else throw new _e(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!ca(this.names,this.seen))throw new Ae}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&ca(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&ca(this.names,this.seen)}},Z0=class hR extends wt{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let r=new hR(this.names);if(typeof t<"u"){let[i,n]=t;r.seen=new Set(i),r.finished=n}return r}update(t){let r=!1;for(let i of t)if(this.names.has(i)&&!this.seen.has(i))this.seen.add(i),r=!0;else if(!this.names.has(i))throw new _e(`Value ${JSON.stringify(i)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!ca(this.names,this.seen))throw new Ae}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&ca(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&ca(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&ca(this.names,this.seen)}};var V0=Symbol.for("langgraph.state.reduced_value"),xi=class{[V0]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(e,t){this.reducer=t.reducer,this.jsonSchemaExtra=t.jsonSchemaExtra,this.valueSchema=e,this.inputSchema="inputSchema"in t?t.inputSchema:e,this.jsonSchemaExtra=t.jsonSchemaExtra}static isInstance(e){return typeof e=="object"&&e!==null&&V0 in e&&e[V0]===!0}};var gR=Symbol.for("langgraph.state.untracked_value"),So=class{[gR]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&gR in e}};var G0=Symbol.for("langgraph.state.state_schema"),Hn=class{[G0]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(xi.isInstance(r)){let i=sa(r.valueSchema);e[t]=new gi(r.reducer,i)}else if(So.isInstance(r)){let i=r.schema?sa(r.schema):void 0;e[t]=new Jm({guard:r.guard,initialValueFactory:i})}else if(wi(r))e[t]=new fn(sa(r));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[r,i]of Object.entries(this.fields)){let n;if(xi.isInstance(i)?(n=oa(i.valueSchema),i.jsonSchemaExtra&&(n={...n??{},...i.jsonSchemaExtra})):So.isInstance(i)?n=i.schema?oa(i.schema):void 0:wi(i)&&(n=oa(i)),n){e[r]=n;let a=!1;xi.isInstance(i)?a=sa(i.valueSchema)!==void 0:So.isInstance(i)?a=i.schema?sa(i.schema)!==void 0:!1:a=sa(i)!==void 0,a||t.push(r)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,r]of Object.entries(this.fields)){let i;xi.isInstance(r)?(i=oa(r.inputSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):So.isInstance(r)?i=r.schema?oa(r.schema):void 0:wi(r)&&(i=oa(r)),i&&(e[t]=i)}return{type:"object",properties:e}}getChannelKeys(){return Object.entries(this.fields).map(([e])=>e)}getAllKeys(){return Object.keys(this.fields)}async validateInput(e){if(e==null||typeof e!="object")return e;let t={};for(let[r,i]of Object.entries(e)){let n=this.fields[r];if(n===void 0){t[r]=i;continue}let a;if(xi.isInstance(n)?a=n.inputSchema:So.isInstance(n)?a=n.schema:wi(n)&&(a=n),a){let o=await a["~standard"].validate(i);if(o.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(o.issues)}`);t[r]=o.value}else t[r]=i}return t}static isInstance(e){return typeof e=="object"&&e!==null&&G0 in e&&e[G0]===!0}};var NB="__remove_all__";function ua(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t],n=r.map(St),a=i.map(St);for(let l of n)(l.id===null||l.id===void 0)&&(l.id=$l(),l.lc_kwargs.id=l.id);let o;for(let l=0;l<a.length;l+=1){let d=a[l];(d.id===null||d.id===void 0)&&(d.id=$l(),d.lc_kwargs.id=d.id),Xr.isInstance(d)&&d.id==="__remove_all__"&&(o=l)}if(o!=null)return a.slice(o+1);let s=[...n],c=new Map(s.map((l,d)=>[l.id,d])),u=new Set;for(let l of a){let d=c.get(l.id);if(d!==void 0)Xr.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(Xr.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,s.length),s.push(l)}}return s.filter(l=>!u.has(l.id))}var RB=new xi(Br.custom().default(()=>[]),{inputSchema:Br.custom(),reducer:ua,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var jB=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let r=this.get(e);this._map.set(e,t(r))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},r=Ka(e);for(let[i,n]of Object.entries(r)){let a=this.get(n);a?.reducer?t[i]=new gi(a.reducer.fn,a.default):t[i]=new fn(a?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,a])=>a===!0).sort(([a],[o])=>a.localeCompare(o)).map(([a,o])=>`${a}:${o}`).join("|"),i=this._extensionCache.get(r)??new Map;if(i.has(e))return i.get(e);let n=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let a=Object.entries(Ka(e)).map(([o,s])=>{let c=this.get(s),u=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=si(u)??si(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[o,u]});n=Jf(e,Object.fromEntries(a)),tt(n)&&(n._def.unknownKeys="strip")}return t.asPartial&&(n=Is(n)),i.set(e,n),this._extensionCache.set(r,i),n}},dl=new jB;function _R(e,t){if(t.reducer&&!t.default){let r=Kf(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return dl.extend(r,()=>t),r}else return dl.extend(e,()=>t),e}function ko(e){return e==null?!1:!!(Hn.isInstance(e)||qt(e)||typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot"||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0&&Object.values(e).every(t=>typeof t=="function"||p0(t)))}function yR(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&ko(t.state),i="stateSchema"in t&&ko(t.stateSchema),n="input"in t&&ko(t.input);return!(!r&&!i&&!n||"input"in t&&t.input!=null&&!ko(t.input)||"output"in t&&t.output!=null&&!ko(t.output))}var Si="__root__",Km=Symbol.for("langgraph.state.partial"),H0=class extends D0{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=dl;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),i=r.state??r.stateSchema??r.input;if(!i)throw new _c;let n=this._getChannelsFromSchema(i);this._schemaDefinition=n,Hn.isInstance(i)?this._schemaRuntimeDefinition=i:qt(i)&&(this._schemaRuntimeDefinition=i),r.input?Hn.isInstance(r.input)?this._inputRuntimeDefinition=r.input:qt(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=Km:this._inputRuntimeDefinition=Km,r.output?Hn.isInstance(r.output)?this._outputRuntimeDefinition=r.output:qt(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let a=r.input?this._getChannelsFromSchema(r.input):n,o=r.output?this._getChannelsFromSchema(r.output):n;this._inputDefinition=a,this._outputDefinition=o,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&qt(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}_normalizeToStateGraphInit(e,t){if(yR(e)){if(qt(t)||Em.isInstance(t))return{...e,context:t};let r=t;return{...e,input:e.input??r?.input,output:e.output??r?.output,context:e.context??r?.context,interrupt:e.interrupt??r?.interrupt,writer:e.writer??r?.writer,nodes:e.nodes??r?.nodes}}if(ko(e)){if(qt(t)||Em.isInstance(t))return{state:e,context:t};let r=t;return{state:e,input:r?.input,output:r?.output,context:r?.context,interrupt:r?.interrupt,writer:r?.writer,nodes:r?.nodes}}if(zB(e))return{state:MB(e.channels)};throw new _c}_getChannelsFromSchema(e){if(Hn.isInstance(e))return e.getChannels();if(qt(e))return this._metaRegistry.getChannelsForSchema(e);if(typeof e=="object"&&"lc_graph_name"in e&&e.lc_graph_name==="AnnotationRoot")return e.spec;if(typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e;throw new _c("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([e,t])=>e.map(r=>[r,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,r]of Object.entries(e)){let i;if(typeof r=="function"?i=r():i=r,this.channels[t]!==void 0){if(!this.channels[t].equals(i)&&i.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=i}}}addNode(...e){function t(i){return i.length>=1&&typeof i[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([i,n])=>[i,n]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[i,n,a]of r){if(i in this.channels)throw new Error(`${i} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let l of["|",":"])if(i.includes(l))throw new Error(`"${l}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),i in this.nodes)throw new Error(`Node \`${i}\` already present.`);if(i==="__end__"||i==="__start__")throw new Error(`Node \`${i}\` is reserved.`);let o=this._schemaDefinition;a?.input!==void 0&&(o=this._getChannelsFromSchema(a.input)),this._addSchema(o);let s;re.isRunnable(n)?s=n:typeof n=="function"?s=new Dt({func:n,name:i,trace:!1}):s=Xe(n);let c=a?.cachePolicy;typeof c=="boolean"&&(c=c?{}:void 0);let u={runnable:s,retryPolicy:a?.retryPolicy,cachePolicy:c,metadata:a?.metadata,input:o??this._schemaDefinition,subgraphs:ol(s)?[s]:a?.subgraphs,ends:a?.ends,defer:a?.defer};this.nodes[i]=u}return this}addEdge(e,t){if(typeof e=="string")return super.addEdge(e,t);this.compiled&&console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let r of e){if(r==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(i=>i===r))throw new Error(`Need to add a node named "${r}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(r=>r===t))throw new Error(`Need to add a node named "${t}" first`);return this.waitingEdges.add([e,t]),this}addSequence(e){let t=Array.isArray(e)?e:Object.entries(e);if(t.length===0)throw new Error("Sequence requires at least one node.");let r;for(let[i,n,a]of t){if(i in this.nodes)throw new Error(`Node names must be unique: node with the name "${i}" already exists.`);let o=i;this.addNode(o,n,a),r!=null&&this.addEdge(r,o),r=o}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:i,interruptAfter:n,name:a,description:o}={}){this.validate([...Array.isArray(i)?i:[],...Array.isArray(n)?n:[]]);let s=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),c=s.length===1&&s[0]===Si?Si:s,u=Object.keys(this.channels),l=u.length===1&&u[0]===Si?Si:u,d=this._interrupt,f=new bR({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:i,autoValidate:!1,nodes:{},channels:{...this.channels,[Fe]:new gn},inputChannels:Fe,outputChannels:c,streamChannels:l,streamMode:"updates",store:t,cache:r,name:a,description:o,userInterrupt:d});f.attachNode(Fe);for(let[p,m]of Object.entries(this.nodes))f.attachNode(p,m);f.attachBranch(Fe,qm,vR(),{withReader:!1});for(let[p]of Object.entries(this.nodes))f.attachBranch(p,qm,vR(),{withReader:!1});for(let[p,m]of this.edges)f.attachEdge(p,m);for(let[p,m]of this.waitingEdges)f.attachEdge(p,m);for(let[p,m]of Object.entries(this.branches))for(let[_,v]of Object.entries(m))f.attachBranch(p,_,v);return f.validate()}};function MB(e){let t={};for(let[r,i]of Object.entries(e))r===Si?t[r]=Tm(i):t[r]=Tm(i);return t}var bR=class extends U0{description;_metaRegistry=dl;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let r;e==="__start__"?r=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([s])=>s):r=Object.keys(this.builder.channels);function i(s){if(ft(s))return s.graph===tr.PARENT?null:s._updateAsTuples();if(Array.isArray(s)&&s.length>0&&s.some(c=>ft(c))){let c=[];for(let u of s)if(ft(u)){if(u.graph===tr.PARENT)continue;c.push(...u._updateAsTuples())}else c.push([Si,u]);return c}else if(s!=null)return[[Si,s]];return null}let n=e;function a(s){if(s){if(ft(s))return s.graph===tr.PARENT?null:s._updateAsTuples().filter(([c])=>r.includes(c));if(Array.isArray(s)&&s.length>0&&s.some(ft)){let c=[];for(let u of s)if(ft(u)){if(u.graph===tr.PARENT)continue;c.push(...u._updateAsTuples().filter(([l])=>r.includes(l)))}else{let l=a(u);l&&c.push(...l??[])}return c}else{if(typeof s=="object"&&!Array.isArray(s))return Object.entries(s).filter(([c])=>r.includes(c));{let c=Array.isArray(s)?"array":typeof s;throw new _e(`Expected node "${n.toString()}" to return an object or an array containing at least one Command object, received ${c}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}}else return null}let o=[{value:fr,mapper:new Dt({func:r.length&&r[0]===Si?i:a,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new mn({tags:[st],triggers:[Fe],channels:[Fe],writers:[new rt(o,[st])]});else{let s=t?.input??this.builder._schemaDefinition,c=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(s)).map(d=>[d,d])),u=Object.keys(c).length===1&&Si in c,l=`branch:to:${e}`;this.channels[l]=t?.defer?new m0:new gn(!1),this.nodes[e]=new mn({triggers:[l],channels:u?Object.keys(c):c,writers:[new rt(o,[st])],mapper:u?void 0:d=>Object.fromEntries(Object.entries(d).filter(([f])=>f in c)),bound:t?.runnable,metadata:t?.metadata,retryPolicy:t?.retryPolicy,cachePolicy:t?.cachePolicy,subgraphs:t?.subgraphs,ends:t?.ends})}}attachEdge(e,t){if(t!=="__end__"){if(typeof e=="string")this.nodes[e].writers.push(new rt([{channel:`branch:to:${t}`,value:null}],[st]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new Z0(new Set(e)):new B0(new Set(e)),this.nodes[t].triggers.push(r);for(let i of e)this.nodes[i].writers.push(new rt([{channel:r,value:i}],[st]))}}}attachBranch(e,t,r,i={withReader:!0}){let n=async(a,o)=>{let s=a.filter(u=>u!==We);if(!s.length)return;let c=s.map(u=>ct(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await rt.doWrite({...o,tags:(o.tags??[]).concat([st])},c)};this.nodes[e].writers.push(r.run(n,i.withReader?a=>jN.doRead(a,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,r=this.builder._schemaRuntimeDefinition;if(Hn.isInstance(t)){if(ft(e)){let n=e;return e.update&&(n.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await t.validateInput(e)}if(t===Km&&Hn.isInstance(r)){if(ft(e)){let n=e;return e.update&&(n.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),n}return await r.validateInput(e)}let i=(()=>{let n=a=>{if(a!=null)return this._metaRegistry.getExtendedChannelSchemas(a,{withReducerSchema:!0})};if(qt(t))return n(t);if(t===Km)return qt(r)?Is(n(r)):void 0})();if(ft(e)){let n=e;return e.update&&i!=null&&(n.update=ks(i,e.update)),n}return i!=null?ks(i,e):e}isInterrupted(e){return gc(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return qt(t)&&ks(t,e),e}};function zB(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function DB(e){if(ct(e))return[e];let t=[];ft(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(ft));let r=[];for(let i of t){if(i.graph===tr.PARENT)throw new vl(i);ct(i.goto)||typeof i.goto=="string"?r.push(i.goto):Array.isArray(i.goto)&&r.push(...i.goto)}return r}function vR(){return new z0({path:new Dt({func:DB,tags:[st],trace:!1,recurse:!1,name:"<control_branch>"})})}var UB=class extends H0{constructor(){super({channels:{__root__:{reducer:ua,default:()=>[]}}})}};function LB(e,t){let{stateKey:r,...i}=t??{},n=nc(i),a=r??"messages";r===null&&(a=void 0);let o=St(e);if(!o.id)throw new Error("Message ID is required.");let s=(Array.isArray(n.callbacks)?n.callbacks:typeof n.callbacks<"u"?n.callbacks.handlers:[]).find(c=>"name"in c&&c.name==="StreamMessagesHandler");if(s){let c=n.metadata??{},u=(c.langgraph_checkpoint_ns??"").split("|");s._emit([u,c],o,void 0,!1)}return a&&n.configurable?.__pregel_send?.([[a,o]]),o}function FB(e,t){let r=typeof e=="string"?{name:e,retry:void 0,cachePolicy:void 0}:e,{name:i,retry:n}=r;if(b0(t)||w0(t))throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");let a=r.cachePolicy??("cache"in r?r.cache:void 0),o;return typeof a=="boolean"?o=a?{}:void 0:o=a,(...s)=>GN({func:t,name:i,retry:n,cache:o},...s)}var wR=function(t,r){let{name:i,checkpointer:n,store:a,cache:o}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t;if(b0(r)||w0(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let s="updates",c=VN(i,r);function u(p){return typeof p=="object"&&p!==null&&"__lg_type"in p&&p.__lg_type==="__pregel_final"}let l=new Dt({name:"pluckReturnValue",func:p=>u(p)?p.value:p}),d=new Dt({name:"pluckSaveValue",func:p=>u(p)?p.save:p}),f=new mn({bound:c,triggers:[Fe],channels:[Fe],writers:[new rt([{channel:We,value:fr,mapper:l},{channel:ga,value:fr,mapper:d}],[st])]});return new Hm({name:i,checkpointer:n,nodes:{[i]:f},channels:{[Fe]:new gn,[We]:new fn,[ga]:new fn},inputChannels:Fe,outputChannels:We,streamChannels:We,streamMode:s,store:a,cache:o})};wR.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};function BB(){return $e.getRunnableConfig().configurable?.[ha]}var ZB=il.Root({messages:il({reducer:ua,default:()=>[]})}),xR={reducer:{fn:ua},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},VB=bt.object({messages:_R(bt.custom(),xR)});function GB(e){let t=$e.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let r=t.configurable;if(!r)throw new Error("No configurable found in config");return r.writer?.(e)}export{Fe as a,We as b,Be as c,Wm as d,Y0 as e,ma as f,ct as g,$R as h,gc as i,tr as j,ft as k,Jr as l,Xm as m,Ym as n,_a as o,Wn as p,yl as q,vl as r,Qm as s,ya as t,qn as u,bl as v,Ae as w,_e as x,IR as y,eh as z,ER as A,_c as B,TR as C,CS as D,Ft as E,oj as F,kn as G,LS as H,wc as I,FS as J,Me as K,Je as L,Zt as M,zo as N,kc as O,Do as P,Ee as Q,Lo as R,mt as S,qr as T,wa as U,Sa as V,Ye as W,ka as X,Xr as Y,Vt as Z,ei as _,Ok as $,Fo as aa,Oh as ba,$e as ca,yt as da,vt as ea,ye as fa,ir as ga,yr as ha,ut as ia,Ri as ja,zi as ka,Ma as la,Zi as ma,mf as na,Ha as oa,De as pa,tt as qa,sr as ra,Hf as sa,qT as ta,ks as ua,si as va,qt as wa,Ka as xa,Is as ya,Kf as za,YT as Aa,D as Ba,bt as Ca,op as Da,ht as Ea,re as Fa,Ur as Ga,kr as Ha,Rt as Ia,wC as Ja,mp as Ka,QC as La,o6 as Ma,wu as Na,xp as Oa,mw as Pa,_O as Qa,yO as Ra,d6 as Sa,f6 as Ta,gw as Ua,ta as Va,Ow as Wa,Zs as Xa,zu as Ya,Br as Za,iF as _a,cF as $a,gF as ab,ec as bb,ln as cb,Sm as db,yN as eb,rc as fb,$m as gb,wN as hb,wt as ib,gi as jb,il as kb,GF as lb,HF as mb,h0 as nb,JF as ob,v0 as pb,Dt as qb,D0 as rb,wi as sb,PB as tb,oa as ub,sa as vb,Jm as wb,xi as xb,So as yb,Hn as zb,NB as Ab,ua as Bb,RB as Cb,dl as Db,_R as Eb,H0 as Fb,bR as Gb,UB as Hb,LB as Ib,FB as Jb,wR as Kb,BB as Lb,ZB as Mb,xR as Nb,VB as Ob,GB as Pb};
|