@arcgis/ai-components 5.1.0-next.7 → 5.1.0-next.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/24MYCR6F.js +3 -0
- package/dist/cdn/276ERLGQ.js +2 -0
- package/dist/cdn/2MLMI2OK.js +2 -0
- package/dist/cdn/3D2FSGMT.js +75 -0
- package/dist/cdn/3M7XAZRH.js +2 -0
- package/dist/cdn/{ZYQ6U2YH.js → 5PT7ZFXF.js} +46 -6
- package/dist/cdn/7CRP5WU6.js +2 -0
- package/dist/cdn/{LTBEINKG.js → ABCHVJTB.js} +13 -1
- package/dist/cdn/B4DEC7PH.js +2 -0
- package/dist/cdn/B66A2V6H.js +2 -0
- package/dist/cdn/BUO7QQDY.js +2 -0
- package/dist/cdn/C5BYUKXO.js +72 -0
- package/dist/cdn/DR56NDCW.js +2 -0
- package/dist/cdn/{62K6RJZZ.js → ESTSYVJP.js} +15 -2
- package/dist/cdn/FEBQMS6F.js +2 -0
- package/dist/cdn/GY6V3KIF.js +2 -0
- package/dist/cdn/IHZ6MKIF.js +2 -0
- package/dist/cdn/IR3YHQ5A.js +225 -0
- package/dist/cdn/JG7SOQYZ.js +2 -0
- package/dist/cdn/{UY4FI7AP.js → KADK7ZYA.js} +1 -1
- package/dist/cdn/KVH3PDVW.js +2 -0
- package/dist/cdn/KWBMH7LU.js +61 -0
- package/dist/cdn/L7YTPHKQ.js +349 -0
- package/dist/cdn/MZBTKGRF.js +2 -0
- package/dist/cdn/MZJGADGH.js +122 -0
- package/dist/cdn/OLR6WPCR.js +2 -0
- package/dist/cdn/OQNCJHHX.js +2 -0
- package/dist/cdn/RFTAJAJW.js +2 -0
- package/dist/cdn/RMM7LKZF.js +3 -0
- package/dist/cdn/SGGBOB5K.js +4 -0
- package/dist/cdn/SN2JIWIP.js +2 -0
- package/dist/cdn/TD3EJQQF.js +2 -0
- package/dist/cdn/WH52UBDS.js +2 -0
- package/dist/cdn/WPWVMXUE.js +2 -0
- package/dist/cdn/Y4YK5Q2F.js +2 -0
- package/dist/cdn/{WBSNYWJJ.js → YGW7TUNX.js} +1 -1
- package/dist/cdn/ZDEYVBH7.js +44 -0
- 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.en.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-chat-entry/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.bs.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-HK.json +1 -0
- package/dist/cdn/assets/assistant-message-feedback/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.bs.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-HK.json +1 -0
- package/dist/cdn/assets/assistant-message-footer/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.bs.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-HK.json +1 -0
- package/dist/cdn/assets/assistant-message-read-aloud/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.bs.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-HK.json +1 -0
- package/dist/cdn/assets/assistant-suggested-prompts/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/converterUtils.js +117 -0
- package/dist/chunks/utils.js +16 -14
- package/dist/chunks/utils2.js +8 -3
- package/dist/components/arcgis-assistant/customElement.d.ts +342 -27
- package/dist/components/arcgis-assistant/customElement.js +216 -147
- package/dist/components/arcgis-assistant/index.js +9 -2
- package/dist/components/arcgis-assistant/types.d.ts +136 -0
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +22 -8
- package/dist/components/arcgis-assistant-agent/customElement.js +7 -7
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -9
- package/dist/components/arcgis-assistant-chat/customElement.js +13 -13
- package/dist/components/arcgis-assistant-chat/index.js +0 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +15 -12
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +59 -25
- package/dist/components/arcgis-assistant-chat-entry/index.js +1 -2
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.d.ts +73 -6
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.d.ts +73 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +26 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +8 -8
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +6 -6
- package/dist/components/arcgis-assistant-message/customElement.d.ts +18 -0
- package/dist/components/arcgis-assistant-message/customElement.js +29 -0
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +4 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +8 -0
- package/dist/components/arcgis-assistant-message-block/customElement.js +29 -0
- package/dist/components/arcgis-assistant-message-block/index.js +2 -0
- package/dist/components/arcgis-assistant-message-content/customElement.d.ts +12 -0
- package/dist/components/arcgis-assistant-message-content/customElement.js +62 -0
- package/dist/components/arcgis-assistant-message-content/index.js +4 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +23 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.js +36 -0
- package/dist/components/arcgis-assistant-message-feedback/index.js +3 -0
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +25 -0
- package/dist/components/arcgis-assistant-message-footer/customElement.js +62 -0
- package/dist/components/arcgis-assistant-message-footer/index.js +6 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +10 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +23 -0
- package/dist/components/arcgis-assistant-message-loading/index.js +4 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +11 -0
- package/dist/components/arcgis-assistant-message-log/customElement.js +29 -0
- package/dist/components/arcgis-assistant-message-log/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-log/index.js +3 -0
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +19 -0
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.js +104 -0
- package/dist/components/arcgis-assistant-message-read-aloud/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-read-aloud/index.js +3 -0
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +22 -0
- package/dist/components/arcgis-assistant-message-text/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/index.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.d.ts +53 -6
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +31 -0
- package/dist/components/arcgis-assistant-speech-input/customElement.js +488 -0
- package/dist/components/arcgis-assistant-speech-input/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-speech-input/index.js +2 -0
- package/dist/components/arcgis-assistant-speech-input/support/types.d.ts +20 -0
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +16 -0
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +27 -0
- package/dist/components/arcgis-assistant-suggested-prompts/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-suggested-prompts/index.js +3 -0
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +10 -0
- package/dist/components/arcgis-assistant-user-message/customElement.js +23 -0
- package/dist/components/arcgis-assistant-user-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-user-message/index.js +2 -0
- 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 +78 -22
- package/dist/loader.js +19 -11
- package/dist/types/lumina.d.ts +83 -26
- package/dist/types/preact.d.ts +96 -31
- package/dist/types/react.d.ts +109 -36
- package/dist/types/stencil.d.ts +83 -26
- package/dist/utils/index.d.ts +305 -0
- package/dist/utils/index.js +13 -0
- package/package.json +15 -8
- package/dist/cdn/26V7SXDR.js +0 -4
- package/dist/cdn/2PLHSU7P.js +0 -271
- package/dist/cdn/4Y73V2HU.js +0 -2
- package/dist/cdn/6T2EIYO4.js +0 -59
- package/dist/cdn/AIAY4NON.js +0 -245
- package/dist/cdn/CN6VFVA2.js +0 -19
- package/dist/cdn/GCFT45CD.js +0 -2
- package/dist/cdn/GN2HYJJX.js +0 -4
- package/dist/cdn/HN2HMAMX.js +0 -28
- package/dist/cdn/I22GHLAO.js +0 -2
- package/dist/cdn/IFSNQY7L.js +0 -2
- package/dist/cdn/IFWK7P7O.js +0 -2
- package/dist/cdn/J35M7O4J.js +0 -2
- package/dist/cdn/JABDBJPC.js +0 -2
- package/dist/cdn/KJZARHAM.js +0 -2
- package/dist/cdn/M672SFG6.js +0 -2
- package/dist/cdn/M7XUI5KY.js +0 -77
- package/dist/cdn/NKNUZCLA.js +0 -17
- package/dist/cdn/Q674OE2M.js +0 -2
- package/dist/cdn/SOWNHB7F.js +0 -30
- package/dist/cdn/VUHDKXFM.js +0 -2
- package/dist/cdn/X7WF7TCS.js +0 -2
- package/dist/cdn/XGVAPO3I.js +0 -2
- package/dist/cdn/XVUE27HC.js +0 -2
- package/dist/cdn/Y7UZYXEV.js +0 -2
- package/dist/cdn/ZF7JAW4Z.js +0 -2
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ar.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.bg.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.bs.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ca.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.cs.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.da.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.de.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.el.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.en.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.es.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.et.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.fi.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.fr.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.he.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.hr.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.hu.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.id.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.it.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ja.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ko.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.lt.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.lv.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.nl.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.no.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.pl.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.pt-BR.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.pt-PT.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ro.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.ru.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.sk.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.sl.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.sr.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.sv.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.th.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.tr.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.uk.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.vi.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.zh-CN.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.zh-HK.json +0 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.zh-TW.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ar.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.bg.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.bs.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ca.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.cs.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.da.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.de.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.el.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.en.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.es.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.et.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.fi.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.fr.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.he.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.hr.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.hu.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.id.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.it.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ja.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ko.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.lt.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.lv.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.nl.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.no.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.pl.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.pt-BR.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.pt-PT.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ro.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.ru.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.sk.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.sl.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.sr.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.sv.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.th.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.tr.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.uk.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.vi.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.zh-CN.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.zh-HK.json +0 -1
- package/dist/cdn/assets/assistant-shell/t9n/messages.zh-TW.json +0 -1
- package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +0 -32
- package/dist/components/arcgis-assistant-chat-card/customElement.js +0 -53
- package/dist/components/arcgis-assistant-chat-card/index.js +0 -6
- package/dist/components/arcgis-assistant-chat-card-content/customElement.d.ts +0 -12
- package/dist/components/arcgis-assistant-chat-card-content/customElement.js +0 -40
- package/dist/components/arcgis-assistant-chat-card-content/index.js +0 -2
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.d.ts +0 -8
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +0 -26
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.d.ts +0 -8
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +0 -26
- package/dist/components/arcgis-assistant-shell/customElement.d.ts +0 -37
- package/dist/components/arcgis-assistant-shell/customElement.js +0 -27
- package/dist/components/arcgis-assistant-shell/index.js +0 -6
- /package/dist/components/{arcgis-assistant-chat-card-content → arcgis-assistant-help-agent}/index.d.ts +0 -0
- /package/dist/components/{arcgis-assistant-layer-filter-agent → arcgis-assistant-help-agent}/index.js +0 -0
- /package/dist/components/{arcgis-assistant-chat-card → arcgis-assistant-message-block}/index.d.ts +0 -0
- /package/dist/components/{arcgis-assistant-layer-filter-agent → arcgis-assistant-message-content}/index.d.ts +0 -0
- /package/dist/components/{arcgis-assistant-layer-query-agent → arcgis-assistant-message-feedback}/index.d.ts +0 -0
- /package/dist/components/{arcgis-assistant-shell → arcgis-assistant-message-footer}/index.d.ts +0 -0
- /package/dist/components/{arcgis-assistant-layer-query-agent/index.js → arcgis-assistant-message-loading/index.d.ts} +0 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{a as de,b as li,c as qo}from"./CFDTXKJ6.js";export default $arcgis.t(([PT,Ov,J6,AX,OX])=>{var QT=de((xQ,YT)=>{"use strict";YT.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 aA=de((IQ,Wv)=>{"use strict";var EF=/[\p{Lu}]/u,$F=/[\p{Ll}]/u,eA=/^[\p{Lu}](?![\p{Lu}])/gu,nA=/([\p{Alpha}\p{N}_]|$)/u,iA=/[_.\- ]+/,TF=new RegExp("^"+iA.source),tA=new RegExp(iA.source+nA.source,"gu"),rA=new RegExp("\\d+"+nA.source,"gu"),AF=(e,t,r)=>{let n=!1,i=!1,o=!1;for(let a=0;a<e.length;a++){let s=e[a];n&&EF.test(s)?(e=e.slice(0,a)+"-"+e.slice(a),n=!1,o=i,i=!0,a++):i&&o&&$F.test(s)?(e=e.slice(0,a-1)+"-"+e.slice(a-1),o=i,i=!1,n=!0):(n=t(s)===s&&r(s)!==s,o=i,i=r(s)===s&&t(s)!==s)}return e},OF=(e,t)=>(eA.lastIndex=0,e.replace(eA,r=>t(r))),CF=(e,t)=>(tA.lastIndex=0,rA.lastIndex=0,e.replace(tA,(r,n)=>t(n)).replace(rA,r=>t(r))),oA=(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(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(t.locale),n=t.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(t.locale);return e.length===1?t.pascalCase?n(e):r(e):(e!==r(e)&&(e=AF(e,r,n)),e=e.replace(TF,""),t.preserveConsecutiveUppercase?e=OF(e,r):e=r(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),CF(e,n))};Wv.exports=oA;Wv.exports.default=oA});var OC=de((nne,Fb)=>{"use strict";var l3=Object.prototype.hasOwnProperty,gr="~";function Od(){}Object.create&&(Od.prototype=Object.create(null),new Od().__proto__||(gr=!1));function d3(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function AC(e,t,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new d3(r,n||e,i),a=gr?gr+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],o]:e._events[a].push(o):(e._events[a]=o,e._eventsCount++),e}function Zm(e,t){--e._eventsCount===0?e._events=new Od:delete e._events[t]}function rr(){this._events=new Od,this._eventsCount=0}rr.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)l3.call(r,n)&&t.push(gr?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};rr.prototype.listeners=function(t){var r=gr?gr+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a};rr.prototype.listenerCount=function(t){var r=gr?gr+t:t,n=this._events[r];return n?n.fn?1:n.length:0};rr.prototype.emit=function(t,r,n,i,o,a){var s=gr?gr+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,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,o),!0;case 6:return c.fn.call(c.context,r,n,i,o,a),!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,n);break;case 4:c[d].fn.call(c[d].context,r,n,i);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};rr.prototype.on=function(t,r,n){return AC(this,t,r,n,!1)};rr.prototype.once=function(t,r,n){return AC(this,t,r,n,!0)};rr.prototype.removeListener=function(t,r,n,i){var o=gr?gr+t:t;if(!this._events[o])return this;if(!r)return Zm(this,o),this;var a=this._events[o];if(a.fn)a.fn===r&&(!i||a.once)&&(!n||a.context===n)&&Zm(this,o);else{for(var s=0,c=[],u=a.length;s<u;s++)(a[s].fn!==r||i&&!a[s].once||n&&a[s].context!==n)&&c.push(a[s]);c.length?this._events[o]=c.length===1?c[0]:c:Zm(this,o)}return this};rr.prototype.removeAllListeners=function(t){var r;return t?(r=gr?gr+t:t,this._events[r]&&Zm(this,r)):(this._events=new Od,this._eventsCount=0),this};rr.prototype.off=rr.prototype.removeListener;rr.prototype.addListener=rr.prototype.on;rr.prefixed=gr;rr.EventEmitter=rr;typeof Fb<"u"&&(Fb.exports=rr)});var PC=de((ine,CC)=>{"use strict";CC.exports=(e,t)=>(t=t||(()=>{}),e.then(r=>new Promise(n=>{n(t())}).then(()=>r),r=>new Promise(n=>{n(t())}).then(()=>{throw r})))});var NC=de((one,Hm)=>{"use strict";var p3=PC(),Gm=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},RC=(e,t,r)=>new Promise((n,i)=>{if(typeof t!="number"||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0){n(e);return}let o=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let a=typeof r=="string"?r:`Promise timed out after ${t} milliseconds`,s=r instanceof Error?r:new Gm(a);typeof e.cancel=="function"&&e.cancel(),i(s)},t);p3(e.then(n,i),()=>{clearTimeout(o)})});Hm.exports=RC;Hm.exports.default=RC;Hm.exports.TimeoutError=Gm});var MC=de(Bb=>{"use strict";Object.defineProperty(Bb,"__esModule",{value:!0});function f3(e,t,r){let n=0,i=e.length;for(;i>0;){let o=i/2|0,a=n+o;r(e[a],t)<=0?(n=++a,i-=o+1):i=o}return n}Bb.default=f3});var jC=de(Zb=>{"use strict";Object.defineProperty(Zb,"__esModule",{value:!0});var m3=MC(),Vb=class{constructor(){this._queue=[]}enqueue(t,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:t};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=m3.default(this._queue,n,(o,a)=>a.priority-o.priority);this._queue.splice(i,0,n)}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}};Zb.default=Vb});var Km=de(Hb=>{"use strict";Object.defineProperty(Hb,"__esModule",{value:!0});var h3=OC(),zC=NC(),g3=jC(),qm=()=>{},_3=new zC.TimeoutError,Gb=class extends h3{constructor(t){var r,n,i,o;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=qm,this._resolveIdle=qm,t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:g3.default},t),!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=t.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${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 \`${(o=(i=t.interval)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""}\` (${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=qm,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=qm,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((n,i)=>{let o=async()=>{this._pendingCount++,this._intervalCount++;try{let a=this._timeout===void 0&&r.timeout===void 0?t():zC.default(Promise.resolve(t()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(_3)});n(await a)}catch(a){i(a)}this._next()};this._queue.enqueue(o,r),this._tryToStartAnother(),this.emit("add")})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,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}};Hb.default=Gb});var Pd=de((mne,LC)=>{"use strict";var v3="2.0.0",b3=Number.MAX_SAFE_INTEGER||9007199254740991,w3=16,x3=250,I3=["major","premajor","minor","preminor","patch","prepatch","prerelease"];LC.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:w3,MAX_SAFE_BUILD_LENGTH:x3,MAX_SAFE_INTEGER:b3,RELEASE_TYPES:I3,SEMVER_SPEC_VERSION:v3,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Rd=de((hne,UC)=>{"use strict";var S3=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};UC.exports=S3});var tu=de((bi,FC)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:Wb,MAX_SAFE_BUILD_LENGTH:k3,MAX_LENGTH:E3}=Pd(),$3=Rd();bi=FC.exports={};var T3=bi.re=[],A3=bi.safeRe=[],re=bi.src=[],O3=bi.safeSrc=[],ne=bi.t={},C3=0,Jb="[a-zA-Z0-9-]",P3=[["\\s",1],["\\d",E3],[Jb,k3]],R3=e=>{for(let[t,r]of P3)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},Ee=(e,t,r)=>{let n=R3(t),i=C3++;$3(e,i,t),ne[e]=i,re[i]=t,O3[i]=n,T3[i]=new RegExp(t,r?"g":void 0),A3[i]=new RegExp(n,r?"g":void 0)};Ee("NUMERICIDENTIFIER","0|[1-9]\\d*");Ee("NUMERICIDENTIFIERLOOSE","\\d+");Ee("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${Jb}*`);Ee("MAINVERSION",`(${re[ne.NUMERICIDENTIFIER]})\\.(${re[ne.NUMERICIDENTIFIER]})\\.(${re[ne.NUMERICIDENTIFIER]})`);Ee("MAINVERSIONLOOSE",`(${re[ne.NUMERICIDENTIFIERLOOSE]})\\.(${re[ne.NUMERICIDENTIFIERLOOSE]})\\.(${re[ne.NUMERICIDENTIFIERLOOSE]})`);Ee("PRERELEASEIDENTIFIER",`(?:${re[ne.NONNUMERICIDENTIFIER]}|${re[ne.NUMERICIDENTIFIER]})`);Ee("PRERELEASEIDENTIFIERLOOSE",`(?:${re[ne.NONNUMERICIDENTIFIER]}|${re[ne.NUMERICIDENTIFIERLOOSE]})`);Ee("PRERELEASE",`(?:-(${re[ne.PRERELEASEIDENTIFIER]}(?:\\.${re[ne.PRERELEASEIDENTIFIER]})*))`);Ee("PRERELEASELOOSE",`(?:-?(${re[ne.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${re[ne.PRERELEASEIDENTIFIERLOOSE]})*))`);Ee("BUILDIDENTIFIER",`${Jb}+`);Ee("BUILD",`(?:\\+(${re[ne.BUILDIDENTIFIER]}(?:\\.${re[ne.BUILDIDENTIFIER]})*))`);Ee("FULLPLAIN",`v?${re[ne.MAINVERSION]}${re[ne.PRERELEASE]}?${re[ne.BUILD]}?`);Ee("FULL",`^${re[ne.FULLPLAIN]}$`);Ee("LOOSEPLAIN",`[v=\\s]*${re[ne.MAINVERSIONLOOSE]}${re[ne.PRERELEASELOOSE]}?${re[ne.BUILD]}?`);Ee("LOOSE",`^${re[ne.LOOSEPLAIN]}$`);Ee("GTLT","((?:<|>)?=?)");Ee("XRANGEIDENTIFIERLOOSE",`${re[ne.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);Ee("XRANGEIDENTIFIER",`${re[ne.NUMERICIDENTIFIER]}|x|X|\\*`);Ee("XRANGEPLAIN",`[v=\\s]*(${re[ne.XRANGEIDENTIFIER]})(?:\\.(${re[ne.XRANGEIDENTIFIER]})(?:\\.(${re[ne.XRANGEIDENTIFIER]})(?:${re[ne.PRERELEASE]})?${re[ne.BUILD]}?)?)?`);Ee("XRANGEPLAINLOOSE",`[v=\\s]*(${re[ne.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ne.XRANGEIDENTIFIERLOOSE]})(?:\\.(${re[ne.XRANGEIDENTIFIERLOOSE]})(?:${re[ne.PRERELEASELOOSE]})?${re[ne.BUILD]}?)?)?`);Ee("XRANGE",`^${re[ne.GTLT]}\\s*${re[ne.XRANGEPLAIN]}$`);Ee("XRANGELOOSE",`^${re[ne.GTLT]}\\s*${re[ne.XRANGEPLAINLOOSE]}$`);Ee("COERCEPLAIN",`(^|[^\\d])(\\d{1,${Wb}})(?:\\.(\\d{1,${Wb}}))?(?:\\.(\\d{1,${Wb}}))?`);Ee("COERCE",`${re[ne.COERCEPLAIN]}(?:$|[^\\d])`);Ee("COERCEFULL",re[ne.COERCEPLAIN]+`(?:${re[ne.PRERELEASE]})?(?:${re[ne.BUILD]})?(?:$|[^\\d])`);Ee("COERCERTL",re[ne.COERCE],!0);Ee("COERCERTLFULL",re[ne.COERCEFULL],!0);Ee("LONETILDE","(?:~>?)");Ee("TILDETRIM",`(\\s*)${re[ne.LONETILDE]}\\s+`,!0);bi.tildeTrimReplace="$1~";Ee("TILDE",`^${re[ne.LONETILDE]}${re[ne.XRANGEPLAIN]}$`);Ee("TILDELOOSE",`^${re[ne.LONETILDE]}${re[ne.XRANGEPLAINLOOSE]}$`);Ee("LONECARET","(?:\\^)");Ee("CARETTRIM",`(\\s*)${re[ne.LONECARET]}\\s+`,!0);bi.caretTrimReplace="$1^";Ee("CARET",`^${re[ne.LONECARET]}${re[ne.XRANGEPLAIN]}$`);Ee("CARETLOOSE",`^${re[ne.LONECARET]}${re[ne.XRANGEPLAINLOOSE]}$`);Ee("COMPARATORLOOSE",`^${re[ne.GTLT]}\\s*(${re[ne.LOOSEPLAIN]})$|^$`);Ee("COMPARATOR",`^${re[ne.GTLT]}\\s*(${re[ne.FULLPLAIN]})$|^$`);Ee("COMPARATORTRIM",`(\\s*)${re[ne.GTLT]}\\s*(${re[ne.LOOSEPLAIN]}|${re[ne.XRANGEPLAIN]})`,!0);bi.comparatorTrimReplace="$1$2$3";Ee("HYPHENRANGE",`^\\s*(${re[ne.XRANGEPLAIN]})\\s+-\\s+(${re[ne.XRANGEPLAIN]})\\s*$`);Ee("HYPHENRANGELOOSE",`^\\s*(${re[ne.XRANGEPLAINLOOSE]})\\s+-\\s+(${re[ne.XRANGEPLAINLOOSE]})\\s*$`);Ee("STAR","(<|>)?=?\\s*\\*");Ee("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");Ee("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Jm=de((gne,BC)=>{"use strict";var N3=Object.freeze({loose:!0}),M3=Object.freeze({}),j3=e=>e?typeof e!="object"?N3:e:M3;BC.exports=j3});var Xb=de((_ne,GC)=>{"use strict";var VC=/^[0-9]+$/,ZC=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;let r=VC.test(e),n=VC.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},z3=(e,t)=>ZC(t,e);GC.exports={compareIdentifiers:ZC,rcompareIdentifiers:z3}});var nr=de((yne,qC)=>{"use strict";var Xm=Rd(),{MAX_LENGTH:HC,MAX_SAFE_INTEGER:Ym}=Pd(),{safeRe:Qm,t:eh}=tu(),D3=Jm(),{compareIdentifiers:Yb}=Xb(),Qb=class e{constructor(t,r){if(r=D3(r),t instanceof e){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>HC)throw new TypeError(`version is longer than ${HC} characters`);Xm("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let n=t.trim().match(r.loose?Qm[eh.LOOSE]:Qm[eh.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Ym||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Ym||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Ym||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){let o=+i;if(o>=0&&o<Ym)return o}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(Xm("SemVer.compare",this.version,this.options,t),!(t instanceof e)){if(typeof t=="string"&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let n=this.prerelease[r],i=t.prerelease[r];if(Xm("prerelease compare",r,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return Yb(n,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let n=this.build[r],i=t.build[r];if(Xm("build compare",r,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return Yb(n,i)}while(++r)}inc(t,r,n){if(t.startsWith("pre")){if(!r&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let i=`-${r}`.match(this.options.loose?Qm[eh.PRERELEASELOOSE]:Qm[eh.PRERELEASE]);if(!i||i[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,n),this.inc("pre",r,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,n),this.inc("pre",r,n);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let i=Number(n)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let o=this.prerelease.length;for(;--o>=0;)typeof this.prerelease[o]=="number"&&(this.prerelease[o]++,o=-2);if(o===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let o=[r,i];n===!1&&(o=[r]),Yb(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=o):this.prerelease=o}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};qC.exports=Qb});var ps=de((vne,WC)=>{"use strict";var KC=nr(),L3=(e,t,r=!1)=>{if(e instanceof KC)return e;try{return new KC(e,t)}catch(n){if(!r)return null;throw n}};WC.exports=L3});var XC=de((bne,JC)=>{"use strict";var U3=ps(),F3=(e,t)=>{let r=U3(e,t);return r?r.version:null};JC.exports=F3});var QC=de((wne,YC)=>{"use strict";var B3=ps(),V3=(e,t)=>{let r=B3(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};YC.exports=V3});var rP=de((xne,tP)=>{"use strict";var eP=nr(),Z3=(e,t,r,n,i)=>{typeof r=="string"&&(i=n,n=r,r=void 0);try{return new eP(e instanceof eP?e.version:e,r).inc(t,n,i).version}catch{return null}};tP.exports=Z3});var oP=de((Ine,iP)=>{"use strict";var nP=ps(),G3=(e,t)=>{let r=nP(e,null,!0),n=nP(t,null,!0),i=r.compare(n);if(i===0)return null;let o=i>0,a=o?r:n,s=o?n:r,c=!!a.prerelease.length;if(!!s.prerelease.length&&!c){if(!s.patch&&!s.minor)return"major";if(s.compareMain(a)===0)return s.minor&&!s.patch?"minor":"patch"}let l=c?"pre":"";return r.major!==n.major?l+"major":r.minor!==n.minor?l+"minor":r.patch!==n.patch?l+"patch":"prerelease"};iP.exports=G3});var sP=de((Sne,aP)=>{"use strict";var H3=nr(),q3=(e,t)=>new H3(e,t).major;aP.exports=q3});var uP=de((kne,cP)=>{"use strict";var K3=nr(),W3=(e,t)=>new K3(e,t).minor;cP.exports=W3});var dP=de((Ene,lP)=>{"use strict";var J3=nr(),X3=(e,t)=>new J3(e,t).patch;lP.exports=X3});var fP=de(($ne,pP)=>{"use strict";var Y3=ps(),Q3=(e,t)=>{let r=Y3(e,t);return r&&r.prerelease.length?r.prerelease:null};pP.exports=Q3});var hn=de((Tne,hP)=>{"use strict";var mP=nr(),eV=(e,t,r)=>new mP(e,r).compare(new mP(t,r));hP.exports=eV});var _P=de((Ane,gP)=>{"use strict";var tV=hn(),rV=(e,t,r)=>tV(t,e,r);gP.exports=rV});var vP=de((One,yP)=>{"use strict";var nV=hn(),iV=(e,t)=>nV(e,t,!0);yP.exports=iV});var th=de((Cne,wP)=>{"use strict";var bP=nr(),oV=(e,t,r)=>{let n=new bP(e,r),i=new bP(t,r);return n.compare(i)||n.compareBuild(i)};wP.exports=oV});var IP=de((Pne,xP)=>{"use strict";var aV=th(),sV=(e,t)=>e.sort((r,n)=>aV(r,n,t));xP.exports=sV});var kP=de((Rne,SP)=>{"use strict";var cV=th(),uV=(e,t)=>e.sort((r,n)=>cV(n,r,t));SP.exports=uV});var Nd=de((Nne,EP)=>{"use strict";var lV=hn(),dV=(e,t,r)=>lV(e,t,r)>0;EP.exports=dV});var rh=de((Mne,$P)=>{"use strict";var pV=hn(),fV=(e,t,r)=>pV(e,t,r)<0;$P.exports=fV});var ew=de((jne,TP)=>{"use strict";var mV=hn(),hV=(e,t,r)=>mV(e,t,r)===0;TP.exports=hV});var tw=de((zne,AP)=>{"use strict";var gV=hn(),_V=(e,t,r)=>gV(e,t,r)!==0;AP.exports=_V});var nh=de((Dne,OP)=>{"use strict";var yV=hn(),vV=(e,t,r)=>yV(e,t,r)>=0;OP.exports=vV});var ih=de((Lne,CP)=>{"use strict";var bV=hn(),wV=(e,t,r)=>bV(e,t,r)<=0;CP.exports=wV});var rw=de((Une,PP)=>{"use strict";var xV=ew(),IV=tw(),SV=Nd(),kV=nh(),EV=rh(),$V=ih(),TV=(e,t,r,n)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return xV(e,r,n);case"!=":return IV(e,r,n);case">":return SV(e,r,n);case">=":return kV(e,r,n);case"<":return EV(e,r,n);case"<=":return $V(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};PP.exports=TV});var NP=de((Fne,RP)=>{"use strict";var AV=nr(),OV=ps(),{safeRe:oh,t:ah}=tu(),CV=(e,t)=>{if(e instanceof AV)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?oh[ah.COERCEFULL]:oh[ah.COERCE]);else{let c=t.includePrerelease?oh[ah.COERCERTLFULL]:oh[ah.COERCERTL],u;for(;(u=c.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||u.index+u[0].length!==r.index+r[0].length)&&(r=u),c.lastIndex=u.index+u[1].length+u[2].length;c.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",o=r[4]||"0",a=t.includePrerelease&&r[5]?`-${r[5]}`:"",s=t.includePrerelease&&r[6]?`+${r[6]}`:"";return OV(`${n}.${i}.${o}${a}${s}`,t)};RP.exports=CV});var jP=de((Bne,MP)=>{"use strict";var nw=class{constructor(){this.max=1e3,this.map=new Map}get(t){let r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){let i=this.map.keys().next().value;this.delete(i)}this.map.set(t,r)}return this}};MP.exports=nw});var gn=de((Vne,UP)=>{"use strict";var PV=/\s+/g,iw=class e{constructor(t,r){if(r=NV(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof ow)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(PV," "),this.set=this.raw.split("||").map(n=>this.parseRange(n.trim())).filter(n=>n.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let n=this.set[0];if(this.set=this.set.filter(i=>!DP(i[0])),this.set.length===0)this.set=[n];else if(this.set.length>1){for(let i of this.set)if(i.length===1&&FV(i[0])){this.set=[i];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");let r=this.set[t];for(let n=0;n<r.length;n++)n>0&&(this.formatted+=" "),this.formatted+=r[n].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){let n=((this.options.includePrerelease&&LV)|(this.options.loose&&UV))+":"+t,i=zP.get(n);if(i)return i;let o=this.options.loose,a=o?_r[ir.HYPHENRANGELOOSE]:_r[ir.HYPHENRANGE];t=t.replace(a,XV(this.options.includePrerelease)),ut("hyphen replace",t),t=t.replace(_r[ir.COMPARATORTRIM],jV),ut("comparator trim",t),t=t.replace(_r[ir.TILDETRIM],zV),ut("tilde trim",t),t=t.replace(_r[ir.CARETTRIM],DV),ut("caret trim",t);let s=t.split(" ").map(d=>BV(d,this.options)).join(" ").split(/\s+/).map(d=>JV(d,this.options));o&&(s=s.filter(d=>(ut("loose invalid filter",d,this.options),!!d.match(_r[ir.COMPARATORLOOSE])))),ut("range list",s);let c=new Map,u=s.map(d=>new ow(d,this.options));for(let d of u){if(DP(d))return[d];c.set(d.value,d)}c.size>1&&c.has("")&&c.delete("");let l=[...c.values()];return zP.set(n,l),l}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(n=>LP(n,r)&&t.set.some(i=>LP(i,r)&&n.every(o=>i.every(a=>o.intersects(a,r)))))}test(t){if(!t)return!1;if(typeof t=="string")try{t=new MV(t,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(YV(this.set[r],t,this.options))return!0;return!1}};UP.exports=iw;var RV=jP(),zP=new RV,NV=Jm(),ow=Md(),ut=Rd(),MV=nr(),{safeRe:_r,t:ir,comparatorTrimReplace:jV,tildeTrimReplace:zV,caretTrimReplace:DV}=tu(),{FLAG_INCLUDE_PRERELEASE:LV,FLAG_LOOSE:UV}=Pd(),DP=e=>e.value==="<0.0.0-0",FV=e=>e.value==="",LP=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();for(;r&&n.length;)r=n.every(o=>i.intersects(o,t)),i=n.pop();return r},BV=(e,t)=>(e=e.replace(_r[ir.BUILD],""),ut("comp",e,t),e=GV(e,t),ut("caret",e),e=VV(e,t),ut("tildes",e),e=qV(e,t),ut("xrange",e),e=WV(e,t),ut("stars",e),e),yr=e=>!e||e.toLowerCase()==="x"||e==="*",VV=(e,t)=>e.trim().split(/\s+/).map(r=>ZV(r,t)).join(" "),ZV=(e,t)=>{let r=t.loose?_r[ir.TILDELOOSE]:_r[ir.TILDE];return e.replace(r,(n,i,o,a,s)=>{ut("tilde",e,n,i,o,a,s);let c;return yr(i)?c="":yr(o)?c=`>=${i}.0.0 <${+i+1}.0.0-0`:yr(a)?c=`>=${i}.${o}.0 <${i}.${+o+1}.0-0`:s?(ut("replaceTilde pr",s),c=`>=${i}.${o}.${a}-${s} <${i}.${+o+1}.0-0`):c=`>=${i}.${o}.${a} <${i}.${+o+1}.0-0`,ut("tilde return",c),c})},GV=(e,t)=>e.trim().split(/\s+/).map(r=>HV(r,t)).join(" "),HV=(e,t)=>{ut("caret",e,t);let r=t.loose?_r[ir.CARETLOOSE]:_r[ir.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(i,o,a,s,c)=>{ut("caret",e,i,o,a,s,c);let u;return yr(o)?u="":yr(a)?u=`>=${o}.0.0${n} <${+o+1}.0.0-0`:yr(s)?o==="0"?u=`>=${o}.${a}.0${n} <${o}.${+a+1}.0-0`:u=`>=${o}.${a}.0${n} <${+o+1}.0.0-0`:c?(ut("replaceCaret pr",c),o==="0"?a==="0"?u=`>=${o}.${a}.${s}-${c} <${o}.${a}.${+s+1}-0`:u=`>=${o}.${a}.${s}-${c} <${o}.${+a+1}.0-0`:u=`>=${o}.${a}.${s}-${c} <${+o+1}.0.0-0`):(ut("no pr"),o==="0"?a==="0"?u=`>=${o}.${a}.${s}${n} <${o}.${a}.${+s+1}-0`:u=`>=${o}.${a}.${s}${n} <${o}.${+a+1}.0-0`:u=`>=${o}.${a}.${s} <${+o+1}.0.0-0`),ut("caret return",u),u})},qV=(e,t)=>(ut("replaceXRanges",e,t),e.split(/\s+/).map(r=>KV(r,t)).join(" ")),KV=(e,t)=>{e=e.trim();let r=t.loose?_r[ir.XRANGELOOSE]:_r[ir.XRANGE];return e.replace(r,(n,i,o,a,s,c)=>{ut("xRange",e,n,i,o,a,s,c);let u=yr(o),l=u||yr(a),d=l||yr(s),f=d;return i==="="&&f&&(i=""),c=t.includePrerelease?"-0":"",u?i===">"||i==="<"?n="<0.0.0-0":n="*":i&&f?(l&&(a=0),s=0,i===">"?(i=">=",l?(o=+o+1,a=0,s=0):(a=+a+1,s=0)):i==="<="&&(i="<",l?o=+o+1:a=+a+1),i==="<"&&(c="-0"),n=`${i+o}.${a}.${s}${c}`):l?n=`>=${o}.0.0${c} <${+o+1}.0.0-0`:d&&(n=`>=${o}.${a}.0${c} <${o}.${+a+1}.0-0`),ut("xRange return",n),n})},WV=(e,t)=>(ut("replaceStars",e,t),e.trim().replace(_r[ir.STAR],"")),JV=(e,t)=>(ut("replaceGTE0",e,t),e.trim().replace(_r[t.includePrerelease?ir.GTE0PRE:ir.GTE0],"")),XV=e=>(t,r,n,i,o,a,s,c,u,l,d,f)=>(yr(n)?r="":yr(i)?r=`>=${n}.0.0${e?"-0":""}`:yr(o)?r=`>=${n}.${i}.0${e?"-0":""}`:a?r=`>=${r}`:r=`>=${r}${e?"-0":""}`,yr(u)?c="":yr(l)?c=`<${+u+1}.0.0-0`:yr(d)?c=`<${u}.${+l+1}.0-0`:f?c=`<=${u}.${l}.${d}-${f}`:e?c=`<${u}.${l}.${+d+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),YV=(e,t,r)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let n=0;n<e.length;n++)if(ut(e[n].semver),e[n].semver!==ow.ANY&&e[n].semver.prerelease.length>0){let i=e[n].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}return!1}return!0}});var Md=de((Zne,HP)=>{"use strict";var jd=Symbol("SemVer ANY"),cw=class e{static get ANY(){return jd}constructor(t,r){if(r=FP(r),t instanceof e){if(t.loose===!!r.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(" "),sw("comparator",t,r),this.options=r,this.loose=!!r.loose,this.parse(t),this.semver===jd?this.value="":this.value=this.operator+this.semver.version,sw("comp",this)}parse(t){let r=this.options.loose?BP[VP.COMPARATORLOOSE]:BP[VP.COMPARATOR],n=t.match(r);if(!n)throw new TypeError(`Invalid comparator: ${t}`);this.operator=n[1]!==void 0?n[1]:"",this.operator==="="&&(this.operator=""),n[2]?this.semver=new ZP(n[2],this.options.loose):this.semver=jd}toString(){return this.value}test(t){if(sw("Comparator.test",t,this.options.loose),this.semver===jd||t===jd)return!0;if(typeof t=="string")try{t=new ZP(t,this.options)}catch{return!1}return aw(t,this.operator,this.semver,this.options)}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new GP(t.value,r).test(this.value):t.operator===""?t.value===""?!0:new GP(this.value,r).test(t.semver):(r=FP(r),r.includePrerelease&&(this.value==="<0.0.0-0"||t.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&t.operator.startsWith(">")||this.operator.startsWith("<")&&t.operator.startsWith("<")||this.semver.version===t.semver.version&&this.operator.includes("=")&&t.operator.includes("=")||aw(this.semver,"<",t.semver,r)&&this.operator.startsWith(">")&&t.operator.startsWith("<")||aw(this.semver,">",t.semver,r)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}};HP.exports=cw;var FP=Jm(),{safeRe:BP,t:VP}=tu(),aw=rw(),sw=Rd(),ZP=nr(),GP=gn()});var zd=de((Gne,qP)=>{"use strict";var QV=gn(),eZ=(e,t,r)=>{try{t=new QV(t,r)}catch{return!1}return t.test(e)};qP.exports=eZ});var WP=de((Hne,KP)=>{"use strict";var tZ=gn(),rZ=(e,t)=>new tZ(e,t).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));KP.exports=rZ});var XP=de((qne,JP)=>{"use strict";var nZ=nr(),iZ=gn(),oZ=(e,t,r)=>{let n=null,i=null,o=null;try{o=new iZ(t,r)}catch{return null}return e.forEach(a=>{o.test(a)&&(!n||i.compare(a)===-1)&&(n=a,i=new nZ(n,r))}),n};JP.exports=oZ});var QP=de((Kne,YP)=>{"use strict";var aZ=nr(),sZ=gn(),cZ=(e,t,r)=>{let n=null,i=null,o=null;try{o=new sZ(t,r)}catch{return null}return e.forEach(a=>{o.test(a)&&(!n||i.compare(a)===1)&&(n=a,i=new aZ(n,r))}),n};YP.exports=cZ});var rR=de((Wne,tR)=>{"use strict";var uw=nr(),uZ=gn(),eR=Nd(),lZ=(e,t)=>{e=new uZ(e,t);let r=new uw("0.0.0");if(e.test(r)||(r=new uw("0.0.0-0"),e.test(r)))return r;r=null;for(let n=0;n<e.set.length;++n){let i=e.set[n],o=null;i.forEach(a=>{let s=new uw(a.semver.version);switch(a.operator){case">":s.prerelease.length===0?s.patch++:s.prerelease.push(0),s.raw=s.format();case"":case">=":(!o||eR(s,o))&&(o=s);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${a.operator}`)}}),o&&(!r||eR(r,o))&&(r=o)}return r&&e.test(r)?r:null};tR.exports=lZ});var iR=de((Jne,nR)=>{"use strict";var dZ=gn(),pZ=(e,t)=>{try{return new dZ(e,t).range||"*"}catch{return null}};nR.exports=pZ});var sh=de((Xne,cR)=>{"use strict";var fZ=nr(),sR=Md(),{ANY:mZ}=sR,hZ=gn(),gZ=zd(),oR=Nd(),aR=rh(),_Z=ih(),yZ=nh(),vZ=(e,t,r,n)=>{e=new fZ(e,n),t=new hZ(t,n);let i,o,a,s,c;switch(r){case">":i=oR,o=_Z,a=aR,s=">",c=">=";break;case"<":i=aR,o=yZ,a=oR,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(gZ(e,t,n))return!1;for(let u=0;u<t.set.length;++u){let l=t.set[u],d=null,f=null;if(l.forEach(p=>{p.semver===mZ&&(p=new sR(">=0.0.0")),d=d||p,f=f||p,i(p.semver,d.semver,n)?d=p:a(p.semver,f.semver,n)&&(f=p)}),d.operator===s||d.operator===c||(!f.operator||f.operator===s)&&o(e,f.semver))return!1;if(f.operator===c&&a(e,f.semver))return!1}return!0};cR.exports=vZ});var lR=de((Yne,uR)=>{"use strict";var bZ=sh(),wZ=(e,t,r)=>bZ(e,t,">",r);uR.exports=wZ});var pR=de((Qne,dR)=>{"use strict";var xZ=sh(),IZ=(e,t,r)=>xZ(e,t,"<",r);dR.exports=IZ});var hR=de((eie,mR)=>{"use strict";var fR=gn(),SZ=(e,t,r)=>(e=new fR(e,r),t=new fR(t,r),e.intersects(t,r));mR.exports=SZ});var _R=de((tie,gR)=>{"use strict";var kZ=zd(),EZ=hn();gR.exports=(e,t,r)=>{let n=[],i=null,o=null,a=e.sort((l,d)=>EZ(l,d,r));for(let l of a)kZ(l,t,r)?(o=l,i||(i=l)):(o&&n.push([i,o]),o=null,i=null);i&&n.push([i,null]);let s=[];for(let[l,d]of n)l===d?s.push(l):!d&&l===a[0]?s.push("*"):d?l===a[0]?s.push(`<=${d}`):s.push(`${l} - ${d}`):s.push(`>=${l}`);let c=s.join(" || "),u=typeof t.raw=="string"?t.raw:String(t);return c.length<u.length?c:t}});var IR=de((rie,xR)=>{"use strict";var yR=gn(),dw=Md(),{ANY:lw}=dw,Dd=zd(),pw=hn(),$Z=(e,t,r={})=>{if(e===t)return!0;e=new yR(e,r),t=new yR(t,r);let n=!1;e:for(let i of e.set){for(let o of t.set){let a=AZ(i,o,r);if(n=n||a!==null,a)continue e}if(n)return!1}return!0},TZ=[new dw(">=0.0.0-0")],vR=[new dw(">=0.0.0")],AZ=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===lw){if(t.length===1&&t[0].semver===lw)return!0;r.includePrerelease?e=TZ:e=vR}if(t.length===1&&t[0].semver===lw){if(r.includePrerelease)return!0;t=vR}let n=new Set,i,o;for(let p of e)p.operator===">"||p.operator===">="?i=bR(i,p,r):p.operator==="<"||p.operator==="<="?o=wR(o,p,r):n.add(p.semver);if(n.size>1)return null;let a;if(i&&o){if(a=pw(i.semver,o.semver,r),a>0)return null;if(a===0&&(i.operator!==">="||o.operator!=="<="))return null}for(let p of n){if(i&&!Dd(p,String(i),r)||o&&!Dd(p,String(o),r))return null;for(let m of t)if(!Dd(p,String(m),r))return!1;return!0}let s,c,u,l,d=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,f=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;d&&d.prerelease.length===1&&o.operator==="<"&&d.prerelease[0]===0&&(d=!1);for(let p of t){if(l=l||p.operator===">"||p.operator===">=",u=u||p.operator==="<"||p.operator==="<=",i){if(f&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch&&(f=!1),p.operator===">"||p.operator===">="){if(s=bR(i,p,r),s===p&&s!==i)return!1}else if(i.operator===">="&&!Dd(i.semver,String(p),r))return!1}if(o){if(d&&p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===d.major&&p.semver.minor===d.minor&&p.semver.patch===d.patch&&(d=!1),p.operator==="<"||p.operator==="<="){if(c=wR(o,p,r),c===p&&c!==o)return!1}else if(o.operator==="<="&&!Dd(o.semver,String(p),r))return!1}if(!p.operator&&(o||i)&&a!==0)return!1}return!(i&&u&&!o&&a!==0||o&&l&&!i&&a!==0||f||d)},bR=(e,t,r)=>{if(!e)return t;let n=pw(e.semver,t.semver,r);return n>0?e:n<0||t.operator===">"&&e.operator===">="?t:e},wR=(e,t,r)=>{if(!e)return t;let n=pw(e.semver,t.semver,r);return n<0?e:n>0||t.operator==="<"&&e.operator==="<="?t:e};xR.exports=$Z});var $R=de((nie,ER)=>{"use strict";var fw=tu(),SR=Pd(),OZ=nr(),kR=Xb(),CZ=ps(),PZ=XC(),RZ=QC(),NZ=rP(),MZ=oP(),jZ=sP(),zZ=uP(),DZ=dP(),LZ=fP(),UZ=hn(),FZ=_P(),BZ=vP(),VZ=th(),ZZ=IP(),GZ=kP(),HZ=Nd(),qZ=rh(),KZ=ew(),WZ=tw(),JZ=nh(),XZ=ih(),YZ=rw(),QZ=NP(),e9=Md(),t9=gn(),r9=zd(),n9=WP(),i9=XP(),o9=QP(),a9=rR(),s9=iR(),c9=sh(),u9=lR(),l9=pR(),d9=hR(),p9=_R(),f9=IR();ER.exports={parse:CZ,valid:PZ,clean:RZ,inc:NZ,diff:MZ,major:jZ,minor:zZ,patch:DZ,prerelease:LZ,compare:UZ,rcompare:FZ,compareLoose:BZ,compareBuild:VZ,sort:ZZ,rsort:GZ,gt:HZ,lt:qZ,eq:KZ,neq:WZ,gte:JZ,lte:XZ,cmp:YZ,coerce:QZ,Comparator:e9,Range:t9,satisfies:r9,toComparators:n9,maxSatisfying:i9,minSatisfying:o9,minVersion:a9,validRange:s9,outside:c9,gtr:u9,ltr:l9,intersects:d9,simplifyRange:p9,subset:f9,SemVer:OZ,re:fw.re,src:fw.src,tokens:fw.t,SEMVER_SPEC_VERSION:SR.SEMVER_SPEC_VERSION,RELEASE_TYPES:SR.RELEASE_TYPES,compareIdentifiers:kR.compareIdentifiers,rcompareIdentifiers:kR.rcompareIdentifiers}});var WR=de((Kie,KR)=>{"use strict";var HR=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,qR=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function z9(){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,n]of Object.entries(t)){for(let[i,o]of Object.entries(n))t[i]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[i]=t[i],e.set(o[0],o[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi256=HR(),t.color.ansi16m=qR(),t.bgColor.ansi256=HR(10),t.bgColor.ansi16m=qR(10),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,i)=>r===n&&n===i?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:i}=n.groups;i.length===3&&(i=i.split("").map(a=>a+a).join(""));let o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1}}),t}Object.defineProperty(KR,"exports",{enumerable:!0,get:z9})});var nz=de(o_=>{"use strict";o_.byteLength=Fq;o_.toByteArray=Vq;o_.fromByteArray=Hq;var Mi=[],kn=[],Uq=typeof Uint8Array<"u"?Uint8Array:Array,QS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Hs=0,tz=QS.length;Hs<tz;++Hs)Mi[Hs]=QS[Hs],kn[QS.charCodeAt(Hs)]=Hs;var Hs,tz;kn[45]=62;kn[95]=63;function rz(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 n=r===t?0:4-r%4;return[r,n]}function Fq(e){var t=rz(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Bq(e,t,r){return(t+r)*3/4-r}function Vq(e){var t,r=rz(e),n=r[0],i=r[1],o=new Uq(Bq(e,n,i)),a=0,s=i>0?n-4:n,c;for(c=0;c<s;c+=4)t=kn[e.charCodeAt(c)]<<18|kn[e.charCodeAt(c+1)]<<12|kn[e.charCodeAt(c+2)]<<6|kn[e.charCodeAt(c+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=t&255;return i===2&&(t=kn[e.charCodeAt(c)]<<2|kn[e.charCodeAt(c+1)]>>4,o[a++]=t&255),i===1&&(t=kn[e.charCodeAt(c)]<<10|kn[e.charCodeAt(c+1)]<<4|kn[e.charCodeAt(c+2)]>>2,o[a++]=t>>8&255,o[a++]=t&255),o}function Zq(e){return Mi[e>>18&63]+Mi[e>>12&63]+Mi[e>>6&63]+Mi[e&63]}function Gq(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Zq(n));return i.join("")}function Hq(e){for(var t,r=e.length,n=r%3,i=[],o=16383,a=0,s=r-n;a<s;a+=o)i.push(Gq(e,a,a+o>s?s:a+o));return n===1?(t=e[r-1],i.push(Mi[t>>2]+Mi[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Mi[t>>10]+Mi[t>>4&63]+Mi[t<<2&63]+"=")),i.join("")}});var Ye="__start__",it="__end__",di="__input__";var jc="__error__",Kf="__pregel_ns_writes",cn="__pregel_send",dd="__pregel_call",On="__pregel_read",Cn="__pregel_checkpointer",zc="__pregel_resuming",pd="__pregel_task_id",fd="__pregel_stream",rF="__pregel_resume_value",Dc="__pregel_resume_map",Br="__pregel_scratchpad",Lc="__pregel_previous",nF="__pregel_durability",Wf="checkpoint_id",un="checkpoint_ns",DT="__pregel_node_finished",ln="checkpoint_map",LT="__pregel_abort_signals",ot="__interrupt__",Vr="__resume__",md="__no_writes__",Ko="__return__",ts="__previous__",Tt="langsmith:hidden";var Pv="__self__",pi="__pregel_tasks",dn="__pregel_push",Jf="__pregel_pull",Zr="00000000-0000-0000-0000-000000000000",UT=[Tt,di,ot,Vr,jc,md,cn,On,Cn,nF,fd,zc,pd,dd,rF,Br,Lc,ln,un,Wf],Cv=Symbol.for("langgraph.command"),FT=class{[Cv];constructor(e){this[Cv]=e}};function Xf(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var es=class{lg_name="Send";node;args;constructor(e,t){this.node=e,this.args=ld(t)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function At(e){return e instanceof es}var Mc="__overwrite__",iF=class{lg_name="Overwrite";[Mc];constructor(e){this[Mc]=e}get value(){return this[Mc]}toJSON(){return{[Mc]:this[Mc]}}static isInstance(e){return!e||typeof e!="object"?!1:"__overwrite__"in e||"lg_name"in e&&e.lg_name==="Overwrite"}};function Yf(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[Mc]]:[!1,void 0]}function BT(e){return Yf(e)[0]}function hd(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[ot])}var Ar=class extends FT{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)?ld(e.goto):[ld(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:At(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 Nt(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function ld(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((n,i)=>{r[i]=ld(n,t)});else if(Nt(e)&&!(e instanceof Ar))r=new Ar(e),t.set(e,r);else if(Xf(e)&&!(e instanceof es))r=new es(e.node,e.args),t.set(e,r);else if(Nt(e)||At(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[n,i]of Object.entries(e))r[n]=ld(i,t)}return r}return e}var eo=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}},Rv=class extends eo{get is_bubble_up(){return!0}},Nv=class extends eo{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},rs=class extends eo{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},to=class extends Rv{interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},Qf=class extends to{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},em=class extends Rv{command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function Mv(e){return e!==void 0&&e.name===em.unminifiable_name}function ns(e){return e!==void 0&&e.is_bubble_up===!0}function ro(e){return e!==void 0&&[to.unminifiable_name,Qf.unminifiable_name].includes(e.name)}var tm=class extends eo{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},Ve=class extends eo{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},Re=class extends eo{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}};var jv=class extends eo{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}};var gd=class extends eo{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"}};var VT=/^(?:[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 oF(e){return typeof e=="string"&&VT.test(e)}var Uc=oF;function aF(e){if(!Uc(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 rm=aF;var Kt=[];for(nm=0;nm<256;++nm)Kt.push((nm+256).toString(16).slice(1));var nm;function pn(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 im,sF=new Uint8Array(16);function is(){if(!im&&(im=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!im))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return im(sF)}var zv,om,Dv=0,Lv=0;function cF(e,t,r){var n=t&&r||0,i=t||new Array(16);e=e||{};var o=e.node,a=e.clockseq;if(e._v6||(o||(o=zv),a==null&&(a=om)),o==null||a==null){var s=e.random||(e.rng||is)();o==null&&(o=[s[0],s[1],s[2],s[3],s[4],s[5]],!zv&&!e._v6&&(o[0]|=1,zv=o)),a==null&&(a=(s[6]<<8|s[7])&16383,om===void 0&&!e._v6&&(om=a))}var c=e.msecs!==void 0?e.msecs:Date.now(),u=e.nsecs!==void 0?e.nsecs:Lv+1,l=c-Dv+(u-Lv)/1e4;if(l<0&&e.clockseq===void 0&&(a=a+1&16383),(l<0||c>Dv)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Dv=c,Lv=u,om=a,c+=122192928e5;var d=((c&268435455)*1e4+u)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=c/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=a>>>8|128,i[n++]=a&255;for(var p=0;p<6;++p)i[n+p]=o[p];return t||pn(i)}var ZT=cF;function Uv(e){var t=typeof e=="string"?rm(e):e,r=uF(t);return typeof e=="string"?pn(r):r}function uF(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 lF(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var dF="6ba7b810-9dad-11d1-80b4-00c04fd430c8",pF="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Fv(e,t,r){function n(i,o,a,s){var c;if(typeof i=="string"&&(i=lF(i)),typeof o=="string"&&(o=rm(o)),((c=o)===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+i.length);if(u.set(o),u.set(i,o.length),u=r(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,a){s=s||0;for(var l=0;l<16;++l)a[s+l]=u[l];return a}return pn(u)}try{n.name=e}catch{}return n.DNS=dF,n.URL=pF,n}var fF=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Bv={randomUUID:fF};function mF(e,t,r){if(Bv.randomUUID&&!t&&!e)return Bv.randomUUID();e=e||{};var n=e.random||(e.rng||is)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return pn(n)}var fi=mF;function hF(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function Vv(e,t){return e<<t|e>>>32-t}function gF(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i<n.length;++i)e.push(n.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,a=Math.ceil(o/16),s=new Array(a),c=0;c<a;++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[a-1][14]=(e.length-1)*8/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<a;++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]=Vv(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=r[0],w=r[1],_=r[2],y=r[3],x=r[4],S=0;S<80;++S){var $=Math.floor(S/20),j=Vv(h,5)+hF($,w,_,y)+x+t[$]+f[S]>>>0;x=y,y=_,_=Vv(w,30)>>>0,w=h,h=j}r[0]=r[0]+h>>>0,r[1]=r[1]+w>>>0,r[2]=r[2]+_>>>0,r[3]=r[3]+y>>>0,r[4]=r[4]+x>>>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 GT=gF;var _F=Fv("v5",80,GT),_d=_F;function HT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function qT(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?HT(Object(r),!0).forEach(function(n){yF(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):HT(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function yF(e,t,r){return(t=vF(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vF(e){var t=bF(e,"string");return typeof t=="symbol"?t:t+""}function bF(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function am(e={},t,r=0){var n=ZT(qT(qT({},e),{},{_v6:!0}),new Uint8Array(16));if(n=Uv(n),t){for(var i=0;i<16;i++)t[r+i]=n[i];return t}return pn(n)}var KT=null,WT=null,Pn=0;function wF(e,t,r){e=e||{};var n=t&&r||0,i=t||new Uint8Array(16),o=e.random||(e.rng||is)(),a=e.msecs!==void 0?e.msecs:Date.now(),s=e.seq!==void 0?e.seq:null,c=WT,u=KT;return a>Pn&&e.msecs===void 0&&(Pn=a,s!==null&&(c=null,u=null)),s!==null&&(s>2147483647&&(s=2147483647),c=s>>>19&4095,u=s&524287),(c===null||u===null)&&(c=o[6]&127,c=c<<8|o[7],u=o[8]&63,u=u<<8|o[9],u=u<<5|o[10]>>>3),a+1e4>Pn&&s===null?++u>524287&&(u=0,++c>4095&&(c=0,Pn++)):Pn=a,WT=c,KT=u,i[n++]=Pn/1099511627776&255,i[n++]=Pn/4294967296&255,i[n++]=Pn/16777216&255,i[n++]=Pn/65536&255,i[n++]=Pn/256&255,i[n++]=Pn&255,i[n++]=c>>>4&15|112,i[n++]=c&255,i[n++]=u>>>13&63|128,i[n++]=u>>>5&255,i[n++]=u<<3&255|o[10]&7,i[n++]=o[11],i[n++]=o[12],i[n++]=o[13],i[n++]=o[14],i[n++]=o[15],t||pn(i)}var yd=wF;function vd(e){return am({clockseq:e})}function no(e,t){let r=t.replace(/-/g,"").match(/.{2}/g).map(n=>parseInt(n,16));return _d(e,new Uint8Array(r))}var bd="__pregel_tasks",Zv="__error__",os="__scheduled__",Gv="__interrupt__",Hv="__resume__";var JT="[...]",IF="[Circular]",sm=[],Fc=[];function SF(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function XT(e,t,r,n){typeof n>"u"&&(n=SF()),Kv(e,"",0,[],void 0,0,n);var i;try{Fc.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,kF(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;sm.length!==0;){var o=sm.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function qv(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),sm.push([n,r,t,i])):Fc.push([t,r,e]):(n[r]=e,sm.push([n,r,t]))}function Kv(e,t,r,n,i,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){qv(IF,e,t,i);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){qv(JT,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){qv(JT,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)Kv(e[s],s,s,n,e,o,a);else{var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];Kv(e[u],u,s,n,e,o,a)}}n.pop()}}function kF(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Fc.length>0)for(var n=0;n<Fc.length;n++){var i=Fc[n];if(i[1]===t&&i[0]===r){r=i[2],Fc.splice(n,1);break}}return e.call(this,t,r)}}var sA=qo(QT(),1),cA=qo(aA(),1);function uA(e,t){return t?.[e]||(0,sA.default)(e)}function lA(e,t){return t?.[e]||(0,cA.default)(e)}function cm(e,t,r){let n={};for(let i in e)Object.hasOwn(e,i)&&(n[t(i,r)]=e[i]);return n}var dA="__lc_escaped__";function PF(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function RF(e){return{[dA]:e}}function Jv(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function NF(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function MF(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 um(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return MF(e);if(NF(e))return e;t.add(e);let r=e;if(PF(r))return t.delete(e),RF(r);let n={};for(let[i,o]of Object.entries(r))n[i]=um(o,t);return t.delete(e),n}return Array.isArray(e)?e.map(r=>um(r,t)):e}function lm(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(Jv(t))return t[dA];let r={};for(let[n,i]of Object.entries(t))r[n]=lm(i);return r}return Array.isArray(e)?e.map(t=>lm(t)):e}var pA=Object.defineProperty,P=(e,t)=>{let r={};for(var n in e)pA(r,n,{get:e[n],enumerable:!0});return t||pA(r,Symbol.toStringTag,{value:"Module"}),r};var mA=P({Serializable:()=>kt,get_lc_unique_name:()=>Bc});function fA(e){return Array.isArray(e)?[...e]:{...e}}function jF(e,t){let r=fA(e);for(let[n,i]of Object.entries(t)){let[o,...a]=n.split(".").reverse(),s=r;for(let c of a.reverse()){if(s[c]===void 0)break;s[c]=fA(s[c]),s=s[c]}s[o]!==void 0&&(s[o]={lc:1,type:"secret",id:[i]})}return r}function Bc(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 kt=class hA{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Bc(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(([n])=>this.lc_serializable_keys?.includes(n))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof hA||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},r={},n=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(n,Reflect.get(s,"lc_attributes",this));Object.keys(r).forEach(s=>{let c=this,u=n,[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 i={},o=new WeakSet;o.add(this);for(let[s,c]of Object.entries(n))i[s]=um(c,o);let a=cm(Object.keys(r).length?jF(i,r):i,uA,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:a}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}};var gA=P({getEnv:()=>pm,getEnvironmentVariable:()=>et,getRuntimeEnvironment:()=>Yv,isBrowser:()=>_A,isDeno:()=>dm,isJsDom:()=>vA,isNode:()=>bA,isWebWorker:()=>yA}),_A=()=>typeof window<"u"&&typeof window.document<"u",yA=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",vA=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),dm=()=>typeof Deno<"u",bA=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!dm(),pm=()=>{let e;return _A()?e="browser":bA()?e="node":yA()?e="webworker":vA()?e="jsdom":dm()?e="deno":e="other",e},Xv;function Yv(){return Xv===void 0&&(Xv={library:"langchain-js",runtime:pm()}),Xv}function et(e){try{return typeof process<"u"?process.env?.[e]:dm()?Deno?.env.get(e):void 0}catch{return}}var wA=[];var xA=P({});var IA=P({});var oe="0123456789abcdef".split(""),zF=[-2147483648,8388608,32768,128],Rn=[24,16,8,0],fm=[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],Ft=[];function Nn(e,t){t?(Ft[0]=Ft[16]=Ft[1]=Ft[2]=Ft[3]=Ft[4]=Ft[5]=Ft[6]=Ft[7]=Ft[8]=Ft[9]=Ft[10]=Ft[11]=Ft[12]=Ft[13]=Ft[14]=Ft[15]=0,this.blocks=Ft):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}Nn.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 n,i=0,o,a=e.length,s=this.blocks;i<a;){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(o=this.start;i<a&&o<64;++i)s[o>>>2]|=e[i]<<Rn[o++&3];else for(o=this.start;i<a&&o<64;++i)n=e.charCodeAt(i),n<128?s[o>>>2]|=n<<Rn[o++&3]:n<2048?(s[o>>>2]|=(192|n>>>6)<<Rn[o++&3],s[o>>>2]|=(128|n&63)<<Rn[o++&3]):n<55296||n>=57344?(s[o>>>2]|=(224|n>>>12)<<Rn[o++&3],s[o>>>2]|=(128|n>>>6&63)<<Rn[o++&3],s[o>>>2]|=(128|n&63)<<Rn[o++&3]):(n=65536+((n&1023)<<10|e.charCodeAt(++i)&1023),s[o>>>2]|=(240|n>>>18)<<Rn[o++&3],s[o>>>2]|=(128|n>>>12&63)<<Rn[o++&3],s[o>>>2]|=(128|n>>>6&63)<<Rn[o++&3],s[o>>>2]|=(128|n&63)<<Rn[o++&3]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=s[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Nn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=zF[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()}};Nn.prototype.hash=function(){var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,c=this.blocks,u,l,d,f,p,m,h,w,_,y,x;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(x=t&r,u=0;u<64;u+=4)this.first?(this.is224?(w=300032,p=c[0]-1413257819,s=p-150054599<<0,n=p+24177077<<0):(w=704751109,p=c[0]-210244248,s=p-1521486534<<0,n=p+143694565<<0),this.first=!1):(l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),d=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),w=e&t,f=w^e&r^x,h=i&o^~i&a,p=s+d+h+fm[u]+c[u],m=l+f,s=n+p<<0,n=p+m<<0),l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),_=n&e,f=_^n&t^w,h=a&s^~a&i,p=o+d+h+fm[u+1]+c[u+1],m=l+f,a=r+p<<0,r=p+m<<0,l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),y=r&n,f=y^r&e^_,h=o&a^~o&s,p=i+d+h+fm[u+2]+c[u+2],m=l+f,o=t+p<<0,t=p+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=t&r,f=x^t&n^y,h=o&a^~o&s,p=i+d+h+fm[u+3]+c[u+3],m=l+f,i=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+n<<0,this.h4=this.h4+i<<0,this.h5=this.h5+o<<0,this.h6=this.h6+a<<0,this.h7=this.h7+s<<0};Nn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=this.h6,s=this.h7,c=oe[e>>>28&15]+oe[e>>>24&15]+oe[e>>>20&15]+oe[e>>>16&15]+oe[e>>>12&15]+oe[e>>>8&15]+oe[e>>>4&15]+oe[e&15]+oe[t>>>28&15]+oe[t>>>24&15]+oe[t>>>20&15]+oe[t>>>16&15]+oe[t>>>12&15]+oe[t>>>8&15]+oe[t>>>4&15]+oe[t&15]+oe[r>>>28&15]+oe[r>>>24&15]+oe[r>>>20&15]+oe[r>>>16&15]+oe[r>>>12&15]+oe[r>>>8&15]+oe[r>>>4&15]+oe[r&15]+oe[n>>>28&15]+oe[n>>>24&15]+oe[n>>>20&15]+oe[n>>>16&15]+oe[n>>>12&15]+oe[n>>>8&15]+oe[n>>>4&15]+oe[n&15]+oe[i>>>28&15]+oe[i>>>24&15]+oe[i>>>20&15]+oe[i>>>16&15]+oe[i>>>12&15]+oe[i>>>8&15]+oe[i>>>4&15]+oe[i&15]+oe[o>>>28&15]+oe[o>>>24&15]+oe[o>>>20&15]+oe[o>>>16&15]+oe[o>>>12&15]+oe[o>>>8&15]+oe[o>>>4&15]+oe[o&15]+oe[a>>>28&15]+oe[a>>>24&15]+oe[a>>>20&15]+oe[a>>>16&15]+oe[a>>>12&15]+oe[a>>>8&15]+oe[a>>>4&15]+oe[a&15];return this.is224||(c+=oe[s>>>28&15]+oe[s>>>24&15]+oe[s>>>20&15]+oe[s>>>16&15]+oe[s>>>12&15]+oe[s>>>8&15]+oe[s>>>4&15]+oe[s&15]),c};Nn.prototype.toString=Nn.prototype.hex;Nn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,o=this.h5,a=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,n>>>24&255,n>>>16&255,n>>>8&255,n&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,s&255),c};Nn.prototype.array=Nn.prototype.digest;Nn.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 Vc=(...e)=>new Nn(!1,!0).update(e.join("")).hex();var SA=P({sha256:()=>Vc});function kA(e){let t=Symbol.for(e);return{brand(r,n){let i=n?Symbol.for(`${e}.${n}`):t;class o extends r{[i]=!0;constructor(...s){super(...s)}static isInstance(s){return typeof s=="object"&&s!==null&&i in s&&s[i]===!0}}return Object.defineProperty(o,"name",{value:r.name}),o},sub(r){return kA(`${e}.${r}`)},isInstance(r){return typeof r=="object"&&r!==null&&t in r&&r[t]===!0}}}var EA=kA("langchain");var $A=P({ContextOverflowError:()=>eb,LangChainError:()=>Qv,ModelAbortError:()=>hm,addLangChainErrorFields:()=>io,ns:()=>mm});function io(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 mm=EA.sub("error"),Qv=class extends mm.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},hm=class extends mm.brand(Qv,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},eb=class TA extends mm.brand(Qv,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let r=new TA(t.message);return r.cause=t,r}};function Or(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 Zc(e){return Or(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function Gc(e){return Or(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function AA(e){return Or(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function gm(e){return Or(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function _m(e){if(Or(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 wd(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(),n=t[1].trim();if(r===""||n==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let o of e.split(";").slice(1)){let a=o.split("=");if(a.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let s=a[0].trim(),c=a[1].trim();if(s==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[s]=c}return{type:r,subtype:n,parameters:i}}function Wo({dataUrl:e,asTypedArray:t=!1}){let r=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),n;if(r){n=r[1].toLowerCase();let i=t?Uint8Array.from(atob(r[2]),o=>o.charCodeAt(0)):r[2];return{mime_type:n,data:i}}}function Hc(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 Y(e,t){return ce(e)&&e.type===t}function ce(e){return typeof e=="object"&&e!==null}function Mt(e){return Array.isArray(e)}function D(e){return typeof e=="string"}function Gr(e){return typeof e=="number"}function ym(e){return e instanceof Uint8Array}function tb(e){try{return JSON.parse(e)}catch{return}}var Hr=e=>e();function DF(e){if(e.type==="char_location"&&D(e.document_title)&&Gr(e.start_char_index)&&Gr(e.end_char_index)&&D(e.cited_text)){let{document_title:t,start_char_index:r,end_char_index:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"char",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="page_location"&&D(e.document_title)&&Gr(e.start_page_number)&&Gr(e.end_page_number)&&D(e.cited_text)){let{document_title:t,start_page_number:r,end_page_number:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"page",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="content_block_location"&&D(e.document_title)&&Gr(e.start_block_index)&&Gr(e.end_block_index)&&D(e.cited_text)){let{document_title:t,start_block_index:r,end_block_index:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"block",title:t??void 0,startIndex:r,endIndex:n,citedText:i}}if(e.type==="web_search_result_location"&&D(e.url)&&D(e.title)&&D(e.encrypted_index)&&D(e.cited_text)){let{url:t,title:r,encrypted_index:n,cited_text:i,...o}=e;return{...o,type:"citation",source:"url",url:t,title:r,startIndex:Number(n),endIndex:Number(n),citedText:i}}if(e.type==="search_result_location"&&D(e.source)&&D(e.title)&&Gr(e.start_block_index)&&Gr(e.end_block_index)&&D(e.cited_text)){let{source:t,title:r,start_block_index:n,end_block_index:i,cited_text:o,...a}=e;return{...a,type:"citation",source:"search",url:t,title:r??void 0,startIndex:n,endIndex:i,citedText:o}}}function CA(e){if(Y(e,"document")&&ce(e.source)&&"type"in e.source){if(e.source.type==="base64"&&D(e.source.media_type)&&D(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&D(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&D(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&D(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(Y(e,"image")&&ce(e.source)&&"type"in e.source){if(e.source.type==="base64"&&D(e.source.media_type)&&D(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&D(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&D(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function PA(e){function*t(){for(let r of e){let n=CA(r);n?yield n:yield r}}return Array.from(t())}function OA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Y(n,"text")&&D(n.text)){let{text:i,citations:o,...a}=n;if(Mt(o)&&o.length){let s=o.reduce((c,u)=>{let l=DF(u);return l?[...c,l]:c},[]);yield{...a,type:"text",text:i,annotations:s};continue}else{yield{...a,type:"text",text:i};continue}}else if(Y(n,"thinking")&&D(n.thinking)){let{thinking:i,signature:o,...a}=n;yield{...a,type:"reasoning",reasoning:i,signature:o};continue}else if(Y(n,"redacted_thinking")){yield{type:"non_standard",value:n};continue}else if(Y(n,"tool_use")&&D(n.name)&&D(n.id)){yield{type:"tool_call",id:n.id,name:n.name,args:n.input};continue}else if(Y(n,"input_json_delta")){if(LF(e)&&e.tool_call_chunks?.length){let i=e.tool_call_chunks[0];yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args,index:i.index};continue}}else if(Y(n,"server_tool_use")&&D(n.name)&&D(n.id)){let{name:i,id:o}=n;if(i==="web_search"){yield{id:o,type:"server_tool_call",name:"web_search",args:{query:Hr(()=>{if(typeof n.input=="string")return n.input;if(ce(n.input)&&D(n.input.query))return n.input.query;if(D(n.partial_json)){let a=tb(n.partial_json);if(a?.query)return a.query}return""})}};continue}else if(n.name==="code_execution"){yield{id:o,type:"server_tool_call",name:"code_execution",args:{code:Hr(()=>{if(typeof n.input=="string")return n.input;if(ce(n.input)&&D(n.input.code))return n.input.code;if(D(n.partial_json)){let a=tb(n.partial_json);if(a?.code)return a.code}return""})}};continue}}else if(Y(n,"web_search_tool_result")&&D(n.tool_use_id)&&Mt(n.content)){let{content:i,tool_use_id:o}=n;yield{type:"server_tool_call_result",name:"web_search",toolCallId:o,status:"success",output:{urls:i.reduce((a,s)=>Y(s,"web_search_result")?[...a,s.url]:a,[])}};continue}else if(Y(n,"code_execution_tool_result")&&D(n.tool_use_id)&&ce(n.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(Y(n,"mcp_tool_use")){yield{id:n.id,type:"server_tool_call",name:"mcp_tool_use",args:n.input};continue}else if(Y(n,"mcp_tool_result")&&D(n.tool_use_id)&&ce(n.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:n.tool_use_id,status:"success",output:n.content};continue}else if(Y(n,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:n.input};continue}else if(Y(n,"search_result")){yield{id:n.id,type:"non_standard",value:n};continue}else if(Y(n,"tool_result")){yield{id:n.id,type:"non_standard",value:n};continue}else{let i=CA(n);if(i){yield i;continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var RA={translateContent:OA,translateContentChunk:OA};function LF(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function UF(e){return Zc(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:Gc(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:gm(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function NA(e){return e.map(UF)}function MA(e){return!!(Y(e,"image_url")&&ce(e.image_url)||Y(e,"input_audio")&&ce(e.input_audio)||Y(e,"file")&&ce(e.file))}function jA(e){if(Y(e,"image_url")&&ce(e.image_url)&&D(e.image_url.url)){let t=Wo({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(Y(e,"input_audio")&&ce(e.input_audio)&&D(e.input_audio.data)&&D(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(Y(e,"file")&&ce(e.file)&&D(e.file.data)){let t=Wo({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(D(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function FF(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...vm(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 BF(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...vm(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 vm(e){let t=[];for(let r of e)MA(r)?t.push(jA(r)):t.push(r);return t}function VF(e){if(e.type==="url_citation"){let{url:t,title:r,start_index:n,end_index:i}=e;return{type:"citation",url:t,title:r,startIndex:n,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:r,index:n}=e;return{type:"citation",title:r,startIndex:n,endIndex:n,fileId:t}}return e}function zA(e){function*t(){ce(e.additional_kwargs?.reasoning)&&Mt(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((n,i)=>ce(i)&&D(i.text)?`${n}${i.text}`:n,"")});let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r)if(Y(n,"text")){let{text:i,annotations:o,...a}=n;Array.isArray(o)?yield{...a,type:"text",text:String(i),annotations:o.map(VF)}:yield{...a,type:"text",text:String(i)}}for(let n of e.tool_calls??[])yield{type:"tool_call",id:n.id,name:n.name,args:n.args};if(ce(e.additional_kwargs)&&Mt(e.additional_kwargs.tool_outputs))for(let n of e.additional_kwargs.tool_outputs){if(Y(n,"web_search_call")){let i={};if(ce(n.action)&&D(n.action.query)&&(i.query=n.action.query),yield{id:n.id,type:"server_tool_call",name:"web_search",args:i},n.status==="completed"||n.status==="failed"){let o={};ce(n.action)&&(o.action=n.action),yield{type:"server_tool_call_result",toolCallId:D(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:o}}continue}else if(Y(n,"file_search_call")){yield{id:n.id,type:"server_tool_call",name:"file_search",args:{queries:Mt(n.queries)?n.queries:[]}},(n.status==="completed"||n.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:D(n.id)?n.id:"",status:n.status==="completed"?"success":"error",output:Mt(n.results)?{results:n.results}:{}});continue}else if(Y(n,"computer_call")){yield{type:"non_standard",value:n};continue}else if(Y(n,"code_interpreter_call")){if(D(n.code)&&(yield{id:n.id,type:"server_tool_call",name:"code_interpreter",args:{code:n.code}}),Mt(n.outputs)){let i=Hr(()=>{if(n.status!=="in_progress"){if(n.status==="completed")return 0;if(n.status==="incomplete")return 127;if(n.status!=="interpreting"&&n.status==="failed")return 1}});for(let o of n.outputs)if(Y(o,"logs")){yield{type:"server_tool_call_result",toolCallId:n.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(o.logs),stdout:[0,void 0].includes(i)?String(o.logs):void 0}};continue}}continue}else if(Y(n,"mcp_call")){yield{id:n.id,type:"server_tool_call",name:"mcp_call",args:n.input};continue}else if(Y(n,"mcp_list_tools")){yield{id:n.id,type:"server_tool_call",name:"mcp_list_tools",args:n.input};continue}else if(Y(n,"mcp_approval_request")){yield{type:"non_standard",value:n};continue}else if(Y(n,"tool_search_call")){let i={};ce(n.arguments)&&Object.assign(i,n.arguments);let o={};D(n.execution)&&(o.execution=n.execution),D(n.status)&&(o.status=n.status),D(n.call_id)&&(o.call_id=n.call_id),yield{id:D(n.id)?n.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(o).length>0?{extras:o}:{}};continue}else if(Y(n,"tool_search_output")){let i={name:"tool_search"};D(n.execution)&&(i.execution=n.execution),yield{type:"server_tool_call_result",toolCallId:D(n.id)?n.id:"",status:n.status==="completed"?"success":n.status==="failed"?"error":"success",output:{tools:Mt(n.tools)?n.tools:[]},extras:i};continue}else if(Y(n,"image_generation_call")){D(n.result)&&(yield{type:"image",mimeType:"image/png",data:n.result,id:D(n.id)?n.id:void 0,metadata:{status:D(n.status)?n.status:void 0}}),yield{type:"non_standard",value:n};continue}ce(n)&&(yield{type:"non_standard",value:n})}}return Array.from(t())}function ZF(e){function*t(){yield*zA(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 DA={translateContent:e=>typeof e.content=="string"?FF(e):zA(e),translateContentChunk:e=>typeof e.content=="string"?BF(e):ZF(e)};function bm(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function LA(e,t="pretty"){return t==="pretty"?GF(e):JSON.stringify(e)}function GF(e){let t=[],r=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,n=Math.floor((80-r.length)/2),i="=".repeat(n),o=r.length%2===0?i:`${i}=`;if(t.push(`${i}${r}${o}`),e.type==="ai"){let a=e;if(a.tool_calls&&a.tool_calls.length>0){t.push("Tool Calls:");for(let s of a.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 a=e;a.name&&t.push(`Name: ${a.name}`)}return typeof e.content=="string"&&e.content.trim()&&(t.length>1&&t.push(""),t.push(e.content)),t.join(`
|
|
9
|
+
`)}var rb=Symbol.for("langchain.message");function er(e,t){return typeof e=="string"?e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(r=>Or(r))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t]:Array.isArray(t)?Jo(e,t)??[...e,...t]:t===""?e:Array.isArray(e)&&e.some(r=>Or(r))?[...e,{type:"file",source_type:"text",text:t}]:[...e,{type:"text",text:t}]}function wm(e,t){return e==="error"||t==="error"?"error":"success"}function HF(e,t){function r(n,i){if(typeof n!="object"||n===null||n===void 0)return n;if(i>=t)return Array.isArray(n)?"[Array]":"[Object]";if(Array.isArray(n))return n.map(a=>r(a,i+1));let o={};for(let a of Object.keys(n))o[a]=r(n[a],i+1);return o}return JSON.stringify(r(e,0),null,2)}var tt=class extends kt{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[rb]=!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[NA,vm,PA].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&&rb in e&&e[rb]===!0&&bm(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=HF(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return LA(this,e)}};function FA(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var nb=["index","created","timestamp"];function pt(e,t,r){let n=r?.ignoreKeys??nb;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let i={...e};for(let[o,a]of Object.entries(t))if(i[o]==null)i[o]=a;else{if(a==null)continue;if(typeof i[o]!=typeof a||Array.isArray(i[o])!==Array.isArray(a))throw new Error(`field[${o}] already exists in the message chunk, but with a different type.`);if(typeof i[o]=="string"){if(o==="type")continue;if(["id","name","output_version","model_provider"].includes(o))a&&(i[o]=a);else{if(n.includes(o))continue;i[o]+=a}}else if(typeof i[o]=="number"){if(n.includes(o))continue;i[o]=i[o]+a}else if(typeof i[o]=="object"&&!Array.isArray(i[o]))i[o]=pt(i[o],a,r);else if(Array.isArray(i[o]))i[o]=Jo(i[o],a,r);else{if(i[o]===a)continue;console.warn(`field[${o}] already exists in this message chunk and value has unsupported type.`)}}return i}function qF(e){return typeof e=="number"||typeof e=="string"}function UA(e){return typeof e!="object"||e===null||!("index"in e)?!1:qF(e.index)}function Jo(e,t,r){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let n=[...e];for(let i of t)if(UA(i)){let o=n.findIndex(a=>{if(!UA(a))return!1;let s=a.index===i.index,c=a.id!=null&&a.id!=="",u=i.id!=null&&i.id!=="",l=c&&u&&a.id===i.id;return s&&(l||!c||!u)});o!==-1&&typeof n[o]=="object"&&n[o]!==null?n[o]=pt(n[o],i,r):n.push(i)}else{if(typeof i=="object"&&i!==null&&"text"in i&&i.text==="")continue;n.push(i)}return n}}}function xm(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 Jo(e,t,r);if(typeof e=="object"&&typeof t=="object")return pt(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 fr=class BA extends tt{static isInstance(t){if(!super.isInstance(t))return!1;let r=Object.getPrototypeOf(t);for(;r!==null;){if(r===BA.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}};function Im(e){return typeof e.role=="string"}function ft(e){return typeof e?._getType=="function"}function oo(e){return fr.isInstance(e)}var VA=P({ToolMessage:()=>jt,ToolMessageChunk:()=>Xo,defaultToolCallParser:()=>Id,isDirectToolOutput:()=>xd,isToolMessage:()=>as,isToolMessageChunk:()=>ib});function xd(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var jt=class extends tt{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 n=typeof e=="string"||Array.isArray(e)?{content:e,name:r,tool_call_id:t}:e;super(n),this.tool_call_id=n.tool_call_id,this.artifact=n.artifact,this.status=n.status,this.metadata=n.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}}},Xo=class extends fr{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:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:pt(this.response_metadata,e.response_metadata),artifact:xm(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:wm(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function Id(e){let t=[],r=[];for(let n of e)if(n.function){let i=n.function.name;try{let o=JSON.parse(n.function.arguments);t.push({name:i||"",args:o||{},id:n.id})}catch{r.push({name:i,args:n.function.arguments,id:n.id,error:"Malformed args."})}}else continue;return[t,r]}function as(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function ib(e){return e._getType()==="tool"}function Yo(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function ZA(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 qc=class extends Error{output;constructor(e,t){super(e),this.output=t}};function ss(e,t=mi){e=e.trim();let r=e.indexOf("```");if(r===-1)return t(e);let n=e.substring(r+3);n.startsWith(`json
|
|
14
|
+
`)?n=n.substring(5):n.startsWith("json")?n=n.substring(4):n.startsWith(`
|
|
15
|
+
`)&&(n=n.substring(1));let i=n.indexOf("```"),o=n;return i!==-1&&(o=n.substring(0,i)),t(o.trim())}function KF(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 n(){for(;r<t.length&&/\s/.test(t[r]);)r+=1}function i(){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 o(){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 a(){if(n(),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 i();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 o();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,n(),r>=t.length)return l;if(t[r]==="]")return r+=1,l;for(;r<t.length;){if(n(),r>=t.length||(l.push(a()),n(),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,n(),r>=t.length)return l;if(t[r]==="}")return r+=1,l;for(;r<t.length;){if(n(),r>=t.length)return l;let d=i();if(n(),r>=t.length)return l;if(t[r]!==":")throw new Error(`Expected ':' at position ${r}, got '${t[r]}'`);if(r+=1,n(),r>=t.length||(l[d]=a(),n(),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=a();if(n(),r<t.length)throw new Error(`Unexpected character '${t[r]}' at position ${r}`);return u}function mi(e){try{return typeof e>"u"?null:KF(e)}catch{return null}}function ob(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 WF(e){if(ce(e.document)&&ce(e.document.source)){let t=ob(ce(e.document)&&D(e.document.format)?e.document.format:"");if(ce(e.document.source)){if(ce(e.document.source.s3Location)&&D(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(ym(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(D(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(Mt(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((r,n)=>ce(n)&&D(n.text)?r+n.text:r,"")}}}return{type:"non_standard",value:e}}function JF(e){if(Y(e,"image")&&ce(e.image)){let t=ob(ce(e.image)&&D(e.image.format)?e.image.format:"");if(ce(e.image.source)){if(ce(e.image.source.s3Location)&&D(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(ym(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function XF(e){if(Y(e,"video")&&ce(e.video)){let t=ob(ce(e.video)&&D(e.video.format)?e.video.format:"");if(ce(e.video.source)){if(ce(e.video.source.s3Location)&&D(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(ym(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function GA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Y(n,"cache_point")){yield{type:"non_standard",value:n};continue}else if(Y(n,"citations_content")&&ce(n.citationsContent)){yield{type:"text",text:Mt(n.citationsContent.content)?n.citationsContent.content.reduce((i,o)=>ce(o)&&D(o.text)?i+o.text:i,""):"",annotations:Mt(n.citationsContent.citations)?n.citationsContent.citations.reduce((i,o)=>{if(ce(o)){let a=Mt(o.sourceContent)?o.sourceContent.reduce((c,u)=>ce(u)&&D(u.text)?c+u.text:c,""):"",s=Hr(()=>{if(ce(o.location)){let c=o.location.documentChar||o.location.documentPage||o.location.documentChunk;if(ce(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{}});i.push({type:"citation",citedText:a,...s})}return i},[]):[]};continue}else if(Y(n,"document")&&ce(n.document)){yield WF(n);continue}else if(Y(n,"guard_content")){yield{type:"non_standard",value:n};continue}else if(Y(n,"image")&&ce(n.image)){yield JF(n);continue}else if(Y(n,"reasoning_content")&&D(n.reasoningText)){yield{type:"reasoning",reasoning:n.reasoningText};continue}else if(Y(n,"text")&&D(n.text)){yield{type:"text",text:n.text};continue}else if(Y(n,"tool_result")){yield{type:"non_standard",value:n};continue}else{if(Y(n,"tool_call"))continue;if(Y(n,"video")&&ce(n.video)){yield XF(n);continue}}yield{type:"non_standard",value:n}}}return Array.from(t())}var HA={translateContent:GA,translateContentChunk:GA};function qA(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(D(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 n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&D(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var KA={translateContent:qA,translateContentChunk:qA};function WA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Y(n,"text")&&D(n.text)){yield{type:"text",text:n.text};continue}else if(Y(n,"thinking")&&D(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(Y(n,"inlineData")&&ce(n.inlineData)&&D(n.inlineData.mimeType)&&D(n.inlineData.data)){yield{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data};continue}else if(Y(n,"functionCall")&&ce(n.functionCall)&&D(n.functionCall.name)&&ce(n.functionCall.args)){yield{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args};continue}else if(Y(n,"functionResponse")){yield{type:"non_standard",value:n};continue}else if(Y(n,"fileData")&&ce(n.fileData)&&D(n.fileData.mimeType)&&D(n.fileData.fileUri)){yield{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri};continue}else if(Y(n,"executableCode")){yield{type:"non_standard",value:n};continue}else if(Y(n,"codeExecutionResult")){yield{type:"non_standard",value:n};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var JA={translateContent:WA,translateContentChunk:WA};function XA(e){function*t(){let r=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let n of r){if(Y(n,"reasoning")&&D(n.reasoning)){let i=Hr(()=>{let o=r.indexOf(n);if(Mt(e.additional_kwargs?.signatures)&&o>=0)return e.additional_kwargs.signatures.at(o)});D(i)?yield{type:"reasoning",reasoning:n.reasoning,signature:i}:yield{type:"reasoning",reasoning:n.reasoning};continue}else if(Y(n,"thinking")&&D(n.thinking)){yield{type:"reasoning",reasoning:n.thinking,...n.signature?{signature:n.signature}:{}};continue}else if(Y(n,"text")&&D(n.text)){yield{type:"text",text:n.text};continue}else if(Y(n,"image_url")){if(D(n.image_url))if(n.image_url.startsWith("data:")){let i=n.image_url.match(/^data:([^;]+);base64,(.+)$/);i?yield{type:"image",data:i[2],mimeType:i[1]}:yield{type:"image",url:n.image_url}}else yield{type:"image",url:n.image_url};continue}else if(Y(n,"media")&&D(n.mimeType)&&D(n.data)){yield{type:"file",mimeType:n.mimeType,data:n.data};continue}yield{type:"non_standard",value:n}}}return Array.from(t())}var YA={translateContent:XA,translateContentChunk:XA};function QA(e){let t=[],r=e.additional_kwargs?.reasoning;if(D(r)&&r.length>0&&t.push({type:"reasoning",reasoning:r}),typeof e.content=="string"){let n=e.content,i=n.match(/<think>([\s\S]*?)<\/think>/);if(i){let o=i[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})}else for(let n of e.content)if(typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&D(n.text)){let i=n.text,o=i.match(/<think>([\s\S]*?)<\/think>/);if(o){let a=o[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})}for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var eO={translateContent:QA,translateContentChunk:QA};function tO(e){let t=[],r=e.additional_kwargs?.reasoning_content;if(D(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 n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&D(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var rO={translateContent:tO,translateContentChunk:tO};function nO(e){let t=[];if(ce(e.additional_kwargs?.reasoning)){let n=e.additional_kwargs.reasoning;if(Mt(n.summary)){let i=n.summary.reduce((o,a)=>ce(a)&&D(a.text)?`${o}${a.text}`:o,"");i.length>0&&t.push({type:"reasoning",reasoning:i})}}let r=e.additional_kwargs?.reasoning_content;if(D(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 n of e.content)typeof n=="object"&&"type"in n&&n.type==="text"&&"text"in n&&D(n.text)&&t.push({type:"text",text:n.text});for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}var iO={translateContent:nO,translateContentChunk:nO};function oO(e){function*t(){let r=Hr(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let n=e.additional_kwargs?.originalTextContentBlock;if(n?.thoughtSignature&&!e.content.some(i=>"thoughtSignature"in i)){let i=[...e.content];for(let o=i.length-1;o>=0;o--){let a=i[o];if(a.type==="text"&&!a.thought)return a.thoughtSignature=n.thoughtSignature,i}}return e.content}});for(let n of r){let i=Hr(()=>Y(n,"text")&&D(n.text)?{type:"text",text:n.text}:Y(n,"inlineData")&&ce(n.inlineData)&&D(n.inlineData.mimeType)&&D(n.inlineData.data)?{type:"file",mimeType:n.inlineData.mimeType,data:n.inlineData.data}:Y(n,"functionCall")&&ce(n.functionCall)&&D(n.functionCall.name)&&ce(n.functionCall.args)?{type:"tool_call",id:e.id,name:n.functionCall.name,args:n.functionCall.args}:Y(n,"functionResponse")?{type:"non_standard",value:n}:Y(n,"fileData")&&ce(n.fileData)&&D(n.fileData.mimeType)&&D(n.fileData.fileUri)?{type:"file",mimeType:n.fileData.mimeType,fileId:n.fileData.fileUri}:Y(n,"executableCode")?{type:"non_standard",value:n}:Y(n,"codeExecutionResult")?{type:"non_standard",value:n}:{type:"non_standard",value:n}),o=Hr(()=>"thought"in n&&n.thought?{type:"reasoning",reasoning:i.type==="text"?i.text:"",reasoningContentBlock:i}:i),a={thought:n.thought,thoughtSignature:n.thoughtSignature,partMetadata:n.partMetadata,...o};for(let s in a)a[s]===void 0&&delete a[s];yield a}}return Array.from(t())}var aO={translateContent:oO,translateContentChunk:oO};globalThis.lc_block_translators_registry??=new Map([["anthropic",RA],["bedrock-converse",HA],["deepseek",KA],["google",aO],["google-genai",JA],["google-vertexai",YA],["groq",eO],["ollama",rO],["openai",DA],["xai",iO]]);function ab(e){return globalThis.lc_block_translators_registry.get(e)}function Sm(e,t){return pt(e,t)??{}}function sO(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 YF(e,t){let r={...sO(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 QF(e,t){let r={...sO(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(r.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),r}function Kc(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:YF(e?.input_token_details,t?.input_token_details),output_token_details:QF(e?.output_token_details,t?.output_token_details)}}var be=class extends tt{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,n=t.tool_calls;r!=null&&r.length>0&&(n===void 0||n.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&&n===void 0){let[i,o]=Id(r);t.tool_calls=i??[],t.invalid_tool_calls=o??[]}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(o=>({type:"tool_call",id:o.id,name:o.name,args:o.args})));let i=t.contentBlocks.filter(o=>o.type==="tool_call").filter(o=>!t.tool_calls?.some(a=>a.id===o.id&&a.name===o.name));i.length>0&&(t.tool_calls=i.map(o=>({type:"tool_call",id:o.id,name:o.name,args:o.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=ab(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(n=>n.id===r.id&&n.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 hi(e){return e._getType()==="ai"}function Sd(e){return e._getType()==="ai"}var at=class extends fr{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=km(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=ab(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:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:Sm(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 n=Jo(this.tool_call_chunks,e.tool_call_chunks);n!==void 0&&n.length>0&&(t.tool_call_chunks=n)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let n=Jo(this.tool_calls,e.tool_calls);n!==void 0&&n.length>0&&(t.tool_calls=n)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=Kc(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 mr=class cO extends tt{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return cO}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}}},ao=class extends fr{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:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:pt(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 uO(e){return e._getType()==="generic"}function lO(e){return e._getType()==="generic"}var cs=class extends tt{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},so=class extends fr{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:pt(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function dO(e){return e._getType()==="function"}function pO(e){return e._getType()==="function"}var st=class extends tt{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},co=class extends fr{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:pt(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function fO(e){return e.getType()==="human"}function mO(e){return e.getType()==="human"}var Mn=class extends tt{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 hr=class Em extends tt{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Em({...this,content:er(this.content,t)});if(Em.isInstance(t))return new Em({...this,additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},content:er(this.content,t.content)});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},fn=class extends fr{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:er(this.content,e.content),additional_kwargs:pt(this.additional_kwargs,e.additional_kwargs),response_metadata:pt(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function hO(e){return e._getType()==="system"}function gO(e){return e._getType()==="system"}var $m=e=>e();function eB(e){return Yo(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 tB(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function sb(e){let t,r;if(tB(e)){let n=e.id.at(-1);n==="HumanMessage"||n==="HumanMessageChunk"?t="user":n==="AIMessage"||n==="AIMessageChunk"?t="assistant":n==="SystemMessage"||n==="SystemMessageChunk"?t="system":n==="FunctionMessage"||n==="FunctionMessageChunk"?t="function":n==="ToolMessage"||n==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:n,...i}=e;t=n,r=i}if(t==="human"||t==="user")return new st(r);if(t==="ai"||t==="assistant"){let{tool_calls:n,...i}=r;if(!Array.isArray(n))return new be(r);let o=n.map(eB);return new be({...i,tool_calls:o})}else{if(t==="system")return new hr(r);if(t==="developer")return new hr({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new jt({...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 Mn({...r,id:r.id});throw io(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 tr(e){if(typeof e=="string")return new st(e);if(ft(e))return e;if(Array.isArray(e)){let[t,r]=e;return sb({type:t,content:r})}else if(Im(e)){let{role:t,...r}=e;return sb({...r,type:t})}else return sb(e)}function rB(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 Wc(e,t="Human",r="AI"){let n=[];for(let i of e){let o;if(i.type==="human")o=t;else if(i.type==="ai")o=r;else if(i.type==="system")o="System";else if(i.type==="tool")o="Tool";else if(i.type==="generic")o=i.role;else throw new Error(`Got unsupported message type: ${i.type}`);let a=i.name?`${i.name}, `:"",s=typeof i.content=="string"?i.content:Array.isArray(i.content)?i.content.map(rB).filter(Boolean).join(""):"",c=`${o}: ${a}${s}`;if(i.type==="ai"){let u=i;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))}n.push(c)}return n.join(`
|
|
21
|
+
`)}function nB(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 kd(e){let t=nB(e);switch(t.type){case"human":return new st(t.data);case"ai":return new be(t.data);case"system":return new hr(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new cs(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 jt(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new mr(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function _O(e){return e.map(kd)}function yO(e){return e.map(t=>t.toDict())}function us(e){let t=e._getType();if(t==="human")return new co({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(n=>({...n,type:"tool_call_chunk",index:void 0,args:JSON.stringify(n.args)}))}),new at({...r})}else{if(t==="system")return new fn({...e});if(t==="function")return new so({...e});if(mr.isInstance(e))return new ao({...e});throw new Error("Unknown message type.")}}function km(e){let t=e.reduce((i,o)=>{let a=i.findIndex(([s])=>"id"in o&&o.id&&"index"in o&&o.index!==void 0?o.id===s.id&&o.index===s.index:"id"in o&&o.id?o.id===s.id:"index"in o&&o.index!==void 0?o.index===s.index:!1);return a!==-1?i[a].push(o):i.push([o]),i},[]),r=[],n=[];for(let i of t){let o=null,a=i[0]?.name??"",s=i.map(l=>l.args||"").join("").trim(),c=s.length?s:"{}",u=i[0]?.id;try{if(o=mi(c),!u||o===null||typeof o!="object"||Array.isArray(o))throw new Error("Malformed tool call chunk args.");r.push({name:a,args:o,id:u,type:"tool_call"})}catch{n.push({name:a,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:n}}var vO=P({BaseCache:()=>wO,InMemoryCache:()=>cb,defaultHashKeyEncoder:()=>bO,deserializeStoredGeneration:()=>iB,serializeGeneration:()=>oB}),bO=(...e)=>Vc(e.join("_"));function iB(e){return e.message!==void 0?{text:e.text,message:kd(e.message)}:{text:e.text}}function oB(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var wO=class{keyEncoder=bO;makeDefaultKeyEncoder(e){this.keyEncoder=e}},aB=new Map,cb=class xO extends wO{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,n){this.cache.set(this.keyEncoder(t,r),n)}static global(){return new xO(aB)}};var IO=/^(?:[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 sB(e){return typeof e=="string"&&IO.test(e)}var Qo=sB;function cB(e){if(!Qo(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 ub=cB;var Wt=[];for(let e=0;e<256;++e)Wt.push((e+256).toString(16).slice(1));function Jc(e,t=0){return(Wt[e[t+0]]+Wt[e[t+1]]+Wt[e[t+2]]+Wt[e[t+3]]+"-"+Wt[e[t+4]]+Wt[e[t+5]]+"-"+Wt[e[t+6]]+Wt[e[t+7]]+"-"+Wt[e[t+8]]+Wt[e[t+9]]+"-"+Wt[e[t+10]]+Wt[e[t+11]]+Wt[e[t+12]]+Wt[e[t+13]]+Wt[e[t+14]]+Wt[e[t+15]]).toLowerCase()}var lb,uB=new Uint8Array(16);function Xc(){if(!lb){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");lb=crypto.getRandomValues.bind(crypto)}return lb(uB)}function lB(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 SO="6ba7b810-9dad-11d1-80b4-00c04fd430c8",kO="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function db(e,t,r,n,i,o){let a=typeof r=="string"?lB(r):r,s=typeof n=="string"?ub(n):n;if(typeof n=="string"&&(n=ub(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){o=o||0;for(let u=0;u<16;++u)i[o+u]=c[u];return i}return Jc(c)}var dB=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pb={randomUUID:dB};function pB(e,t,r){if(pb.randomUUID&&!t&&!e)return pb.randomUUID();e=e||{};let n=e.random??e.rng?.()??Xc();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[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 i=0;i<16;++i)t[r+i]=n[i];return t}return Jc(n)}var fb=pB;function fB(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function mb(e,t){return e<<t|e>>>32-t}function mB(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let i=e.length/4+2,o=Math.ceil(i/16),a=new Array(o);for(let s=0;s<o;++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];a[s]=c}a[o-1][14]=(e.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<o;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[s][m];for(let m=16;m<80;++m)c[m]=mb(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 h=Math.floor(m/20),w=mb(u,5)+fB(h,l,d,f)+p+t[h]+c[m]>>>0;p=f,f=d,d=mb(l,30)>>>0,l=u,u=w}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 EO=mB;function hb(e,t,r,n){return db(80,EO,e,t,r,n)}hb.DNS=SO;hb.URL=kO;var Tm=hb;var gb={};function hB(e,t,r){let n;if(e)n=$O(e.random??e.rng?.()??Xc(),e.msecs,e.seq,t,r);else{let i=Date.now(),o=Xc();gB(gb,i,o),n=$O(o,gb.msecs,gb.seq,t,r)}return t??Jc(n)}function gB(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 $O(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=t&255,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|e[10]&3,n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}var mn=hB;var TO=P({BaseCallbackHandler:()=>jn,callbackHandlerPrefersStreaming:()=>Ed,isBaseCallbackHandler:()=>_b}),yB=class{};function Ed(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}var jn=class extends yB{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,Bc(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=et("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 kt.prototype.toJSON.call(this)}toJSONNotImplemented(){return kt.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends jn{name=mn();constructor(){super(),Object.assign(this,e)}}return new t}},_b=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var AO="gen_ai.operation.name",OO="gen_ai.system",yb="gen_ai.request.model",CO="gen_ai.response.model",vb="gen_ai.usage.input_tokens",bb="gen_ai.usage.output_tokens",wb="gen_ai.usage.total_tokens",PO="gen_ai.request.max_tokens",RO="gen_ai.request.temperature",NO="gen_ai.request.top_p",MO="gen_ai.request.frequency_penalty",jO="gen_ai.request.presence_penalty",zO="gen_ai.response.finish_reasons",DO="gen_ai.prompt",LO="gen_ai.completion",UO="gen_ai.request.extra_query",FO="gen_ai.request.extra_body",BO="gen_ai.serialized.name",VO="gen_ai.serialized.signature",ZO="gen_ai.serialized.doc",GO="gen_ai.response.id",HO="gen_ai.response.service_tier",qO="gen_ai.response.system_fingerprint",KO="gen_ai.usage.input_token_details",WO="gen_ai.usage.output_token_details",JO="langsmith.trace.session_id",XO="langsmith.trace.session_name",YO="langsmith.span.kind",QO="langsmith.trace.name",eC="langsmith.metadata",xb="langsmith.span.tags";var tC="langsmith.request.streaming",rC="langsmith.request.headers";var bB=(...e)=>fetch(...e),wB,nC=Symbol.for("ls:fetch_implementation");var iC=()=>globalThis[nC]===void 0?!0:wB??!1,oC=e=>async(...t)=>{if(e||gt("DEBUG")==="true"){let[n,i]=t;console.log(`\u2192 ${i?.method||"GET"} ${n}`)}let r=await(globalThis[nC]??bB)(...t);return(e||gt("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var $d=()=>gt("PROJECT")??qr("LANGCHAIN_SESSION")??"default";var aC={};function ls(e){aC[e]||(console.warn(e),aC[e]=!0)}var L=e=>BigInt(e),lC=L("0x9E3779B1"),dC=L("0x85EBCA77"),xB=L("0xC2B2AE3D"),ea=L("0x9E3779B185EBCA87"),ds=L("0xC2B2AE3D27D4EB4F"),pC=L("0x165667B19E3779F9"),Eb=L("0x85EBCA77C2B2AE63"),IB=L("0x27D4EB2F165667C5"),SB=L("0x165667919E3779F9"),kB=L("0x9FB21C651E98DF25");function EB(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 gi=EB("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Qc=(L(1)<<L(128))-L(1),Ae=(L(1)<<L(64))-L(1),Pm=(L(1)<<L(32))-L(1),uo=64,fC=uo/8,$B=8,Am=4;function rt(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function ct(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Yc(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function Ib(e,t=0){return e[t]}var TB=e=>(e&L(255))<<L(56)|(e&L(65280))<<L(40)|(e&L(16711680))<<L(24)|(e&L(4278190080))<<L(8)|(e&L(0xff00000000))>>L(8)|(e&L(0xff0000000000))>>L(24)|(e&L(0xff000000000000))>>L(40)|(e&L(0xff00000000000000))>>L(56),AB=e=>(e=(e&L(65535))<<L(16)|(e&L(4294901760))>>L(16),e=(e&L(16711935))<<L(8)|(e&L(4278255360))>>L(8),e),OB=(e,t)=>(e&Pm)*(t&Pm)&Ae,eu=e=>{if(!e)throw new Error("Assert failed")};function CB(e,t){return(e<<t|e>>L(32)-t)&Pm}function mC(e,t,r){for(let n=0;n<fC;n++){let i=ct(t,n*8),o=i^ct(r,n*8);e[n^1]+=i,e[n]+=OB(o,o>>L(32))}return e}function sC(e,t,r,n){for(let i=0;i<n;i++)mC(e,rt(t,i*uo),rt(r,i*8));return e}function PB(e,t){for(let r=0;r<fC;r++){let n=ct(t,r*8),i=e[r];i=Sb(i,L(47)),i^=n,i*=lC,e[r]=i&Ae}return e}function Om(e,t){return hC(e[0]^ct(t,0),e[1]^ct(t,$B))}function cC(e,t,r){let n=r;return n+=Om(e.slice(0),rt(t,0*Am)),n+=Om(e.slice(2),rt(t,4*Am)),n+=Om(e.slice(4),rt(t,8*Am)),n+=Om(e.slice(6),rt(t,12*Am)),_i(n&Ae)}function RB(e,t,r,n,i){let o=Math.floor((r.byteLength-uo)/8),a=uo*o,s=Math.floor((t.byteLength-1)/a);for(let c=0;c<s;c++)e=sC(e,rt(t,c*a),r,o),e=i(e,rt(r,r.byteLength-uo));{let c=Math.floor((t.byteLength-1-a*s)/uo);e=sC(e,rt(t,s*a),r,c),e=n(e,rt(t,t.byteLength-uo),rt(r,r.byteLength-uo-7))}return e}function NB(e,t,r){let n=new BigUint64Array([xB,ea,ds,pC,Eb,dC,IB,lC]);eu(e.length>128),n=RB(n,e,t,mC,PB),eu(n.length*8==64);{let i=cC(n,rt(t,11),L(e.byteLength)*ea&Ae);return cC(n,rt(t,t.byteLength-uo-11),~(L(e.byteLength)*ds)&Ae)<<L(64)|i}}function hC(e,t){let r=e*t&Qc;return r&Ae^r>>L(64)}function uC(e,t,r){return hC((ct(e,0)^ct(t,0)+r)&Ae,(ct(e,8)^ct(t,8)-r)&Ae)}function Cm(e,t,r,n,i){let o=e&Ae,a=e>>L(64)&Ae;return o+=uC(t,n,i),o^=ct(r,0)+ct(r,8),o&=Ae,a+=uC(r,rt(n,16),i),a^=ct(t,0)+ct(t,8),a&=Ae,a<<L(64)|o}function _i(e){return e^=e>>L(37),e*=SB,e&=Ae,e^=e>>L(32),e}function Rm(e){return e^=e>>L(33),e*=ds,e&=Ae,e^=e>>L(29),e*=pC,e&=Ae,e^=e>>L(32),e}function MB(e,t,r){let n=e.byteLength;eu(n>0&&n<=3);let i=L(Ib(e,n-1))|L(n<<8)|L(Ib(e,0)<<16)|L(Ib(e,n>>1)<<24),o=(L(Yc(t,0))^L(Yc(t,4)))+r,a=(i^o)&Ae,s=(L(Yc(t,8))^L(Yc(t,12)))-r,c=(CB(AB(i),L(13))^s)&Ae;return(Rm(c)&Ae)<<L(64)|Rm(a)}function Sb(e,t){return e^e>>t}function jB(e,t,r){let n=e.byteLength;eu(n>=4&&n<=8);{let i=Yc(e,0),o=Yc(e,n-4),a=L(i)|L(o)<<L(32),s=(ct(t,16)^ct(t,24))+r&Ae,u=(a^s)*(ea+(L(n)<<L(2)))&Qc;return u+=(u&Ae)<<L(65),u&=Qc,u^=u>>L(67),Sb(Sb(u&Ae,L(35))*kB&Ae,L(28))|_i(u>>L(64))<<L(64)}}function zB(e,t,r){let n=e.byteLength;eu(n>=9&&n<=16);{let i=(ct(t,32)^ct(t,40))+r&Ae,o=(ct(t,48)^ct(t,56))-r&Ae,a=ct(e),s=ct(e,n-8),c=(a^s^i)*ea,u=(c&Ae)+(L(n-1)<<L(54));c=c&(Qc^Ae)|u,s^=o,c+=s+(s&Pm)*(dC-L(1))<<L(64),c&=Qc,c^=TB(c>>L(64));let l=(c&Ae)*ds;return l+=(c>>L(64))*ds<<L(64),l&=Qc,_i(l&Ae)|_i(l>>L(64))<<L(64)}}function DB(e,t){let r=e.byteLength;return eu(r<=16),r>8?zB(e,gi,t):r>=4?jB(e,gi,t):r>0?MB(e,gi,t):Rm(t^ct(gi,64)^ct(gi,72))|Rm(t^ct(gi,80)^ct(gi,88))<<L(64)}function kb(e){return~e+L(1)&Ae}function LB(e,t,r){let n=L(e.byteLength)*ea&Ae,i=L(e.byteLength-1)/L(32);for(;i>=0;){let s=Number(i);n=Cm(n,rt(e,16*s),rt(e,e.byteLength-16*(s+1)),rt(t,32*s),r),i--}let o=n+(n>>L(64))&Ae;o=_i(o);let a=(n&Ae)*ea+(n>>L(64))*Eb+(L(e.byteLength)-r&Ae)*ds;return a&=Ae,a=kb(_i(a)),o|a<<L(64)}function UB(e,t,r){let n=L(e.byteLength)*ea&Ae;for(let a=32;a<160;a+=32)n=Cm(n,rt(e,a-32),rt(e,a-16),rt(t,a-32),r);n=_i(n&Ae)|_i(n>>L(64))<<L(64);for(let a=160;a<=e.byteLength;a+=32)n=Cm(n,rt(e,a-32),rt(e,a-16),rt(t,3+a-160),r);n=Cm(n,rt(e,e.byteLength-16),rt(e,e.byteLength-32),rt(t,103),kb(r));let i=n+(n>>L(64))&Ae;i=_i(i);let o=(n&Ae)*ea+(n>>L(64))*Eb+(L(e.byteLength)-r&Ae)*ds;return o&=Ae,o=kb(_i(o)),i|o<<L(64)}function gC(e,t=L(0)){let r=e.byteLength;return r<=16?DB(e,t):r<=128?LB(e,gi,t):r<=240?UB(e,gi,t):NB(e,gi,t)}function _C(e){let t=new Uint8Array(16),r=new DataView(t.buffer),n=e&Ae,i=e>>L(64);return r.setBigUint64(0,i,!1),r.setBigUint64(8,n,!1),t}var yC=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Se(e,t){if(!yC.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Nm(e){let t=typeof e=="string"?Date.parse(e):e;return yd({msecs:t,seq:0})}function FB(e){if(!yC.test(e))return null;let t=e[14];return parseInt(t,16)}function BB(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let n=0;n<16;n++)r[n]=parseInt(t.slice(n*2,n*2+2),16);return r}function VB(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 ZB=new TextEncoder;function GB(e){let t=ZB.encode(e),r=gC(t);return _C(r)}function Td(e,t){let r=`${e}:${t}`,n=GB(r),i=new Uint8Array(16);if(FB(e)===7){let a=BB(e);i.set(a.slice(0,6),0)}else{let a=Date.now();i[0]=a/1099511627776&255,i[1]=a/4294967296&255,i[2]=a/16777216&255,i[3]=a/65536&255,i[4]=a/256&255,i[5]=a&255}return i[6]=112|n[0]&15,i[7]=n[1],i[8]=128|n[2]&63,i.set(n.slice(3,10),9),VB(i)}var Ad={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function vC(e){}async function bC(e,t){}async function wC(e){return[]}async function xC(e){return{size:0}}function Mm(e){return!1}function IC(e){return""}function qB(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var jm=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 n=this.cache.get(t);if(!n){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...n,refreshFunc:r}),this._metrics.hits+=1,n.value}set(t,r,n){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let o=this.cache.keys().next().value;o!==void 0&&this.cache.delete(o)}let i={value:r,createdAt:Date.now(),refreshFunc:n};this.cache.delete(t),this.cache.set(t,i)}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[o,a]of this.cache.entries())r[o]=a.value;let n=Ad.dirname(t);Mm(n)||void 0;let i=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(o){throw Mm(i)&&void 0,o}}load(t){if(!Mm(t))return 0;let r;try{let o=IC(t);r=JSON.parse(o).entries??null}catch{return 0}if(!r)return 0;let n=0,i=Date.now();for(let[o,a]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:a,createdAt:i};this.cache.set(o,s),n+=1}return n}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,n]of this.cache.entries())qB(n,this.ttlSeconds)&&t.push([r,n]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,n]of t)if(n.refreshFunc!==void 0)try{let i=await n.refreshFunc();this.set(r,i,n.refreshFunc),this._metrics.refreshes+=1}catch(i){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,i)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},zm=new jm;var Dm="0.5.12";var vi,KB=()=>typeof window<"u"&&typeof window.document<"u",WB=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",JB=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),SC=()=>typeof Deno<"u",XB=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!SC(),Ab=()=>vi||(typeof Bun<"u"?vi="bun":KB()?vi="browser":XB()?vi="node":WB()?vi="webworker":JB()?vi="jsdom":SC()?vi="deno":vi="other",vi),$b;function Lm(){if($b===void 0){let e=Ab(),t=QB();$b={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Dm,...t}}return $b}function Ob(){let e=YB(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[n,i]of Object.entries(e))typeof i=="string"&&!r.includes(n)&&!n.toLowerCase().includes("key")&&!n.toLowerCase().includes("secret")&&!n.toLowerCase().includes("token")&&(n==="LANGCHAIN_REVISION_ID"?t.revision_id=i:t[n]=i);return t}function YB(){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 qr(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function gt(e){return qr(`LANGSMITH_${e}`)||qr(`LANGCHAIN_${e}`)}var Tb;function QB(){if(Tb!==void 0)return Tb;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 n=qr(r);n!==void 0&&(t[r]=n)}return Tb=t,t}function Um(){return qr("OTEL_ENABLED")==="true"||gt("OTEL_ENABLED")==="true"}var Rb=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&Um()&&(console.warn('You have enabled OTEL export via the `OTEL_ENABLED` or `LANGSMITH_OTEL_ENABLED` environment variable, but have not initialized the required OTEL instances. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let n;if(r.length===1&&typeof r[0]=="function"?n=r[0]:r.length===2&&typeof r[1]=="function"?n=r[1]:r.length===3&&typeof r[2]=="function"&&(n=r[2]),typeof n=="function")return n()}},Nb=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new Rb})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},Mb=class{active(){return{}}with(t,r){return r()}},Cb=Symbol.for("ls:otel_trace"),Pb=Symbol.for("ls:otel_context"),kC=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),e3=new Nb,t3=new Mb,jb=class{getTraceInstance(){return globalThis[Cb]??e3}getContextInstance(){return globalThis[Pb]??t3}initializeGlobalInstances(t){globalThis[Cb]===void 0&&(globalThis[Cb]=t.trace),globalThis[Pb]===void 0&&(globalThis[Pb]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[kC]=t}getDefaultOTLPTracerComponents(){return globalThis[kC]??void 0}},zb=new jb;function Fm(){return zb.getTraceInstance()}function EC(){return zb.getContextInstance()}function $C(){return zb.getDefaultOTLPTracerComponents()}var r3={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function n3(e){return r3[e]||e}var Bm=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let n of t)try{if(!n.run)continue;if(n.operation==="post"){let i=this.createSpanForRun(n,n.run,r.get(n.id));i&&!n.run.end_time&&this.spans.set(n.id,i)}else this.updateSpanForRun(n,n.run)}catch(i){console.error(`Error processing operation ${n.id}:`,i)}}createSpanForRun(t,r,n){let i=n&&Fm().getSpan(n);if(i)try{return this.finishSpanSetup(i,r,t)}catch(o){console.error(`Failed to create span for run ${t.id}:`,o);return}}finishSpanSetup(t,r,n){return this.setSpanAttributes(t,r,n),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 n=this.spans.get(t.id);if(!n){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(n,r,t),r.error?(n.setStatus({code:2}),n.recordException(new Error(r.error))):n.setStatus({code:1});let i=r.end_time;i&&(n.end(new Date(i)),this.spans.delete(t.id))}catch(n){console.error(`Failed to update span for run ${t.id}:`,n)}}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 n=r.invocation_params;if(n.model)return n.model;if(n.model_name)return n.model_name}}}setSpanAttributes(t,r,n){if("run_type"in r&&r.run_type){t.setAttribute(YO,r.run_type);let s=n3(r.run_type||"chain");t.setAttribute(AO,s)}"name"in r&&r.name&&t.setAttribute(QO,r.name),"session_id"in r&&r.session_id&&t.setAttribute(JO,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(XO,r.session_name),this.setGenAiSystem(t,r);let i=this.extractModelName(r);i&&t.setAttribute(yb,i),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(vb,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(bb,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(wb,r.total_tokens),this.setInvocationParameters(t,r);let o=r.extra?.metadata||{};for(let[s,c]of Object.entries(o))c!=null&&t.setAttribute(`${eC}.${s}`,String(c));let a=r.tags;if(a&&Array.isArray(a)?t.setAttribute(xb,a.join(", ")):a&&t.setAttribute(xb,String(a)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(BO,String(s.name)),s.signature&&t.setAttribute(VO,String(s.signature)),s.doc&&t.setAttribute(ZO,String(s.doc))}this.setIOAttributes(t,n)}setGenAiSystem(t,r){let n="langchain",i=this.extractModelName(r);if(i){let o=i.toLowerCase();o.includes("anthropic")||o.startsWith("claude")?n="anthropic":o.includes("bedrock")?n="aws.bedrock":o.includes("azure")&&o.includes("openai")?n="az.ai.openai":o.includes("azure")&&o.includes("inference")?n="az.ai.inference":o.includes("cohere")?n="cohere":o.includes("deepseek")?n="deepseek":o.includes("gemini")?n="gemini":o.includes("groq")?n="groq":o.includes("watson")||o.includes("ibm")?n="ibm.watsonx.ai":o.includes("mistral")?n="mistral_ai":o.includes("gpt")||o.includes("openai")?n="openai":o.includes("perplexity")||o.includes("sonar")?n="perplexity":o.includes("vertex")?n="vertex_ai":(o.includes("xai")||o.includes("grok"))&&(n="xai")}t.setAttribute(OO,n)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let n=r.extra.metadata.invocation_params;n.max_tokens!==void 0&&t.setAttribute(PO,n.max_tokens),n.temperature!==void 0&&t.setAttribute(RO,n.temperature),n.top_p!==void 0&&t.setAttribute(NO,n.top_p),n.frequency_penalty!==void 0&&t.setAttribute(MO,n.frequency_penalty),n.presence_penalty!==void 0&&t.setAttribute(jO,n.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let n=r.run.inputs;typeof n=="object"&&n!==null&&(n.model&&Array.isArray(n.messages)&&t.setAttribute(yb,n.model),n.stream!==void 0&&t.setAttribute(tC,n.stream),n.extra_headers&&t.setAttribute(rC,JSON.stringify(n.extra_headers)),n.extra_query&&t.setAttribute(UO,JSON.stringify(n.extra_query)),n.extra_body&&t.setAttribute(FO,JSON.stringify(n.extra_body))),t.setAttribute(DO,JSON.stringify(n))}catch(n){console.debug(`Failed to process inputs for run ${r.id}`,n)}if(r.run.outputs)try{let n=r.run.outputs,i=this.getUnifiedRunTokens(n);if(i&&(t.setAttribute(vb,i[0]),t.setAttribute(bb,i[1]),t.setAttribute(wb,i[0]+i[1])),n&&typeof n=="object"){if(n.model&&t.setAttribute(CO,String(n.model)),n.id&&t.setAttribute(GO,n.id),n.choices&&Array.isArray(n.choices)){let o=n.choices.map(a=>a.finish_reason).filter(a=>a).map(String);o.length>0&&t.setAttribute(zO,o.join(", "))}if(n.service_tier&&t.setAttribute(HO,n.service_tier),n.system_fingerprint&&t.setAttribute(qO,n.system_fingerprint),n.usage_metadata&&typeof n.usage_metadata=="object"){let o=n.usage_metadata;o.input_token_details&&t.setAttribute(KO,JSON.stringify(o.input_token_details)),o.output_token_details&&t.setAttribute(WO,JSON.stringify(o.output_token_details))}}t.setAttribute(LO,JSON.stringify(n))}catch(n){console.debug(`Failed to process outputs for run ${r.id}`,n)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let n=Object.keys(t);for(let a of n){let s=t[a];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 i=t.generations||[];if(!Array.isArray(i))return null;let o=Array.isArray(i[0])?i.flat():i;for(let a of o)if(typeof a=="object"&&a.message&&typeof a.message=="object"&&a.message.kwargs&&typeof a.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(a.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 i3=Object.prototype.toString,o3=e=>i3.call(e)==="[object Error]",a3=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 Db(e){if(!(e&&o3(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:n}=e;return r==="Load failed"?n===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:a3.has(r)}function s3(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 Vm(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!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 Lb=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 c3(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function TC(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function u3({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof Lb)throw o.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await i.onFailedAttempt(c),TC(n,s)<=0)throw o;let u=await i.shouldConsumeRetry(c),l=TC(n,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!Db(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;let d=c3(r,i),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(w),i.signal?.removeEventListener("abort",h),m(i.signal.reason)},w=setTimeout(()=>{i.signal?.removeEventListener("abort",h),p()},f);i.unref&&w.unref?.(),i.signal?.addEventListener("abort",h,{once:!0})}),i.signal?.throwIfAborted(),!0}async function Ub(e,t={}){if(t={...t},s3(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,Vm("factor",t.factor,{min:0,allowInfinity:!1}),Vm("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Vm("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Vm("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await u3({error:o,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Wm=qo(Km(),1),DC="default"in Wm.default?Wm.default.default:Wm.default;var y3=[408,425,429,500,502,503,504],Cd=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 DC({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...n){let i=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&i>0&&this.queueSizeBytes+i>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${i} bytes.`));i>0&&(this.queueSizeBytes+=i);let o=this.onFailedResponseHook,a=this.queue.add(()=>Ub(()=>r(...n).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(o&&await o(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!y3.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return i>0&&(a=a.finally(()=>{this.queueSizeBytes-=i})),t.signal?Promise.race([a,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):a}};function qb(e){return typeof e?._getType=="function"}function Kb(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}var m9=qo($R(),1);function uh(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 mw=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}},hw=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 gw(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}async function ae(e,t,r){let n;if(e.ok){r&&(n=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(n="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(n===void 0)try{n=await e.text()}catch{n=""}let i=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${n}`;if(e.status===404)throw new hw(i);if(e.status===409)throw new mw(i);let o=new Error(i);throw o.status=e.status,o}var TR="ERR_CONFLICTING_ENDPOINTS",ch=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:TR}),this.name="ConflictingEndpointsError"}};function AR(e){return typeof e=="object"&&e!==null&&e.code===TR}function wi(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(uh(e));let[t,r]=e.split(":"),n=r||"latest";if(t.includes("/")){let[i,o]=t.split("/",2);if(!i||!o)throw new Error(uh(e));return[i,o,n]}else{if(!t)throw new Error(uh(e));return["-",t,n]}}var OR="[...]",h9={result:"[Circular]"},dh=[],ru=[],g9=new TextEncoder;function _9(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function lh(e){return g9.encode(e)}function CR(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 y9(e){return function(t,r){if(e){let n=e.call(this,t,r);if(n!==void 0)return n}return CR(r)}}function Cr(e,t,r,n,i){try{let o=JSON.stringify(e,y9(r),n);return lh(o)}catch(o){if(!o.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
|
|
26
|
+
Context: ${t}`:""}`),lh("[Unserializable]");gt("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
|
|
27
|
+
Context: ${t}`:""}`),typeof i>"u"&&(i=_9()),yw(e,"",0,[],void 0,0,i);let a;try{ru.length===0?a=JSON.stringify(e,r,n):a=JSON.stringify(e,v9(r),n)}catch{return lh("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;dh.length!==0;){let s=dh.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return lh(a)}}function _w(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),dh.push([n,r,t,i])):ru.push([t,r,e]):(n[r]=e,dh.push([n,r,t]))}function yw(e,t,r,n,i,o,a){o+=1;var s;if(typeof e=="object"&&e!==null){for(s=0;s<n.length;s++)if(n[s]===e){_w(h9,e,t,i);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){_w(OR,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){_w(OR,e,t,i);return}if(n.push(e),Array.isArray(e))for(s=0;s<e.length;s++)yw(e[s],s,s,n,e,o,a);else{e=CR(e);var c=Object.keys(e);for(s=0;s<c.length;s++){var u=c[s];yw(e[u],u,s,n,e,o,a)}}n.pop()}}function v9(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(ru.length>0)for(var n=0;n<ru.length;n++){var i=ru[n];if(i[1]===t&&i[0]===r){r=i[2],ru.splice(n,1);break}}return e.call(this,t,r)}}function PR(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function Ld(e){return{...e,start_time:PR(e.start_time),end_time:PR(e.end_time)}}function RR(e,t,r){if(r)return e;let n=Lm(),i=t??Ob(),o=e.extra??{},a=o.metadata;return e.extra={...o,runtime:{...n,...o?.runtime},metadata:{...i,...i.revision_id||"revision_id"in e&&e.revision_id?{revision_id:("revision_id"in e?e.revision_id:void 0)??i.revision_id}:{},...a}},e}var b9=e=>{let t=e?.toString()??gt("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},w9=e=>{let r=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return r==="localhost"||r==="127.0.0.1"||r==="::1"};async function x9(e){let t=[];for await(let r of e)t.push(r);return t}function ph(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var I9=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 NR(e){return typeof e=="number"?Number(e.toFixed(4)):e}var S9=24*1024*1024,zR=1024*1024*1024,k9=1e4,E9=100,MR="https://api.smith.langchain.com",vw=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??zR}peek(){return this.items[0]}push(t){let r,n=new Promise(o=>{r=o}),i=Cr(t.item,`Serializing run with id: ${t.item.id}`).length;return this.sizeBytes+i>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: ${i} bytes.`),r(),n):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:r,itemPromise:n,size:i}),this.sizeBytes+=i,n)}pop({upToSizeBytes:t,upToSize:r}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let n=[],i=0;for(;i+(this.peek()?.size??0)<t&&this.items.length>0&&n.length<r;){let o=this.items.shift();o&&(n.push(o),i+=o.size,this.sizeBytes-=o.size)}if(n.length===0&&this.items.length>0){let o=this.items.shift();n.push(o),i+=o.size,this.sizeBytes-=o.size}return[n.map(o=>({action:o.action,item:o.payload,otelContext:o.otelContext,apiKey:o.apiKey,apiUrl:o.apiUrl,size:o.size})),()=>n.forEach(o=>o.itemPromiseResolve())]}},yi=class e{get _fetch(){return this.fetchImplementation||oC(this.debug)}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,"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:qr("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,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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,"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:gt("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,"debug",{enumerable:!0,configurable:!0,writable:!0,value:qr("LANGSMITH_DEBUG")==="true"});let r=e.getDefaultClientConfig();if(this.tracingSampleRate=b9(t.tracingSamplingRate),this.apiUrl=ph(t.apiUrl??r.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1)),this.apiKey=ph(t.apiKey??r.apiKey),this.webUrl=ph(t.webUrl??r.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=ph(t.workspaceId??gt("WORKSPACE_ID")),this.timeout_ms=t.timeout_ms??9e4,this.caller=new Cd({...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=gt("FAILED_TRACES_DIR")||void 0;let n=gt("FAILED_TRACES_MAX_MB");if(n){let o=parseInt(n,10);Number.isFinite(o)&&o>0&&(this.failedTracesMaxBytes=o*1024*1024)}let i=t.maxIngestMemoryBytes??zR;this.batchIngestCaller=new Cd({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:i,...t.callerOptions??{},onFailedResponseHook:I9,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??r.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??r.hideOutputs,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new vw(i),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,Um()&&(this.langSmithToOTELTranslator=new Bm),this.cachedLSEnvVarsForMetadata=Ob(),t.cache!==void 0&&t.disablePromptCache&&ls("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?(ls("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=zm:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=zm)}static getDefaultClientConfig(){let t=gt("API_KEY"),r=gt("ENDPOINT")??MR,n=gt("HIDE_INPUTS")==="true",i=gt("HIDE_OUTPUTS")==="true";return{apiUrl:r,apiKey:t,webUrl:void 0,hideInputs:n,hideOutputs:i}}getHostUrl(){return this.webUrl?this.webUrl:w9(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("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get headers(){let t={"User-Agent":`langsmith-js/${Dm}`};return this.apiKey&&(t["x-api-key"]=`${this.apiKey}`),this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),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 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}async _getResponse(t,r){let n=r?.toString()??"",i=`${this.apiUrl}${t}?${n}`;return await this.caller.call(async()=>{let a=await this._fetch(i,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(a,`fetch ${t}`),a})}async _get(t,r){return(await this._getResponse(t,r)).json()}async*_getPaginated(t,r=new URLSearchParams,n){let i=Number(r.get("offset"))||0,o=Number(r.get("limit"))||100;for(;;){r.set("offset",String(i)),r.set("limit",String(o));let a=`${this.apiUrl}${t}?${r}`,s=await this.caller.call(async()=>{let u=await this._fetch(a,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(u,`fetch ${t}`),u}),c=n?n(await s.json()):await s.json();if(c.length===0||(yield c,c.length<o))break;i+=c.length}}async*_getCursorPaginatedList(t,r=null,n="POST",i="runs"){let o=r?{...r}:{};for(;;){let a=JSON.stringify(o),c=await(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}${t}`,{method:n,headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(l,`fetch ${t}`),l})).json();if(!c||!c[i])break;yield c[i];let u=c.cursors;if(!u||!u.next)break;o.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 n=[];for(let i of t)this.filteredPostUuids.has(i.trace_id)?i.id===i.trace_id&&this.filteredPostUuids.delete(i.trace_id):n.push(i);return n}else{let n=[];for(let i of t){let o=i.trace_id??i.id;this.filteredPostUuids.has(o)||(i.id===o?this._shouldSample()?n.push(i):this.filteredPostUuids.add(o):n.push(i))}return n}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??S9}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??E9}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:r}){let n=[];for(;this.autoBatchQueue.items.length>0;){let[i,o]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:r});if(!i.length){o();break}let a=i.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(a)){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(o);n.push(c)}return Promise.all(n)}static async _writeTraceToFallbackDir(t,r,n,i,o){try{let a=typeof r=="string"?Buffer.from(r,"utf8"):Buffer.from(r),s=JSON.stringify({version:1,endpoint:i,headers:n,body_base64:a.toString("base64")}),c=`trace_${Date.now()}_${fi().slice(0,8)}.json`,u=Ad.join(t,c);if(e._fallbackDirsCreated.has(t)||(await vC(t),e._fallbackDirsCreated.add(t)),o!==void 0&&o>0)try{let d=(await wC(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),f=0;for(let p of d){let{size:m}=await xC(Ad.join(t,p));f+=m}if(f>=o){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${f} bytes >= ${o} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await bC(u,s),console.warn(`LangSmith trace upload failed; data saved to ${u} for later replay.`)}catch(a){console.error(`LangSmith tracing error: could not write trace to fallback dir ${t}:`,a)}}async _processBatch(t,r){if(!t.length)return;let n=t.reduce((i,o)=>i+(o.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let i={runCreates:t.filter(s=>s.action==="create").map(s=>s.item),runUpdates:t.filter(s=>s.action==="update").map(s=>s.item)},o=await this._ensureServerInfo();if(!this._multipartDisabled&&(o?.batch_ingest_config?.use_multipart_endpoint??!0)){let s=!this._runCompressionDisabled&&o?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(i,{...r,useGzip:s,sizeBytes:n})}catch(c){if(gw(c))this._multipartDisabled=!0,await this.batchIngestRuns(i,{...r,sizeBytes:n});else throw c}}else await this.batchIngestRuns(i,{...r,sizeBytes:n})}}catch(i){console.error("Error exporting batch:",i)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let r=new Map,n=[];for(let i of t)i.item.id&&i.otelContext&&(r.set(i.item.id,i.otelContext),i.action==="create"?n.push({operation:"post",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}):n.push({operation:"patch",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}));this.langSmithToOTELTranslator.exportBatch(n,r)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=RR(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let r=this.autoBatchQueue.push(t);if(this.manualFlushMode)return r;let n=await this._getBatchSizeLimitBytes(),i=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>n||this.autoBatchQueue.items.length>i)&&this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i}),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this.drainAutoBatchQueue({batchSizeLimitBytes:n,batchSizeLimit:i})},this.autoBatchAggregationDelayMs)),r}async _getServerInfo(){let r=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{Accept:"application/json"},signal:AbortSignal.timeout(k9),...this.fetchOptions});return await ae(n,"get server info"),n})).json();return this.debug&&console.log(`
|
|
28
|
+
=== LangSmith Server Configuration ===
|
|
29
|
+
`+JSON.stringify(r,null,2)+`
|
|
30
|
+
`),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=Fm(),r=EC();if(this.langSmithToOTELTranslator!==void 0){let n=t.getActiveSpan();if(n)return t.setSpan(r.active(),n)}}async createRun(t,r){if(!this._filterForSampling([t]).length)return;let n={...this.headers,"Content-Type":"application/json"},i=t.project_name;delete t.project_name;let o=await this.prepareRunCreateOrUpdateInputs({session_name:i,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&o.trace_id!==void 0&&o.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:o,otelContext:c,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let a=RR(o,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(n["x-tenant-id"]=r.workspaceId);let s=Cr(a,`Creating run with id: ${a.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await ae(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),o=await Promise.all(r?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(i.length>0&&o.length>0){let c=i.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of o)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);i=Object.values(c),o=u}let a={post:i,patch:o};if(!a.post.length&&!a.patch.length)return;let s={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=a[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(Cr(s,`Ingesting runs with ids: ${c}`),n)}}async _postBatchIngestRuns(t,r){let n={...this.headers,"Content-Type":"application/json",Accept:"application/json"};r?.apiKey!==void 0&&(n["x-api-key"]=r.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let i=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:n,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await ae(i,"batch create run",!0),i})}async multipartIngestRuns({runCreates:t,runUpdates:r},n){if(t===void 0&&r===void 0)return;let i={},o=[];for(let d of t??[]){let f=await this.prepareRunCreateOrUpdateInputs(d);f.id!==void 0&&f.attachments!==void 0&&(i[f.id]=f.attachments),delete f.attachments,o.push(f)}let a=[];for(let d of r??[])a.push(await this.prepareRunCreateOrUpdateInputs(d));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 creating a run');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 updating a run');if(o.length>0&&a.length>0){let d=o.reduce((p,m)=>(m.id&&(p[m.id]=m),p),{}),f=[];for(let p of a)p.id!==void 0&&d[p.id]?d[p.id]={...d[p.id],...p}:f.push(p);o=Object.values(d),a=f}if(o.length===0&&a.length===0)return;let u=[],l=[];for(let[d,f]of[["post",o],["patch",a]])for(let p of f){let{inputs:m,outputs:h,events:w,extra:_,error:y,serialized:x,attachments:S,...$}=p,j={inputs:m,outputs:h,events:w,extra:_,error:y,serialized:x},C=Cr($,`Serializing for multipart ingestion of run with id: ${$.id}`);l.push({name:`${d}.${$.id}`,payload:new Blob([C],{type:`application/json; length=${C.length}`})});for(let[b,H]of Object.entries(j)){if(H===void 0)continue;let R=Cr(H,`Serializing ${b} for multipart ingestion of run with id: ${$.id}`);l.push({name:`${d}.${$.id}.${b}`,payload:new Blob([R],{type:`application/json; length=${R.length}`})})}if($.id!==void 0){let b=i[$.id];if(b){delete i[$.id];for(let[H,R]of Object.entries(b)){let V,xe;if(Array.isArray(R)?[V,xe]=R:(V=R.mimeType,xe=R.data),H.includes(".")){console.warn(`Skipping attachment '${H}' for run ${$.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}l.push({name:`attachment.${$.id}.${H}`,payload:new Blob([xe],{type:`${V}; length=${xe.byteLength}`})})}}}u.push(`trace=${$.trace_id},id=${$.id}`)}await this._sendMultipartRequest(l,u.join("; "),n)}async _createNodeFetchBody(t,r){let n=[];for(let a of t)n.push(new Blob([`--${r}\r
|
|
31
|
+
`])),n.push(new Blob([`Content-Disposition: form-data; name="${a.name}"\r
|
|
32
|
+
`,`Content-Type: ${a.payload.type}\r
|
|
33
|
+
\r
|
|
34
|
+
`])),n.push(a.payload),n.push(new Blob([`\r
|
|
35
|
+
`]));return n.push(new Blob([`--${r}--\r
|
|
36
|
+
`])),await new Blob(n).arrayBuffer()}async _createMultipartStream(t,r){let n=new TextEncoder;return new ReadableStream({async start(o){let a=async s=>{typeof s=="string"?o.enqueue(n.encode(s)):o.enqueue(s)};for(let s of t){await a(`--${r}\r
|
|
37
|
+
`),await a(`Content-Disposition: form-data; name="${s.name}"\r
|
|
38
|
+
`),await a(`Content-Type: ${s.payload.type}\r
|
|
39
|
+
\r
|
|
40
|
+
`);let u=s.payload.stream().getReader();try{let l;for(;!(l=await u.read()).done;)o.enqueue(l.value)}finally{u.releaseLock()}await a(`\r
|
|
41
|
+
`)}await a(`--${r}--\r
|
|
42
|
+
`),o.close()}})}async _sendMultipartRequest(t,r,n){let i="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),o=()=>this._createNodeFetchBody(t,i),a=()=>this._createMultipartStream(t,i),s=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:n?.sizeBytes},async()=>{let u=await c(),l={...this.headers,"Content-Type":`multipart/form-data; boundary=${i}`};n?.apiKey!==void 0&&(l["x-api-key"]=n.apiKey);let d=u;n?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let f=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(f,"Failed to send multipart request",!0),f});try{let c,u=!1;iC()&&!this.multipartStreamingDisabled&&Ab()!=="bun"?(u=!0,c=await s(a)):c=await s(o),(!this.multipartStreamingDisabled||u)&&c.status===422&&(n?.apiUrl??this.apiUrl)!==MR&&(console.warn(`Streaming multipart upload to ${n?.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(o))}catch(c){if(gw(c))throw c;if(console.warn(`${c.message.trim()}
|
|
43
|
+
|
|
44
|
+
Context: ${r}`),this.failedTracesDir){let u=await this._createNodeFetchBody(t,i).catch(()=>null);u&&await e._writeTraceToFallbackDir(this.failedTracesDir,u,{"Content-Type":`multipart/form-data; boundary=${i}`},"runs/multipart",this.failedTracesMaxBytes)}}}async updateRun(t,r,n){Se(t),r.inputs&&(r.inputs=await this.processInputs(r.inputs)),r.outputs&&(r.outputs=await this.processOutputs(r.outputs));let i={...r,id:t};if(!this._filterForSampling([i],!0).length)return;if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){let s=this._cloneCurrentOTELContext();if(r.end_time!==void 0&&i.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:i,otelContext:s,apiKey:n?.apiKey,apiUrl:n?.apiUrl}).catch(console.error);return}let o={...this.headers,"Content-Type":"application/json"};n?.apiKey!==void 0&&(o["x-api-key"]=n.apiKey),n?.workspaceId!==void 0&&(o["x-tenant-id"]=n.workspaceId);let a=Cr(r,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let s=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:o,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(s,"update run",!0),s})}async readRun(t,{loadChildRuns:r}={loadChildRuns:!1}){Se(t);let n=Ld(await this._get(`/runs/${t}`));return r&&(n=await this._loadChildRuns(n)),n}async getRunUrl({runId:t,run:r,projectOpts:n}){if(r!==void 0){let i;r.session_id?i=r.session_id:n?.projectName?i=(await this.readProject({projectName:n?.projectName})).id:n?.projectId?i=n?.projectId:i=(await this.readProject({projectName:gt("PROJECT")||"default"})).id;let o=await this._getTenantId();return`${this.getHostUrl()}/o/${o}/projects/p/${i}/r/${r.id}?poll=true`}else if(t!==void 0){let i=await this.readRun(t);if(!i.app_path)throw new Error(`Run ${t} has no app_path`);return`${this.getHostUrl()}${i.app_path}`}else throw new Error("Must provide either runId or run")}async _loadChildRuns(t){let r=await x9(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),n={},i={};r.sort((o,a)=>(o?.dotted_order??"").localeCompare(a?.dotted_order??""));for(let o of r){if(o.parent_run_id===null||o.parent_run_id===void 0)throw new Error(`Child run ${o.id} has no parent`);o.dotted_order?.startsWith(t.dotted_order??"")&&o.id!==t.id&&(o.parent_run_id in n||(n[o.parent_run_id]=[]),n[o.parent_run_id].push(o),i[o.id]=o)}t.child_runs=n[t.id]||[];for(let o in n)o!==t.id&&(i[o].child_runs=n[o]);return t}async*listRuns(t){let{projectId:r,projectName:n,parentRunId:i,traceId:o,referenceExampleId:a,startTime:s,executionOrder:c,isRoot:u,runType:l,error:d,id:f,query:p,filter:m,traceFilter:h,treeFilter:w,limit:_,select:y,order:x}=t,S=[];if(r&&(S=Array.isArray(r)?r:[r]),n){let b=Array.isArray(n)?n:[n],H=await Promise.all(b.map(R=>this.readProject({projectName:R}).then(V=>V.id)));S.push(...H)}let $=["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"],j={session:S.length?S:null,run_type:l,reference_example:a,query:p,filter:m,trace_filter:h,tree_filter:w,execution_order:c,parent_run:i,start_time:s?s.toISOString():null,error:d,id:f,limit:_,trace:o,select:y||$,is_root:u,order:x};j.select.includes("child_run_ids")&&ls("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let C=0;for await(let b of this._getCursorPaginatedList("/runs/query",j)){let H=b.map(Ld);if(_){if(C>=_)break;if(H.length+C>_){yield*H.slice(0,_-C);break}C+=H.length,yield*H}else yield*H}}async*listGroupRuns(t){let{projectId:r,projectName:n,groupBy:i,filter:o,startTime:a,endTime:s,limit:c,offset:u}=t,d={session_id:r||(await this.readProject({projectName:n})).id,group_by:i,filter:o,start_time:a?a.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 h={...d,offset:f},w=Object.fromEntries(Object.entries(h).filter(([j,C])=>C!==void 0)),_=JSON.stringify(w),x=await(await this.caller.call(async()=>{let j=await this._fetch(m,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:_});return await ae(j,`Failed to fetch ${p}`),j})).json(),{groups:S,total:$}=x;if(S.length===0)break;for(let j of S)yield j;if(f+=S.length,f>=$)break}}async*readThread(t){let{threadId:r,projectId:n,projectName:i,isRoot:o=!0,limit:a,filter:s,order:c="asc"}=t;if(!n&&!i)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:n??void 0,projectName:i??void 0,isRoot:o,limit:a,filter:l,order:c})}async listThreads(t){let{projectId:r,projectName:n,limit:i,offset:o=0,filter:a,startTime:s,isRoot:c=!0}=t;if(!r&&!n)throw new Error("Either projectId or projectName must be provided");if(r&&n)throw new Error("Provide exactly one of projectId or projectName");let u=r??(await this.readProject({projectName:n})).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()};a!=null&&(f.filter=a);let p=new Map;for await(let _ of this._getCursorPaginatedList("/runs/query",f))for(let y of _){let x=Ld(y),S=x.thread_id;if(S){let $=p.get(S)??[];$.push(x),p.set(S,$)}}let m=[];for(let[_,y]of p.entries()){y.sort((C,b)=>{let H=C,R=b,V=H.start_time??"",xe=R.start_time??"";if(V!==xe)return V.localeCompare(xe);let Ge=H.dotted_order??"",qt=R.dotted_order??"";return Ge.localeCompare(qt)});let S=[...y.map(C=>C.start_time).filter(Boolean)].sort(),$=S.length?S[0]:"",j=S.length?S[S.length-1]:"";m.push({thread_id:_,runs:y,count:y.length,filter:"",total_tokens:0,total_cost:null,min_start_time:$,max_start_time:j,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}m.sort((_,y)=>{let x=_.max_start_time??"";return(y.max_start_time??"").localeCompare(x)});let h=o>0?m.slice(o):m;return i!==void 0?h.slice(0,i):h}async getRunStats({id:t,trace:r,parentRun:n,runType:i,projectNames:o,projectIds:a,referenceExampleIds:s,startTime:c,endTime:u,error:l,query:d,filter:f,traceFilter:p,treeFilter:m,isRoot:h,dataSourceType:w}){let _=a||[];o&&(_=[...a||[],...await Promise.all(o.map(C=>this.readProject({projectName:C}).then(b=>b.id)))]);let x=Object.fromEntries(Object.entries({id:t,trace:r,parent_run:n,run_type:i,session:_,reference_example:s,start_time:c,end_time:u,error:l,query:d,filter:f,trace_filter:p,tree_filter:m,is_root:h,data_source_type:w}).filter(([C,b])=>b!==void 0)),S=JSON.stringify(x);return await(await this.caller.call(async()=>{let C=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:S});return await ae(C,"get run stats"),C})).json()}async shareRun(t,{shareId:r}={}){let n={run_id:t,share_token:r||fi()};Se(t);let i=JSON.stringify(n),a=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await ae(s,"share run"),s})).json();if(a===null||!("share_token"in a))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${a.share_token}/r`}async unshareRun(t){Se(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(r,"unshare run",!0),r})}async readRunSharedLink(t){Se(t);let n=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,"read run shared link"),i})).json();if(!(n===null||!("share_token"in n)))return`${this.getHostUrl()}/public/${n.share_token}/r`}async listSharedRuns(t,{runIds:r}={}){let n=new URLSearchParams({share_token:t});if(r!==void 0)for(let a of r)n.append("id",a);return Se(t),(await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/public/${t}/runs${n}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(a,"list shared runs"),a})).json()).map(Ld)}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),Se(t);let i=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(o,"read dataset shared schema"),o})).json();return i.url=`${this.getHostUrl()}/public/${i.share_token}/d`,i}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 n={dataset_id:t};Se(t);let i=JSON.stringify(n),a=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await ae(s,"share dataset"),s})).json();return a.url=`${this.getHostUrl()}/public/${a.share_token}/d`,a}async unshareDataset(t){Se(t),await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(r,"unshare dataset",!0),r})}async readSharedDataset(t){return Se(t),await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,"read shared dataset"),i})).json()}async listSharedExamples(t,r){let n={};r?.exampleIds&&(n.id=r.exampleIds);let i=new URLSearchParams;Object.entries(n).forEach(([s,c])=>{Array.isArray(c)?c.forEach(u=>i.append(s,u)):i.append(s,c)});let o=await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/public/${t}/examples?${i.toString()}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(s,"list shared examples"),s}),a=await o.json();if(!o.ok)throw"detail"in a?new Error(`Failed to list shared examples.
|
|
45
|
+
Status: ${o.status}
|
|
46
|
+
Message: ${Array.isArray(a.detail)?a.detail.join(`
|
|
47
|
+
`):"Unspecified error"}`):new Error(`Failed to list shared examples: ${o.status} ${o.statusText}`);return a.map(s=>({...s,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:r=null,metadata:n=null,upsert:i=!1,projectExtra:o=null,referenceDatasetId:a=null}){let s=i?"?upsert=true":"",c=`${this.apiUrl}/sessions${s}`,u=o||{};n&&(u.metadata=n);let l={name:t,extra:u,description:r};a!==null&&(l.reference_dataset_id=a);let d=JSON.stringify(l);return await(await this.caller.call(async()=>{let m=await this._fetch(c,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await ae(m,"create project"),m})).json()}async updateProject(t,{name:r=null,description:n=null,metadata:i=null,projectExtra:o=null,endTime:a=null}){let s=`${this.apiUrl}/sessions/${t}`,c=o;i&&(c={...c||{},metadata:i});let u=JSON.stringify({name:r,extra:c,description:n,end_time:a?new Date(a).toISOString():null});return await(await this.caller.call(async()=>{let f=await this._fetch(s,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ae(f,"update project"),f})).json()}async hasProject({projectId:t,projectName:r}){let n="/sessions",i=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)Se(t),n+=`/${t}`;else if(r!==void 0)i.append("name",r);else throw new Error("Must provide projectName or projectId");let o=await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${n}?${i}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(a,"has project"),a});try{let a=await o.json();return o.ok?Array.isArray(a)?a.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:r,includeStats:n}){let i="/sessions",o=new URLSearchParams;if(t!==void 0&&r!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)Se(t),i+=`/${t}`;else if(r!==void 0)o.append("name",r);else throw new Error("Must provide projectName or projectId");n!==void 0&&o.append("include_stats",n.toString());let a=await this._get(i,o),s;if(Array.isArray(a)){if(a.length===0)throw new Error(`Project[id=${t}, name=${r}] not found`);s=a[0]}else s=a;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 n=await this.readProject({projectId:t,projectName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/projects/p/${n.id}`}async getDatasetUrl({datasetId:t,datasetName:r}){if(t===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");let n=await this.readDataset({datasetId:t,datasetName:r}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/datasets/${n.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:n,referenceDatasetId:i,referenceDatasetName:o,includeStats:a,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),n!==void 0&&l.append("name_contains",n),i!==void 0)l.append("reference_dataset",i);else if(o!==void 0){let d=await this.readDataset({datasetName:o});l.append("reference_dataset",d.id)}a!==void 0&&l.append("include_stats",a.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 n;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?n=(await this.readProject({projectName:r})).id:n=t,Se(n),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/sessions/${n}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,`delete session ${n} (${r})`,!0),i})}async uploadCsv({csvFile:t,fileName:r,inputKeys:n,outputKeys:i,description:o,dataType:a,name:s}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,r),n.forEach(p=>{u.append("input_keys",p)}),i.forEach(p=>{u.append("output_keys",p)}),o&&u.append("description",o),a&&u.append("data_type",a),s&&u.append("name",s),await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ae(p,"upload CSV"),p})).json()}async createDataset(t,{description:r,dataType:n,inputsSchema:i,outputsSchema:o,metadata:a}={}){let s={name:t,description:r,extra:{source:"sdk",...a?{metadata:a}:{}}};n&&(s.data_type=n),i&&(s.inputs_schema_definition=i),o&&(s.outputs_schema_definition=o);let c=JSON.stringify(s);return await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ae(d,"create dataset"),d})).json()}async readDataset({datasetId:t,datasetName:r}){let n="/datasets",i=new URLSearchParams({limit:"1"});if(t&&r)throw new Error("Must provide either datasetName or datasetId, not both");if(t)Se(t),n+=`/${t}`;else if(r)i.append("name",r);else throw new Error("Must provide datasetName or datasetId");let o=await this._get(n,i),a;if(Array.isArray(o)){if(o.length===0)throw new Error(`Dataset[id=${t}, name=${r}] not found`);a=o[0]}else a=o;return a}async hasDataset({datasetId:t,datasetName:r}){try{return await this.readDataset({datasetId:t,datasetName:r}),!0}catch(n){if(n instanceof Error&&n.message.toLocaleLowerCase().includes("not found"))return!1;throw n}}async diffDatasetVersions({datasetId:t,datasetName:r,fromVersion:n,toVersion:i}){let o=t;if(o===void 0&&r===void 0)throw new Error("Must provide either datasetName or datasetId");if(o!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");o===void 0&&(o=(await this.readDataset({datasetName:r})).id);let a=new URLSearchParams({from_version:typeof n=="string"?n:n.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return await this._get(`/datasets/${o}/versions/diff`,a)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:r}){let n="/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(`${n}/${t}/openai_ft`)).text()).trim().split(`
|
|
48
|
+
`).map(s=>JSON.parse(s))}async*listDatasets({limit:t=100,offset:r=0,datasetIds:n,datasetName:i,datasetNameContains:o,metadata:a}={}){let s="/datasets",c=new URLSearchParams({limit:t.toString(),offset:r.toString()});if(n!==void 0)for(let u of n)c.append("id",u);i!==void 0&&c.append("name",i),o!==void 0&&c.append("name_contains",o),a!==void 0&&c.append("metadata",JSON.stringify(a));for await(let u of this._getPaginated(s,c))yield*u}async updateDataset(t){let{datasetId:r,datasetName:n,...i}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let o=r??(await this.readDataset({datasetName:n})).id;Se(o);let a=JSON.stringify(i);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(c,"update dataset"),c})).json()}async updateDatasetTag(t){let{datasetId:r,datasetName:n,asOf:i,tag:o}=t;if(!r&&!n)throw new Error("Must provide either datasetName or datasetId");let a=r??(await this.readDataset({datasetName:n})).id;Se(a);let s=JSON.stringify({as_of:typeof i=="string"?i:i.toISOString(),tag:o});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/tags`,{method:"PUT",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await ae(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:r}){let n="/datasets",i=t;if(t!==void 0&&r!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(r!==void 0&&(i=(await this.readDataset({datasetName:r})).id),i!==void 0)Se(i),n+=`/${i}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let o=await this._fetch(this.apiUrl+n,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(o,`delete ${n}`,!0),o})}async indexDataset({datasetId:t,datasetName:r,tag:n}){let i=t;if(!i&&!r)throw new Error("Must provide either datasetName or datasetId");if(i&&r)throw new Error("Must provide either datasetName or datasetId, not both");i||(i=(await this.readDataset({datasetName:r})).id),Se(i);let a=JSON.stringify({tag:n});await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${i}/index`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(c,"index dataset"),c})).json()}async similarExamples(t,r,n,{filter:i}={}){let o={limit:n,inputs:t};i!==void 0&&(o.filter=i),Se(r);let a=JSON.stringify(o);return(await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${r}/search`,{headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,method:"POST",body:a});return await ae(u,"fetch similar examples"),u})).json()).examples}async createExample(t,r,n){if(jR(t)&&(r!==void 0||n!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let i=r?n?.datasetId:t.dataset_id,o=r?n?.datasetName:t.dataset_name;if(i===void 0&&o===void 0)throw new Error("Must provide either datasetName or datasetId");if(i!==void 0&&o!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");i===void 0&&(i=(await this.readDataset({datasetName:o})).id);let a=(r?n?.createdAt:t.created_at)||new Date,s;jR(t)?s=t:s={inputs:t,outputs:r,created_at:a?.toISOString(),id:n?.exampleId,metadata:n?.metadata,split:n?.split,source_run_id:n?.sourceRunId,use_source_run_io:n?.useSourceRunIO,use_source_run_attachments:n?.useSourceRunAttachments,attachments:n?.attachments};let c=await this._uploadExamplesMultipart(i,[s]);return await this.readExample(c.example_ids?.[0]??fi())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let y=t,x=y[0].dataset_id,S=y[0].dataset_name;if(x===void 0&&S===void 0)throw new Error("Must provide either datasetName or datasetId");if(x!==void 0&&S!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");x===void 0&&(x=(await this.readDataset({datasetName:S})).id);let $=await this._uploadExamplesMultipart(x,y);return await Promise.all($.example_ids.map(C=>this.readExample(C)))}let{inputs:r,outputs:n,metadata:i,splits:o,sourceRunIds:a,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 h=r.map((y,x)=>({dataset_id:p,inputs:y,outputs:n?.[x],metadata:i?.[x],split:o?.[x],id:l?.[x],attachments:u?.[x],source_run_id:a?.[x],use_source_run_io:s?.[x],use_source_run_attachments:c?.[x]})),w=await this._uploadExamplesMultipart(p,h);return await Promise.all(w.example_ids.map(y=>this.readExample(y)))}async createLLMExample(t,r,n){return this.createExample({input:t},{output:r},n)}async createChatExample(t,r,n){let i=t.map(a=>qb(a)?Kb(a):a),o=qb(r)?Kb(r):r;return this.createExample({input:i},{output:o},n)}async readExample(t){Se(t);let r=`/examples/${t}`,n=await this._get(r),{attachment_urls:i,...o}=n,a=o;return i&&(a.attachments=Object.entries(i).reduce((s,[c,u])=>(s[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},s),{})),a}async*listExamples({datasetId:t,datasetName:r,exampleIds:n,asOf:i,splits:o,inlineS3Urls:a,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=i?typeof i=="string"?i:i?.toISOString():void 0;m&&p.append("as_of",m);let h=a??!0;if(p.append("inline_s3_urls",h.toString()),n!==void 0)for(let _ of n)p.append("id",_);if(o!==void 0)for(let _ of o)p.append("splits",_);if(s!==void 0){let _=JSON.stringify(s);p.append("metadata",_)}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(_=>p.append("select",_));let w=0;for await(let _ of this._getPaginated("/examples",p)){for(let y of _){let{attachment_urls:x,...S}=y,$=S;x&&($.attachments=Object.entries(x).reduce((j,[C,b])=>(j[C.slice(11)]={presigned_url:b.presigned_url,mime_type:b.mime_type||void 0},j),{})),yield $,w++}if(c!==void 0&&w>=c)break}}async deleteExample(t){Se(t);let r=`/examples/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,`delete ${r}`,!0),n})}async deleteExamples(t,r){if(t.forEach(n=>Se(n)),r?.hardDelete){let n=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${n}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,"hard delete examples",!0),i})}else{let n=new URLSearchParams;t.forEach(i=>n.append("example_ids",i)),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/examples?${n.toString()}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,"delete examples",!0),i})}}async updateExample(t,r){let n;r?n=t:n=t.id,Se(n);let i;r?i={id:n,...r}:i=t;let o;return i.dataset_id!==void 0?o=i.dataset_id:o=(await this.readExample(n)).dataset_id,this._updateExamplesMultipart(o,[i])}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:n,tag:i}){let o;if(t?o=t:o=(await this.readDataset({datasetName:r})).id,Se(o),n&&i||!n&&!i)throw new Error("Exactly one of asOf and tag must be specified.");let a=new URLSearchParams;return n!==void 0&&a.append("as_of",typeof n=="string"?n:n.toISOString()),i!==void 0&&a.append("tag",i),await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${o}/version?${a.toString()}`,{method:"GET",headers:{...this.headers},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(c,"read dataset version"),c})).json()}async listDatasetSplits({datasetId:t,datasetName:r,asOf:n}){let i;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?i=(await this.readDataset({datasetName:r})).id:i=t,Se(i);let o=new URLSearchParams,a=n?typeof n=="string"?n:n?.toISOString():void 0;return a&&o.append("as_of",a),await this._get(`/datasets/${i}/splits`,o)}async updateDatasetSplits({datasetId:t,datasetName:r,splitName:n,exampleIds:i,remove:o=!1}){let a;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?a=(await this.readDataset({datasetName:r})).id:a=t,Se(a);let s={split_name:n,examples:i.map(u=>(Se(u),u)),remove:o},c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${a}/splits`,{method:"PUT",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ae(u,"update dataset splits",!0),u})}async createFeedback(t,r,{score:n,value:i,correction:o,comment:a,sourceInfo:s,feedbackSourceType:c="api",sourceRunId:u,feedbackId:l,feedbackConfig:d,projectId:f,comparativeExperimentId:p,sessionId:m,startTime:h}){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 w={type:c??"api",metadata:s??{}};u!==void 0&&w?.metadata!==void 0&&!w.metadata.__run&&(w.metadata.__run={run_id:u}),w?.metadata!==void 0&&w.metadata.__run?.run_id!==void 0&&Se(w.metadata.__run.run_id);let _={id:l??yd(),run_id:t,key:r,score:NR(n),value:i,correction:o,comment:a,feedback_source:w,comparative_experiment_id:p,feedbackConfig:d,session_id:m??f,start_time:h},y=JSON.stringify(_),x=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let S=await this._fetch(x,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:y});return await ae(S,"create feedback",!0),S}),_}async updateFeedback(t,{score:r,value:n,correction:i,comment:o}){let a={};r!=null&&(a.score=NR(r)),n!=null&&(a.value=n),i!=null&&(a.correction=i),o!=null&&(a.comment=o),Se(t);let s=JSON.stringify(a);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:s});return await ae(c,"update feedback",!0),c})}async readFeedback(t){Se(t);let r=`/feedback/${t}`;return await this._get(r)}async deleteFeedback(t){Se(t);let r=`/feedback/${t}`;await this.caller.call(async()=>{let n=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,`delete ${r}`,!0),n})}async*listFeedback({runIds:t,feedbackKeys:r,feedbackSourceTypes:n}={}){let i=new URLSearchParams;if(t)for(let o of t)Se(o),i.append("run",o);if(r)for(let o of r)i.append("key",o);if(n)for(let o of n)i.append("source",o);for await(let o of this._getPaginated("/feedback",i))yield*o}async createPresignedFeedbackToken(t,r,{expiration:n,feedbackConfig:i}={}){let o={run_id:t,feedback_key:r,feedback_config:i};n?typeof n=="string"?o.expires_at=n:(n?.hours||n?.minutes||n?.days)&&(o.expires_in=n):o.expires_in={hours:3};let a=JSON.stringify(o);return await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(c,"create presigned feedback token"),c})).json()}async createComparativeExperiment({name:t,experimentIds:r,referenceDatasetId:n,createdAt:i,description:o,metadata:a,id:s}){if(r.length===0)throw new Error("At least one experiment is required");if(n||(n=(await this.readProject({projectId:r[0]})).reference_dataset_id),!n==null)throw new Error("A reference dataset is required");let c={id:s,name:t,experiment_ids:r,reference_dataset_id:n,description:o,created_at:(i??new Date)?.toISOString(),extra:{}};a&&(c.extra.metadata=a);let u=JSON.stringify(c);return(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ae(d,"create comparative experiment"),d})).json()}async*listPresignedFeedbackTokens(t){Se(t);let r=new URLSearchParams({run_id:t});for await(let n of this._getPaginated("/feedback/tokens",r))yield*n}_selectEvalResults(t){let r;return"results"in t?r=t.results:Array.isArray(t)?r=t:r=[t],r}async _logEvaluationFeedback(t,r,n){let i=this._selectEvalResults(t),o=[];for(let a of i){let s=n||{};a.evaluatorInfo&&(s={...a.evaluatorInfo,...s});let c=null;a.targetRunId?c=a.targetRunId:r&&(c=r.id),o.push(await this.createFeedback(c,a.key,{score:a.score,value:a.value,comment:a.comment,correction:a.correction,sourceInfo:s,sourceRunId:a.sourceRunId,feedbackConfig:a.feedbackConfig,feedbackSourceType:"model",sessionId:r?.session_id,startTime:r?.start_time}))}return[i,o]}async logEvaluationFeedback(t,r,n){let[i]=await this._logEvaluationFeedback(t,r,n);return i}async createFeedbackConfig(t){let{feedbackKey:r,feedbackConfig:n,isLowerScoreBetter:i=!1}=t,o={feedback_key:r,feedback_config:n,is_lower_score_better:i};return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await ae(s,"create feedback config"),s})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:r,nameContains:n,limit:i}=t,o=new URLSearchParams;r&&r.forEach(s=>{o.append("key",s)}),n&&o.append("name_contains",n),o.append("limit",(i!==void 0?Math.min(i,100):100).toString());let a=0;for await(let s of this._getPaginated("/feedback-configs",o))if(yield*s,a+=s.length,i!==void 0&&a>=i)break}async updateFeedbackConfig(t,r={}){let{feedbackConfig:n,isLowerScoreBetter:i}=r,o={feedback_key:t};return n!==void 0&&(o.feedback_config=n),i!==void 0&&(o.is_lower_score_better=i),(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(o)});return await ae(s,"update feedback config"),s})).json()}async deleteFeedbackConfig(t){let r=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/feedback-configs?${r}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,"delete feedback config",!0),n})}async*listAnnotationQueues(t={}){let{queueIds:r,name:n,nameContains:i,limit:o}=t,a=new URLSearchParams;r&&r.forEach((c,u)=>{Se(c,`queueIds[${u}]`),a.append("ids",c)}),n&&a.append("name",n),i&&a.append("name_contains",i),a.append("limit",(o!==void 0?Math.min(o,100):100).toString());let s=0;for await(let c of this._getPaginated("/annotation-queues",a))if(yield*c,s++,o!==void 0&&s>=o)break}async createAnnotationQueue(t){let{name:r,description:n,queueId:i,rubricInstructions:o,rubricItems:a}=t,s={name:r,description:n,id:i||fi(),rubric_instructions:o,rubric_items:a},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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ae(l,"create annotation queue"),l})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,"read annotation queue"),n})).json()}async updateAnnotationQueue(t,r){let{name:n,description:i,rubricInstructions:o,rubricItems:a}=r,s={};n!==void 0&&(s.name=n),i!==void 0&&(s.description=i),o!==void 0&&(s.rubric_instructions=o),a!==void 0&&(s.rubric_items=a);let c=JSON.stringify(s);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ae(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(r,"delete annotation queue",!0),r})}async addRunsToAnnotationQueue(t,r){let n=JSON.stringify(r.map((i,o)=>Se(i,`runIds[${o}]`).toString()));await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}/runs`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await ae(i,"add runs to annotation queue",!0),i})}async getRunFromAnnotationQueue(t,r){let n=`/annotation-queues/${Se(t,"queueId")}/run`,o=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${n}/${r}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(a,"get run from annotation queue"),a})).json();return Ld(o)}async deleteRunFromAnnotationQueue(t,r){await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}/runs/${Se(r,"queueRunId")}`,{method:"DELETE",headers:{...this.headers,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,"delete run from annotation queue",!0),n})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${Se(t,"queueId")}/size`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(n,"get size from annotation queue"),n})).json()}async _currentTenantIsOwner(t){let r=await this._getSettings();return t=="-"||r.tenant_handle===t}async _ownerConflictError(t,r){let n=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
|
|
49
|
+
|
|
50
|
+
Current tenant: ${n.tenant_handle}
|
|
51
|
+
|
|
52
|
+
Requested tenant: ${r}`)}async _getLatestCommitHash(t){let n=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(i,"get latest commit hash"),i})).json();if(n.commits.length!==0)return n.commits[0].commit_hash}async _likeOrUnlikePrompt(t,r){let[n,i,o]=wi(t),a=JSON.stringify({like:r});return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/likes/${n}/${i}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(c,`${r?"like":"unlike"} prompt`),c})).json()}async _getPromptUrl(t){let[r,n,i]=wi(t);if(await this._currentTenantIsOwner(r)){let o=await this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${n}/${i.substring(0,8)}?organizationId=${o.id}`:`${this.getHostUrl()}/prompts/${n}?organizationId=${o.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${r}/${n}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${r}/${n}`}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,n,i]=wi(t);for await(let o of this._getPaginated(`/commits/${r}/${n}/`,new URLSearchParams,a=>a.commits))yield*o}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 n of this._getPaginated("/repos",r,i=>i.repos))yield*n}async getPrompt(t){let[r,n,i]=wi(t),a=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return s?.status===404?null:(await ae(s,"get prompt"),s)}))?.json();return a?.repo?a.repo:null}async createPrompt(t,r){let n=await this._getSettings();if(r?.isPublic&&!n.tenant_handle)throw new Error(`Cannot create a public prompt without first
|
|
53
|
+
|
|
54
|
+
creating a LangChain Hub handle.
|
|
55
|
+
You can add a handle by creating a public prompt at:
|
|
56
|
+
|
|
57
|
+
https://smith.langchain.com/prompts`);let[i,o,a]=wi(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("create a prompt",i);let s={repo_handle:o,...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.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await ae(d,"create prompt"),d}),{repo:l}=await u.json();return l}async createCommit(t,r,n){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,o,a]=wi(t),s=n?.parentCommitHash==="latest"||!n?.parentCommitHash?await this._getLatestCommitHash(`${i}/${o}`):n?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(r)),parent_commit:s},u=JSON.stringify(c),d=await(await this.caller.call(async()=>{let f=await this._fetch(`${this.apiUrl}/commits/${i}/${o}`,{method:"POST",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await ae(f,"create commit"),f})).json();return this._getPromptUrl(`${i}/${o}${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 n=new FormData;for(let a of r){let s=a.id,c={...a.metadata&&{metadata:a.metadata},...a.split&&{split:a.split}},u=Cr(c,`Serializing body for example with id: ${s}`),l=new Blob([u],{type:"application/json"});if(n.append(s,l),a.inputs){let d=Cr(a.inputs,`Serializing inputs for example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.inputs`,f)}if(a.outputs){let d=Cr(a.outputs,`Serializing outputs whle updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.outputs`,f)}if(a.attachments)for(let[d,f]of Object.entries(a.attachments)){let p,m;Array.isArray(f)?[p,m]=f:(p=f.mimeType,m=f.data);let h=new Blob([m],{type:`${p}; length=${m.byteLength}`});n.append(`${s}.attachment.${d}`,h)}if(a.attachments_operations){let d=Cr(a.attachments_operations,`Serializing attachments while updating example with id: ${s}`),f=new Blob([d],{type:"application/json"});n.append(`${s}.attachments_operations`,f)}}let i=t??r[0]?.dataset_id;return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${i}/examples`)}`,{method:"PATCH",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await ae(a,"update examples"),a})).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 n=new FormData;for(let o of r){let a=(o.id??fi()).toString(),s={created_at:o.created_at,...o.metadata&&{metadata:o.metadata},...o.split&&{split:o.split},...o.source_run_id&&{source_run_id:o.source_run_id},...o.use_source_run_io&&{use_source_run_io:o.use_source_run_io},...o.use_source_run_attachments&&{use_source_run_attachments:o.use_source_run_attachments}},c=Cr(s,`Serializing body for uploaded example with id: ${a}`),u=new Blob([c],{type:"application/json"});if(n.append(a,u),o.inputs){let l=Cr(o.inputs,`Serializing inputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});n.append(`${a}.inputs`,d)}if(o.outputs){let l=Cr(o.outputs,`Serializing outputs for uploaded example with id: ${a}`),d=new Blob([l],{type:"application/json"});n.append(`${a}.outputs`,d)}if(o.attachments)for(let[l,d]of Object.entries(o.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}`});n.append(`${a}.attachment.${l}`,m)}}return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:n});return await ae(o,"upload examples"),o})).json()}async updatePrompt(t,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,i]=wi(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("update a prompt",n);let o={};if(r?.description!==void 0&&(o.description=r.description),r?.readme!==void 0&&(o.readme=r.readme),r?.tags!==void 0&&(o.tags=r.tags),r?.isPublic!==void 0&&(o.is_public=r.isPublic),r?.isArchived!==void 0&&(o.is_archived=r.isArchived),Object.keys(o).length===0)throw new Error("No valid update options provided");let a=JSON.stringify(o);return(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/repos/${n}/${i}`,{method:"PATCH",headers:{...this.headers,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await ae(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,n,i]=wi(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("delete a prompt",r);return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${r}/${n}`,{method:"DELETE",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(a,"delete prompt"),a})).json()}_getPromptCacheKey(t,r){return`${t}${r?":with_model":""}`}async _fetchPromptFromApi(t,r){let[n,i,o]=wi(t),s=await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/commits/${n}/${i}/${o}${r?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this.headers,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await ae(c,"pull prompt commit"),c})).json();return{owner:n,repo:i,commit_hash:s.commit_hash,manifest:s.manifest,examples:s.examples}}async pullPromptCommit(t,r){let n=this._fetchPromptFromApi.bind(this,t,r);if(!r?.skipCache&&this._promptCache){let i=this._getPromptCacheKey(t,r?.includeModel),o=this._promptCache.get(i,n);if(o)return o;let a=await n();return this._promptCache.set(i,a,n),a}return this._fetchPromptFromApi(t,r)}async _pullPrompt(t,r){let n=await this.pullPromptCommit(t,{includeModel:r?.includeModel,skipCache:r?.skipCache});return JSON.stringify(n.manifest)}async pushPrompt(t,r){return await this.promptExists(t)?r&&Object.keys(r).some(i=>i!=="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}):await this._getPromptUrl(t)}async clonePublicDataset(t,r={}){let{sourceApiUrl:n=this.apiUrl,datasetName:i}=r,[o,a]=this.parseTokenOrUrl(t,n),s=new e({apiUrl:o,apiKey:"placeholder"}),c=await s.readSharedDataset(a),u=i||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(a),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,n=2,i="dataset"){try{return Se(t),[r,t]}catch{}try{let a=new URL(t).pathname.split("/").filter(s=>s!=="");if(a.length>=n){let s=a[a.length-n];return[r,s]}else throw new Error(`Invalid public ${i} URL: ${t}`)}catch{throw new Error(`Invalid public ${i} 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();await new Promise(t=>setTimeout(t,1)),await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await $C()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}};Object.defineProperty(yi,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function jR(e){return"dataset_id"in e||"dataset_name"in e}var DR=e=>e!==void 0?e:!!["TRACING_V2","TRACING"].find(r=>gt(r)==="true");var xi=Symbol.for("lc:context_variables");var fh=Symbol.for("langsmith:replica_trace_roots");function bw(e,t){if(xi in e)return e[xi][t]}function LR(e,t,r){let n=xi in e?e[xi]:{};n[t]=r,e[xi]=n}var Ud=36,$9="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function UR(e){let r=Object.keys(e).sort().map(n=>`${n}:${e[n]??""}`).join("|");return _d(r,$9)}function T9(e){return e.replace(/[-:.]/g,"")}function BR(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 ww(e,t,r=1){let n=BR(e,r);return{dottedOrder:T9(n)+t,microsecondPrecisionDatestring:n}}var A9=new Set(["projectName","updates","reroot"]);function O9(e){let t={};for(let r of Object.keys(e))A9.has(r)&&(t[r]=e[r]);return t}var mh=class e{constructor(t,r,n,i){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=n,this.replicas=i}static fromHeader(t){let r=t.split(","),n={},i=[],o,a;for(let s of r){let[c,u]=s.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?n=JSON.parse(l):c==="langsmith-tags"?i=l.split(","):c==="langsmith-project"?o=l:c==="langsmith-replicas"&&(a=JSON.parse(l).map(f=>Array.isArray(f)?f:O9(f)))}return new e(n,i,o,a)}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(",")}},zn=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}),VR(t)){Object.assign(this,{...t});return}let r=e.getDefaultConfig(),{metadata:n,...i}=t,o=i.client??e.getSharedClient(),a={...n,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:a},"id"in i&&i.id==null&&delete i.id,Object.assign(this,{...r,...i,client:o}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=BR(this.start_time,this.execution_order)),this.id||(this.id=Nm(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=N9(this.replicas),!this.dotted_order){let{dottedOrder:s}=ww(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:$d(),child_runs:[],api_url:qr("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:qr("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new yi),e.sharedClient}createChild(t){let r=this.child_execution_order+1,n=this.replicas?.map(f=>{let{reroot:p,...m}=f;return m}),i=t.replicas??n,o=new e({...t,parent_run:this,project_name:this.project_name,replicas:i,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:r,child_execution_order:r}),a=this.extra?.metadata??{},s=o.extra?.metadata??{};Object.keys(a).length>0&&(o.extra={...o.extra,metadata:{...a,...s}}),xi in this&&(o[xi]=this[xi]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(P9(u)){let f={...u},p=C9(f.callbacks)?f.callbacks.copy?.():void 0;p&&(Object.assign(p,{_parentRunId:o.id}),p.handlers?.find(ZR)?.updateFromRunTree?.(o),f.callbacks=p),o.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(o),o}async end(t,r,n=Date.now(),i){this.outputs=this.outputs??t,this.error=this.error??r,this.end_time=this.end_time??n,i&&Object.keys(i).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...i}}:{metadata:i})}_convertToCreate(t,r,n=!0){let i=t.extra??{};if(i?.runtime?.library===void 0&&(i.runtime||(i.runtime={}),r))for(let[s,c]of Object.entries(r))i.runtime[s]||(i.runtime[s]=c);let o=t.parent_run?.id??t.parent_run_id,a;return n?a=[]:a=t.child_runs.map(s=>this._convertToCreate(s,r,n)),{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:i,serialized:t.serialized,error:t.error,inputs:t.inputs,outputs:t.outputs,session_name:t.project_name,child_runs:a,parent_run_id:o,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 n=r.dotted_order.split("."),i=null;for(let o=0;o<n.length;o++)if(n[o].slice(-Ud)===t){i=o;break}if(i!==null){let o=n.slice(i+1);r.dotted_order=o.join("."),o.length>0?r.trace_id=o[0].slice(-Ud):r.trace_id=r.id}}r.parent_run_id===t&&(r.parent_run_id=void 0)}_setReplicaTraceRoot(t,r){let n=bw(this,fh)??{};n[t]=r,LR(this,fh,n);for(let i of this.child_runs)i._setReplicaTraceRoot(t,r)}_remapForProject(t){let{projectName:r,runtimeEnv:n,excludeChildRuns:i=!0,reroot:o=!1,distributedParentId:a,apiUrl:s,apiKey:c,workspaceId:u}=t,l=this._convertToCreate(this,n,i);if(r===this.project_name)return{...l,session_name:r};if(o){if(a)this._sliceParentId(a,l);else if(l.parent_run_id=void 0,l.dotted_order){let y=l.dotted_order.split(".");y.length>0&&(l.dotted_order=y[y.length-1],l.trace_id=l.id)}let _=UR({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});this._setReplicaTraceRoot(_,l.id)}let d;if(!o){let _=bw(this,fh)??{},y=UR({projectName:r,apiUrl:s,apiKey:c,workspaceId:u});if(d=_[y],d&&(l.trace_id=d,l.dotted_order)){let x=l.dotted_order.split("."),S=null;for(let $=0;$<x.length;$++)if(x[$].slice(-Ud)===d){S=$;break}if(S!==null){let $=x.slice(S);l.dotted_order=$.join(".")}}}let f=l.id,p=Td(f,r),m;l.trace_id?m=Td(l.trace_id,r):m=p;let h;l.parent_run_id&&(h=Td(l.parent_run_id,r));let w;return l.dotted_order&&(w=l.dotted_order.split(".").map(x=>{let S=x.slice(-Ud),$=Td(S,r);return x.slice(0,-Ud)+$}).join(".")),{...l,id:p,trace_id:m,parent_run_id:h,dotted_order:w,session_name:r}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let r=Lm();if(this.replicas&&this.replicas.length>0)for(let{projectName:n,apiKey:i,apiUrl:o,workspaceId:a,reroot:s}of this.replicas){let c=this._remapForProject({projectName:n??this.project_name,runtimeEnv:r,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:o,apiKey:i,workspaceId:a});await this.client.createRun(c,{apiKey:i,apiUrl:o,workspaceId:a})}else{let n=this._convertToCreate(this,r,t);await this.client.createRun(n)}if(!t){ls("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let n of this.child_runs)await n.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:n,apiUrl:i,workspaceId:o,updates:a,reroot:s}of this.replicas){let c=this._remapForProject({projectName:r??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:s,distributedParentId:this.distributedParentId,apiUrl:i,apiKey:n,workspaceId:o}),u={id:c.id,name:c.name,run_type:c.run_type,start_time:c.start_time,outputs:c.outputs,error:c.error,parent_run_id:c.parent_run_id,session_name:c.session_name,reference_example_id:c.reference_example_id,end_time:c.end_time,dotted_order:c.dotted_order,trace_id:c.trace_id,events:c.events,tags:c.tags,extra:c.extra,attachments:this.attachments,...a};t?.excludeInputs||(u.inputs=c.inputs),await this.client.updateRun(c.id,u,{apiKey:n,apiUrl:i,workspaceId:o})}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 n=t?.callbacks,i,o,a,s=DR();if(n){let u=n?.getParentRunId?.()??"",l=n?.handlers?.find(d=>d?.name=="langchain_tracer");i=l?.getRun?.(u),o=l?.projectName,a=l?.client,s=s||!!l}return i?new e({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:a,tracingEnabled:s,project_name:o,tags:[...new Set((i?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...i?.extra?.metadata,...t?.metadata}}}).createChild(r):new e({...r,client:a,tracingEnabled:s,project_name:o})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,r){let n="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,i=n["langsmith-trace"];if(!i||typeof i!="string")return;let o=i.trim(),a=o.split(".").map(l=>{let[d,f]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:f}}),s=a[0].uuid,c={...r,name:r?.name??"parent",run_type:r?.run_type??"chain",start_time:r?.start_time??Date.now(),id:a.at(-1)?.uuid,trace_id:s,dotted_order:o};if(n.baggage&&typeof n.baggage=="string"){let l=mh.fromHeader(n.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 mh(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[n,i]of Object.entries(r))t.set(n,i);return r}};Object.defineProperty(zn,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function VR(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function ZR(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function FR(e){return Array.isArray(e)&&e.some(t=>ZR(t))}function C9(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function P9(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(FR(t?.handlers)||FR(t))}function R9(){let e=qr("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let r=[];for(let n of t){if(typeof n!="object"||n===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof n}`);continue}if(typeof n.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_url}`);continue}if(typeof n.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof n.api_key}`);continue}r.push({apiUrl:n.api_url.replace(/\/$/,""),apiKey:n.api_key})}return r}else if(typeof t=="object"&&t!==null){M9(t);let r=[];for(let[n,i]of Object.entries(t)){let o=n.replace(/\/$/,"");if(typeof i=="string")r.push({apiUrl:o,apiKey:i});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${n}: expected string, got ${typeof i}`);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(AR(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 N9(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):R9()}function M9(e){if(Object.keys(e).length>0&>("ENDPOINT"))throw new ch}var GR=P({BaseTracer:()=>Jt,isBaseTracer:()=>fs}),j9=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function Iw(e,t){if(e)return new zn({...e,start_time:e._serialized_start_time??e.start_time,parent_run:Iw(t),child_runs:e.child_runs.map(r=>Iw(r)).filter(r=>r!==void 0),extra:{...e.extra,runtime:Yv()},tracingEnabled:!1})}function xw(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function fs(e){return typeof e._addRunToRunMap=="function"}var Jt=class extends jn{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?j9(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
|
|
58
|
+
|
|
59
|
+
${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:r}=ww(new Date(e.start_time).getTime(),e.id,e.execution_order),n={...e},i=this.getRunById(n.parent_run_id);if(n.parent_run_id!==void 0?i?(this._addChildRun(i,n),i.child_execution_order=Math.max(i.child_execution_order,n.child_execution_order),n.trace_id=i.trace_id,i.dotted_order!==void 0&&(n.dotted_order=[i.dotted_order,t].join("."),n._serialized_start_time=r)):n.parent_run_id=void 0:(n.trace_id=n.id,n.dotted_order=t,n._serialized_start_time=r),this.usesRunTreeMap){let o=Iw(n,i);o!==void 0&&this.runTreeMap.set(n.id,o)}else this.runMap.set(n.id,n);return n}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,n,i,o,a,s){let c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,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:o||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForLLMStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,r,n,i,o,a,s){let c=this._getExecutionOrder(n),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,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:o||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForChatModelStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,r,n,i){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.outputs=e,o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await this.onLLMEnd?.(o),await this._endTrace(o),o}async handleLLMError(e,t,r,n,i){let o=this.getRunById(t);if(!o||o?.run_type!=="llm")throw new Error("No LLM run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),o.extra={...o.extra,...i},await this.onLLMError?.(o),await this._endTrace(o),o}_createRunForChainStart(e,t,r,n,i,o,a,s,c){let u=this._getExecutionOrder(n),l=Date.now(),d={id:r,name:s??e.id[e.id.length-1],parent_run_id:n,start_time:l,serialized:e,events:[{name:"start",time:new Date(l).toISOString()}],inputs:t,execution_order:u,child_execution_order:u,run_type:a??"chain",child_runs:[],extra:o?{...c,metadata:o}:{...c},tags:i||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,r,n,i,o,a,s){let c=this.getRunById(r)??this._createRunForChainStart(e,t,r,n,i,o,a,s);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,r,n,i){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.outputs=xw(e,"output"),o.events.push({name:"end",time:new Date(o.end_time).toISOString()}),i?.inputs!==void 0&&(o.inputs=xw(i.inputs,"input")),await this.onChainEnd?.(o),await this._endTrace(o),o}async handleChainError(e,t,r,n,i){let o=this.getRunById(t);if(!o)throw new Error("No chain run to end.");return o.end_time=Date.now(),o.error=this.stringifyError(e),o.events.push({name:"error",time:new Date(o.end_time).toISOString()}),i?.inputs!==void 0&&(o.inputs=xw(i.inputs,"input")),await this.onChainError?.(o),await this._endTrace(o),o}_createRunForToolStart(e,t,r,n,i,o,a){let s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,r,n,i,o,a){let s=this.getRunById(r)??this._createRunForToolStart(e,t,r,n,i,o,a);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 n=r;n.actions=n.actions||[],n.actions.push(e),n.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,n,i,o,a){let s=this._getExecutionOrder(n),c=Date.now(),u={id:r,name:a??e.id[e.id.length-1],parent_run_id:n,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:o?{metadata:o}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,r,n,i,o,a){let s=this.getRunById(r)??this._createRunForRetrieverStart(e,t,r,n,i,o,a);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,n,i,o){let a=this.getRunById(r);if(!a||a?.run_type!=="llm")throw new Error('Invalid "runId" provided to "handleLLMNewToken" callback.');return a.events.push({name:"new_token",time:new Date().toISOString(),kwargs:{token:e,idx:t,chunk:o?.chunk}}),await this.onLLMNewToken?.(a,e,{chunk:o?.chunk}),a}};var Sw=qo(WR(),1),XR=P({ConsoleCallbackHandler:()=>hh});function vr(e,t){return`${e.open}${t}${e.close}`}function _n(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function JR(e){return typeof e=="string"?e.trim():e==null?e:_n(e,e.toString())}function ta(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:Pr}=Sw.default,hh=class extends Jt{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],r=e;for(;r.parent_run_id;){let n=this.runMap.get(r.parent_run_id);if(n)t.push(n),r=n;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((r,n,i)=>{let o=`${r.execution_order}:${r.run_type}:${r.name}`;return n===i.length-1?vr(Sw.default.bold,o):o}).join(" > ");return vr(Pr.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.green,"[chain/start]")} [${t}] Entering Chain run with input: ${_n(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.cyan,"[chain/end]")} [${t}] [${ta(e)}] Exiting Chain run with output: ${_n(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.red,"[chain/error]")} [${t}] [${ta(e)}] Chain run errored with error: ${_n(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),r="prompts"in e.inputs?{prompts:e.inputs.prompts.map(n=>n.trim())}:e.inputs;console.log(`${vr(Pr.green,"[llm/start]")} [${t}] Entering LLM run with input: ${_n(r,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.cyan,"[llm/end]")} [${t}] [${ta(e)}] Exiting LLM run with output: ${_n(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.red,"[llm/error]")} [${t}] [${ta(e)}] LLM run errored with error: ${_n(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.green,"[tool/start]")} [${t}] Entering Tool run with input: "${JR(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.cyan,"[tool/end]")} [${t}] [${ta(e)}] Exiting Tool run with output: "${JR(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.red,"[tool/error]")} [${t}] [${ta(e)}] Tool run errored with error: ${_n(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${_n(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.cyan,"[retriever/end]")} [${t}] [${ta(e)}] Exiting Retriever run with output: ${_n(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${vr(Pr.red,"[retriever/error]")} [${t}] [${ta(e)}] Retriever run errored with error: ${_n(e.error,"[error]")}`)}onAgentAction(e){let t=e,r=this.getBreadcrumbs(e);console.log(`${vr(Pr.blue,"[agent/action]")} [${r}] Agent selected action: ${_n(t.actions[t.actions.length-1],"[action]")}`)}};var kw,gh=()=>(kw===void 0&&(kw=new yi(et("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),kw);var $w=class{getStore(){}run(t,r){return r()}},Ew=Symbol.for("ls:tracing_async_local_storage"),D9=new $w,Tw=class{getInstance(){return globalThis[Ew]??D9}initializeGlobalInstance(t){globalThis[Ew]===void 0&&(globalThis[Ew]=t)}},L9=new Tw;function YR(e=!1){let t=L9.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
|
|
60
|
+
|
|
61
|
+
Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function _h(e){return typeof e=="function"&&"langsmith:traceable"in e}var QR=P({LangChainTracer:()=>yh});function U9(e){let t;for(let r of e)for(let n of r)be.isInstance(n.message)&&n.message.usage_metadata!==void 0&&(t=Kc(t,n.message.usage_metadata));return t}var yh=class eN extends Jt{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;constructor(t={}){super(t);let{exampleId:r,projectName:n,client:i,replicas:o}=t;this.projectName=n??$d(),this.replicas=o,this.exampleId=r,this.client=i??gh();let a=eN.getTraceableRunTree();a&&this.updateFromRunTree(a)}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 n=U9(r.generations);if(n!==void 0){t.extra=t.extra??{};let i=t.extra.metadata??{};i.usage_metadata=n,t.extra.metadata=i}}}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let r=t,n=new Set;for(;r.parent_run&&!(n.has(r.id)||(n.add(r.id),!r.parent_run));)r=r.parent_run;n.clear();let i=[r];for(;i.length>0;){let o=i.shift();!o||n.has(o.id)||(n.add(o.id),this.runTreeMap.set(o.id,o),o.child_runs&&i.push(...o.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 zn({...r,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return YR(!0)}catch{return}}};var tN=Symbol.for("ls:tracing_async_local_storage"),ra=Symbol.for("lc:context_variables"),rN=e=>{globalThis[tN]=e},na=()=>globalThis[tN];var vh=qo(Km(),1),ms;function F9(){return new("default"in vh.default?vh.default.default:vh.default)({autoStart:!0,concurrency:1})}function B9(){return typeof ms>"u"&&(ms=F9()),ms}async function _t(e,t){if(t===!0){let r=na();r!==void 0?await r.run(void 0,async()=>e()):await e()}else ms=B9(),ms.add(async()=>{let r=na();r!==void 0?await r.run(void 0,async()=>e()):await e()})}async function nN(){let e=gh();await Promise.allSettled([typeof ms<"u"?ms.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var iN=P({awaitAllCallbacks:()=>nN,consumeCallback:()=>_t});var oN=e=>e!==void 0?e:!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>et(t)==="true");function Aw(e){let t=na();if(t!==void 0)return t.getStore()?.[ra]?.[e]}var V9=Symbol("lc:configure_hooks"),aN=()=>Aw(V9)||[];var sN=P({BaseCallbackManager:()=>cN,BaseRunManager:()=>Bd,CallbackManager:()=>Et,CallbackManagerForChainRun:()=>lN,CallbackManagerForLLMRun:()=>Ow,CallbackManagerForRetrieverRun:()=>uN,CallbackManagerForToolRun:()=>dN,ensureHandler:()=>nu,parseCallbackConfigArg:()=>hs});function hs(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var cN=class{setHandler(e){return this.setHandlers([e])}},Bd=class{constructor(e,t,r,n,i,o,a,s){this.runId=e,this.handlers=t,this.inheritableHandlers=r,this.tags=n,this.inheritableTags=i,this.metadata=o,this.inheritableMetadata=a,this._parentRunId=s}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>_t(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,n,i){await Promise.all(this.handlers.map(o=>_t(async()=>{try{await o.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleCustomEvent: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},uN=class extends Bd{getChild(e){let t=new Et(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=>_t(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=>_t(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)))}},Ow=class extends Bd{async handleLLMNewToken(e,t,r,n,i,o){await Promise.all(this.handlers.map(a=>_t(async()=>{if(!a.ignoreLLM)try{await a.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,o)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMNewToken: ${s}`),a.raiseError)throw s}},a.awaitHandlers)))}async handleLLMError(e,t,r,n,i){await Promise.all(this.handlers.map(o=>_t(async()=>{if(!o.ignoreLLM)try{await o.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleLLMEnd(e,t,r,n,i){await Promise.all(this.handlers.map(o=>_t(async()=>{if(!o.ignoreLLM)try{await o.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleLLMEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}},lN=class extends Bd{getChild(e){let t=new Et(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,n,i){await Promise.all(this.handlers.map(o=>_t(async()=>{if(!o.ignoreChain)try{await o.handleChainError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainError: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleChainEnd(e,t,r,n,i){await Promise.all(this.handlers.map(o=>_t(async()=>{if(!o.ignoreChain)try{await o.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((o.raiseError?console.error:console.warn)(`Error in handler ${o.constructor.name}, handleChainEnd: ${a}`),o.raiseError)throw a}},o.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>_t(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=>_t(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)))}},dN=class extends Bd{getChild(e){let t=new Et(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=>_t(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=>_t(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=>_t(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)))}},Et=class Fd extends cN{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,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&n?n:mn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return fs(f)&&f._createRunForLLMStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),_t(async()=>{try{await f.handleLLMStart?.(t,[u],d,this._parentRunId,o,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 Ow(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,r,n=void 0,i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return Promise.all(r.map(async(u,l)=>{let d=l===0&&n?n:mn();return await Promise.all(this.handlers.map(f=>{if(!f.ignoreLLM)return fs(f)&&f._createRunForChatModelStart(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c),_t(async()=>{try{if(f.handleChatModelStart)await f.handleChatModelStart?.(t,[u],d,this._parentRunId,o,this.tags,this.metadata,c);else if(f.handleLLMStart){let p=Wc(u);await f.handleLLMStart?.(t,[p],d,this._parentRunId,o,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 Ow(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,r,n=mn(),i=void 0,o=void 0,a=void 0,s=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return fs(l)&&l._createRunForChainStart(t,r,n,this._parentRunId,this.tags,this.metadata,i,s,u),_t(async()=>{try{await l.handleChainStart?.(t,r,n,this._parentRunId,this.tags,this.metadata,i,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 lN(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,r,n=mn(),i=void 0,o=void 0,a=void 0,s=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return fs(u)&&u._createRunForToolStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),_t(async()=>{try{await u.handleToolStart?.(t,r,n,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 dN(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,r,n=mn(),i=void 0,o=void 0,a=void 0,s=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return fs(c)&&c._createRunForRetrieverStart(t,r,n,this._parentRunId,this.tags,this.metadata,s),_t(async()=>{try{await c.handleRetrieverStart?.(t,r,n,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 uN(n,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,r,n,i,o){await Promise.all(this.handlers.map(a=>_t(async()=>{if(!a.ignoreCustomEvent)try{await a.handleCustomEvent?.(t,r,n,this.tags,this.metadata)}catch(s){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${s}`),a.raiseError)throw s}},a.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 n of t)this.addHandler(n,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 n=new Fd(this._parentRunId);for(let i of this.handlers){let o=this.inheritableHandlers.includes(i);n.addHandler(i,o)}for(let i of this.tags){let o=this.inheritableTags.includes(i);n.addTags([i],o)}for(let i of Object.keys(this.metadata)){let o=Object.keys(this.inheritableMetadata).includes(i);n.addMetadata({[i]:this.metadata[i]},o)}for(let i of t)n.handlers.filter(o=>o.name==="console_callback_handler").some(o=>o.name===i.name)||n.addHandler(i,r);return n}static fromHandlers(t){class r extends jn{name=mn();constructor(){super(),Object.assign(this,t)}}let n=new this;return n.addHandler(new r),n}static configure(t,r,n,i,o,a,s){return this._configureSync(t,r,n,i,o,a,s)}static _configureSync(t,r,n,i,o,a,s){let c;(t||r)&&(Array.isArray(t)||!t?(c=new Fd,c.setHandlers(t?.map(nu)??[],!0)):c=t,c=c.copy(Array.isArray(r)?r.map(nu):r?.handlers,!1));let u=et("LANGCHAIN_VERBOSE")==="true"||s?.verbose,l=yh.getTraceableRunTree(),d=l?.tracingEnabled??oN();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||(et("LANGCHAIN_TRACING")??!1);if(u||f){if(c||(c=new Fd),u&&!c.handlers.some(p=>p.name===hh.prototype.name)){let p=new hh;c.addHandler(p,!0)}if(f&&!c.handlers.some(p=>p.name==="langchain_tracer")&&d){let p=new yh;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:h,envVar:w}of aN()){let _=w&&et(w)==="true"&&h,y,x=p!==void 0?Aw(p):void 0;x&&_b(x)?y=x:_&&(y=new h({})),y!==void 0&&(c||(c=new Fd),c.handlers.some(S=>S.name===y.name)||c.addHandler(y,m))}return(n||i)&&c&&(c.addTags(n??[]),c.addTags(i??[],!1)),(o||a)&&c&&(c.addMetadata(o??{}),c.addMetadata(a??{},!1)),c}};function nu(e){return"name"in e?e:jn.fromMethods(e)}var Cw=class{getStore(){}run(e,t){return t()}enterWith(e){}},Z9=new Cw,pN=Symbol.for("lc:child_config"),G9=class{getInstance(){return na()??Z9}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[pN]}runWithConfig(e,t,r){let n=Et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),o=i.getStore(),a=n?.getParentRunId(),s=n?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return s&&a?c=s.getRunTreeWithTracingConfig(a):r||(c=new zn({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[pN]:e}),o!==void 0&&o[ra]!==void 0&&(c===void 0&&(c={}),c[ra]=o[ra]),i.run(c,t)}initializeGlobalInstance(e){na()===void 0&&rN(e)}},He=new G9;var fN=P({AsyncLocalStorageProviderSingleton:()=>He,MockAsyncLocalStorage:()=>Cw,_CONTEXT_VARIABLES_KEY:()=>ra});async function Ot(e){return Et._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function Bt(...e){let t={};for(let r of e.filter(n=>!!n))for(let n of Object.keys(r))if(n==="metadata")t[n]={...t[n],...r[n]};else if(n==="tags"){let i=t[n]??[];t[n]=[...new Set(i.concat(r[n]??[]))]}else if(n==="configurable")t[n]={...t[n],...r[n]};else if(n==="timeout")t.timeout===void 0?t.timeout=r.timeout:r.timeout!==void 0&&(t.timeout=Math.min(t.timeout,r.timeout));else if(n==="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(n==="callbacks"){let i=t.callbacks,o=r.callbacks;if(Array.isArray(o))if(!i)t.callbacks=o;else if(Array.isArray(i))t.callbacks=i.concat(o);else{let a=i.copy();for(let s of o)a.addHandler(nu(s),!0);t.callbacks=a}else if(o)if(!i)t.callbacks=o;else if(Array.isArray(i)){let a=o.copy();for(let s of i)a.addHandler(nu(s),!0);t.callbacks=a}else t.callbacks=new Et(o._parentRunId,{handlers:i.handlers.concat(o.handlers),inheritableHandlers:i.inheritableHandlers.concat(o.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(o.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(o.inheritableTags))),metadata:{...i.metadata,...o.metadata}})}else{let i=n;t[i]=r[i]??t[i]}return t}var H9=new Set(["string","number","boolean"]);function Ne(e){let t=He.getRunnableConfig(),r={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:n,runName:i,...o}=t;r=Object.entries(o).reduce((a,[s,c])=>(c!==void 0&&(a[s]=c),a),r)}if(e&&(r=Object.entries(e).reduce((n,[i,o])=>(o!==void 0&&(n[i]=o),n),r)),r?.configurable)for(let n of Object.keys(r.configurable))H9.has(typeof r.configurable[n])&&!r.metadata?.[n]&&(r.metadata||(r.metadata={}),r.metadata[n]=r.configurable[n]);if(r.timeout!==void 0){if(r.timeout<=0)throw new Error("Timeout must be a positive number");let n=r.timeout,i=AbortSignal.timeout(n);r.metadata||(r.metadata={}),r.metadata.timeoutMs===void 0&&(r.metadata.timeoutMs=n),r.signal!==void 0?"any"in AbortSignal&&(r.signal=AbortSignal.any([r.signal,i])):r.signal=i,delete r.timeout}return r}function Me(e={},{callbacks:t,maxConcurrency:r,recursionLimit:n,runName:i,configurable:o,runId:a}={}){let s=Ne(e);return t!==void 0&&(delete s.runName,s.callbacks=t),n!==void 0&&(s.recursionLimit=n),r!==void 0&&(s.maxConcurrency=r),i!==void 0&&(s.runName=i),o!==void 0&&(s.configurable={...s.configurable,...o}),a!==void 0&&delete s.runId,s}function br(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 Kr(e,t){if(t===void 0)return e;let r;return Promise.race([e.catch(n=>{if(!t?.aborted)throw n}),new Promise((n,i)=>{r=()=>{i(ia(t))},t.addEventListener("abort",r,{once:!0}),t.aborted&&i(ia(t))})]).finally(()=>t.removeEventListener("abort",r))}function ia(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var mN=P({AsyncGeneratorWithSetup:()=>oa,IterableReadableStream:()=>Ct,atee:()=>bh,concat:()=>Wr,pipeGeneratorWithSetup:()=>Rw}),Ct=class Pw 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 Pw({start(n){return i();function i(){return r.read().then(({done:o,value:a})=>{if(o){n.close();return}return n.enqueue(a),i()})}},cancel(){r.releaseLock()}})}static fromAsyncGenerator(t){return new Pw({async pull(r){let{value:n,done:i}=await t.next();i&&r.close(),r.enqueue(n)},async cancel(r){await t.return(r)}})}};function bh(e,t=2){let r=Array.from({length:t},()=>[]);return r.map(async function*(i){for(;;)if(i.length===0){let o=await e.next();for(let a of r)a.push(o)}else{if(i[0].done)return;yield i.shift().value}})}function Wr(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[n,i]of Object.entries(t))n in r&&!Array.isArray(r[n])?r[n]=Wr(r[n],i):r[n]=i;return r}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var oa=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)=>{He.runWithConfig(br(e.config),async()=>{this.firstResult=this.signal?Kr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,r):this.firstResult.then(n=>t(void 0),r)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?He.runWithConfig(br(this.config),this.signal?async()=>Kr(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 Rw(e,t,r,n,...i){let o=new oa({generator:t,startSetup:r,signal:n}),a=await o.setup;return{output:e(o,a,...i),setup:a}}var q9=Object.prototype.hasOwnProperty;function xh(e,t){return q9.call(e,t)}function Ih(e){if(Array.isArray(e)){let r=new Array(e.length);for(let n=0;n<r.length;n++)r[n]=""+n;return r}if(Object.keys)return Object.keys(e);let t=[];for(let r in e)xh(e,r)&&t.push(r);return t}function Jr(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Sh(e){let t=0,r=e.length,n;for(;t<r;){if(n=e.charCodeAt(t),n>=48&&n<=57){t++;continue}return!1}return!0}function gs(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function gN(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function wh(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(wh(e[r]))return!0}else if(typeof e=="object"){let r=Ih(e),n=r.length;for(var t=0;t<n;t++)if(wh(e[r[t]]))return!0}}return!1}function hN(e,t){let r=[e];for(let n in t){let i=typeof t[n]=="object"?JSON.stringify(t[n],null,2):t[n];typeof i<"u"&&r.push(`${n}: ${i}`)}return r.join(`
|
|
62
|
+
`)}var _N=class extends Error{constructor(e,t,r,n,i){super(hN(e,{name:t,index:r,operation:n,tree:i})),this.name=t,this.index=r,this.operation=n,this.tree=i,Object.setPrototypeOf(this,new.target.prototype),this.message=hN(e,{name:t,index:r,operation:n,tree:i})}};var yN=P({JsonPatchError:()=>vt,_areEquals:()=>Vd,applyOperation:()=>_s,applyPatch:()=>aa,applyReducer:()=>J9,deepClone:()=>K9,getValueByPointer:()=>kh,validate:()=>vN,validator:()=>Eh}),vt=_N,K9=Jr,iu={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 n=e[t];return delete e[t],{newDocument:r,removed:n}},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 n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){let n=kh(r,this.path);n&&(n=Jr(n));let i=_s(r,{op:"remove",path:this.from}).removed;return _s(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){let n=kh(r,this.from);return _s(r,{op:"add",path:this.path,value:Jr(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:Vd(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},W9={add:function(e,t,r){return Sh(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 n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:iu.move,copy:iu.copy,test:iu.test,_get:iu._get};function kh(e,t){if(t=="")return e;var r={op:"_get",path:t};return _s(e,r),r.value}function _s(e,t,r=!1,n=!0,i=!0,o=0){if(r&&(typeof r=="function"?r(t,0,e,t.path):Eh(t,0)),t.path===""){let a={newDocument:e};if(t.op==="add")return a.newDocument=t.value,a;if(t.op==="replace")return a.newDocument=t.value,a.removed=e,a;if(t.op==="move"||t.op==="copy")return a.newDocument=kh(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=Vd(e,t.value),a.test===!1)throw new vt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return a.newDocument=e,a}else{if(t.op==="remove")return a.removed=e,a.newDocument=null,a;if(t.op==="_get")return t.value=e,a;if(r)throw new vt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,t,e);return a}}else{n||(e=Jr(e));let a=(t.path||"").split("/"),s=e,c=1,u=a.length,l,d,f;for(typeof r=="function"?f=r:f=Eh;;){if(d=a[c],d&&d.indexOf("~")!=-1&&(d=gN(d)),i&&(d=="__proto__"||d=="prototype"&&c>0&&a[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=a.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&&!Sh(d))throw new vt("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",o,t,e);Sh(d)&&(d=~~d)}if(c>=u){if(r&&t.op==="add"&&d>s.length)throw new vt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);let p=W9[t.op].call(t,s,d,e);if(p.test===!1)throw new vt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}}else if(c>=u){let p=iu[t.op].call(t,s,d,e);if(p.test===!1)throw new vt("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return p}if(s=s[d],r&&c<u&&(!s||typeof s!="object"))throw new vt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,t,e)}}}function aa(e,t,r,n=!0,i=!0){if(r&&!Array.isArray(t))throw new vt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=Jr(e));let o=new Array(t.length);for(let a=0,s=t.length;a<s;a++)o[a]=_s(e,t[a],r,!0,i,a),e=o[a].newDocument;return o.newDocument=e,o}function J9(e,t,r){let n=_s(e,t);if(n.test===!1)throw new vt("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function Eh(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new vt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(iu[e.op]){if(typeof e.path!="string")throw new vt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new vt('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 vt("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 vt("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")&&wh(e.value))throw new vt("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 i=e.path.split("/").length,o=n.split("/").length;if(i!==o+1&&i!==o)throw new vt("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!==n)throw new vt("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 a=vN([{op:"_get",path:e.from,value:void 0}],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new vt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new vt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function vN(e,t,r){try{if(!Array.isArray(e))throw new vt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)aa(Jr(t),Jr(e),r||!0);else{r=r||Eh;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(i){if(i instanceof vt)return i;throw i}}function Vd(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),i,o,a;if(r&&n){if(o=e.length,o!=t.length)return!1;for(i=o;i--!==0;)if(!Vd(e[i],t[i]))return!1;return!0}if(r!=n)return!1;var s=Object.keys(e);if(o=s.length,o!==Object.keys(t).length)return!1;for(i=o;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=o;i--!==0;)if(a=s[i],!Vd(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}function bN(e,t,r,n,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var o=Ih(t),a=Ih(e),s=!1,c=a.length-1;c>=0;c--){var u=a[c],l=e[u];if(xh(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)?bN(l,d,r,n+"/"+gs(u),i):l!==d&&(i&&r.push({op:"test",path:n+"/"+gs(u),value:Jr(l)}),r.push({op:"replace",path:n+"/"+gs(u),value:Jr(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:n+"/"+gs(u),value:Jr(l)}),r.push({op:"remove",path:n+"/"+gs(u)}),s=!0):(i&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}))}if(!(!s&&o.length==a.length))for(var c=0;c<o.length;c++){var u=o[c];!xh(e,u)&&t[u]!==void 0&&r.push({op:"add",path:n+"/"+gs(u),value:Jr(t[u])})}}}function sa(e,t,r=!1){var n=[];return bN(e,t,n,"",r),n}({...yN});var IN=P({LogStreamCallbackHandler:()=>Th,RunLog:()=>$h,RunLogPatch:()=>Ii,isLogStreamHandler:()=>Mw}),Ii=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),r=aa({},t);return new $h({ops:t,state:r[r.length-1].newDocument})}},$h=class Nw extends Ii{state;constructor(t){super(t),this.state=t.state}concat(t){let r=this.ops.concat(t.ops),n=aa(this.state,t.ops);return new Nw({ops:r,state:n[n.length-1].newDocument})}static fromRunLogPatch(t){let r=aa({},t.ops);return new Nw({ops:t.ops,state:r[r.length-1].newDocument})}},Mw=e=>e.name==="log_stream_tracer";async function wN(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 xN(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 X9(e){return e!==void 0&&e.message!==void 0}var Th=class extends Jt{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=Ct.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(n=>this.includeTags?.includes(n))!==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(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){for await(let r of t){if(e!==this.rootId){let n=this.keyMapByRunId[e];n&&await this.writer.write(new Ii({ops:[{op:"add",path:`/logs/${n}/streamed_output/-`,value:r}]}))}yield r}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new Ii({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 wN(e,this._schemaFormat)),await this.writer.write(new Ii({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 wN(e,this._schemaFormat)}),r.push({op:"add",path:`/logs/${t}/final_output`,value:await xN(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 n=new Ii({ops:r});await this.writer.write(n)}finally{if(e.id===this.rootId){let t=new Ii({ops:[{op:"replace",path:"/final_output",value:await xN(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,r){let n=this.keyMapByRunId[e.id];if(n===void 0)return;let i=e.inputs.messages!==void 0,o;i?X9(r?.chunk)?o=r?.chunk:o=new at({id:`run-${e.id}`,content:t}):o=t;let a=new Ii({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:o}]});await this.writer.write(a)}};var SN=P({ChatGenerationChunk:()=>Xr,GenerationChunk:()=>Si,RUN_KEY:()=>ys}),ys="__run",Si=class kN{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new kN({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},Xr=class EN extends Si{message;constructor(t){super(t),this.message=t.message}concat(t){return new EN({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}};var Y9=Object.prototype.toString,Q9=e=>Y9.call(e)==="[object Error]",e5=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 $N(e){if(!(e&&Q9(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:e5.has(t)}function t5(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 Ah(e,t,{min:r=0,allowInfinity:n=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${n?" or Infinity":""}.`);if(!n&&!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 r5=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 n5(e,t){let r=Math.max(1,e+1),n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*t.factor**(r-1));return i=Math.min(i,t.maxTimeout),i}function TN(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function i5({error:e,attemptNumber:t,retriesConsumed:r,startTime:n,options:i}){let o=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(o instanceof r5)throw o.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-r):i.retries,s=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:o,attemptNumber:t,retriesLeft:a,retriesConsumed:r});if(await i.onFailedAttempt(c),TN(n,s)<=0)throw o;let u=await i.shouldConsumeRetry(c),l=TN(n,s);if(l<=0||a<=0)throw o;if(o instanceof TypeError&&!$N(o)){if(u)throw o;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw o;if(!u)return i.signal?.throwIfAborted(),!1;let d=n5(r,i),f=Math.min(d,l);return f>0&&await new Promise((p,m)=>{let h=()=>{clearTimeout(w),i.signal?.removeEventListener("abort",h),m(i.signal.reason)},w=setTimeout(()=>{i.signal?.removeEventListener("abort",h),p()},f);i.unref&&w.unref?.(),i.signal?.addEventListener("abort",h,{once:!0})}),i.signal?.throwIfAborted(),!0}async function Zd(e,t={}){if(t={...t},t5(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,Ah("factor",t.factor,{min:0,allowInfinity:!1}),Ah("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),Ah("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),Ah("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,n=0,i=performance.now();for(;!Number.isFinite(t.retries)||n<=t.retries;){r++;try{t.signal?.throwIfAborted();let o=await e(r);return t.signal?.throwIfAborted(),o}catch(o){await i5({error:o,attemptNumber:r,retriesConsumed:n,startTime:i,options:t})&&n++}}throw new Error("Retry attempts exhausted without throwing an error.")}var Oh=qo(Km(),1),AN=P({AsyncCaller:()=>lo}),o5=[400,401,402,403,404,405,406,407,409],a5=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,n=t??r;if(n&&o5.includes(+n))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 i=new Error("message"in e&&typeof e.message=="string"?e.message:"Insufficient quota");throw i.name="InsufficientQuotaError",i}},lo=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??a5,this.queue=new("default"in Oh.default?Oh.default.default:Oh.default)({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>Zd(()=>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 n;return Promise.race([this.call(t,...r),new Promise((i,o)=>{n=()=>{o(ia(e.signal))},e.signal?.addEventListener("abort",n,{once:!0})})]).finally(()=>{e.signal&&n&&e.signal.removeEventListener("abort",n)})}return this.call(t,...r)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}};var ON=P({isSerializableSchema:()=>ki,isStandardJsonSchema:()=>Ch,isStandardSchema:()=>CN});function CN(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 Ch(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 ki(e){return CN(e)&&Ch(e)}var ho={};li(ho,{$ZodAny:()=>x0,$ZodArray:()=>k0,$ZodAsyncError:()=>Dn,$ZodBase64:()=>p0,$ZodBase64URL:()=>f0,$ZodBigInt:()=>Qh,$ZodBigIntFormat:()=>y0,$ZodBoolean:()=>ip,$ZodCIDRv4:()=>u0,$ZodCIDRv6:()=>l0,$ZodCUID:()=>Xx,$ZodCUID2:()=>Yx,$ZodCatch:()=>V0,$ZodCheck:()=>Qe,$ZodCheckBigIntFormat:()=>$x,$ZodCheckEndsWith:()=>Lx,$ZodCheckGreaterThan:()=>Hh,$ZodCheckIncludes:()=>zx,$ZodCheckLengthEquals:()=>Rx,$ZodCheckLessThan:()=>Gh,$ZodCheckLowerCase:()=>Mx,$ZodCheckMaxLength:()=>Cx,$ZodCheckMaxSize:()=>Tx,$ZodCheckMimeType:()=>Fx,$ZodCheckMinLength:()=>Px,$ZodCheckMinSize:()=>Ax,$ZodCheckMultipleOf:()=>kx,$ZodCheckNumberFormat:()=>Ex,$ZodCheckOverwrite:()=>Bx,$ZodCheckProperty:()=>Ux,$ZodCheckRegex:()=>Nx,$ZodCheckSizeEquals:()=>Ox,$ZodCheckStartsWith:()=>Dx,$ZodCheckStringFormat:()=>pu,$ZodCheckUpperCase:()=>jx,$ZodCodec:()=>cp,$ZodCustom:()=>X0,$ZodCustomStringFormat:()=>g0,$ZodDate:()=>S0,$ZodDefault:()=>L0,$ZodDiscriminatedUnion:()=>T0,$ZodE164:()=>m0,$ZodEmail:()=>qx,$ZodEmoji:()=>Wx,$ZodEncodeError:()=>ca,$ZodEnum:()=>R0,$ZodError:()=>Yd,$ZodExactOptional:()=>z0,$ZodFile:()=>M0,$ZodFunction:()=>K0,$ZodGUID:()=>Gx,$ZodIPv4:()=>a0,$ZodIPv6:()=>s0,$ZodISODate:()=>n0,$ZodISODateTime:()=>r0,$ZodISODuration:()=>o0,$ZodISOTime:()=>i0,$ZodIntersection:()=>A0,$ZodJWT:()=>h0,$ZodKSUID:()=>t0,$ZodLazy:()=>J0,$ZodLiteral:()=>N0,$ZodMAC:()=>c0,$ZodMap:()=>C0,$ZodNaN:()=>Z0,$ZodNanoID:()=>Jx,$ZodNever:()=>ap,$ZodNonOptional:()=>F0,$ZodNull:()=>w0,$ZodNullable:()=>D0,$ZodNumber:()=>Yh,$ZodNumberFormat:()=>_0,$ZodObject:()=>i1,$ZodObjectJIT:()=>E0,$ZodOptional:()=>Is,$ZodPipe:()=>G0,$ZodPrefault:()=>U0,$ZodPromise:()=>W0,$ZodReadonly:()=>H0,$ZodRealError:()=>Nr,$ZodRecord:()=>O0,$ZodRegistry:()=>ig,$ZodSet:()=>P0,$ZodString:()=>xs,$ZodStringFormat:()=>Ke,$ZodSuccess:()=>B0,$ZodSymbol:()=>v0,$ZodTemplateLiteral:()=>q0,$ZodTransform:()=>j0,$ZodTuple:()=>eg,$ZodType:()=>we,$ZodULID:()=>Qx,$ZodURL:()=>Kx,$ZodUUID:()=>Hx,$ZodUndefined:()=>b0,$ZodUnion:()=>sp,$ZodUnknown:()=>op,$ZodVoid:()=>I0,$ZodXID:()=>e0,$ZodXor:()=>$0,$brand:()=>Ph,$constructor:()=>I,$input:()=>Q0,$output:()=>Y0,Doc:()=>np,JSONSchema:()=>nM,JSONSchemaGenerator:()=>Ng,NEVER:()=>jw,TimePrecision:()=>nI,_any:()=>SI,_array:()=>AI,_base64:()=>xg,_base64url:()=>Ig,_bigint:()=>_I,_boolean:()=>hI,_catch:()=>E8,_check:()=>rM,_cidrv4:()=>bg,_cidrv6:()=>wg,_coercedBigint:()=>yI,_coercedBoolean:()=>gI,_coercedDate:()=>$I,_coercedNumber:()=>uI,_coercedString:()=>tI,_cuid:()=>fg,_cuid2:()=>mg,_custom:()=>CI,_date:()=>EI,_decode:()=>jh,_decodeAsync:()=>Dh,_default:()=>I8,_discriminatedUnion:()=>d8,_e164:()=>Sg,_email:()=>ag,_emoji:()=>dg,_encode:()=>Mh,_encodeAsync:()=>zh,_endsWith:()=>vu,_enum:()=>_8,_file:()=>OI,_float32:()=>dI,_float64:()=>pI,_gt:()=>Ti,_gte:()=>wr,_guid:()=>dp,_includes:()=>_u,_int:()=>lI,_int32:()=>fI,_int64:()=>vI,_intersection:()=>p8,_ipv4:()=>yg,_ipv6:()=>vg,_isoDate:()=>oI,_isoDateTime:()=>iI,_isoDuration:()=>sI,_isoTime:()=>aI,_jwt:()=>kg,_ksuid:()=>_g,_lazy:()=>O8,_length:()=>Es,_literal:()=>v8,_lowercase:()=>hu,_lt:()=>$i,_lte:()=>Qr,_mac:()=>rI,_map:()=>h8,_max:()=>Qr,_maxLength:()=>ks,_maxSize:()=>ma,_mime:()=>bu,_min:()=>wr,_minLength:()=>fo,_minSize:()=>Ai,_multipleOf:()=>fa,_nan:()=>TI,_nanoid:()=>pg,_nativeEnum:()=>y8,_negative:()=>$g,_never:()=>mp,_nonnegative:()=>Ag,_nonoptional:()=>S8,_nonpositive:()=>Tg,_normalize:()=>wu,_null:()=>II,_nullable:()=>x8,_number:()=>cI,_optional:()=>w8,_overwrite:()=>Ln,_parse:()=>cu,_parseAsync:()=>uu,_pipe:()=>$8,_positive:()=>Eg,_promise:()=>C8,_property:()=>Og,_readonly:()=>T8,_record:()=>m8,_refine:()=>PI,_regex:()=>mu,_safeDecode:()=>Uh,_safeDecodeAsync:()=>Bh,_safeEncode:()=>Lh,_safeEncodeAsync:()=>Fh,_safeParse:()=>lu,_safeParseAsync:()=>du,_set:()=>g8,_size:()=>Ss,_slugify:()=>ku,_startsWith:()=>yu,_string:()=>eI,_stringFormat:()=>Eu,_stringbool:()=>jI,_success:()=>k8,_superRefine:()=>RI,_symbol:()=>wI,_templateLiteral:()=>A8,_toLowerCase:()=>Iu,_toUpperCase:()=>Su,_transform:()=>b8,_trim:()=>xu,_tuple:()=>f8,_uint32:()=>mI,_uint64:()=>bI,_ulid:()=>hg,_undefined:()=>xI,_union:()=>u8,_unknown:()=>fp,_uppercase:()=>gu,_url:()=>pp,_uuid:()=>sg,_uuidv4:()=>cg,_uuidv6:()=>ug,_uuidv7:()=>lg,_void:()=>kI,_xid:()=>gg,_xor:()=>l8,clone:()=>lt,config:()=>bt,createStandardJSONSchemaMethod:()=>$u,createToJSONSchemaMethod:()=>zI,decode:()=>N5,decodeAsync:()=>j5,describe:()=>NI,encode:()=>R5,encodeAsync:()=>M5,extractDefs:()=>ga,finalize:()=>_a,flattenError:()=>Qd,formatError:()=>ep,globalConfig:()=>Gd,globalRegistry:()=>Be,initializeContext:()=>ha,isValidBase64:()=>d0,isValidBase64URL:()=>e1,isValidJWT:()=>t1,locales:()=>lp,meta:()=>MI,parse:()=>Ei,parseAsync:()=>bs,prettifyError:()=>Kw,process:()=>Ze,regexes:()=>vn,registry:()=>og,safeDecode:()=>D5,safeDecodeAsync:()=>U5,safeEncode:()=>z5,safeEncodeAsync:()=>L5,safeParse:()=>Ww,safeParseAsync:()=>Jw,toDotPath:()=>jN,toJSONSchema:()=>mo,treeifyError:()=>qw,util:()=>F,version:()=>Vx});var jw=Object.freeze({status:"aborted"});function I(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=a.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 i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(s){var c;let u=r?.Parent?new o:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Ph=Symbol("zod_brand"),Dn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ca=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Gd={};function bt(e){return e&&Object.assign(Gd,e),Gd}var F={};li(F,{BIGINT_FORMAT_RANGES:()=>Hw,Class:()=>Dw,NUMBER_FORMAT_RANGES:()=>Gw,aborted:()=>pa,allowsEval:()=>Fw,assert:()=>d5,assertEqual:()=>s5,assertIs:()=>u5,assertNever:()=>l5,assertNotEqual:()=>c5,assignProp:()=>la,base64ToUint8Array:()=>RN,base64urlToUint8Array:()=>T5,cached:()=>au,captureStackTrace:()=>Nh,cleanEnum:()=>$5,cleanRegex:()=>Kd,clone:()=>lt,cloneDef:()=>f5,createTransparentProxy:()=>v5,defineLazy:()=>Oe,esc:()=>Rh,escapeRegex:()=>yn,extend:()=>x5,finalizeIssue:()=>Rr,floatSafeRemainder:()=>Lw,getElementAtPath:()=>m5,getEnumValues:()=>qd,getLengthableOrigin:()=>Xd,getParsedType:()=>y5,getSizableOrigin:()=>Jd,hexToUint8Array:()=>O5,isObject:()=>vs,isPlainObject:()=>da,issue:()=>su,joinValues:()=>A,jsonStringifyReplacer:()=>ou,merge:()=>S5,mergeDefs:()=>po,normalizeParams:()=>q,nullish:()=>ua,numKeys:()=>_5,objectClone:()=>p5,omit:()=>w5,optionalKeys:()=>Zw,parsedType:()=>Z,partial:()=>k5,pick:()=>b5,prefixIssues:()=>Yr,primitiveTypes:()=>Vw,promiseAllObject:()=>h5,propertyKeyTypes:()=>Wd,randomString:()=>g5,required:()=>E5,safeExtend:()=>I5,shallowClone:()=>Bw,slugify:()=>Uw,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>NN,uint8ArrayToBase64url:()=>A5,uint8ArrayToHex:()=>C5,unwrapMessage:()=>Hd});function s5(e){return e}function c5(e){return e}function u5(e){}function l5(e){throw new Error("Unexpected value in exhaustive check")}function d5(e){}function qd(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function A(e,t="|"){return e.map(r=>U(r)).join(t)}function ou(e,t){return typeof t=="bigint"?t.toString():t}function au(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ua(e){return e==null}function Kd(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Lw(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){let c=n.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}let o=r>i?r:i,a=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return a%s/10**o}var PN=Symbol("evaluating");function Oe(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==PN)return n===void 0&&(n=PN,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function p5(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function la(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function po(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function f5(e){return po(e._zod.def)}function m5(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function h5(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function g5(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Rh(e){return JSON.stringify(e)}function Uw(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Nh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function vs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Fw=au(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function da(e){if(vs(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(vs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Bw(e){return da(e)?{...e}:Array.isArray(e)?[...e]:e}function _5(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var y5=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}`)}},Wd=new Set(["string","number","symbol"]),Vw=new Set(["string","number","bigint","boolean","symbol","undefined"]);function yn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function q(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 v5(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function U(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Zw(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Gw={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]},Hw={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function b5(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=po(e._zod.def,{get shape(){let a={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(a[s]=r.shape[s])}return la(this,"shape",a),a},checks:[]});return lt(e,o)}function w5(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=po(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete a[s]}return la(this,"shape",a),a},checks:[]});return lt(e,o)}function x5(e,t){if(!da(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=po(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return la(this,"shape",o),o}});return lt(e,i)}function I5(e,t){if(!da(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=po(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return la(this,"shape",n),n}});return lt(e,r)}function S5(e,t){let r=po(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return la(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return lt(e,r)}function k5(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=po(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 la(this,"shape",c),c},checks:[]});return lt(t,a)}function E5(e,t,r){let n=po(t._zod.def,{get shape(){let i=t._zod.def.shape,o={...i};if(r)for(let a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(o[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(let a in i)o[a]=new e({type:"nonoptional",innerType:i[a]});return la(this,"shape",o),o}});return lt(t,n)}function pa(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 Yr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Hd(e){return typeof e=="string"?e:e?.message}function Rr(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=Hd(e.inst?._zod.def?.error?.(e))??Hd(t?.error?.(e))??Hd(r.customError?.(e))??Hd(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Jd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Xd(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Z(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 su(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function $5(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function RN(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function NN(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function T5(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return RN(t+r)}function A5(e){return NN(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function O5(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 n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function C5(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Dw=class{constructor(...t){}};var MN=(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,ou,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Yd=I("$ZodError",MN),Nr=I("$ZodError",MN,{Parent:Error});function Qd(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function ep(e,t=r=>r.message){let r={_errors:[]},n=i=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>n({issues:a}));else if(o.code==="invalid_key")n({issues:o.issues});else if(o.code==="invalid_element")n({issues:o.issues});else if(o.path.length===0)r._errors.push(t(o));else{let a=r,s=0;for(;s<o.path.length;){let c=o.path[s];s===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(o))):a[c]=a[c]||{_errors:[]},a=a[c],s++}}};return n(e),r}function qw(e,t=r=>r.message){let r={errors:[]},n=(i,o=[])=>{var a,s;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>n({issues:u},c.path));else if(c.code==="invalid_key")n({issues:c.issues},c.path);else if(c.code==="invalid_element")n({issues:c.issues},c.path);else{let u=[...o,...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={}),(a=l.properties)[f]??(a[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 n(e),r}function jN(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function Kw(e){let t=[],r=[...e.issues].sort((n,i)=>(n.path??[]).length-(i.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${jN(n.path)}`);return t.join(`
|
|
63
|
+
`)}var cu=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Dn;if(a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>Rr(c,o,bt())));throw Nh(s,i?.callee),s}return a.value},Ei=cu(Nr),uu=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>Rr(c,o,bt())));throw Nh(s,i?.callee),s}return a.value},bs=uu(Nr),lu=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Dn;return o.issues.length?{success:!1,error:new(e??Yd)(o.issues.map(a=>Rr(a,i,bt())))}:{success:!0,data:o.value}},Ww=lu(Nr),du=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>Rr(a,i,bt())))}:{success:!0,data:o.value}},Jw=du(Nr),Mh=e=>(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return cu(e)(t,r,i)},R5=Mh(Nr),jh=e=>(t,r,n)=>cu(e)(t,r,n),N5=jh(Nr),zh=e=>async(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return uu(e)(t,r,i)},M5=zh(Nr),Dh=e=>async(t,r,n)=>uu(e)(t,r,n),j5=Dh(Nr),Lh=e=>(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return lu(e)(t,r,i)},z5=Lh(Nr),Uh=e=>(t,r,n)=>lu(e)(t,r,n),D5=Uh(Nr),Fh=e=>async(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return du(e)(t,r,i)},L5=Fh(Nr),Bh=e=>async(t,r,n)=>du(e)(t,r,n),U5=Bh(Nr);var vn={};li(vn,{base64:()=>px,base64url:()=>Vh,bigint:()=>yx,boolean:()=>bx,browserEmail:()=>K5,cidrv4:()=>lx,cidrv6:()=>dx,cuid:()=>Xw,cuid2:()=>Yw,date:()=>mx,datetime:()=>gx,domain:()=>X5,duration:()=>nx,e164:()=>fx,email:()=>ox,emoji:()=>ax,extendedDuration:()=>F5,guid:()=>ix,hex:()=>Y5,hostname:()=>J5,html5Email:()=>G5,idnEmail:()=>q5,integer:()=>vx,ipv4:()=>sx,ipv6:()=>cx,ksuid:()=>tx,lowercase:()=>Ix,mac:()=>ux,md5_base64:()=>eG,md5_base64url:()=>tG,md5_hex:()=>Q5,nanoid:()=>rx,null:()=>wx,number:()=>Zh,rfc5322Email:()=>H5,sha1_base64:()=>nG,sha1_base64url:()=>iG,sha1_hex:()=>rG,sha256_base64:()=>aG,sha256_base64url:()=>sG,sha256_hex:()=>oG,sha384_base64:()=>uG,sha384_base64url:()=>lG,sha384_hex:()=>cG,sha512_base64:()=>pG,sha512_base64url:()=>fG,sha512_hex:()=>dG,string:()=>_x,time:()=>hx,ulid:()=>Qw,undefined:()=>xx,unicodeEmail:()=>zN,uppercase:()=>Sx,uuid:()=>ws,uuid4:()=>B5,uuid6:()=>V5,uuid7:()=>Z5,xid:()=>ex});var Xw=/^[cC][^\s-]{8,}$/,Yw=/^[0-9a-z]+$/,Qw=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ex=/^[0-9a-vA-V]{20}$/,tx=/^[A-Za-z0-9]{27}$/,rx=/^[a-zA-Z0-9_-]{21}$/,nx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,F5=/^[-+]?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)?)??$/,ix=/^([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})$/,ws=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)$/,B5=ws(4),V5=ws(6),Z5=ws(7),ox=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,G5=/^[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])?)*$/,H5=/^(([^<>()\[\]\\.,;:\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,}))$/,zN=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,q5=zN,K5=/^[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])?)*$/,W5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ax(){return new RegExp(W5,"u")}var sx=/^(?:(?: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])$/,cx=/^(([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}|:))$/,ux=e=>{let t=yn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},lx=/^((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])$/,dx=/^(([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])$/,px=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vh=/^[A-Za-z0-9_-]*$/,J5=/^(?=.{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])?)*\.?$/,X5=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,fx=/^\+[1-9]\d{6,14}$/,DN="(?:(?:\\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])))",mx=new RegExp(`^${DN}$`);function LN(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 hx(e){return new RegExp(`^${LN(e)}$`)}function gx(e){let t=LN({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${DN}T(?:${n})$`)}var _x=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},yx=/^-?\d+n?$/,vx=/^-?\d+$/,Zh=/^-?\d+(?:\.\d+)?$/,bx=/^(?:true|false)$/i,wx=/^null$/i;var xx=/^undefined$/i;var Ix=/^[^A-Z]*$/,Sx=/^[^a-z]*$/,Y5=/^[0-9a-fA-F]*$/;function tp(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function rp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Q5=/^[0-9a-fA-F]{32}$/,eG=tp(22,"=="),tG=rp(22),rG=/^[0-9a-fA-F]{40}$/,nG=tp(27,"="),iG=rp(27),oG=/^[0-9a-fA-F]{64}$/,aG=tp(43,"="),sG=rp(43),cG=/^[0-9a-fA-F]{96}$/,uG=tp(64,""),lG=rp(64),dG=/^[0-9a-fA-F]{128}$/,pG=tp(86,"=="),fG=rp(86);var Qe=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),FN={number:"number",bigint:"bigint",object:"date"},Gh=I("$ZodCheckLessThan",(e,t)=>{Qe.init(e,t);let r=FN[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hh=I("$ZodCheckGreaterThan",(e,t)=>{Qe.init(e,t);let r=FN[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kx=I("$ZodCheckMultipleOf",(e,t)=>{Qe.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Lw(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})}}),Ex=I("$ZodCheckNumberFormat",(e,t)=>{Qe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Gw[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,r&&(s.pattern=vx)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),$x=I("$ZodCheckBigIntFormat",(e,t)=>{Qe.init(e,t);let[r,n]=Hw[t.format];e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,o.minimum=r,o.maximum=n}),e._zod.check=i=>{let o=i.value;o<r&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>n&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),Tx=I("$ZodCheckMaxSize",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;i.size<=t.maximum||n.issues.push({origin:Jd(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ax=I("$ZodCheckMinSize",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;i.size>=t.minimum||n.issues.push({origin:Jd(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ox=I("$ZodCheckSizeEquals",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=n=>{let i=n.value,o=i.size;if(o===t.size)return;let a=o>t.size;n.issues.push({origin:Jd(i),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cx=I("$ZodCheckMaxLength",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let a=Xd(i);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Px=I("$ZodCheckMinLength",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let a=Xd(i);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Rx=I("$ZodCheckLengthEquals",(e,t)=>{var r;Qe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!ua(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let a=Xd(i),s=o>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),pu=I("$ZodCheckStringFormat",(e,t)=>{var r,n;Qe.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Nx=I("$ZodCheckRegex",(e,t)=>{pu.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})}}),Mx=I("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ix),pu.init(e,t)}),jx=I("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sx),pu.init(e,t)}),zx=I("$ZodCheckIncludes",(e,t)=>{Qe.init(e,t);let r=yn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Dx=I("$ZodCheckStartsWith",(e,t)=>{Qe.init(e,t);let r=new RegExp(`^${yn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Lx=I("$ZodCheckEndsWith",(e,t)=>{Qe.init(e,t);let r=new RegExp(`.*${yn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function UN(e,t,r){e.issues.length&&t.issues.push(...Yr(r,e.issues))}var Ux=I("$ZodCheckProperty",(e,t)=>{Qe.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(i=>UN(i,r,t.property));UN(n,r,t.property)}}),Fx=I("$ZodCheckMimeType",(e,t)=>{Qe.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),Bx=I("$ZodCheckOverwrite",(e,t)=>{Qe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var np=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 n=t.split(`
|
|
64
|
+
`).filter(a=>a),i=Math.min(...n.map(a=>a.length-a.trimStart().length)),o=n.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...r,i.join(`
|
|
65
|
+
`))}};var Vx={major:4,minor:3,patch:6};var we=I("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vx;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,s,c)=>{let u=pa(a),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new Dn;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=pa(a,f)))});else{if(a.issues.length===f)continue;u||(u=pa(a,f))}}return l?l.then(()=>a):a},o=(a,s,c)=>{if(pa(a))return a.aborted=!0,a;let u=i(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new Dn;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>o(l,a,s)):o(u,a,s)}let c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new Dn;return c.then(u=>i(u,n,s))}return i(c,n,s)}}Oe(e,"~standard",()=>({validate:i=>{try{let o=Ww(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Jw(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),xs=I("$ZodString",(e,t)=>{we.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??_x(e._zod.bag),e._zod.parse=(r,n)=>{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}}),Ke=I("$ZodStringFormat",(e,t)=>{pu.init(e,t),xs.init(e,t)}),Gx=I("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ix),Ke.init(e,t)}),Hx=I("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ws(n))}else t.pattern??(t.pattern=ws());Ke.init(e,t)}),qx=I("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ox),Ke.init(e,t)}),Kx=I("$ZodURL",(e,t)=>{Ke.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Wx=I("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ax()),Ke.init(e,t)}),Jx=I("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=rx),Ke.init(e,t)}),Xx=I("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Xw),Ke.init(e,t)}),Yx=I("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yw),Ke.init(e,t)}),Qx=I("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qw),Ke.init(e,t)}),e0=I("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ex),Ke.init(e,t)}),t0=I("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tx),Ke.init(e,t)}),r0=I("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=gx(t)),Ke.init(e,t)}),n0=I("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=mx),Ke.init(e,t)}),i0=I("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hx(t)),Ke.init(e,t)}),o0=I("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nx),Ke.init(e,t)}),a0=I("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sx),Ke.init(e,t),e._zod.bag.format="ipv4"}),s0=I("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cx),Ke.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})}}}),c0=I("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=ux(t.delimiter)),Ke.init(e,t),e._zod.bag.format="mac"}),u0=I("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=lx),Ke.init(e,t)}),l0=I("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=dx),Ke.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[i,o]=n;if(!o)throw new Error;let a=Number(o);if(`${a}`!==o)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function d0(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var p0=I("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=px),Ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{d0(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function e1(e){if(!Vh.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return d0(r)}var f0=I("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Vh),Ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{e1(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),m0=I("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fx),Ke.init(e,t)});function t1(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var h0=I("$ZodJWT",(e,t)=>{Ke.init(e,t),e._zod.check=r=>{t1(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),g0=I("$ZodCustomStringFormat",(e,t)=>{Ke.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})}}),Yh=I("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zh,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),_0=I("$ZodNumberFormat",(e,t)=>{Ex.init(e,t),Yh.init(e,t)}),ip=I("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=bx,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),Qh=I("$ZodBigInt",(e,t)=>{we.init(e,t),e._zod.pattern=yx,e._zod.parse=(r,n)=>{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}}),y0=I("$ZodBigIntFormat",(e,t)=>{$x.init(e,t),Qh.init(e,t)}),v0=I("$ZodSymbol",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),r}}),b0=I("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=xx,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),r}}),w0=I("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=wx,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}}),x0=I("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),op=I("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),ap=I("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),I0=I("$ZodVoid",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),S0=I("$ZodDate",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function VN(e,t,r){e.issues.length&&t.issues.push(...Yr(r,e.issues)),t.value[r]=e.value}var k0=I("$ZodArray",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let s=i[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?o.push(c.then(u=>VN(u,r,a))):VN(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Xh(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...Yr(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function r1(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Zw(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function n1(e,t,r,n,i,o){let a=[],s=i.keySet,c=i.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in t){if(s.has(d))continue;if(u==="never"){a.push(d);continue}let f=c.run({value:t[d],issues:[]},n);f instanceof Promise?e.push(f.then(p=>Xh(p,r,d,t,l))):Xh(f,r,d,t,l)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var i1=I("$ZodObject",(e,t)=>{if(we.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 n=au(()=>r1(t));Oe(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 i=vs,o=t.catchall,a;e._zod.parse=(s,c)=>{a??(a=n.value);let u=s.value;if(!i(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=a.shape;for(let f of a.keys){let p=d[f],m=p._zod.optout==="optional",h=p._zod.run({value:u[f],issues:[]},c);h instanceof Promise?l.push(h.then(w=>Xh(w,s,f,u,m))):Xh(h,s,f,u,m)}return o?n1(l,u,s,c,n.value,e):l.length?Promise.all(l).then(()=>s):s}}),E0=I("$ZodObjectJIT",(e,t)=>{i1.init(e,t);let r=e._zod.parse,n=au(()=>r1(t)),i=f=>{let p=new np(["shape","payload","ctx"]),m=n.value,h=x=>{let S=Rh(x);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};p.write("const input = payload.value;");let w=Object.create(null),_=0;for(let x of m.keys)w[x]=`key_${_++}`;p.write("const newResult = {};");for(let x of m.keys){let S=w[x],$=Rh(x),C=f[x]?._zod?.optout==="optional";p.write(`const ${S} = ${h(x)};`),C?p.write(`
|
|
66
|
+
if (${S}.issues.length) {
|
|
67
|
+
if (${$} in input) {
|
|
68
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
69
|
+
...iss,
|
|
70
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
71
|
+
})));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (${S}.value === undefined) {
|
|
76
|
+
if (${$} in input) {
|
|
77
|
+
newResult[${$}] = undefined;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
newResult[${$}] = ${S}.value;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
`):p.write(`
|
|
84
|
+
if (${S}.issues.length) {
|
|
85
|
+
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
86
|
+
...iss,
|
|
87
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
88
|
+
})));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (${S}.value === undefined) {
|
|
92
|
+
if (${$} in input) {
|
|
93
|
+
newResult[${$}] = undefined;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
newResult[${$}] = ${S}.value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(x,S)=>y(f,x,S)},o,a=vs,s=!Gd.jitless,u=s&&Fw.value,l=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=n.value);let m=f.value;return a(m)?s&&u&&p?.async===!1&&p.jitless!==!0?(o||(o=i(t.shape)),f=o(f,p),l?n1([],m,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function ZN(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!pa(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>Rr(a,n,bt())))}),t)}var sp=I("$ZodUnion",(e,t)=>{we.init(e,t),Oe(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Oe(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Oe(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Oe(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Kd(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:i.value,issues:[]},o);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>ZN(c,i,e,o)):ZN(s,i,e,o)}});function GN(e,t,r,n){let i=e.filter(o=>o.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>Rr(a,n,bt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var $0=I("$ZodXor",(e,t)=>{sp.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:i.value,issues:[]},o);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(c=>GN(c,i,e,o)):GN(s,i,e,o)}}),T0=I("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,sp.init(e,t);let r=e._zod.parse;Oe(e._zod,"propValues",()=>{let i={};for(let o of t.options){let a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[s,c]of Object.entries(a)){i[s]||(i[s]=new Set);for(let u of c)i[s].add(u)}}return i});let n=au(()=>{let i=t.options,o=new Map;for(let a of i){let s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of s){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,a)}}return o});e._zod.parse=(i,o)=>{let a=i.value;if(!vs(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),A0=I("$ZodIntersection",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),a=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,u])=>HN(r,c,u)):HN(r,o,a)}});function Zx(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(da(e)&&da(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let a=Zx(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};i[o]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],a=Zx(i,o);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function HN(e,t,r){let n=new Map,i;for(let s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.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)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let o=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),pa(e))return e;let a=Zx(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var eg=I("$ZodTuple",(e,t)=>{we.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],s=[...r].reverse().findIndex(l=>l._zod.optin!=="optional"),c=s===-1?0:r.length-s;if(!t.rest){let l=o.length>r.length,d=o.length<c-1;if(l||d)return n.issues.push({...l?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:e,origin:"array"}),n}let u=-1;for(let l of r){if(u++,u>=o.length&&u>=c)continue;let d=l._zod.run({value:o[u],issues:[]},i);d instanceof Promise?a.push(d.then(f=>qh(f,n,u))):qh(d,n,u)}if(t.rest){let l=o.slice(r.length);for(let d of l){u++;let f=t.rest._zod.run({value:d,issues:[]},i);f instanceof Promise?a.push(f.then(p=>qh(p,n,u))):qh(f,n,u)}}return a.length?Promise.all(a).then(()=>n):n}});function qh(e,t,r){e.issues.length&&t.issues.push(...Yr(r,e.issues)),t.value[r]=e.value}var O0=I("$ZodRecord",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!da(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[],a=t.keyType._zod.values;if(a){r.value={};let s=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.valueType._zod.run({value:i[u],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...Yr(u,d.issues)),r.value[u]=d.value})):(l.issues.length&&r.issues.push(...Yr(u,l.issues)),r.value[u]=l.value)}let c;for(let u in i)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Zh.test(s)&&c.issues.length){let d=t.keyType._zod.run({value:Number(s),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=i[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Rr(d,n,bt())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...Yr(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Yr(s,l.issues)),r.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>r):r}}),C0=I("$ZodMap",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let o=[];r.value=new Map;for(let[a,s]of i){let c=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||u instanceof Promise?o.push(Promise.all([c,u]).then(([l,d])=>{qN(l,d,r,a,i,e,n)})):qN(c,u,r,a,i,e,n)}return o.length?Promise.all(o).then(()=>r):r}});function qN(e,t,r,n,i,o,a){e.issues.length&&(Wd.has(typeof n)?r.issues.push(...Yr(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(s=>Rr(s,a,bt()))})),t.issues.length&&(Wd.has(typeof n)?r.issues.push(...Yr(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:t.issues.map(s=>Rr(s,a,bt()))})),r.value.set(e.value,t.value)}var P0=I("$ZodSet",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let a of i){let s=t.valueType._zod.run({value:a,issues:[]},n);s instanceof Promise?o.push(s.then(c=>KN(c,r))):KN(s,r)}return o.length?Promise.all(o).then(()=>r):r}});function KN(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var R0=I("$ZodEnum",(e,t)=>{we.init(e,t);let r=qd(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>Wd.has(typeof i)).map(i=>typeof i=="string"?yn(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let a=i.value;return n.has(a)||i.issues.push({code:"invalid_value",values:r,input:a,inst:e}),i}}),N0=I("$ZodLiteral",(e,t)=>{if(we.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(n=>typeof n=="string"?yn(n):n?yn(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),M0=I("$ZodFile",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),j0=I("$ZodTransform",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ca(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(r.value=a,r));if(i instanceof Promise)throw new Dn;return r.value=i,r}});function WN(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Is=I("$ZodOptional",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Kd(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>WN(o,r.value)):WN(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),z0=I("$ZodExactOptional",(e,t)=>{Is.init(e,t),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),D0=I("$ZodNullable",(e,t)=>{we.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Kd(r.source)}|null)$`):void 0}),Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),L0=I("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>JN(o,t)):JN(i,t)}});function JN(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var U0=I("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),F0=I("$ZodNonOptional",(e,t)=>{we.init(e,t),Oe(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>XN(o,e)):XN(i,e)}});function XN(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 B0=I("$ZodSuccess",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ca("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),V0=I("$ZodCatch",(e,t)=>{we.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Rr(a,n,bt()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>Rr(o,n,bt()))},input:r.value}),r.issues=[]),r)}}),Z0=I("$ZodNaN",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),G0=I("$ZodPipe",(e,t)=>{we.init(e,t),Oe(e._zod,"values",()=>t.in._zod.values),Oe(e._zod,"optin",()=>t.in._zod.optin),Oe(e._zod,"optout",()=>t.out._zod.optout),Oe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Kh(a,t.in,n)):Kh(o,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Kh(o,t.out,n)):Kh(i,t.out,n)}});function Kh(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var cp=I("$ZodCodec",(e,t)=>{we.init(e,t),Oe(e._zod,"values",()=>t.in._zod.values),Oe(e._zod,"optin",()=>t.in._zod.optin),Oe(e._zod,"optout",()=>t.out._zod.optout),Oe(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(a=>Wh(a,t,n)):Wh(o,t,n)}else{let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Wh(a,t,n)):Wh(o,t,n)}}});function Wh(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Jh(e,o,t.out,r)):Jh(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Jh(e,o,t.in,r)):Jh(e,i,t.in,r)}}function Jh(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var H0=I("$ZodReadonly",(e,t)=>{we.init(e,t),Oe(e._zod,"propValues",()=>t.innerType._zod.propValues),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"optin",()=>t.innerType?._zod?.optin),Oe(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(YN):YN(i)}});function YN(e){return e.value=Object.freeze(e.value),e}var q0=I("$ZodTemplateLiteral",(e,t)=>{we.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let o=i.startsWith("^")?1:0,a=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(o,a))}else if(n===null||Vw.has(typeof n))r.push(yn(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),K0=I("$ZodFunction",(e,t)=>(we.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(...n){let i=e._def.input?Ei(e._def.input,n):n,o=Reflect.apply(r,this,i);return e._def.output?Ei(e._def.output,o):o}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await bs(e._def.input,n):n,o=await Reflect.apply(r,this,i);return e._def.output?await bs(e._def.output,o):o}},e._zod.parse=(r,n)=>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 n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new eg({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),W0=I("$ZodPromise",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),J0=I("$ZodLazy",(e,t)=>{we.init(e,t),Oe(e._zod,"innerType",()=>t.getter()),Oe(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Oe(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Oe(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Oe(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),X0=I("$ZodCustom",(e,t)=>{Qe.init(e,t),we.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>QN(o,r,n,e));QN(i,r,n,e)}});function QN(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(su(i))}}var lp={};li(lp,{ar:()=>o1,az:()=>a1,be:()=>c1,bg:()=>u1,ca:()=>l1,cs:()=>d1,da:()=>p1,de:()=>f1,en:()=>tg,eo:()=>m1,es:()=>h1,fa:()=>g1,fi:()=>_1,fr:()=>y1,frCA:()=>v1,he:()=>b1,hu:()=>w1,hy:()=>I1,id:()=>S1,is:()=>k1,it:()=>E1,ja:()=>$1,ka:()=>T1,kh:()=>A1,km:()=>rg,ko:()=>O1,lt:()=>P1,mk:()=>R1,ms:()=>N1,nl:()=>M1,no:()=>j1,ota:()=>z1,pl:()=>L1,ps:()=>D1,pt:()=>U1,ru:()=>B1,sl:()=>V1,sv:()=>Z1,ta:()=>G1,th:()=>H1,tr:()=>q1,ua:()=>K1,uk:()=>ng,ur:()=>W1,uz:()=>J1,vi:()=>X1,yo:()=>eM,zhCN:()=>Y1,zhTW:()=>Q1});var hG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return i.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 ${U(i.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: ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()} ${a.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 ${i.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${i.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${i.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${i.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${i.keys.length>1?"\u0629":""}: ${A(i.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${i.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 ${i.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function o1(){return{localeError:hG()}}var gG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${s}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${U(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??i.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${i.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${i.keys.length>1?"lar":""}: ${A(i.keys,", ")}`;case"invalid_key":return`${i.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${i.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function a1(){return{localeError:gG()}}function s1(e,t,r,n){let i=Math.abs(e),o=i%10,a=i%100;return a>=11&&a<=19?n:o===1?t:o>=2&&o<=4?r:n}var _G=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${i.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 ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=s1(s,a.unit.one,a.unit.few,a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${i.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 ${i.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=s1(s,a.unit.one,a.unit.few,a.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 ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${i.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 ${i.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${i.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${A(i.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${i.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 ${i.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function c1(){return{localeError:_G()}}var yG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${i.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${i.minimum.toString()} ${a.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${i.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;if(o.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 "${o.prefix}"`;if(o.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 "${o.suffix}"`;if(o.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 "${o.includes}"`;if(o.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 ${o.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${i.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u043E\u0432\u0435":""}: ${A(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${i.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 ${i.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function u1(){return{localeError:yG()}}var vG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${s}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${U(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${A(i.values," o ")}`;case"too_big":{let o=i.inclusive?"com a m\xE0xim":"menys de",a=t(i.origin);return a?`Massa gran: s'esperava que ${i.origin??"el valor"} contingu\xE9s ${o} ${i.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(i.origin);return a?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${o} ${i.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${i.divisor}`;case"unrecognized_keys":return`Clau${i.keys.length>1?"s":""} no reconeguda${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${i.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${i.origin}`;default:return"Entrada inv\xE0lida"}}};function l1(){return{localeError:vG()}}var bG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${s}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${U(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${o}${i.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??i.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${i.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${A(i.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${i.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${i.origin}`;default:return"Neplatn\xFD vstup"}}};function d1(){return{localeError:bG()}}var wG=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(i){return e[i]??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"},n={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${s}`:`Ugyldigt input: forventede ${o}, fik ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${U(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=n[i.origin]??i.origin;return a?`For stor: forventede ${s??"value"} ${a.verb} ${o} ${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=n[i.origin]??i.origin;return a?`For lille: forventede ${s} ${a.verb} ${o} ${i.minimum.toString()} ${a.unit}`:`For lille: forventede ${s} havde ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${A(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${i.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${i.origin}`;default:return"Ugyldigt input"}}};function p1(){return{localeError:wG()}}var xG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${s}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${U(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${o}${i.maximum.toString()} ist`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${o}${i.minimum.toString()} ist`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${i.divisor} sein`;case"unrecognized_keys":return`${i.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${A(i.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${i.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${i.origin}`;default:return"Ung\xFCltige Eingabe"}}};function f1(){return{localeError:xG()}}var IG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return`Invalid input: expected ${o}, received ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${U(i.values[0])}`:`Invalid option: expected one of ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${o}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${o}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function tg(){return{localeError:IG()}}var SG=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${s}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${U(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${o}${i.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??i.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${i.divisor}`;case"unrecognized_keys":return`Nekonata${i.keys.length>1?"j":""} \u015Dlosilo${i.keys.length>1?"j":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${i.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${i.origin}`;default:return"Nevalida enigo"}}};function m1(){return{localeError:SG()}}var kG=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${U(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${o}${i.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=n[i.origin]??i.origin;return a?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${o}${i.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??i.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Llave${i.keys.length>1?"s":""} desconocida${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${n[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${n[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function h1(){return{localeError:kG()}}var EG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${i.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 ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return i.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${U(i.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 ${A(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${i.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??i.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 ${i.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${i.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${A(i.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${i.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 ${i.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function g1(){return{localeError:EG()}}var $G=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${s}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${U(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${o}${i.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${o}${i.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??i.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${i.divisor} monikerta`;case"unrecognized_keys":return`${i.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${A(i.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 _1(){return{localeError:$G()}}var TG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"nombre",array:"tableau"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${s} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${U(i.values[0])} attendu`:`Option invalide : une valeur parmi ${A(i.values,"|")} attendue`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Trop grand : ${i.origin??"valeur"} doit ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i.origin??"valeur"} doit \xEAtre ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Trop petit : ${i.origin} doit ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Trop petit : ${i.origin} doit \xEAtre ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${A(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function y1(){return{localeError:TG()}}var AG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${s}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${U(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u2264":"<",a=t(i.origin);return a?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${o}${i.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u2265":">",a=t(i.origin);return a?`Trop petit : attendu que ${i.origin} ait ${o}${i.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${i.origin} soit ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??i.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${i.divisor}`;case"unrecognized_keys":return`Cl\xE9${i.keys.length>1?"s":""} non reconnue${i.keys.length>1?"s":""} : ${A(i.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${i.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${i.origin}`;default:return"Entr\xE9e invalide"}}};function v1(){return{localeError:AG()}}var OG=()=>{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,n=u=>{let l=r(u);return l?l.label:u??e.unknown.label},i=u=>`\u05D4${n(u)}`,o=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",a=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??""]??n(l),f=Z(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 ${U(u.values[0])}`;let l=u.values.map(p=>U(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=a(u.origin),d=i(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",h=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 ${h}`.trim()}let f=u.inclusive?"<=":"<",p=o(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=a(u.origin),d=i(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 w=(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 ${w}`}let h=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 ${h}`.trim()}let f=u.inclusive?">=":">",p=o(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"}: ${A(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${i(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function b1(){return{localeError:OG()}}var CG=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${U(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${i.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${o}${i.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??i.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${i.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${i.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${i.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function w1(){return{localeError:CG()}}function x1(e,t,r){return Math.abs(e)===1?t:r}function fu(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 PG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=x1(s,a.unit.one,a.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 ${fu(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.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 ${fu(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=x1(s,a.unit.one,a.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 ${fu(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${i.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 ${fu(i.origin)} \u056C\u056B\u0576\u056B ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.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 ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??i.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 ${i.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${i.keys.length>1?"\u0576\u0565\u0580":""}. ${A(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${fu(i.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 ${fu(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function I1(){return{localeError:PG()}}var RG=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${o}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${U(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${o}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: diharapkan ${i.origin} memiliki ${o}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??i.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${i.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${i.origin}`;default:return"Input tidak valid"}}};function S1(){return{localeError:RG()}}var NG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${U(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${o}${i.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${o}${i.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??i.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${i.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${i.keys.length>1?"ir lyklar":"ur lykill"}: ${A(i.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${i.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${i.origin}`;default:return"Rangt gildi"}}};function k1(){return{localeError:NG()}}var MG=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${s}`:`Input non valido: atteso ${o}, ricevuto ${s}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${U(i.values[0])}`:`Opzione non valida: atteso uno tra ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Troppo grande: ${i.origin??"valore"} deve avere ${o}${i.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Troppo piccolo: ${i.origin} deve avere ${o}${i.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${i.origin} deve essere ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${i.divisor}`;case"unrecognized_keys":return`Chiav${i.keys.length>1?"i":"e"} non riconosciut${i.keys.length>1?"e":"a"}: ${A(i.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${i.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${i.origin}`;default:return"Input non valido"}}};function E1(){return{localeError:MG()}}var jG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${i.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: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${U(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${A(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=i.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(i.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${a.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=i.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(i.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${a.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${i.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${i.keys.length>1?"\u7FA4":""}: ${A(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${i.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function $1(){return{localeError:jG()}}var zG=()=>{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(i){return e[i]??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 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},n={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\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 ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.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 ${i.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\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 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??i.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 ${i.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${i.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${A(i.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${i.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 ${i.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function T1(){return{localeError:zG()}}var DG=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${A(i.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 ${i.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 ${i.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 rg(){return{localeError:DG()}}function A1(){return rg()}var LG=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${i.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${U(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${A(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${o}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${o}${a}`}case"too_small":{let o=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(i.origin),c=s?.unit??"\uC694\uC18C";return s?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${o}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${o}${a}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??i.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${i.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${A(i.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${i.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${i.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function O1(){return{localeError:LG()}}var up=e=>e.charAt(0).toUpperCase()+e.slice(1);function C1(e){let t=Math.abs(e),r=t%10,n=t%100;return n>=11&&n<=19||r===0?"many":r===1?"one":"few"}var UG=()=>{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(i,o,a,s){let c=e[i]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[s][a?"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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${o}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${U(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${A(i.values,"|")} pasirinkim\u0173`;case"too_big":{let o=n[i.origin]??i.origin,a=t(i.origin,C1(Number(i.maximum)),i.inclusive??!1,"smaller");if(a?.verb)return`${up(o??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.maximum.toString()} ${a.unit??"element\u0173"}`;let s=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${up(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.maximum.toString()} ${a?.unit}`}case"too_small":{let o=n[i.origin]??i.origin,a=t(i.origin,C1(Number(i.minimum)),i.inclusive??!1,"bigger");if(a?.verb)return`${up(o??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.minimum.toString()} ${a.unit??"element\u0173"}`;let s=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${up(o??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${i.minimum.toString()} ${a?.unit}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??i.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${i.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${i.keys.length>1?"i":"as"} rakt${i.keys.length>1?"ai":"as"}: ${A(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=n[i.origin]??i.origin;return`${up(o??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function P1(){return{localeError:UG()}}var FG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${i.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 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${i.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`Invalid ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`${i.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"}: ${A(i.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${i.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 ${i.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function R1(){return{localeError:FG()}}var BG=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${s}`:`Input tidak sah: dijangka ${o}, diterima ${s}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${U(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: dijangka ${i.origin??"nilai"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: dijangka ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${A(i.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${i.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${i.origin}`;default:return"Input tidak sah"}}};function N1(){return{localeError:BG()}}var VG=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${o}, ontving ${s}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${U(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin),s=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return a?`Te ${s}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${s}: verwacht dat ${i.origin??"waarde"} ${o}${i.maximum.toString()} is`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin),s=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return a?`Te ${s}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${s}: verwacht dat ${i.origin} ${o}${i.minimum.toString()} is`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??i.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${i.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${i.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${i.origin}`;default:return"Ongeldige invoer"}}};function M1(){return{localeError:VG()}}var ZG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${s}`:`Ugyldig input: forventet ${o}, fikk ${s}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${U(i.values[0])}`:`Ugyldig valg: forventet en av ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??i.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${A(i.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${i.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${i.origin}`;default:return"Ugyldig input"}}};function j1(){return{localeError:ZG()}}var GG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${U(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${o}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${o}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=i;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??i.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${i.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${i.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function z1(){return{localeError:GG()}}var HG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${i.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 ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return i.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${U(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${A(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${i.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${o}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??i.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${i.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${i.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${A(i.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${i.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 ${i.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function D1(){return{localeError:HG()}}var qG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${s}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${U(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${i.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??i.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${i.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${i.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${i.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function L1(){return{localeError:qG()}}var KG=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${s}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${s}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${U(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${o}${i.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Muito pequeno: esperado que ${i.origin} tivesse ${o}${i.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??i.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${i.divisor}`;case"unrecognized_keys":return`Chave${i.keys.length>1?"s":""} desconhecida${i.keys.length>1?"s":""}: ${A(i.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${i.origin}`;default:return"Campo inv\xE1lido"}}};function U1(){return{localeError:KG()}}function F1(e,t,r,n){let i=Math.abs(e),o=i%10,a=i%100;return a>=11&&a<=19?n:o===1?t:o>=2&&o<=4?r:n}var WG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${i.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 ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return i.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);if(a){let s=Number(i.maximum),c=F1(s,a.unit.one,a.unit.few,a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);if(a){let s=Number(i.minimum),c=F1(s,a.unit.one,a.unit.few,a.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 ${i.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${i.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 ${i.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${i.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0438":""}: ${A(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${i.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 ${i.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 B1(){return{localeError:WG()}}var JG=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${s}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${U(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${o}${i.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${o}${i.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??i.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${i.divisor}`;case"unrecognized_keys":return`Neprepoznan${i.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${A(i.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${i.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${i.origin}`;default:return"Neveljaven vnos"}}};function V1(){return{localeError:JG()}}var XG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${s}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${U(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??i.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${i.divisor}`;case"unrecognized_keys":return`${i.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${A(i.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${i.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${i.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function Z1(){return{localeError:XG()}}var YG=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\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 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\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 ${i.origin} ${o}${i.minimum.toString()} ${a.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 ${i.origin} ${o}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.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[o.format]??i.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${i.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${i.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${A(i.keys,", ")}`;case"invalid_key":return`${i.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`${i.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 G1(){return{localeError:YG()}}var QG=()=>{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(i){return e[i]??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"},n={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 i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return i.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(i.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(i.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${i.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.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 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??i.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 ${i.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: ${A(i.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${i.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 ${i.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function H1(){return{localeError:QG()}}var e8=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${s}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${U(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??i.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${i.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${i.keys.length>1?"lar":""}: ${A(i.keys,", ")}`;case"invalid_key":return`${i.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${i.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function q1(){return{localeError:e8()}}var t8=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.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 ${i.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 ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return i.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 ${U(i.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 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${o}${i.maximum.toString()} ${a.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 ${i.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${i.origin} \u0431\u0443\u0434\u0435 ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.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 "${o.suffix}"`:o.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 "${o.includes}"`:o.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 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${i.keys.length>1?"\u0456":""}: ${A(i.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${i.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 ${i.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 ng(){return{localeError:t8()}}function K1(){return ng()}var r8=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${i.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: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${U(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${A(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${i.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${o}${i.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u0627 ${o}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${i.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${i.keys.length>1?"\u0632":""}: ${A(i.keys,"\u060C ")}`;case"invalid_key":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${i.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function W1(){return{localeError:r8()}}var n8=()=>{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"}};function t(i){return e[i]??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"},n={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${s}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${U(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??i.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${i.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${i.keys.length>1?"lar":""}: ${A(i.keys,", ")}`;case"invalid_key":return`${i.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${i.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function J1(){return{localeError:n8()}}var i8=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${i.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${U(i.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${o}${i.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${a.verb} ${o}${i.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${A(i.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${i.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 ${i.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function X1(){return{localeError:i8()}}var o8=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${U(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??i.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${i.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${A(i.keys,", ")}`;case"invalid_key":return`${i.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${i.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function Y1(){return{localeError:o8()}}var a8=()=>{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(i){return e[i]??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"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${i.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${U(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??i.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${i.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${i.keys.length>1?"\u5011":""}\uFF1A${A(i.keys,"\u3001")}`;case"invalid_key":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${i.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function Q1(){return{localeError:a8()}}var s8=()=>{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(i){return e[i]??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"},n={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=Z(i.input),s=n[a]??a;return/^[A-Z]/.test(i.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${i.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${U(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${A(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin??"iye"} ${a.verb} ${o}${i.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.maximum}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${i.origin} ${a.verb} ${o}${i.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${i.minimum}`}case"invalid_format":{let o=i;return o.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 "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??i.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 ${i.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${A(i.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${i.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 ${i.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function eM(){return{localeError:s8()}}var tM,Y0=Symbol("ZodOutput"),Q0=Symbol("ZodInput"),ig=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){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 n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function og(){return new ig}(tM=globalThis).__zod_globalRegistry??(tM.__zod_globalRegistry=og());var Be=globalThis.__zod_globalRegistry;function eI(e,t){return new e({type:"string",...q(t)})}function tI(e,t){return new e({type:"string",coerce:!0,...q(t)})}function ag(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...q(t)})}function dp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...q(t)})}function sg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...q(t)})}function cg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(t)})}function ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(t)})}function lg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(t)})}function pp(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...q(t)})}function dg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...q(t)})}function pg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(t)})}function fg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...q(t)})}function mg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(t)})}function hg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...q(t)})}function gg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...q(t)})}function _g(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(t)})}function yg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(t)})}function vg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(t)})}function rI(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...q(t)})}function bg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(t)})}function wg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(t)})}function xg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...q(t)})}function Ig(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...q(t)})}function Sg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...q(t)})}function kg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...q(t)})}var nI={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function iI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(t)})}function oI(e,t){return new e({type:"string",format:"date",check:"string_format",...q(t)})}function aI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...q(t)})}function sI(e,t){return new e({type:"string",format:"duration",check:"string_format",...q(t)})}function cI(e,t){return new e({type:"number",checks:[],...q(t)})}function uI(e,t){return new e({type:"number",coerce:!0,checks:[],...q(t)})}function lI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...q(t)})}function dI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...q(t)})}function pI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...q(t)})}function fI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...q(t)})}function mI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...q(t)})}function hI(e,t){return new e({type:"boolean",...q(t)})}function gI(e,t){return new e({type:"boolean",coerce:!0,...q(t)})}function _I(e,t){return new e({type:"bigint",...q(t)})}function yI(e,t){return new e({type:"bigint",coerce:!0,...q(t)})}function vI(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...q(t)})}function bI(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...q(t)})}function wI(e,t){return new e({type:"symbol",...q(t)})}function xI(e,t){return new e({type:"undefined",...q(t)})}function II(e,t){return new e({type:"null",...q(t)})}function SI(e){return new e({type:"any"})}function fp(e){return new e({type:"unknown"})}function mp(e,t){return new e({type:"never",...q(t)})}function kI(e,t){return new e({type:"void",...q(t)})}function EI(e,t){return new e({type:"date",...q(t)})}function $I(e,t){return new e({type:"date",coerce:!0,...q(t)})}function TI(e,t){return new e({type:"nan",...q(t)})}function $i(e,t){return new Gh({check:"less_than",...q(t),value:e,inclusive:!1})}function Qr(e,t){return new Gh({check:"less_than",...q(t),value:e,inclusive:!0})}function Ti(e,t){return new Hh({check:"greater_than",...q(t),value:e,inclusive:!1})}function wr(e,t){return new Hh({check:"greater_than",...q(t),value:e,inclusive:!0})}function Eg(e){return Ti(0,e)}function $g(e){return $i(0,e)}function Tg(e){return Qr(0,e)}function Ag(e){return wr(0,e)}function fa(e,t){return new kx({check:"multiple_of",...q(t),value:e})}function ma(e,t){return new Tx({check:"max_size",...q(t),maximum:e})}function Ai(e,t){return new Ax({check:"min_size",...q(t),minimum:e})}function Ss(e,t){return new Ox({check:"size_equals",...q(t),size:e})}function ks(e,t){return new Cx({check:"max_length",...q(t),maximum:e})}function fo(e,t){return new Px({check:"min_length",...q(t),minimum:e})}function Es(e,t){return new Rx({check:"length_equals",...q(t),length:e})}function mu(e,t){return new Nx({check:"string_format",format:"regex",...q(t),pattern:e})}function hu(e){return new Mx({check:"string_format",format:"lowercase",...q(e)})}function gu(e){return new jx({check:"string_format",format:"uppercase",...q(e)})}function _u(e,t){return new zx({check:"string_format",format:"includes",...q(t),includes:e})}function yu(e,t){return new Dx({check:"string_format",format:"starts_with",...q(t),prefix:e})}function vu(e,t){return new Lx({check:"string_format",format:"ends_with",...q(t),suffix:e})}function Og(e,t,r){return new Ux({check:"property",property:e,schema:t,...q(r)})}function bu(e,t){return new Fx({check:"mime_type",mime:e,...q(t)})}function Ln(e){return new Bx({check:"overwrite",tx:e})}function wu(e){return Ln(t=>t.normalize(e))}function xu(){return Ln(e=>e.trim())}function Iu(){return Ln(e=>e.toLowerCase())}function Su(){return Ln(e=>e.toUpperCase())}function ku(){return Ln(e=>Uw(e))}function AI(e,t,r){return new e({type:"array",element:t,...q(r)})}function u8(e,t,r){return new e({type:"union",options:t,...q(r)})}function l8(e,t,r){return new e({type:"union",options:t,inclusive:!1,...q(r)})}function d8(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...q(n)})}function p8(e,t,r){return new e({type:"intersection",left:t,right:r})}function f8(e,t,r,n){let i=r instanceof we,o=i?n:r,a=i?r:null;return new e({type:"tuple",items:t,rest:a,...q(o)})}function m8(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...q(n)})}function h8(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...q(n)})}function g8(e,t,r){return new e({type:"set",valueType:t,...q(r)})}function _8(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:n,...q(r)})}function y8(e,t,r){return new e({type:"enum",entries:t,...q(r)})}function v8(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...q(r)})}function OI(e,t){return new e({type:"file",...q(t)})}function b8(e,t){return new e({type:"transform",transform:t})}function w8(e,t){return new e({type:"optional",innerType:t})}function x8(e,t){return new e({type:"nullable",innerType:t})}function I8(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Bw(r)}})}function S8(e,t,r){return new e({type:"nonoptional",innerType:t,...q(r)})}function k8(e,t){return new e({type:"success",innerType:t})}function E8(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function $8(e,t,r){return new e({type:"pipe",in:t,out:r})}function T8(e,t){return new e({type:"readonly",innerType:t})}function A8(e,t,r){return new e({type:"template_literal",parts:t,...q(r)})}function O8(e,t){return new e({type:"lazy",getter:t})}function C8(e,t){return new e({type:"promise",innerType:t})}function CI(e,t,r){let n=q(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function PI(e,t,r){return new e({type:"custom",check:"custom",fn:t,...q(r)})}function RI(e){let t=rM(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(su(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(su(i))}},e(r.value,r)));return t}function rM(e,t){let r=new Qe({check:"custom",...q(t)});return r._zod.check=e,r}function NI(e){let t=new Qe({check:"describe"});return t._zod.onattach=[r=>{let n=Be.get(r)??{};Be.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function MI(e){let t=new Qe({check:"meta"});return t._zod.onattach=[r=>{let n=Be.get(r)??{};Be.add(r,{...n,...e})}],t._zod.check=()=>{},t}function jI(e,t){let r=q(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(p=>typeof p=="string"?p.toLowerCase():p),i=i.map(p=>typeof p=="string"?p.toLowerCase():p));let o=new Set(n),a=new Set(i),s=e.Codec??cp,c=e.Boolean??ip,u=e.String??xs,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 h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:a.has(h)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:m.value,inst:f,continue:!1}),{})}),reverseTransform:((p,m)=>p===!0?n[0]||"true":i[0]||"false"),error:r.error});return f}function Eu(e,t,r,n={}){let i=q(n),o={...q(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...i};return r instanceof RegExp&&(o.pattern=r),new e(o)}function ha(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??Be,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 Ze(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let f=a.schema,p=t.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),Ze(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&xr(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function ga(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}let i=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=p,{defId:p,ref:`${f("__shared")}#/${s}/${p}`}}if(a[1]===r)return{ref:"#"};let u=`#/${s}/`,l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=i(a);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 a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
100
|
+
|
|
101
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&e.reused==="ref"){o(a);continue}}}function _a(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let s=e.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let f=e.seen.get(l),p=f.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):Object.assign(c,p),Object.assign(c,u),a._zod.parent===l)for(let h in c)h==="$ref"||h==="allOf"||h in u||delete c[h];if(p.$ref&&f.def)for(let h in c)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(c[h])===JSON.stringify(f.def[h])&&delete c[h]}let d=a._zod.parent;if(d&&d!==l){n(d);let f=e.seen.get(d);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(let p in c)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(c[p])===JSON.stringify(f.def[p])&&delete c[p]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}Object.assign(i,r.def??r.schema);let o=e.external?.defs??{};for(let a of e.seen.entries()){let s=a[1];s.def&&s.defId&&(o[s.defId]=s.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:$u(t,"input",e.processors),output:$u(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function xr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return xr(n.element,r);if(n.type==="set")return xr(n.valueType,r);if(n.type==="lazy")return xr(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return xr(n.innerType,r);if(n.type==="intersection")return xr(n.left,r)||xr(n.right,r);if(n.type==="record"||n.type==="map")return xr(n.keyType,r)||xr(n.valueType,r);if(n.type==="pipe")return xr(n.in,r)||xr(n.out,r);if(n.type==="object"){for(let i in n.shape)if(xr(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(xr(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(xr(i,r))return!0;return!!(n.rest&&xr(n.rest,r))}return!1}var zI=(e,t={})=>r=>{let n=ha({...r,processors:t});return Ze(e,n),ga(n,e),_a(n,e)},$u=(e,t,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},a=ha({...i??{},target:o,io:t,processors:r});return Ze(e,a),ga(a,e),_a(a,e)};var P8={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},DI=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof a=="number"&&(i.maxLength=a),s&&(i.format=P8[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},LI=(e,t,r,n)=>{let i=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l),typeof o=="number"&&(i.minimum=o,typeof l=="number"&&t.target!=="draft-04"&&(l>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},UI=(e,t,r,n)=>{r.type="boolean"},FI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},BI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},VI=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ZI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},GI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},HI=(e,t,r,n)=>{r.not={}},qI=(e,t,r,n)=>{},KI=(e,t,r,n)=>{},WI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},JI=(e,t,r,n)=>{let i=e._zod.def,o=qd(i.entries);o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},XI=(e,t,r,n)=>{let i=e._zod.def,o=[];for(let a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},YI=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},QI=(e,t,r,n)=>{let i=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},eS=(e,t,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,o)},tS=(e,t,r,n)=>{r.type="boolean"},rS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},nS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},iS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},oS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},aS=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},sS=(e,t,r,n)=>{let i=r,o=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=Ze(o.element,t,{...n,path:[...n.path,"items"]})},cS=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object",i.properties={};let a=o.shape;for(let u in a)i.properties[u]=Ze(a[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Ze(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Pg=(e,t,r,n)=>{let i=e._zod.def,o=i.inclusive===!1,a=i.options.map((s,c)=>Ze(s,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},uS=(e,t,r,n)=>{let i=e._zod.def,o=Ze(i.left,t,{...n,path:[...n.path,"allOf",0]}),a=Ze(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c},lS=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((f,p)=>Ze(f,t,{...n,path:[...n.path,a,p]})),u=o.rest?Ze(o.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof d=="number"&&(i.maxItems=d)},dS=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=Ze(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let d of c)i.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ze(o.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=Ze(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l)}},pS=(e,t,r,n)=>{let i=e._zod.def,o=Ze(i.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},fS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},mS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},hS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},gS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},_S=(e,t,r,n)=>{let i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ze(o,t,n);let a=t.seen.get(e);a.ref=o},yS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},vS=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Rg=(e,t,r,n)=>{let i=e._zod.def;Ze(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},bS=(e,t,r,n)=>{let i=e._zod.innerType;Ze(i,t,n);let o=t.seen.get(e);o.ref=i},Cg={string:DI,number:LI,boolean:UI,bigint:FI,symbol:BI,null:VI,undefined:ZI,void:GI,never:HI,any:qI,unknown:KI,date:WI,enum:JI,literal:XI,nan:YI,template_literal:QI,file:eS,success:tS,custom:rS,function:nS,transform:iS,map:oS,set:aS,array:sS,object:cS,union:Pg,intersection:uS,tuple:lS,record:dS,nullable:pS,nonoptional:fS,default:mS,prefault:hS,catch:gS,pipe:_S,readonly:yS,promise:vS,optional:Rg,lazy:bS};function mo(e,t){if("_idmap"in e){let n=e,i=ha({...t,processors:Cg}),o={};for(let c of n._idmap.entries()){let[u,l]=c;Ze(l,i)}let a={},s={registry:n,uri:t?.uri,defs:o};i.external=s;for(let c of n._idmap.entries()){let[u,l]=c;ga(i,l),a[u]=_a(i,l)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=ha({...t,processors:Cg});return Ze(e,r),ga(r,e),_a(r,e)}var Ng=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=ha({processors:Cg,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 Ze(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)),ga(this.ctx,t);let n=_a(this.ctx,t),{"~standard":i,...o}=n;return o}};var nM={};function We(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 mt(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 iM(e){return We(e)&&console.warn("[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior."),mt(e)}function zt(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(We(e)||mt(e))}function wS(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 xS(e){return We(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 oM(e){return!!(wS(e)||xS(e))}async function jg(e,t){if(We(e))try{return{success:!0,data:await bs(e,t)}}catch(r){return{success:!1,error:r}}if(mt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function ya(e,t){if(We(e))return await bs(e,t);if(mt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function aM(e,t){if(We(e))try{return{success:!0,data:Ei(e,t)}}catch(r){return{success:!1,error:r}}if(mt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Au(e,t){if(We(e))return Ei(e,t);if(mt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Un(e){if(We(e))return Be.get(e)?.description;if(mt(e)||"description"in e&&typeof e.description=="string")return e.description}function sM(e){if(!zt(e))return!1;if(mt(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(We(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 Ou(e){return zt(e)?mt(e)?e._def.typeName==="ZodString":We(e)?e._zod.def.type==="string":!1:!1}function hp(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 bn(e){return We(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 gp(e){return We(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 IS(e){return We(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 SS(e){return We(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 Ir(e){return!!(hp(e)||bn(e))}function Ts(e){if(mt(e))return e.shape;if(We(e))return e._zod.def.shape;throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function zg(e,t){if(mt(e))return e.extend(t);if(We(e))return F.extend(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Cu(e){if(mt(e))return e.partial();if(We(e))return F.partial(Is,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Tu(e,t=!1){if(hp(e))return e.strict();if(bn(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(bn(a))r[o]=Tu(a,t);else if(gp(a)){let c=a._zod.def.element;bn(c)&&(c=Tu(c,t)),r[o]=lt(a,{...a._zod.def,element:c})}else r[o]=a;let s=Be.get(a);s&&Be.add(r[o],s)}let n=lt(e,{...e._zod.def,shape:r,catchall:mp(ap)}),i=Be.get(e);return i&&Be.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Mg(e,t=!1){if(hp(e))return e.passthrough();if(bn(e)){let r=e._zod.def.shape;if(t)for(let[o,a]of Object.entries(e._zod.def.shape)){if(bn(a))r[o]=Mg(a,t);else if(gp(a)){let c=a._zod.def.element;bn(c)&&(c=Mg(c,t)),r[o]=lt(a,{...a._zod.def,element:c})}else r[o]=a;let s=Be.get(a);s&&Be.add(r[o],s)}let n=lt(e,{...e._zod.def,shape:r,catchall:fp(op)}),i=Be.get(e);return i&&Be.add(n,i),n}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Dg(e){if(mt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(We(e))try{let t=Ei(e,void 0);return()=>t}catch{return}}function N8(e){return mt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function M8(e){return We(e)&&e._zod.def.type==="pipe"}function $s(e,t,r){let n=r.get(e);if(n!==void 0)return n;if(mt(e))return N8(e)?$s(e._def.schema,t,r):e;if(We(e)){let i=e;if(M8(e)&&(i=$s(e._zod.def.in,t,r)),t){if(bn(i)){let a={};for(let[s,c]of Object.entries(i._zod.def.shape))a[s]=$s(c,t,r);i=lt(i,{...i._zod.def,shape:a})}else if(gp(i)){let a=$s(i._zod.def.element,t,r);i=lt(i,{...i._zod.def,element:a})}else if(IS(i)){let a=$s(i._zod.def.innerType,t,r);i=lt(i,{...i._zod.def,innerType:a})}else if(SS(i)){let a=$s(i._zod.def.innerType,t,r);i=lt(i,{...i._zod.def,innerType:a})}}let o=Be.get(e);return o&&Be.add(i,o),r.set(e,i),i}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Lg(e,t=!1){return $s(e,t,new WeakMap)}function cM(e,t){if(mt(e)){let r=Ts(e),n={};for(let[i,o]of Object.entries(r))t(i,o)?n[i]=o.optional():n[i]=o;return e.extend(n)}if(We(e)){let r=Ts(e),n={...e._zod.def.shape};for(let[a,s]of Object.entries(r))t(a,s)&&(n[a]=new Is({type:"optional",innerType:s}));let i=lt(e,{...e._zod.def,shape:n}),o=Be.get(e);return o&&Be.add(i,o),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Ug(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var lM=Symbol("Let zodToJsonSchema decide on which parser to use"),uM={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"},dM=e=>typeof e=="string"?{...uM,name:e}:{...uM,...e};var pM=e=>{let t=dM(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(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};var Fg=(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 ht(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?Fg(t,e.currentPath):t.join("/")}}function kS(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Ue(e,t,r,n,i){e[t]=r,kS(e,t,n,i)}var Vt={};li(Vt,{BRAND:()=>sH,DIRTY:()=>As,EMPTY_PATH:()=>L8,INVALID:()=>me,NEVER:()=>GH,OK:()=>or,ParseStatus:()=>Xt,Schema:()=>Ce,ZodAny:()=>wa,ZodArray:()=>vo,ZodBigInt:()=>Cs,ZodBoolean:()=>Ps,ZodBranded:()=>yp,ZodCatch:()=>Vs,ZodDate:()=>Rs,ZodDefault:()=>Bs,ZodDiscriminatedUnion:()=>Zg,ZodEffects:()=>In,ZodEnum:()=>Us,ZodError:()=>Mr,ZodFirstPartyTypeKind:()=>O,ZodFunction:()=>Hg,ZodIntersection:()=>zs,ZodIssueCode:()=>B,ZodLazy:()=>Ds,ZodLiteral:()=>Ls,ZodMap:()=>zu,ZodNaN:()=>Lu,ZodNativeEnum:()=>Fs,ZodNever:()=>Fn,ZodNull:()=>Ms,ZodNullable:()=>Pi,ZodNumber:()=>Os,ZodObject:()=>jr,ZodOptional:()=>wn,ZodParsedType:()=>te,ZodPipeline:()=>vp,ZodPromise:()=>xa,ZodReadonly:()=>Zs,ZodRecord:()=>Gg,ZodSchema:()=>Ce,ZodSet:()=>Du,ZodString:()=>ba,ZodSymbol:()=>Mu,ZodTransformer:()=>In,ZodTuple:()=>Ci,ZodType:()=>Ce,ZodUndefined:()=>Ns,ZodUnion:()=>js,ZodUnknown:()=>yo,ZodVoid:()=>ju,addIssueToContext:()=>W,any:()=>gH,array:()=>bH,bigint:()=>dH,boolean:()=>IM,coerce:()=>ZH,custom:()=>bM,date:()=>pH,datetimeRegex:()=>yM,defaultErrorMap:()=>go,discriminatedUnion:()=>SH,effect:()=>jH,enum:()=>RH,function:()=>OH,getErrorMap:()=>Pu,getParsedType:()=>Oi,instanceof:()=>uH,intersection:()=>kH,isAborted:()=>Bg,isAsync:()=>Ru,isDirty:()=>Vg,isValid:()=>va,late:()=>cH,lazy:()=>CH,literal:()=>PH,makeIssue:()=>_p,map:()=>TH,nan:()=>lH,nativeEnum:()=>NH,never:()=>yH,null:()=>hH,nullable:()=>DH,number:()=>xM,object:()=>wH,objectUtil:()=>ES,oboolean:()=>VH,onumber:()=>BH,optional:()=>zH,ostring:()=>FH,pipeline:()=>UH,preprocess:()=>LH,promise:()=>MH,quotelessJson:()=>j8,record:()=>$H,set:()=>AH,setErrorMap:()=>D8,strictObject:()=>xH,string:()=>wM,symbol:()=>fH,transformer:()=>jH,tuple:()=>EH,undefined:()=>mH,union:()=>IH,unknown:()=>_H,util:()=>Le,void:()=>vH});var Le;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(let s of o)a[s]=i[s];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},e.find=(i,o)=>{for(let a of i)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Le||(Le={}));var ES;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(ES||(ES={}));var te=Le.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oi=e=>{switch(typeof e){case"undefined":return te.undefined;case"string":return te.string;case"number":return Number.isNaN(e)?te.nan:te.number;case"boolean":return te.boolean;case"function":return te.function;case"bigint":return te.bigint;case"symbol":return te.symbol;case"object":return Array.isArray(e)?te.array:e===null?te.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?te.promise:typeof Map<"u"&&e instanceof Map?te.map:typeof Set<"u"&&e instanceof Set?te.set:typeof Date<"u"&&e instanceof Date?te.date:te.object;default:return te.unknown}};var B=Le.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"]),j8=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Mr=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(o){return o.message},n={_errors:[]},i=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return i(this),n}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,Le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Mr.create=e=>new Mr(e);var z8=(e,t)=>{let r;switch(e.code){case B.invalid_type:e.received===te.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case B.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Le.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:r=`Unrecognized key(s) in object: ${Le.joinValues(e.keys,", ")}`;break;case B.invalid_union:r="Invalid input";break;case B.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Le.joinValues(e.options)}`;break;case B.invalid_enum_value:r=`Invalid enum value. Expected ${Le.joinValues(e.options)}, received '${e.received}'`;break;case B.invalid_arguments:r="Invalid function arguments";break;case B.invalid_return_type:r="Invalid function return type";break;case B.invalid_date:r="Invalid date";break;case B.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}"`:Le.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case B.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 B.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 B.custom:r="Invalid input";break;case B.invalid_intersection_types:r="Intersection results could not be merged";break;case B.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case B.not_finite:r="Number must be finite";break;default:r=t.defaultError,Le.assertNever(e)}return{message:r}},go=z8;var fM=go;function D8(e){fM=e}function Pu(){return fM}var _p=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...i,path:o,message:s}},L8=[];function W(e,t){let r=Pu(),n=_p({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===go?void 0:go].filter(i=>!!i)});e.common.issues.push(n)}var Xt=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 n=[];for(let i of r){if(i.status==="aborted")return me;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,a=await i.value;n.push({key:o,value:a})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return me;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:t.value,value:n}}},me=Object.freeze({status:"aborted"}),As=e=>({status:"dirty",value:e}),or=e=>({status:"valid",value:e}),Bg=e=>e.status==="aborted",Vg=e=>e.status==="dirty",va=e=>e.status==="valid",Ru=e=>typeof Promise<"u"&&e instanceof Promise;var se;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(se||(se={}));var xn=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},mM=(e,t)=>{if(va(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 Mr(e.common.issues);return this._error=r,this._error}}};function $e(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var Ce=class{get description(){return this._def.description}_getType(t){return Oi(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Xt,ctx:{common:t.parent.common,data:t.data,parsedType:Oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ru(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 n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oi(t)},i=this._parseSync({data:t,path:n.path,parent:n});return mM(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oi(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return va(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>va(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Oi(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(Ru(i)?i:Promise.resolve(i));return mM(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let a=t(i),s=()=>o.addIssue({code:B.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new In({schema:this,typeName:O.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 wn.create(this,this._def)}nullable(){return Pi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vo.create(this)}promise(){return xa.create(this,this._def)}or(t){return js.create([this,t],this._def)}and(t){return zs.create(this,t,this._def)}transform(t){return new In({...$e(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Bs({...$e(this._def),innerType:this,defaultValue:r,typeName:O.ZodDefault})}brand(){return new yp({typeName:O.ZodBranded,type:this,...$e(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Vs({...$e(this._def),innerType:this,catchValue:r,typeName:O.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return vp.create(this,t)}readonly(){return Zs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},U8=/^c[^\s-]{8,}$/i,F8=/^[0-9a-z]+$/,B8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,V8=/^[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,Z8=/^[a-z0-9_-]{21}$/i,G8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,H8=/^[-+]?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)?)??$/,q8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,K8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",$S,W8=/^(?:(?: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])$/,J8=/^(?:(?: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])$/,X8=/^(([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]))$/,Y8=/^(([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])$/,Q8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,eH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gM="((\\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])))",tH=new RegExp(`^${gM}$`);function _M(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 rH(e){return new RegExp(`^${_M(e)}$`)}function yM(e){let t=`${gM}T${_M(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 nH(e,t){return!!((t==="v4"||!t)&&W8.test(e)||(t==="v6"||!t)&&X8.test(e))}function iH(e,t){if(!G8.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function oH(e,t){return!!((t==="v4"||!t)&&J8.test(e)||(t==="v6"||!t)&&Y8.test(e))}var ba=class e extends Ce{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==te.string){let o=this._getOrReturnCtx(t);return W(o,{code:B.invalid_type,expected:te.string,received:o.parsedType}),me}let n=new Xt,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),W(i,{code:B.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),W(i,{code:B.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(t,i),a?W(i,{code:B.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&W(i,{code:B.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")q8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"email",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")$S||($S=new RegExp(K8,"u")),$S.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"emoji",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")V8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"uuid",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Z8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"nanoid",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")U8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"cuid",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")F8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"cuid2",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")B8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"ulid",code:B.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),W(i,{validation:"url",code:B.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"regex",code:B.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?yM(o).test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?tH.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?rH(o).test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{code:B.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?H8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"duration",code:B.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?nH(t.data,o.version)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"ip",code:B.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?iH(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"jwt",code:B.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?oH(t.data,o.version)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"cidr",code:B.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Q8.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"base64",code:B.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?eH.test(t.data)||(i=this._getOrReturnCtx(t,i),W(i,{validation:"base64url",code:B.invalid_string,message:o.message}),n.dirty()):Le.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:B.invalid_string,...se.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...se.errToObj(t)})}url(t){return this._addCheck({kind:"url",...se.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...se.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...se.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...se.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...se.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...se.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...se.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...se.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...se.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...se.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...se.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...se.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,...se.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,...se.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...se.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...se.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...se.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...se.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...se.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...se.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...se.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...se.errToObj(r)})}nonempty(t){return this.min(1,se.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}};ba.create=e=>new ba({checks:[],typeName:O.ZodString,coerce:e?.coerce??!1,...$e(e)});function aH(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return o%a/10**i}var Os=class e extends Ce{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)!==te.number){let o=this._getOrReturnCtx(t);return W(o,{code:B.invalid_type,expected:te.number,received:o.parsedType}),me}let n,i=new Xt;for(let o of this._def.checks)o.kind==="int"?Le.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),W(n,{code:B.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?aH(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),W(n,{code:B.not_finite,message:o.message}),i.dirty()):Le.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,se.toString(r))}gt(t,r){return this.setLimit("min",t,!1,se.toString(r))}lte(t,r){return this.setLimit("max",t,!0,se.toString(r))}lt(t,r){return this.setLimit("max",t,!1,se.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:se.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:se.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:se.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:se.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:se.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:se.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:se.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:se.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:se.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:se.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"&&Le.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Os.create=e=>new Os({checks:[],typeName:O.ZodNumber,coerce:e?.coerce||!1,...$e(e)});var Cs=class e extends Ce{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)!==te.bigint)return this._getInvalidInput(t);let n,i=new Xt;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),W(n,{code:B.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Le.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return W(r,{code:B.invalid_type,expected:te.bigint,received:r.parsedType}),me}gte(t,r){return this.setLimit("min",t,!0,se.toString(r))}gt(t,r){return this.setLimit("min",t,!1,se.toString(r))}lte(t,r){return this.setLimit("max",t,!0,se.toString(r))}lt(t,r){return this.setLimit("max",t,!1,se.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:se.toString(i)}]})}_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:se.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:se.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:se.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:se.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:se.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}};Cs.create=e=>new Cs({checks:[],typeName:O.ZodBigInt,coerce:e?.coerce??!1,...$e(e)});var Ps=class extends Ce{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==te.boolean){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.boolean,received:n.parsedType}),me}return or(t.data)}};Ps.create=e=>new Ps({typeName:O.ZodBoolean,coerce:e?.coerce||!1,...$e(e)});var Rs=class e extends Ce{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==te.date){let o=this._getOrReturnCtx(t);return W(o,{code:B.invalid_type,expected:te.date,received:o.parsedType}),me}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return W(o,{code:B.invalid_date}),me}let n=new Xt,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),W(i,{code:B.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),W(i,{code:B.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Le.assertNever(o);return{status:n.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:se.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:se.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}};Rs.create=e=>new Rs({checks:[],coerce:e?.coerce||!1,typeName:O.ZodDate,...$e(e)});var Mu=class extends Ce{_parse(t){if(this._getType(t)!==te.symbol){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.symbol,received:n.parsedType}),me}return or(t.data)}};Mu.create=e=>new Mu({typeName:O.ZodSymbol,...$e(e)});var Ns=class extends Ce{_parse(t){if(this._getType(t)!==te.undefined){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.undefined,received:n.parsedType}),me}return or(t.data)}};Ns.create=e=>new Ns({typeName:O.ZodUndefined,...$e(e)});var Ms=class extends Ce{_parse(t){if(this._getType(t)!==te.null){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.null,received:n.parsedType}),me}return or(t.data)}};Ms.create=e=>new Ms({typeName:O.ZodNull,...$e(e)});var wa=class extends Ce{constructor(){super(...arguments),this._any=!0}_parse(t){return or(t.data)}};wa.create=e=>new wa({typeName:O.ZodAny,...$e(e)});var yo=class extends Ce{constructor(){super(...arguments),this._unknown=!0}_parse(t){return or(t.data)}};yo.create=e=>new yo({typeName:O.ZodUnknown,...$e(e)});var Fn=class extends Ce{_parse(t){let r=this._getOrReturnCtx(t);return W(r,{code:B.invalid_type,expected:te.never,received:r.parsedType}),me}};Fn.create=e=>new Fn({typeName:O.ZodNever,...$e(e)});var ju=class extends Ce{_parse(t){if(this._getType(t)!==te.undefined){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.void,received:n.parsedType}),me}return or(t.data)}};ju.create=e=>new ju({typeName:O.ZodVoid,...$e(e)});var vo=class e extends Ce{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==te.array)return W(r,{code:B.invalid_type,expected:te.array,received:r.parsedType}),me;if(i.exactLength!==null){let a=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(a||s)&&(W(r,{code:a?B.too_big:B.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(W(r,{code:B.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(W(r,{code:B.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>i.type._parseAsync(new xn(r,a,r.path,s)))).then(a=>Xt.mergeArray(n,a));let o=[...r.data].map((a,s)=>i.type._parseSync(new xn(r,a,r.path,s)));return Xt.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:se.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:se.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:se.toString(r)}})}nonempty(t){return this.min(1,t)}};vo.create=(e,t)=>new vo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...$e(t)});function Nu(e){if(e instanceof jr){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=wn.create(Nu(n))}return new jr({...e._def,shape:()=>t})}else return e instanceof vo?new vo({...e._def,type:Nu(e.element)}):e instanceof wn?wn.create(Nu(e.unwrap())):e instanceof Pi?Pi.create(Nu(e.unwrap())):e instanceof Ci?Ci.create(e.items.map(t=>Nu(t))):e}var jr=class e extends Ce{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=Le.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==te.object){let u=this._getOrReturnCtx(t);return W(u,{code:B.invalid_type,expected:te.object,received:u.parsedType}),me}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Fn&&this._def.unknownKeys==="strip"))for(let u in i.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=o[u],d=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new xn(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Fn){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(u==="strict")s.length>0&&(W(i,{code:B.unrecognized_keys,keys:s}),n.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=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new xn(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.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=>Xt.mergeObjectSync(n,u)):Xt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return se.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:se.errToObj(t).message??i}:{message:i}}}:{}})}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:O.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of Le.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of Le.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return Nu(this)}partial(t){let r={};for(let n of Le.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of Le.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof wn;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return vM(Le.objectKeys(this.shape))}};jr.create=(e,t)=>new jr({shape:()=>e,unknownKeys:"strip",catchall:Fn.create(),typeName:O.ZodObject,...$e(t)});jr.strictCreate=(e,t)=>new jr({shape:()=>e,unknownKeys:"strict",catchall:Fn.create(),typeName:O.ZodObject,...$e(t)});jr.lazycreate=(e,t)=>new jr({shape:e,unknownKeys:"strip",catchall:Fn.create(),typeName:O.ZodObject,...$e(t)});var js=class extends Ce{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new Mr(s.ctx.common.issues));return W(r,{code:B.invalid_union,unionErrors:a}),me}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let o,a=[];for(let c of n){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"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new Mr(c));return W(r,{code:B.invalid_union,unionErrors:s}),me}}get options(){return this._def.options}};js.create=(e,t)=>new js({options:e,typeName:O.ZodUnion,...$e(t)});var _o=e=>e instanceof Ds?_o(e.schema):e instanceof In?_o(e.innerType()):e instanceof Ls?[e.value]:e instanceof Us?e.options:e instanceof Fs?Le.objectValues(e.enum):e instanceof Bs?_o(e._def.innerType):e instanceof Ns?[void 0]:e instanceof Ms?[null]:e instanceof wn?[void 0,..._o(e.unwrap())]:e instanceof Pi?[null,..._o(e.unwrap())]:e instanceof yp||e instanceof Zs?_o(e.unwrap()):e instanceof Vs?_o(e._def.innerType):[],Zg=class e extends Ce{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==te.object)return W(r,{code:B.invalid_type,expected:te.object,received:r.parsedType}),me;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(W(r,{code:B.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let a=_o(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,o)}}return new e({typeName:O.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...$e(n)})}};function TS(e,t){let r=Oi(e),n=Oi(t);if(e===t)return{valid:!0,data:e};if(r===te.object&&n===te.object){let i=Le.objectKeys(t),o=Le.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(let s of o){let c=TS(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===te.array&&n===te.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let a=e[o],s=t[o],c=TS(a,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===te.date&&n===te.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var zs=class extends Ce{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,a)=>{if(Bg(o)||Bg(a))return me;let s=TS(o.value,a.value);return s.valid?((Vg(o)||Vg(a))&&r.dirty(),{status:r.value,value:s.data}):(W(n,{code:B.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};zs.create=(e,t,r)=>new zs({left:e,right:t,typeName:O.ZodIntersection,...$e(r)});var Ci=class e extends Ce{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==te.array)return W(n,{code:B.invalid_type,expected:te.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(n,{code:B.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:B.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new xn(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>Xt.mergeArray(r,a)):Xt.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ci.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ci({items:e,typeName:O.ZodTuple,rest:null,...$e(t)})};var Gg=class e extends Ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==te.object)return W(n,{code:B.invalid_type,expected:te.object,received:n.parsedType}),me;let i=[],o=this._def.keyType,a=this._def.valueType;for(let s in n.data)i.push({key:o._parse(new xn(n,s,n.path,s)),value:a._parse(new xn(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Xt.mergeObjectAsync(r,i):Xt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Ce?new e({keyType:t,valueType:r,typeName:O.ZodRecord,...$e(n)}):new e({keyType:ba.create(),valueType:t,typeName:O.ZodRecord,...$e(r)})}},zu=class extends Ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==te.map)return W(n,{code:B.invalid_type,expected:te.map,received:n.parsedType}),me;let i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,c],u)=>({key:i._parse(new xn(n,s,n.path,[u,"key"])),value:o._parse(new xn(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return me;(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 a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return me;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};zu.create=(e,t,r)=>new zu({valueType:t,keyType:e,typeName:O.ZodMap,...$e(r)});var Du=class e extends Ce{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==te.set)return W(n,{code:B.invalid_type,expected:te.set,received:n.parsedType}),me;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(W(n,{code:B.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(W(n,{code:B.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return me;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>o._parse(new xn(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:se.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:se.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Du.create=(e,t)=>new Du({valueType:e,minSize:null,maxSize:null,typeName:O.ZodSet,...$e(t)});var Hg=class e extends Ce{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==te.function)return W(r,{code:B.invalid_type,expected:te.function,received:r.parsedType}),me;function n(s,c){return _p({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pu(),go].filter(u=>!!u),issueData:{code:B.invalid_arguments,argumentsError:c}})}function i(s,c){return _p({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pu(),go].filter(u=>!!u),issueData:{code:B.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof xa){let s=this;return or(async function(...c){let u=new Mr([]),l=await s._def.args.parseAsync(c,o).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,o).catch(p=>{throw u.addIssue(i(d,p)),u})})}else{let s=this;return or(function(...c){let u=s._def.args.safeParse(c,o);if(!u.success)throw new Mr([n(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=s._def.returns.safeParse(l,o);if(!d.success)throw new Mr([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ci.create(t).rest(yo.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,n){return new e({args:t||Ci.create([]).rest(yo.create()),returns:r||yo.create(),typeName:O.ZodFunction,...$e(n)})}},Ds=class extends Ce{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})}};Ds.create=(e,t)=>new Ds({getter:e,typeName:O.ZodLazy,...$e(t)});var Ls=class extends Ce{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return W(r,{received:r.data,code:B.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:t.data}}get value(){return this._def.value}};Ls.create=(e,t)=>new Ls({value:e,typeName:O.ZodLiteral,...$e(t)});function vM(e,t){return new Us({values:e,typeName:O.ZodEnum,...$e(t)})}var Us=class e extends Ce{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return W(r,{expected:Le.joinValues(n),received:r.parsedType,code:B.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return W(r,{received:r.data,code:B.invalid_enum_value,options:n}),me}return or(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(n=>!t.includes(n)),{...this._def,...r})}};Us.create=vM;var Fs=class extends Ce{_parse(t){let r=Le.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==te.string&&n.parsedType!==te.number){let i=Le.objectValues(r);return W(n,{expected:Le.joinValues(i),received:n.parsedType,code:B.invalid_type}),me}if(this._cache||(this._cache=new Set(Le.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Le.objectValues(r);return W(n,{received:n.data,code:B.invalid_enum_value,options:i}),me}return or(t.data)}get enum(){return this._def.values}};Fs.create=(e,t)=>new Fs({values:e,typeName:O.ZodNativeEnum,...$e(t)});var xa=class extends Ce{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==te.promise&&r.common.async===!1)return W(r,{code:B.invalid_type,expected:te.promise,received:r.parsedType}),me;let n=r.parsedType===te.promise?r.data:Promise.resolve(r.data);return or(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};xa.create=(e,t)=>new xa({type:e,typeName:O.ZodPromise,...$e(t)});var In=class extends Ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:a=>{W(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return me;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"?As(c.value):r.value==="dirty"?As(c.value):c});{if(r.value==="aborted")return me;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?As(s.value):r.value==="dirty"?As(s.value):s}}if(i.type==="refinement"){let a=s=>{let c=i.refinement(s,o);if(n.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(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?me:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!va(a))return me;let s=i.transform(a.value,o);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:n.data,path:n.path,parent:n}).then(a=>va(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:r.value,value:s})):me);Le.assertNever(i)}};In.create=(e,t,r)=>new In({schema:e,typeName:O.ZodEffects,effect:t,...$e(r)});In.createWithPreprocess=(e,t,r)=>new In({schema:t,effect:{type:"preprocess",transform:e},typeName:O.ZodEffects,...$e(r)});var wn=class extends Ce{_parse(t){return this._getType(t)===te.undefined?or(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};wn.create=(e,t)=>new wn({innerType:e,typeName:O.ZodOptional,...$e(t)});var Pi=class extends Ce{_parse(t){return this._getType(t)===te.null?or(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Pi.create=(e,t)=>new Pi({innerType:e,typeName:O.ZodNullable,...$e(t)});var Bs=class extends Ce{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===te.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Bs.create=(e,t)=>new Bs({innerType:e,typeName:O.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...$e(t)});var Vs=class extends Ce{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ru(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Mr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Mr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Vs.create=(e,t)=>new Vs({innerType:e,typeName:O.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...$e(t)});var Lu=class extends Ce{_parse(t){if(this._getType(t)!==te.nan){let n=this._getOrReturnCtx(t);return W(n,{code:B.invalid_type,expected:te.nan,received:n.parsedType}),me}return{status:"valid",value:t.data}}};Lu.create=e=>new Lu({typeName:O.ZodNaN,...$e(e)});var sH=Symbol("zod_brand"),yp=class extends Ce{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},vp=class e extends Ce{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"?(r.dirty(),As(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:O.ZodPipeline})}},Zs=class extends Ce{_parse(t){let r=this._def.innerType._parse(t),n=i=>(va(i)&&(i.value=Object.freeze(i.value)),i);return Ru(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Zs.create=(e,t)=>new Zs({innerType:e,typeName:O.ZodReadonly,...$e(t)});function hM(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function bM(e,t={},r){return e?wa.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(a=>{if(!a){let s=hM(t,n),c=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!o){let a=hM(t,n),s=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:s})}}):wa.create()}var cH={object:jr.lazycreate},O;(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"})(O||(O={}));var uH=(e,t={message:`Input not instance of ${e.name}`})=>bM(r=>r instanceof e,t),wM=ba.create,xM=Os.create,lH=Lu.create,dH=Cs.create,IM=Ps.create,pH=Rs.create,fH=Mu.create,mH=Ns.create,hH=Ms.create,gH=wa.create,_H=yo.create,yH=Fn.create,vH=ju.create,bH=vo.create,wH=jr.create,xH=jr.strictCreate,IH=js.create,SH=Zg.create,kH=zs.create,EH=Ci.create,$H=Gg.create,TH=zu.create,AH=Du.create,OH=Hg.create,CH=Ds.create,PH=Ls.create,RH=Us.create,NH=Fs.create,MH=xa.create,jH=In.create,zH=wn.create,DH=Pi.create,LH=In.createWithPreprocess,UH=vp.create,FH=()=>wM().optional(),BH=()=>xM().optional(),VH=()=>IM().optional(),ZH={string:(e=>ba.create({...e,coerce:!0})),number:(e=>Os.create({...e,coerce:!0})),boolean:(e=>Ps.create({...e,coerce:!0})),bigint:(e=>Cs.create({...e,coerce:!0})),date:(e=>Rs.create({...e,coerce:!0}))};var GH=me;function SM(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==O.ZodAny&&(r.items=ge(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),Ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function kM(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?Ue(r,"minimum",n.value,n.message,t):Ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Ue(r,"maximum",n.value,n.message,t):Ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":Ue(r,"multipleOf",n.value,n.message,t);break}return r}function EM(){return{type:"boolean"}}function qg(e,t){return ge(e.type._def,t)}var $M=(e,t)=>ge(e.innerType._def,t);function AS(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(i=>AS(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return HH(e,t)}}var HH=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":Ue(r,"minimum",n.value,n.message,t);break;case"max":Ue(r,"maximum",n.value,n.message,t);break}return r};function TM(e,t){return{...ge(e.innerType._def,t),default:e.defaultValue()}}function AM(e,t){return t.effectStrategy==="input"?ge(e.schema._def,t):ht(t)}function OM(e){return{type:"string",enum:Array.from(e.values)}}var qH=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function CM(e,t){let r=[ge(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ge(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(qH(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...c}=o;a=c}else n=void 0;i.push(a)}}),i.length?{allOf:i,...n}:void 0}function PM(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 OS,Bn={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:()=>(OS===void 0&&(OS=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),OS),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 Kg(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":Ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":Ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Vn(r,"email",n.message,t);break;case"format:idn-email":Vn(r,"idn-email",n.message,t);break;case"pattern:zod":Sr(r,Bn.email,n.message,t);break}break;case"url":Vn(r,"uri",n.message,t);break;case"uuid":Vn(r,"uuid",n.message,t);break;case"regex":Sr(r,n.regex,n.message,t);break;case"cuid":Sr(r,Bn.cuid,n.message,t);break;case"cuid2":Sr(r,Bn.cuid2,n.message,t);break;case"startsWith":Sr(r,RegExp(`^${CS(n.value,t)}`),n.message,t);break;case"endsWith":Sr(r,RegExp(`${CS(n.value,t)}$`),n.message,t);break;case"datetime":Vn(r,"date-time",n.message,t);break;case"date":Vn(r,"date",n.message,t);break;case"time":Vn(r,"time",n.message,t);break;case"duration":Vn(r,"duration",n.message,t);break;case"length":Ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),Ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Sr(r,RegExp(CS(n.value,t)),n.message,t);break;case"ip":n.version!=="v6"&&Vn(r,"ipv4",n.message,t),n.version!=="v4"&&Vn(r,"ipv6",n.message,t);break;case"base64url":Sr(r,Bn.base64url,n.message,t);break;case"jwt":Sr(r,Bn.jwt,n.message,t);break;case"cidr":n.version!=="v6"&&Sr(r,Bn.ipv4Cidr,n.message,t),n.version!=="v4"&&Sr(r,Bn.ipv6Cidr,n.message,t);break;case"emoji":Sr(r,Bn.emoji(),n.message,t);break;case"ulid":Sr(r,Bn.ulid,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":Vn(r,"binary",n.message,t);break;case"contentEncoding:base64":Ue(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Sr(r,Bn.base64,n.message,t);break}break;case"nanoid":Sr(r,Bn.nanoid,n.message,t);break;case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function CS(e,t){return t.patternStrategy==="escape"?WH(e):e}var KH=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function WH(e){let t="";for(let r=0;r<e.length;r++)KH.has(e[r])||(t+="\\"),t+=e[r];return t}function Vn(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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&&n.errorMessages&&{errorMessage:{format:r}}})):Ue(e,"format",t,r,n)}function Sr(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:RM(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Ue(e,"pattern",RM(t,n),r,n)}function RM(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")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,a=!1,s=!1;for(let c=0;c<n.length;c++){if(o){i+=n[c],o=!1;continue}if(r.i){if(a){if(n[c].match(/[a-z]/)){s?(i+=n[c],i+=`${n[c-2]}-${n[c]}`.toUpperCase(),s=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(i+=n[c],s=!0):i+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){i+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){i+=`(^|(?<=[\r
|
|
102
|
+
]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
|
|
103
|
+
]))`;continue}}if(r.s&&n[c]==="."){i+=a?`${n[c]}\r
|
|
104
|
+
`:`[${n[c]}\r
|
|
105
|
+
]`;continue}i+=n[c],n[c]==="\\"?o=!0:a&&n[c]==="]"?a=!1:!a&&n[c]==="["&&(a=!0)}try{new RegExp(i)}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 i}function Wg(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===O.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:ge(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??ht(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:ge(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===O.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=Kg(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===O.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===O.ZodBranded&&e.keyType._def.type._def.typeName===O.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=qg(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function NM(e,t){return t.mapStrategy==="record"?Wg(e,t):{type:"array",maxItems:125,items:{type:"array",items:[ge(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||ht(t),ge(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||ht(t)],minItems:2,maxItems:2}}}function MM(e){let t=e.values,r=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(r.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:r}}function jM(e){return e.target==="openAi"?void 0:{not:ht({...e,currentPath:[...e.currentPath,"not"]})}}function zM(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var bp={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function LM(e,t){if(t.target==="openApi3")return DM(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in bp&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let a=bp[o._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":return o._def.value===null?[...i,"null"]:i;default:return i}},[]);if(n.length===r.length){let i=n.filter((o,a,s)=>s.indexOf(o)===a);return{type:i.length>1?i:i[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return DM(e,t)}var DM=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>ge(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function UM(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:bp[e.innerType._def.typeName],nullable:!0}:{type:[bp[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=ge(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=ge(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function FM(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",kS(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?Ue(r,"minimum",n.value,n.message,t):Ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Ue(r,"maximum",n.value,n.message,t):Ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":Ue(r,"multipleOf",n.value,n.message,t);break}return r}function BM(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let s in o){let c=o[s];if(c===void 0||c._def===void 0)continue;let u=XH(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=ge(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,u||i.push(s))}i.length&&(n.required=i);let a=JH(e,t);return a!==void 0&&(n.additionalProperties=a),n}function JH(e,t){if(e.catchall._def.typeName!=="ZodNever")return ge(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 XH(e){try{return e.isOptional()}catch{return!0}}var VM=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return ge(e.innerType._def,t);let r=ge(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:ht(t)},r]}:ht(t)};var ZM=(e,t)=>{if(t.pipeStrategy==="input")return ge(e.in._def,t);if(t.pipeStrategy==="output")return ge(e.out._def,t);let r=ge(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,ge(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(n=>n!==void 0)}};function GM(e,t){return ge(e.type._def,t)}function HM(e,t){let r={type:"array",uniqueItems:!0,items:ge(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ue(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ue(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}function qM(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>ge(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:ge(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>ge(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function KM(e){return{not:ht(e)}}function WM(e){return ht(e)}var JM=(e,t)=>ge(e.innerType._def,t);var XM=(e,t,r)=>{switch(t){case O.ZodString:return Kg(e,r);case O.ZodNumber:return FM(e,r);case O.ZodObject:return BM(e,r);case O.ZodBigInt:return kM(e,r);case O.ZodBoolean:return EM();case O.ZodDate:return AS(e,r);case O.ZodUndefined:return KM(r);case O.ZodNull:return zM(r);case O.ZodArray:return SM(e,r);case O.ZodUnion:case O.ZodDiscriminatedUnion:return LM(e,r);case O.ZodIntersection:return CM(e,r);case O.ZodTuple:return qM(e,r);case O.ZodRecord:return Wg(e,r);case O.ZodLiteral:return PM(e,r);case O.ZodEnum:return OM(e);case O.ZodNativeEnum:return MM(e);case O.ZodNullable:return UM(e,r);case O.ZodOptional:return VM(e,r);case O.ZodMap:return NM(e,r);case O.ZodSet:return HM(e,r);case O.ZodLazy:return()=>e.getter()._def;case O.ZodPromise:return GM(e,r);case O.ZodNaN:case O.ZodNever:return jM(r);case O.ZodEffects:return AM(e,r);case O.ZodAny:return ht(r);case O.ZodUnknown:return WM(r);case O.ZodDefault:return TM(e,r);case O.ZodBranded:return qg(e,r);case O.ZodReadonly:return JM(e,r);case O.ZodCatch:return $M(e,r);case O.ZodPipeline:return ZM(e,r);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return(n=>{})(t)}};function ge(e,t,r=!1){let n=t.seen.get(e);if(t.override){let s=t.override?.(e,t,n,r);if(s!==lM)return s}if(n&&!r){let s=YH(n,t);if(s!==void 0)return s}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=XM(e,e.typeName,t),a=typeof o=="function"?ge(o(),t):o;if(a&&QH(e,t,a),t.postProcess){let s=t.postProcess(a,e,t);return i.jsonSchema=a,s}return i.jsonSchema=a,a}var YH=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Fg(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),ht(t)):t.$refStrategy==="seen"?ht(t):void 0}},QH=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var YM=(e,t)=>{let r=pM(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:ge(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??ht(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=ge(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??ht(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};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 Ri(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(!Ri(e[i],t[i]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let a of n)if(!Ri(e[a],t[a]))return!1;return!0}return e===t}function en(e){return encodeURI(eq(e))}function eq(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var tq={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},rq={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},nq={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},iq=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 Zn(e,t=Object.create(null),r=iq,n=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let o=e.$id||e.id;if(o){let a=new URL(o,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",n===""?r=a:Zn(e,t,r))}}else if(e!==!0&&e!==!1)return t;let i=r.href+(n?"#"+n:"");if(t[i]!==void 0)throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let o=new URL(e.$ref,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:o.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let o=new URL(e.$recursiveRef,r.href);o.hash=o.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:o.href})}if(e.$anchor){let o=new URL("#"+e.$anchor,r.href);t[o.href]=e}for(let o in e){if(nq[o])continue;let a=`${n}/${en(o)}`,s=e[o];if(Array.isArray(s)){if(tq[o]){let c=s.length;for(let u=0;u<c;u++)Zn(s[u],t,r,`${a}/${u}`)}}else if(rq[o])for(let c in s)Zn(s[c],t,r,`${a}/${en(c)}`);else Zn(s,t,r,a)}return t}var oq=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,aq=[0,31,28,31,30,31,30,31,31,30,31,30,31],sq=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,cq=/^(?=.{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,uq=/^(?:[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,lq=/^(?:(?:[^\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,dq=/^(?:(?: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,pq=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,fq=/^(?:\/(?:[^~/]|~0|~1)*)*$/,mq=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,hq=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,gq=e=>{if(e[0]==='"')return!1;let[t,r,...n]=e.split("@");return!t||!r||n.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(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},_q=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,yq=/^((([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,vq=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 Ni(e){return e.test.bind(e)}var PS={date:QM,time:ej.bind(void 0,!1),"date-time":xq,duration:vq,uri:kq,"uri-reference":Ni(uq),"uri-template":Ni(lq),url:Ni(dq),email:gq,hostname:Ni(cq),ipv4:Ni(_q),ipv6:Ni(yq),regex:$q,uuid:Ni(pq),"json-pointer":Ni(fq),"json-pointer-uri-fragment":Ni(mq),"relative-json-pointer":Ni(hq)};function bq(e){return e%4===0&&(e%100!==0||e%400===0)}function QM(e){let t=e.match(oq);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n==2&&bq(r)?29:aq[n])}function ej(e,t){let r=t.match(sq);if(!r)return!1;let n=+r[1],i=+r[2],o=+r[3],a=!!r[5];return(n<=23&&i<=59&&o<=59||n==23&&i==59&&o==60)&&(!e||a)}var wq=/t|\s/i;function xq(e){let t=e.split(wq);return t.length==2&&QM(t[0])&&ej(!0,t[1])}var Iq=/\/|:/,Sq=/^(?:[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 kq(e){return Iq.test(e)&&Sq.test(e)}var Eq=/[^\\]\\Z/;function $q(e){if(Eq.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}var tj;(function(e){e[e.Flag=1]="Flag",e[e.Basic=2]="Basic",e[e.Detailed=4]="Detailed"})(tj||(tj={}));function rj(e){let t=0,r=e.length,n=0,i;for(;n<r;)t++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<r&&(i=e.charCodeAt(n),(i&64512)==56320&&n++);return t}function nt(e,t,r="2019-09",n=Zn(t),i=!0,o=null,a="#",s="#",c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:a,keyword:"false",keywordLocation:a,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:h,enum:w,required:_,not:y,anyOf:x,allOf:S,oneOf:$,if:j,then:C,else:b,format:H,properties:R,patternProperties:V,additionalProperties:xe,unevaluatedProperties:Ge,minProperties:qt,maxProperties:Fr,propertyNames:ze,dependentRequired:Xa,dependentSchemas:Yi,dependencies:Ya,prefixItems:Tn,items:Qi,additionalItems:sd,unevaluatedItems:cd,contains:ud,minContains:An,maxContains:v,minItems:g,maxItems:z,uniqueItems:k,minimum:De,maximum:qe,exclusiveMinimum:Rt,exclusiveMaximum:It,multipleOf:Qt,minLength:sn,maxLength:St,pattern:ui,__absolute_ref__:Nc,__absolute_recursive_ref__:qf}=t,ee=[];if(p===!0&&o===null&&(o=t),f==="#"){let _e=o===null?n[qf]:o,le=`${s}/$recursiveRef`,Ie=nt(e,o===null?t:o,r,n,i,_e,a,le,c);Ie.valid||ee.push({instanceLocation:a,keyword:"$recursiveRef",keywordLocation:le,error:"A subschema had errors."},...Ie.errors)}if(d!==void 0){let le=n[Nc||d];if(le===void 0){let X=`Unresolved $ref "${d}".`;throw Nc&&Nc!==d&&(X+=` Absolute URI "${Nc}".`),X+=`
|
|
106
|
+
Known schemas:
|
|
107
|
+
- ${Object.keys(n).join(`
|
|
108
|
+
- `)}`,new Error(X)}let Ie=`${s}/$ref`,ie=nt(e,le,r,n,i,o,a,Ie,c);if(ie.valid||ee.push({instanceLocation:a,keyword:"$ref",keywordLocation:Ie,error:"A subschema had errors."},...ie.errors),r==="4"||r==="7")return{valid:ee.length===0,errors:ee}}if(Array.isArray(m)){let _e=m.length,le=!1;for(let Ie=0;Ie<_e;Ie++)if(l===m[Ie]||m[Ie]==="integer"&&l==="number"&&e%1===0&&e===e){le=!0;break}le||ee.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&ee.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&ee.push({instanceLocation:a,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(h!==void 0&&(l==="object"||l==="array"?Ri(e,h)||ee.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&ee.push({instanceLocation:a,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),w!==void 0&&(l==="object"||l==="array"?w.some(_e=>Ri(e,_e))||ee.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`}):w.some(_e=>e===_e)||ee.push({instanceLocation:a,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(w)}.`})),y!==void 0){let _e=`${s}/not`;nt(e,y,r,n,i,o,a,_e).valid&&ee.push({instanceLocation:a,keyword:"not",keywordLocation:_e,error:'Instance matched "not" schema.'})}let Qa=[];if(x!==void 0){let _e=`${s}/anyOf`,le=ee.length,Ie=!1;for(let ie=0;ie<x.length;ie++){let X=x[ie],ve=Object.create(c),ye=nt(e,X,r,n,i,p===!0?o:null,a,`${_e}/${ie}`,ve);ee.push(...ye.errors),Ie=Ie||ye.valid,ye.valid&&Qa.push(ve)}Ie?ee.length=le:ee.splice(le,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:_e,error:"Instance does not match any subschemas."})}if(S!==void 0){let _e=`${s}/allOf`,le=ee.length,Ie=!0;for(let ie=0;ie<S.length;ie++){let X=S[ie],ve=Object.create(c),ye=nt(e,X,r,n,i,p===!0?o:null,a,`${_e}/${ie}`,ve);ee.push(...ye.errors),Ie=Ie&&ye.valid,ye.valid&&Qa.push(ve)}Ie?ee.length=le:ee.splice(le,0,{instanceLocation:a,keyword:"allOf",keywordLocation:_e,error:"Instance does not match every subschema."})}if($!==void 0){let _e=`${s}/oneOf`,le=ee.length,Ie=$.filter((ie,X)=>{let ve=Object.create(c),ye=nt(e,ie,r,n,i,p===!0?o:null,a,`${_e}/${X}`,ve);return ee.push(...ye.errors),ye.valid&&Qa.push(ve),ye.valid}).length;Ie===1?ee.length=le:ee.splice(le,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:_e,error:`Instance does not match exactly one subschema (${Ie} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...Qa),j!==void 0){let _e=`${s}/if`;if(nt(e,j,r,n,i,o,a,_e,c).valid){if(C!==void 0){let Ie=nt(e,C,r,n,i,o,a,`${s}/then`,c);Ie.valid||ee.push({instanceLocation:a,keyword:"if",keywordLocation:_e,error:'Instance does not match "then" schema.'},...Ie.errors)}}else if(b!==void 0){let Ie=nt(e,b,r,n,i,o,a,`${s}/else`,c);Ie.valid||ee.push({instanceLocation:a,keyword:"if",keywordLocation:_e,error:'Instance does not match "else" schema.'},...Ie.errors)}}if(l==="object"){if(_!==void 0)for(let ie of _)ie in e||ee.push({instanceLocation:a,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${ie}".`});let _e=Object.keys(e);if(qt!==void 0&&_e.length<qt&&ee.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${qt} properties.`}),Fr!==void 0&&_e.length>Fr&&ee.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${Fr} properties.`}),ze!==void 0){let ie=`${s}/propertyNames`;for(let X in e){let ve=`${a}/${en(X)}`,ye=nt(X,ze,r,n,i,o,ve,ie);ye.valid||ee.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:ie,error:`Property name "${X}" does not match schema.`},...ye.errors)}}if(Xa!==void 0){let ie=`${s}/dependantRequired`;for(let X in Xa)if(X in e){let ve=Xa[X];for(let ye of ve)ye in e||ee.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:ie,error:`Instance has "${X}" but does not have "${ye}".`})}}if(Yi!==void 0)for(let ie in Yi){let X=`${s}/dependentSchemas`;if(ie in e){let ve=nt(e,Yi[ie],r,n,i,o,a,`${X}/${en(ie)}`,c);ve.valid||ee.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:X,error:`Instance has "${ie}" but does not match dependant schema.`},...ve.errors)}}if(Ya!==void 0){let ie=`${s}/dependencies`;for(let X in Ya)if(X in e){let ve=Ya[X];if(Array.isArray(ve))for(let ye of ve)ye in e||ee.push({instanceLocation:a,keyword:"dependencies",keywordLocation:ie,error:`Instance has "${X}" but does not have "${ye}".`});else{let ye=nt(e,ve,r,n,i,o,a,`${ie}/${en(X)}`);ye.valid||ee.push({instanceLocation:a,keyword:"dependencies",keywordLocation:ie,error:`Instance has "${X}" but does not match dependant schema.`},...ye.errors)}}}let le=Object.create(null),Ie=!1;if(R!==void 0){let ie=`${s}/properties`;for(let X in R){if(!(X in e))continue;let ve=`${a}/${en(X)}`,ye=nt(e[X],R[X],r,n,i,o,ve,`${ie}/${en(X)}`);if(ye.valid)c[X]=le[X]=!0;else if(Ie=i,ee.push({instanceLocation:a,keyword:"properties",keywordLocation:ie,error:`Property "${X}" does not match schema.`},...ye.errors),Ie)break}}if(!Ie&&V!==void 0){let ie=`${s}/patternProperties`;for(let X in V){let ve=new RegExp(X,"u"),ye=V[X];for(let Tr in e){if(!ve.test(Tr))continue;let jT=`${a}/${en(Tr)}`,zT=nt(e[Tr],ye,r,n,i,o,jT,`${ie}/${en(X)}`);zT.valid?c[Tr]=le[Tr]=!0:(Ie=i,ee.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:ie,error:`Property "${Tr}" matches pattern "${X}" but does not match associated schema.`},...zT.errors))}}}if(!Ie&&xe!==void 0){let ie=`${s}/additionalProperties`;for(let X in e){if(le[X])continue;let ve=`${a}/${en(X)}`,ye=nt(e[X],xe,r,n,i,o,ve,ie);ye.valid?c[X]=!0:(Ie=i,ee.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:ie,error:`Property "${X}" does not match additional properties schema.`},...ye.errors))}}else if(!Ie&&Ge!==void 0){let ie=`${s}/unevaluatedProperties`;for(let X in e)if(!c[X]){let ve=`${a}/${en(X)}`,ye=nt(e[X],Ge,r,n,i,o,ve,ie);ye.valid?c[X]=!0:ee.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:ie,error:`Property "${X}" does not match unevaluated properties schema.`},...ye.errors)}}}else if(l==="array"){z!==void 0&&e.length>z&&ee.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${z}).`}),g!==void 0&&e.length<g&&ee.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${g}).`});let _e=e.length,le=0,Ie=!1;if(Tn!==void 0){let ie=`${s}/prefixItems`,X=Math.min(Tn.length,_e);for(;le<X;le++){let ve=nt(e[le],Tn[le],r,n,i,o,`${a}/${le}`,`${ie}/${le}`);if(c[le]=!0,!ve.valid&&(Ie=i,ee.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:ie,error:"Items did not match schema."},...ve.errors),Ie))break}}if(Qi!==void 0){let ie=`${s}/items`;if(Array.isArray(Qi)){let X=Math.min(Qi.length,_e);for(;le<X;le++){let ve=nt(e[le],Qi[le],r,n,i,o,`${a}/${le}`,`${ie}/${le}`);if(c[le]=!0,!ve.valid&&(Ie=i,ee.push({instanceLocation:a,keyword:"items",keywordLocation:ie,error:"Items did not match schema."},...ve.errors),Ie))break}}else for(;le<_e;le++){let X=nt(e[le],Qi,r,n,i,o,`${a}/${le}`,ie);if(c[le]=!0,!X.valid&&(Ie=i,ee.push({instanceLocation:a,keyword:"items",keywordLocation:ie,error:"Items did not match schema."},...X.errors),Ie))break}if(!Ie&&sd!==void 0){let X=`${s}/additionalItems`;for(;le<_e;le++){let ve=nt(e[le],sd,r,n,i,o,`${a}/${le}`,X);c[le]=!0,ve.valid||(Ie=i,ee.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:X,error:"Items did not match additional items schema."},...ve.errors))}}}if(ud!==void 0)if(_e===0&&An===void 0)ee.push({instanceLocation:a,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(An!==void 0&&_e<An)ee.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${_e}) than minContains (${An}).`});else{let ie=`${s}/contains`,X=ee.length,ve=0;for(let ye=0;ye<_e;ye++){let Tr=nt(e[ye],ud,r,n,i,o,`${a}/${ye}`,ie);Tr.valid?(c[ye]=!0,ve++):ee.push(...Tr.errors)}ve>=(An||0)&&(ee.length=X),An===void 0&&v===void 0&&ve===0?ee.splice(X,0,{instanceLocation:a,keyword:"contains",keywordLocation:ie,error:"Array does not contain item matching schema."}):An!==void 0&&ve<An?ee.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${An} items matching schema. Only ${ve} items were found.`}):v!==void 0&&ve>v&&ee.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${v} items matching schema. ${ve} items were found.`})}if(!Ie&&cd!==void 0){let ie=`${s}/unevaluatedItems`;for(le;le<_e;le++){if(c[le])continue;let X=nt(e[le],cd,r,n,i,o,`${a}/${le}`,ie);c[le]=!0,X.valid||ee.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:ie,error:"Items did not match unevaluated items schema."},...X.errors)}}if(k)for(let ie=0;ie<_e;ie++){let X=e[ie],ve=typeof X=="object"&&X!==null;for(let ye=0;ye<_e;ye++){if(ie===ye)continue;let Tr=e[ye];(X===Tr||ve&&(typeof Tr=="object"&&Tr!==null)&&Ri(X,Tr))&&(ee.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${ie} and ${ye}.`}),ie=Number.MAX_SAFE_INTEGER,ye=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(r==="4"?(De!==void 0&&(Rt===!0&&e<=De||e<De)&&ee.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${Rt?"or equal to ":""} ${De}.`}),qe!==void 0&&(It===!0&&e>=qe||e>qe)&&ee.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${It?"or equal to ":""} ${qe}.`})):(De!==void 0&&e<De&&ee.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${De}.`}),qe!==void 0&&e>qe&&ee.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${qe}.`}),Rt!==void 0&&e<=Rt&&ee.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${Rt}.`}),It!==void 0&&e>=It&&ee.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${It}.`})),Qt!==void 0){let _e=e%Qt;Math.abs(0-_e)>=11920929e-14&&Math.abs(Qt-_e)>=11920929e-14&&ee.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Qt}.`})}}else if(l==="string"){let _e=sn===void 0&&St===void 0?0:rj(e);sn!==void 0&&_e<sn&&ee.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${_e} < ${sn}).`}),St!==void 0&&_e>St&&ee.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${_e} > ${St}).`}),ui!==void 0&&!new RegExp(ui,"u").test(e)&&ee.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),H!==void 0&&PS[H]&&!PS[H](e)&&ee.push({instanceLocation:a,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${H}".`})}return{valid:ee.length===0,errors:ee}}var Jg=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",n=!0){this.schema=t,this.draft=r,this.shortCircuit=n,this.lookup=Zn(t)}validate(t){return nt(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),Zn(t,this.lookup)}};var nj=P({Validator:()=>Jg,deepCompareStrict:()=>Ri,toJsonSchema:()=>dt,validatesOnlyStrings:()=>Uu});function dt(e,t){if(Ch(e)&&!We(e))return e["~standard"].jsonSchema.input({target:"draft-07"});if(We(e)){let r=Lg(e,!0);return bn(r)?mo(Tu(r,!0),t):mo(e,t)}return mt(e)?YM(e):e}function Uu(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=>Uu(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=>Uu(r))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,r=Zn(e);return r[t]?Uu(r[t]):!1}return!1}function wp(e){return e?e.lc_runnable:!1}var ij=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,n=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||n.some(i=>this.includeTags?.includes(i))),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&&n.every(i=>!this.excludeTags?.includes(i))),r}},oj=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function RS(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var Tq=["*","_","`"];function Aq(e){let t="";for(let[r,n]of Object.entries(e))t+=` classDef ${r} ${n};
|
|
109
|
+
`;return t}function aj(e,t,r){let{firstNode:n,lastNode:i,nodeColors:o,withStyles:a=!0,curveStyle:s="linear",wrapLabelNWords:c=9}=r??{},u=a?`%%{init: {'flowchart': {'curve': '${s}'}}}%%
|
|
110
|
+
graph TD;
|
|
111
|
+
`:`graph TD;
|
|
112
|
+
`;if(a){let m="default",h={[m]:"{0}({1})"};n!==void 0&&(h[n]="{0}([{1}]):::first"),i!==void 0&&(h[i]="{0}([{1}]):::last");for(let[w,_]of Object.entries(e)){let y=_.name.split(":").pop()??"",x=Tq.some($=>y.startsWith($)&&y.endsWith($))?`<p>${y}</p>`:y;Object.keys(_.metadata??{}).length&&(x+=`<hr/><small><em>${Object.entries(_.metadata??{}).map(([$,j])=>`${$} = ${j}`).join(`
|
|
113
|
+
`)}</em></small>`);let S=(h[w]??h[m]).replace("{0}",RS(w)).replace("{1}",x);u+=` ${S}
|
|
114
|
+
`}}let l={};for(let m of t){let h=m.source.split(":"),w=m.target.split(":"),_=h.filter((y,x)=>y===w[x]).join(":");l[_]||(l[_]=[]),l[_].push(m)}let d=new Set;function f(m){return[...m].sort((h,w)=>h.split(":").length-w.split(":").length)}function p(m,h){let w=m.length===1&&m[0].source===m[0].target;if(h&&!w){let y=h.split(":").pop();if(d.has(h))throw new Error(`Found duplicate subgraph '${y}' at '${h} -- 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(h),u+=` subgraph ${y}
|
|
115
|
+
`}let _=f(Object.keys(l).filter(y=>y.startsWith(`${h}:`)&&y!==h&&y.split(":").length===h.split(":").length+1));for(let y of _)p(l[y],y);for(let y of m){let{source:x,target:S,data:$,conditional:j}=y,C="";if($!==void 0){let b=$,H=b.split(" ");H.length>c&&(b=Array.from({length:Math.ceil(H.length/c)},(R,V)=>H.slice(V*c,(V+1)*c).join(" ")).join(" <br> ")),C=j?` -. ${b} .-> `:` -- ${b} --> `}else C=j?" -.-> ":" --> ";u+=` ${RS(x)}${C}${RS(S)};
|
|
116
|
+
`}h&&!w&&(u+=` end
|
|
117
|
+
`)}p(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&p(l[m],m);return a&&(u+=Aq(o??{})),u}async function sj(e,t){let r=t?.backgroundColor??"white",n=t?.imageType??"png",i=oj(e);r!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(r)||(r=`!${r}`));let o=`https://mermaid.ink/img/${i}?bgColor=${r}&type=${n}`,a=await fetch(o);if(!a.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${a.status}`,`Status text: ${a.statusText}`].join(`
|
|
118
|
+
`));return await a.blob()}var lj=P({Graph:()=>Gs});function Oq(e,t){if(e!==void 0&&!Qo(e))return e;if(wp(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 Cq(e){return wp(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...dt(e.data.schema),title:e.data.name}}}var Gs=class dj{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,n)=>{t[r.id]=Qo(r.id)?n:r.id}),{nodes:Object.values(this.nodes).map(r=>({id:t[r.id],...Cq(r)})),edges:this.edges.map(r=>{let n={source:t[r.source],target:t[r.target]};return typeof r.data<"u"&&(n.data=r.data),typeof r.conditional<"u"&&(n.conditional=r.conditional),n})}}addNode(t,r,n){if(r!==void 0&&this.nodes[r]!==void 0)throw new Error(`Node with id ${r} already exists`);let i=r??fb(),o={id:i,data:t,name:Oq(r,t),metadata:n};return this.nodes[i]=o,o}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(r=>r.source!==t.id&&r.target!==t.id)}addEdge(t,r,n,i){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 o={source:t.id,target:r.id,data:n,conditional:i};return this.edges.push(o),o}firstNode(){return cj(this)}lastNode(){return uj(this)}extend(t,r=""){let n=r;Object.values(t.nodes).map(c=>c.id).every(Qo)&&(n="");let i=c=>n?`${n}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[i(c)]={...u,id:i(c)}});let o=t.edges.map(c=>({...c,source:i(c.source),target:i(c.target)}));this.edges=[...this.edges,...o];let a=t.firstNode(),s=t.lastNode();return[a?{id:i(a.id),data:a.data}:void 0,s?{id:i(s.id),data:s.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&cj(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&uj(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),r=new Map;Object.values(t).forEach(i=>{r.set(i,(r.get(i)||0)+1)});let n=i=>{let o=t[i];return Qo(i)&&r.get(o)===1?o:i};return new dj({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,o])=>[n(i),{...o,id:n(i)}])),edges:this.edges.map(i=>({...i,source:n(i.source),target:n(i.target)}))})}drawMermaid(t){let{withStyles:r,curveStyle:n,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:o}=t??{},a=this.reid(),s=a.firstNode(),c=a.lastNode();return aj(a.nodes,a.edges,{firstNode:s?.id,lastNode:c?.id,withStyles:r,curveStyle:n,nodeColors:i,wrapLabelNWords:o})}async drawMermaidPng(t){return sj(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function cj(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.source)).map(i=>i.target)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function uj(e,t=[]){let r=new Set(e.edges.filter(i=>!t.includes(i.target)).map(i=>i.source)),n=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!r.has(i.id)&&n.push(i);return n.length===1?n[0]:void 0}function Xg({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 pj=e=>e.name==="event_stream_tracer",fj=class extends Jt{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=Ct.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(n=>this.includeTags?.includes(n))!==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(n=>!this.excludeTags?.includes(n))),r}async*tapOutputIterable(e,t){let r=await t.next();if(r.done)return;let n=this.runInfoMap.get(e);if(n===void 0){yield r.value;return}function i(a,s){return a==="llm"&&typeof s=="string"?new Si({text:s}):s}let o=this.tappedPromises.get(e);if(o===void 0){let a;o=new Promise(s=>{a=s}),this.tappedPromises.set(e,o);try{let s={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...s,data:{chunk:i(n.runType,r.value)}},n),yield r.value;for await(let c of t)n.runType!=="tool"&&n.runType!=="retriever"&&await this.send({...s,data:{chunk:i(n.runType,c)}},n),yield c}finally{a?.()}}else{yield r.value;for await(let a of t)yield a}}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=Xg(e),r=e.inputs.messages!==void 0?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:r,inputs:e.inputs};this.runInfoMap.set(e.id,n);let i=`on_${r}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,r){let n=this.runInfoMap.get(e.id),i,o;if(n===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(n.runType==="chat_model")o="on_chat_model_stream",r?.chunk===void 0?i=new at({content:t,id:`run-${e.id}`}):i=r.chunk.message;else if(n.runType==="llm")o="on_llm_stream",r?.chunk===void 0?i=new Si({text:t}):i=r.chunk;else throw new Error(`Unexpected run type ${n.runType}`);await this.send({event:o,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}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 n=e.outputs?.generations,i;if(t.runType==="chat_model"){for(let o of n??[]){if(i!==void 0)break;i=o[0]?.message}r="on_chat_model_end"}else if(t.runType==="llm")i={generations:n?.map(o=>o.map(a=>({text:a.text,generationInfo:a.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:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){let t=Xg(e),r=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},i={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(i={},n.inputs={}):e.inputs.input!==void 0?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${r}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}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`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&Object.keys(n).length===1&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:r,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=Xg(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=Xg(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 n=this.runInfoMap.get(r);if(n===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:n.tags,metadata:n.metadata,data:t},n)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}};var NS=class extends Jt{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:r,onError:n}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=r,this.argOnError=n}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 mj(e){let t=new TextEncoder,r=new ReadableStream({async start(n){for await(let i of e)n.enqueue(t.encode(`event: data
|
|
119
|
+
data: ${JSON.stringify(i)}
|
|
120
|
+
|
|
121
|
+
`));n.enqueue(t.encode(`event: end
|
|
122
|
+
|
|
123
|
+
`)),n.close()}});return Ct.fromReadableStream(r)}function MS(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var hj=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function Yg(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function jS(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function gj(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*zS(e,t){for(;;){let{value:r,done:n}=He.runWithConfig(br(e),t.next.bind(t),!0);if(n)break;yield r}}async function*Qg(e,t){let r=t[Symbol.asyncIterator]();for(;;){let{value:n,done:i}=await He.runWithConfig(br(e),r.next.bind(t),!0);if(i)break;yield n}}function Pt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var pe=class extends kt{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 t_({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Sn({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new DS({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(Ne);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(([n])=>n!=="runId"));return Array.from({length:t},(n,i)=>Ne(i===0?e:r))}return Array.from({length:t},()=>Ne(e))}async batch(e,t,r){let n=this._getOptionsList(t??{},e.length),i=new lo({maxConcurrency:n[0]?.maxConcurrency??r?.maxConcurrency,onFailedAttempt:a=>{throw a}}),o=e.map((a,s)=>i.call(async()=>{try{return await this.invoke(a,n[s])}catch(c){if(r?.returnExceptions)return c;throw c}}));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let r=Ne(t),n=new oa({generator:this._streamIterator(e,r),config:r});return await n.setup,Ct.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Ne(e):t=Ne({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 n=Ne(r),i=await(await Ot(n))?.handleChainStart(this.toJSON(),Pt(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName());delete n.runId;let o;try{o=await Kr(e.call(this,t,n,i),n.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(Pt(o,"output")),o}async _batchWithConfig(e,t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(Ot)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),Pt(t[u],"input"),i[u].runId,i[u].runType,void 0,void 0,i[u].runName??this.getName());return delete i[u].runId,l})),s;try{s=await Kr(e.call(this,t,i,a,n),i?.[0]?.signal)}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(Pt(s,"output")))),s}_concatOutputChunks(e,t){return Wr(e,t)}async*_transformStreamWithConfig(e,t,r){let n,i=!0,o,a=!0,s=Ne(r),c=await Ot(s),u=this;async function*l(){for await(let f of e){if(i)if(n===void 0)n=f;else try{n=u._concatOutputChunks(n,f)}catch{n=void 0,i=!1}yield f}}let d;try{let f=await Rw(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(pj),m=f.output;p!==void 0&&d!==void 0&&(m=p.tapOutputIterable(d.runId,m));let h=d?.handlers.find(Mw);h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));for await(let w of m)if(yield w,a)if(o===void 0)o=w;else try{o=this._concatOutputChunks(o,w)}catch{o=void 0,a=!1}}catch(f){throw await d?.handleChainError(f,void 0,void 0,void 0,{inputs:Pt(n,"input")}),f}await d?.handleChainEnd(o??{},void 0,void 0,void 0,{inputs:Pt(n,"input")})}getGraph(e){let t=new Gs,r=t.addNode({name:`${this.getName()}Input`,schema:Vt.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:Vt.any()});return t.addEdge(r,n),t.addEdge(n,i),t}pipe(e){return new tn({first:this,last:yt(e)})}pick(e){return this.pipe(new LS(e))}assign(e){return this.pipe(new Ip(new Ia({steps:e})))}async*transform(e,t){let r;for await(let n of e)r===void 0?r=n:r=this._concatOutputChunks(r,n);yield*this._streamIterator(r,Ne(t))}async*streamLog(e,t,r){let n=new Th({...r,autoClose:!1,_schemaFormat:"original"}),i=Ne(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,r){let{callbacks:n}=r;if(n===void 0)r.callbacks=[t];else if(Array.isArray(n))r.callbacks=n.concat([t]);else{let s=n.copy();s.addHandler(t,!0),r.callbacks=s}let i=this.stream(e,r);async function o(){try{let s=await i;for await(let c of s){let u=new Ii({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let a=o();try{for await(let s of t)yield s}finally{await a}}streamEvents(e,t,r){let n;if(t.version==="v1")n=this._streamEventsV1(e,t,r);else if(t.version==="v2")n=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"?mj(n):Ct.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,r){let n=new fj({...r,autoClose:!1}),i=Ne(t),o=i.runId??mn();i.runId=o;let a=i.callbacks;if(a===void 0)i.callbacks=[n];else if(Array.isArray(a))i.callbacks=a.concat(n);else{let p=a.copy();p.addHandler(n,!0),i.callbacks=p}let s=new AbortController,c=this;async function u(){let p;try{if(i.signal)if("any"in AbortSignal)p=AbortSignal.any([s.signal,i.signal]);else{let w=new AbortController;i.signal.addEventListener("abort",()=>w.abort(),{once:!0}),s.signal.addEventListener("abort",()=>w.abort(),{once:!0}),p=w.signal}else p=s.signal;let m=await c.stream(e,{...i,signal:p}),h=n.tapOutputIterable(o,m);for await(let w of h)if(s.signal.aborted)break}finally{await n.finish()}}let l=u(),d=!1,f;try{for await(let p of n){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 n,i=!1,o=Ne(t),a=o.tags??[],s=o.metadata??{},c=o.runName??this.getName(),u=new Th({...r,autoClose:!1,_schemaFormat:"streaming_events"}),l=new ij({...r}),d=this._streamLog(e,u,o);for await(let p of d){if(n?n=n.concat(p):n=$h.fromRunLogPatch(p),n.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;let _={...n.state},y={run_id:_.id,event:`on_${_.type}_start`,name:c,tags:a,metadata:s,data:{input:e}};l.includeEvent(y,_.type)&&(yield y)}let m=p.ops.filter(_=>_.path.startsWith("/logs/")).map(_=>_.path.split("/")[2]),h=[...new Set(m)];for(let _ of h){let y,x={},S=n.state.logs[_];if(S.end_time===void 0?S.streamed_output.length>0?y="stream":y="start":y="end",y==="start")S.inputs!==void 0&&(x.input=S.inputs);else if(y==="end")S.inputs!==void 0&&(x.input=S.inputs),x.output=S.final_output;else if(y==="stream"){let $=S.streamed_output.length;if($!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${$} instead. Encountered in: "${S.name}"`);x={chunk:S.streamed_output[0]},S.streamed_output=[]}yield{event:`on_${S.type}_${y}`,name:S.name,run_id:S.id,tags:S.tags,metadata:S.metadata,data:x}}let{state:w}=n;if(w.streamed_output.length>0){let _=w.streamed_output.length;if(_!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${_} instead. Encountered in: "${w.name}"`);let y={chunk:w.streamed_output[0]};w.streamed_output=[];let x={event:`on_${w.type}_stream`,run_id:w.id,tags:a,metadata:s,name:c,data:y};l.includeEvent(x,w.type)&&(yield x)}}let f=n?.state;if(f!==void 0){let p={event:`on_${f.type}_end`,name:c,run_id:f.id,tags:a,metadata:s,data:{output:f.final_output}};l.includeEvent(p,f.type)&&(yield p)}}static isRunnable(e){return wp(e)}withListeners({onStart:e,onEnd:t,onError:r}){return new Sn({bound:this,config:{},configFactories:[n=>({callbacks:[new NS({config:n,onStart:e,onEnd:t,onError:r})]})]})}asTool(e){return Nq(this,e)}},Sn=class _j extends pe{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=Bt(this.config,...t);return Bt(r,...this.configFactories?await Promise.all(this.configFactories.map(async n=>await n(r))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new t_({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,n){let i=Array.isArray(r)?await Promise.all(r.map(async o=>this._mergeConfig(Ne(o),this.kwargs))):await this._mergeConfig(Ne(r),this.kwargs);return this.bound.batch(t,i,n)}_concatOutputChunks(t,r){return this.bound._concatOutputChunks(t,r)}async*_streamIterator(t,r){yield*this.bound._streamIterator(t,await this._mergeConfig(Ne(r),this.kwargs))}async stream(t,r){return this.bound.stream(t,await this._mergeConfig(Ne(r),this.kwargs))}async*transform(t,r){yield*this.bound.transform(t,await this._mergeConfig(Ne(r),this.kwargs))}streamEvents(t,r,n){let i=this,o=async function*(){yield*i.bound.streamEvents(t,{...await i._mergeConfig(Ne(r),i.kwargs),version:r.version},n)};return Ct.fromAsyncGenerator(o())}static isRunnableBinding(t){return t.bound&&pe.isRunnable(t.bound)}withListeners({onStart:t,onEnd:r,onError:n}){return new _j({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new NS({config:i,onStart:t,onEnd:r,onError:n})]})]})}},yj=class vj extends pe{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,n){return this.bound.batch(t,Me(r,{callbacks:n?.getChild()}))}withListeners({onStart:t,onEnd:r,onError:n}){return new vj({bound:this.bound.withListeners({onStart:t,onEnd:r,onError:n})})}},t_=class extends Sn{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 n=e>1?`retry:attempt:${e}`:void 0;return Me(t,{callbacks:r?.getChild(n)})}async _invoke(e,t,r){return Zd(n=>super.invoke(e,this._patchConfigForRetry(n,t,r)),{onFailedAttempt:({error:n})=>this.onFailedAttempt(n,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,n){let i={};try{await Zd(async o=>{let a=e.map((d,f)=>f).filter(d=>i[d.toString()]===void 0||i[d.toString()]instanceof Error),s=a.map(d=>e[d]),c=a.map(d=>this._patchConfigForRetry(o,t?.[d],r?.[d])),u=await super.batch(s,c,{...n,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let f=u[d],p=a[d];f instanceof Error&&l===void 0&&(l=f,l.input=s[d]),i[p.toString()]=f}if(l)throw l;return u},{onFailedAttempt:({error:o})=>this.onFailedAttempt(o,o.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(o){if(n?.returnExceptions!==!0)throw o}return Object.keys(i).sort((o,a)=>parseInt(o,10)-parseInt(a,10)).map(o=>i[parseInt(o,10)])}async batch(e,t,r){return this._batchWithConfig(this._batch.bind(this),e,t,r)}},tn=class xp extends pe{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 n=Ne(r),i=await(await Ot(n))?.handleChainStart(this.toJSON(),Pt(t,"input"),n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o=t,a;try{let s=[this.first,...this.middle];for(let c=0;c<s.length;c+=1)o=await Kr(s[c].invoke(o,Me(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),n.signal);if(n.signal?.aborted)throw ia(n.signal);a=await this.last.invoke(o,Me(n,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(s){throw await i?.handleChainError(s),s}return await i?.handleChainEnd(Pt(a,"output")),a}async batch(t,r,n){let i=this._getOptionsList(r??{},t.length),o=await Promise.all(i.map(Ot)),a=await Promise.all(o.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),Pt(t[u],"input"),i[u].runId,void 0,void 0,void 0,i[u].runName);return delete i[u].runId,l})),s=t;try{for(let c=0;c<this.steps.length;c+=1)s=await Kr(this.steps[c].batch(s,a.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Me(i[l],{callbacks:d})}),n),i[0]?.signal)}catch(c){throw await Promise.all(a.map(u=>u?.handleChainError(c))),c}return await Promise.all(a.map(c=>c?.handleChainEnd(Pt(s,"output")))),s}_concatOutputChunks(t,r){return this.last._concatOutputChunks(t,r)}async*_streamIterator(t,r){let n=await Ot(r),{runId:i,...o}=r??{},a=await n?.handleChainStart(this.toJSON(),Pt(t,"input"),i,void 0,void 0,void 0,o?.runName),s=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=s[0].transform(l(),Me(o,{callbacks:a?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let f=1;f<s.length;f+=1)d=await s[f].transform(d,Me(o,{callbacks:a?.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 a?.handleChainError(d),d}await a?.handleChainEnd(Pt(u,"output"))}getGraph(t){let r=new Gs,n=null;return this.steps.forEach((i,o)=>{let a=i.getGraph(t);o!==0&&a.trimFirstNode(),o!==this.steps.length-1&&a.trimLastNode(),r.extend(a);let s=a.firstNode();if(!s)throw new Error(`Runnable ${i} has no first node`);n&&r.addEdge(n,s),n=a.lastNode()}),r}pipe(t){return xp.isRunnableSequence(t)?new xp({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new xp({first:this.first,middle:[...this.middle,this.last],last:yt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&pe.isRunnable(t)}static from([t,...r],n){let i={};return typeof n=="string"?i.name=n:n!==void 0&&(i=n),new xp({...i,first:yt(t),middle:r.slice(0,-1).map(yt),last:yt(r[r.length-1])})}},Ia=class bj extends pe{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,n]of Object.entries(t.steps))this.steps[r]=yt(n)}static from(t){return new bj({steps:t})}async invoke(t,r){let n=Ne(r),i=await(await Ot(n))?.handleChainStart(this.toJSON(),{input:t},n.runId,void 0,void 0,void 0,n?.runName);delete n.runId;let o={};try{let a=Object.entries(this.steps).map(async([s,c])=>{o[s]=await c.invoke(t,Me(n,{callbacks:i?.getChild(`map:key:${s}`)}))});await Kr(Promise.all(a),n.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(o),o}async*_transform(t,r,n){let i={...this.steps},o=bh(t,Object.keys(i).length),a=new Map(Object.entries(i).map(([s,c],u)=>{let l=c.transform(o[u],Me(n,{callbacks:r?.getChild(`map:key:${s}`)}));return[s,l.next().then(d=>({key:s,gen:l,result:d}))]}));for(;a.size;){let{key:s,result:c,gen:u}=await Kr(Promise.race(a.values()),n?.signal);a.delete(s),c.done||(yield{[s]:c.value},a.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*n(){yield t}let i=Ne(r),o=new oa({generator:this.transform(n(),i),config:i});return await o.setup,Ct.fromAsyncGenerator(o)}},Pq=class wj extends pe{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!_h(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[n]=this._getOptionsList(r??{},1),i=await Ot(n);return Kr(this.func(Me(n,{callbacks:i}),t),n?.signal)}async*_streamIterator(t,r){let[n]=this._getOptionsList(r??{},1),i=await this.invoke(t,r);if(Yg(i)){for await(let o of i)n?.signal?.throwIfAborted(),yield o;return}if(hj(i)){for(;;){n?.signal?.throwIfAborted();let o=i.next();if(o.done)break;yield o.value}return}yield i}static from(t){return new wj({func:t})}};function Rq(e){if(_h(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var Zt=class xj extends pe{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(_h(t.func))return Pq.from(t.func);super(t),Rq(t.func),this.func=t.func}static from(t){return new xj({func:t})}async _invoke(t,r,n){return new Promise((i,o)=>{let a=Me(r,{callbacks:n?.getChild(),recursionLimit:(r?.recursionLimit??25)-1});He.runWithConfig(br(a),async()=>{try{let s=await this.func(t,{...a});if(s&&pe.isRunnable(s)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");s=await s.invoke(t,{...a,recursionLimit:(a.recursionLimit??25)-1})}else if(Yg(s)){let c;for await(let u of Qg(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}else if(MS(s)){let c;for(let u of zS(a,s))if(r?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}s=c}i(s)}catch(s){o(s)}})})}async invoke(t,r){return this._callWithConfig(this._invoke.bind(this),t,r)}async*_transform(t,r,n){let i;for await(let s of t)if(i===void 0)i=s;else try{i=this._concatOutputChunks(i,s)}catch{i=s}let o=Me(n,{callbacks:r?.getChild(),recursionLimit:(n?.recursionLimit??25)-1}),a=await new Promise((s,c)=>{He.runWithConfig(br(o),async()=>{try{s(await this.func(i,{...o,config:o}))}catch(u){c(u)}})});if(a&&pe.isRunnable(a)){if(n?.recursionLimit===0)throw new Error("Recursion limit reached.");let s=await a.stream(i,o);for await(let c of s)yield c}else if(Yg(a))for await(let s of Qg(o,a))n?.signal?.throwIfAborted(),yield s;else if(MS(a))for(let s of zS(o,a))n?.signal?.throwIfAborted(),yield s;else yield a}transform(t,r){return this._transformStreamWithConfig(t,this._transform.bind(this),r)}async stream(t,r){async function*n(){yield t}let i=Ne(r),o=new oa({generator:this.transform(n(),i),config:i});return await o.setup,Ct.fromAsyncGenerator(o)}},Ij=class extends Ia{},DS=class extends pe{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=Ne(t),n=await Ot(r),{runId:i,...o}=r,a=await n?.handleChainStart(this.toJSON(),Pt(e,"input"),i,void 0,void 0,void 0,o?.runName),s=Me(o,{callbacks:a?.getChild()});return await He.runWithConfig(s,async()=>{let c;for(let u of this.runnables()){r?.signal?.throwIfAborted();try{let l=await u.invoke(e,s);return await a?.handleChainEnd(Pt(l,"output")),l}catch(l){c===void 0&&(c=l)}}throw c===void 0?new Error("No error stored at end of fallback."):(await a?.handleChainError(c),c)})}async*_streamIterator(e,t){let r=Ne(t),n=await Ot(r),{runId:i,...o}=r,a=await n?.handleChainStart(this.toJSON(),Pt(e,"input"),i,void 0,void 0,void 0,o?.runName),s,c;for(let l of this.runnables()){r?.signal?.throwIfAborted();let d=Me(o,{callbacks:a?.getChild()});try{c=Qg(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 a?.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 a?.handleChainError(l),l}await a?.handleChainEnd(Pt(u,"output"))}async batch(e,t,r){if(r?.returnExceptions)throw new Error("Not implemented.");let n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(s=>Ot(s))),o=await Promise.all(i.map(async(s,c)=>{let u=await s?.handleChainStart(this.toJSON(),Pt(e[c],"input"),n[c].runId,void 0,void 0,void 0,n[c].runName);return delete n[c].runId,u})),a;for(let s of this.runnables()){n[0].signal?.throwIfAborted();try{let c=await s.batch(e,o.map((u,l)=>Me(n[l],{callbacks:u?.getChild()})),r);return await Promise.all(o.map((u,l)=>u?.handleChainEnd(Pt(c[l],"output")))),c}catch(c){a===void 0&&(a=c)}}throw a?(await Promise.all(o.map(s=>s?.handleChainError(a))),a):new Error("No error stored at end of fallbacks.")}};function yt(e){if(typeof e=="function")return new Zt({func:e});if(pe.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=yt(n);return new Ia({steps:t})}else throw new Error(`Expected a Runnable, function or object.
|
|
124
|
+
Instead got an unsupported type.`)}var Ip=class extends pe{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof Ia&&(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 n=this.mapper.getStepsKeys(),[i,o]=bh(e),a=this.mapper.transform(o,Me(r,{callbacks:t?.getChild()})),s=a.next();for await(let c of i){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])=>!n.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await s).value;for await(let c of a)yield c}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*r(){yield e}let n=Ne(t),i=new oa({generator:this.transform(r(),n),config:n});return await i.setup,Ct.fromAsyncGenerator(i)}},LS=class extends pe{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 n=Ne(t),i=new oa({generator:this.transform(r(),n),config:n});return await i.setup,Ct.fromAsyncGenerator(i)}},e_=class extends Sn{name;description;schema;constructor(e){let t=tn.from([Zt.from(async r=>{let n;if(Yo(r))try{n=await ya(this.schema,r.args)}catch{throw new qc("Received tool input did not match expected schema",JSON.stringify(r.args))}else n=r;return n}).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 Nq(e,t){let r=t.name??e.getName(),n=t.description??Un(t.schema);return Ou(t.schema)?new e_({name:r,description:n,schema:Vt.object({input:Vt.string()}).transform(i=>i.input),bound:e}):new e_({name:r,description:n,schema:t.schema,bound:e})}var r_=(e,t)=>{let r=[...new Set(t?.map(i=>{if(typeof i=="string")return i;let o=new i({});if(!("getType"in o)||typeof o.getType!="function")throw new Error("Invalid type provided.");return o.getType()}))],n=e.getType();return r.some(i=>i===n)};function Tj(e,t){return Array.isArray(e)?Sj(e,t):Zt.from(r=>Sj(r,e))}function Sj(e,t={}){let{includeNames:r,excludeNames:n,includeTypes:i,excludeTypes:o,includeIds:a,excludeIds:s}=t,c=[];for(let u of e)if(!(n&&u.name&&n.includes(u.name))){{if(o&&r_(u,o))continue;if(s&&u.id&&s.includes(u.id))continue}i||a||r?(r&&u.name&&r.some(l=>l===u.name)||i&&r_(u,i)||a&&u.id&&a.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function Aj(e){return Array.isArray(e)?kj(e):Zt.from(kj)}function kj(e){if(!e.length)return[];let t=[];for(let r of e){let n=r,i=t.pop();if(!i)t.push(n);else if(n.getType()==="tool"||n.getType()!==i.getType())t.push(i,n);else{let o=us(i),a=us(n),s=o.concat(a);typeof o.content=="string"&&typeof a.content=="string"&&(s.content=`${o.content}
|
|
125
|
+
${a.content}`),t.push(jq(s))}}return t}function Oj(e,t){if(Array.isArray(e)){let r=e;if(!t)throw new Error("Options parameter is required when providing messages.");return Ej(r,t)}else{let r=e;return Zt.from(n=>Ej(n,r)).withConfig({runName:"trim_messages"})}}async function Ej(e,t){let{maxTokens:r,tokenCounter:n,strategy:i="last",allowPartial:o=!1,endOn:a,startOn:s,includeSystem:c=!1,textSplitter:u}=t;if(s&&i==="first")throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(c&&i==="first")throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let l;"getNumTokens"in n?l=async f=>(await Promise.all(f.map(p=>n.getNumTokens(p.content)))).reduce((p,m)=>p+m,0):l=async f=>n(f);let d=FS;if(u&&("splitText"in u?d=u.splitText:d=async f=>u(f)),i==="first")return Cj(e,{maxTokens:r,tokenCounter:l,textSplitter:d,partialStrategy:o?"first":void 0,endOn:a});if(i==="last")return Mq(e,{maxTokens:r,tokenCounter:l,textSplitter:d,allowPartial:o,includeSystem:c,startOn:s,endOn:a});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function Cj(e,t){let{maxTokens:r,tokenCounter:n,textSplitter:i,partialStrategy:o,endOn:a}=t,s=[...e],c=0;for(let u=0;u<s.length;u+=1)if(await n(u>0?s.slice(0,-u):s)<=r){c=s.length-u;break}if(c<s.length&&o){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=o==="last"?[...l.content].reverse():l.content;for(let p=1;p<=d;p+=1){let m=o==="first"?f.slice(0,p):f.slice(-p),h=Object.fromEntries(Object.entries(l).filter(([y])=>y!=="type"&&!y.startsWith("lc_"))),w=US(l.getType(),{...h,content:m}),_=[...s.slice(0,c),w];if(await n(_)<=r)s=_,c+=1,u=!0;else break}u&&o==="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 i(d),p=f.length;o==="last"&&f.reverse();for(let m=0;m<p-1;m+=1)if(f.pop(),l.content=f.join(""),await n([...s.slice(0,c),l])<=r){o==="last"&&(l.content=[...f].reverse().join("")),s=[...s.slice(0,c),l],c+=1;break}}}}if(a){let u=Array.isArray(a)?a:[a];for(;c>0&&!r_(s[c-1],u);)c-=1}return s.slice(0,c)}async function Mq(e,t){let{allowPartial:r=!1,includeSystem:n=!1,endOn:i,startOn:o,...a}=t,s=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([f])=>f!=="type"&&!f.startsWith("lc_")));return US(l.getType(),d,oo(l))});if(i){let l=Array.isArray(i)?i:[i];for(;s.length>0&&!r_(s[s.length-1],l);)s=s.slice(0,-1)}let c=n&&s[0]?.getType()==="system",u=c?s.slice(0,1).concat(s.slice(1).reverse()):s.reverse();return u=await Cj(u,{...a,partialStrategy:r?"last":void 0,endOn:o}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var $j={human:{message:st,messageChunk:co},ai:{message:be,messageChunk:at},system:{message:hr,messageChunk:fn},developer:{message:hr,messageChunk:fn},tool:{message:jt,messageChunk:Xo},function:{message:cs,messageChunk:so},generic:{message:mr,messageChunk:ao},remove:{message:Mn,messageChunk:Mn}};function US(e,t,r){let n,i;switch(e){case"human":r?n=new co(t):i=new st(t);break;case"ai":if(r){let o={...t};"tool_calls"in o&&(o={...o,tool_call_chunks:o.tool_calls?.map(a=>({...a,type:"tool_call_chunk",index:void 0,args:JSON.stringify(a.args)}))}),n=new at(o)}else i=new be(t);break;case"system":r?n=new fn(t):i=new hr(t);break;case"developer":r?n=new fn({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):i=new hr({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)r?n=new Xo(t):i=new jt(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(r)n=new so(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");i=new cs(t)}break;case"generic":if("role"in t)r?n=new ao(t):i=new mr(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&&n)return n;if(i)return i;throw new Error(`Unrecognized message type ${e}`)}function jq(e){let t=e.getType(),r,n=Object.fromEntries(Object.entries(e).filter(([i])=>!["type","tool_call_chunks"].includes(i)&&!i.startsWith("lc_")));if(t in $j&&(r=US(t,n)),!r)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys($j)}`);return r}function FS(e){let t=e.split(`
|
|
126
|
+
`);return Promise.resolve([...t.slice(0,-1).map(r=>`${r}
|
|
127
|
+
`),t[t.length-1]])}var Pj=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"];var Rj=["image","video","audio","text-plain","file"];var Nj=["text","reasoning",...Pj,...Rj];var Mj=P({AIMessage:()=>be,AIMessageChunk:()=>at,BaseMessage:()=>tt,BaseMessageChunk:()=>fr,ChatMessage:()=>mr,ChatMessageChunk:()=>ao,DEFAULT_MERGE_IGNORE_KEYS:()=>nb,FunctionMessage:()=>cs,FunctionMessageChunk:()=>so,HumanMessage:()=>st,HumanMessageChunk:()=>co,KNOWN_BLOCK_TYPES:()=>Nj,RemoveMessage:()=>Mn,SystemMessage:()=>hr,SystemMessageChunk:()=>fn,ToolMessage:()=>jt,ToolMessageChunk:()=>Xo,_isMessageFieldWithRole:()=>Im,_mergeDicts:()=>pt,_mergeLists:()=>Jo,_mergeObj:()=>xm,_mergeStatus:()=>wm,coerceMessageLikeToMessage:()=>tr,collapseToolCallChunks:()=>km,convertToChunk:()=>us,convertToOpenAIImageBlock:()=>_m,convertToProviderContentBlock:()=>Hc,defaultTextSplitter:()=>FS,defaultToolCallParser:()=>Id,filterMessages:()=>Tj,getBufferString:()=>Wc,iife:()=>$m,isAIMessage:()=>hi,isAIMessageChunk:()=>Sd,isBase64ContentBlock:()=>Gc,isBaseMessage:()=>ft,isBaseMessageChunk:()=>oo,isChatMessage:()=>uO,isChatMessageChunk:()=>lO,isDataContentBlock:()=>Or,isDirectToolOutput:()=>xd,isFunctionMessage:()=>dO,isFunctionMessageChunk:()=>pO,isHumanMessage:()=>fO,isHumanMessageChunk:()=>mO,isIDContentBlock:()=>gm,isMessage:()=>bm,isOpenAIToolCallArray:()=>FA,isPlainTextContentBlock:()=>AA,isSystemMessage:()=>hO,isSystemMessageChunk:()=>gO,isToolMessage:()=>as,isToolMessageChunk:()=>ib,isURLContentBlock:()=>Zc,mapChatMessagesToStoredMessages:()=>yO,mapStoredMessageToChatMessage:()=>kd,mapStoredMessagesToChatMessages:()=>_O,mergeContent:()=>er,mergeMessageRuns:()=>Aj,mergeResponseMetadata:()=>Sm,mergeUsageMetadata:()=>Kc,parseBase64DataUrl:()=>Wo,parseMimeType:()=>wd,trimMessages:()=>Oj});var jj=P({BaseChatMessageHistory:()=>BS,BaseListChatMessageHistory:()=>n_,InMemoryChatMessageHistory:()=>zq}),BS=class extends kt{async addMessages(e){for(let t of e)await this.addMessage(t)}},n_=class extends kt{addUserMessage(e){return this.addMessage(new st(e))}addAIMessage(e){return this.addMessage(new be(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},zq=class extends n_{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 rn=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};var VS=class extends pe{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},zj=class extends VS{async transformDocuments(e){let t=[];for(let r of e){let n=await this._transformDocument(r);t.push(n)}return t}};var Dj=P({BaseDocumentTransformer:()=>VS,Document:()=>rn,MappingDocumentTransformer:()=>zj});var Lj=P({BaseDocumentLoader:()=>ZS}),ZS=class{};var Uj=P({LangSmithLoader:()=>Dq}),Dq=class extends ZS{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 yi(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??Lq,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 o of this.contentKey)r=r[o];let n=this.formatContent(r),i=t;["created_at","modified_at"].forEach(o=>{o in i&&typeof i[o]=="object"&&(i[o]=i[o].toString())}),e.push({pageContent:n,metadata:i})}return e}};function Lq(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var Fj=P({Embeddings:()=>Fu}),Fu=class{caller;constructor(e){this.caller=new lo(e??{})}};var Bu=class extends kt{lc_namespace=["langchain_core","example_selectors","base"]};var GS=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},Bj=class extends GS{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 Vj(e){return e._modelType()==="base_llm"}function Zj(e){return e._modelType()==="base_chat_model"}function Gj(e){return e.split(/\n| /).length}var Hj=class qj extends Bu{examples=[];examplePrompt;getTextLength=Gj;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??Gj}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:n,examplePrompt:i}=r;return(await Promise.all(n.map(o=>i.format(o)))).map(o=>this.getTextLength(o))}async selectExamples(t){let r=Object.values(t).join(" "),n=this.maxLength-this.getTextLength(r),i=0,o=[];for(;n>0&&i<this.examples.length;){let a=n-this.exampleTextLengths[i];if(a<0)break;o.push(this.examples[i]),n=a,i+=1}return o}static async fromExamples(t,r){let n=new qj(r);return await Promise.all(t.map(i=>n.addExample(i))),n}};function HS(e){return Object.keys(e).sort().map(t=>e[t])}var Kj=class Wj extends Bu{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=HS((this.inputKeys??Object.keys(t)).reduce((n,i)=>({...n,[i]:t[i]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new rn({pageContent:r,metadata:t})])}async selectExamples(t){let r=HS((this.inputKeys??Object.keys(t)).reduce((i,o)=>({...i,[o]:t[o]}),{})).join(" "),n=(await this.vectorStoreRetriever.invoke(r)).map(i=>i.metadata);return this.exampleKeys?n.map(i=>this.exampleKeys.reduce((o,a)=>({...o,[a]:i[a]}),{})):n}static async fromExamples(t,r,n,i={}){let o=i.inputKeys??null,a=t.map(s=>HS(o?o.reduce((c,u)=>({...c,[u]:s[u]}),{}):s).join(" "));return new Wj({vectorStore:await n.fromTexts(a,t,r,i),k:i.k??4,exampleKeys:i.exampleKeys,inputKeys:i.inputKeys})}};var Jj=P({BaseExampleSelector:()=>Bu,BasePromptSelector:()=>GS,ConditionalPromptSelector:()=>Bj,LengthBasedExampleSelector:()=>Hj,SemanticSimilarityExampleSelector:()=>Kj,isChatModel:()=>Zj,isLLM:()=>Vj});var Sp="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",Xj=class extends kt{lc_namespace=["langchain","recordmanagers"]};var qS=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=Vc;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 rn({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 Tm(this.keyEncoder(e),Sp)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return Tm(this.keyEncoder(t),Sp)}};function KS(e,t){let r=[],n=[];return t.forEach(i=>{n.push(i),n.length>=e&&(r.push(n),n=[])}),n.length>0&&r.push(n),r}function WS(e){let t=new Set,r=[];for(let n of e){if(!n.hash_)throw new Error("Hashed document does not have a hash");t.has(n.hash_)||(t.add(n.hash_),r.push(n))}return r}function JS(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 XS=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function Yj(e){let{docsSource:t,recordManager:r,vectorStore:n,options:i}=e,{batchSize:o=100,cleanup:a,sourceIdKey:s,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=i??{};if(a==="incremental"&&!s)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=XS(t)?await t.load():t,d=JS(s??null),f=await r.getTime(),p=0,m=0,h=0,w=0,_=KS(o??100,l);for(let y of _){let x=WS(y.map(R=>qS.fromDocument(R))),S=x.map(R=>d(R));a==="incremental"&&x.forEach((R,V)=>{if(S[V]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let $=await r.exists(x.map(R=>R.uid)),j=[],C=[],b=[],H=new Set;if(x.forEach((R,V)=>{if($[V])if(u)H.add(R.uid);else{b.push(R.uid);return}j.push(R.uid),C.push(R.toDocument())}),b.length>0&&(await r.update(b,{timeAtLeast:f}),w+=b.length),C.length>0&&(await n.addDocuments(C,{ids:j}),p+=C.length-H.size,h+=H.size),await r.update(x.map(R=>R.uid),{timeAtLeast:f,groupIds:S}),a==="incremental"){S.forEach(V=>{if(!V)throw new Error("Source id cannot be null")});let R=await r.listKeys({before:f,groupIds:S});R.length>0&&(await n.delete({ids:R}),await r.deleteKeys(R),m+=R.length)}}if(a==="full"){let y=await r.listKeys({before:f,limit:c});for(;y.length>0;)await n.delete({ids:y}),await r.deleteKeys(y),m+=y.length,y=await r.listKeys({before:f,limit:c})}return{numAdded:p,numDeleted:m,numUpdated:h,numSkipped:w}}var Qj=P({RecordManager:()=>Xj,UUIDV5_NAMESPACE:()=>Sp,_HashedDocument:()=>qS,_batch:()=>KS,_deduplicateInOrder:()=>WS,_getSourceIdAssigner:()=>JS,_isBaseDocumentLoader:()=>XS,index:()=>Yj});var ez=P({BasePromptValue:()=>i_,ChatPromptValue:()=>Ep,ImagePromptValue:()=>YS,StringPromptValue:()=>kp}),i_=class extends kt{},kp=class extends i_{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 st(this.value)]}},Ep=class extends i_{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 Wc(this.messages)}toChatMessages(){return this.messages}},YS=class extends i_{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 st({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}};var iz=qo(nz(),1),qq=Object.defineProperty,Kq=(e,t,r)=>t in e?qq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wq=(e,t,r)=>(Kq(e,typeof t!="symbol"?t+"":t,r),r);function Jq(e,t){let r=Array.from({length:e.length},(n,i)=>({start:i,end:i+1}));for(;r.length>1;){let n=null;for(let i=0;i<r.length-1;i++){let o=e.slice(r[i].start,r[i+1].end),a=t.get(o.join(","));a!=null&&(n==null||a<n[0])&&(n=[a,i])}if(n!=null){let i=n[1];r[i]={start:r[i].start,end:r[i+1].end},r.splice(i+1,1)}else break}return r}function Xq(e,t){return e.length===1?[t.get(e.join(","))]:Jq(e,t).map(r=>t.get(e.slice(r.start,r.end).join(","))).filter(r=>r!=null)}function Yq(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var ek=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(`
|
|
128
|
+
`).filter(Boolean).reduce((n,i)=>{let[o,a,...s]=i.split(" "),c=Number.parseInt(a,10);return s.forEach((u,l)=>n[u]=c+l),n},{});for(let[n,i]of Object.entries(r)){let o=iz.default.toByteArray(n);this.rankMap.set(o.join(","),i),this.textMap.set(i,o)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((n,[i,o])=>(n[o]=this.textEncoder.encode(i),n),{})}encode(e,t=[],r="all"){let n=new RegExp(this.patStr,"ug"),i=ek.specialTokenRegex(Object.keys(this.specialTokens)),o=[],a=new Set(t==="all"?Object.keys(this.specialTokens):t),s=new Set(r==="all"?Object.keys(this.specialTokens).filter(u=>!a.has(u)):r);if(s.size>0){let u=ek.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(;i.lastIndex=l,u=i.exec(e),!(u==null||a.has(u[0]));)l=u.index+1;let d=u?.index??e.length;for(let p of e.substring(c,d).matchAll(n)){let m=this.textEncoder.encode(p[0]),h=this.rankMap.get(m.join(","));if(h!=null){o.push(h);continue}o.push(...Xq(m,this.rankMap))}if(u==null)break;let f=this.specialTokens[u[0]];o.push(f),c=u.index+u[0].length}return o}decode(e){let t=[],r=0;for(let o=0;o<e.length;++o){let a=e[o],s=this.textMap.get(a)??this.inverseSpecialTokens[a];s!=null&&(t.push(s),r+=s.length)}let n=new Uint8Array(r),i=0;for(let o of t)n.set(o,i),i+=o.length;return this.textDecoder.decode(n)}},a_=ek;Wq(a_,"specialTokenRegex",e=>new RegExp(e.map(t=>Yq(t)).join("|"),"g"));function tk(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 oz=P({encodingForModel:()=>c_,getEncoding:()=>az}),s_={},Qq=new lo({});async function az(e){return e in s_||(s_[e]=Qq.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new a_(t)).catch(t=>{throw delete s_[e],t})),await s_[e]}async function c_(e){return az(tk(e))}var sz=P({BaseLangChain:()=>l_,BaseLanguageModel:()=>Tp,calculateMaxTokens:()=>uz,getEmbeddingContextSize:()=>eK,getModelContextSize:()=>cz,getModelNameForTiktoken:()=>u_,isOpenAITool:()=>$p}),u_=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,eK=e=>e==="text-embedding-ada-002"?8191:2046,cz=e=>{switch(u_(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 $p(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 uz=async({prompt:e,modelName:t})=>{let r;try{r=(await c_(u_(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 cz(t)-r},tK=()=>!1,l_=class extends pe{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??tK(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.35")}_addVersion(e,t){let r=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof r=="object"&&r!==null?r:{},[e]:t}}}},Tp=class extends l_{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...r}){let{cache:n,...i}=r;super({callbacks:e??t,...i}),typeof n=="object"?this.cache=n:n?this.cache=cb.global():this.cache=void 0,this.caller=new lo(r??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(n=>typeof n=="string"?n:n.type==="text"&&"text"in n?n.text:"").join("");let r=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await c_("modelName"in this?u_(this.modelName):"gpt2")}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}if(this._encoding)try{r=this._encoding.encode(t).length}catch(n){console.warn("Failed to calculate number of tokens, falling back to approximate count",n)}return r}static _convertInputToPromptValue(e){return typeof e=="string"?new kp(e):Array.isArray(e)?new Ep(e.map(tr)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let r={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(r).filter(([n,i])=>i!==void 0).map(([n,i])=>`${n}:${JSON.stringify(i)}`).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 bo=class extends pe{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=Ne(t);return this.func&&await this.func(e,r),this._callWithConfig(n=>Promise.resolve(n),e,r)}async*transform(e,t){let r=Ne(t),n,i=!0;for await(let o of this._transformStreamWithConfig(e,a=>a,r))if(yield o,i)if(n===void 0)n=o;else try{n=Wr(n,o)}catch{n=void 0,i=!1}this.func&&n!==void 0&&await this.func(n,r)}static assign(e){return new Ip(new Ia({steps:e}))}};var lz=class extends pe{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:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.invoke(n,Ne(t))}async batch(e,t,r){let n=e.map(l=>l.key),i=e.map(l=>l.input);if(n.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let o=n.map(l=>this.runnables[l]),a=this._getOptionsList(t??{},e.length),s=a[0]?.maxConcurrency??r?.maxConcurrency,c=s&&s>0?s:e.length,u=[];for(let l=0;l<i.length;l+=c){let d=i.slice(l,l+c).map((p,m)=>o[m].invoke(p,a[m])),f=await Promise.all(d);u.push(f)}return u.flat()}async stream(e,t){let{key:r,input:n}=e,i=this.runnables[r];if(i===void 0)throw new Error(`No runnable associated with key "${r}".`);return i.stream(n,t)}};var dz=class extends pe{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(([n,i])=>[yt(n),yt(i)]),r=yt(e[e.length-1]);return new this({branches:t,default:r})}async _invoke(e,t,r){let n;for(let i=0;i<this.branches.length;i+=1){let[o,a]=this.branches[i];if(await o.invoke(e,Me(t,{callbacks:r?.getChild(`condition:${i+1}`)}))){n=await a.invoke(e,Me(t,{callbacks:r?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,Me(t,{callbacks:r?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let r=await(await Ot(t))?.handleChainStart(this.toJSON(),Pt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),n,i=!0,o;try{for(let a=0;a<this.branches.length;a+=1){let[s,c]=this.branches[a];if(await s.invoke(e,Me(t,{callbacks:r?.getChild(`condition:${a+1}`)}))){o=await c.stream(e,Me(t,{callbacks:r?.getChild(`branch:${a+1}`)}));for await(let u of o)if(yield u,i)if(n===void 0)n=u;else try{n=Wr(n,u)}catch{n=void 0,i=!1}break}}if(o===void 0){o=await this.default.stream(e,Me(t,{callbacks:r?.getChild("branch:default")}));for await(let a of o)if(yield a,i)if(n===void 0)n=a;else try{n=Wr(n,a)}catch{n=void 0,i=!1}}}catch(a){throw await r?.handleChainError(a),a}await r?.handleChainEnd(n??{})}};var pz=class extends Sn{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=Zt.from((o,a)=>this._enterHistory(o,a??{})).withConfig({runName:"loadHistory"}),r=e.historyMessagesKey??e.inputMessagesKey;r&&(t=bo.assign({[r]:t}).withConfig({runName:"insertHistory"}));let n=t.pipe(e.runnable.withListeners({onEnd:(o,a)=>this._exitHistory(o,a??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),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)&&!ft(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 st(t)];if(Array.isArray(t))return t;if(ft(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
129
|
+
Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!ft(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 be(t)];if(Array.isArray(t))return t;if(ft(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,n;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?n=e.inputs[0]:n=e.inputs;let i=this._getInputMessages(n);if(this.historyMessagesKey===void 0){let s=await r.getMessages();i=i.slice(s.length)}let o=e.outputs;if(!o)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let a=this._getOutputMessages(o);await r.addMessages([...i,...a])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let n={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
130
|
+
eg. chain.invoke(${JSON.stringify(n)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:r}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(r),t}};var fz=P({RouterRunnable:()=>lz,Runnable:()=>pe,RunnableAssign:()=>Ip,RunnableBinding:()=>Sn,RunnableBranch:()=>dz,RunnableEach:()=>yj,RunnableLambda:()=>Zt,RunnableMap:()=>Ia,RunnableParallel:()=>Ij,RunnablePassthrough:()=>bo,RunnablePick:()=>LS,RunnableRetry:()=>t_,RunnableSequence:()=>tn,RunnableToolLike:()=>e_,RunnableWithFallbacks:()=>DS,RunnableWithMessageHistory:()=>pz,_coerceToRunnable:()=>yt,ensureConfig:()=>Ne,getCallbackManagerForConfig:()=>Ot,mergeConfigs:()=>Bt,patchConfig:()=>Me,pickRunnableConfigKeys:()=>br,raceWithSignal:()=>Kr});var mz=P({applyPatch:()=>aa,compare:()=>sa});var Vu=class extends pe{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,n)=>this.parseResult([{text:r}],n?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(r,n)=>this.parseResult([{message:r,text:this._baseMessageToString(r)}],n?.callbacks),e,{...t,runType:"parser"})}},Gn=class extends Vu{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")}},ar=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,r,n=!1){if(super(e),this.llmOutput=t,this.observation=r,this.sendToLLM=n,n&&(r===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");io(this,"OUTPUT_PARSING_FAILURE")}};var wo=class extends Gn{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"})}},ji=class extends wo{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,r;for await(let n of e){if(typeof n!="string"&&typeof n.content!="string")throw new Error("Cannot handle non-string output.");let i;if(oo(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new Xr({message:n,text:n.content})}else if(ft(n)){if(typeof n.content!="string")throw new Error("Cannot handle non-string message output.");i=new Xr({message:us(n),text:n.content})}else i=new Si({text:n});r===void 0?r=i:r=r.concat(i);let o=await this.parsePartialResult([r]);o!=null&&!Ri(o,t)&&(this.diff?yield this._diff(t,o):yield o,t=o)}}getFormatInstructions(){return""}};var hz=class extends wo{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 Zu=class extends wo{re;async*_transform(e){let t="";for await(let r of e)if(typeof r=="string"?t+=r:t+=r.content,this.re){let n=[...t.matchAll(this.re)];if(n.length>1){let i=0;for(let o of n.slice(0,-1))yield[o[1]],i+=(o.index??0)+o[0].length;t=t.slice(i)}}else{let n=await this.parse(t);if(n.length>1){for(let i of n.slice(0,-1))yield[i];t=n[n.length-1]}}for(let r of await this.parse(t))yield[r]}},gz=class extends Zu{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 ar(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},_z=class extends Zu{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 ar(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===ar.prototype?t:new ar(`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\`)`}},yz=class extends Zu{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:
|
|
131
|
+
|
|
132
|
+
1. foo
|
|
133
|
+
|
|
134
|
+
2. bar
|
|
135
|
+
|
|
136
|
+
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},vz=class extends Zu{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:
|
|
137
|
+
|
|
138
|
+
1. foo
|
|
139
|
+
|
|
140
|
+
2. bar
|
|
141
|
+
|
|
142
|
+
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}};var bz=class extends wo{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 Gu=class extends ji{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?sa(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return ss(e[0].text)}async parse(e){return ss(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}};var d_=class extends Gn{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=ss(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 ar(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}getFormatInstructions(){return""}};var Ap=class extends Gn{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=Vt.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Vt.string().describe(n)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
143
|
+
|
|
144
|
+
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
145
|
+
|
|
146
|
+
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
147
|
+
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.
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
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!
|
|
151
|
+
|
|
152
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
153
|
+
\`\`\`json
|
|
154
|
+
${JSON.stringify(dt(this.schema))}
|
|
155
|
+
\`\`\`
|
|
156
|
+
`}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,(n,i)=>`"${i.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await ya(this.schema,JSON.parse(r))}catch(t){throw new ar(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}},rk=class extends Ap{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:
|
|
157
|
+
\`\`\`json
|
|
158
|
+
${this._schemaToInstruction(dt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
|
|
159
|
+
\`\`\``}_schemaToInstruction(e,t=2){let r=e;if("type"in r){let n=!1,i;if(Array.isArray(r.type)){let s=r.type.findIndex(c=>c==="null");s!==-1&&(n=!0,r.type.splice(s,1)),i=r.type.join(" | ")}else i=r.type;if(r.type==="object"&&r.properties){let s=r.description?` // ${r.description}`:"";return`{
|
|
160
|
+
${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(`
|
|
161
|
+
`)}
|
|
162
|
+
${" ".repeat(t-2)}}${s}`}if(r.type==="array"&&r.items){let s=r.description?` // ${r.description}`:"";return`array[
|
|
163
|
+
${" ".repeat(t)}${this._schemaToInstruction(r.items,t+2)}
|
|
164
|
+
${" ".repeat(t-2)}] ${s}`}let o=n?" (nullable)":"",a=r.description?` // ${r.description}`:"";return`${i}${a}${o}`}if("anyOf"in r)return r.anyOf.map(n=>this._schemaToInstruction(n,t)).join(`
|
|
165
|
+
${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=Vt.object(Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Vt.string().describe(n)])));return new this(t)}},wz=class extends Gn{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new rk(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(r){throw new ar(`Failed to parse. Text: "${e}". Error: ${r}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}};var rK=function(){let e={};e.parser=function(v,g){return new r(v,g)},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(v,g){if(!(this instanceof r))return new r(v,g);var z=this;i(z),z.q=z.c="",z.bufferCheckPosition=e.MAX_BUFFER_LENGTH,z.opt=g||{},z.opt.lowercase=z.opt.lowercase||z.opt.lowercasetags,z.looseCase=z.opt.lowercase?"toLowerCase":"toUpperCase",z.tags=[],z.closed=z.closedRoot=z.sawRoot=!1,z.tag=z.error=null,z.strict=!!v,z.noscript=!!(v||z.opt.noscript),z.state=b.BEGIN,z.strictEntities=z.opt.strictEntities,z.ENTITIES=z.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),z.attribList=[],z.opt.xmlns&&(z.ns=Object.create(m)),z.trackPosition=z.opt.position!==!1,z.trackPosition&&(z.position=z.line=z.column=0),R(z,"onready")}Object.create||(Object.create=function(v){function g(){}return g.prototype=v,new g}),Object.keys||(Object.keys=function(v){var g=[];for(var z in v)v.hasOwnProperty(z)&&g.push(z);return g});function n(v){for(var g=Math.max(e.MAX_BUFFER_LENGTH,10),z=0,k=0,De=t.length;k<De;k++){var qe=v[t[k]].length;if(qe>g)switch(t[k]){case"textNode":xe(v);break;case"cdata":V(v,"oncdata",v.cdata),v.cdata="";break;case"script":V(v,"onscript",v.script),v.script="";break;default:qt(v,"Max buffer length exceeded: "+t[k])}z=Math.max(z,qe)}v.bufferCheckPosition=e.MAX_BUFFER_LENGTH-z+v.position}function i(v){for(var g=0,z=t.length;g<z;g++)v[t[g]]=""}function o(v){xe(v),v.cdata!==""&&(V(v,"oncdata",v.cdata),v.cdata=""),v.script!==""&&(V(v,"onscript",v.script),v.script="")}r.prototype={end:function(){Fr(this)},write:An,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a=ReadableStream;a||(a=function(){});var s=e.EVENTS.filter(function(v){return v!=="error"&&v!=="end"});function c(v,g){return new u(v,g)}function u(v,g){if(!(this instanceof u))return new u(v,g);a.apply(this),this._parser=new r(v,g),this.writable=!0,this.readable=!0;var z=this;this._parser.onend=function(){z.emit("end")},this._parser.onerror=function(k){z.emit("error",k),z._parser.error=null},this._decoder=null,s.forEach(function(k){Object.defineProperty(z,"on"+k,{get:function(){return z._parser["on"+k]},set:function(De){if(!De)return z.removeAllListeners(k),z._parser["on"+k]=De,De;z.on(k,De)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(a.prototype,{constructor:{value:u}}),u.prototype.write=function(v){return this._parser.write(v.toString()),this.emit("data",v),!0},u.prototype.end=function(v){return v&&v.length&&this.write(v),this._parser.end(),!0},u.prototype.on=function(v,g){var z=this;return!z._parser["on"+v]&&s.indexOf(v)!==-1&&(z._parser["on"+v]=function(){var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);k.splice(0,0,v),z.emit.apply(z,k)}),a.prototype.on.call(z,v,g)};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},h=/[:_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-]/,_=/[#:_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]/,y=/[#:_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 x(v){return v===" "||v===`
|
|
166
|
+
`||v==="\r"||v===" "}function S(v){return v==='"'||v==="'"}function $(v){return v===">"||x(v)}function j(v,g){return v.test(g)}function C(v,g){return!j(v,g)}var b=0;e.STATE={BEGIN:b++,BEGIN_WHITESPACE:b++,TEXT:b++,TEXT_ENTITY:b++,OPEN_WAKA:b++,SGML_DECL:b++,SGML_DECL_QUOTED:b++,DOCTYPE:b++,DOCTYPE_QUOTED:b++,DOCTYPE_DTD:b++,DOCTYPE_DTD_QUOTED:b++,COMMENT_STARTING:b++,COMMENT:b++,COMMENT_ENDING:b++,COMMENT_ENDED:b++,CDATA:b++,CDATA_ENDING:b++,CDATA_ENDING_2:b++,PROC_INST:b++,PROC_INST_BODY:b++,PROC_INST_ENDING:b++,OPEN_TAG:b++,OPEN_TAG_SLASH:b++,ATTRIB:b++,ATTRIB_NAME:b++,ATTRIB_NAME_SAW_WHITE:b++,ATTRIB_VALUE:b++,ATTRIB_VALUE_QUOTED:b++,ATTRIB_VALUE_CLOSED:b++,ATTRIB_VALUE_UNQUOTED:b++,ATTRIB_VALUE_ENTITY_Q:b++,ATTRIB_VALUE_ENTITY_U:b++,CLOSE_TAG:b++,CLOSE_TAG_SAW_WHITE:b++,SCRIPT:b++,SCRIPT_ENDING:b++},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(v){var g=e.ENTITIES[v],z=typeof g=="number"?String.fromCharCode(g):g;e.ENTITIES[v]=z});for(var H in e.STATE)e.STATE[e.STATE[H]]=H;b=e.STATE;function R(v,g,z){v[g]&&v[g](z)}function V(v,g,z){v.textNode&&xe(v),R(v,g,z)}function xe(v){v.textNode=Ge(v.opt,v.textNode),v.textNode&&R(v,"ontext",v.textNode),v.textNode=""}function Ge(v,g){return v.trim&&(g=g.trim()),v.normalize&&(g=g.replace(/\s+/g," ")),g}function qt(v,g){return xe(v),v.trackPosition&&(g+=`
|
|
167
|
+
Line: `+v.line+`
|
|
168
|
+
Column: `+v.column+`
|
|
169
|
+
Char: `+v.c),g=new Error(g),v.error=g,R(v,"onerror",g),v}function Fr(v){return v.sawRoot&&!v.closedRoot&&ze(v,"Unclosed root tag"),v.state!==b.BEGIN&&v.state!==b.BEGIN_WHITESPACE&&v.state!==b.TEXT&&qt(v,"Unexpected end"),xe(v),v.c="",v.closed=!0,R(v,"onend"),r.call(v,v.strict,v.opt),v}function ze(v,g){if(typeof v!="object"||!(v instanceof r))throw new Error("bad call to strictFail");v.strict&&qt(v,g)}function Xa(v){v.strict||(v.tagName=v.tagName[v.looseCase]());var g=v.tags[v.tags.length-1]||v,z=v.tag={name:v.tagName,attributes:{}};v.opt.xmlns&&(z.ns=g.ns),v.attribList.length=0,V(v,"onopentagstart",z)}function Yi(v,g){var z=v.indexOf(":")<0?["",v]:v.split(":"),k=z[0],De=z[1];return g&&v==="xmlns"&&(k="xmlns",De=""),{prefix:k,local:De}}function Ya(v){if(v.strict||(v.attribName=v.attribName[v.looseCase]()),v.attribList.indexOf(v.attribName)!==-1||v.tag.attributes.hasOwnProperty(v.attribName)){v.attribName=v.attribValue="";return}if(v.opt.xmlns){var g=Yi(v.attribName,!0),z=g.prefix,k=g.local;if(z==="xmlns")if(k==="xml"&&v.attribValue!==f)ze(v,"xml: prefix must be bound to "+f+`
|
|
170
|
+
Actual: `+v.attribValue);else if(k==="xmlns"&&v.attribValue!==p)ze(v,"xmlns: prefix must be bound to "+p+`
|
|
171
|
+
Actual: `+v.attribValue);else{var De=v.tag,qe=v.tags[v.tags.length-1]||v;De.ns===qe.ns&&(De.ns=Object.create(qe.ns)),De.ns[k]=v.attribValue}v.attribList.push([v.attribName,v.attribValue])}else v.tag.attributes[v.attribName]=v.attribValue,V(v,"onattribute",{name:v.attribName,value:v.attribValue});v.attribName=v.attribValue=""}function Tn(v,g){if(v.opt.xmlns){var z=v.tag,k=Yi(v.tagName);z.prefix=k.prefix,z.local=k.local,z.uri=z.ns[k.prefix]||"",z.prefix&&!z.uri&&(ze(v,"Unbound namespace prefix: "+JSON.stringify(v.tagName)),z.uri=k.prefix);var De=v.tags[v.tags.length-1]||v;z.ns&&De.ns!==z.ns&&Object.keys(z.ns).forEach(function(Qa){V(v,"onopennamespace",{prefix:Qa,uri:z.ns[Qa]})});for(var qe=0,Rt=v.attribList.length;qe<Rt;qe++){var It=v.attribList[qe],Qt=It[0],sn=It[1],St=Yi(Qt,!0),ui=St.prefix,Nc=St.local,qf=ui===""?"":z.ns[ui]||"",ee={name:Qt,value:sn,prefix:ui,local:Nc,uri:qf};ui&&ui!=="xmlns"&&!qf&&(ze(v,"Unbound namespace prefix: "+JSON.stringify(ui)),ee.uri=ui),v.tag.attributes[Qt]=ee,V(v,"onattribute",ee)}v.attribList.length=0}v.tag.isSelfClosing=!!g,v.sawRoot=!0,v.tags.push(v.tag),V(v,"onopentag",v.tag),g||(!v.noscript&&v.tagName.toLowerCase()==="script"?v.state=b.SCRIPT:v.state=b.TEXT,v.tag=null,v.tagName=""),v.attribName=v.attribValue="",v.attribList.length=0}function Qi(v){if(!v.tagName){ze(v,"Weird empty close tag."),v.textNode+="</>",v.state=b.TEXT;return}if(v.script){if(v.tagName!=="script"){v.script+="</"+v.tagName+">",v.tagName="",v.state=b.SCRIPT;return}V(v,"onscript",v.script),v.script=""}var g=v.tags.length,z=v.tagName;v.strict||(z=z[v.looseCase]());for(var k=z;g--&&v.tags[g].name!==k;)ze(v,"Unexpected close tag");if(g<0){ze(v,"Unmatched closing tag: "+v.tagName),v.textNode+="</"+v.tagName+">",v.state=b.TEXT;return}v.tagName=z;for(var De=v.tags.length;De-- >g;){var qe=v.tag=v.tags.pop();v.tagName=v.tag.name,V(v,"onclosetag",v.tagName);var Rt={};for(var It in qe.ns)Rt[It]=qe.ns[It];var Qt=v.tags[v.tags.length-1]||v;v.opt.xmlns&&qe.ns!==Qt.ns&&Object.keys(qe.ns).forEach(function(sn){var St=qe.ns[sn];V(v,"onclosenamespace",{prefix:sn,uri:St})})}g===0&&(v.closedRoot=!0),v.tagName=v.attribValue=v.attribName="",v.attribList.length=0,v.state=b.TEXT}function sd(v){var g=v.entity,z=g.toLowerCase(),k,De="";return v.ENTITIES[g]?v.ENTITIES[g]:v.ENTITIES[z]?v.ENTITIES[z]:(g=z,g.charAt(0)==="#"&&(g.charAt(1)==="x"?(g=g.slice(2),k=parseInt(g,16),De=k.toString(16)):(g=g.slice(1),k=parseInt(g,10),De=k.toString(10))),g=g.replace(/^0+/,""),isNaN(k)||De.toLowerCase()!==g?(ze(v,"Invalid character entity"),"&"+v.entity+";"):String.fromCodePoint(k))}function cd(v,g){g==="<"?(v.state=b.OPEN_WAKA,v.startTagPosition=v.position):x(g)||(ze(v,"Non-whitespace before first tag."),v.textNode=g,v.state=b.TEXT)}function ud(v,g){var z="";return g<v.length&&(z=v.charAt(g)),z}function An(v){var g=this;if(this.error)throw this.error;if(g.closed)return qt(g,"Cannot write after close. Assign an onready handler.");if(v===null)return Fr(g);typeof v=="object"&&(v=v.toString());for(var z=0,k="";k=ud(v,z++),g.c=k,!!k;)switch(g.trackPosition&&(g.position++,k===`
|
|
172
|
+
`?(g.line++,g.column=0):g.column++),g.state){case b.BEGIN:if(g.state=b.BEGIN_WHITESPACE,k==="\uFEFF")continue;cd(g,k);continue;case b.BEGIN_WHITESPACE:cd(g,k);continue;case b.TEXT:if(g.sawRoot&&!g.closedRoot){for(var De=z-1;k&&k!=="<"&&k!=="&";)k=ud(v,z++),k&&g.trackPosition&&(g.position++,k===`
|
|
173
|
+
`?(g.line++,g.column=0):g.column++);g.textNode+=v.substring(De,z-1)}k==="<"&&!(g.sawRoot&&g.closedRoot&&!g.strict)?(g.state=b.OPEN_WAKA,g.startTagPosition=g.position):(!x(k)&&(!g.sawRoot||g.closedRoot)&&ze(g,"Text data outside of root node."),k==="&"?g.state=b.TEXT_ENTITY:g.textNode+=k);continue;case b.SCRIPT:k==="<"?g.state=b.SCRIPT_ENDING:g.script+=k;continue;case b.SCRIPT_ENDING:k==="/"?g.state=b.CLOSE_TAG:(g.script+="<"+k,g.state=b.SCRIPT);continue;case b.OPEN_WAKA:if(k==="!")g.state=b.SGML_DECL,g.sgmlDecl="";else if(!x(k))if(j(h,k))g.state=b.OPEN_TAG,g.tagName=k;else if(k==="/")g.state=b.CLOSE_TAG,g.tagName="";else if(k==="?")g.state=b.PROC_INST,g.procInstName=g.procInstBody="";else{if(ze(g,"Unencoded <"),g.startTagPosition+1<g.position){var qe=g.position-g.startTagPosition;k=new Array(qe).join(" ")+k}g.textNode+="<"+k,g.state=b.TEXT}continue;case b.SGML_DECL:(g.sgmlDecl+k).toUpperCase()===l?(V(g,"onopencdata"),g.state=b.CDATA,g.sgmlDecl="",g.cdata=""):g.sgmlDecl+k==="--"?(g.state=b.COMMENT,g.comment="",g.sgmlDecl=""):(g.sgmlDecl+k).toUpperCase()===d?(g.state=b.DOCTYPE,(g.doctype||g.sawRoot)&&ze(g,"Inappropriately located doctype declaration"),g.doctype="",g.sgmlDecl=""):k===">"?(V(g,"onsgmldeclaration",g.sgmlDecl),g.sgmlDecl="",g.state=b.TEXT):(S(k)&&(g.state=b.SGML_DECL_QUOTED),g.sgmlDecl+=k);continue;case b.SGML_DECL_QUOTED:k===g.q&&(g.state=b.SGML_DECL,g.q=""),g.sgmlDecl+=k;continue;case b.DOCTYPE:k===">"?(g.state=b.TEXT,V(g,"ondoctype",g.doctype),g.doctype=!0):(g.doctype+=k,k==="["?g.state=b.DOCTYPE_DTD:S(k)&&(g.state=b.DOCTYPE_QUOTED,g.q=k));continue;case b.DOCTYPE_QUOTED:g.doctype+=k,k===g.q&&(g.q="",g.state=b.DOCTYPE);continue;case b.DOCTYPE_DTD:g.doctype+=k,k==="]"?g.state=b.DOCTYPE:S(k)&&(g.state=b.DOCTYPE_DTD_QUOTED,g.q=k);continue;case b.DOCTYPE_DTD_QUOTED:g.doctype+=k,k===g.q&&(g.state=b.DOCTYPE_DTD,g.q="");continue;case b.COMMENT:k==="-"?g.state=b.COMMENT_ENDING:g.comment+=k;continue;case b.COMMENT_ENDING:k==="-"?(g.state=b.COMMENT_ENDED,g.comment=Ge(g.opt,g.comment),g.comment&&V(g,"oncomment",g.comment),g.comment=""):(g.comment+="-"+k,g.state=b.COMMENT);continue;case b.COMMENT_ENDED:k!==">"?(ze(g,"Malformed comment"),g.comment+="--"+k,g.state=b.COMMENT):g.state=b.TEXT;continue;case b.CDATA:k==="]"?g.state=b.CDATA_ENDING:g.cdata+=k;continue;case b.CDATA_ENDING:k==="]"?g.state=b.CDATA_ENDING_2:(g.cdata+="]"+k,g.state=b.CDATA);continue;case b.CDATA_ENDING_2:k===">"?(g.cdata&&V(g,"oncdata",g.cdata),V(g,"onclosecdata"),g.cdata="",g.state=b.TEXT):k==="]"?g.cdata+="]":(g.cdata+="]]"+k,g.state=b.CDATA);continue;case b.PROC_INST:k==="?"?g.state=b.PROC_INST_ENDING:x(k)?g.state=b.PROC_INST_BODY:g.procInstName+=k;continue;case b.PROC_INST_BODY:if(!g.procInstBody&&x(k))continue;k==="?"?g.state=b.PROC_INST_ENDING:g.procInstBody+=k;continue;case b.PROC_INST_ENDING:k===">"?(V(g,"onprocessinginstruction",{name:g.procInstName,body:g.procInstBody}),g.procInstName=g.procInstBody="",g.state=b.TEXT):(g.procInstBody+="?"+k,g.state=b.PROC_INST_BODY);continue;case b.OPEN_TAG:j(w,k)?g.tagName+=k:(Xa(g),k===">"?Tn(g):k==="/"?g.state=b.OPEN_TAG_SLASH:(x(k)||ze(g,"Invalid character in tag name"),g.state=b.ATTRIB));continue;case b.OPEN_TAG_SLASH:k===">"?(Tn(g,!0),Qi(g)):(ze(g,"Forward-slash in opening tag not followed by >"),g.state=b.ATTRIB);continue;case b.ATTRIB:if(x(k))continue;k===">"?Tn(g):k==="/"?g.state=b.OPEN_TAG_SLASH:j(h,k)?(g.attribName=k,g.attribValue="",g.state=b.ATTRIB_NAME):ze(g,"Invalid attribute name");continue;case b.ATTRIB_NAME:k==="="?g.state=b.ATTRIB_VALUE:k===">"?(ze(g,"Attribute without value"),g.attribValue=g.attribName,Ya(g),Tn(g)):x(k)?g.state=b.ATTRIB_NAME_SAW_WHITE:j(w,k)?g.attribName+=k:ze(g,"Invalid attribute name");continue;case b.ATTRIB_NAME_SAW_WHITE:if(k==="=")g.state=b.ATTRIB_VALUE;else{if(x(k))continue;ze(g,"Attribute without value"),g.tag.attributes[g.attribName]="",g.attribValue="",V(g,"onattribute",{name:g.attribName,value:""}),g.attribName="",k===">"?Tn(g):j(h,k)?(g.attribName=k,g.state=b.ATTRIB_NAME):(ze(g,"Invalid attribute name"),g.state=b.ATTRIB)}continue;case b.ATTRIB_VALUE:if(x(k))continue;S(k)?(g.q=k,g.state=b.ATTRIB_VALUE_QUOTED):(ze(g,"Unquoted attribute value"),g.state=b.ATTRIB_VALUE_UNQUOTED,g.attribValue=k);continue;case b.ATTRIB_VALUE_QUOTED:if(k!==g.q){k==="&"?g.state=b.ATTRIB_VALUE_ENTITY_Q:g.attribValue+=k;continue}Ya(g),g.q="",g.state=b.ATTRIB_VALUE_CLOSED;continue;case b.ATTRIB_VALUE_CLOSED:x(k)?g.state=b.ATTRIB:k===">"?Tn(g):k==="/"?g.state=b.OPEN_TAG_SLASH:j(h,k)?(ze(g,"No whitespace between attributes"),g.attribName=k,g.attribValue="",g.state=b.ATTRIB_NAME):ze(g,"Invalid attribute name");continue;case b.ATTRIB_VALUE_UNQUOTED:if(!$(k)){k==="&"?g.state=b.ATTRIB_VALUE_ENTITY_U:g.attribValue+=k;continue}Ya(g),k===">"?Tn(g):g.state=b.ATTRIB;continue;case b.CLOSE_TAG:if(g.tagName)k===">"?Qi(g):j(w,k)?g.tagName+=k:g.script?(g.script+="</"+g.tagName,g.tagName="",g.state=b.SCRIPT):(x(k)||ze(g,"Invalid tagname in closing tag"),g.state=b.CLOSE_TAG_SAW_WHITE);else{if(x(k))continue;C(h,k)?g.script?(g.script+="</"+k,g.state=b.SCRIPT):ze(g,"Invalid tagname in closing tag."):g.tagName=k}continue;case b.CLOSE_TAG_SAW_WHITE:if(x(k))continue;k===">"?Qi(g):ze(g,"Invalid characters in closing tag");continue;case b.TEXT_ENTITY:case b.ATTRIB_VALUE_ENTITY_Q:case b.ATTRIB_VALUE_ENTITY_U:var Rt,It;switch(g.state){case b.TEXT_ENTITY:Rt=b.TEXT,It="textNode";break;case b.ATTRIB_VALUE_ENTITY_Q:Rt=b.ATTRIB_VALUE_QUOTED,It="attribValue";break;case b.ATTRIB_VALUE_ENTITY_U:Rt=b.ATTRIB_VALUE_UNQUOTED,It="attribValue";break}if(k===";")if(g.opt.unparsedEntities){var Qt=sd(g);g.entity="",g.state=Rt,g.write(Qt)}else g[It]+=sd(g),g.entity="",g.state=Rt;else j(g.entity.length?y:_,k)?g.entity+=k:(ze(g,"Invalid character in entity name"),g[It]+="&"+g.entity+k,g.entity="",g.state=Rt);continue;default:throw new Error(g,"Unknown state: "+g.state)}return g.position>=g.bufferCheckPosition&&n(g),g}return String.fromCodePoint||(function(){var v=String.fromCharCode,g=Math.floor,z=function(){var k=16384,De=[],qe,Rt,It=-1,Qt=arguments.length;if(!Qt)return"";for(var sn="";++It<Qt;){var St=Number(arguments[It]);if(!isFinite(St)||St<0||St>1114111||g(St)!==St)throw RangeError("Invalid code point: "+St);St<=65535?De.push(St):(St-=65536,qe=(St>>10)+55296,Rt=St%1024+56320,De.push(qe,Rt)),(It+1===Qt||De.length>k)&&(sn+=v.apply(null,De),De.length=0)}return sn};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:z,configurable:!0,writable:!0}):String.fromCodePoint=z})(),e},xz=rK();var p_=`The output should be formatted as a XML file.
|
|
174
|
+
1. Output should conform to the tags below.
|
|
175
|
+
2. If tags are not given, make them on your own.
|
|
176
|
+
3. Remember to always open and close all the tags.
|
|
177
|
+
|
|
178
|
+
As an example, for the tags ["foo", "bar", "baz"]:
|
|
179
|
+
1. String "<foo>
|
|
180
|
+
<bar>
|
|
181
|
+
<baz></baz>
|
|
182
|
+
</bar>
|
|
183
|
+
</foo>" is a well-formatted instance of the schema.
|
|
184
|
+
2. String "<foo>
|
|
185
|
+
<bar>
|
|
186
|
+
</foo>" is a badly-formatted instance.
|
|
187
|
+
3. String "<foo>
|
|
188
|
+
<tag>
|
|
189
|
+
</tag>
|
|
190
|
+
</foo>" is a badly-formatted instance.
|
|
191
|
+
|
|
192
|
+
Here are the output tags:
|
|
193
|
+
\`\`\`
|
|
194
|
+
{tags}
|
|
195
|
+
\`\`\``,Iz=class extends ji{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?sa(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return f_(e[0].text)}async parse(e){return f_(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?p_.replace("{tags}",this.tags?.join(", ")??""):p_}},nK=e=>e.split(`
|
|
196
|
+
`).map(t=>t.replace(/^\s+/,"")).join(`
|
|
197
|
+
`).trim(),Sz=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(Sz),t):(t[e.name]=e.text??void 0,t)};function f_(e){let t=nK(e),r=xz.parser(!0),n={},i=[];r.onopentag=s=>{let c={name:s.name,attributes:s.attributes,children:[],text:"",isSelfClosing:s.isSelfClosing};i.length>0?i[i.length-1].children.push(c):n=c,s.isSelfClosing||i.push(c)},r.onclosetag=()=>{if(i.length>0){let s=i.pop();i.length===0&&s&&(n=s)}},r.ontext=s=>{if(i.length>0){let c=i[i.length-1];c.text+=s}},r.onattribute=s=>{if(i.length>0){let c=i[i.length-1];c.attributes[s.name]=s.value}};let o=/```(xml)?(.*)```/s.exec(t),a=o?o[2]:t;return r.write(a).close(),n&&n.name==="?xml"&&(n=n.children[0]),Sz(n)}var kz=P({AsymmetricStructuredOutputParser:()=>wz,BaseCumulativeTransformOutputParser:()=>ji,BaseLLMOutputParser:()=>Vu,BaseOutputParser:()=>Gn,BaseTransformOutputParser:()=>wo,BytesOutputParser:()=>hz,CommaSeparatedListOutputParser:()=>gz,CustomListOutputParser:()=>_z,JsonMarkdownStructuredOutputParser:()=>rk,JsonOutputParser:()=>Gu,ListOutputParser:()=>Zu,MarkdownListOutputParser:()=>vz,NumberedListOutputParser:()=>yz,OutputParserException:()=>ar,StandardSchemaOutputParser:()=>d_,StringOutputParser:()=>bz,StructuredOutputParser:()=>Ap,XMLOutputParser:()=>Iz,XML_FORMAT_INSTRUCTIONS:()=>p_,parseJsonMarkdown:()=>ss,parsePartialJson:()=>mi,parseXMLMarkdown:()=>f_});var Ez=P({extendInteropZodObject:()=>zg,getInteropZodDefaultGetter:()=>Dg,getInteropZodObjectShape:()=>Ts,getSchemaDescription:()=>Un,interopParse:()=>Au,interopParseAsync:()=>ya,interopSafeParse:()=>aM,interopSafeParseAsync:()=>jg,interopZodObjectMakeFieldsOptional:()=>cM,interopZodObjectPartial:()=>Cu,interopZodObjectPassthrough:()=>Mg,interopZodObjectStrict:()=>Tu,interopZodTransformInputSchema:()=>Lg,isInteropZodError:()=>Ug,isInteropZodLiteral:()=>oM,isInteropZodObject:()=>Ir,isInteropZodSchema:()=>zt,isShapelessZodSchema:()=>sM,isSimpleStringZodSchema:()=>Ou,isZodArrayV4:()=>gp,isZodLiteralV3:()=>wS,isZodLiteralV4:()=>xS,isZodNullableV4:()=>SS,isZodObjectV3:()=>hp,isZodObjectV4:()=>bn,isZodOptionalV4:()=>IS,isZodSchema:()=>iM,isZodSchemaV3:()=>mt,isZodSchemaV4:()=>We});function qs(e,t){if(e.function===void 0)return;let r;if(t?.partial)try{r=mi(e.function.arguments??"{}")}catch{return}else try{r=JSON.parse(e.function.arguments)}catch(i){throw new ar([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${i.message}`].join(`
|
|
198
|
+
`))}let n={name:e.function.name,args:r,type:"tool_call"};return t?.returnId&&(n.id=e.id),n}function m_(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 Sa(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var nk=class extends ji{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,n;if(hi(r)&&r.tool_calls?.length?n=r.tool_calls.map(o=>{let{id:a,...s}=o;return this.returnId?{id:a,...s}:s}):r.additional_kwargs.tool_calls!==void 0&&(n=JSON.parse(JSON.stringify(r.additional_kwargs.tool_calls)).map(o=>qs(o,{returnId:this.returnId,partial:t}))),!n)return[];let i=[];for(let o of n)if(o!==void 0){let a={type:o.name,args:o.args,id:o.id};i.push(a)}return i}},h_=class extends nk{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 ar(`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 jg(this.zodSchema,e);if(t.success)return t.data;throw new ar(`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(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?r[0]:r}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(n=>n.type===this.keyName),r=t;if(t.length)return this.returnId||(r=t.map(n=>n.args)),this.returnSingle?this._validateResult(r[0]):await Promise.all(r.map(n=>this._validateResult(n)))}};var $z=P({assembleStructuredOutputPipeline:()=>Op,createContentParser:()=>g_,createFunctionCallingParser:()=>ik});function g_(e){return zt(e)?Ap.fromZodSchema(e):ki(e)?d_.fromSerializableSchema(e):new Gu}function ik(e,t,r){let n=r??h_;return zt(e)?new n({returnSingle:!0,keyName:t,zodSchema:e}):ki(e)?new n({returnSingle:!0,keyName:t,serializableSchema:e}):new n({returnSingle:!0,keyName:t})}function Op(e,t,r,n){if(!r){let c=e.pipe(t);return n?c.withConfig({runName:n}):c}let i=bo.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),o=bo.assign({parsed:()=>null}),a=i.withFallbacks({fallbacks:[o]}),s=tn.from([{raw:e},a]);return n?s.withConfig({runName:n}):s}var Tz=e=>e();function __(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}function ka(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>t!=="tools"&&r!==null&&r!==void 0))}var Az=P({BaseChatModel:()=>zi,SimpleChatModel:()=>iK});function ok(e){let t=[];for(let r of e){let n=r;if(Array.isArray(r.content))for(let i=0;i<r.content.length;i++){let o=r.content[i];(Zc(o)||Gc(o))&&n===r&&(n=new r.constructor({...n,content:[...r.content.slice(0,i),_m(o),...r.content.slice(i+1)]}))}t.push(n)}return t}var zi=class Ks extends Tp{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=Tz(()=>{let r=t.outputVersion??et("LC_OUTPUT_VERSION");return r&&["v0","v1"].includes(r)?r:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async invoke(t,r){let n=Ks._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}async*_streamIterator(t,r){if(this._streamResponseChunks===Ks.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,r);else{let n=Ks._convertInputToPromptValue(t).toChatMessages(),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a={...i.metadata,...this.getLsParamsWithDefaults(o)},s=this?.invocationParams(o),c=ka(s),u=Et.configure(i.callbacks,this.callbacks,i.tags,this.tags,a,{...c,...this.metadata},{verbose:this.verbose}),l={options:o,invocation_params:s,batch_size:1},d=o.outputVersion??this.outputVersion,f=await u?.handleChatModelStart(this.toJSON(),[ok(n)],i.runId,void 0,l,void 0,void 0,i.runName),p,m;try{for await(let h of this._streamResponseChunks(n,o,f?.[0])){if(o.signal?.throwIfAborted(),h.message.id==null){let w=f?.at(0)?.runId;w!=null&&h.message._updateId(`run-${w}`)}h.message.response_metadata={...h.generationInfo,...h.message.response_metadata},d==="v1"?yield __(h.message):yield h.message,p?p=p.concat(h):p=h,Sd(h.message)&&h.message.usage_metadata!==void 0&&(m={tokenUsage:{promptTokens:h.message.usage_metadata.input_tokens,completionTokens:h.message.usage_metadata.output_tokens,totalTokens:h.message.usage_metadata.total_tokens}})}o.signal?.throwIfAborted()}catch(h){throw await Promise.all((f??[]).map(w=>w?.handleLLMError(h))),h}await Promise.all((f??[]).map(h=>h?.handleLLMEnd({generations:[[p]],llmOutput:m})))}}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,n,i){let o=t.map(d=>d.map(tr)),a;if(i!==void 0&&i.length===o.length)a=i;else{let d={...n.metadata,...this.getLsParamsWithDefaults(r)},f=this?.invocationParams(r),p=ka(f),m=Et.configure(n.callbacks,this.callbacks,n.tags,this.tags,d,{...p,...this.metadata},{verbose:this.verbose}),h={options:r,invocation_params:f,batch_size:1};a=await m?.handleChatModelStart(this.toJSON(),o.map(ok),n.runId,void 0,h,void 0,void 0,n.runName)}let s=r.outputVersion??this.outputVersion,c=[],u=[];if(a?.[0].handlers.find(Ed)&&!this.disableStreaming&&o.length===1&&this._streamResponseChunks!==Ks.prototype._streamResponseChunks)try{let d=await this._streamResponseChunks(o[0],r,a?.[0]),f,p;for await(let m of d){if(r.signal?.aborted){let h=f?.message;throw new hm("Model invocation was aborted.",h)}if(m.message.id==null){let h=a?.at(0)?.runId;h!=null&&m.message._updateId(`run-${h}`)}f===void 0?f=m:f=Wr(f,m),Sd(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 hm("Model invocation was aborted.",m)}if(f===void 0)throw new Error("Received empty response from chat model call.");c.push([f]),await a?.[0].handleLLMEnd({generations:c,llmOutput:p})}catch(d){throw await a?.[0].handleLLMError(d),d}else{let d=await Promise.allSettled(o.map(async(f,p)=>{let m=await this._generate(f,{...r,promptIndex:p},a?.[p]);if(s==="v1")for(let h of m.generations)h.message=__(h.message);return m}));await Promise.all(d.map(async(f,p)=>{if(f.status==="fulfilled"){let m=f.value;for(let h of m.generations){if(h.message.id==null){let w=a?.at(0)?.runId;w!=null&&h.message._updateId(`run-${w}`)}h.message.response_metadata={...h.generationInfo,...h.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,a?.[p]?.handleLLMEnd({generations:[m.generations],llmOutput:m.llmOutput})}else return await a?.[p]?.handleLLMError(f.reason),Promise.reject(f.reason)}))}let l={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(l,ys,{value:a?{runIds:a?.map(d=>d.runId)}:void 0,configurable:!0}),l}async _generateCached({messages:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o}){let a=t.map(y=>y.map(tr)),s={...o.metadata,...this.getLsParamsWithDefaults(i)},c=this?.invocationParams(i),u=ka(c),l=Et.configure(o.callbacks,this.callbacks,o.tags,this.tags,s,{...u,...this.metadata},{verbose:this.verbose}),d={options:i,invocation_params:c,batch_size:1},f=await l?.handleChatModelStart(this.toJSON(),a.map(ok),o.runId,void 0,d,void 0,void 0,o.runName),p=[],m=(await Promise.allSettled(a.map(async(y,x)=>{let S=Ks._convertInputToPromptValue(y).toString(),$=await r.lookup(S,n);return $==null&&p.push(x),$}))).map((y,x)=>({result:y,runManager:f?.[x]})).filter(({result:y})=>y.status==="fulfilled"&&y.value!=null||y.status==="rejected"),h=i.outputVersion??this.outputVersion,w=[];await Promise.all(m.map(async({result:y,runManager:x},S)=>{if(y.status==="fulfilled"){let $=y.value;return w[S]=$.map(j=>("message"in j&&ft(j.message)&&hi(j.message)&&(j.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},h==="v1"&&(j.message=__(j.message))),j.generationInfo={...j.generationInfo,tokenUsage:{}},j)),$.length&&await x?.handleLLMNewToken($[0].text),x?.handleLLMEnd({generations:[$]},void 0,void 0,void 0,{cached:!0})}else return await x?.handleLLMError(y.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(y.reason)}));let _={generations:w,missingPromptIndices:p,startedRunManagers:f};return Object.defineProperty(_,ys,{value:f?{runIds:f?.map(y=>y.runId)}:void 0,configurable:!0}),_}async generate(t,r,n){let i;Array.isArray(r)?i={stop:r}:i=r;let o=t.map(m=>m.map(tr)),[a,s]=this._separateRunnableConfigFromCallOptionsCompat(i);if(a.callbacks=a.callbacks??n,!this.cache)return this._generateUncached(o,s,a);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(s),{generations:l,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:o,cache:c,llmStringKey:u,parsedOptions:s,handledOptions:a}),p={};if(d.length>0){let m=await this._generateUncached(d.map(h=>o[h]),s,a,f!==void 0?d.map(h=>f?.[h]):void 0);await Promise.all(m.generations.map(async(h,w)=>{let _=d[w];l[_]=h;let y=Ks._convertInputToPromptValue(o[_]).toString();return c.update(y,u,h)})),p=m.llmOutput??{}}return{generations:l,llmOutput:p}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,r,n){let i=t.map(o=>o.toChatMessages());return this.generate(i,r,n)}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 n=t,i=r?.name,o=Un(n)??"A function available to call.",a=r?.method,s=r?.includeRaw;if(a==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=i??"extract";!zt(n)&&!ki(n)&&"name"in n&&(c=n.name);let u=zt(n)||ki(n)?dt(n):n,l=[{type:"function",function:{name:c,description:o,parameters:u}}];return Op(this.bindTools(l),Zt.from(d=>{if(!at.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")}},iK=class extends zi{async _generate(e,t,r){let n=new be(await this._call(e,t,r));if(typeof n.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:n.content,message:n}]}}};var Oz=P({BaseLLM:()=>ak,LLM:()=>y_}),ak=class Cp extends Tp{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,r){let n=Cp._convertInputToPromptValue(t);return(await this.generatePrompt([n],r,r?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,r,n){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[r,n]=super._separateRunnableConfigFromCallOptions(t);return n.signal=r.signal,[r,n]}async*_streamIterator(t,r){if(this._streamResponseChunks===Cp.prototype._streamResponseChunks)yield this.invoke(t,r);else{let n=Cp._convertInputToPromptValue(t),[i,o]=this._separateRunnableConfigFromCallOptionsCompat(r),a=this?.invocationParams(o),s=ka(a),c=Et.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,{...s,...this.metadata},{verbose:this.verbose}),u={options:o,invocation_params:a,batch_size:1},l=await c?.handleLLMStart(this.toJSON(),[n.toString()],i.runId,void 0,u,void 0,void 0,i.runName),d=new Si({text:""});try{for await(let f of this._streamResponseChunks(n.toString(),o,l?.[0]))d?d=d.concat(f):d=f,typeof f.text=="string"&&(yield f.text)}catch(f){throw await Promise.all((l??[]).map(p=>p?.handleLLMError(f))),f}await Promise.all((l??[]).map(f=>f?.handleLLMEnd({generations:[[d]]})))}}async generatePrompt(t,r,n){let i=t.map(o=>o.toString());return this.generate(i,r,n)}invocationParams(t){return{}}_flattenLLMResult(t){let r=[];for(let n=0;n<t.generations.length;n+=1){let i=t.generations[n];if(n===0)r.push({generations:[i],llmOutput:t.llmOutput});else{let o=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;r.push({generations:[i],llmOutput:o})}}return r}async _generateUncached(t,r,n,i){let o;if(i!==void 0&&i.length===t.length)o=i;else{let u=this?.invocationParams(r),l=ka(u),d=Et.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,{...l,...this.metadata},{verbose:this.verbose}),f={options:r,invocation_params:u,batch_size:t.length};o=await d?.handleLLMStart(this.toJSON(),t,n.runId,void 0,f,void 0,void 0,n?.runName)}let a=!!o?.[0].handlers.find(Ed),s;if(a&&t.length===1&&this._streamResponseChunks!==Cp.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],r,o?.[0]),l;for await(let d of u)l===void 0?l=d:l=Wr(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");s={generations:[[l]],llmOutput:{}},await o?.[0].handleLLMEnd(s)}catch(u){throw await o?.[0].handleLLMError(u),u}else{try{s=await this._generate(t,r,o?.[0])}catch(l){throw await Promise.all((o??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(s);await Promise.all((o??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=o?.map(u=>u.runId)||void 0;return Object.defineProperty(s,ys,{value:c?{runIds:c}:void 0,configurable:!0}),s}async _generateCached({prompts:t,cache:r,llmStringKey:n,parsedOptions:i,handledOptions:o,runId:a}){let s=this?.invocationParams(i),c=ka(s),u=Et.configure(o.callbacks,this.callbacks,o.tags,this.tags,o.metadata,{...c,...this.metadata},{verbose:this.verbose}),l={options:i,invocation_params:s,batch_size:t.length},d=await u?.handleLLMStart(this.toJSON(),t,a,void 0,l,void 0,void 0,o?.runName),f=[],p=(await Promise.allSettled(t.map(async(w,_)=>{let y=await r.lookup(w,n);return y==null&&f.push(_),y}))).map((w,_)=>({result:w,runManager:d?.[_]})).filter(({result:w})=>w.status==="fulfilled"&&w.value!=null||w.status==="rejected"),m=[];await Promise.all(p.map(async({result:w,runManager:_},y)=>{if(w.status==="fulfilled"){let x=w.value;return m[y]=x.map(S=>(S.generationInfo={...S.generationInfo,tokenUsage:{}},S)),x.length&&await _?.handleLLMNewToken(x[0].text),_?.handleLLMEnd({generations:[x]},void 0,void 0,void 0,{cached:!0})}else return await _?.handleLLMError(w.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(w.reason)}));let h={generations:m,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(h,ys,{value:d?{runIds:d?.map(w=>w.runId)}:void 0,configurable:!0}),h}async generate(t,r,n){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let i;Array.isArray(r)?i={stop:r}:i=r;let[o,a]=this._separateRunnableConfigFromCallOptionsCompat(i);if(o.callbacks=o.callbacks??n,!this.cache)return this._generateUncached(t,a,o);let{cache:s}=this,c=this._getSerializedCacheKeyParametersForCall(a),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:s,llmStringKey:c,parsedOptions:a,handledOptions:o,runId:o.runId}),f={};if(l.length>0){let p=await this._generateUncached(l.map(m=>t[m]),a,o,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(p.generations.map(async(m,h)=>{let w=l[h];return u[w]=m,s.update(t[w],c,m)})),f=p.llmOutput??{}}return{generations:u,llmOutput:f}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},y_=class extends ak{async _generate(e,t,r){return{generations:await Promise.all(e.map((n,i)=>this._call(n,{...t,promptIndex:i},r).then(o=>[{text:o}])))}}};var Cz=P({});var Pz=P({BaseMemory:()=>oK,getInputValue:()=>aK,getOutputValue:()=>sK,getPromptInputKey:()=>cK}),oK=class{},Rz=(e,t)=>{if(t!==void 0)return e[t];let r=Object.keys(e);if(r.length===1)return e[r[0]]},aK=(e,t)=>{let r=Rz(e,t);if(!r){let n=Object.keys(e);throw new Error(`input values have ${n.length} keys, you must specify an input key or pass only 1 key as input`)}return r},sK=(e,t)=>{let r=Rz(e,t);if(!r&&r!==""){let n=Object.keys(e);throw new Error(`output values have ${n.length} keys, you must specify an output key or pass only 1 key as output`)}return r};function cK(e,t){let r=Object.keys(e).filter(n=>!t.includes(n)&&n!=="stop");if(r.length!==1)throw new Error(`One input key expected, but got ${r.length}`);return r[0]}var sk=class extends Vu{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)}`)}},ck=class extends ji{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 sk(e)}_diff(e,t){if(t)return sa(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:r}=t,n=r.additional_kwargs.function_call;if(n)return this.argsOnly?mi(n.arguments):{...n,arguments:mi(n.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""}},Nz=class extends Vu{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new ck;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 Mz=P({JsonKeyOutputFunctionsParser:()=>Nz,JsonOutputFunctionsParser:()=>ck,OutputFunctionsParser:()=>sk});var jz=P({JsonOutputKeyToolsParser:()=>h_,JsonOutputToolsParser:()=>nk,convertLangChainToolCallToOpenAI:()=>m_,makeInvalidToolCall:()=>Sa,parseToolCall:()=>qs});var Di=class extends pe{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[n,i]of Object.entries(t))typeof i=="string"?r[n]=i:r[n]=await i();return{...r,...e}}async invoke(e,t){let r={...this.metadata,...t?.metadata},n=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(i=>this.formatPromptValue(i),e,{...t,tags:n,metadata:r,runType:"prompt"})}};var xo=class extends Di{async formatPromptValue(e){return new kp(await this.format(e))}};var uK=Object.prototype.toString,qu=Array.isArray||function(t){return uK.call(t)==="[object Array]"};function lk(e){return typeof e=="function"}function lK(e){return qu(e)?"array":typeof e}function uk(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function zz(e,t){return e!=null&&typeof e=="object"&&t in e}function dK(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var pK=RegExp.prototype.test;function fK(e,t){return pK.call(e,t)}var mK=/\S/;function hK(e){return!fK(mK,e)}var gK={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function _K(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return gK[r]})}var yK=/\s*/,vK=/\s+/,Dz=/\s*=/,bK=/\s*\}/,wK=/#|\^|\/|>|\{|&|=|!/;function xK(e,t){if(!e)return[];var r=!1,n=[],i=[],o=[],a=!1,s=!1,c="",u=0;function l(){if(a&&!s)for(;o.length;)delete i[o.pop()];else o=[];a=!1,s=!1}var d,f,p;function m(b){if(typeof b=="string"&&(b=b.split(vK,2)),!qu(b)||b.length!==2)throw new Error("Invalid tags: "+b);d=new RegExp(uk(b[0])+"\\s*"),f=new RegExp("\\s*"+uk(b[1])),p=new RegExp("\\s*"+uk("}"+b[1]))}m(t||En.tags);for(var h=new Rp(e),w,_,y,x,S,$;!h.eos();){if(w=h.pos,y=h.scanUntil(d),y)for(var j=0,C=y.length;j<C;++j)x=y.charAt(j),hK(x)?(o.push(i.length),c+=x):(s=!0,r=!0,c+=" "),i.push(["text",x,w,w+1]),w+=1,x===`
|
|
199
|
+
`&&(l(),c="",u=0,r=!1);if(!h.scan(d))break;if(a=!0,_=h.scan(wK)||"name",h.scan(yK),_==="="?(y=h.scanUntil(Dz),h.scan(Dz),h.scanUntil(f)):_==="{"?(y=h.scanUntil(p),h.scan(bK),h.scanUntil(f),_="&"):y=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(_==">"?S=[_,y,w,h.pos,c,u,r]:S=[_,y,w,h.pos],u++,i.push(S),_==="#"||_==="^")n.push(S);else if(_==="/"){if($=n.pop(),!$)throw new Error('Unopened section "'+y+'" at '+w);if($[1]!==y)throw new Error('Unclosed section "'+$[1]+'" at '+w)}else _==="name"||_==="{"||_==="&"?s=!0:_==="="&&m(y)}if(l(),$=n.pop(),$)throw new Error('Unclosed section "'+$[1]+'" at '+h.pos);return SK(IK(i))}function IK(e){for(var t=[],r,n,i=0,o=e.length;i<o;++i)r=e[i],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function SK(e){for(var t=[],r=t,n=[],i,o,a=0,s=e.length;a<s;++a)switch(i=e[a],i[0]){case"#":case"^":r.push(i),n.push(i),r=i[4]=[];break;case"/":o=n.pop(),o[5]=i[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(i)}return t}function Rp(e){this.string=e,this.tail=e,this.pos=0}Rp.prototype.eos=function(){return this.tail===""};Rp.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};Rp.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function Hu(e,t){this.view=e,this.cache={".":this.view},this.parent=t}Hu.prototype.push=function(t){return new Hu(t,this)};Hu.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var i=this,o,a,s,c=!1;i;){if(t.indexOf(".")>0)for(o=i.view,a=t.split("."),s=0;o!=null&&s<a.length;)s===a.length-1&&(c=zz(o,a[s])||dK(o,a[s])),o=o[a[s++]];else o=i.view[t],c=zz(i.view,t);if(c){n=o;break}i=i.parent}r[t]=n}return lk(n)&&(n=n.call(this.view)),n};function kr(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}kr.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};kr.prototype.parse=function(t,r){var n=this.templateCache,i=t+":"+(r||En.tags).join(":"),o=typeof n<"u",a=o?n.get(i):void 0;return a==null&&(a=xK(t,r),o&&n.set(i,a)),a};kr.prototype.render=function(t,r,n,i){var o=this.getConfigTags(i),a=this.parse(t,o),s=r instanceof Hu?r:new Hu(r,void 0);return this.renderTokens(a,s,n,t,i)};kr.prototype.renderTokens=function(t,r,n,i,o){for(var a="",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,n,i,o):c==="^"?u=this.renderInverted(s,r,n,i,o):c===">"?u=this.renderPartial(s,r,n,o):c==="&"?u=this.unescapedValue(s,r):c==="name"?u=this.escapedValue(s,r,o):c==="text"&&(u=this.rawValue(s)),u!==void 0&&(a+=u);return a};kr.prototype.renderSection=function(t,r,n,i,o){var a=this,s="",c=r.lookup(t[1]);function u(f){return a.render(f,r,n,o)}if(c){if(qu(c))for(var l=0,d=c.length;l<d;++l)s+=this.renderTokens(t[4],r.push(c[l]),n,i,o);else if(typeof c=="object"||typeof c=="string"||typeof c=="number")s+=this.renderTokens(t[4],r.push(c),n,i,o);else if(lk(c)){if(typeof i!="string")throw new Error("Cannot use higher-order sections without the original template");c=c.call(r.view,i.slice(t[3],t[5]),u),c!=null&&(s+=c)}else s+=this.renderTokens(t[4],r,n,i,o);return s}};kr.prototype.renderInverted=function(t,r,n,i,o){var a=r.lookup(t[1]);if(!a||qu(a)&&a.length===0)return this.renderTokens(t[4],r,n,i,o)};kr.prototype.indentPartial=function(t,r,n){for(var i=r.replace(/[^ \t]/g,""),o=t.split(`
|
|
200
|
+
`),a=0;a<o.length;a++)o[a].length&&(a>0||!n)&&(o[a]=i+o[a]);return o.join(`
|
|
201
|
+
`)};kr.prototype.renderPartial=function(t,r,n,i){if(n){var o=this.getConfigTags(i),a=lk(n)?n(t[1]):n[t[1]];if(a!=null){var s=t[6],c=t[5],u=t[4],l=a;c==0&&u&&(l=this.indentPartial(a,u,s));var d=this.parse(l,o);return this.renderTokens(d,r,n,l,i)}}};kr.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};kr.prototype.escapedValue=function(t,r,n){var i=this.getConfigEscape(n)||En.escape,o=r.lookup(t[1]);if(o!=null)return typeof o=="number"&&i===En.escape?String(o):i(o)};kr.prototype.rawValue=function(t){return t[1]};kr.prototype.getConfigTags=function(t){return qu(t)?t:t&&typeof t=="object"?t.tags:void 0};kr.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!qu(t))return t.escape};var En={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){Pp.templateCache=e},get templateCache(){return Pp.templateCache}},Pp=new kr;En.clearCache=function(){return Pp.clearCache()};En.parse=function(t,r){return Pp.parse(t,r)};En.render=function(t,r,n,i){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+lK(t)+'" was given as the first argument for mustache#render(template, view, partials)');return Pp.render(t,r,n,i)};En.escape=_K;En.Scanner=Rp;En.Context=Hu;En.Writer=kr;var v_=En;function Lz(){v_.escape=e=>e}var Ws=e=>{let t=e.split(""),r=[],n=(o,a)=>{for(let s=a;s<t.length;s+=1)if(o.includes(t[s]))return s;return-1},i=0;for(;i<t.length;)if(t[i]==="{"&&i+1<t.length&&t[i+1]==="{")r.push({type:"literal",text:"{"}),i+=2;else if(t[i]==="}"&&i+1<t.length&&t[i+1]==="}")r.push({type:"literal",text:"}"}),i+=2;else if(t[i]==="{"){let o=n("}",i);if(o<0)throw new Error("Unclosed '{' in template.");r.push({type:"variable",name:t.slice(i+1,o).join("")}),i=o+1}else{if(t[i]==="}")throw new Error("Single '}' in template.");{let o=n("{}",i),a=(o<0?t.slice(i):t.slice(i,o)).join("");r.push({type:"literal",text:a}),i=o<0?t.length:o}}return r},Uz=(e,t=[])=>{let r=[];for(let n of e)if(n[0]==="name"){let i=n[1].includes(".")?n[1].split(".")[0]:n[1];r.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(n[0])){if(r.push({type:"variable",name:n[1]}),n[0]==="#"&&n.length>4&&Array.isArray(n[4])){let i=[...t,n[1]],o=Uz(n[4],i);r.push(...o)}}else r.push({type:"literal",text:n[1]});return r},Ku=e=>(Lz(),Uz(v_.parse(e))),dk=(e,t)=>Ws(e).reduce((r,n)=>{if(n.type==="variable"){if(n.name in t)return r+(typeof t[n.name]=="string"?t[n.name]:JSON.stringify(t[n.name]));throw new Error(`(f-string) Missing value for input ${n.name}`)}return r+n.text},""),pk=(e,t)=>(Lz(),v_.render(e,t)),Np={"f-string":dk,mustache:pk},fk={"f-string":Ws,mustache:Ku},sr=(e,t,r)=>{try{return Np[t](e,r)}catch(n){throw io(n,"INVALID_PROMPT_INPUT")}},Js=(e,t)=>fk[t](e),Io=(e,t,r)=>{if(!(t in Np)){let n=Object.keys(Np);throw new Error(`Invalid template format. Got \`${t}\`;
|
|
202
|
+
should be one of ${n}`)}try{let n=Object.fromEntries(r.map(i=>[i,"foo"]));Array.isArray(e)?e.forEach(i=>{if(i.type==="text"&&"text"in i&&typeof i.text=="string")sr(i.text,t,n);else if(i.type==="image_url"){if(typeof i.image_url=="string")sr(i.image_url,t,n);else if(typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"){let o=i.image_url.url;sr(o,t,n)}}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):sr(e,t,n)}catch(n){throw new Error(`Invalid prompt schema: ${n.message}`)}};var Hn=class Mp extends xo{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))),Io(this.template,this.templateFormat,r)}}_getPromptType(){return"prompt"}async format(t){let r=await this.mergePartialAndUserVariables(t);return sr(this.template,this.templateFormat,r)}static fromExamples(t,r,n,i=`
|
|
203
|
+
|
|
204
|
+
`,o=""){return new Mp({inputVariables:n,template:[o,...t,r].join(i)})}static fromTemplate(t,r){let{templateFormat:n="f-string",...i}=r??{},o=new Set;return Js(t,n).forEach(a=>{a.type==="variable"&&o.add(a.name)}),new Mp({inputVariables:[...o],templateFormat:n,template:t,...i})}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new Mp({...this,inputVariables:r,partialVariables:n})}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 Mp({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}};var Wu=class Fz extends Di{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))),Io([{type:"image_url",image_url:this.template}],this.templateFormat,r)}}_getPromptType(){return"prompt"}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new Fz({...this,inputVariables:r,partialVariables:n})}async format(t){let r={};for(let[a,s]of Object.entries(this.template))typeof s=="string"?r[a]=sr(s,this.templateFormat,t):r[a]=s;let n=t.url||r.url,i=t.detail||r.detail;if(!n)throw new Error("Must provide either an image URL.");if(typeof n!="string")throw new Error("url must be a string.");let o={url:n};return i&&(o.detail=i),o}async formatPromptValue(t){return new YS(await this.format(t))}};var jp=class extends pe{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=mk(e.template,t);super({inputVariables:r,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=r}async format(e){return hk(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function mk(e,t){let r=[];for(let n of Object.values(e))if(typeof n=="string")Js(n,t).forEach(i=>{i.type==="variable"&&r.push(i.name)});else if(Array.isArray(n))for(let i of n)typeof i=="string"?Js(i,t).forEach(o=>{o.type==="variable"&&r.push(o.name)}):typeof i=="object"&&r.push(...mk(i,t));else typeof n=="object"&&n!==null&&r.push(...mk(n,t));return Array.from(new Set(r))}function hk(e,t,r){let n={};for(let[i,o]of Object.entries(e))if(typeof o=="string")n[i]=sr(o,r,t);else if(Array.isArray(o)){let a=[];for(let s of o)typeof s=="string"?a.push(sr(s,r,t)):typeof s=="object"&&a.push(hk(s,t,r));n[i]=a}else typeof o=="object"&&o!==null?n[i]=hk(o,t,r):n[i]=o;return n}var zp=class extends pe{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(r=>this.formatMessages(r),e,{...t,runType:"prompt"})}},w_=class extends zp{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 n=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw n.name="InputFormatError",n}let r;try{Array.isArray(t)?r=t.map(tr):r=[tr(t)]}catch(n){let i=typeof t=="string"?t:JSON.stringify(t,null,2),o=new Error([`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages or coerceable values as input.`,`Received value: ${i}`,`Additional message: ${n.message}`].join(`
|
|
205
|
+
|
|
206
|
+
`));throw o.name="InputFormatError",o.lc_error_code=n.lc_error_code,o}return r}},gk=class extends zp{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)]}},Dp=class extends Di{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new Ep(await this.formatMessages(e))}},_k=class extends gk{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 mr(await this.prompt.format(e),this.role)}static fromTemplate(e,t,r){return new this(Hn.fromTemplate(e,{templateFormat:r?.templateFormat}),t)}};function kK(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function EK(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 yk=class extends zp{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(n=>{"inputVariables"in n&&(r=r.concat(n.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(Hn.fromTemplate(e,t));let r=[];for(let n of e)if(typeof n=="string")r.push(Hn.fromTemplate(n,t));else if(n!==null)if(kK(n)){let i="";typeof n.text=="string"&&(i=n.text??"");let o={...t,additionalContentFields:n};r.push(Hn.fromTemplate(i,o))}else if(EK(n)){let i=n.image_url??"",o,a=[];if(typeof i=="string"){let s;t?.templateFormat==="mustache"?s=Ku(i):s=Ws(i);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.
|
|
207
|
+
Got: ${c}
|
|
208
|
+
From: ${i}`);a=[c[0]]}else a=[];i={url:i},o=new Wu({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:n})}else if(typeof i=="object"){if("url"in i){let s;t?.templateFormat==="mustache"?s=Ku(i.url):s=Ws(i.url),a=s.flatMap(c=>c.type==="variable"?[c.name]:[])}else a=[];o=new Wu({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:n})}else throw new Error("Invalid image template");r.push(o)}else typeof n=="object"&&r.push(new jp({template:n,templateFormat:t?.templateFormat}));return new this({prompt:r,additionalOptions:t})}async format(e){if(this.prompt instanceof xo){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let r of this.prompt){let n={};if(!("inputVariables"in r))throw new Error(`Prompt ${r} does not have inputVariables defined.`);for(let i of r.inputVariables)n||(n={[i]:e[i]}),n={...n,[i]:e[i]};if(r instanceof xo){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),i!==""&&t.push({...o,type:"text",text:i})}else if(r instanceof Wu){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,type:"image_url",image_url:i})}else if(r instanceof jp){let i=await r.format(n),o;"additionalContentFields"in r&&(o=r.additionalContentFields),t.push({...o,...i})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},x_=class extends yk{static _messageClass(){return st}static lc_name(){return"HumanMessagePromptTemplate"}},vk=class extends yk{static _messageClass(){return be}static lc_name(){return"AIMessagePromptTemplate"}},Lp=class extends yk{static _messageClass(){return hr}static lc_name(){return"SystemMessagePromptTemplate"}};function $K(e){return typeof e.formatMessages=="function"}function TK(e,t){if($K(e)||ft(e))return e;if(Array.isArray(e)&&e[0]==="placeholder"){let i=e[1];if(t?.templateFormat==="mustache"&&typeof i=="string"&&i.slice(0,2)==="{{"&&i.slice(-2)==="}}")return new w_({variableName:i.slice(2,-2),optional:!0});if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}")return new w_({variableName:i.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=tr(e),n;if(typeof r.content=="string"?n=r.content:n=r.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),r._getType()==="human")return x_.fromTemplate(n,t);if(r._getType()==="ai")return vk.fromTemplate(n,t);if(r._getType()==="system")return Lp.fromTemplate(n,t);if(mr.isInstance(r))return _k.fromTemplate(r.content,r.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${r._getType()}".`)}function AK(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Ea=class b_ extends Dp{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 tt))for(let c of s.inputVariables)r.add(c);let n=this.inputVariables,i=new Set(this.partialVariables?n.concat(Object.keys(this.partialVariables)):n),o=new Set([...i].filter(s=>!r.has(s)));if(o.size>0)throw new Error(`Input variables \`${[...o]}\` are not used in any of the prompt messages.`);let a=new Set([...r].filter(s=>!i.has(s)));if(a.size>0)throw new Error(`Input variables \`${[...a]}\` 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 n=>{if(n.type!=="image_url")return n;let i="";typeof n.image_url=="string"?i=n.image_url:typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url&&typeof n.image_url.url=="string"&&(i=n.image_url.url);let o=await Hn.fromTemplate(i,{templateFormat:this.templateFormat}).format(r);return typeof n.image_url=="object"&&n.image_url!==null&&"url"in n.image_url?n.image_url.url=o:n.image_url=o,n}))),t}async formatMessages(t){let r=await this.mergePartialAndUserVariables(t),n=[];for(let i of this.promptMessages)if(i instanceof tt)n.push(await this._parseImagePrompts(i,r));else{let o;this.templateFormat==="mustache"?o={...r}:o=i.inputVariables.reduce((s,c)=>{if(!(c in r)&&!(AK(i)&&i.optional))throw io(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return s[c]=r[c],s},{});let a=await i.formatMessages(o);n=n.concat(a)}return n}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new b_({...this,inputVariables:r,partialVariables:n})}static fromTemplate(t,r){let n=new x_({prompt:Hn.fromTemplate(t,r)});return this.fromMessages([n])}static fromMessages(t,r){let n=t.reduce((a,s)=>a.concat(s instanceof b_?s.promptMessages:[TK(s,r)]),[]),i=t.reduce((a,s)=>s instanceof b_?Object.assign(a,s.partialVariables):a,Object.create(null)),o=new Set;for(let a of n)if(!(a instanceof tt))for(let s of a.inputVariables)s in i||o.add(s);return new this({...r,inputVariables:[...o],promptMessages:n,partialVariables:i,templateFormat:r?.templateFormat})}};var Bz=class bk extends xo{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
209
|
+
|
|
210
|
+
`;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))),Io(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(i=>!(i in t)),n={...this.partialVariables??{},...t};return new bk({...this,inputVariables:r,partialVariables:n})}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=await Promise.all(n.map(o=>this.examplePrompt.format(o)));return sr([this.prefix,...i,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 n=await Hn.deserialize(r),i;if(Array.isArray(t.examples))i=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new bk({inputVariables:t.input_variables,examplePrompt:n,examples:i,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},Vz=class Zz extends Dp{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
211
|
+
|
|
212
|
+
`;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??`
|
|
213
|
+
|
|
214
|
+
`,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))),Io(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),n=await this.getExamples(r);n=n.map(o=>{let a={};return this.examplePrompt.inputVariables.forEach(s=>{a[s]=o[s]}),a});let i=[];for(let o of n){let a=await this.examplePrompt.formatMessages(o);i.push(...a)}return i}async format(t){let r=await this.mergePartialAndUserVariables(t),n=await this.getExamples(r),i=(await Promise.all(n.map(o=>this.examplePrompt.formatMessages(o)))).flat().map(o=>o.content);return sr([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,r)}async partial(t){let r=this.inputVariables.filter(i=>!(i in t)),n={...this.partialVariables??{},...t};return new Zz({...this,inputVariables:r,partialVariables:n})}};var Gz=class I_ extends Di{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(n=>n.name),r=this.pipelinePrompts.map(n=>n.prompt.inputVariables.filter(i=>!t.includes(i))).flat();return[...new Set(r)]}static extractRequiredInputValues(t,r){return r.reduce((n,i)=>(n[i]=t[i],n),{})}async formatPipelinePrompts(t){let r=await this.mergePartialAndUserVariables(t);for(let{name:n,prompt:i}of this.pipelinePrompts){let o=I_.extractRequiredInputValues(r,i.inputVariables);i instanceof Ea?r[n]=await i.formatMessages(o):r[n]=await i.format(o)}return I_.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(n=>!(n in t)),r.partialVariables={...this.partialVariables??{},...t},new I_(r)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function Hz(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function OK(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 qz=class Kz extends Ea{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(Hz(t))return super.pipe(t.withStructuredOutput(this.schema));if(OK(t)&&Hz(t.bound))return super.pipe(new Sn({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,n){return Kz.fromMessages(t,{schema:r,method:n})}};var Wz=P({AIMessagePromptTemplate:()=>vk,BaseChatPromptTemplate:()=>Dp,BaseMessagePromptTemplate:()=>zp,BaseMessageStringPromptTemplate:()=>gk,BasePromptTemplate:()=>Di,BaseStringPromptTemplate:()=>xo,ChatMessagePromptTemplate:()=>_k,ChatPromptTemplate:()=>Ea,DEFAULT_FORMATTER_MAPPING:()=>Np,DEFAULT_PARSER_MAPPING:()=>fk,DictPromptTemplate:()=>jp,FewShotChatMessagePromptTemplate:()=>Vz,FewShotPromptTemplate:()=>Bz,HumanMessagePromptTemplate:()=>x_,ImagePromptTemplate:()=>Wu,MessagesPlaceholder:()=>w_,PipelinePromptTemplate:()=>Gz,PromptTemplate:()=>Hn,StructuredPrompt:()=>qz,SystemMessagePromptTemplate:()=>Lp,checkValidTemplate:()=>Io,interpolateFString:()=>dk,interpolateMustache:()=>pk,parseFString:()=>Ws,parseMustache:()=>Ku,parseTemplate:()=>Js,renderTemplate:()=>sr});var Jz=P({BaseDocumentCompressor:()=>CK}),CK=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}};var Xz=P({BaseRetriever:()=>Up}),Up=class extends pe{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=Ne(hs(t)),n=await(await Et.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 i=await this._getRelevantDocuments(e,n);return await n?.handleRetrieverEnd(i),i}catch(i){throw await n?.handleRetrieverError(i),i}}};var Yz=P({BaseStore:()=>Qz,InMemoryStore:()=>PK}),Qz=class extends kt{},PK=class extends Qz{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 qn={and:"and",or:"or",not:"not"},je={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},S_=class{},k_=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")}},E_=class extends k_{},eD=class extends E_{exprName="Comparison";constructor(e,t,r){super(),this.comparator=e,this.attribute=t,this.value=r}},tD=class extends E_{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},rD=class extends k_{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function wk(e){return e&&typeof e=="object"&&!Array.isArray(e)}function zr(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:wk(e)&&Object.keys(e).length===0:!0}function xk(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 Ik(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 Sk(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function kk(e){return typeof e=="boolean"}function Ju(e){let t;if(Sk(e))t=e;else if(xk(e))t=parseInt(e,10);else if(Ik(e))t=parseFloat(e);else if(kk(e))t=!!e;else throw new Error("Unsupported value type");return t}var Fp=class extends S_{},nD=class extends Fp{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[qn.and,qn.or],this.allowedComparators=e?.allowedComparators??[je.eq,je.ne,je.gt,je.gte,je.lt,je.lte]}formatFunction(e){if(e in je){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 qn){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)]:Ju(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,r="and",n=!1){if(!(zr(e)&&zr(t))){if(zr(e)||r==="replace")return zr(t)?void 0:t;if(zr(t))return n?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 iD=class extends Fp{allowedOperators=[qn.and,qn.or];allowedComparators=[je.eq,je.ne,je.gt,je.gte,je.lt,je.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[je.eq,je.ne,je.gt,je.gte,je.lt,je.lte];case"number":return[je.eq,je.ne,je.gt,je.gte,je.lt,je.lte];case"boolean":return[je.eq,je.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case je.eq:return(t,r)=>t===r;case je.ne:return(t,r)=>t!==r;case je.gt:return(t,r)=>t>r;case je.gte:return(t,r)=>t>=r;case je.lt:return(t,r)=>t<r;case je.lte:return(t,r)=>t<=r;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case qn.and:return(t,r)=>t&&r;case qn.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 n=this.getOperatorFunction(t);return i=>r?r.reduce((o,a)=>{let s=a.accept(this);if(typeof s=="function")return n(o,s(i));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:n}=e,i=[je.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof n).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof n}`);let o=this.getComparatorFunction(t);return a=>{let s=a.metadata[r];return s===void 0?!!i.includes(t):o(s,Ju(n))}}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(!(zr(e)&&zr(t))){if(zr(e)||r==="replace")return zr(t)?void 0:t;if(zr(t))return r==="and"?void 0:e;if(r==="and")return n=>e(n)&&t(n);if(r==="or")return n=>e(n)||t(n);throw new Error("Unknown merge type")}}};var oD=P({BaseTranslator:()=>Fp,BasicTranslator:()=>nD,Comparators:()=>je,Comparison:()=>eD,Expression:()=>k_,FilterDirective:()=>E_,FunctionalTranslator:()=>iD,Operation:()=>tD,Operators:()=>qn,StructuredQuery:()=>rD,Visitor:()=>S_,castValue:()=>Ju,isBoolean:()=>kk,isFilterEmpty:()=>zr,isFloat:()=>Ik,isInt:()=>xk,isObject:()=>wk,isString:()=>Sk});function Bp(e){return tt.isInstance(e)?e.constructor.name||e.type:typeof e}function $_(e,t){return function(r,n){let{isNot:i,utils:o}=this;if(!t(r))return{pass:!1,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
215
|
+
|
|
216
|
+
Expected: ${i?"not ":""}${e}
|
|
217
|
+
Received: ${Bp(r)}`,actual:Bp(r),expected:e};if(n===void 0)return{pass:!0,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
218
|
+
|
|
219
|
+
Expected: not ${e}
|
|
220
|
+
Received: ${e}`};let a=r;return typeof n=="string"?{pass:a.content===n,message:()=>`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
221
|
+
|
|
222
|
+
Expected: ${e} with content ${o.printExpected(n)}
|
|
223
|
+
Received: ${e} with content ${o.printReceived(a.content)}`,actual:a.content,expected:n}:{pass:Object.entries(n).every(([s,c])=>this.equals(a[s],c)),message:()=>{let s={};for(let c of Object.keys(n))s[c]=a[c];return`${o.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
224
|
+
|
|
225
|
+
Expected: ${e} matching ${o.printExpected(n)}
|
|
226
|
+
Received: ${e} with ${o.printReceived(s)}`},actual:(()=>{let s={};for(let c of Object.keys(n))s[c]=a[c];return s})(),expected:n}}}var Ek=$_("HumanMessage",st.isInstance),$k=$_("AIMessage",be.isInstance),Tk=$_("SystemMessage",hr.isInstance),Ak=$_("ToolMessage",jt.isInstance);function Ok(e,t){let{isNot:r,utils:n}=this;if(!be.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
227
|
+
|
|
228
|
+
Expected: AIMessage
|
|
229
|
+
Received: ${Bp(e)}`};let i=e.tool_calls??[];if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
230
|
+
|
|
231
|
+
Expected ${r?"not ":""}${t.length} tool call(s), received ${i.length}`,actual:i.length,expected:t.length};let o=t.filter(a=>!i.some(s=>Object.entries(a).every(([c,u])=>this.equals(s[c],u))));return o.length>0?{pass:!1,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
232
|
+
|
|
233
|
+
Could not find matching tool call(s) for:
|
|
234
|
+
${n.printExpected(o)}
|
|
235
|
+
Received tool calls: ${n.printReceived(i.map(a=>({name:a.name,id:a.id,args:a.args})))}`,actual:i.map(a=>({name:a.name,id:a.id,args:a.args})),expected:t}:{pass:!0,message:()=>`${n.matcherHint("toHaveToolCalls")}
|
|
236
|
+
|
|
237
|
+
Expected AIMessage not to have matching tool calls`}}function Ck(e,t){let{isNot:r,utils:n}=this;if(!be.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolCallCount")}
|
|
238
|
+
|
|
239
|
+
Expected: AIMessage
|
|
240
|
+
Received: ${Bp(e)}`};let i=e.tool_calls?.length??0;return{pass:i===t,message:()=>`${n.matcherHint("toHaveToolCallCount")}
|
|
241
|
+
|
|
242
|
+
Expected ${r?"not ":""}${t} tool call(s)
|
|
243
|
+
Received: ${i}`,actual:i,expected:t}}function Pk(e,t){let{isNot:r,utils:n}=this;if(!be.isInstance(e))return{pass:!1,message:()=>`${n.matcherHint("toContainToolCall")}
|
|
244
|
+
|
|
245
|
+
Expected: AIMessage
|
|
246
|
+
Received: ${Bp(e)}`};let i=e.tool_calls??[];return{pass:i.some(o=>Object.entries(t).every(([a,s])=>this.equals(o[a],s))),message:()=>`${n.matcherHint("toContainToolCall")}
|
|
247
|
+
|
|
248
|
+
Expected AIMessage ${r?"not ":""}to contain a tool call matching ${n.printExpected(t)}
|
|
249
|
+
Received tool calls: ${n.printReceived(i.map(o=>({name:o.name,id:o.id})))}`,actual:i.map(o=>({name:o.name,id:o.id})),expected:t}}function Rk(e,t){let{isNot:r,utils:n}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
250
|
+
|
|
251
|
+
Expected an array of messages
|
|
252
|
+
Received: ${typeof e}`};let i=e.filter(jt.isInstance);if(i.length!==t.length)return{pass:!1,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
253
|
+
|
|
254
|
+
Expected ${r?"not ":""}${t.length} tool message(s), found ${i.length}`,actual:i.length,expected:t.length};for(let o=0;o<t.length;o++)if(!Object.entries(t[o]).every(([a,s])=>this.equals(i[o][a],s)))return{pass:!1,message:()=>{let a={};for(let s of Object.keys(t[o]))a[s]=i[o][s];return`${n.matcherHint("toHaveToolMessages")}
|
|
255
|
+
|
|
256
|
+
Tool message at index ${o} did not match:
|
|
257
|
+
Expected: ${n.printExpected(t[o])}
|
|
258
|
+
Received: ${n.printReceived(a)}`},actual:i[o],expected:t[o]};return{pass:!0,message:()=>`${n.matcherHint("toHaveToolMessages")}
|
|
259
|
+
|
|
260
|
+
Expected messages not to contain matching tool messages`}}function Nk(e,t){let{isNot:r,utils:n}=this,i=e?.__interrupt__;if(!(Array.isArray(i)&&i.length>0))return{pass:!1,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
261
|
+
|
|
262
|
+
Expected result ${r?"not ":""}to have been interrupted
|
|
263
|
+
Received __interrupt__: ${n.printReceived(i)}`};if(t===void 0)return{pass:!0,message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
264
|
+
|
|
265
|
+
Expected result not to have been interrupted
|
|
266
|
+
Received ${i.length} interrupt(s)`};let o=i[0]?.value;return{pass:this.equals(o,t),message:()=>`${n.matcherHint("toHaveBeenInterrupted")}
|
|
267
|
+
|
|
268
|
+
Expected interrupt value: ${n.printExpected(t)}
|
|
269
|
+
Received interrupt value: ${n.printReceived(o)}`,actual:o,expected:t}}function Mk(e,t){let{isNot:r,utils:n}=this,i=e?.structuredResponse;return i===void 0?{pass:!1,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
270
|
+
|
|
271
|
+
Expected result ${r?"not ":""}to have a structured response
|
|
272
|
+
Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
273
|
+
|
|
274
|
+
Expected result not to have a structured response`}:{pass:Object.entries(t).every(([o,a])=>this.equals(i[o],a)),message:()=>`${n.matcherHint("toHaveStructuredResponse")}
|
|
275
|
+
|
|
276
|
+
Expected structured response: ${n.printExpected(t)}
|
|
277
|
+
Received structured response: ${n.printReceived(i)}`,actual:i,expected:t}}var aD={toBeHumanMessage:Ek,toBeAIMessage:$k,toBeSystemMessage:Tk,toBeToolMessage:Ak,toHaveToolCalls:Ok,toHaveToolCallCount:Ck,toContainToolCall:Pk,toHaveToolMessages:Rk,toHaveBeenInterrupted:Nk,toHaveStructuredResponse:Mk};function RK(e){return e.map(t=>t.text).filter(Boolean).join("-")}var sD=0;function NK(){return sD+=1,`fake_tc_${sD}`}var jk=class cD extends zi{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}):tt.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??NK(),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],n=new cD;return n.queue=this.queue,n._alwaysThrowError=this._alwaysThrowError,n._structuredResponseValue=this._structuredResponseValue,n._tools=r,n._calls=this._calls,n._callIndex=this._callIndex,n.withConfig({})}withStructuredOutput(t,r){let{_structuredResponseValue:n}=this;return Zt.from(async()=>n)}async _generate(t,r,n){this._calls.push({messages:[...t],options:r});let i=this._callIndex;if(this._callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let o=this.queue[i];if(!o)throw new Error(`FakeModel: no response queued for invocation ${i} (${this.queue.length} total queued).`);if(o.kind==="error")throw o.error;if(o.kind==="factory"){let s=o.factory(t);if(!tt.isInstance(s))throw s;return{generations:[{text:"",message:s}]}}if(o.kind==="message")return{generations:[{text:"",message:o.message}]};let a=RK(t);return{generations:[{text:a,message:new be({content:a,id:i.toString(),tool_calls:o.toolCalls.length>0?o.toolCalls.map(s=>({...s,type:"tool_call"})):void 0})}],llmOutput:{}}}};function uD(){return new jk}var lD=P({FakeBuiltModel:()=>jk,fakeModel:()=>uD,langchainMatchers:()=>aD,toBeAIMessage:()=>$k,toBeHumanMessage:()=>Ek,toBeSystemMessage:()=>Tk,toBeToolMessage:()=>Ak,toContainToolCall:()=>Pk,toHaveBeenInterrupted:()=>Nk,toHaveStructuredResponse:()=>Mk,toHaveToolCallCount:()=>Ck,toHaveToolCalls:()=>Ok,toHaveToolMessages:()=>Rk});function Vp(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function Zp(e){return e!==void 0&&pe.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function Gp(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(zt(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 So(e){return Gp(e)||Zp(e)||Vp(e)}var M={};li(M,{$brand:()=>Ph,$input:()=>Q0,$output:()=>Y0,NEVER:()=>jw,TimePrecision:()=>nI,ZodAny:()=>aE,ZodArray:()=>lE,ZodBase64:()=>K_,ZodBase64URL:()=>W_,ZodBigInt:()=>nl,ZodBigIntFormat:()=>Y_,ZodBoolean:()=>rl,ZodCIDRv4:()=>H_,ZodCIDRv6:()=>q_,ZodCUID:()=>L_,ZodCUID2:()=>U_,ZodCatch:()=>PE,ZodCodec:()=>ay,ZodCustom:()=>nf,ZodCustomStringFormat:()=>el,ZodDate:()=>Yp,ZodDefault:()=>EE,ZodDiscriminatedUnion:()=>pE,ZodE164:()=>J_,ZodEmail:()=>j_,ZodEmoji:()=>z_,ZodEnum:()=>Yu,ZodError:()=>MK,ZodExactOptional:()=>IE,ZodFile:()=>wE,ZodFirstPartyTypeKind:()=>ZE,ZodFunction:()=>FE,ZodGUID:()=>qp,ZodIPv4:()=>Z_,ZodIPv6:()=>G_,ZodISODate:()=>O_,ZodISODateTime:()=>A_,ZodISODuration:()=>P_,ZodISOTime:()=>C_,ZodIntersection:()=>fE,ZodIssueCode:()=>zK,ZodJWT:()=>X_,ZodKSUID:()=>V_,ZodLazy:()=>DE,ZodLiteral:()=>bE,ZodMAC:()=>Qk,ZodMap:()=>yE,ZodNaN:()=>NE,ZodNanoID:()=>D_,ZodNever:()=>cE,ZodNonOptional:()=>iy,ZodNull:()=>iE,ZodNullable:()=>kE,ZodNumber:()=>tl,ZodNumberFormat:()=>Ys,ZodObject:()=>ef,ZodOptional:()=>ny,ZodPipe:()=>oy,ZodPrefault:()=>TE,ZodPromise:()=>UE,ZodReadonly:()=>ME,ZodRealError:()=>Dr,ZodRecord:()=>rf,ZodSet:()=>vE,ZodString:()=>Qu,ZodStringFormat:()=>Je,ZodSuccess:()=>CE,ZodSymbol:()=>rE,ZodTemplateLiteral:()=>zE,ZodTransform:()=>xE,ZodTuple:()=>hE,ZodType:()=>Te,ZodULID:()=>F_,ZodURL:()=>Xp,ZodUUID:()=>Li,ZodUndefined:()=>nE,ZodUnion:()=>tf,ZodUnknown:()=>sE,ZodVoid:()=>uE,ZodXID:()=>B_,ZodXor:()=>dE,_ZodString:()=>M_,_default:()=>$E,_function:()=>_4,any:()=>WD,array:()=>Qp,base64:()=>PD,base64url:()=>RD,bigint:()=>ZD,boolean:()=>tE,catch:()=>RE,check:()=>y4,cidrv4:()=>OD,cidrv6:()=>CD,clone:()=>lt,codec:()=>m4,coerce:()=>GE,config:()=>bt,core:()=>ho,cuid:()=>xD,cuid2:()=>ID,custom:()=>v4,date:()=>XD,decode:()=>Hk,decodeAsync:()=>Kk,describe:()=>b4,discriminatedUnion:()=>n4,e164:()=>ND,email:()=>pD,emoji:()=>bD,encode:()=>Gk,encodeAsync:()=>qk,endsWith:()=>vu,enum:()=>ty,exactOptional:()=>SE,file:()=>l4,flattenError:()=>Qd,float32:()=>UD,float64:()=>FD,formatError:()=>ep,fromJSONSchema:()=>$4,function:()=>_4,getErrorMap:()=>LK,globalRegistry:()=>Be,gt:()=>Ti,gte:()=>wr,guid:()=>fD,hash:()=>LD,hex:()=>DD,hostname:()=>zD,httpUrl:()=>vD,includes:()=>_u,instanceof:()=>x4,int:()=>N_,int32:()=>BD,int64:()=>GD,intersection:()=>mE,ipv4:()=>$D,ipv6:()=>AD,iso:()=>Xu,json:()=>S4,jwt:()=>MD,keyof:()=>YD,ksuid:()=>ED,lazy:()=>LE,length:()=>Es,literal:()=>u4,locales:()=>lp,looseObject:()=>t4,looseRecord:()=>o4,lowercase:()=>hu,lt:()=>$i,lte:()=>Qr,mac:()=>TD,map:()=>a4,maxLength:()=>ks,maxSize:()=>ma,meta:()=>w4,mime:()=>bu,minLength:()=>fo,minSize:()=>Ai,multipleOf:()=>fa,nan:()=>f4,nanoid:()=>wD,nativeEnum:()=>c4,negative:()=>$g,never:()=>Q_,nonnegative:()=>Ag,nonoptional:()=>OE,nonpositive:()=>Tg,normalize:()=>wu,null:()=>oE,nullable:()=>Wp,nullish:()=>d4,number:()=>eE,object:()=>QD,optional:()=>Kp,overwrite:()=>Ln,parse:()=>Fk,parseAsync:()=>Bk,partialRecord:()=>i4,pipe:()=>Jp,positive:()=>Eg,prefault:()=>AE,preprocess:()=>k4,prettifyError:()=>Kw,promise:()=>g4,property:()=>Og,readonly:()=>jE,record:()=>_E,refine:()=>BE,regex:()=>mu,regexes:()=>vn,registry:()=>og,safeDecode:()=>Jk,safeDecodeAsync:()=>Yk,safeEncode:()=>Wk,safeEncodeAsync:()=>Xk,safeParse:()=>Vk,safeParseAsync:()=>Zk,set:()=>s4,setErrorMap:()=>DK,size:()=>Ss,slugify:()=>ku,startsWith:()=>yu,strictObject:()=>e4,string:()=>R_,stringFormat:()=>jD,stringbool:()=>I4,success:()=>p4,superRefine:()=>VE,symbol:()=>qD,templateLiteral:()=>h4,toJSONSchema:()=>mo,toLowerCase:()=>Iu,toUpperCase:()=>Su,transform:()=>ry,treeifyError:()=>qw,trim:()=>xu,tuple:()=>gE,uint32:()=>VD,uint64:()=>HD,ulid:()=>SD,undefined:()=>KD,union:()=>ey,unknown:()=>Xs,uppercase:()=>gu,url:()=>yD,util:()=>F,uuid:()=>mD,uuidv4:()=>hD,uuidv6:()=>gD,uuidv7:()=>_D,void:()=>JD,xid:()=>kD,xor:()=>r4});var Hp={};li(Hp,{ZodAny:()=>aE,ZodArray:()=>lE,ZodBase64:()=>K_,ZodBase64URL:()=>W_,ZodBigInt:()=>nl,ZodBigIntFormat:()=>Y_,ZodBoolean:()=>rl,ZodCIDRv4:()=>H_,ZodCIDRv6:()=>q_,ZodCUID:()=>L_,ZodCUID2:()=>U_,ZodCatch:()=>PE,ZodCodec:()=>ay,ZodCustom:()=>nf,ZodCustomStringFormat:()=>el,ZodDate:()=>Yp,ZodDefault:()=>EE,ZodDiscriminatedUnion:()=>pE,ZodE164:()=>J_,ZodEmail:()=>j_,ZodEmoji:()=>z_,ZodEnum:()=>Yu,ZodExactOptional:()=>IE,ZodFile:()=>wE,ZodFunction:()=>FE,ZodGUID:()=>qp,ZodIPv4:()=>Z_,ZodIPv6:()=>G_,ZodIntersection:()=>fE,ZodJWT:()=>X_,ZodKSUID:()=>V_,ZodLazy:()=>DE,ZodLiteral:()=>bE,ZodMAC:()=>Qk,ZodMap:()=>yE,ZodNaN:()=>NE,ZodNanoID:()=>D_,ZodNever:()=>cE,ZodNonOptional:()=>iy,ZodNull:()=>iE,ZodNullable:()=>kE,ZodNumber:()=>tl,ZodNumberFormat:()=>Ys,ZodObject:()=>ef,ZodOptional:()=>ny,ZodPipe:()=>oy,ZodPrefault:()=>TE,ZodPromise:()=>UE,ZodReadonly:()=>ME,ZodRecord:()=>rf,ZodSet:()=>vE,ZodString:()=>Qu,ZodStringFormat:()=>Je,ZodSuccess:()=>CE,ZodSymbol:()=>rE,ZodTemplateLiteral:()=>zE,ZodTransform:()=>xE,ZodTuple:()=>hE,ZodType:()=>Te,ZodULID:()=>F_,ZodURL:()=>Xp,ZodUUID:()=>Li,ZodUndefined:()=>nE,ZodUnion:()=>tf,ZodUnknown:()=>sE,ZodVoid:()=>uE,ZodXID:()=>B_,ZodXor:()=>dE,_ZodString:()=>M_,_default:()=>$E,_function:()=>_4,any:()=>WD,array:()=>Qp,base64:()=>PD,base64url:()=>RD,bigint:()=>ZD,boolean:()=>tE,catch:()=>RE,check:()=>y4,cidrv4:()=>OD,cidrv6:()=>CD,codec:()=>m4,cuid:()=>xD,cuid2:()=>ID,custom:()=>v4,date:()=>XD,describe:()=>b4,discriminatedUnion:()=>n4,e164:()=>ND,email:()=>pD,emoji:()=>bD,enum:()=>ty,exactOptional:()=>SE,file:()=>l4,float32:()=>UD,float64:()=>FD,function:()=>_4,guid:()=>fD,hash:()=>LD,hex:()=>DD,hostname:()=>zD,httpUrl:()=>vD,instanceof:()=>x4,int:()=>N_,int32:()=>BD,int64:()=>GD,intersection:()=>mE,ipv4:()=>$D,ipv6:()=>AD,json:()=>S4,jwt:()=>MD,keyof:()=>YD,ksuid:()=>ED,lazy:()=>LE,literal:()=>u4,looseObject:()=>t4,looseRecord:()=>o4,mac:()=>TD,map:()=>a4,meta:()=>w4,nan:()=>f4,nanoid:()=>wD,nativeEnum:()=>c4,never:()=>Q_,nonoptional:()=>OE,null:()=>oE,nullable:()=>Wp,nullish:()=>d4,number:()=>eE,object:()=>QD,optional:()=>Kp,partialRecord:()=>i4,pipe:()=>Jp,prefault:()=>AE,preprocess:()=>k4,promise:()=>g4,readonly:()=>jE,record:()=>_E,refine:()=>BE,set:()=>s4,strictObject:()=>e4,string:()=>R_,stringFormat:()=>jD,stringbool:()=>I4,success:()=>p4,superRefine:()=>VE,symbol:()=>qD,templateLiteral:()=>h4,transform:()=>ry,tuple:()=>gE,uint32:()=>VD,uint64:()=>HD,ulid:()=>SD,undefined:()=>KD,union:()=>ey,unknown:()=>Xs,url:()=>yD,uuid:()=>mD,uuidv4:()=>hD,uuidv6:()=>gD,uuidv7:()=>_D,void:()=>JD,xid:()=>kD,xor:()=>r4});var T_={};li(T_,{endsWith:()=>vu,gt:()=>Ti,gte:()=>wr,includes:()=>_u,length:()=>Es,lowercase:()=>hu,lt:()=>$i,lte:()=>Qr,maxLength:()=>ks,maxSize:()=>ma,mime:()=>bu,minLength:()=>fo,minSize:()=>Ai,multipleOf:()=>fa,negative:()=>$g,nonnegative:()=>Ag,nonpositive:()=>Tg,normalize:()=>wu,overwrite:()=>Ln,positive:()=>Eg,property:()=>Og,regex:()=>mu,size:()=>Ss,slugify:()=>ku,startsWith:()=>yu,toLowerCase:()=>Iu,toUpperCase:()=>Su,trim:()=>xu,uppercase:()=>gu});var Xu={};li(Xu,{ZodISODate:()=>O_,ZodISODateTime:()=>A_,ZodISODuration:()=>P_,ZodISOTime:()=>C_,date:()=>Dk,datetime:()=>zk,duration:()=>Uk,time:()=>Lk});var A_=I("ZodISODateTime",(e,t)=>{r0.init(e,t),Je.init(e,t)});function zk(e){return iI(A_,e)}var O_=I("ZodISODate",(e,t)=>{n0.init(e,t),Je.init(e,t)});function Dk(e){return oI(O_,e)}var C_=I("ZodISOTime",(e,t)=>{i0.init(e,t),Je.init(e,t)});function Lk(e){return aI(C_,e)}var P_=I("ZodISODuration",(e,t)=>{o0.init(e,t),Je.init(e,t)});function Uk(e){return sI(P_,e)}var dD=(e,t)=>{Yd.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ep(e,r)},flatten:{value:r=>Qd(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ou,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ou,2)}},isEmpty:{get(){return e.issues.length===0}}})},MK=I("ZodError",dD),Dr=I("ZodError",dD,{Parent:Error});var Fk=cu(Dr),Bk=uu(Dr),Vk=lu(Dr),Zk=du(Dr),Gk=Mh(Dr),Hk=jh(Dr),qk=zh(Dr),Kk=Dh(Dr),Wk=Lh(Dr),Jk=Uh(Dr),Xk=Fh(Dr),Yk=Bh(Dr);var Te=I("ZodType",(e,t)=>(we.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:$u(e,"input"),output:$u(e,"output")}}),e.toJSONSchema=zI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(F.mergeDefs(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>lt(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Fk(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Vk(e,r,n),e.parseAsync=async(r,n)=>Bk(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Zk(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Gk(e,r,n),e.decode=(r,n)=>Hk(e,r,n),e.encodeAsync=async(r,n)=>qk(e,r,n),e.decodeAsync=async(r,n)=>Kk(e,r,n),e.safeEncode=(r,n)=>Wk(e,r,n),e.safeDecode=(r,n)=>Jk(e,r,n),e.safeEncodeAsync=async(r,n)=>Xk(e,r,n),e.safeDecodeAsync=async(r,n)=>Yk(e,r,n),e.refine=(r,n)=>e.check(BE(r,n)),e.superRefine=r=>e.check(VE(r)),e.overwrite=r=>e.check(Ln(r)),e.optional=()=>Kp(e),e.exactOptional=()=>SE(e),e.nullable=()=>Wp(e),e.nullish=()=>Kp(Wp(e)),e.nonoptional=r=>OE(e,r),e.array=()=>Qp(e),e.or=r=>ey([e,r]),e.and=r=>mE(e,r),e.transform=r=>Jp(e,ry(r)),e.default=r=>$E(e,r),e.prefault=r=>AE(e,r),e.catch=r=>RE(e,r),e.pipe=r=>Jp(e,r),e.readonly=()=>jE(e),e.describe=r=>{let n=e.clone();return Be.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Be.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Be.get(e);let n=e.clone();return Be.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),M_=I("_ZodString",(e,t)=>{xs.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(n,i,o)=>DI(e,n,i,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(mu(...n)),e.includes=(...n)=>e.check(_u(...n)),e.startsWith=(...n)=>e.check(yu(...n)),e.endsWith=(...n)=>e.check(vu(...n)),e.min=(...n)=>e.check(fo(...n)),e.max=(...n)=>e.check(ks(...n)),e.length=(...n)=>e.check(Es(...n)),e.nonempty=(...n)=>e.check(fo(1,...n)),e.lowercase=n=>e.check(hu(n)),e.uppercase=n=>e.check(gu(n)),e.trim=()=>e.check(xu()),e.normalize=(...n)=>e.check(wu(...n)),e.toLowerCase=()=>e.check(Iu()),e.toUpperCase=()=>e.check(Su()),e.slugify=()=>e.check(ku())}),Qu=I("ZodString",(e,t)=>{xs.init(e,t),M_.init(e,t),e.email=r=>e.check(ag(j_,r)),e.url=r=>e.check(pp(Xp,r)),e.jwt=r=>e.check(kg(X_,r)),e.emoji=r=>e.check(dg(z_,r)),e.guid=r=>e.check(dp(qp,r)),e.uuid=r=>e.check(sg(Li,r)),e.uuidv4=r=>e.check(cg(Li,r)),e.uuidv6=r=>e.check(ug(Li,r)),e.uuidv7=r=>e.check(lg(Li,r)),e.nanoid=r=>e.check(pg(D_,r)),e.guid=r=>e.check(dp(qp,r)),e.cuid=r=>e.check(fg(L_,r)),e.cuid2=r=>e.check(mg(U_,r)),e.ulid=r=>e.check(hg(F_,r)),e.base64=r=>e.check(xg(K_,r)),e.base64url=r=>e.check(Ig(W_,r)),e.xid=r=>e.check(gg(B_,r)),e.ksuid=r=>e.check(_g(V_,r)),e.ipv4=r=>e.check(yg(Z_,r)),e.ipv6=r=>e.check(vg(G_,r)),e.cidrv4=r=>e.check(bg(H_,r)),e.cidrv6=r=>e.check(wg(q_,r)),e.e164=r=>e.check(Sg(J_,r)),e.datetime=r=>e.check(zk(r)),e.date=r=>e.check(Dk(r)),e.time=r=>e.check(Lk(r)),e.duration=r=>e.check(Uk(r))});function R_(e){return eI(Qu,e)}var Je=I("ZodStringFormat",(e,t)=>{Ke.init(e,t),M_.init(e,t)}),j_=I("ZodEmail",(e,t)=>{qx.init(e,t),Je.init(e,t)});function pD(e){return ag(j_,e)}var qp=I("ZodGUID",(e,t)=>{Gx.init(e,t),Je.init(e,t)});function fD(e){return dp(qp,e)}var Li=I("ZodUUID",(e,t)=>{Hx.init(e,t),Je.init(e,t)});function mD(e){return sg(Li,e)}function hD(e){return cg(Li,e)}function gD(e){return ug(Li,e)}function _D(e){return lg(Li,e)}var Xp=I("ZodURL",(e,t)=>{Kx.init(e,t),Je.init(e,t)});function yD(e){return pp(Xp,e)}function vD(e){return pp(Xp,{protocol:/^https?$/,hostname:vn.domain,...F.normalizeParams(e)})}var z_=I("ZodEmoji",(e,t)=>{Wx.init(e,t),Je.init(e,t)});function bD(e){return dg(z_,e)}var D_=I("ZodNanoID",(e,t)=>{Jx.init(e,t),Je.init(e,t)});function wD(e){return pg(D_,e)}var L_=I("ZodCUID",(e,t)=>{Xx.init(e,t),Je.init(e,t)});function xD(e){return fg(L_,e)}var U_=I("ZodCUID2",(e,t)=>{Yx.init(e,t),Je.init(e,t)});function ID(e){return mg(U_,e)}var F_=I("ZodULID",(e,t)=>{Qx.init(e,t),Je.init(e,t)});function SD(e){return hg(F_,e)}var B_=I("ZodXID",(e,t)=>{e0.init(e,t),Je.init(e,t)});function kD(e){return gg(B_,e)}var V_=I("ZodKSUID",(e,t)=>{t0.init(e,t),Je.init(e,t)});function ED(e){return _g(V_,e)}var Z_=I("ZodIPv4",(e,t)=>{a0.init(e,t),Je.init(e,t)});function $D(e){return yg(Z_,e)}var Qk=I("ZodMAC",(e,t)=>{c0.init(e,t),Je.init(e,t)});function TD(e){return rI(Qk,e)}var G_=I("ZodIPv6",(e,t)=>{s0.init(e,t),Je.init(e,t)});function AD(e){return vg(G_,e)}var H_=I("ZodCIDRv4",(e,t)=>{u0.init(e,t),Je.init(e,t)});function OD(e){return bg(H_,e)}var q_=I("ZodCIDRv6",(e,t)=>{l0.init(e,t),Je.init(e,t)});function CD(e){return wg(q_,e)}var K_=I("ZodBase64",(e,t)=>{p0.init(e,t),Je.init(e,t)});function PD(e){return xg(K_,e)}var W_=I("ZodBase64URL",(e,t)=>{f0.init(e,t),Je.init(e,t)});function RD(e){return Ig(W_,e)}var J_=I("ZodE164",(e,t)=>{m0.init(e,t),Je.init(e,t)});function ND(e){return Sg(J_,e)}var X_=I("ZodJWT",(e,t)=>{h0.init(e,t),Je.init(e,t)});function MD(e){return kg(X_,e)}var el=I("ZodCustomStringFormat",(e,t)=>{g0.init(e,t),Je.init(e,t)});function jD(e,t,r={}){return Eu(el,e,t,r)}function zD(e){return Eu(el,"hostname",vn.hostname,e)}function DD(e){return Eu(el,"hex",vn.hex,e)}function LD(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=vn[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return Eu(el,n,i,t)}var tl=I("ZodNumber",(e,t)=>{Yh.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(n,i,o)=>LI(e,n,i,o),e.gt=(n,i)=>e.check(Ti(n,i)),e.gte=(n,i)=>e.check(wr(n,i)),e.min=(n,i)=>e.check(wr(n,i)),e.lt=(n,i)=>e.check($i(n,i)),e.lte=(n,i)=>e.check(Qr(n,i)),e.max=(n,i)=>e.check(Qr(n,i)),e.int=n=>e.check(N_(n)),e.safe=n=>e.check(N_(n)),e.positive=n=>e.check(Ti(0,n)),e.nonnegative=n=>e.check(wr(0,n)),e.negative=n=>e.check($i(0,n)),e.nonpositive=n=>e.check(Qr(0,n)),e.multipleOf=(n,i)=>e.check(fa(n,i)),e.step=(n,i)=>e.check(fa(n,i)),e.finite=()=>e;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 eE(e){return cI(tl,e)}var Ys=I("ZodNumberFormat",(e,t)=>{_0.init(e,t),tl.init(e,t)});function N_(e){return lI(Ys,e)}function UD(e){return dI(Ys,e)}function FD(e){return pI(Ys,e)}function BD(e){return fI(Ys,e)}function VD(e){return mI(Ys,e)}var rl=I("ZodBoolean",(e,t)=>{ip.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>UI(e,r,n,i)});function tE(e){return hI(rl,e)}var nl=I("ZodBigInt",(e,t)=>{Qh.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(n,i,o)=>FI(e,n,i,o),e.gte=(n,i)=>e.check(wr(n,i)),e.min=(n,i)=>e.check(wr(n,i)),e.gt=(n,i)=>e.check(Ti(n,i)),e.gte=(n,i)=>e.check(wr(n,i)),e.min=(n,i)=>e.check(wr(n,i)),e.lt=(n,i)=>e.check($i(n,i)),e.lte=(n,i)=>e.check(Qr(n,i)),e.max=(n,i)=>e.check(Qr(n,i)),e.positive=n=>e.check(Ti(BigInt(0),n)),e.negative=n=>e.check($i(BigInt(0),n)),e.nonpositive=n=>e.check(Qr(BigInt(0),n)),e.nonnegative=n=>e.check(wr(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(fa(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function ZD(e){return _I(nl,e)}var Y_=I("ZodBigIntFormat",(e,t)=>{y0.init(e,t),nl.init(e,t)});function GD(e){return vI(Y_,e)}function HD(e){return bI(Y_,e)}var rE=I("ZodSymbol",(e,t)=>{v0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>BI(e,r,n,i)});function qD(e){return wI(rE,e)}var nE=I("ZodUndefined",(e,t)=>{b0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ZI(e,r,n,i)});function KD(e){return xI(nE,e)}var iE=I("ZodNull",(e,t)=>{w0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>VI(e,r,n,i)});function oE(e){return II(iE,e)}var aE=I("ZodAny",(e,t)=>{x0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>qI(e,r,n,i)});function WD(){return SI(aE)}var sE=I("ZodUnknown",(e,t)=>{op.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>KI(e,r,n,i)});function Xs(){return fp(sE)}var cE=I("ZodNever",(e,t)=>{ap.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>HI(e,r,n,i)});function Q_(e){return mp(cE,e)}var uE=I("ZodVoid",(e,t)=>{I0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>GI(e,r,n,i)});function JD(e){return kI(uE,e)}var Yp=I("ZodDate",(e,t)=>{S0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(n,i,o)=>WI(e,n,i,o),e.min=(n,i)=>e.check(wr(n,i)),e.max=(n,i)=>e.check(Qr(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function XD(e){return EI(Yp,e)}var lE=I("ZodArray",(e,t)=>{k0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sS(e,r,n,i),e.element=t.element,e.min=(r,n)=>e.check(fo(r,n)),e.nonempty=r=>e.check(fo(1,r)),e.max=(r,n)=>e.check(ks(r,n)),e.length=(r,n)=>e.check(Es(r,n)),e.unwrap=()=>e.element});function Qp(e,t){return AI(lE,e,t)}function YD(e){let t=e._zod.def.shape;return ty(Object.keys(t))}var ef=I("ZodObject",(e,t)=>{E0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cS(e,r,n,i),F.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>ty(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Xs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Xs()}),e.strict=()=>e.clone({...e._zod.def,catchall:Q_()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>F.extend(e,r),e.safeExtend=r=>F.safeExtend(e,r),e.merge=r=>F.merge(e,r),e.pick=r=>F.pick(e,r),e.omit=r=>F.omit(e,r),e.partial=(...r)=>F.partial(ny,e,r[0]),e.required=(...r)=>F.required(iy,e,r[0])});function QD(e,t){let r={type:"object",shape:e??{},...F.normalizeParams(t)};return new ef(r)}function e4(e,t){return new ef({type:"object",shape:e,catchall:Q_(),...F.normalizeParams(t)})}function t4(e,t){return new ef({type:"object",shape:e,catchall:Xs(),...F.normalizeParams(t)})}var tf=I("ZodUnion",(e,t)=>{sp.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pg(e,r,n,i),e.options=t.options});function ey(e,t){return new tf({type:"union",options:e,...F.normalizeParams(t)})}var dE=I("ZodXor",(e,t)=>{tf.init(e,t),$0.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Pg(e,r,n,i),e.options=t.options});function r4(e,t){return new dE({type:"union",options:e,inclusive:!1,...F.normalizeParams(t)})}var pE=I("ZodDiscriminatedUnion",(e,t)=>{tf.init(e,t),T0.init(e,t)});function n4(e,t,r){return new pE({type:"union",options:t,discriminator:e,...F.normalizeParams(r)})}var fE=I("ZodIntersection",(e,t)=>{A0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uS(e,r,n,i)});function mE(e,t){return new fE({type:"intersection",left:e,right:t})}var hE=I("ZodTuple",(e,t)=>{eg.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lS(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function gE(e,t,r){let n=t instanceof we,i=n?r:t,o=n?t:null;return new hE({type:"tuple",items:e,rest:o,...F.normalizeParams(i)})}var rf=I("ZodRecord",(e,t)=>{O0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>dS(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function _E(e,t,r){return new rf({type:"record",keyType:e,valueType:t,...F.normalizeParams(r)})}function i4(e,t,r){let n=lt(e);return n._zod.values=void 0,new rf({type:"record",keyType:n,valueType:t,...F.normalizeParams(r)})}function o4(e,t,r){return new rf({type:"record",keyType:e,valueType:t,mode:"loose",...F.normalizeParams(r)})}var yE=I("ZodMap",(e,t)=>{C0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>oS(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ai(...r)),e.nonempty=r=>e.check(Ai(1,r)),e.max=(...r)=>e.check(ma(...r)),e.size=(...r)=>e.check(Ss(...r))});function a4(e,t,r){return new yE({type:"map",keyType:e,valueType:t,...F.normalizeParams(r)})}var vE=I("ZodSet",(e,t)=>{P0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>aS(e,r,n,i),e.min=(...r)=>e.check(Ai(...r)),e.nonempty=r=>e.check(Ai(1,r)),e.max=(...r)=>e.check(ma(...r)),e.size=(...r)=>e.check(Ss(...r))});function s4(e,t){return new vE({type:"set",valueType:e,...F.normalizeParams(t)})}var Yu=I("ZodEnum",(e,t)=>{R0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(n,i,o)=>JI(e,n,i,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Yu({...t,checks:[],...F.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Yu({...t,checks:[],...F.normalizeParams(i),entries:o})}});function ty(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Yu({type:"enum",entries:r,...F.normalizeParams(t)})}function c4(e,t){return new Yu({type:"enum",entries:e,...F.normalizeParams(t)})}var bE=I("ZodLiteral",(e,t)=>{N0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>XI(e,r,n,i),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 u4(e,t){return new bE({type:"literal",values:Array.isArray(e)?e:[e],...F.normalizeParams(t)})}var wE=I("ZodFile",(e,t)=>{M0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>eS(e,r,n,i),e.min=(r,n)=>e.check(Ai(r,n)),e.max=(r,n)=>e.check(ma(r,n)),e.mime=(r,n)=>e.check(bu(Array.isArray(r)?r:[r],n))});function l4(e){return OI(wE,e)}var xE=I("ZodTransform",(e,t)=>{j0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>iS(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ca(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(F.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(F.issue(a))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function ry(e){return new xE({type:"transform",transform:e})}var ny=I("ZodOptional",(e,t)=>{Is.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rg(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Kp(e){return new ny({type:"optional",innerType:e})}var IE=I("ZodExactOptional",(e,t)=>{z0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Rg(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function SE(e){return new IE({type:"optional",innerType:e})}var kE=I("ZodNullable",(e,t)=>{D0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>pS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Wp(e){return new kE({type:"nullable",innerType:e})}function d4(e){return Kp(Wp(e))}var EE=I("ZodDefault",(e,t)=>{L0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $E(e,t){return new EE({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():F.shallowClone(t)}})}var TE=I("ZodPrefault",(e,t)=>{U0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function AE(e,t){return new TE({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():F.shallowClone(t)}})}var iy=I("ZodNonOptional",(e,t)=>{F0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function OE(e,t){return new iy({type:"nonoptional",innerType:e,...F.normalizeParams(t)})}var CE=I("ZodSuccess",(e,t)=>{B0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>tS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function p4(e){return new CE({type:"success",innerType:e})}var PE=I("ZodCatch",(e,t)=>{V0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function RE(e,t){return new PE({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var NE=I("ZodNaN",(e,t)=>{Z0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>YI(e,r,n,i)});function f4(e){return TI(NE,e)}var oy=I("ZodPipe",(e,t)=>{G0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_S(e,r,n,i),e.in=t.in,e.out=t.out});function Jp(e,t){return new oy({type:"pipe",in:e,out:t})}var ay=I("ZodCodec",(e,t)=>{oy.init(e,t),cp.init(e,t)});function m4(e,t,r){return new ay({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var ME=I("ZodReadonly",(e,t)=>{H0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function jE(e){return new ME({type:"readonly",innerType:e})}var zE=I("ZodTemplateLiteral",(e,t)=>{q0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>QI(e,r,n,i)});function h4(e,t){return new zE({type:"template_literal",parts:e,...F.normalizeParams(t)})}var DE=I("ZodLazy",(e,t)=>{J0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bS(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function LE(e){return new DE({type:"lazy",getter:e})}var UE=I("ZodPromise",(e,t)=>{W0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vS(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function g4(e){return new UE({type:"promise",innerType:e})}var FE=I("ZodFunction",(e,t)=>{K0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>nS(e,r,n,i)});function _4(e){return new FE({type:"function",input:Array.isArray(e?.input)?gE(e?.input):e?.input??Qp(Xs()),output:e?.output??Xs()})}var nf=I("ZodCustom",(e,t)=>{X0.init(e,t),Te.init(e,t),e._zod.processJSONSchema=(r,n,i)=>rS(e,r,n,i)});function y4(e){let t=new Qe({check:"custom"});return t._zod.check=e,t}function v4(e,t){return CI(nf,e??(()=>!0),t)}function BE(e,t={}){return PI(nf,e,t)}function VE(e){return RI(e)}var b4=NI,w4=MI;function x4(e,t={}){let r=new nf({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...F.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var I4=(...e)=>jI({Codec:ay,Boolean:rl,String:Qu},...e);function S4(e){let t=LE(()=>ey([R_(e),eE(),tE(),oE(),Qp(t),_E(R_(),t)]));return t}function k4(e,t){return Jp(ry(e),t)}var zK={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 DK(e){bt({customError:e})}function LK(){return bt().customError}var ZE;ZE||(ZE={});var J={...Hp,...T_,iso:Xu},UK=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 FK(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 BK(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 n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let i=r[1];if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function E4(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return J.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 i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return J.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let o=BK(i,t),a=cr(o,t);return t.refs.set(i,a),t.processing.delete(i),a}if(e.enum!==void 0){let i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return J.null();if(i.length===0)return J.never();if(i.length===1)return J.literal(i[0]);if(i.every(a=>typeof a=="string"))return J.enum(i);let o=i.map(a=>J.literal(a));return o.length<2?o[0]:J.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return J.literal(e.const);let r=e.type;if(Array.isArray(r)){let i=r.map(o=>{let a={...e,type:o};return E4(a,t)});return i.length===0?J.never():i.length===1?i[0]:J.union(i)}if(!r)return J.any();let n;switch(r){case"string":{let i=J.string();if(e.format){let o=e.format;o==="email"?i=i.check(J.email()):o==="uri"||o==="uri-reference"?i=i.check(J.url()):o==="uuid"||o==="guid"?i=i.check(J.uuid()):o==="date-time"?i=i.check(J.iso.datetime()):o==="date"?i=i.check(J.iso.date()):o==="time"?i=i.check(J.iso.time()):o==="duration"?i=i.check(J.iso.duration()):o==="ipv4"?i=i.check(J.ipv4()):o==="ipv6"?i=i.check(J.ipv6()):o==="mac"?i=i.check(J.mac()):o==="cidr"?i=i.check(J.cidrv4()):o==="cidr-v6"?i=i.check(J.cidrv6()):o==="base64"?i=i.check(J.base64()):o==="base64url"?i=i.check(J.base64url()):o==="e164"?i=i.check(J.e164()):o==="jwt"?i=i.check(J.jwt()):o==="emoji"?i=i.check(J.emoji()):o==="nanoid"?i=i.check(J.nanoid()):o==="cuid"?i=i.check(J.cuid()):o==="cuid2"?i=i.check(J.cuid2()):o==="ulid"?i=i.check(J.ulid()):o==="xid"?i=i.check(J.xid()):o==="ksuid"&&(i=i.check(J.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),n=i;break}case"number":case"integer":{let i=r==="integer"?J.number().int():J.number();typeof e.minimum=="number"&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),n=i;break}case"boolean":{n=J.boolean();break}case"null":{n=J.null();break}case"object":{let i={},o=e.properties||{},a=new Set(e.required||[]);for(let[c,u]of Object.entries(o)){let l=cr(u,t);i[c]=a.has(c)?l:l.optional()}if(e.propertyNames){let c=cr(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?cr(e.additionalProperties,t):J.any();if(Object.keys(i).length===0){n=J.record(c,u);break}let l=J.object(i).passthrough(),d=J.looseRecord(c,u);n=J.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let p=cr(c[f],t),m=J.string().regex(new RegExp(f));l.push(J.looseRecord(m,p))}let d=[];if(Object.keys(i).length>0&&d.push(J.object(i).passthrough()),d.push(...l),d.length===0)n=J.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=J.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=J.intersection(f,d[p]);n=f}break}let s=J.object(i);e.additionalProperties===!1?n=s.strict():typeof e.additionalProperties=="object"?n=s.catchall(cr(e.additionalProperties,t)):n=s.passthrough();break}case"array":{let i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){let a=i.map(c=>cr(c,t)),s=o&&typeof o=="object"&&!Array.isArray(o)?cr(o,t):void 0;s?n=J.tuple(a).rest(s):n=J.tuple(a),typeof e.minItems=="number"&&(n=n.check(J.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(J.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=o.map(c=>cr(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?cr(e.additionalItems,t):void 0;s?n=J.tuple(a).rest(s):n=J.tuple(a),typeof e.minItems=="number"&&(n=n.check(J.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(J.maxLength(e.maxItems)))}else if(o!==void 0){let a=cr(o,t),s=J.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),n=s}else n=J.array(J.any());break}default:throw new Error(`Unsupported type: ${r}`)}return e.description&&(n=n.describe(e.description)),e.default!==void 0&&(n=n.default(e.default)),n}function cr(e,t){if(typeof e=="boolean")return e?J.any():J.never();let r=E4(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>cr(u,t)),c=J.union(s);r=n?J.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>cr(u,t)),c=J.xor(s);r=n?J.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:J.any();else{let s=n?r:cr(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)s=J.intersection(s,cr(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=J.nullable(r)),e.readOnly===!0&&(r=J.readonly(r));let i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(i[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(i[s]=e[s]);for(let s of Object.keys(e))UK.has(s)||(i[s]=e[s]);return Object.keys(i).length>0&&t.registry.add(r,i),r}function $4(e,t){if(typeof e=="boolean")return e?J.any():J.never();let r=FK(e,t?.defaultTarget),n=e.$defs||e.definitions||{},i={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??Be};return cr(e,i)}var GE={};li(GE,{bigint:()=>HK,boolean:()=>GK,date:()=>qK,number:()=>ZK,string:()=>VK});function VK(e){return tI(Qu,e)}function ZK(e){return uI(tl,e)}function GK(e){return gI(rl,e)}function HK(e){return yI(nl,e)}function qK(e){return $I(Yp,e)}bt(tg());var T4=P({BaseToolkit:()=>WK,DynamicStructuredTool:()=>A4,DynamicTool:()=>qE,StructuredTool:()=>of,Tool:()=>HE,ToolInputParsingException:()=>qc,isLangChainTool:()=>So,isRunnableToolLike:()=>Zp,isStructuredTool:()=>Vp,isStructuredToolParams:()=>Gp,tool:()=>af}),of=class extends l_{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,n=Ne(Bt(this.defaultConfig,t));return Yo(e)?(r=e.args,n={...n,toolCall:e}):r=e,this.call(r,n)}async call(e,t,r){let n=Yo(e)?e.args:e,i;if(zt(this.schema))try{i=await ya(this.schema,n)}catch(p){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
278
|
+
Details: ${p.message}`),Ug(p)&&(m=`${m}
|
|
279
|
+
|
|
280
|
+
${M.prettifyError(p)}`),new qc(m,JSON.stringify(e))}else{let p=nt(n,this.schema);if(!p.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
281
|
+
Details: ${p.errors.map(h=>`${h.keywordLocation}: ${h.error}`).join(`
|
|
282
|
+
`)}`),new qc(m,JSON.stringify(e))}i=n}let o=hs(t),a=Et.configure(o.callbacks,this.callbacks,o.tags||r,this.tags,o.metadata,this.metadata,{verbose:this.verbose}),s;Yo(e)&&(s=e.id),!s&&ZA(o)&&(s=o.toolCall.id);let c=await a?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),o.runId,void 0,void 0,void 0,o.runName,s);delete o.runId;let u;try{let p=await this._call(i,c,o);u=jS(p)?await gj(p,async m=>{try{await c?.handleToolEvent(m)}catch(h){await c?.handleToolError(h)}}):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.
|
|
283
|
+
Result: ${JSON.stringify(u)}`);else l=u;let f=JK({content:l,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},HE=class extends of{schema=Vt.object({input:Vt.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)}},qE=class extends HE{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=hs(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r)}_call(e,t,r){return this.func(e,t,r)}},A4=class extends of{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 n=hs(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n,r)}_call(e,t,r){return this.func(e,t,r)}},WK=class{getTools(){return this.tools}};function af(e,t){let r=Ou(t.schema),n=Uu(t.schema);if(!t.schema||r||n)return new qE({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(a,s,c)=>new Promise((u,l)=>{let d=Me(c,{callbacks:s?.getChild()});He.runWithConfig(br(d),async()=>{try{u(e(a,d))}catch(f){l(f)}})})});let i=t.schema,o=t.description??t.schema.description??`${t.name} tool`;return new A4({...t,description:o,schema:i,func:async(a,s,c)=>new Promise((u,l)=>{let d,f=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{f(),l(ia(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let p=Me(c,{callbacks:s?.getChild()});He.runWithConfig(br(p),async()=>{try{let m=await e(a,p);if(jS(m)){u(m);return}if(c?.signal?.aborted){f();return}f(),u(m)}catch(m){f(),l(m)}})})})}function JK(e){let{content:t,artifact:r,toolCallId:n,metadata:i}=e;return n&&!xd(t)?typeof t=="string"||Array.isArray(t)&&t.every(o=>typeof o=="object")?new jt({status:"success",content:t,artifact:r,tool_call_id:n,name:e.name,metadata:i}):new jt({status:"success",content:XK(t),artifact:r,tool_call_id:n,name:e.name,metadata:i}):t}function XK(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var O4=P({RunCollectorCallbackHandler:()=>YK}),YK=class extends Jt{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 C4=P({});var P4=P({chunkArray:()=>sy}),sy=(e,t)=>e.reduce((r,n,i)=>{let o=Math.floor(i/t);return r[o]=(r[o]||[]).concat([n]),r},[]);var R4=P({context:()=>QK});function QK(e,...t){let r=e.raw,n="";for(let i=0;i<r.length;i++){let o=r[i].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(n+=o,i<t.length){let a=eW(t[i],n);n+=typeof a=="string"?a:JSON.stringify(a)}}return n=tW(n),n=n.trim(),n=n.replace(/\\n/g,`
|
|
284
|
+
`),n}function eW(e,t){if(typeof e!="string"||!e.includes(`
|
|
285
|
+
`))return e;let r=t.slice(t.lastIndexOf(`
|
|
286
|
+
`)+1).match(/^(\s+)/);if(r){let n=r[1];return e.replace(/\n/g,`
|
|
287
|
+
${n}`)}return e}function tW(e){let t=e.split(`
|
|
288
|
+
`),r=null;for(let n of t){let i=n.match(/^(\s+)\S+/);if(i){let o=i[1].length;r===null?r=o:r=Math.min(r,o)}}return r===null?e:t.map(n=>n[0]===" "||n[0]===" "?n.slice(r):n).join(`
|
|
289
|
+
`)}var N4=P({EventStreamContentType:()=>rW,convertEventStreamToIterableReadableDataStream:()=>iW,getBytes:()=>M4,getLines:()=>j4,getMessages:()=>z4}),rW="text/event-stream";async function M4(e,t){if(e instanceof ReadableStream){let r=e.getReader();for(;;){let n=await r.read();if(n.done){t(new Uint8Array,!0);break}t(n.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(`
|
|
290
|
+
`))}}var il=(function(e){return e[e.NewLine=10]="NewLine",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.Colon=58]="Colon",e})(il||{});function j4(e){let t,r,n,i=!1;return function(a,s){if(s){e(a,0,!0);return}t===void 0?(t=a,r=0,n=-1):t=nW(t,a);let c=t.length,u=0;for(;r<c;){i&&(t[r]===il.NewLine&&(u=++r),i=!1);let l=-1;for(;r<c&&l===-1;++r)switch(t[r]){case il.Colon:n===-1&&(n=r-u);break;case il.CarriageReturn:i=!0;case il.NewLine:l=r;break}if(l===-1)break;e(t.subarray(u,l),n),u=r,n=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),r-=u)}}function z4(e,t,r){let n=KE(),i=new TextDecoder;return function(a,s,c){if(c){oW(n)||(e?.(n),n=KE());return}if(a.length===0)e?.(n),n=KE();else if(s>0){let u=i.decode(a.subarray(0,s)),l=s+(a[s+1]===il.Space?2:1),d=i.decode(a.subarray(l));switch(u){case"data":n.data=n.data?n.data+`
|
|
291
|
+
`+d:d;break;case"event":n.event=d;break;case"id":t?.(n.id=d);break;case"retry":{let f=parseInt(d,10);Number.isNaN(f)||r?.(n.retry=f);break}}}}}function nW(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function KE(){return{data:"",event:"",id:"",retry:void 0}}function iW(e,t){let r=new ReadableStream({async start(n){let i=z4(a=>{if(a.event==="error")throw new Error(a.data??"Unspecified event streaming error.");a.event==="metadata"?t?.(a):a.data&&n.enqueue(a.data)});await M4(e,j4((a,s,c)=>{i(a,s,c),c&&n.close()}))}});return Ct.fromReadableStream(r)}function oW(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var D4=P({});var L4=P({convertToOpenAIFunction:()=>U4,convertToOpenAITool:()=>WE,isLangChainTool:()=>So,isRunnableToolLike:()=>Zp,isStructuredTool:()=>Vp,isStructuredToolParams:()=>Gp});function U4(e,t){let r=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:dt(e.schema),...r?.strict!==void 0?{strict:r.strict}:{}}}function WE(e,t){let r=typeof t=="number"?void 0:t,n;return So(e)?n={type:"function",function:U4(e)}:n=e,r?.strict!==void 0&&(n.function.strict=r.strict),n}function cy(e,t){let r=0,n=0,i=0;for(let o=0;o<e.length;o++)r+=e[o]*t[o],n+=e[o]*e[o],i+=t[o]*t[o];return r/(Math.sqrt(n)*Math.sqrt(i))}function F4(e,t){let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}function aW(e,t){let r=0;for(let n=0;n<e.length;n++)r+=(e[n]-t[n])*(e[n]-t[n]);return r}function B4(e,t){return Math.sqrt(aW(e,t))}var V4=P({cosineSimilarity:()=>JE,euclideanDistance:()=>uW,innerProduct:()=>cW,matrixFunc:()=>uy,maximalMarginalRelevance:()=>lW,normalize:()=>sW});function uy(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(n=>t.map(i=>r(n,i)).map(i=>Number.isNaN(i)?0:i))}function sW(e,t=!1){let r=dW(e);return e.map(n=>n.map(i=>t?1-i/r:i/r))}function JE(e,t){return uy(e,t,cy)}function cW(e,t){return uy(e,t,F4)}function uW(e,t){return uy(e,t,B4)}function lW(e,t,r=.5,n=4){if(Math.min(n,t.length)<=0)return[];let i=JE(Array.isArray(e[0])?e:[e],t)[0],o=Z4(i).maxIndex,a=[t[o]],s=[o];for(;s.length<Math.min(n,t.length);){let c=-1/0,u=-1,l=JE(t,a);i.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)}),a.push(t[u]),s.push(u)}return s}function Z4(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],r=0;for(let n=1;n<e.length;n+=1)e[n]>t&&(r=n,t=e[n]);return{maxIndex:r,maxValue:t}}function dW(e){return e.reduce((t,r)=>Math.max(t,Z4(r).maxValue),0)}var G4=P({isCloudMetadata:()=>XE,isLocalhost:()=>YE,isPrivateIp:()=>J4,isSafeUrl:()=>vW,isSameOrigin:()=>bW,validateSafeUrl:()=>X4}),pW=["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"],fW=["169.254.169.254","169.254.170.2","100.100.100.200"],mW=["metadata.google.internal","metadata","instance-data"],hW=["localhost","localhost.localdomain"],gW=/^(?:(?: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 H4(e){return gW.test(e)}function ly(e){return W4(e)!==null}function q4(e){return H4(e)||ly(e)}function K4(e){if(H4(e))return e.split(".").map(t=>parseInt(t,10));if(ly(e)){let t=W4(e);if(!t)return null;let r=t.split(":"),n=[];for(let i of r)n.push(parseInt(i,16));return n}return null}function W4(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let n=t.split("::");if(n.length>2)return null;let[i,o]=n,a=i?i.split(":"):[],s=o?o.split(":"):[],c=8-(a.length+s.length);if(c<0)return null;let u=Array(c).fill("0");t=[...a,...u,...s].filter(l=>l!=="").join(":")}let r=t.split(":");if(r.length!==8)return null;for(let n of r)if(n.length===0||n.length>4||!/^[0-9a-fA-F]+$/.test(n))return null;return r.map(n=>n.padStart(4,"0").toLowerCase()).join(":")}function _W(e){let[t,r]=e.split("/");if(!t||!r)return null;let n=K4(t);if(!n)return null;let i=parseInt(r,10);if(isNaN(i))return null;let o=ly(t);return o&&i>128||!o&&i>32?null:{addr:n,prefixLen:i,isIpv6:o}}function yW(e,t){let r=K4(e);if(!r)return!1;let n=_W(t);if(!n)return!1;let i=ly(e);if(i!==n.isIpv6)return!1;let{addr:o,prefixLen:a}=n;if(i)for(let s=0;s<Math.ceil(a/16);s++){let c=65535<<16-Math.min(16,a-s*16)&65535;if((r[s]&c)!==(o[s]&c))return!1}else for(let s=0;s<Math.ceil(a/8);s++){let c=255<<8-Math.min(8,a-s*8)&255;if((r[s]&c)!==(o[s]&c))return!1}return!0}function J4(e){if(!q4(e))return!1;for(let t of pW)if(yW(e,t))return!0;return!1}function XE(e,t){if(fW.includes(t||""))return!0;let r=e.toLowerCase();return!!mW.includes(r)}function YE(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!!hW.includes(r)}function X4(e,t){let r=t?.allowPrivate??!1,n=t?.allowHttp??!1;try{let i;try{i=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let o=i.hostname;if(!o)throw new Error("URL missing hostname.");if(XE(o))throw new Error(`URL points to cloud metadata endpoint: ${o}`);if(YE(o)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}let a=i.protocol;if(a!=="http:"&&a!=="https:")throw new Error(`Invalid URL scheme: ${a}. Only http and https are allowed.`);if(a==="http:"&&!n)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(q4(o)){let s=o;if(YE(o,s)){if(!r)throw new Error(`URL points to localhost: ${o}`);return e}if(XE(o,s))throw new Error(`URL resolves to cloud metadata IP: ${s} (${o})`);if(J4(s)&&!r)throw new Error(`URL resolves to private IP: ${s} (${o}). Set allowPrivate: true to allow.`);return e}return e}catch(i){throw i&&typeof i=="object"&&"message"in i?i:new Error(`URL validation failed: ${i}`)}}function vW(e,t){try{return X4(e,t),!0}catch{return!1}}function bW(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var Y4=P({SaveableVectorStore:()=>wW,VectorStore:()=>py,VectorStoreRetriever:()=>dy}),dy=class extends Up{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)}},py=class extends kt{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,n=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)).map(i=>i[0])}async similaritySearchWithScore(e,t=4,r=void 0,n=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,r)}static fromTexts(e,t,r,n){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,n,i,o){if(typeof e=="number")return new dy({vectorStore:this,k:e,filter:t,tags:[...n??[],this._vectorstoreType()],metadata:i,verbose:o,callbacks:r});{let a={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 dy({...a,searchKwargs:e.searchKwargs}):new dy({...a})}}},wW=class extends py{static load(e,t){throw new Error("Not implemented")}};var Q4=class extends zi{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,r){if(t?.stop?.length)return{generations:[{message:new be(t.stop[0]),text:t.stop[0]}]};let n=e.map(i=>typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2)).join(`
|
|
292
|
+
`);return await r?.handleLLMNewToken(n),{generations:[{message:new be(n),text:n}],llmOutput:{}}}},eL=class tL extends zi{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:r=[],chunks:n=[],toolStyle:i="openai",thrownErrorString:o,...a}){super(a),this.sleep=t,this.responses=r,this.chunks=n,this.toolStyle=i,this.thrownErrorString=o}_llmType(){return"fake"}bindTools(t){let r=[...this.tools,...t],n=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:dt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:dt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:dt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:dt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new tL({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return o.tools=r,o.withConfig({tools:i})}async _generate(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new be({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,r,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let a of this.chunks){let s=new Xr({message:new at({content:a.content,tool_calls:a.tool_calls,additional_kwargs:a.additional_kwargs??{}}),text:a.content?.toString()??""});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(a.content,void 0,void 0,void 0,void 0,{chunk:s})}return}let i=this.responses?.[0]??new be(typeof t[0].content=="string"?t[0].content:""),o=typeof i.content=="string"?i.content:"";for(let a of o){await new Promise(c=>setTimeout(c,this.sleep));let s=new Xr({message:new at({content:a}),text:a});if(r.signal?.aborted)break;yield s,await n?.handleLLMNewToken(a,void 0,void 0,void 0,void 0,{chunk:s})}}},rL=class nL extends zi{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:n,emitCustomEvent:i,generationInfo:o}=t;this.responses=r,this.sleep=n,this.emitCustomEvent=i??this.emitCustomEvent,this.generationInfo=o}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,r,n){if(await this._sleepIfRequested(),r?.thrownErrorString)throw new Error(r.thrownErrorString);if(this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0}),r?.stop?.length)return{generations:[this._formatGeneration(r.stop[0])]};{let i=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(i)],llmOutput:{}}}}_formatGeneration(t){return{message:new be(t),text:t}}async*_streamResponseChunks(t,r,n){let i=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await n?.handleCustomEvent("some_test_event",{someval:!0});let o=[...i];for(let a=0;a<o.length;a++){let s=o[a],c=a===o.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,n?.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 Xr({message:new at({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],n=r.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:dt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:dt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:dt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:dt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:n}]:n,o=new nL({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return o.tools=r,o.toolStyle=this.toolStyle,o.i=this.i,o.withConfig({tools:i})}withStructuredOutput(t,r){return Zt.from(async n=>{let i=await this.invoke(n);if(i.tool_calls?.[0]?.args)return i.tool_calls[0].args;if(typeof i.content=="string")return JSON.parse(i.content);throw new Error("No structured output found")})}};var iL=class extends Fu{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,n=r===0?0:this.vectorSize-r,i=t.length+n;t=t.padEnd(i," ");let o=t.length/this.vectorSize,a=[];for(let s=0;s<t.length;s+=o)a.push(t.slice(s,s+o));return a.map(s=>{let c=0;for(let u=0;u<s.length;u+=1)c+=s===" "?0:s.charCodeAt(u);return c%26/26})}},oL=class extends Fu{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 aL=class extends y_{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 n=this.response??e;return await r?.handleLLMNewToken(n),n}},sL=class extends y_{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 n=this.responses?.[0];this.responses=this.responses?.slice(1);for(let i of n??e)await new Promise(o=>setTimeout(o,this.sleep)),yield{text:i,generationInfo:{}},await r?.handleLLMNewToken(i)}};var cL=class extends BS{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 st(e))}async addAIMessage(e){this.messages.push(new be(e))}async clear(){this.messages=[]}},uL=class extends n_{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},lL=class extends Jt{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}};var dL=class extends Gn{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}};var pL=class extends Up{lc_namespace=["test","fake"];output=[new rn({pageContent:"foo"}),new rn({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}};var fL=class extends pe{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}};var mL=class extends of{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 hL=class extends Jt{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 gL=class _L extends py{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:r,...n}={}){super(t,n),this.similarity=r??cy}async addDocuments(t){let r=t.map(({pageContent:n})=>n);return this.addVectors(await this.embeddings.embedDocuments(r),t)}async addVectors(t,r){let n=t.map((i,o)=>({content:r[o].pageContent,embedding:i,metadata:r[o].metadata}));this.memoryVectors=this.memoryVectors.concat(n)}async similaritySearchVectorWithScore(t,r,n){let i=a=>n?n(new rn({metadata:a.metadata,pageContent:a.content})):!0,o=this.memoryVectors.filter(i);return o.map((a,s)=>({similarity:this.similarity(t,a.embedding),index:s})).sort((a,s)=>a.similarity>s.similarity?-1:0).slice(0,r).map(a=>[new rn({metadata:o[a.index].metadata,pageContent:o[a.index].content}),a.similarity])}static async fromTexts(t,r,n,i){let o=[];for(let a=0;a<t.length;a+=1){let s=Array.isArray(r)?r[a]:r,c=new rn({pageContent:t[a],metadata:s});o.push(c)}return _L.fromDocuments(o,n,i)}static async fromDocuments(t,r,n){let i=new this(r,n);return await i.addDocuments(t),i}static async fromExistingIndex(t,r){return new this(t,r)}};var yL=P({FakeChatMessageHistory:()=>cL,FakeChatModel:()=>Q4,FakeEmbeddings:()=>oL,FakeLLM:()=>aL,FakeListChatMessageHistory:()=>uL,FakeListChatModel:()=>rL,FakeRetriever:()=>pL,FakeRunnable:()=>fL,FakeSplitIntoListParser:()=>dL,FakeStreamingChatModel:()=>eL,FakeStreamingLLM:()=>sL,FakeTool:()=>mL,FakeTracer:()=>lL,FakeVectorStore:()=>gL,SingleRunExtractor:()=>hL,SyntheticEmbeddings:()=>iL});var vL=P({agents:()=>IA,caches:()=>vO,callbacks__base:()=>TO,callbacks__manager:()=>sN,callbacks__promises:()=>iN,chat_history:()=>jj,document_loaders__base:()=>Lj,document_loaders__langsmith:()=>Uj,documents:()=>Dj,embeddings:()=>Fj,errors:()=>$A,example_selectors:()=>Jj,index:()=>xA,indexing:()=>Qj,language_models__base:()=>sz,language_models__chat_models:()=>Az,language_models__llms:()=>Oz,language_models__profile:()=>Cz,language_models__structured_output:()=>$z,load__serializable:()=>mA,memory:()=>Pz,messages:()=>Mj,messages__tool:()=>VA,output_parsers:()=>kz,output_parsers__openai_functions:()=>Mz,output_parsers__openai_tools:()=>jz,outputs:()=>SN,prompt_values:()=>ez,prompts:()=>Wz,retrievers:()=>Xz,retrievers__document_compressors:()=>Jz,runnables:()=>fz,runnables__graph:()=>lj,singletons:()=>fN,stores:()=>Yz,structured_query:()=>oD,testing:()=>lD,tools:()=>T4,tracers__base:()=>GR,tracers__console:()=>XR,tracers__log_stream:()=>IN,tracers__run_collector:()=>O4,tracers__tracer_langchain:()=>QR,types__stream:()=>C4,utils__async_caller:()=>AN,utils__chunk_array:()=>P4,utils__context:()=>R4,utils__env:()=>gA,utils__event_source_parse:()=>N4,utils__format:()=>D4,utils__function_calling:()=>L4,utils__hash:()=>SA,utils__json_patch:()=>mz,utils__json_schema:()=>nj,utils__math:()=>V4,utils__ssrf:()=>G4,utils__standard_schema:()=>ON,utils__stream:()=>mN,utils__testing:()=>yL,utils__tiktoken:()=>oz,utils__types:()=>Ez,vectorstores:()=>Y4});var xW=50;function IW(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,[n,i])=>(r[i]=n,r),{})}async function fy(e){let{optionalImportsMap:t,optionalImportEntrypoints:r,importMap:n,secretsMap:i,secretsFromEnv:o,path:a,depth:s,maxDepth:c}=this,u=a.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)=>fy.call({...this,path:[...a,`${p}`],depth:s+1},f)));let l=e;if(Jv(l))return lm(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[f]=l.id;if(f in i)return i[f];if(o){let p=et(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 p=JSON.stringify(l);throw new Error(`Trying to load an object that doesn't implement serialization: ${u} -> ${p}`)}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,...h]=f.id.slice().reverse(),w=h.reverse(),_={langchain_core:vL,langchain:n},y=null,x=[w.join("/")];w[0]==="langchain_community"&&x.push(["langchain",...w.slice(1)].join("/"));let S=x.find(C=>C in t);if(wA.concat(r).includes(w.join("/"))||S)if(S!==void 0)y=await t[S];else throw new Error(`Missing key "${w.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let C;if(w[0]==="langchain"||w[0]==="langchain_core")C=_[w[0]],w.shift();else throw new Error(`Invalid namespace: ${u} -> ${p}`);if(w.length===0)throw new Error(`Invalid namespace: ${u} -> ${p}`);let b;do{if(b=w.join("__"),b in C)break;w.pop()}while(w.length>0);b in C&&(y=C[b])}if(typeof y!="object"||y===null)throw new Error(`Invalid namespace: ${u} -> ${p}`);let $=y[m]??Object.values(y).find(C=>typeof C=="function"&&Bc(C)===m);if(typeof $!="function")throw new Error(`Invalid identifer: ${u} -> ${p}`);let j=new $(cm(await fy.call({...this,path:[...a,"kwargs"],depth:s+1},f.kwargs),lA,IW($)));return Object.defineProperty(j.constructor,"name",{value:m}),j}let d={};for(let[f,p]of Object.entries(l))d[f]=await fy.call({...this,path:[...a,f],depth:s+1},p);return d}async function bL(e,t){let r=JSON.parse(e),n={optionalImportsMap:t?.optionalImportsMap??{},optionalImportEntrypoints:t?.optionalImportEntrypoints??[],secretsMap:t?.secretsMap??{},secretsFromEnv:t?.secretsFromEnv??!1,importMap:t?.importMap??{},path:["$"],depth:0,maxDepth:t?.maxDepth??xW};return fy.call(n,r)}function SW(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function QE(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>QE(t)));{let t={};for(let[r,n]of Object.entries(e))t[r]=await QE(n);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],n;switch(r){case"Set":n=Set;break;case"Map":n=Map;break;case"RegExp":n=RegExp;break;case"Error":n=Error;break;case"Uint8Array":n=Uint8Array;break;default:return t}return t.method?n[t.method](...t.args||[]):new n(...t.args||[])}catch{return t}else if(SW(t))return bL(JSON.stringify(t));return t}}return e}function my(e,t,r,n){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:r??[],kwargs:n??{}}}function kW(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Set||e instanceof Map?my(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?my(RegExp,void 0,[e.source,e.flags]):e instanceof Error?my(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args}:e instanceof Uint8Array?my(Uint8Array,"from",[Array.from(e)]):e}var hy=class{_dumps(e){return new TextEncoder().encode(XT(e,(t,r)=>kW(r)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return QE(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 e$(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]=e$(e[r]));return t}function ol(){return{v:4,id:vd(-2),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function Kn(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:e$(e.versions_seen)}}var gy=class{serde=new hy;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 _y(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function sf(...e){return e.reduce((t,r,n)=>n===0?r:_y(t,r)>=0?t:r)}var cf={[Zv]:-1,[os]:-2,[Gv]:-3,[Hv]:-4};function t$(e){return e.configurable?.checkpoint_id||e.configurable?.thread_ts||""}function uf(e,t,r){return JSON.stringify([e,t,r])}function EW(e){let[t,r,n]=JSON.parse(e);return{threadId:t,checkpointNamespace:r,checkpointId:n}}var yy=class extends gy{storage={};writes={};constructor(e){super(e)}async _migratePendingSends(e,t,r,n){let i=e,o=uf(t,r,n),a=await Promise.all(Object.values(this.writes[o]??{}).filter(([s,c])=>c===bd).map(async([s,c,u])=>await this.serde.loadsTyped("json",u)));i.channel_values??={},i.channel_values[bd]=a,i.channel_versions??={},i.channel_versions[bd]=Object.keys(i.channel_versions).length>0?sf(...Object.values(i.channel_versions)):this.getNextVersion(void 0)}async getTuple(e){let t=e.configurable?.thread_id,r=e.configurable?.checkpoint_ns??"",n=t$(e);if(n){let i=this.storage[t]?.[r]?.[n];if(i!==void 0){let[o,a,s]=i,c=uf(t,r,n),u=await this.serde.loadsTyped("json",o);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",a),pendingWrites:l};return s!==void 0&&(d.parentConfig={configurable:{thread_id:t,checkpoint_ns:r,checkpoint_id:s}}),d}}else{let i=this.storage[t]?.[r];if(i!==void 0){n=Object.keys(i).sort((f,p)=>p.localeCompare(f))[0];let[o,a,s]=i[n],c=uf(t,r,n),u=await this.serde.loadsTyped("json",o);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:n,checkpoint_ns:r}},checkpoint:u,metadata:await this.serde.loadsTyped("json",a),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:n,filter:i}=t??{},o=e.configurable?.thread_id?[e.configurable?.thread_id]:Object.keys(this.storage),a=e.configurable?.checkpoint_ns,s=e.configurable?.checkpoint_id;for(let c of o)for(let u of Object.keys(this.storage[c]??{})){if(a!==void 0&&u!==a)continue;let l=this.storage[c]?.[u]??{},d=Object.entries(l).sort((f,p)=>p[0].localeCompare(f[0]));for(let[f,[p,m,h]]of d){if(s&&f!==s||r&&r.configurable?.checkpoint_id&&f>=r.configurable.checkpoint_id)continue;let w=await this.serde.loadsTyped("json",m);if(i&&!Object.entries(i).every(([j,C])=>w[j]===C))continue;if(n!==void 0){if(n<=0)break;n-=1}let _=uf(c,u,f),y=Object.values(this.writes[_]||{}),x=await Promise.all(y.map(async([j,C,b])=>[j,C,await this.serde.loadsTyped("json",b)])),S=await this.serde.loadsTyped("json",p);S.v<4&&h!==void 0&&await this._migratePendingSends(S,c,u,h);let $={config:{configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:f}},checkpoint:S,metadata:w,pendingWrites:x};h!==void 0&&($.parentConfig={configurable:{thread_id:c,checkpoint_ns:u,checkpoint_id:h}}),yield $}}}async put(e,t,r){let n=Kn(t),i=e.configurable?.thread_id,o=e.configurable?.checkpoint_ns??"";if(i===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[i]||(this.storage[i]={}),this.storage[i][o]||(this.storage[i][o]={});let[[,a],[,s]]=await Promise.all([this.serde.dumpsTyped(n),this.serde.dumpsTyped(r)]);return this.storage[i][o][t.id]=[a,s,e.configurable?.checkpoint_id],{configurable:{thread_id:i,checkpoint_ns:o,checkpoint_id:t.id}}}async putWrites(e,t,r){let n=e.configurable?.thread_id,i=e.configurable?.checkpoint_ns,o=e.configurable?.checkpoint_id;if(n===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property');if(o===void 0)throw new Error('Failed to put writes. The passed RunnableConfig is missing a required "checkpoint_id" field in its "configurable" property.');let a=uf(n,i,o),s=this.writes[a];this.writes[a]===void 0&&(this.writes[a]={}),await Promise.all(t.map(async([c,u],l)=>{let[,d]=await this.serde.dumpsTyped(u),f=[r,cf[c]||l],p=`${f[0]},${f[1]}`;f[1]>=0&&s&&p in s||(this.writes[a][p]=[r,c,d])}))}async deleteThread(e){delete this.storage[e];for(let t of Object.keys(this.writes))EW(t).threadId===e&&delete this.writes[t]}};var al=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function $W(e){if(e.length===0)throw new al("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new al(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new al(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new al(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new al(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var lf=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:r,limit:n=10,offset:i=0,query:o}=t;return(await this.batch([{namespacePrefix:e,filter:r,limit:n,offset:i,query:o}]))[0]}async put(e,t,r,n){$W(e),await this.batch([{namespace:e,key:t,value:r,index:n}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:r,maxDepth:n,limit:i=100,offset:o=0}=e,a=[];return t&&a.push({matchType:"prefix",path:t}),r&&a.push({matchType:"suffix",path:r}),(await this.batch([{matchConditions:a.length?a:void 0,maxDepth:n,limit:i,offset:o}]))[0]}start(){}stop(){}};var TW=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,vy=class extends lf{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=TW(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:n=10,offset:i=0,query:o}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:r,limit:n,offset:i,query:o})}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 n=this.nextKey;this.nextKey+=1,this.queue.set(n,{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:n})=>n),r=await this.store.batch(t);e.forEach(({resolve:n},i)=>{n(r[Array.from(e.keys()).indexOf(i)])})}catch(t){e.forEach(({reject:r})=>{r(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}};var by=class{serde=new hy;constructor(e){this.serde=e||this.serde}};function n$(e){return e!=null&&e.lg_is_channel===!0}var Gt=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===Ve.unminifiable_name)return!1;throw e}}equals(e){return this===e}},r$=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function df(e){if(e[r$]===!0)return e;let t={};for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=e[r];n$(n)&&(t[r]=n)}return Object.assign(t,{[r$]:!0}),t}function $a(e,t){let r=df(e),n={};for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let o=t.channel_values[i];n[i]=r[i].fromCheckpoint(o)}return Object.assign(n,{[r$]:!0}),n}function Wn(e,t,r,n){let i;if(t===void 0)i=e.channel_values;else{i={};for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))try{i[o]=t[o].checkpoint()}catch(a){if(a.name!==Ve.unminifiable_name)throw a}}return{v:4,id:n?.id??vd(r),ts:new Date().toISOString(),channel_values:i,channel_versions:e.channel_versions,versions_seen:e.versions_seen}}var OW=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",ko=class wL extends Gt{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 wL(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 i=r[0],[o,a]=Yf(i);o?this.value=a:this.value=i,r=r.slice(1)}let n=!1;for(let i of r)if(BT(i)){if(n)throw new Re("Can receive only one Overwrite value per step.");let[,o]=Yf(i);this.value=o,n=!0;continue}else!n&&this.value!==void 0&&(this.value=this.operator(this.value,i));return!0}get(){if(this.value===void 0)throw new Ve;return this.value}checkpoint(){if(this.value===void 0)throw new Ve;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:OW(t)?this.operator===t.operator:!1}};var Jn=class xL extends Gt{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let r=new xL(this.initialValueFactory);return typeof t<"u"&&(r.value=[t]),r}update(t){if(t.length===0)return!1;if(t.length!==1)throw new Re("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 Ve;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ve;return this.value[0]}isAvailable(){return this.value.length!==0}},i$=class IL extends Gt{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let r=new IL;if(typeof t<"u"){let[n,i]=t;r.value=[n],r.finished=i}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 Ve;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 wy=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"}},Xn=function(e){return e?xy(e):new Jn};Xn.Root=e=>new wy(e);function xy(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new ko(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new ko(e.value,e.default):new Jn}var CW=["tags","metadata","callbacks","configurable"],PW=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal"],RW=25;function pf(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:RW,configurable:{}},r=He.getRunnableConfig();if(r!==void 0){for(let[n,i]of Object.entries(r))if(i!==void 0)if(CW.includes(n)){let o;Array.isArray(i)?o=[...i]:typeof i=="object"?n==="callbacks"&&"copy"in i&&typeof i.copy=="function"?o=i.copy():o={...i}:o=i,t[n]=o}else t[n]=i}for(let n of e)if(n!==void 0)for(let[i,o]of Object.entries(n))o!==void 0&&PW.includes(i)&&(t[i]=o);for(let[n,i]of Object.entries(t.configurable))t.metadata=t.metadata??{},!n.startsWith("__")&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&!(n in t.metadata)&&(t.metadata[n]=i);return t}function SL(){return He.getRunnableConfig()}function Iy(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function kL(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var ur=class extends pe{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((n,i)=>{let o=Me(t,{callbacks:r?.getChild()});He.runWithConfig(o,async()=>{try{n(await this.func(e,o))}catch(a){i(a)}})})}async invoke(e,t){let r,n=pf(t),i=Bt(this.config,n);return this.trace?r=await this._callWithConfig(this._tracedInvoke,e,i):r=await He.runWithConfig(i,async()=>this.func(e,i)),pe.isRunnable(r)&&this.recurse?await He.runWithConfig(i,async()=>r.invoke(e,i)):r}};function*Eo(e,t){if(t===void 0)yield*e;else for(let r of e)yield[t,r]}async function Yn(e){let t=[];for await(let r of await e)t.push(r);return t}function Qs(e){let t=[];for(let r of e)t.push(r);return t}function ec(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function EL(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(async function*(){}).constructor}function $L(e){return e!=null&&typeof e=="function"&&e instanceof Object.getPrototypeOf(function*(){}).constructor}function NW(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var Lr={[Symbol.for("LG_PASSTHROUGH")]:!0};function Sy(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var o$=Symbol("IS_WRITER"),wt=class s$ extends ur{writes;constructor(t,r){let n=`ChannelWrite<${t.map(i=>At(i)?i.node:"channel"in i?i.channel:"...").join(",")}>`;super({writes:t,name:n,tags:r,trace:!1,func:async(i,o)=>this._write(i,o??{})}),this.writes=t}async _write(t,r){let n=this.writes.map(i=>a$(i)&&Sy(i.value)?{mapper:i.mapper,value:t}:ky(i)&&Sy(i.value)?{channel:i.channel,value:t,skipNone:i.skipNone,mapper:i.mapper}:i);return await s$.doWrite(r,n),t}static async doWrite(t,r){for(let o of r){if(ky(o)){if(o.channel==="__pregel_tasks")throw new Re("Cannot write to the reserved channel TASKS");if(Sy(o.value))throw new Re("PASSTHROUGH value must be replaced")}if(a$(o)&&Sy(o.value))throw new Re("PASSTHROUGH value must be replaced")}let n=[];for(let o of r)if(At(o))n.push([pi,o]);else if(a$(o)){let a=await o.mapper.invoke(o.value,t);a!=null&&a.length>0&&n.push(...a)}else if(ky(o)){let a=o.mapper!==void 0?await o.mapper.invoke(o.value,t):o.value;if(NW(a)||o.skipNone&&a===void 0)continue;n.push([o.channel,a])}else throw new Error(`Invalid write entry: ${JSON.stringify(o)}`);let i=t.configurable?.[cn];i(n)}static isWriter(t){return t instanceof s$||o$ in t&&!!t[o$]}static registerWriter(t){return Object.defineProperty(t,o$,{value:!0})}};function ky(e){return e!==void 0&&typeof e.channel=="string"}function a$(e){return e!==void 0&&!ky(e)&&pe.isRunnable(e.mapper)}var TL=class AL extends ur{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,r,n=!1){super({trace:!1,func:(i,o)=>AL.doRead(o,this.channel,this.fresh,this.mapper)}),this.fresh=n,this.mapper=r,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,r,n,i){let o=t.configurable?.[On];if(!o)throw new Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");return i?i(o(r,n)):o(r,n)}},sl=new bo,Qn=class ff extends Sn{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=sl;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor(t){let{channels:r,triggers:n,mapper:i,writers:o,bound:a,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??sl,config:{...t.config?t.config:{},tags:m}}),this.channels=r,this.triggers=n,this.mapper=i,this.writers=o??this.writers,this.bound=a??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 wt&&t[t.length-2]instanceof wt;){let r=t.slice(-2),n=r[0].writes.concat(r[1].writes);t[t.length-2]=new wt(n,r[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===sl&&t.length===0))return this.bound===sl&&t.length===1?t[0]:this.bound===sl?new tn({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new tn({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 ff({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 wt.isWriter(t)?new ff({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===sl?new ff({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:yt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):new ff({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 MW(e){return"steps"in e&&Array.isArray(e.steps)}function mf(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function Ey(e){let t=[e];for(let r of t){if(mf(r))return r;MW(r)&&t.push(...r.steps)}}var K=e=>BigInt(e),Xe=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),RL=K("0x9E3779B1"),NL=K("0x85EBCA77"),jW=K("0xC2B2AE3D"),Ta=K("0x9E3779B185EBCA87"),tc=K("0xC2B2AE3D27D4EB4F"),ML=K("0x165667B19E3779F9"),l$=K("0x85EBCA77C2B2AE63"),zW=K("0x27D4EB2F165667C5"),DW=K("0x165667919E3779F9"),LW=K("0x9FB21C651E98DF25"),UW=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let r=t/2,n=new Uint8Array(r),i=0,o=0;for(;o<r;){let a=e.slice(i,i+=2);n[o]=Number.parseInt(a,16),o+=1}return Xe(n)},Ui=UW("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),cl=(K(1)<<K(128))-K(1),Pe=(K(1)<<K(64))-K(1),Oy=(K(1)<<K(32))-K(1),$o=64,jL=$o/8,FW=8,$y=4;function ul(e){if(!e)throw new Error("Assert failed")}function BW(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function VW(e){let t=e;return t=(t&K(65535))<<K(16)|(t&K(4294901760))>>K(16),t=(t&K(16711935))<<K(8)|(t&K(4278255360))>>K(8),t}function ZW(e,t){return(e&Oy)*(t&Oy)&Pe}function GW(e,t){return(e<<t|e>>K(32)-t)&Oy}function zL(e,t,r){for(let n=0;n<jL;n+=1){let i=t.getBigUint64(n*8,!0),o=i^r.getBigUint64(n*8,!0);e[n^1]+=i,e[n]+=ZW(o,o>>K(32))}return e}function OL(e,t,r,n){for(let i=0;i<n;i+=1)zL(e,Xe(t,i*$o),Xe(r,i*8));return e}function HW(e,t){for(let r=0;r<jL;r+=1){let n=t.getBigUint64(r*8,!0),i=e[r];i=c$(i,K(47)),i^=n,i*=RL,e[r]=i&Pe}return e}function Ty(e,t){return DL(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(FW,!0))}function CL(e,t,r){let n=r;return n+=Ty(e.slice(0),Xe(t,0*$y)),n+=Ty(e.slice(2),Xe(t,4*$y)),n+=Ty(e.slice(4),Xe(t,8*$y)),n+=Ty(e.slice(6),Xe(t,12*$y)),Fi(n&Pe)}function qW(e,t,r,n,i){let o=e,a=Math.floor((r.byteLength-$o)/8),s=$o*a,c=Math.floor((t.byteLength-1)/s);for(let u=0;u<c;u+=1)o=OL(o,Xe(t,u*s),r,a),o=i(o,Xe(r,r.byteLength-$o));{let u=Math.floor((t.byteLength-1-s*c)/$o);o=OL(o,Xe(t,c*s),r,u),o=n(o,Xe(t,t.byteLength-$o),Xe(r,r.byteLength-$o-7))}return o}function KW(e,t){let r=new BigUint64Array([jW,Ta,tc,ML,l$,NL,zW,RL]);ul(e.byteLength>128),r=qW(r,e,t,zL,HW),ul(r.length*8===64);{let n=CL(r,Xe(t,11),K(e.byteLength)*Ta&Pe);return CL(r,Xe(t,t.byteLength-$o-11),~(K(e.byteLength)*tc)&Pe)<<K(64)|n}}function DL(e,t){let r=e*t&cl;return r&Pe^r>>K(64)}function PL(e,t,r){return DL((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+r)&Pe,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-r)&Pe)}function Ay(e,t,r,n,i){let o=e&Pe,a=e>>K(64)&Pe;return o+=PL(t,n,i),o^=r.getBigUint64(0,!0)+r.getBigUint64(8,!0),o&=Pe,a+=PL(r,Xe(n,16),i),a^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),a&=Pe,a<<K(64)|o}function Fi(e){let t=e;return t^=t>>K(37),t*=DW,t&=Pe,t^=t>>K(32),t}function Cy(e){let t=e;return t^=t>>K(33),t*=tc,t&=Pe,t^=t>>K(29),t*=ML,t&=Pe,t^=t>>K(32),t}function WW(e,t,r){let n=e.byteLength;ul(n>0&&n<=3);let i=K(e.getUint8(n-1))|K(n<<8)|K(e.getUint8(0)<<16)|K(e.getUint8(n>>1)<<24),o=(i^(K(t.getUint32(0,!0))^K(t.getUint32(4,!0)))+r)&Pe,a=(K(t.getUint32(8,!0))^K(t.getUint32(12,!0)))-r;return(Cy((GW(VW(i),K(13))^a)&Pe)&Pe)<<K(64)|Cy(o)}function c$(e,t){return e^e>>t}function JW(e,t,r){let n=e.byteLength;ul(n>=4&&n<=8);{let i=e.getUint32(0,!0),o=e.getUint32(n-4,!0),a=((K(i)|K(o)<<K(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+r&Pe)*(Ta+(K(n)<<K(2)))&cl;return a+=(a&Pe)<<K(65),a&=cl,a^=a>>K(67),c$(c$(a&Pe,K(35))*LW&Pe,K(28))|Fi(a>>K(64))<<K(64)}}function XW(e,t,r){let n=e.byteLength;ul(n>=9&&n<=16);{let i=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+r&Pe,o=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-r&Pe,a=e.getBigUint64(0,!0),s=e.getBigUint64(n-8,!0),c=(a^s^i)*Ta,u=(c&Pe)+(K(n-1)<<K(54));c=c&(cl^Pe)|u,s^=o,c+=s+(s&Oy)*(NL-K(1))<<K(64),c&=cl,c^=BW(c>>K(64));let l=(c&Pe)*tc;return l+=(c>>K(64))*tc<<K(64),l&=cl,Fi(l&Pe)|Fi(l>>K(64))<<K(64)}}function YW(e,t){let r=e.byteLength;return ul(r<=16),r>8?XW(e,Ui,t):r>=4?JW(e,Ui,t):r>0?WW(e,Ui,t):Cy(t^Ui.getBigUint64(64,!0)^Ui.getBigUint64(72,!0))|Cy(t^Ui.getBigUint64(80,!0)^Ui.getBigUint64(88,!0))<<K(64)}function u$(e){return~e+K(1)&Pe}function QW(e,t,r){let n=K(e.byteLength)*Ta&Pe,i=K(e.byteLength-1)/K(32);for(;i>=0;){let s=Number(i);n=Ay(n,Xe(e,16*s),Xe(e,e.byteLength-16*(s+1)),Xe(t,32*s),r),i-=K(1)}let o=n+(n>>K(64))&Pe;o=Fi(o);let a=(n&Pe)*Ta+(n>>K(64))*l$+(K(e.byteLength)-r&Pe)*tc;return a&=Pe,a=u$(Fi(a)),o|a<<K(64)}function eJ(e,t,r){let n=K(e.byteLength)*Ta&Pe;for(let a=32;a<160;a+=32)n=Ay(n,Xe(e,a-32),Xe(e,a-16),Xe(t,a-32),r);n=Fi(n&Pe)|Fi(n>>K(64))<<K(64);for(let a=160;a<=e.byteLength;a+=32)n=Ay(n,Xe(e,a-32),Xe(e,a-16),Xe(t,3+a-160),r);n=Ay(n,Xe(e,e.byteLength-16),Xe(e,e.byteLength-32),Xe(t,103),u$(r));let i=n+(n>>K(64))&Pe;i=Fi(i);let o=(n&Pe)*Ta+(n>>K(64))*l$+(K(e.byteLength)-r&Pe)*tc;return o&=Pe,o=u$(Fi(o)),i|o<<K(64)}function To(e,t=K(0)){let r=new TextEncoder,n=Xe(typeof e=="string"?r.encode(e):e),i=n.byteLength,o=a=>a.toString(16).padStart(32,"0");return i<=16?o(YW(n,t)):i<=128?o(QW(n,Ui,t)):i<=240?o(eJ(n,Ui,t)):o(KW(n,Ui))}function Py(e){return/^[0-9a-f]{32}$/.test(e)}function rc(e,t,r=!0,n=!1){try{return e[t].get()}catch(i){if(i.name===Ve.unminifiable_name){if(n)return i;if(r)return null}throw i}}function ei(e,t,r=!0){if(Array.isArray(t)){let n={};for(let i of t)try{n[i]=rc(e,i,!r)}catch(o){if(o.name===Ve.unminifiable_name)continue}return n}else return rc(e,t)}function*LL(e,t){if(e.graph===Ar.PARENT)throw new Re("There is no parent graph.");if(e.goto){let r;Array.isArray(e.goto)?r=e.goto:r=[e.goto];for(let n of r)if(At(n))yield[Zr,pi,n];else if(typeof n=="string")yield[Zr,`branch:to:${n}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof n}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(Py))for(let[r,n]of Object.entries(e.resume)){let i=t.filter(o=>o[0]===r&&o[1]==="__resume__").map(o=>o[2]).slice(0,1)??[];i.push(n),yield[r,Vr,i]}else yield[Zr,Vr,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,n]of e.update)yield[Zr,r,n];else for(let[r,n]of Object.entries(e.update))yield[Zr,r,n]}}function*Ry(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*Ny(e,t,r){Array.isArray(e)?(t===!0||t.find(([n,i])=>e.includes(n)))&&(yield ei(r,e)):(t===!0||t.some(([n,i])=>n===e))&&(yield rc(r,e))}function*UL(e,t,r){let n=t.filter(([s,c])=>(s.config===void 0||!s.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!n.length)return;let i;n.some(([s])=>s.writes.some(([c,u])=>c==="__return__"))?i=n.flatMap(([s])=>s.writes.filter(([c,u])=>c===Ko).map(([c,u])=>[s.name,u])):Array.isArray(e)?i=n.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)))]]}):i=n.flatMap(([s])=>s.writes.filter(([c,u])=>c===e).map(([c,u])=>[s.name,u]));let o={};for(let[s,c]of i)s in o||(o[s]=[]),o[s].push(c);let a={};for(let s in o)if(o[s].length===1){let[c]=o[s];a[s]=c}else a[s]=o[s];r&&(a.__metadata__={cached:r}),yield a}function My(e){let t=typeof e[Ye];if(t==="number")return 0;if(t==="string")return"";for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let n=typeof e[r];if(n==="number")return 0;if(n==="string")return"";break}}function ll(e,t){if(Object.keys(e).length>0){let r=My(t);return Object.fromEntries(Object.entries(t).filter(([n,i])=>i>(e[n]??r)))}else return t}function FL(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function Ur(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function Aa(e,t){let r=t?.parents??{};return Object.keys(r).length>0?Ur(e,{[ln]:{...r,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function dl(...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};if(typeof AbortSignal.any=="function")return{signal:AbortSignal.any(t),dispose:void 0};let r=new AbortController,n=()=>{let o=t.find(a=>a.aborted)?.reason;r.abort(o),t.forEach(a=>a.removeEventListener("abort",n))};t.forEach(o=>o.addEventListener("abort",n,{once:!0}));let i=t.find(o=>o.aborted);return i&&r.abort(i.reason),{signal:r.signal,dispose:()=>{t.forEach(o=>o.removeEventListener("abort",n))}}}var BL=(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 VL=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:e,name:t,input:r,retry:n,cache:i,callbacks:o}){this.func=e,this.name=t,this.input=r,this.retry=n,this.cache=i,this.callbacks=o}};function ZL(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function GL(e,t){return new tn({name:e,first:new ur({func:r=>t(...r),name:e,trace:!1,recurse:!1}),last:new wt([{channel:Ko,value:Lr}],[Tt])})}function HL(e,t){return new ur({func:(r,n)=>t(r,n),name:e,trace:!1,recurse:!1})}var qL=e=>e!==void 0?e+1:1;function tJ(e,t){if(t==null)return!1;for(let r of e)if(t[r])return!0;return!1}function rJ(e){let t;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t==null?t=e[r]:t=sf(t,e[r]));return t}function gf(e,t,r){let n=My(e.channel_versions),i=e.versions_seen.__interrupt__??{},o=!1;if((e.channel_versions.__start__??n)>(i.__start__??n))o=!0;else for(let s in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,s)&&e.channel_versions[s]>(i[s]??n)){o=!0;break}let a=r.some(s=>t==="*"?!s.config?.tags?.includes(Tt):t.includes(s.name));return o&&a}function hf(e,t,r,n,i=!1){let o=new Set;if(Array.isArray(n))o=new Set(n.filter(s=>r.writes.some(([c,u])=>c===s)));else{for(let[s]of r.writes)if(s===n){o=new Set([s]);break}o=o||new Set}let a;if(i&&o.size>0){let s=Object.fromEntries(Object.entries(t).filter(([l,d])=>o.has(l))),c=Wn(e,s,-1),u=$a(s,c);Er(Kn(c),u,[r],void 0,void 0),a=ei({...t,...u},n)}else a=ei(t,n);return a}function d$(e,t,r){for(let[n,i]of r)if(["__pregel_push","__pregel_tasks"].includes(n)&&i!=null){if(!At(i))throw new Re(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(i)}`);if(!(i.node in t))throw new Re(`Invalid node name "${i.node}" in Send packet`)}e(r)}var nJ=new Set([md,dn,Vr,ot,Ko,jc]);function Er(e,t,r,n,i){r.sort((f,p)=>{let m=f.path?.slice(0,3)||[],h=p.path?.slice(0,3)||[];for(let w=0;w<Math.min(m.length,h.length);w+=1){if(m[w]<h[w])return-1;if(m[w]>h[w])return 1}return m.length-h.length});let o=r.some(f=>f.triggers.length>0),a=df(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=rJ(e.channel_versions),c=new Set(r.flatMap(f=>f.triggers).filter(f=>!UT.includes(f))),u=!1;for(let f of c)f in a&&a[f].consume()&&n!==void 0&&(e.channel_versions[f]=n(s),u=!0);let l={};for(let f of r)for(let[p,m]of f.writes)nJ.has(p)||p in a&&(l[p]??=[],l[p].push(m));s!=null&&n!=null&&(s=u?n(s):s);let d=new Set;for(let[f,p]of Object.entries(l))if(f in a){let m=a[f],h;try{h=m.update(p)}catch(w){if(w.name===Re.unminifiable_name){let _=new Re(`Invalid update for channel "${f}" with values ${JSON.stringify(p)}: ${w.message}`);throw _.lc_error_code=w.lc_error_code,_}else throw w}h&&n!==void 0&&(e.channel_versions[f]=n(s),m.isAvailable()&&d.add(f))}if(o)for(let f in a){if(!Object.prototype.hasOwnProperty.call(a,f))continue;let p=a[f];p.isAvailable()&&!d.has(f)&&p.update([])&&n!==void 0&&(e.channel_versions[f]=n(s),p.isAvailable()&&d.add(f))}if(o&&!tJ(d,i))for(let f in a){if(!Object.prototype.hasOwnProperty.call(a,f))continue;let p=a[f];p.finish()&&n!==void 0&&(e.channel_versions[f]=n(s),p.isAvailable()&&d.add(f))}return d}function*iJ(e,t,r){if(r.updatedChannels!=null&&r.triggerToNodes!=null){let n=new Set;for(let i of r.updatedChannels){let o=r.triggerToNodes[i];for(let a of o??[])n.add(a)}yield*[...n].sort();return}if(!(()=>{for(let n in e.channel_versions)if(e.channel_versions[n]!==null)return!1;return!0})())for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(yield n)}function Oa(e,t,r,n,i,o,a){let s={},c=n[pi];if(c?.isAvailable()){let u=c.get().length;for(let l=0;l<u;l+=1){let d=jy([dn,l],e,t,r,n,i,o,a);d!==void 0&&(s[d.id]=d)}}for(let u of iJ(e,r,a)){let l=jy([Jf,u],e,t,r,n,i,o,a);l!==void 0&&(s[l.id]=l)}return s}function jy(e,t,r,n,i,o,a,s){let{step:c,checkpointer:u,manager:l}=s,d=o.configurable??{},f=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&ZL(e[e.length-1])){let p=e[e.length-1],m=GL(p.name,p.func),h=[dn],w=f===""?p.name:`${f}|${p.name}`,_=no(JSON.stringify([w,c.toString(),p.name,dn,e[1],e[2]]),t.id),y=`${w}:${_}`,x=[...e.slice(0,3),!0],S={langgraph_step:c,langgraph_node:p.name,langgraph_triggers:h,langgraph_path:x,langgraph_checkpoint_ns:y};if(a){let $=[];return{name:p.name,input:p.input,proc:m,writes:$,config:Me(Bt(o,{metadata:S,store:s.store??o.store}),{runName:p.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pd]:_,[cn]:j=>d$(C=>$.push(...C),n,j),[On]:(j,C=!1)=>hf(t,i,{name:p.name,writes:$,triggers:h,path:x},j,C),[Cn]:u??d.__pregel_checkpointer,[ln]:{...d[ln],[f]:t.id},[Br]:p$({pendingWrites:r??[],taskId:_,currentTaskInput:p.input,resumeMap:o.configurable?.[Dc],namespaceHash:To(y)}),[Lc]:t.channel_values[ts],checkpoint_id:void 0,checkpoint_ns:y}}),triggers:h,retry_policy:p.retry,cache_key:p.cache?{key:To((p.cache.keyFunc??JSON.stringify)([p.input])),ns:[Kf,p.name??"__dynamic__"],ttl:p.cache.ttl}:void 0,id:_,path:x,writers:[]}}else return{id:_,name:p.name,interrupts:[],path:x}}else if(e[0]==="__pregel_push"){let p=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!i.__pregel_tasks?.isAvailable())return;let m=i[pi].get();if(p<0||p>=m.length)return;let h=Xf(m[p])&&!At(m[p])?new es(m[p].node,m[p].args):m[p];if(!Xf(h)){console.warn(`Ignoring invalid packet ${JSON.stringify(h)} in pending sends.`);return}if(!(h.node in n)){console.warn(`Ignoring unknown node name ${h.node} in pending sends.`);return}let w=[dn],_=f===""?h.node:`${f}|${h.node}`,y=no(JSON.stringify([_,c.toString(),h.node,dn,p.toString()]),t.id),x=`${_}:${y}`,S={langgraph_step:c,langgraph_node:h.node,langgraph_triggers:w,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:x};if(a){let $=n[h.node],j=$.getNode();if(j!==void 0){$.metadata!==void 0&&(S={...S,...$.metadata});let C=[];return{name:h.node,input:h.args,proc:j,subgraphs:$.subgraphs,writes:C,config:Me(Bt(o,{metadata:S,tags:$.tags,store:s.store??o.store}),{runName:h.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pd]:y,[cn]:b=>d$(H=>C.push(...H),n,b),[On]:(b,H=!1)=>hf(t,i,{name:h.node,writes:C,triggers:w,path:e},b,H),[Cn]:u??d.__pregel_checkpointer,[ln]:{...d[ln],[f]:t.id},[Br]:p$({pendingWrites:r??[],taskId:y,currentTaskInput:h.args,resumeMap:o.configurable?.[Dc],namespaceHash:To(x)}),[Lc]:t.channel_values[ts],checkpoint_id:void 0,checkpoint_ns:x}}),triggers:w,retry_policy:$.retryPolicy,cache_key:$.cachePolicy?{key:To(($.cachePolicy.keyFunc??JSON.stringify)([h.args])),ns:[Kf,$.name??"__dynamic__",h.node],ttl:$.cachePolicy.ttl}:void 0,id:y,path:e,writers:$.getWriters()}}}else return{id:y,name:h.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let p=e[1].toString(),m=n[p];if(m===void 0)return;if(r?.length){let y=f===""?p:`${f}|${p}`,x=no(JSON.stringify([y,c.toString(),p,Jf,p]),t.id);if(r.some(S=>S[0]===x&&S[1]!=="__error__"))return}let h=My(t.channel_versions);if(h===void 0)return;let w=t.versions_seen[p]??{},_=m.triggers.find(y=>i[y].isAvailable()?(t.channel_versions[y]??h)>(w[y]??h):!1);if(_!==void 0){let y=oJ(m,i,a);if(y===void 0)return;let x=f===""?p:`${f}|${p}`,S=no(JSON.stringify([x,c.toString(),p,Jf,[_]]),t.id),$=`${x}:${S}`,j={langgraph_step:c,langgraph_node:p,langgraph_triggers:[_],langgraph_path:e,langgraph_checkpoint_ns:$};if(a){let C=m.getNode();if(C!==void 0){m.metadata!==void 0&&(j={...j,...m.metadata});let b=[];return{name:p,input:y,proc:C,subgraphs:m.subgraphs,writes:b,config:Me(Bt(o,{metadata:j,tags:m.tags,store:s.store??o.store}),{runName:p,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[pd]:S,[cn]:H=>d$(R=>{b.push(...R)},n,H),[On]:(H,R=!1)=>hf(t,i,{name:p,writes:b,triggers:[_],path:e},H,R),[Cn]:u??d.__pregel_checkpointer,[ln]:{...d[ln],[f]:t.id},[Br]:p$({pendingWrites:r??[],taskId:S,currentTaskInput:y,resumeMap:o.configurable?.[Dc],namespaceHash:To($)}),[Lc]:t.channel_values[ts],checkpoint_id:void 0,checkpoint_ns:$}}),triggers:[_],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:To((m.cachePolicy.keyFunc??JSON.stringify)([y])),ns:[Kf,m.name??"__dynamic__",p],ttl:m.cachePolicy.ttl}:void 0,id:S,path:e,writers:m.getWriters()}}}else return{id:S,name:p,interrupts:[],path:e}}}}function oJ(e,t,r){let n;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){n={};for(let[i,o]of Object.entries(e.channels))if(e.triggers.includes(o))try{n[i]=rc(t,o,!1)}catch(a){if(a.name===Ve.unminifiable_name)return;throw a}else if(o in t)try{n[i]=rc(t,o,!1)}catch(a){if(a.name===Ve.unminifiable_name)continue;throw a}}else if(Array.isArray(e.channels)){let i=!1;for(let o of e.channels)try{n=rc(t,o,!1),i=!0;break}catch(a){if(a.name===Ve.unminifiable_name)continue;throw a}if(!i)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return r&&e.mapper!==void 0&&(n=e.mapper(n)),n}function KL(e,t){if(typeof e.args!="object"||e.args===null)return e;let r={};for(let[n,i]of Object.entries(e.args)){let o=t[n];(!o||o.lc_graph_name!=="UntrackedValue")&&(r[n]=i)}return new es(e.node,r)}function p$({pendingWrites:e,taskId:t,currentTaskInput:r,resumeMap:n,namespaceHash:i}){let o=e.find(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__")?.[2],a={callCounter:0,interruptCounter:-1,resume:(()=>{let s=e.filter(([c,u])=>c===t&&u==="__resume__").flatMap(([c,u,l])=>l);if(n!=null&&i in n){let c=n[i];s.push(c)}return s})(),nullResume:o,subgraphCounter:0,currentTaskInput:r,consumeNullResume:()=>{if(a.nullResume)return delete a.nullResume,e.splice(e.findIndex(([s,c])=>s==="00000000-0000-0000-0000-000000000000"&&c==="__resume__"),1),o}};return a}var _f={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},yf=(e,t)=>`${e.start}${t}${e.end}`;function*f$(e){for(let{id:t,name:r,input:n,config:i,triggers:o,writes:a}of e)i?.tags?.includes("langsmith:hidden")||(yield{id:t,name:r,input:n,triggers:o,interrupts:a.filter(([s,c])=>s===t&&c==="__interrupt__").map(([,s])=>s)})}function aJ(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function WL(e){let t={};for(let[r,n]of e){let i=String(r);if(i in t){let o=aJ(t[i])?t[i].$writes:[t[i]];o.push(n),t[i]={$writes:o}}else t[i]=n}return t}function*JL(e,t){for(let[{id:r,name:n,config:i},o]of e)i?.tags?.includes("langsmith:hidden")||(yield{id:r,name:n,result:WL(o.filter(([a])=>Array.isArray(t)?t.includes(a):a===t)),interrupts:o.filter(a=>a[0]===ot).map(a=>a[1])})}function*XL(e,t,r,n,i,o,a,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 i){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(Ey))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:ei(t,r),metadata:n,next:i.map(d=>d.name),tasks:m$(i,o,l,s),parentConfig:a?c(a):void 0}}function m$(e,t,r,n){return e.map(i=>{let o=t.find(([u,l])=>u===i.id&&l==="__error__")?.[2],a=t.filter(([u,l])=>u===i.id&&l==="__interrupt__").map(([,,u])=>u),s=(()=>{if(o||a.length||!t.length)return;let u=t.findIndex(([l,d])=>l===i.id&&d==="__return__");if(u>=0)return t[u][2];if(typeof n=="string")return t.find(([l,d])=>l===i.id&&d===n)?.[2];if(Array.isArray(n)){let l=t.filter(([d,f])=>d===i.id&&n.includes(f)).map(([,d,f])=>[d,f]);return l.length?WL(l):void 0}})();if(o)return{id:i.id,name:i.name,path:i.path,error:o,interrupts:a,result:s};let c=r?.[i.id];return{id:i.id,name:i.name,path:i.path,interrupts:a,...c!==void 0?{state:c}:{},result:s}})}function YL(e,t,r){console.log([`${yf(_f.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
|
|
293
|
+
`,JSON.stringify(ei(t,r),null,2)].join(""))}function zy(e,t){let r=t.length;console.log([`${yf(_f.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${r} task${r===1?"":"s"}:\x1B[0m
|
|
294
|
+
`,t.map(n=>`- ${yf(_f.green,String(n.name))} -> ${JSON.stringify(n.input,null,2)}`).join(`
|
|
295
|
+
`)].join(""))}function QL(e,t,r){let n={};for(let[i,o]of t)r.includes(i)&&(n[i]||(n[i]=[]),n[i].push(o));console.log([`${yf(_f.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(n).length} channel${Object.keys(n).length!==1?"s":""}:\x1B[0m
|
|
296
|
+
`,Object.entries(n).map(([i,o])=>`- ${yf(_f.yellow,i)} -> ${o.map(a=>JSON.stringify(a)).join(", ")}`).join(`
|
|
297
|
+
`)].join(""))}var g$=class extends Ct{_abortController;_innerReader;_disposeSignal;constructor(e,t,r){let n=e.getReader(),i=t??new AbortController,o=r;super({start(a){return s();function s(){return n.read().then(({done:c,value:u})=>{if(c){a.close(),o?.();return}return a.enqueue(u),s()})}}}),this._abortController=i,this._innerReader=n,this._disposeSignal=r}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock(),this._disposeSignal?.()}get signal(){return this._abortController.signal}},Dy=class extends Ct{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,r=new Promise(n=>{t=n});super({start:n=>{t(n)}}),r.then(n=>{this.controller=n}),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)}},rU=class extends jn{name="StreamToolsHandler";streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,r,n,i,o,a,s){if(!o||i&&i.includes("langsmith:hidden"))return;let c=o.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:s,toolName:a??"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 sJ(e){return JSON.stringify(e,function(t,r){let n=this[t];if(n!=null&&typeof n=="object"&&"toDict"in n&&typeof n.toDict=="function"){let{type:i,data:o}=n.toDict();return{...o,type:i}}return r})}function cJ(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function _$(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function h$(e){return!_$(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 eU(e){if(_$(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([n])=>!n.startsWith("__"))),r={...e,configurable:t};return delete r.callbacks,r}return e}function tU(e){let t={...e,checkpoint:h$(e.config),parent_checkpoint:h$(e.parentConfig),config:eU(e.config),parent_config:eU(e.parentConfig),tasks:e.tasks.map(r=>{if(_$(r.state)){let n=h$(r.state);if(n!=null){let i={...r,checkpoint:n};return delete i.state,i}}return r})};return delete t.parentConfig,t}function nU(e){let t=new TextEncoder;return new ReadableStream({async start(r){let n=i=>{r.enqueue(t.encode(`event: ${i.event}
|
|
298
|
+
data: ${sJ(i.data)}
|
|
299
|
+
|
|
300
|
+
`))};try{for await(let i of e){let[o,a,s]=i,c=s;if(a==="debug"){let u=s;u.type==="checkpoint"&&(c={...u,payload:tU(u.payload)})}a==="checkpoints"&&(c=tU(s)),n({event:o?.length?`${a}|${o.join("|")}`:a,data:c})}}catch(i){n({event:"error",data:cJ(i)})}r.close()}})}var Ly=Symbol.for("INPUT_DONE"),y$=Symbol.for("INPUT_RESUMING"),uJ=25;function lJ(...e){return new Dy({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 dJ=class extends by{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}},iU=class oU{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=[];isNested;_checkpointerChainedPromise=Promise.resolve();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,n=this.input===null||this.input===void 0,i=Nt(this.input)&&this.input.resume!=null,o=this.input===y$,a=!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||n||i||o||a)}constructor(t){this.input=t.input,this.checkpointer=t.checkpointer,this.checkpointer!==void 0?this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer):this.checkpointerGetNextVersion=qL,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 dJ(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:n}=t;n!==void 0&&r.configurable?.__pregel_stream!==void 0&&(n=lJ(n,r.configurable[fd]));let i=r.configurable?!("checkpoint_id"in r.configurable):!0,o=r.configurable?.[Br];r.configurable&&o&&(o.subgraphCounter>0&&(r=Ur(r,{[un]:[r.configurable[un],o.subgraphCounter.toString()].join("|")})),o.subgraphCounter+=1);let a=On in(r.configurable??{});!a&&r.configurable?.checkpoint_ns!==void 0&&r.configurable?.checkpoint_ns!==""&&(r=Ur(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=Ur(r,{checkpoint_id:r.configurable[ln][r.configurable?.checkpoint_ns]}));let c=r.configurable?.checkpoint_ns?.split("|")??[],u=await t.checkpointer?.getTuple(s)??{config:r,checkpoint:ol(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};s={...r,...u.config,configurable:{checkpoint_ns:"",...r.configurable,...u.config.configurable}};let l=u.parentConfig,d=Kn(u.checkpoint),f={...u.metadata},p=u.pendingWrites??[],m=$a(t.channelSpecs,d),h=(f.step??0)+1,w=h+(r.recursionLimit??uJ)+1,_={...d.channel_versions},y=t.store?new vy(t.store):void 0;return y&&await y.start(),new oU({input:t.input,config:r,checkpointer:t.checkpointer,checkpoint:d,checkpointMetadata:f,checkpointConfig:s,prevCheckpointConfig:l,checkpointNamespace:c,channels:m,isNested:a,manager:t.manager,skipDoneTasks:i,step:h,stop:w,checkpointPreviousVersions:_,checkpointPendingWrites:p,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:n,store:y,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.checkpointerPromises.push(this._checkpointerChainedPromise)}putWrites(t,r){let n=r;if(n.length===0)return;n.every(([c])=>c in cf)&&(n=Array.from(new Map(n.map(c=>[c[0],c])).values()));let i=!1;for(let c in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,c)&&this.channels[c].lc_graph_name==="UntrackedValue"){i=!0;break}let o=n;i&&(o=n.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&At(u)?[c,KL(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of o)this.checkpointPendingWrites.push([t,c,u]);let a=Ur(this.checkpointConfig,{[un]:this.config.configurable?.checkpoint_ns??"",[Wf]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this.checkpointerPromises.push(this.checkpointer.putWrites(a,o,t)),this.tasks&&this._outputWrites(t,n),!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,n=!1){let i=this.tasks[t];if(i!==void 0){if(i.config!==void 0&&(i.config.tags??[]).includes("langsmith:hidden"))return;if(r.length>0)if(r[0][0]==="__interrupt__"){if(i.path?.[0]==="__pregel_push"&&i.path?.[i.path.length-1]===!0)return;let o=r.filter(a=>a[0]===ot).flatMap(a=>a[1]);this._emit([["updates",{[ot]:o}],["values",{[ot]:o}]])}else r[0][0]!=="__error__"&&this._emit(Qs(Eo(UL(this.outputKeys,[[i,r]],n),"updates")));n||this._emit(Qs(Eo(JL([[i,r]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],r=([a,s])=>`ns:${a.join(",")}|key:${s}`,n=[],i={};for(let a of Object.values(this.tasks))a.cache_key!=null&&!a.writes.length&&(n.push([a.cache_key.ns,a.cache_key.key]),i[r([a.cache_key.ns,a.cache_key.key])]=a);if(n.length===0)return[];let o=await this.cache.get(n);for(let{key:a,value:s}of o){let c=i[r(a)];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(![Ly,y$].includes(this.input))await this._first(r);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new to;if(Object.values(this.tasks).every(i=>i.writes.length>0)){let i=Object.values(this.tasks).flatMap(a=>a.writes);this.updatedChannels=Er(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let o=await Yn(Eo(Ny(this.outputKeys,i,this.channels),"values"));if(this._emit(o),this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),gf(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new to;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[zc]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=Oa(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 Yn(Eo(XL(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[i,o,a]of this.checkpointPendingWrites){if(o==="__error__"||o==="__interrupt__"||o==="__resume__")continue;let s=Object.values(this.tasks).find(c=>c.id===i);s&&s.writes.push([o,a])}for(let i of Object.values(this.tasks))i.writes.length>0&&this._outputWrites(i.id,i.writes,!0)}if(Object.values(this.tasks).every(i=>i.writes.length>0))return this.tick({inputKeys:r});if(gf(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new to;let n=await Yn(Eo(f$(Object.values(this.tasks)),"tasks"));return this._emit(n),!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(n=>!n.includes(":")))&&(this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let r=this._suppressInterrupt(t);return(r||t===void 0)&&(this.output=ei(this.channels,this.outputKeys)),r&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(n=>n.writes.length>0)&&(this.updatedChannels=Er(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emit(Qs(Eo(Ny(this.outputKeys,Object.values(this.tasks).flatMap(n=>n.writes),this.channels),"values")))),ro(t)&&!t.interrupts.length&&this._emit([["updates",{[ot]:[]}],["values",{[ot]:[]}]])),r}async acceptPush(t,r,n){if(this.interruptAfter?.length>0&&gf(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let i=jy([dn,t.path??[],r,t.id,n],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(!i)return;if(this.interruptBefore?.length>0&&gf(this.checkpoint,this.interruptBefore,[i])){this.toInterrupt.push(i);return}this._emit(Qs(Eo(f$([i]),"tasks"))),this.debug&&zy(this.step,[i]),this.tasks[i.id]=i,this.skipDoneTasks&&this._matchWrites({[i.id]:i});let o=await this._matchCachedWrites();for(let{task:a}of o)this._outputWrites(a.id,a.writes,!0);return i}_suppressInterrupt(t){return ro(t)&&!this.isNested}async _first(t){let{configurable:r}=this.config,n=r?.[Br];if(n&&n.nullResume!==void 0&&this.putWrites(Zr,[[Vr,n.nullResume]]),Nt(this.input)){let a=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(Py)&&(this.config.configurable??={},this.config.configurable[Dc]=this.input.resume),a&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let s={};for(let[c,u,l]of LL(this.input,this.checkpointPendingWrites))s[c]??=[],s[c].push([u,l]);if(Object.keys(s).length===0)throw new tm("Received empty Command input");for(let[c,u]of Object.entries(s))this.putWrites(c,u)}let i=(this.checkpointPendingWrites??[]).filter(a=>a[0]===Zr).map(a=>a.slice(1));i.length>0&&Er(this.checkpoint,this.channels,[{name:di,writes:i,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let o=Nt(this.input)&&i.length>0;if(this.isResuming||o){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[ot]={...this.checkpoint.versions_seen[ot],[s]:c}}let a=await Yn(Eo(Ny(this.outputKeys,!0,this.channels),"values"));this._emit(a)}if(this.isResuming)this.input=y$;else if(o)await this._putCheckpoint({source:"input"}),this.input=Ly;else{let a=await Yn(Ry(t,this.input));if(a.length>0){let s=Oa(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=Er(this.checkpoint,this.channels,Object.values(s).concat([{name:di,writes:a,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=Ly}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=Ly;else throw new tm(`Received no input writes for ${JSON.stringify(t,null,2)}`)}this.isNested||(this.config=Ur(this.config,{[zc]:this.isResuming}))}_emit(t){for(let[r,n]of t)if(this.stream.modes.has(r)&&this.stream.push([this.checkpointNamespace,r,n]),(r==="checkpoints"||r==="tasks")&&this.stream.modes.has("debug")){let i=r==="checkpoints"?this.step-1:this.step,o=new Date().toISOString(),a=r==="checkpoints"?"checkpoint":typeof n=="object"&&n!=null&&"result"in n?"task_result":"task";this.stream.push([this.checkpointNamespace,"debug",{step:i,type:a,timestamp:o,payload:n}])}}_putCheckpoint(t){let r=this.checkpointMetadata===t,n=this.checkpointer!=null&&(this.durability!=="exit"||r),i=o=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=Ur(this.checkpointConfig,{[un]:this.config.configurable?.checkpoint_ns??""});let a={...this.checkpoint.channel_versions},s=ll(this.checkpointPreviousVersions,a);this.checkpointPreviousVersions=a,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:Kn(o),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=Wn(this.checkpoint,n?this.channels:void 0,this.step,r?{id:this.checkpoint.id}:void 0),n&&i(this.checkpoint),r||(this.step+=1)}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=Ur(this.checkpointConfig,{[un]:this.config.configurable?.checkpoint_ns??"",[Wf]:this.checkpoint.id}),r={};for(let[n,i,o]of this.checkpointPendingWrites)r[n]??=[],r[n].push([i,o]);for(let[n,i]of Object.entries(r))this.checkpointerPromises.push(this.checkpointer.putWrites(t,i,n))}_matchWrites(t){for(let[r,n,i]of this.checkpointPendingWrites){if(n==="__error__"||n==="__interrupt__"||n==="__resume__")continue;let o=Object.values(t).find(a=>a.id===r);o&&o.writes.push([n,i])}for(let r of Object.values(t))r.writes.length>0&&this._outputWrites(r.id,r.writes,!0)}};function pJ(e){return ft(e?.message)}var aU=class extends jn{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,r,n=!1){if(n&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let i=t.id;r!=null&&(as(t)?i??=`run-${r}-tool-${t.tool_call_id}`:((i==null||i===`run-${r}`)&&(i=this.stableMessageIdMap[r]??i??`run-${r}`),this.stableMessageIdMap[r]??=i)),i!==t.id&&(t.id=i,t.lc_kwargs.id=i),t.id!=null&&(this.seen[t.id]=t),this.streamFn([e[0],"messages",[t,e[1]]])}handleChatModelStart(e,t,r,n,i,o,a,s){a&&(!o||!o.includes("langsmith:nostream")&&!o.includes("nostream"))&&(this.metadatas[r]=[a.langgraph_checkpoint_ns.split("|"),{tags:o,name:s,...a}])}handleLLMNewToken(e,t,r,n,i,o){let a=o?.chunk;this.emittedChatModelRunIds[r]=!0,this.metadatas[r]!==void 0&&(pJ(a)?this._emit(this.metadatas[r],a.message,r):this._emit(this.metadatas[r],new at({content:e}),r))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let r=e.generations?.[0]?.[0];ft(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,n,i,o,a,s){if(o!==void 0&&s===o.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[r]=[o.langgraph_checkpoint_ns.split("|"),{tags:i,name:s,...o}],typeof t=="object")){for(let c of Object.values(t))if((ft(c)||oo(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(ft(u)||oo(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(ft(e))this._emit(r,e,t,!0);else if(Array.isArray(e))for(let n of e)ft(n)&&this._emit(r,n,t,!0);else if(e!=null&&typeof e=="object"){for(let n of Object.values(e))if(ft(n))this._emit(r,n,t,!0);else if(Array.isArray(n))for(let i of n)ft(i)&&this._emit(r,i,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};var fJ=[400,401,402,403,404,405,406,407,409],mJ=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&&fJ.includes(+t)||e?.error?.code==="insufficient_quota")};async function v$(e,t,r,n){let i=e.retry_policy??t,o=i!==void 0?i.initialInterval??500:0,a=0,s,c,{config:u}=e;for(r&&(u=Ur(u,r)),u={...u,signal:n};!n?.aborted;){e.writes.splice(0,e.writes.length),s=void 0;try{c=await e.proc.invoke(e.input,u);break}catch(l){if(s=l,s.pregelTaskId=e.id,Mv(s)){let p=u?.configurable?.checkpoint_ns,m=s.command;if(m.graph===p){for(let h of e.writers)await h.invoke(m,u);s=void 0;break}else if(m.graph===Ar.PARENT){let h=kL(p);s.command=new Ar({...s.command,graph:h})}}if(ns(s)||i===void 0||(a+=1,a>=(i.maxAttempts??3))||!(i.retryOn??mJ)(s))break;o=Math.min(i.maxInterval??128e3,o*(i.backoffFactor??2));let d=i.jitter?Math.floor(o+Math.random()*1e3):o;await new Promise(p=>setTimeout(p,d));let f=s.name??s.constructor.unminifiable_name??s.constructor.name;(i?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${o.toFixed(2)}ms (attempt ${a}) after ${f}: ${s}`),u=Ur(u,{[zc]:!0})}}return{task:e,result:c,error:s,signalAborted:n?.aborted}}var b$=Symbol.for("promiseAdded");function hJ(){let e={next:()=>{},wait:Promise.resolve(b$)};function t(r){e.next=()=>{e.wait=new Promise(t),r(b$)}}return e.wait=new Promise(t),e}var sU=class{nodeFinished;loop;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:r,onStepWrite:n,maxConcurrency:i}=e,o=new Set,a,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:i});for await(let{task:m,error:h,signalAborted:w}of p)this._commit(m,h),ro(h)||ns(h)&&!ro(a)?a=h:h&&(o.size===0||!w)&&(s.abort(),o.add(h));if(f?.(),n?.(this.loop.step,Object.values(this.loop.tasks).map(m=>m.writes).flat()),o.size===1)throw Array.from(o)[0];if(o.size>1)throw new AggregateError(Array.from(o),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(ro(a)||ns(a)&&this.loop.isNested)throw a}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:r}){let n=this.loop.config.configurable?.__pregel_abort_signals??{},i=n.externalAbortSignal??r,o=t??n.timeoutAbortSignal,{signal:a,dispose:s}=dl(i,o,e),c={externalAbortSignal:i,timeoutAbortSignal:o,composedAbortSignal:a};return this.loop.config=Ur(this.loop.config,{[LT]:c}),{signals:c,disposeCombinedSignal:s}}async*_executeTasksWithRetry(e,t){let{retryPolicy:r,maxConcurrency:n,signals:i}=t??{},o=hJ(),a={},s={executingTasksMap:a,barrier:o,retryPolicy:r,scheduleTask:async(f,p,m)=>this.loop.acceptPush(f,p,m)};if(i?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=dl(i?.externalAbortSignal,i?.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(a).length>0)&&e.length;){for(;Object.values(a).length<(n??e.length)&&c<e.length;c+=1){let p=e[c];a[p.id]=v$(p,r,{[dd]:cU?.bind(s,this,p)},i?.composedAbortSignal).catch(m=>({task:p,error:m,signalAborted:i?.composedAbortSignal?.aborted}))}let f=await Promise.race([...Object.values(a),...d?[d]:[],o.wait]);f!==b$&&(yield f,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete a[f.task.id])}}_commit(e,t){if(t!==void 0)if(ro(t)){if(t.interrupts.length){let r=t.interrupts.map(i=>[ot,i]),n=e.writes.filter(i=>i[0]===Vr);n.length&&r.push(...n),this.loop.putWrites(e.id,r)}}else ns(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):this.loop.putWrites(e.id,[[jc,{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([md,null]),this.loop.putWrites(e.id,e.writes)}};async function cU(e,t,r,n,i,o={}){let a=t.config?.configurable?.[Br];if(!a)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let s=a.callCounter;a.callCounter+=1;let c=new VL({func:r,name:n,input:i,cache:o.cache,retry:o.retry,callbacks:o.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===Ko),f=u.writes.filter(([p])=>p===jc);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=v$(u,o.retry,{[dd]:cU.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 Ao=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function uU({nodes:e,channels:t,inputChannels:r,outputChannels:n,streamChannels:i,interruptAfterNodes:o,interruptBeforeNodes:a}){if(!t)throw new Ao("Channels not provided");let s=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Ao(`"Node name ${ot} is reserved"`);if(l.constructor===Qn)l.triggers.forEach(d=>s.add(d));else throw new Ao(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of s)if(!(u in t))throw new Ao(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(r)){if(r.every(u=>!s.has(u)))throw new Ao(`None of the input channels ${r} are subscribed to by any node`)}else if(!s.has(r))throw new Ao(`Input channel ${String(r)} is not subscribed to by any node`);Array.isArray(n)?n.forEach(u=>c.add(u)):c.add(n),i&&!Array.isArray(i)?c.add(i):Array.isArray(i)&&i.forEach(u=>c.add(u));for(let u of c)if(!(u in t))throw new Ao(`Output channel '${String(u)}' not in channels`);if(o&&o!=="*"){for(let u of o)if(!(u in e))throw new Ao(`Node ${String(u)} not in nodes`)}if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new Ao(`Node ${String(u)} not in nodes`)}}function w$(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 x$=class lU extends Gt{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 lU({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 n=t.flat();if(n.length>0)if(this.unique)for(let i of n)this.seen.has(i)||(r=!0,this.seen.add(i),this.values.push(i));else r=!0,this.values.push(...n);return r}get(){if(this.values.length===0)throw new Ve;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function dU(e){let t=He.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 rs("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=r[Br];n.interruptCounter+=1;let i=n.interruptCounter;if(n.resume.length>0&&i<n.resume.length)return r[cn]?.([[Vr,n.resume]]),n.resume[i];if(n.nullResume!==void 0){if(n.resume.length!==i)throw new Error(`Resume length mismatch: ${n.resume.length} !== ${i}`);let a=n.consumeNullResume();return n.resume.push(a),r[cn]?.([[Vr,n.resume]]),a}let o=r[un]?.split("|");throw new to([{id:o?To(o.join("|")):void 0,value:e}])}var pU=class{static subscribeTo(e,t){let{key:r,tags:n}={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 i;return typeof e=="string"?r?i={[r]:e}:i=[e]:i=Object.fromEntries(e.map(o=>[o,o])),new Qn({channels:i,triggers:Array.isArray(e)?e:[e],tags:n})}static writeTo(e,t){let r=[];for(let n of e)r.push({channel:n,value:Lr,skipNone:!1});for(let[n,i]of Object.entries(t??{}))pe.isRunnable(i)||typeof i=="function"?r.push({channel:n,value:Lr,skipNone:!0,mapper:yt(i)}):r.push({channel:n,value:i,skipNone:!1});return new wt(r)}},gJ=class extends pe{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)}},Uy=class extends gJ{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 '${pi}' is reserved and cannot be used in the graph.`);this.channels[pi]=new x$({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=Bt(this.config,e);return new this.constructor({...this,config:t})}validate(){uU({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,n]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(r))continue;let i=n.subgraphs?.length?n.subgraphs:[n.bound];for(let o of i){let a=Ey(o);if(a!==void 0){if(r===e){yield[r,a];return}if(e===void 0&&(yield[r,a]),t){let s=e;e!==void 0&&(s=e.slice(r.length+1));for(let[c,u]of a.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:n=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let i=$a(this.channels,t.checkpoint);if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([f,p])=>f===Zr).map(([f,p,m])=>[String(p),m]);d.length>0&&Er(t.checkpoint,i,[{name:di,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let o=Object.values(Oa(t.checkpoint,t.pendingWrites,this.nodes,i,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),a=await Yn(this.getSubgraphsAsync()),s=t.config.configurable?.checkpoint_ns??"",c={};for(let d of o){let f=a.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:{[Cn]:r,thread_id:t.config.configurable?.thread_id,checkpoint_ns:p}},h=f[1];c[d.id]=await h.getState(m,{subgraphs:!0})}}if(n&&t.pendingWrites?.length){let d=Object.fromEntries(o.map(p=>[p.id,p]));for(let[p,m,h]of t.pendingWrites)["__error__","__interrupt__",os].includes(m)||p in d&&d[p].writes.push([String(m),h]);let f=o.filter(p=>p.writes.length>0);f.length>0&&Er(t.checkpoint,i,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=o.filter(d=>d.writes.length===0).map(d=>d.name);return{values:ei(i,this.streamChannelsAsIs),next:l,tasks:m$(o,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:Aa(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 rs("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Iy(n);for await(let[s,c]of this.getSubgraphsAsync(a,!0))if(s===a)return await c.getState(ec(e,{[Cn]:r}),{subgraphs:t?.subgraphs})}let i=Bt(this.config,e),o=await r.getTuple(e);return await this._prepareStateSnapshot({config:i,saved:o,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 rs("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let o=Iy(n);for await(let[a,s]of this.getSubgraphsAsync(o,!0))if(a===o){yield*s.getStateHistory(ec(e,{[Cn]:r}),t);return}}let i=Bt(this.config,e,{configurable:{checkpoint_ns:n}});for await(let o of r.list(i,t))yield this._prepareStateSnapshot({config:o.config,saved:o})}async bulkUpdateState(e,t){let r=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!r)throw new rs("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if(t.length===0)throw new Error("No supersteps provided");if(t.some(a=>a.updates.length===0))throw new Error("No updates provided");let n=e.configurable?.checkpoint_ns??"";if(n!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=Iy(n);for await(let[,s]of this.getSubgraphsAsync(a,!0))return await s.bulkUpdateState(ec(e,{[Cn]:r}),t);throw new Error(`Subgraph "${a}" not found`)}let i=async(a,s)=>{let c=this.config?Bt(this.config,a):a,u=await r.getTuple(c),l=u!==void 0?Kn(u.checkpoint):ol(),d={...u?.checkpoint.channel_versions},f=u?.metadata?.step??-1,p=ec(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(p=ec(c,u.config.configurable),m={...u.metadata,...m});let{values:h,asNode:w}=s[0];if(h==null&&w===void 0){if(s.length>1)throw new Re("Cannot create empty checkpoint with multiple updates");return Aa(await r.put(p,Wn(l,void 0,f),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let _=$a(this.channels,l);if(h===null&&w==="__end__"){if(s.length>1)throw new Re("Cannot apply multiple updates when clearing state");if(u){let C=Oa(l,u.pendingWrites||[],this.nodes,_,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:r,store:this.store}),b=(u.pendingWrites||[]).filter(H=>H[0]===Zr).map(H=>H.slice(1));b.length>0&&Er(l,_,[{name:di,writes:b,triggers:[]}],r.getNextVersion.bind(r),this.triggerToNodes);for(let[H,R,V]of u.pendingWrites||[])["__error__","__interrupt__",os].includes(R)||H in C&&C[H].writes.push([R,V]);Er(l,_,Object.values(C),r.getNextVersion.bind(r),this.triggerToNodes)}return Aa(await r.put(p,Wn(l,_,f),{...m,source:"update",step:f+1,parents:u?.metadata?.parents??{}},ll(d,l.channel_versions)),u?u.metadata:void 0)}if(w==="__copy__"){if(s.length>1)throw new Re("Cannot copy checkpoint with multiple updates");if(u==null)throw new Re("Cannot copy a non-existent checkpoint");let C=R=>!Array.isArray(R)||R.length===0?!1:R.every(V=>Array.isArray(V)&&V.length===2),b=Wn(l,void 0,f),H=await r.put(u.parentConfig??ec(u.config,{checkpoint_id:void 0}),b,{source:"fork",step:f+1,parents:u.metadata?.parents??{}},{});if(C(h)){let R=Oa(b,u.pendingWrites,this.nodes,_,H,!1,{step:f+2}),V=Object.values(R).reduce((Ge,{name:qt,id:Fr})=>(Ge[qt]??=[],Ge[qt].push({id:Fr}),Ge),{}),xe=h.reduce((Ge,qt)=>{let[Fr,ze]=qt;Ge[ze]??=[];let Xa=Ge[ze].length,Yi=V[ze]?.[Xa]?.id;return Ge[ze].push({values:Fr,asNode:ze,taskId:Yi}),Ge},{});return i(Aa(H,u.metadata),Object.values(xe).flat())}return Aa(H,u.metadata)}if(w==="__input__"){if(s.length>1)throw new Re("Cannot apply multiple updates when updating as input");let C=await Yn(Ry(this.inputChannels,h));if(C.length===0)throw new Re(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);Er(l,_,[{name:di,writes:C,triggers:[]}],r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let b=u?.metadata?.step!=null?u.metadata.step+1:-1,H=await r.put(p,Wn(l,_,b),{source:"input",step:b,parents:u?.metadata?.parents??{}},ll(d,l.channel_versions));return await r.putWrites(H,C,no(di,l.id)),Aa(H,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let C=Oa(l,u.pendingWrites,this.nodes,_,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),b=(u.pendingWrites??[]).filter(R=>R[0]===Zr).map(R=>R.slice(1));b.length>0&&Er(u.checkpoint,_,[{name:di,writes:b,triggers:[]}],void 0,this.triggerToNodes);for(let[R,V,xe]of u.pendingWrites)["__error__","__interrupt__",os].includes(V)||C[R]===void 0||C[R].writes.push([V,xe]);let H=Object.values(C).filter(R=>R.writes.length>0);H.length>0&&Er(l,_,H,void 0,this.triggerToNodes)}let y=Object.values(l.versions_seen).map(C=>Object.values(C)).flat().find(C=>!!C),x=[];if(s.length===1){let{values:C,asNode:b,taskId:H}=s[0];if(b===void 0&&Object.keys(this.nodes).length===1)[b]=Object.keys(this.nodes);else if(b===void 0&&y===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(b=this.inputChannels);else if(b===void 0){let R=Object.entries(l.versions_seen).map(([V,xe])=>Object.values(xe).map(Ge=>[Ge,V])).flat().filter(([V,xe])=>xe!==ot).sort(([V],[xe])=>_y(V,xe));R&&(R.length===1?b=R[0][1]:R[R.length-1][0]!==R[R.length-2][0]&&(b=R[R.length-1][1]))}if(b===void 0)throw new Re('Ambiguous update, specify "asNode"');x.push({values:C,asNode:b,taskId:H})}else for(let{asNode:C,values:b,taskId:H}of s){if(C==null)throw new Re('"asNode" is required when applying multiple updates');x.push({values:b,asNode:C,taskId:H})}let S=[];for(let{asNode:C,values:b,taskId:H}of x){if(this.nodes[C]===void 0)throw new Re(`Node "${C.toString()}" does not exist`);let R=this.nodes[C].getWriters();if(!R.length)throw new Re(`No writers found for node "${C.toString()}"`);S.push({name:C,input:b,proc:R.length>1?tn.from(R,{omitSequenceTags:!0}):R[0],writes:[],triggers:[ot],id:H??no("__interrupt__",l.id),writers:[]})}for(let C of S)await C.proc.invoke(C.input,Me({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[cn]:b=>C.writes.push(...b),[On]:(b,H=!1)=>hf(l,_,C,b,H)}}));for(let C of S){let b=C.writes.filter(H=>H[0]!==dn);u!==void 0&&b.length>0&&await r.putWrites(p,b,C.id)}Er(l,_,S,r.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let $=ll(d,l.channel_versions),j=await r.put(p,Wn(l,_,f+1),{source:"update",step:f+1,parents:u?.metadata?.parents??{}},$);for(let C of S){let b=C.writes.filter(H=>H[0]===dn);b.length>0&&await r.putWrites(j,b,C.id)}return Aa(j,u?u.metadata:void 0)},o=e;for(let{updates:a}of t)o=await i(o,a);return o}async updateState(e,t,r){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:r}]}])}_defaults(e){let{debug:t,streamMode:r,inputKeys:n,outputKeys:i,interruptAfter:o,interruptBefore:a,...s}=e,c=!0,u=t!==void 0?t:this.debug,l=i;l===void 0?l=this.streamChannelsAsIs:w$(l,this.channels);let d=n;d===void 0?d=this.inputChannels:w$(d,this.channels);let f=a??this.interruptBefore??[],p=o??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 h;if(this.checkpointer===!1)h=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)h=e.configurable[Cn];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");h=this.checkpointer}let w=e.store??this.store,_=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 y=(()=>{if(e.checkpointDuring!=null)return e.checkpointDuring===!1?"exit":"async"})(),x=e.durability??y??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,s,f,p,h,w,c,_,x]}async stream(e,t){let r=new AbortController,{signal:n,dispose:i}=dl(t?.signal,r.signal),o={recursionLimit:this.config?.recursionLimit,...t,signal:n},a=await super.stream(e,o);return new g$(t?.encoding==="text/event-stream"?nU(a):a,r,i)}streamEvents(e,t,r){let n=new AbortController,{signal:i,dispose:o}=dl(t?.signal,n.signal),a={recursionLimit:this.config?.recursionLimit,...t,callbacks:BL(this.config?.callbacks,t?.callbacks),signal:i};return new g$(super.streamEvents(e,a,r),n,o)}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,n=t?.subgraphs,i=pf(this.config,t);if(i.recursionLimit===void 0||i.recursionLimit<1)throw new Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&i.configurable===void 0)throw new Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let o=await this._validateInput(e),{runId:a,...s}=i,[c,u,,l,d,f,p,m,h,w,_,y]=this._defaults(s);typeof d.context<"u"?d.context=await this._validateContext(d.context):d.configurable=await this._validateContext(d.configurable);let x=new Dy({modes:new Set(u)});if(this.checkpointer===!0){d.configurable??={};let R=d.configurable.checkpoint_ns??"";d.configurable[un]=R.split("|").map(V=>V.split(":")[0]).join("|")}if(u.includes("messages")){let R=new aU(xe=>x.push(xe)),{callbacks:V}=d;if(V===void 0)d.callbacks=[R];else if(Array.isArray(V))d.callbacks=V.concat(R);else{let xe=V.copy();xe.addHandler(R,!0),d.callbacks=xe}}if(u.includes("tools")){let R=new rU(xe=>x.push(xe)),{callbacks:V}=d;if(V===void 0)d.callbacks=[R];else if(Array.isArray(V))d.callbacks=V.concat(R);else{let xe=V.copy();xe.addHandler(R,!0),d.callbacks=xe}}d.writer??=R=>{if(!u.includes("custom"))return;let V=SL()?.configurable?.[un]?.split("|").slice(0,-1);x.push([V??[],"custom",R])},d.interrupt??=this.userInterrupt??dU;let S=await(await Ot(d))?.handleChainStart(this.toJSON(),FL(e,"input"),a,void 0,void 0,void 0,d?.runName??this.getName()),$=df(this.channels),j,C,H=(async()=>{try{j=await iU.initialize({input:o,config:d,checkpointer:m,nodes:this.nodes,channelSpecs:$,outputKeys:l,streamKeys:this.streamChannelsAsIs,store:h,cache:_,stream:x,interruptAfter:p,interruptBefore:f,manager:S,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:y});let R=new sU({loop:j,nodeFinished:d.configurable?.[DT]});t?.subgraphs&&(j.config.configurable={...j.config.configurable,[fd]:j.stream}),await this._runLoop({loop:j,runner:R,debug:c,config:d}),y==="sync"&&await Promise.all(j?.checkpointerPromises??[])}catch(R){C=R}finally{try{j&&(await j.store?.stop(),await j.cache?.stop()),await Promise.all(j?.checkpointerPromises??[])}catch(R){C=C??R}C?x.error(C):x.close()}})();try{for await(let R of x){if(R===void 0)throw new Error("Data structure error.");let[V,xe,Ge]=R;if(u.includes(xe)){if(r==="text/event-stream"){n?yield[V,xe,Ge]:yield[null,xe,Ge];continue}n&&!w?yield[V,xe,Ge]:w?n?yield[V,Ge]:yield Ge:yield[xe,Ge]}}}catch(R){throw await S?.handleChainError(C),R}finally{await H}await S?.handleChainEnd(j?.output??{},a,void 0,void 0,void 0)}async invoke(e,t){let r=t?.streamMode??"values",n={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:r,encoding:void 0},i=[],o=await this.stream(e,n),a=[],s;for await(let c of o)r==="values"?hd(c)?a.push(c[ot]):s=c:i.push(c);if(r==="values"){if(a.length>0){let c=a.flat(1);if(s==null)return{[ot]:c};if(typeof s=="object")return{...s,[ot]:c}}return s}return i}async _runLoop(e){let{loop:t,runner:r,debug:n,config:i}=e,o;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:a}of await t._matchCachedWrites())t._outputWrites(a.id,a.writes,!0);n&&YL(t.checkpointMetadata.step,t.channels,this.streamChannelsList),n&&zy(t.step,Object.values(t.tasks)),await r.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(a,s)=>{n&&QL(a,s,this.streamChannelsList)},maxConcurrency:i.maxConcurrency,signal:i.signal})}if(t.status==="out_of_steps")throw new Nv([`Recursion limit of ${i.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(a){if(o=a,!await t.finishAndHandleError(o))throw a}finally{o===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};var ti=class fU extends Gt{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let r=new fU(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 Re("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new Ve;return this.value[0]}checkpoint(){if(this.value.length===0)throw new Ve;return this.value[0]}isAvailable(){return this.value.length!==0}};var I$=class{path;ends;constructor(e){pe.isRunnable(e.path)?this.path=e.path:this.path=yt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,r)=>(t[r]=r,t),{}):e.pathMap}run(e,t){return wt.registerWriter(new ur({name:"<branch_run>",trace:!1,func:async(r,n)=>{try{return await this._route(r,n,e,t)}catch(i){throw i.name===Qf.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
301
|
+
NodeInterrupt should only be thrown inside a node, not in edge conditions.`),i}}}))}async _route(e,t,r,n){let i=await this.path.invoke(n?n(t):e,t);Array.isArray(i)||(i=[i]);let o;if(this.ends?o=i.map(a=>At(a)?a:this.ends[a]):o=i,o.some(a=>!a))throw new Error("Branch condition returned unknown or null destination");if(o.filter(At).some(a=>a.node==="__end__"))throw new Re("Cannot send a packet to the END node");return await r(o,t)??e}},S$=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(n){return n.length>=1&&typeof n[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[n,i,o]of r){for(let s of["|",":"])if(n.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."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__")throw new Error(`Node \`${n}\` is reserved.`);let a=yt(i);this.nodes[n]={runnable:a,metadata:o?.metadata,subgraphs:mf(a)?[a]:o?.subgraphs,ends:o?.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 n=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."),pe.isRunnable(n.path)||(n.path=yt(n.path));let i=n.path.getName()==="RunnableLambda"?"condition":n.path.getName();if(this.branches[n.source]&&this.branches[n.source][i])throw new Error(`Condition \`${i}\` already present for node \`${e}\``);return this.branches[n.source]??={},this.branches[n.source][i]=new I$(n),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(Ye,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,it)}compile({checkpointer:e,interruptBefore:t,interruptAfter:r,name:n}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);let i=new k$({builder:this,checkpointer:e,interruptAfter:r,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[Ye]:new ti,[it]:new ti},inputChannels:Ye,outputChannels:it,streamChannels:[],streamMode:"values",name:n});for(let[o,a]of Object.entries(this.nodes))i.attachNode(o,a);for(let[o,a]of this.edges)i.attachEdge(o,a);for(let[o,a]of Object.entries(this.branches))for(let[s,c]of Object.entries(a))i.attachBranch(o,s,c);return i.validate()}validate(e){let t=new Set([...this.allEdges].map(([n,i])=>n));for(let[n]of Object.entries(this.branches))t.add(n);for(let n of t)if(n!=="__start__"&&!(n in this.nodes))throw new Error(`Found edge starting at unknown node \`${n}\``);let r=new Set([...this.allEdges].map(([n,i])=>i));for(let[n,i]of Object.entries(this.branches))for(let o of Object.values(i))if(o.ends!=null)for(let a of Object.values(o.ends))r.add(a);else{r.add(it);for(let a of Object.keys(this.nodes))a!==n&&r.add(a)}for(let n of Object.values(this.nodes))for(let i of n.ends??[])r.add(i);for(let n of Object.keys(this.nodes))if(!r.has(n))throw new jv([`Node \`${n}\` 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(`
|
|
302
|
+
`),{lc_error_code:"UNREACHABLE_NODE"});for(let n of r)if(n!=="__end__"&&!(n in this.nodes))throw new Error(`Found edge ending at unknown node \`${n}\``);if(e){for(let n of e)if(!(n in this.nodes))throw new Error(`Interrupt node \`${n}\` is not present`)}this.compiled=!0}},k$=class extends Uy{builder;constructor({builder:e,...t}){super(t),this.builder=e}attachNode(e,t){this.channels[e]=new ti,this.nodes[e]=new Qn({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new wt([{channel:e,value:Lr}],[Tt])),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 wt([{channel:it,value:Lr}],[Tt]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,r){e==="__start__"&&!this.nodes.__start__&&(this.nodes[Ye]=pU.subscribeTo(Ye,{tags:[Tt]})),this.nodes[e].pipe(r.run(i=>new wt(i.map(o=>At(o)?o:{channel:o==="__end__"?it:`branch:${e}:${t}:${o}`,value:Lr}),[Tt])));let n=r.ends?Object.values(r.ends):Object.keys(this.nodes);for(let i of n)if(i!=="__end__"){let o=`branch:${e}:${t}:${i}`;this.channels[o]=new ti,this.nodes[i].triggers.push(o),this.nodes[i].channels.push(o)}}async getGraphAsync(e){let t=e?.xray,r=new Gs,n={[Ye]:r.addNode({schema:M.any()},Ye)},i={},o={};t&&(o=Object.fromEntries((await Yn(this.getSubgraphsAsync())).filter(c=>mU(c[1]))));function a(c,u,l,d=!1){if(u==="__end__"&&i.__end__===void 0&&(i[it]=r.addNode({schema:M.any()},it)),n[c]!==void 0){if(i[u]===void 0)throw new Error(`End node ${u} not found!`);return r.addEdge(n[c],i[u],l!==u?l:void 0,d)}}for(let[c,u]of Object.entries(this.builder.nodes)){let l=lr(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=o[c]!==void 0?await o[c].getGraphAsync({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let _=function(x){return x?x.lc_runnable:!1},y=function(x,S){if(x!==void 0&&!Uc(x))return x;if(_(S))try{let $=S.getName();return $=$.startsWith("Runnable")?$.slice(8):$,$}catch{return S.getName()}else return S.name??"UnknownSchema"},[h,w]=r.extend(m,l);if(h===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);w!==void 0&&(n[l]={name:y(w.id,w.data),...w}),i[l]={name:y(h.id,h.data),...h}}else{let h=r.addNode(d,l,f);n[l]=h,i[l]=h}}else{let p=r.addNode(d,l,f);n[l]=p,i[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)a(lr(c),lr(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=>[lr(d),lr(d)])),[it]:it};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))a(lr(c),lr(m),p,!0)}}for(let[c,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let l of u.ends)a(lr(c),lr(l),void 0,!0);return r}getGraph(e){let t=e?.xray,r=new Gs,n={[Ye]:r.addNode({schema:M.any()},Ye)},i={},o={};t&&(o=Object.fromEntries(Qs(this.getSubgraphs()).filter(c=>mU(c[1]))));function a(c,u,l,d=!1){return u==="__end__"&&i.__end__===void 0&&(i[it]=r.addNode({schema:M.any()},it)),r.addEdge(n[c],i[u],l!==u?l:void 0,d)}for(let[c,u]of Object.entries(this.builder.nodes)){let l=lr(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=o[c]!==void 0?o[c].getGraph({...e,xray:p}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let _=function(x){return x?x.lc_runnable:!1},y=function(x,S){if(x!==void 0&&!Uc(x))return x;if(_(S))try{let $=S.getName();return $=$.startsWith("Runnable")?$.slice(8):$,$}catch{return S.getName()}else return S.name??"UnknownSchema"},[h,w]=r.extend(m,l);if(h===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);w!==void 0&&(n[l]={name:y(w.id,w.data),...w}),i[l]={name:y(h.id,h.data),...h}}else{let h=r.addNode(d,l,f);n[l]=h,i[l]=h}}else{let p=r.addNode(d,l,f);n[l]=p,i[l]=p}}let s=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of s)a(lr(c),lr(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=>[lr(d),lr(d)])),[it]:it};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))a(lr(c),lr(m),p,!0)}}return r}};function mU(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function lr(e){return e==="subgraph"?`"${e}"`:e}function Ca(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function hU(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Pa(e){if(hU(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function Ra(e){if(e!=null&&Ca(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 n=r.value;return()=>n}}}catch{}}var E$=Symbol.for("langgraph.channel.missing"),Fy=class gU extends Gt{lc_graph_name="UntrackedValue";guard;_value=E$;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new gU({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new Re("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===E$)throw new Ve;return this._value}checkpoint(){}isAvailable(){return this._value!==E$}};var Na=(e,t)=>e.size===t.size&&[...e].every(r=>t.has(r)),$$=class _U extends Gt{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let r=new _U(this.names);return typeof t<"u"&&(r.seen=new Set(t)),r}update(t){let r=!1;for(let n of t)if(this.names.has(n))this.seen.has(n)||(this.seen.add(n),r=!0);else throw new Re(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!Na(this.names,this.seen))throw new Ve}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&Na(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&Na(this.names,this.seen)}},T$=class yU extends Gt{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 yU(this.names);if(typeof t<"u"){let[n,i]=t;r.seen=new Set(n),r.finished=i}return r}update(t){let r=!1;for(let n of t)if(this.names.has(n)&&!this.seen.has(n))this.seen.add(n),r=!0;else if(!this.names.has(n))throw new Re(`Value ${JSON.stringify(n)} not in names ${JSON.stringify(this.names)}`);return r}get(){if(!this.finished||!Na(this.names,this.seen))throw new Ve}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&Na(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&Na(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&Na(this.names,this.seen)}};var A$=Symbol.for("langgraph.state.reduced_value"),Oo=class{[A$]=!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&&A$ in e&&e[A$]===!0}};var vU=Symbol.for("langgraph.state.untracked_value"),nc=class{[vU]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&vU in e}};var O$=Symbol.for("langgraph.state.state_schema"),Bi=class{[O$]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,r]of Object.entries(this.fields))if(Oo.isInstance(r)){let n=Ra(r.valueSchema);e[t]=new ko(r.reducer,n)}else if(nc.isInstance(r)){let n=r.schema?Ra(r.schema):void 0;e[t]=new Fy({guard:r.guard,initialValueFactory:n})}else if(Ca(r))e[t]=new Jn(Ra(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,n]of Object.entries(this.fields)){let i;if(Oo.isInstance(n)?(i=Pa(n.valueSchema),n.jsonSchemaExtra&&(i={...i??{},...n.jsonSchemaExtra})):nc.isInstance(n)?i=n.schema?Pa(n.schema):void 0:Ca(n)&&(i=Pa(n)),i){e[r]=i;let o=!1;Oo.isInstance(n)?o=Ra(n.valueSchema)!==void 0:nc.isInstance(n)?o=n.schema?Ra(n.schema)!==void 0:!1:o=Ra(n)!==void 0,o||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 n;Oo.isInstance(r)?(n=Pa(r.inputSchema),r.jsonSchemaExtra&&(n={...n??{},...r.jsonSchemaExtra})):nc.isInstance(r)?n=r.schema?Pa(r.schema):void 0:Ca(r)&&(n=Pa(r)),n&&(e[t]=n)}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,n]of Object.entries(e)){let i=this.fields[r];if(i===void 0){t[r]=n;continue}let o;if(Oo.isInstance(i)?o=i.inputSchema:nc.isInstance(i)?o=i.schema:Ca(i)&&(o=i),o){let a=await o["~standard"].validate(n);if(a.issues)throw new Error(`Validation failed for field "${r}": ${JSON.stringify(a.issues)}`);t[r]=a.value}else t[r]=n}return t}static isInstance(e){return typeof e=="object"&&e!==null&&O$ in e&&e[O$]===!0}};function ic(e,t){let r=Array.isArray(e)?e:[e],n=Array.isArray(t)?t:[t],i=r.map(tr),o=n.map(tr);for(let l of i)(l.id===null||l.id===void 0)&&(l.id=fi(),l.lc_kwargs.id=l.id);let a;for(let l=0;l<o.length;l+=1){let d=o[l];(d.id===null||d.id===void 0)&&(d.id=fi(),d.lc_kwargs.id=d.id),Mn.isInstance(d)&&d.id==="__remove_all__"&&(a=l)}if(a!=null)return o.slice(a+1);let s=[...i],c=new Map(s.map((l,d)=>[l.id,d])),u=new Set;for(let l of o){let d=c.get(l.id);if(d!==void 0)Mn.isInstance(l)?u.add(l.id):(u.delete(l.id),s[d]=l);else{if(Mn.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 _J=new Oo(M.custom().default(()=>[]),{inputSchema:M.custom(),reducer:ic,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var yJ=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=Ts(e);for(let[n,i]of Object.entries(r)){let o=this.get(i);o?.reducer?t[n]=new ko(o.reducer.fn,o.default):t[n]=new Jn(o?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let r=Object.entries(t).filter(([,o])=>o===!0).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}:${a}`).join("|"),n=this._extensionCache.get(r)??new Map;if(n.has(e))return n.get(e);let i=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let o=Object.entries(Ts(e)).map(([a,s])=>{let c=this.get(s),u=t.withReducerSchema?c?.reducer?.schema??s:s;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=Un(u)??Un(s),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[a,u]});i=zg(e,Object.fromEntries(o)),mt(i)&&(i._def.unknownKeys="strip")}return t.asPartial&&(i=Cu(i)),n.set(e,i),this._extensionCache.set(r,n),i}},vf=new yJ;function bU(e,t){if(t.reducer&&!t.default){let r=Dg(e);r!=null&&(t.default=r)}if(t.reducer){let r=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return vf.extend(r,()=>t),r}else return vf.extend(e,()=>t),e}function oc(e){return e==null?!1:!!(Bi.isInstance(e)||Ir(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"||n$(t)))}function wU(e){if(typeof e!="object"||e==null)return!1;let t=e,r="state"in t&&oc(t.state),n="stateSchema"in t&&oc(t.stateSchema),i="input"in t&&oc(t.input);return!(!r&&!n&&!i||"input"in t&&t.input!=null&&!oc(t.input)||"output"in t&&t.output!=null&&!oc(t.output))}var Co="__root__",By=Symbol.for("langgraph.state.partial"),Vy=class extends S${channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=vf;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(e,t){super();let r=this._normalizeToStateGraphInit(e,t),n=r.state??r.stateSchema??r.input;if(!n)throw new gd;let i=this._getChannelsFromSchema(n);this._schemaDefinition=i,Bi.isInstance(n)?this._schemaRuntimeDefinition=n:Ir(n)&&(this._schemaRuntimeDefinition=n),r.input?Bi.isInstance(r.input)?this._inputRuntimeDefinition=r.input:Ir(r.input)?this._inputRuntimeDefinition=r.input:this._inputRuntimeDefinition=By:this._inputRuntimeDefinition=By,r.output?Bi.isInstance(r.output)?this._outputRuntimeDefinition=r.output:Ir(r.output)?this._outputRuntimeDefinition=r.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let o=r.input?this._getChannelsFromSchema(r.input):i,a=r.output?this._getChannelsFromSchema(r.output):i;this._inputDefinition=o,this._outputDefinition=a,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),r.context&&Ir(r.context)&&(this._configRuntimeSchema=r.context),this._interrupt=r.interrupt,this._writer=r.writer}_normalizeToStateGraphInit(e,t){if(wU(e)){if(Ir(t)||wy.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(oc(e)){if(Ir(t)||wy.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(bJ(e))return{state:vJ(e.channels)};throw new gd}_getChannelsFromSchema(e){if(Bi.isInstance(e))return e.getChannels();if(Ir(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 gd("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 n;if(typeof r=="function"?n=r():n=r,this.channels[t]!==void 0){if(!this.channels[t].equals(n)&&n.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=n}}}addNode(...e){function t(n){return n.length>=1&&typeof n[0]!="string"}let r=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([n,i])=>[n,i]):[[e[0],e[1],e[2]]];if(r.length===0)throw new Error("No nodes provided in `addNode`");for(let[n,i,o]of r){if(n in this.channels)throw new Error(`${n} 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(n.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."),n in this.nodes)throw new Error(`Node \`${n}\` already present.`);if(n==="__end__"||n==="__start__")throw new Error(`Node \`${n}\` is reserved.`);let a=this._schemaDefinition;o?.input!==void 0&&(a=this._getChannelsFromSchema(o.input)),this._addSchema(a);let s;pe.isRunnable(i)?s=i:typeof i=="function"?s=new ur({func:i,name:n,trace:!1}):s=yt(i);let c=o?.cachePolicy;typeof c=="boolean"&&(c=c?{}:void 0);let u={runnable:s,retryPolicy:o?.retryPolicy,cachePolicy:c,metadata:o?.metadata,input:a??this._schemaDefinition,subgraphs:mf(s)?[s]:o?.subgraphs,ends:o?.ends,defer:o?.defer};this.nodes[n]=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(n=>n===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[n,i,o]of t){if(n in this.nodes)throw new Error(`Node names must be unique: node with the name "${n}" already exists.`);let a=n;this.addNode(a,i,o),r!=null&&this.addEdge(r,a),r=a}return this}compile({checkpointer:e,store:t,cache:r,interruptBefore:n,interruptAfter:i,name:o,description:a}={}){this.validate([...Array.isArray(n)?n:[],...Array.isArray(i)?i:[]]);let s=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),c=s.length===1&&s[0]===Co?Co:s,u=Object.keys(this.channels),l=u.length===1&&u[0]===Co?Co:u,d=this._interrupt,f=new IU({builder:this,checkpointer:e,interruptAfter:i,interruptBefore:n,autoValidate:!1,nodes:{},channels:{...this.channels,[Ye]:new ti},inputChannels:Ye,outputChannels:c,streamChannels:l,streamMode:"updates",store:t,cache:r,name:o,description:a,userInterrupt:d});f.attachNode(Ye);for(let[p,m]of Object.entries(this.nodes))f.attachNode(p,m);f.attachBranch(Ye,Pv,xU(),{withReader:!1});for(let[p]of Object.entries(this.nodes))f.attachBranch(p,Pv,xU(),{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[h,w]of Object.entries(m))f.attachBranch(p,h,w);return f.validate()}};function vJ(e){let t={};for(let[r,n]of Object.entries(e))r===Co?t[r]=xy(n):t[r]=xy(n);return t}var IU=class extends k${description;_metaRegistry=vf;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 n(s){if(Nt(s))return s.graph===Ar.PARENT?null:s._updateAsTuples();if(Array.isArray(s)&&s.length>0&&s.some(c=>Nt(c))){let c=[];for(let u of s)if(Nt(u)){if(u.graph===Ar.PARENT)continue;c.push(...u._updateAsTuples())}else c.push([Co,u]);return c}else if(s!=null)return[[Co,s]];return null}let i=e;function o(s){if(s){if(Nt(s))return s.graph===Ar.PARENT?null:s._updateAsTuples().filter(([c])=>r.includes(c));if(Array.isArray(s)&&s.length>0&&s.some(Nt)){let c=[];for(let u of s)if(Nt(u)){if(u.graph===Ar.PARENT)continue;c.push(...u._updateAsTuples().filter(([l])=>r.includes(l)))}else{let l=o(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 Re(`Expected node "${i.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 a=[{value:Lr,mapper:new ur({func:r.length&&r[0]===Co?n:o,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new Qn({tags:[Tt],triggers:[Ye],channels:[Ye],writers:[new wt(a,[Tt])]});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&&Co in c,l=`branch:to:${e}`;this.channels[l]=t?.defer?new i$:new ti(!1),this.nodes[e]=new Qn({triggers:[l],channels:u?Object.keys(c):c,writers:[new wt(a,[Tt])],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 wt([{channel:`branch:to:${t}`,value:null}],[Tt]));else if(Array.isArray(e)){let r=`join:${e.join("+")}:${t}`;this.channels[r]=this.builder.nodes[t].defer?new T$(new Set(e)):new $$(new Set(e)),this.nodes[t].triggers.push(r);for(let n of e)this.nodes[n].writers.push(new wt([{channel:r,value:n}],[Tt]))}}}attachBranch(e,t,r,n={withReader:!0}){let i=async(o,a)=>{let s=o.filter(u=>u!==it);if(!s.length)return;let c=s.map(u=>At(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await wt.doWrite({...a,tags:(a.tags??[]).concat([Tt])},c)};this.nodes[e].writers.push(r.run(i,n.withReader?o=>TL.doRead(o,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(Bi.isInstance(t)){if(Nt(e)){let i=e;return e.update&&(i.update=await t.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await t.validateInput(e)}if(t===By&&Bi.isInstance(r)){if(Nt(e)){let i=e;return e.update&&(i.update=await r.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await r.validateInput(e)}let n=(()=>{let i=o=>{if(o!=null)return this._metaRegistry.getExtendedChannelSchemas(o,{withReducerSchema:!0})};if(Ir(t))return i(t);if(t===By)return Ir(r)?Cu(i(r)):void 0})();if(Nt(e)){let i=e;return e.update&&n!=null&&(i.update=Au(n,e.update)),i}return n!=null?Au(n,e):e}isInterrupted(e){return hd(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return Ir(t)&&Au(t,e),e}};function bJ(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function wJ(e){if(At(e))return[e];let t=[];Nt(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(Nt));let r=[];for(let n of t){if(n.graph===Ar.PARENT)throw new em(n);At(n.goto)||typeof n.goto=="string"?r.push(n.goto):Array.isArray(n.goto)&&r.push(...n.goto)}return r}function xU(){return new I$({path:new ur({func:wJ,tags:[Tt],trace:!1,recurse:!1,name:"<control_branch>"})})}var SU=function(t,r){let{name:n,checkpointer:i,store:o,cache:a}=typeof t=="string"?{name:t,checkpointer:void 0,store:void 0}:t;if(EL(r)||$L(r))throw new Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let s="updates",c=HL(n,r);function u(p){return typeof p=="object"&&p!==null&&"__lg_type"in p&&p.__lg_type==="__pregel_final"}let l=new ur({name:"pluckReturnValue",func:p=>u(p)?p.value:p}),d=new ur({name:"pluckSaveValue",func:p=>u(p)?p.save:p}),f=new Qn({bound:c,triggers:[Ye],channels:[Ye],writers:[new wt([{channel:it,value:Lr,mapper:l},{channel:ts,value:Lr,mapper:d}],[Tt])]});return new Uy({name:n,checkpointer:i,nodes:{[n]:f},channels:{[Ye]:new ti,[it]:new Jn,[ts]:new Jn},inputChannels:Ye,outputChannels:it,streamChannels:it,streamMode:s,store:o,cache:a})};SU.final=function({value:t,save:r}){return{value:t,save:r,__lg_type:"__pregel_final"}};var xJ=Xn.Root({messages:Xn({reducer:ic,default:()=>[]})}),kU={reducer:{fn:ic},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},IJ=Vt.object({messages:bU(Vt.custom(),kU)});async function C$(e,t,r){if(r===void 0)throw new Error(["Unable to dispatch a custom event without a parent run id.",'"dispatchCustomEvent" can only be called from within an existing run (e.g.,',"inside a tool or a RunnableLambda).",`
|
|
303
|
+
|
|
304
|
+
If you continue to see this error, please import from "@langchain/core/callbacks/dispatch/web"`,"and explicitly pass in a config parameter.",`
|
|
305
|
+
|
|
306
|
+
Or, if you are calling this from a custom tool, ensure you're using the "tool" helper constructor as documented here:`,`
|
|
307
|
+
|`,`
|
|
308
|
+
\u2514-> https://js.langchain.com/docs/how_to/custom_tools#tool-function`,`
|
|
309
|
+
`].join(" "));let n=await Ot(r),i=n?.getParentRunId();n!==void 0&&i!==void 0&&await n.handleCustomEvent?.(e,t,i)}var $n=M;function bf(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
310
|
+
|
|
311
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
312
|
+
`,e}function ue(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}function E(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}var P$=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return P$=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^r()&15>>+n/4).toString(16))};function wf(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}var xf=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){let t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};var Q=class extends Error{},Dt=class e extends Q{constructor(t,r,n,i){super(`${e.makeMessage(t,r,n)}`),this.status=t,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=r;let o=r;this.code=o?.code,this.param=o?.param,this.type=o?.type}static makeMessage(t,r,n){let i=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,r,n,i){if(!t||!i)return new Ma({message:n,cause:xf(r)});let o=r?.error;return t===400?new pl(t,o,n,i):t===401?new fl(t,o,n,i):t===403?new ml(t,o,n,i):t===404?new hl(t,o,n,i):t===409?new gl(t,o,n,i):t===422?new _l(t,o,n,i):t===429?new yl(t,o,n,i):t>=500?new vl(t,o,n,i):new e(t,o,n,i)}},xt=class extends Dt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}},Ma=class extends Dt{constructor({message:t,cause:r}){super(void 0,void 0,t||"Connection error.",void 0),r&&(this.cause=r)}},Vi=class extends Ma{constructor({message:t}={}){super({message:t??"Request timed out."})}},pl=class extends Dt{},fl=class extends Dt{},ml=class extends Dt{},hl=class extends Dt{},gl=class extends Dt{},_l=class extends Dt{},yl=class extends Dt{},vl=class extends Dt{},bl=class extends Q{constructor(){super("Could not parse response content as the length limit was reached")}},wl=class extends Q{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},Zi=class extends Error{constructor(t){super(t)}};var kJ=/^[a-z][a-z0-9+.-]*:/i,EU=e=>kJ.test(e),dr=e=>(dr=Array.isArray,dr(e)),R$=dr;function N$(e){return typeof e!="object"?{}:e??{}}function M$(e){if(!e)return!0;for(let t in e)return!1;return!0}function $U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function If(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}var TU=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new Q(`${e} must be an integer`);if(t<0)throw new Q(`${e} must be a positive integer`);return t};var AU=e=>{try{return JSON.parse(e)}catch{return}};var Gi=e=>new Promise(t=>setTimeout(t,e));var ja="6.32.0";var RU=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function EJ(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var $J=()=>{let e=EJ();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ja,"X-Stainless-OS":CU(Deno.build.os),"X-Stainless-Arch":OU(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ja,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ja,"X-Stainless-OS":CU(globalThis.process.platform??"unknown"),"X-Stainless-Arch":OU(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=TJ();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ja,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ja,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function TJ(){if(typeof navigator>"u"||!navigator)return null;let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:t,pattern:r}of e){let n=r.exec(navigator.userAgent);if(n){let i=n[1]||0,o=n[2]||0,a=n[3]||0;return{browser:t,version:`${i}.${o}.${a}`}}}return null}var OU=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",CU=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),PU,NU=()=>PU??(PU=$J());function MU(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function j$(...e){let t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Zy(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return j$({start(){},async pull(r){let{done:n,value:i}=await t.next();n?r.close():r.enqueue(i)},async cancel(){await t.return?.()}})}function z$(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let r=await t.read();return r?.done&&t.releaseLock(),r}catch(r){throw t.releaseLock(),r}},async return(){let r=t.cancel();return t.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function jU(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}var zU=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});var D$="RFC3986",L$=e=>String(e),U$={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:L$},DU="RFC1738";var Gy=(e,t)=>(Gy=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Gy(e,t)),Hi=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var F$=1024,LU=(e,t,r,n,i)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),r==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(s){return"%26%23"+parseInt(s.slice(2),16)+"%3B"});let a="";for(let s=0;s<o.length;s+=F$){let c=o.length>=F$?o.slice(s,s+F$):o,u=[];for(let l=0;l<c.length;++l){let d=c.charCodeAt(l);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||i===DU&&(d===40||d===41)){u[u.length]=c.charAt(l);continue}if(d<128){u[u.length]=Hi[d];continue}if(d<2048){u[u.length]=Hi[192|d>>6]+Hi[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=Hi[224|d>>12]+Hi[128|d>>6&63]+Hi[128|d&63];continue}l+=1,d=65536+((d&1023)<<10|c.charCodeAt(l)&1023),u[u.length]=Hi[240|d>>18]+Hi[128|d>>12&63]+Hi[128|d>>6&63]+Hi[128|d&63]}a+=u.join("")}return a};function UU(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function B$(e,t){if(dr(e)){let r=[];for(let n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)}var BU={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},VU=function(e,t){Array.prototype.push.apply(e,dr(t)?t:[t])},FU,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:LU,encodeValuesOnly:!1,format:D$,formatter:L$,indices:!1,serializeDate(e){return(FU??(FU=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function CJ(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var V$={};function ZU(e,t,r,n,i,o,a,s,c,u,l,d,f,p,m,h,w,_){let y=e,x=_,S=0,$=!1;for(;(x=x.get(V$))!==void 0&&!$;){let R=x.get(e);if(S+=1,typeof R<"u"){if(R===S)throw new RangeError("Cyclic object value");$=!0}typeof x.get(V$)>"u"&&(S=0)}if(typeof u=="function"?y=u(t,y):y instanceof Date?y=f?.(y):r==="comma"&&dr(y)&&(y=B$(y,function(R){return R instanceof Date?f?.(R):R})),y===null){if(o)return c&&!h?c(t,Lt.encoder,w,"key",p):t;y=""}if(CJ(y)||UU(y)){if(c){let R=h?t:c(t,Lt.encoder,w,"key",p);return[m?.(R)+"="+m?.(c(y,Lt.encoder,w,"value",p))]}return[m?.(t)+"="+m?.(String(y))]}let j=[];if(typeof y>"u")return j;let C;if(r==="comma"&&dr(y))h&&c&&(y=B$(y,c)),C=[{value:y.length>0?y.join(",")||null:void 0}];else if(dr(u))C=u;else{let R=Object.keys(y);C=l?R.sort(l):R}let b=s?String(t).replace(/\./g,"%2E"):String(t),H=n&&dr(y)&&y.length===1?b+"[]":b;if(i&&dr(y)&&y.length===0)return H+"[]";for(let R=0;R<C.length;++R){let V=C[R],xe=typeof V=="object"&&typeof V.value<"u"?V.value:y[V];if(a&&xe===null)continue;let Ge=d&&s?V.replace(/\./g,"%2E"):V,qt=dr(y)?typeof r=="function"?r(H,Ge):H:H+(d?"."+Ge:"["+Ge+"]");_.set(e,S);let Fr=new WeakMap;Fr.set(V$,_),VU(j,ZU(xe,qt,r,n,i,o,a,s,r==="comma"&&h&&dr(y)?null:c,u,l,d,f,p,m,h,w,Fr))}return j}function PJ(e=Lt){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||Lt.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=D$;if(typeof e.format<"u"){if(!Gy(U$,e.format))throw new TypeError("Unknown format option provided.");r=e.format}let n=U$[r],i=Lt.filter;(typeof e.filter=="function"||dr(e.filter))&&(i=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in BU?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:Lt.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?Lt.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Lt.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:Lt.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Lt.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Lt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Lt.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Lt.strictNullHandling}}function GU(e,t={}){let r=e,n=PJ(t),i,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):dr(n.filter)&&(o=n.filter,i=o);let a=[];if(typeof r!="object"||r===null)return"";let s=BU[n.arrayFormat],c=s==="comma"&&n.commaRoundTrip;i||(i=Object.keys(r)),n.sort&&i.sort(n.sort);let u=new WeakMap;for(let f=0;f<i.length;++f){let p=i[f];n.skipNulls&&r[p]===null||VU(a,ZU(r[p],p,s,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}let l=a.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}function HU(e){return GU(e,{arrayFormat:"brackets"})}function WU(e){let t=0;for(let i of e)t+=i.length;let r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}var qU;function xl(e){let t;return(qU??(t=new globalThis.TextEncoder,qU=t.encode.bind(t)))(e)}var KU;function Z$(e){let t;return(KU??(t=new globalThis.TextDecoder,KU=t.decode.bind(t)))(e)}var nn,on,ac=class{constructor(){nn.set(this,void 0),on.set(this,void 0),ue(this,nn,new Uint8Array,"f"),ue(this,on,null,"f")}decode(t){if(t==null)return[];let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?xl(t):t;ue(this,nn,WU([E(this,nn,"f"),r]),"f");let n=[],i;for(;(i=NJ(E(this,nn,"f"),E(this,on,"f")))!=null;){if(i.carriage&&E(this,on,"f")==null){ue(this,on,i.index,"f");continue}if(E(this,on,"f")!=null&&(i.index!==E(this,on,"f")+1||i.carriage)){n.push(Z$(E(this,nn,"f").subarray(0,E(this,on,"f")-1))),ue(this,nn,E(this,nn,"f").subarray(E(this,on,"f")),"f"),ue(this,on,null,"f");continue}let o=E(this,on,"f")!==null?i.preceding-1:i.preceding,a=Z$(E(this,nn,"f").subarray(0,o));n.push(a),ue(this,nn,E(this,nn,"f").subarray(i.index),"f"),ue(this,on,null,"f")}return n}flush(){return E(this,nn,"f").length?this.decode(`
|
|
313
|
+
`):[]}};nn=new WeakMap,on=new WeakMap;ac.NEWLINE_CHARS=new Set([`
|
|
314
|
+
`,"\r"]);ac.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function NJ(e,t){for(let i=t??0;i<e.length;i++){if(e[i]===10)return{preceding:i,index:i+1,carriage:!1};if(e[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}function JU(e){for(let n=0;n<e.length-1;n++){if(e[n]===10&&e[n+1]===10||e[n]===13&&e[n+1]===13)return n+2;if(e[n]===13&&e[n+1]===10&&n+3<e.length&&e[n+2]===13&&e[n+3]===10)return n+4}return-1}var qy={off:0,error:200,warn:300,info:400,debug:500},G$=(e,t,r)=>{if(e){if($U(qy,e))return e;$t(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(qy))}`)}};function Sf(){}function Hy(e,t,r){return!t||qy[e]>qy[r]?Sf:t[e].bind(t)}var MJ={error:Sf,warn:Sf,info:Sf,debug:Sf},XU=new WeakMap;function $t(e){let t=e.logger,r=e.logLevel??"off";if(!t)return MJ;let n=XU.get(t);if(n&&n[0]===r)return n[1];let i={error:Hy("error",t,r),warn:Hy("warn",t,r),info:Hy("info",t,r),debug:Hy("debug",t,r)};return XU.set(t,[r,i]),i}var Po=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,r])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":r]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var kf,qi=class e{constructor(t,r,n){this.iterator=t,kf.set(this,void 0),this.controller=r,ue(this,kf,n,"f")}static fromSSEResponse(t,r,n,i){let o=!1,a=n?$t(n):console;async function*s(){if(o)throw new Q("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");o=!0;let c=!1;try{for await(let u of jJ(t,r))if(!c){if(u.data.startsWith("[DONE]")){c=!0;continue}if(u.event===null||!u.event.startsWith("thread.")){let l;try{l=JSON.parse(u.data)}catch(d){throw a.error("Could not parse message into JSON:",u.data),a.error("From chunk:",u.raw),d}if(l&&l.error)throw new Dt(void 0,l.error,void 0,t.headers);yield i?{event:u.event,data:l}:l}else{let l;try{l=JSON.parse(u.data)}catch(d){throw console.error("Could not parse message into JSON:",u.data),console.error("From chunk:",u.raw),d}if(u.event=="error")throw new Dt(void 0,l.error,l.message,void 0);yield{event:u.event,data:l}}}c=!0}catch(u){if(wf(u))return;throw u}finally{c||r.abort()}}return new e(s,r,n)}static fromReadableStream(t,r,n){let i=!1;async function*o(){let s=new ac,c=z$(t);for await(let u of c)for(let l of s.decode(u))yield l;for(let u of s.flush())yield u}async function*a(){if(i)throw new Q("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let s=!1;try{for await(let c of o())s||c&&(yield JSON.parse(c));s=!0}catch(c){if(wf(c))return;throw c}finally{s||r.abort()}}return new e(a,r,n)}[(kf=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],r=[],n=this.iterator(),i=o=>({next:()=>{if(o.length===0){let a=n.next();t.push(a),r.push(a)}return o.shift()}});return[new e(()=>i(t),this.controller,E(this,kf,"f")),new e(()=>i(r),this.controller,E(this,kf,"f"))]}toReadableStream(){let t=this,r;return j$({async start(){r=t[Symbol.asyncIterator]()},async pull(n){try{let{value:i,done:o}=await r.next();if(o)return n.close();let a=xl(JSON.stringify(i)+`
|
|
315
|
+
`);n.enqueue(a)}catch(i){n.error(i)}},async cancel(){await r.return?.()}})}};async function*jJ(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Q("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new Q("Attempted to iterate over a response with no body");let r=new H$,n=new ac,i=z$(e.body);for await(let o of zJ(i))for(let a of n.decode(o)){let s=r.decode(a);s&&(yield s)}for(let o of n.flush()){let a=r.decode(o);a&&(yield a)}}async function*zJ(e){let t=new Uint8Array;for await(let r of e){if(r==null)continue;let n=r instanceof ArrayBuffer?new Uint8Array(r):typeof r=="string"?xl(r):r,i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),t=i;let o;for(;(o=JU(t))!==-1;)yield t.slice(0,o),t=t.slice(o)}t.length>0&&(yield t)}var H$=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
316
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,n,i]=DJ(t,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};function DJ(e,t){let r=e.indexOf(t);return r!==-1?[e.substring(0,r),t,e.substring(r+t.length)]:[e,"",""]}async function Ky(e,t){let{response:r,requestLogID:n,retryOfRequestLogID:i,startTime:o}=t,a=await(async()=>{if(t.options.stream)return $t(e).debug("response",r.status,r.url,r.headers,r.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(r,t.controller,e,t.options.__synthesizeEventData):qi.fromSSEResponse(r,t.controller,e,t.options.__synthesizeEventData);if(r.status===204)return null;if(t.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(r.headers.get("content-length")==="0")return;let f=await r.json();return q$(f,r)}return await r.text()})();return $t(e).debug(`[${n}] response parsed`,Po({retryOfRequestLogID:i,url:r.url,status:r.status,body:a,durationMs:Date.now()-o})),a}function q$(e,t){return!e||typeof e!="object"||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}var Ef,sc=class e extends Promise{constructor(t,r,n=Ky){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=n,Ef.set(this,void 0),ue(this,Ef,t,"f")}_thenUnwrap(t){return new e(E(this,Ef,"f"),this.responsePromise,async(r,n)=>q$(t(await this.parseResponse(r,n),n),n.response))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r,request_id:r.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(E(this,Ef,"f"),t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};Ef=new WeakMap;var Wy,$f=class{constructor(t,r,n,i){Wy.set(this,void 0),ue(this,Wy,t,"f"),this.options=i,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let t=this.nextPageRequestOptions();if(!t)throw new Q("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await E(this,Wy,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(Wy=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let r of t.getPaginatedItems())yield r}},Tf=class extends sc{constructor(t,r,n){super(t,r,async(i,o)=>new n(i,o.response,await Ky(i,o),o.options))}async*[Symbol.asyncIterator](){let t=await this;for await(let r of t)yield r}},Ki=class extends $f{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},ke=class extends $f{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.getPaginatedItems(),r=t[t.length-1]?.id;return r?{...this.options,query:{...N$(this.options.query),after:r}}:null}},ri=class extends $f{constructor(t,r,n,i){super(t,r,n,i),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.last_id;return t?{...this.options,query:{...N$(this.options.query),after:t}}:null}};var J$=()=>{if(typeof File>"u"){let{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Il(e,t,r){return J$(),new File(e,t??"unknown_file",r)}function Af(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}var Jy=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function",za=async(e,t)=>K$(e.body)?{...e,body:await QU(e.body,t)}:e,pr=async(e,t)=>({...e,body:await QU(e.body,t)}),YU=new WeakMap;function UJ(e){let t=typeof e=="function"?e:e.fetch,r=YU.get(t);if(r)return r;let n=(async()=>{try{let i="Response"in t?t.Response:(await t("data:,")).constructor,o=new FormData;return o.toString()!==await new i(o).text()}catch{return!0}})();return YU.set(t,n),n}var QU=async(e,t)=>{if(!await UJ(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;return await Promise.all(Object.entries(e||{}).map(([n,i])=>W$(r,n,i))),r},e2=e=>e instanceof Blob&&"name"in e,FJ=e=>typeof e=="object"&&e!==null&&(e instanceof Response||Jy(e)||e2(e)),K$=e=>{if(FJ(e))return!0;if(Array.isArray(e))return e.some(K$);if(e&&typeof e=="object"){for(let t in e)if(K$(e[t]))return!0}return!1},W$=async(e,t,r)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")e.append(t,String(r));else if(r instanceof Response)e.append(t,Il([await r.blob()],Af(r)));else if(Jy(r))e.append(t,Il([await new Response(Zy(r)).blob()],Af(r)));else if(e2(r))e.append(t,r,Af(r));else if(Array.isArray(r))await Promise.all(r.map(n=>W$(e,t+"[]",n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([n,i])=>W$(e,`${t}[${n}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}};var t2=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",BJ=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&t2(e),VJ=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function Of(e,t,r){if(J$(),e=await e,BJ(e))return e instanceof File?e:Il([await e.arrayBuffer()],e.name);if(VJ(e)){let i=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Il(await X$(i),t,r)}let n=await X$(e);if(t||(t=Af(e)),!r?.type){let i=n.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof i=="string"&&(r={...r,type:i})}return Il(n,t,r)}async function X$(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(t2(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Jy(e))for await(let r of e)t.push(...await X$(r));else{let r=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${ZJ(e)}`)}return t}function ZJ(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(r=>`"${r}"`).join(", ")}]`}var N=class{constructor(t){this._client=t}};function n2(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var r2=Object.freeze(Object.create(null)),HJ=(e=n2)=>function(r,...n){if(r.length===1)return r[0];let i=!1,o=[],a=r.reduce((l,d,f)=>{/[?#]/.test(d)&&(i=!0);let p=n[f],m=(i?encodeURIComponent:e)(""+p);return f!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??r2)??r2)?.toString)&&(m=p+"",o.push({start:l.length+d.length,length:m.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),l+d+(f===n.length?"":m)},""),s=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,u;for(;(u=c.exec(s))!==null;)o.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(o.sort((l,d)=>l.start-d.start),o.length>0){let l=0,d=o.reduce((f,p)=>{let m=" ".repeat(p.start-l),h="^".repeat(p.length);return l=p.start+p.length,f+m+h},"");throw new Q(`Path parameters result in path with invalid segments:
|
|
317
|
+
${o.map(f=>f.error).join(`
|
|
318
|
+
`)}
|
|
319
|
+
${a}
|
|
320
|
+
${d}`)}return a},T=HJ(n2);var cc=class extends N{list(t,r={},n){return this._client.getAPIList(T`/chat/completions/${t}/messages`,ke,{query:r,...n})}};function Cf(e){return e!==void 0&&"function"in e&&e.function!==void 0}function i2(e,t){let r={...e};return Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}function Pf(e){return e?.$brand==="auto-parseable-response-format"}function uc(e){return e?.$brand==="auto-parseable-tool"}function o2(e,t){return!t||!Y$(t)?{...e,choices:e.choices.map(r=>(s2(r.message.tool_calls),{...r,message:{...r.message,parsed:null,...r.message.tool_calls?{tool_calls:r.message.tool_calls}:void 0}}))}:Rf(e,t)}function Rf(e,t){let r=e.choices.map(n=>{if(n.finish_reason==="length")throw new bl;if(n.finish_reason==="content_filter")throw new wl;return s2(n.message.tool_calls),{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:n.message.tool_calls?.map(i=>JJ(t,i))??void 0}:void 0,parsed:n.message.content&&!n.message.refusal?WJ(t,n.message.content):null}}});return{...e,choices:r}}function WJ(e,t){return e.response_format?.type!=="json_schema"?null:e.response_format?.type==="json_schema"?"$parseRaw"in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}function JJ(e,t){let r=e.tools?.find(n=>Cf(n)&&n.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:uc(r)?r.$parseRaw(t.function.arguments):r?.function.strict?JSON.parse(t.function.arguments):null}}}function a2(e,t){if(!e||!("tools"in e)||!e.tools)return!1;let r=e.tools?.find(n=>Cf(n)&&n.function?.name===t.function.name);return Cf(r)&&(uc(r)||r?.function.strict||!1)}function Y$(e){return Pf(e.response_format)?!0:e.tools?.some(t=>uc(t)||t.type==="function"&&t.function.strict===!0)??!1}function s2(e){for(let t of e||[])if(t.type!=="function")throw new Q(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}function c2(e){for(let t of e??[]){if(t.type!=="function")throw new Q(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new Q(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var Sl=e=>e?.role==="assistant",Q$=e=>e?.role==="tool";var eT,Xy,Yy,Nf,Mf,Qy,jf,Ro,zf,ev,tv,kl,u2,Da=class{constructor(){eT.add(this),this.controller=new AbortController,Xy.set(this,void 0),Yy.set(this,()=>{}),Nf.set(this,()=>{}),Mf.set(this,void 0),Qy.set(this,()=>{}),jf.set(this,()=>{}),Ro.set(this,{}),zf.set(this,!1),ev.set(this,!1),tv.set(this,!1),kl.set(this,!1),ue(this,Xy,new Promise((t,r)=>{ue(this,Yy,t,"f"),ue(this,Nf,r,"f")}),"f"),ue(this,Mf,new Promise((t,r)=>{ue(this,Qy,t,"f"),ue(this,jf,r,"f")}),"f"),E(this,Xy,"f").catch(()=>{}),E(this,Mf,"f").catch(()=>{})}_run(t){setTimeout(()=>{t().then(()=>{this._emitFinal(),this._emit("end")},E(this,eT,"m",u2).bind(this))},0)}_connected(){this.ended||(E(this,Yy,"f").call(this),this._emit("connect"))}get ended(){return E(this,zf,"f")}get errored(){return E(this,ev,"f")}get aborted(){return E(this,tv,"f")}abort(){this.controller.abort()}on(t,r){return(E(this,Ro,"f")[t]||(E(this,Ro,"f")[t]=[])).push({listener:r}),this}off(t,r){let n=E(this,Ro,"f")[t];if(!n)return this;let i=n.findIndex(o=>o.listener===r);return i>=0&&n.splice(i,1),this}once(t,r){return(E(this,Ro,"f")[t]||(E(this,Ro,"f")[t]=[])).push({listener:r,once:!0}),this}emitted(t){return new Promise((r,n)=>{ue(this,kl,!0,"f"),t!=="error"&&this.once("error",n),this.once(t,r)})}async done(){ue(this,kl,!0,"f"),await E(this,Mf,"f")}_emit(t,...r){if(E(this,zf,"f"))return;t==="end"&&(ue(this,zf,!0,"f"),E(this,Qy,"f").call(this));let n=E(this,Ro,"f")[t];if(n&&(E(this,Ro,"f")[t]=n.filter(i=>!i.once),n.forEach(({listener:i})=>i(...r))),t==="abort"){let i=r[0];!E(this,kl,"f")&&!n?.length&&Promise.reject(i),E(this,Nf,"f").call(this,i),E(this,jf,"f").call(this,i),this._emit("end");return}if(t==="error"){let i=r[0];!E(this,kl,"f")&&!n?.length&&Promise.reject(i),E(this,Nf,"f").call(this,i),E(this,jf,"f").call(this,i),this._emit("end")}}_emitFinal(){}};Xy=new WeakMap,Yy=new WeakMap,Nf=new WeakMap,Mf=new WeakMap,Qy=new WeakMap,jf=new WeakMap,Ro=new WeakMap,zf=new WeakMap,ev=new WeakMap,tv=new WeakMap,kl=new WeakMap,eT=new WeakSet,u2=function(t){if(ue(this,ev,!0,"f"),t instanceof Error&&t.name==="AbortError"&&(t=new xt),t instanceof xt)return ue(this,tv,!0,"f"),this._emit("abort",t);if(t instanceof Q)return this._emit("error",t);if(t instanceof Error){let r=new Q(t.message);return r.cause=t,this._emit("error",r)}return this._emit("error",new Q(String(t)))};function l2(e){return typeof e.parse=="function"}var $r,tT,rv,rT,nT,iT,d2,p2,XJ=10,El=class extends Da{constructor(){super(...arguments),$r.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(t){this._chatCompletions.push(t),this._emit("chatCompletion",t);let r=t.choices[0]?.message;return r&&this._addMessage(r),t}_addMessage(t,r=!0){if("content"in t||(t.content=null),this.messages.push(t),r){if(this._emit("message",t),Q$(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(Sl(t)&&t.tool_calls)for(let n of t.tool_calls)n.type==="function"&&this._emit("functionToolCall",n.function)}}async finalChatCompletion(){await this.done();let t=this._chatCompletions[this._chatCompletions.length-1];if(!t)throw new Q("stream ended without producing a ChatCompletion");return t}async finalContent(){return await this.done(),E(this,$r,"m",tT).call(this)}async finalMessage(){return await this.done(),E(this,$r,"m",rv).call(this)}async finalFunctionToolCall(){return await this.done(),E(this,$r,"m",rT).call(this)}async finalFunctionToolCallResult(){return await this.done(),E(this,$r,"m",nT).call(this)}async totalUsage(){return await this.done(),E(this,$r,"m",iT).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let t=this._chatCompletions[this._chatCompletions.length-1];t&&this._emit("finalChatCompletion",t);let r=E(this,$r,"m",rv).call(this);r&&this._emit("finalMessage",r);let n=E(this,$r,"m",tT).call(this);n&&this._emit("finalContent",n);let i=E(this,$r,"m",rT).call(this);i&&this._emit("finalFunctionToolCall",i);let o=E(this,$r,"m",nT).call(this);o!=null&&this._emit("finalFunctionToolCallResult",o),this._chatCompletions.some(a=>a.usage)&&this._emit("totalUsage",E(this,$r,"m",iT).call(this))}async _createChatCompletion(t,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),E(this,$r,"m",d2).call(this,r);let o=await t.chat.completions.create({...r,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Rf(o,r))}async _runChatCompletion(t,r,n){for(let i of r.messages)this._addMessage(i,!1);return await this._createChatCompletion(t,r,n)}async _runTools(t,r,n){let i="tool",{tool_choice:o="auto",stream:a,...s}=r,c=typeof o!="string"&&o.type==="function"&&o?.function?.name,{maxChatCompletions:u=XJ}=n||{},l=r.tools.map(p=>{if(uc(p)){if(!p.$callback)throw new Q("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:p.$callback,name:p.function.name,description:p.function.description||"",parameters:p.function.parameters,parse:p.$parseRaw,strict:!0}}}return p}),d={};for(let p of l)p.type==="function"&&(d[p.function.name||p.function.function.name]=p.function);let f="tools"in r?l.map(p=>p.type==="function"?{type:"function",function:{name:p.function.name||p.function.function.name,parameters:p.function.parameters,description:p.function.description,strict:p.function.strict}}:p):void 0;for(let p of r.messages)this._addMessage(p,!1);for(let p=0;p<u;++p){let h=(await this._createChatCompletion(t,{...s,tool_choice:o,tools:f,messages:[...this.messages]},n)).choices[0]?.message;if(!h)throw new Q("missing message in ChatCompletion response");if(!h.tool_calls?.length)return;for(let w of h.tool_calls){if(w.type!=="function")continue;let _=w.id,{name:y,arguments:x}=w.function,S=d[y];if(S){if(c&&c!==y){let b=`Invalid tool_call: ${JSON.stringify(y)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:_,content:b});continue}}else{let b=`Invalid tool_call: ${JSON.stringify(y)}. Available options are: ${Object.keys(d).map(H=>JSON.stringify(H)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:_,content:b});continue}let $;try{$=l2(S)?await S.parse(x):x}catch(b){let H=b instanceof Error?b.message:String(b);this._addMessage({role:i,tool_call_id:_,content:H});continue}let j=await S.function($,this),C=E(this,$r,"m",p2).call(this,j);if(this._addMessage({role:i,tool_call_id:_,content:C}),c)return}}}};$r=new WeakSet,tT=function(){return E(this,$r,"m",rv).call(this).content??null},rv=function(){let t=this.messages.length;for(;t-- >0;){let r=this.messages[t];if(Sl(r))return{...r,content:r.content??null,refusal:r.refusal??null}}throw new Q("stream ended without producing a ChatCompletionMessage with role=assistant")},rT=function(){for(let t=this.messages.length-1;t>=0;t--){let r=this.messages[t];if(Sl(r)&&r?.tool_calls?.length)return r.tool_calls.filter(n=>n.type==="function").at(-1)?.function}},nT=function(){for(let t=this.messages.length-1;t>=0;t--){let r=this.messages[t];if(Q$(r)&&r.content!=null&&typeof r.content=="string"&&this.messages.some(n=>n.role==="assistant"&&n.tool_calls?.some(i=>i.type==="function"&&i.id===r.tool_call_id)))return r.content}},iT=function(){let t={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:r}of this._chatCompletions)r&&(t.completion_tokens+=r.completion_tokens,t.prompt_tokens+=r.prompt_tokens,t.total_tokens+=r.total_tokens);return t},d2=function(t){if(t.n!=null&&t.n>1)throw new Q("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},p2=function(t){return typeof t=="string"?t:t===void 0?"undefined":JSON.stringify(t)};var Df=class e extends El{static runTools(t,r,n){let i=new e,o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(t,r,o)),i}_addMessage(t,r=!0){super._addMessage(t,r),Sl(t)&&t.content&&this._emit("content",t.content)}};var Ht={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},oT=class extends Error{},aT=class extends Error{};function YJ(e,t=Ht.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return QJ(e.trim(),t)}var QJ=(e,t)=>{let r=e.length,n=0,i=f=>{throw new oT(`${f} at position ${n}`)},o=f=>{throw new aT(`${f} at position ${n}`)},a=()=>(d(),n>=r&&i("Unexpected end of input"),e[n]==='"'?s():e[n]==="{"?c():e[n]==="["?u():e.substring(n,n+4)==="null"||Ht.NULL&t&&r-n<4&&"null".startsWith(e.substring(n))?(n+=4,null):e.substring(n,n+4)==="true"||Ht.BOOL&t&&r-n<4&&"true".startsWith(e.substring(n))?(n+=4,!0):e.substring(n,n+5)==="false"||Ht.BOOL&t&&r-n<5&&"false".startsWith(e.substring(n))?(n+=5,!1):e.substring(n,n+8)==="Infinity"||Ht.INFINITY&t&&r-n<8&&"Infinity".startsWith(e.substring(n))?(n+=8,1/0):e.substring(n,n+9)==="-Infinity"||Ht.MINUS_INFINITY&t&&1<r-n&&r-n<9&&"-Infinity".startsWith(e.substring(n))?(n+=9,-1/0):e.substring(n,n+3)==="NaN"||Ht.NAN&t&&r-n<3&&"NaN".startsWith(e.substring(n))?(n+=3,NaN):l()),s=()=>{let f=n,p=!1;for(n++;n<r&&(e[n]!=='"'||p&&e[n-1]==="\\");)p=e[n]==="\\"?!p:!1,n++;if(e.charAt(n)=='"')try{return JSON.parse(e.substring(f,++n-Number(p)))}catch(m){o(String(m))}else if(Ht.STR&t)try{return JSON.parse(e.substring(f,n-Number(p))+'"')}catch{return JSON.parse(e.substring(f,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{n++,d();let f={};try{for(;e[n]!=="}";){if(d(),n>=r&&Ht.OBJ&t)return f;let p=s();d(),n++;try{let m=a();Object.defineProperty(f,p,{value:m,writable:!0,enumerable:!0,configurable:!0})}catch(m){if(Ht.OBJ&t)return f;throw m}d(),e[n]===","&&n++}}catch{if(Ht.OBJ&t)return f;i("Expected '}' at end of object")}return n++,f},u=()=>{n++;let f=[];try{for(;e[n]!=="]";)f.push(a()),d(),e[n]===","&&n++}catch{if(Ht.ARR&t)return f;i("Expected ']' at end of array")}return n++,f},l=()=>{if(n===0){e==="-"&&Ht.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e)}catch(p){if(Ht.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}o(String(p))}}let f=n;for(e[n]==="-"&&n++;e[n]&&!",]}".includes(e[n]);)n++;n==r&&!(Ht.NUM&t)&&i("Unterminated number literal");try{return JSON.parse(e.substring(f,n))}catch{e.substring(f,n)==="-"&&Ht.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e.substring(f,e.lastIndexOf("e")))}catch(m){o(String(m))}}},d=()=>{for(;n<r&&`
|
|
321
|
+
\r `.includes(e[n]);)n++};return a()},sT=e=>YJ(e,Ht.ALL^Ht.NUM);var Ut,No,$l,La,cT,nv,uT,lT,dT,iv,pT,f2,lc=class e extends El{constructor(t){super(),Ut.add(this),No.set(this,void 0),$l.set(this,void 0),La.set(this,void 0),ue(this,No,t,"f"),ue(this,$l,[],"f")}get currentChatCompletionSnapshot(){return E(this,La,"f")}static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}static createChatCompletion(t,r,n){let i=new e(r);return i._run(()=>i._runChatCompletion(t,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createChatCompletion(t,r,n){super._createChatCompletion;let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),E(this,Ut,"m",cT).call(this);let o=await t.chat.completions.create({...r,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let a of o)E(this,Ut,"m",uT).call(this,a);if(o.controller.signal?.aborted)throw new xt;return this._addChatCompletion(E(this,Ut,"m",iv).call(this))}async _fromReadableStream(t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),E(this,Ut,"m",cT).call(this),this._connected();let i=qi.fromReadableStream(t,this.controller),o;for await(let a of i)o&&o!==a.id&&this._addChatCompletion(E(this,Ut,"m",iv).call(this)),E(this,Ut,"m",uT).call(this,a),o=a.id;if(i.controller.signal?.aborted)throw new xt;return this._addChatCompletion(E(this,Ut,"m",iv).call(this))}[(No=new WeakMap,$l=new WeakMap,La=new WeakMap,Ut=new WeakSet,cT=function(){this.ended||ue(this,La,void 0,"f")},nv=function(r){let n=E(this,$l,"f")[r.index];return n||(n={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},E(this,$l,"f")[r.index]=n,n)},uT=function(r){if(this.ended)return;let n=E(this,Ut,"m",f2).call(this,r);this._emit("chunk",r,n);for(let i of r.choices){let o=n.choices[i.index];i.delta.content!=null&&o.message?.role==="assistant"&&o.message?.content&&(this._emit("content",i.delta.content,o.message.content),this._emit("content.delta",{delta:i.delta.content,snapshot:o.message.content,parsed:o.message.parsed})),i.delta.refusal!=null&&o.message?.role==="assistant"&&o.message?.refusal&&this._emit("refusal.delta",{delta:i.delta.refusal,snapshot:o.message.refusal}),i.logprobs?.content!=null&&o.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:i.logprobs?.content,snapshot:o.logprobs?.content??[]}),i.logprobs?.refusal!=null&&o.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:i.logprobs?.refusal,snapshot:o.logprobs?.refusal??[]});let a=E(this,Ut,"m",nv).call(this,o);o.finish_reason&&(E(this,Ut,"m",dT).call(this,o),a.current_tool_call_index!=null&&E(this,Ut,"m",lT).call(this,o,a.current_tool_call_index));for(let s of i.delta.tool_calls??[])a.current_tool_call_index!==s.index&&(E(this,Ut,"m",dT).call(this,o),a.current_tool_call_index!=null&&E(this,Ut,"m",lT).call(this,o,a.current_tool_call_index)),a.current_tool_call_index=s.index;for(let s of i.delta.tool_calls??[]){let c=o.message.tool_calls?.[s.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:s.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:s.function?.arguments??""}):(c?.type,void 0))}}},lT=function(r,n){if(E(this,Ut,"m",nv).call(this,r).done_tool_calls.has(n))return;let o=r.message.tool_calls?.[n];if(!o)throw new Error("no tool call snapshot");if(!o.type)throw new Error("tool call snapshot missing `type`");if(o.type==="function"){let a=E(this,No,"f")?.tools?.find(s=>Cf(s)&&s.function.name===o.function.name);this._emit("tool_calls.function.arguments.done",{name:o.function.name,index:n,arguments:o.function.arguments,parsed_arguments:uc(a)?a.$parseRaw(o.function.arguments):a?.function.strict?JSON.parse(o.function.arguments):null})}else o.type},dT=function(r){let n=E(this,Ut,"m",nv).call(this,r);if(r.message.content&&!n.content_done){n.content_done=!0;let i=E(this,Ut,"m",pT).call(this);this._emit("content.done",{content:r.message.content,parsed:i?i.$parseRaw(r.message.content):null})}r.message.refusal&&!n.refusal_done&&(n.refusal_done=!0,this._emit("refusal.done",{refusal:r.message.refusal})),r.logprobs?.content&&!n.logprobs_content_done&&(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:r.logprobs.content})),r.logprobs?.refusal&&!n.logprobs_refusal_done&&(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:r.logprobs.refusal}))},iv=function(){if(this.ended)throw new Q("stream has ended, this shouldn't happen");let r=E(this,La,"f");if(!r)throw new Q("request ended without sending any chunks");return ue(this,La,void 0,"f"),ue(this,$l,[],"f"),e7(r,E(this,No,"f"))},pT=function(){let r=E(this,No,"f")?.response_format;return Pf(r)?r:null},f2=function(r){var n,i,o,a;let s=E(this,La,"f"),{choices:c,...u}=r;s?Object.assign(s,u):s=ue(this,La,{...u,choices:[]},"f");for(let{delta:l,finish_reason:d,index:f,logprobs:p=null,...m}of r.choices){let h=s.choices[f];if(h||(h=s.choices[f]={finish_reason:d,index:f,message:{},logprobs:p,...m}),p)if(!h.logprobs)h.logprobs=Object.assign({},p);else{let{content:j,refusal:C,...b}=p;Object.assign(h.logprobs,b),j&&((n=h.logprobs).content??(n.content=[]),h.logprobs.content.push(...j)),C&&((i=h.logprobs).refusal??(i.refusal=[]),h.logprobs.refusal.push(...C))}if(d&&(h.finish_reason=d,E(this,No,"f")&&Y$(E(this,No,"f")))){if(d==="length")throw new bl;if(d==="content_filter")throw new wl}if(Object.assign(h,m),!l)continue;let{content:w,refusal:_,function_call:y,role:x,tool_calls:S,...$}=l;if(Object.assign(h.message,$),_&&(h.message.refusal=(h.message.refusal||"")+_),x&&(h.message.role=x),y&&(h.message.function_call?(y.name&&(h.message.function_call.name=y.name),y.arguments&&((o=h.message.function_call).arguments??(o.arguments=""),h.message.function_call.arguments+=y.arguments)):h.message.function_call=y),w&&(h.message.content=(h.message.content||"")+w,!h.message.refusal&&E(this,Ut,"m",pT).call(this)&&(h.message.parsed=sT(h.message.content))),S){h.message.tool_calls||(h.message.tool_calls=[]);for(let{index:j,id:C,type:b,function:H,...R}of S){let V=(a=h.message.tool_calls)[j]??(a[j]={});Object.assign(V,R),C&&(V.id=C),b&&(V.type=b),H&&(V.function??(V.function={name:H.name??"",arguments:""})),H?.name&&(V.function.name=H.name),H?.arguments&&(V.function.arguments+=H.arguments,a2(E(this,No,"f"),V)&&(V.function.parsed_arguments=sT(V.function.arguments)))}}}return s},Symbol.asyncIterator)](){let t=[],r=[],n=!1;return this.on("chunk",i=>{let o=r.shift();o?o.resolve(i):t.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,a)=>r.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new qi(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function e7(e,t){let{id:r,choices:n,created:i,model:o,system_fingerprint:a,...s}=e,c={...s,id:r,choices:n.map(({message:u,finish_reason:l,index:d,logprobs:f,...p})=>{if(!l)throw new Q(`missing finish_reason for choice ${d}`);let{content:m=null,function_call:h,tool_calls:w,..._}=u,y=u.role;if(!y)throw new Q(`missing role for choice ${d}`);if(h){let{arguments:x,name:S}=h;if(x==null)throw new Q(`missing function_call.arguments for choice ${d}`);if(!S)throw new Q(`missing function_call.name for choice ${d}`);return{...p,message:{content:m,function_call:{arguments:x,name:S},role:y,refusal:u.refusal??null},finish_reason:l,index:d,logprobs:f}}return w?{...p,index:d,finish_reason:l,logprobs:f,message:{..._,role:y,content:m,refusal:u.refusal??null,tool_calls:w.map((x,S)=>{let{function:$,type:j,id:C,...b}=x,{arguments:H,name:R,...V}=$||{};if(C==null)throw new Q(`missing choices[${d}].tool_calls[${S}].id
|
|
322
|
+
${ov(e)}`);if(j==null)throw new Q(`missing choices[${d}].tool_calls[${S}].type
|
|
323
|
+
${ov(e)}`);if(R==null)throw new Q(`missing choices[${d}].tool_calls[${S}].function.name
|
|
324
|
+
${ov(e)}`);if(H==null)throw new Q(`missing choices[${d}].tool_calls[${S}].function.arguments
|
|
325
|
+
${ov(e)}`);return{...b,id:C,type:j,function:{...V,name:R,arguments:H}}})}}:{...p,message:{..._,content:m,role:y,refusal:u.refusal??null},finish_reason:l,index:d,logprobs:f}}),created:i,model:o,object:"chat.completion",...a?{system_fingerprint:a}:{}};return o2(c,t)}function ov(e){return JSON.stringify(e)}var Lf=class e extends lc{static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}static runTools(t,r,n){let i=new e(r),o={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(t,r,o)),i}};var Mo=class extends N{constructor(){super(...arguments),this.messages=new cc(this._client)}create(t,r){return this._client.post("/chat/completions",{body:t,...r,stream:t.stream??!1})}retrieve(t,r){return this._client.get(T`/chat/completions/${t}`,r)}update(t,r,n){return this._client.post(T`/chat/completions/${t}`,{body:r,...n})}list(t={},r){return this._client.getAPIList("/chat/completions",ke,{query:t,...r})}delete(t,r){return this._client.delete(T`/chat/completions/${t}`,r)}parse(t,r){return c2(t.tools),this._client.chat.completions.create(t,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(n=>Rf(n,t))}runTools(t,r){return t.stream?Lf.runTools(this._client,t,r):Df.runTools(this._client,t,r)}stream(t,r){return lc.createChatCompletion(this._client,t,r)}};Mo.Messages=cc;var Ua=class extends N{constructor(){super(...arguments),this.completions=new Mo(this._client)}};Ua.Completions=Mo;var m2=Symbol("brand.privateNullableHeaders");function*r7(e){if(!e)return;if(m2 in e){let{values:n,nulls:i}=e;yield*n.entries();for(let o of i)yield[o,null];return}let t=!1,r;e instanceof Headers?r=e.entries():R$(e)?r=e:(t=!0,r=Object.entries(e??{}));for(let n of r){let i=n[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let o=R$(n[1])?n[1]:[n[1]],a=!1;for(let s of o)s!==void 0&&(t&&!a&&(a=!0,yield[i,null]),yield[i,s])}}var G=e=>{let t=new Headers,r=new Set;for(let n of e){let i=new Set;for(let[o,a]of r7(n)){let s=o.toLowerCase();i.has(s)||(t.delete(o),i.add(s)),a===null?(t.delete(o),r.add(s)):(t.append(o,a),r.delete(s))}}return{[m2]:!0,values:t,nulls:r}};var Tl=class extends N{create(t,r){return this._client.post("/audio/speech",{body:t,...r,headers:G([{Accept:"application/octet-stream"},r?.headers]),__binaryResponse:!0})}};var Al=class extends N{create(t,r){return this._client.post("/audio/transcriptions",pr({body:t,...r,stream:t.stream??!1,__metadata:{model:t.model}},this._client))}};var Ol=class extends N{create(t,r){return this._client.post("/audio/translations",pr({body:t,...r,__metadata:{model:t.model}},this._client))}};var Wi=class extends N{constructor(){super(...arguments),this.transcriptions=new Al(this._client),this.translations=new Ol(this._client),this.speech=new Tl(this._client)}};Wi.Transcriptions=Al;Wi.Translations=Ol;Wi.Speech=Tl;var dc=class extends N{create(t,r){return this._client.post("/batches",{body:t,...r})}retrieve(t,r){return this._client.get(T`/batches/${t}`,r)}list(t={},r){return this._client.getAPIList("/batches",ke,{query:t,...r})}cancel(t,r){return this._client.post(T`/batches/${t}/cancel`,r)}};var Cl=class extends N{create(t,r){return this._client.post("/assistants",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(t,r){return this._client.get(T`/assistants/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(t,r,n){return this._client.post(T`/assistants/${t}`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t={},r){return this._client.getAPIList("/assistants",ke,{query:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(t,r){return this._client.delete(T`/assistants/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Pl=class extends N{create(t,r){return this._client.post("/realtime/sessions",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Rl=class extends N{create(t,r){return this._client.post("/realtime/transcription_sessions",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}};var Fa=class extends N{constructor(){super(...arguments),this.sessions=new Pl(this._client),this.transcriptionSessions=new Rl(this._client)}};Fa.Sessions=Pl;Fa.TranscriptionSessions=Rl;var Nl=class extends N{create(t,r){return this._client.post("/chatkit/sessions",{body:t,...r,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}cancel(t,r){return this._client.post(T`/chatkit/sessions/${t}/cancel`,{...r,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}};var Ml=class extends N{retrieve(t,r){return this._client.get(T`/chatkit/threads/${t}`,{...r,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}list(t={},r){return this._client.getAPIList("/chatkit/threads",ri,{query:t,...r,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}delete(t,r){return this._client.delete(T`/chatkit/threads/${t}`,{...r,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},r?.headers])})}listItems(t,r={},n){return this._client.getAPIList(T`/chatkit/threads/${t}/items`,ri,{query:r,...n,headers:G([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}};var Ba=class extends N{constructor(){super(...arguments),this.sessions=new Nl(this._client),this.threads=new Ml(this._client)}};Ba.Sessions=Nl;Ba.Threads=Ml;var jl=class extends N{create(t,r,n){return this._client.post(T`/threads/${t}/messages`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,r,n){let{thread_id:i}=r;return this._client.get(T`/threads/${i}/messages/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,r,n){let{thread_id:i,...o}=r;return this._client.post(T`/threads/${i}/messages/${t}`,{body:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t,r={},n){return this._client.getAPIList(T`/threads/${t}/messages`,ke,{query:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,r,n){let{thread_id:i}=r;return this._client.delete(T`/threads/${i}/messages/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var zl=class extends N{retrieve(t,r,n){let{thread_id:i,run_id:o,...a}=r;return this._client.get(T`/threads/${i}/runs/${o}/steps/${t}`,{query:a,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t,r,n){let{thread_id:i,...o}=r;return this._client.getAPIList(T`/threads/${i}/runs/${t}/steps`,ke,{query:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var h2=e=>{if(typeof Buffer<"u"){let t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{let t=atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return Array.from(new Float32Array(n.buffer))}};var Va=e=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()};var Yt,fc,fT,Ji,av,ni,mc,Dl,pc,uv,an,sv,cv,Bf,Uf,Ff,g2,_2,y2,v2,b2,w2,x2,jo=class extends Da{constructor(){super(...arguments),Yt.add(this),fT.set(this,[]),Ji.set(this,{}),av.set(this,{}),ni.set(this,void 0),mc.set(this,void 0),Dl.set(this,void 0),pc.set(this,void 0),uv.set(this,void 0),an.set(this,void 0),sv.set(this,void 0),cv.set(this,void 0),Bf.set(this,void 0)}[(fT=new WeakMap,Ji=new WeakMap,av=new WeakMap,ni=new WeakMap,mc=new WeakMap,Dl=new WeakMap,pc=new WeakMap,uv=new WeakMap,an=new WeakMap,sv=new WeakMap,cv=new WeakMap,Bf=new WeakMap,Yt=new WeakSet,Symbol.asyncIterator)](){let t=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):t.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,a)=>r.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(t){let r=new fc;return r._run(()=>r._fromReadableStream(t)),r}async _fromReadableStream(t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),this._connected();let i=qi.fromReadableStream(t,this.controller);for await(let o of i)E(this,Yt,"m",Uf).call(this,o);if(i.controller.signal?.aborted)throw new xt;return this._addRun(E(this,Yt,"m",Ff).call(this))}toReadableStream(){return new qi(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(t,r,n,i){let o=new fc;return o._run(()=>o._runToolAssistantStream(t,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}async _createToolAssistantStream(t,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let a={...n,stream:!0},s=await t.submitToolOutputs(r,a,{...i,signal:this.controller.signal});this._connected();for await(let c of s)E(this,Yt,"m",Uf).call(this,c);if(s.controller.signal?.aborted)throw new xt;return this._addRun(E(this,Yt,"m",Ff).call(this))}static createThreadAssistantStream(t,r,n){let i=new fc;return i._run(()=>i._threadAssistantStream(t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}static createAssistantStream(t,r,n,i){let o=new fc;return o._run(()=>o._runAssistantStream(t,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),o}currentEvent(){return E(this,sv,"f")}currentRun(){return E(this,cv,"f")}currentMessageSnapshot(){return E(this,ni,"f")}currentRunStepSnapshot(){return E(this,Bf,"f")}async finalRunSteps(){return await this.done(),Object.values(E(this,Ji,"f"))}async finalMessages(){return await this.done(),Object.values(E(this,av,"f"))}async finalRun(){if(await this.done(),!E(this,mc,"f"))throw Error("Final run was not received.");return E(this,mc,"f")}async _createThreadAssistantStream(t,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let o={...r,stream:!0},a=await t.createAndRun(o,{...n,signal:this.controller.signal});this._connected();for await(let s of a)E(this,Yt,"m",Uf).call(this,s);if(a.controller.signal?.aborted)throw new xt;return this._addRun(E(this,Yt,"m",Ff).call(this))}async _createAssistantStream(t,r,n,i){let o=i?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort()));let a={...n,stream:!0},s=await t.create(r,a,{...i,signal:this.controller.signal});this._connected();for await(let c of s)E(this,Yt,"m",Uf).call(this,c);if(s.controller.signal?.aborted)throw new xt;return this._addRun(E(this,Yt,"m",Ff).call(this))}static accumulateDelta(t,r){for(let[n,i]of Object.entries(r)){if(!t.hasOwnProperty(n)){t[n]=i;continue}let o=t[n];if(o==null){t[n]=i;continue}if(n==="index"||n==="type"){t[n]=i;continue}if(typeof o=="string"&&typeof i=="string")o+=i;else if(typeof o=="number"&&typeof i=="number")o+=i;else if(If(o)&&If(i))o=this.accumulateDelta(o,i);else if(Array.isArray(o)&&Array.isArray(i)){if(o.every(a=>typeof a=="string"||typeof a=="number")){o.push(...i);continue}for(let a of i){if(!If(a))throw new Error(`Expected array delta entry to be an object but got: ${a}`);let s=a.index;if(s==null)throw console.error(a),new Error("Expected array delta entry to have an `index` property");if(typeof s!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${s}`);let c=o[s];c==null?o.push(a):o[s]=this.accumulateDelta(c,a)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${i}, accValue: ${o}`);t[n]=o}return t}_addRun(t){return t}async _threadAssistantStream(t,r,n){return await this._createThreadAssistantStream(r,t,n)}async _runAssistantStream(t,r,n,i){return await this._createAssistantStream(r,t,n,i)}async _runToolAssistantStream(t,r,n,i){return await this._createToolAssistantStream(r,t,n,i)}};fc=jo,Uf=function(t){if(!this.ended)switch(ue(this,sv,t,"f"),E(this,Yt,"m",y2).call(this,t),t.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":E(this,Yt,"m",x2).call(this,t);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":E(this,Yt,"m",_2).call(this,t);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":E(this,Yt,"m",g2).call(this,t);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:}},Ff=function(){if(this.ended)throw new Q("stream has ended, this shouldn't happen");if(!E(this,mc,"f"))throw Error("Final run has not been received");return E(this,mc,"f")},g2=function(t){let[r,n]=E(this,Yt,"m",b2).call(this,t,E(this,ni,"f"));ue(this,ni,r,"f"),E(this,av,"f")[r.id]=r;for(let i of n){let o=r.content[i.index];o?.type=="text"&&this._emit("textCreated",o.text)}switch(t.event){case"thread.message.created":this._emit("messageCreated",t.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",t.data.delta,r),t.data.delta.content)for(let i of t.data.delta.content){if(i.type=="text"&&i.text){let o=i.text,a=r.content[i.index];if(a&&a.type=="text")this._emit("textDelta",o,a.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(i.index!=E(this,Dl,"f")){if(E(this,pc,"f"))switch(E(this,pc,"f").type){case"text":this._emit("textDone",E(this,pc,"f").text,E(this,ni,"f"));break;case"image_file":this._emit("imageFileDone",E(this,pc,"f").image_file,E(this,ni,"f"));break}ue(this,Dl,i.index,"f")}ue(this,pc,r.content[i.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(E(this,Dl,"f")!==void 0){let i=t.data.content[E(this,Dl,"f")];if(i)switch(i.type){case"image_file":this._emit("imageFileDone",i.image_file,E(this,ni,"f"));break;case"text":this._emit("textDone",i.text,E(this,ni,"f"));break}}E(this,ni,"f")&&this._emit("messageDone",t.data),ue(this,ni,void 0,"f")}},_2=function(t){let r=E(this,Yt,"m",v2).call(this,t);switch(ue(this,Bf,r,"f"),t.event){case"thread.run.step.created":this._emit("runStepCreated",t.data);break;case"thread.run.step.delta":let n=t.data.delta;if(n.step_details&&n.step_details.type=="tool_calls"&&n.step_details.tool_calls&&r.step_details.type=="tool_calls")for(let o of n.step_details.tool_calls)o.index==E(this,uv,"f")?this._emit("toolCallDelta",o,r.step_details.tool_calls[o.index]):(E(this,an,"f")&&this._emit("toolCallDone",E(this,an,"f")),ue(this,uv,o.index,"f"),ue(this,an,r.step_details.tool_calls[o.index],"f"),E(this,an,"f")&&this._emit("toolCallCreated",E(this,an,"f")));this._emit("runStepDelta",t.data.delta,r);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":ue(this,Bf,void 0,"f"),t.data.step_details.type=="tool_calls"&&E(this,an,"f")&&(this._emit("toolCallDone",E(this,an,"f")),ue(this,an,void 0,"f")),this._emit("runStepDone",t.data,r);break;case"thread.run.step.in_progress":break}},y2=function(t){E(this,fT,"f").push(t),this._emit("event",t)},v2=function(t){switch(t.event){case"thread.run.step.created":return E(this,Ji,"f")[t.data.id]=t.data,t.data;case"thread.run.step.delta":let r=E(this,Ji,"f")[t.data.id];if(!r)throw Error("Received a RunStepDelta before creation of a snapshot");let n=t.data;if(n.delta){let i=fc.accumulateDelta(r,n.delta);E(this,Ji,"f")[t.data.id]=i}return E(this,Ji,"f")[t.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":E(this,Ji,"f")[t.data.id]=t.data;break}if(E(this,Ji,"f")[t.data.id])return E(this,Ji,"f")[t.data.id];throw new Error("No snapshot available")},b2=function(t,r){let n=[];switch(t.event){case"thread.message.created":return[t.data,n];case"thread.message.delta":if(!r)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let i=t.data;if(i.delta.content)for(let o of i.delta.content)if(o.index in r.content){let a=r.content[o.index];r.content[o.index]=E(this,Yt,"m",w2).call(this,o,a)}else r.content[o.index]=o,n.push(o);return[r,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(r)return[r,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},w2=function(t,r){return fc.accumulateDelta(r,t)},x2=function(t){switch(ue(this,cv,t.data,"f"),t.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":ue(this,mc,t.data,"f"),E(this,an,"f")&&(this._emit("toolCallDone",E(this,an,"f")),ue(this,an,void 0,"f"));break;case"thread.run.cancelling":break}};var hc=class extends N{constructor(){super(...arguments),this.steps=new zl(this._client)}create(t,r,n){let{include:i,...o}=r;return this._client.post(T`/threads/${t}/runs`,{query:{include:i},body:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}retrieve(t,r,n){let{thread_id:i}=r;return this._client.get(T`/threads/${i}/runs/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,r,n){let{thread_id:i,...o}=r;return this._client.post(T`/threads/${i}/runs/${t}`,{body:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t,r={},n){return this._client.getAPIList(T`/threads/${t}/runs`,ke,{query:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(t,r,n){let{thread_id:i}=r;return this._client.post(T`/threads/${i}/runs/${t}/cancel`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(t,r,n){let i=await this.create(t,r,n);return await this.poll(i.id,{thread_id:t},n)}createAndStream(t,r,n){return jo.createAssistantStream(t,this._client.beta.threads.runs,r,n)}async poll(t,r,n){let i=G([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:a}=await this.retrieve(t,r,{...n,headers:{...n?.headers,...i}}).withResponse();switch(o.status){case"queued":case"in_progress":case"cancelling":let s=5e3;if(n?.pollIntervalMs)s=n.pollIntervalMs;else{let c=a.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(s=u)}}await Gi(s);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return o}}}stream(t,r,n){return jo.createAssistantStream(t,this._client.beta.threads.runs,r,n)}submitToolOutputs(t,r,n){let{thread_id:i,...o}=r;return this._client.post(T`/threads/${i}/runs/${t}/submit_tool_outputs`,{body:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:r.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(t,r,n){let i=await this.submitToolOutputs(t,r,n);return await this.poll(i.id,r,n)}submitToolOutputsStream(t,r,n){return jo.createToolAssistantStream(t,this._client.beta.threads.runs,r,n)}};hc.Steps=zl;var Za=class extends N{constructor(){super(...arguments),this.runs=new hc(this._client),this.messages=new jl(this._client)}create(t={},r){return this._client.post("/threads",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(t,r){return this._client.get(T`/threads/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(t,r,n){return this._client.post(T`/threads/${t}`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,r){return this._client.delete(T`/threads/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}createAndRun(t,r){return this._client.post("/threads/runs",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(t,r){let n=await this.createAndRun(t,r);return await this.runs.poll(n.id,{thread_id:n.thread_id},r)}createAndRunStream(t,r){return jo.createThreadAssistantStream(t,this._client.beta.threads,r)}};Za.Runs=hc;Za.Messages=jl;var ii=class extends N{constructor(){super(...arguments),this.realtime=new Fa(this._client),this.chatkit=new Ba(this._client),this.assistants=new Cl(this._client),this.threads=new Za(this._client)}};ii.Realtime=Fa;ii.ChatKit=Ba;ii.Assistants=Cl;ii.Threads=Za;var gc=class extends N{create(t,r){return this._client.post("/completions",{body:t,...r,stream:t.stream??!1})}};var Ll=class extends N{retrieve(t,r,n){let{container_id:i}=r;return this._client.get(T`/containers/${i}/files/${t}/content`,{...n,headers:G([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var _c=class extends N{constructor(){super(...arguments),this.content=new Ll(this._client)}create(t,r,n){return this._client.post(T`/containers/${t}/files`,za({body:r,...n},this._client))}retrieve(t,r,n){let{container_id:i}=r;return this._client.get(T`/containers/${i}/files/${t}`,n)}list(t,r={},n){return this._client.getAPIList(T`/containers/${t}/files`,ke,{query:r,...n})}delete(t,r,n){let{container_id:i}=r;return this._client.delete(T`/containers/${i}/files/${t}`,{...n,headers:G([{Accept:"*/*"},n?.headers])})}};_c.Content=Ll;var Ga=class extends N{constructor(){super(...arguments),this.files=new _c(this._client)}create(t,r){return this._client.post("/containers",{body:t,...r})}retrieve(t,r){return this._client.get(T`/containers/${t}`,r)}list(t={},r){return this._client.getAPIList("/containers",ke,{query:t,...r})}delete(t,r){return this._client.delete(T`/containers/${t}`,{...r,headers:G([{Accept:"*/*"},r?.headers])})}};Ga.Files=_c;var Ul=class extends N{create(t,r,n){let{include:i,...o}=r;return this._client.post(T`/conversations/${t}/items`,{query:{include:i},body:o,...n})}retrieve(t,r,n){let{conversation_id:i,...o}=r;return this._client.get(T`/conversations/${i}/items/${t}`,{query:o,...n})}list(t,r={},n){return this._client.getAPIList(T`/conversations/${t}/items`,ri,{query:r,...n})}delete(t,r,n){let{conversation_id:i}=r;return this._client.delete(T`/conversations/${i}/items/${t}`,n)}};var Ha=class extends N{constructor(){super(...arguments),this.items=new Ul(this._client)}create(t={},r){return this._client.post("/conversations",{body:t,...r})}retrieve(t,r){return this._client.get(T`/conversations/${t}`,r)}update(t,r,n){return this._client.post(T`/conversations/${t}`,{body:r,...n})}delete(t,r){return this._client.delete(T`/conversations/${t}`,r)}};Ha.Items=Ul;var yc=class extends N{create(t,r){let n=!!t.encoding_format,i=n?t.encoding_format:"base64";n&&$t(this._client).debug("embeddings/user defined encoding_format:",t.encoding_format);let o=this._client.post("/embeddings",{body:{...t,encoding_format:i},...r});return n?o:($t(this._client).debug("embeddings/decoding base64 embeddings from base64"),o._thenUnwrap(a=>(a&&a.data&&a.data.forEach(s=>{let c=s.embedding;s.embedding=h2(c)}),a)))}};var Fl=class extends N{retrieve(t,r,n){let{eval_id:i,run_id:o}=r;return this._client.get(T`/evals/${i}/runs/${o}/output_items/${t}`,n)}list(t,r,n){let{eval_id:i,...o}=r;return this._client.getAPIList(T`/evals/${i}/runs/${t}/output_items`,ke,{query:o,...n})}};var vc=class extends N{constructor(){super(...arguments),this.outputItems=new Fl(this._client)}create(t,r,n){return this._client.post(T`/evals/${t}/runs`,{body:r,...n})}retrieve(t,r,n){let{eval_id:i}=r;return this._client.get(T`/evals/${i}/runs/${t}`,n)}list(t,r={},n){return this._client.getAPIList(T`/evals/${t}/runs`,ke,{query:r,...n})}delete(t,r,n){let{eval_id:i}=r;return this._client.delete(T`/evals/${i}/runs/${t}`,n)}cancel(t,r,n){let{eval_id:i}=r;return this._client.post(T`/evals/${i}/runs/${t}`,n)}};vc.OutputItems=Fl;var qa=class extends N{constructor(){super(...arguments),this.runs=new vc(this._client)}create(t,r){return this._client.post("/evals",{body:t,...r})}retrieve(t,r){return this._client.get(T`/evals/${t}`,r)}update(t,r,n){return this._client.post(T`/evals/${t}`,{body:r,...n})}list(t={},r){return this._client.getAPIList("/evals",ke,{query:t,...r})}delete(t,r){return this._client.delete(T`/evals/${t}`,r)}};qa.Runs=vc;var bc=class extends N{create(t,r){return this._client.post("/files",pr({body:t,...r},this._client))}retrieve(t,r){return this._client.get(T`/files/${t}`,r)}list(t={},r){return this._client.getAPIList("/files",ke,{query:t,...r})}delete(t,r){return this._client.delete(T`/files/${t}`,r)}content(t,r){return this._client.get(T`/files/${t}/content`,{...r,headers:G([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}async waitForProcessing(t,{pollInterval:r=5e3,maxWait:n=1800*1e3}={}){let i=new Set(["processed","error","deleted"]),o=Date.now(),a=await this.retrieve(t);for(;!a.status||!i.has(a.status);)if(await Gi(r),a=await this.retrieve(t),Date.now()-o>n)throw new Vi({message:`Giving up on waiting for file ${t} to finish processing after ${n} milliseconds.`});return a}};var Bl=class extends N{};var Vl=class extends N{run(t,r){return this._client.post("/fine_tuning/alpha/graders/run",{body:t,...r})}validate(t,r){return this._client.post("/fine_tuning/alpha/graders/validate",{body:t,...r})}};var wc=class extends N{constructor(){super(...arguments),this.graders=new Vl(this._client)}};wc.Graders=Vl;var Zl=class extends N{create(t,r,n){return this._client.getAPIList(T`/fine_tuning/checkpoints/${t}/permissions`,Ki,{body:r,method:"post",...n})}retrieve(t,r={},n){return this._client.get(T`/fine_tuning/checkpoints/${t}/permissions`,{query:r,...n})}list(t,r={},n){return this._client.getAPIList(T`/fine_tuning/checkpoints/${t}/permissions`,ri,{query:r,...n})}delete(t,r,n){let{fine_tuned_model_checkpoint:i}=r;return this._client.delete(T`/fine_tuning/checkpoints/${i}/permissions/${t}`,n)}};var xc=class extends N{constructor(){super(...arguments),this.permissions=new Zl(this._client)}};xc.Permissions=Zl;var Gl=class extends N{list(t,r={},n){return this._client.getAPIList(T`/fine_tuning/jobs/${t}/checkpoints`,ke,{query:r,...n})}};var Ic=class extends N{constructor(){super(...arguments),this.checkpoints=new Gl(this._client)}create(t,r){return this._client.post("/fine_tuning/jobs",{body:t,...r})}retrieve(t,r){return this._client.get(T`/fine_tuning/jobs/${t}`,r)}list(t={},r){return this._client.getAPIList("/fine_tuning/jobs",ke,{query:t,...r})}cancel(t,r){return this._client.post(T`/fine_tuning/jobs/${t}/cancel`,r)}listEvents(t,r={},n){return this._client.getAPIList(T`/fine_tuning/jobs/${t}/events`,ke,{query:r,...n})}pause(t,r){return this._client.post(T`/fine_tuning/jobs/${t}/pause`,r)}resume(t,r){return this._client.post(T`/fine_tuning/jobs/${t}/resume`,r)}};Ic.Checkpoints=Gl;var oi=class extends N{constructor(){super(...arguments),this.methods=new Bl(this._client),this.jobs=new Ic(this._client),this.checkpoints=new xc(this._client),this.alpha=new wc(this._client)}};oi.Methods=Bl;oi.Jobs=Ic;oi.Checkpoints=xc;oi.Alpha=wc;var Hl=class extends N{};var Ka=class extends N{constructor(){super(...arguments),this.graderModels=new Hl(this._client)}};Ka.GraderModels=Hl;var Sc=class extends N{createVariation(t,r){return this._client.post("/images/variations",pr({body:t,...r},this._client))}edit(t,r){return this._client.post("/images/edits",pr({body:t,...r,stream:t.stream??!1},this._client))}generate(t,r){return this._client.post("/images/generations",{body:t,...r,stream:t.stream??!1})}};var kc=class extends N{retrieve(t,r){return this._client.get(T`/models/${t}`,r)}list(t){return this._client.getAPIList("/models",Ki,t)}delete(t,r){return this._client.delete(T`/models/${t}`,r)}};var Ec=class extends N{create(t,r){return this._client.post("/moderations",{body:t,...r})}};var ql=class extends N{accept(t,r,n){return this._client.post(T`/realtime/calls/${t}/accept`,{body:r,...n,headers:G([{Accept:"*/*"},n?.headers])})}hangup(t,r){return this._client.post(T`/realtime/calls/${t}/hangup`,{...r,headers:G([{Accept:"*/*"},r?.headers])})}refer(t,r,n){return this._client.post(T`/realtime/calls/${t}/refer`,{body:r,...n,headers:G([{Accept:"*/*"},n?.headers])})}reject(t,r={},n){return this._client.post(T`/realtime/calls/${t}/reject`,{body:r,...n,headers:G([{Accept:"*/*"},n?.headers])})}};var Kl=class extends N{create(t,r){return this._client.post("/realtime/client_secrets",{body:t,...r})}};var zo=class extends N{constructor(){super(...arguments),this.clientSecrets=new Kl(this._client),this.calls=new ql(this._client)}};zo.ClientSecrets=Kl;zo.Calls=ql;function I2(e,t){return!t||!R7(t)?{...e,output_parsed:null,output:e.output.map(r=>r.type==="function_call"?{...r,parsed_arguments:null}:r.type==="message"?{...r,content:r.content.map(n=>({...n,parsed:null}))}:r)}:mT(e,t)}function mT(e,t){let r=e.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:j7(t,i)};if(i.type==="message"){let o=i.content.map(a=>a.type==="output_text"?{...a,parsed:P7(t,a.text)}:a);return{...i,content:o}}return i}),n=Object.assign({},e,{output:r});return Object.getOwnPropertyDescriptor(e,"output_text")||lv(n),Object.defineProperty(n,"output_parsed",{enumerable:!0,get(){for(let i of n.output)if(i.type==="message"){for(let o of i.content)if(o.type==="output_text"&&o.parsed!==null)return o.parsed}return null}}),n}function P7(e,t){return e.text?.format?.type!=="json_schema"?null:"$parseRaw"in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t)}function R7(e){return!!Pf(e.text?.format)}function N7(e){return e?.$brand==="auto-parseable-tool"}function M7(e,t){return e.find(r=>r.type==="function"&&r.name===t)}function j7(e,t){let r=M7(e.tools??[],t.name);return{...t,...t,parsed_arguments:N7(r)?r.$parseRaw(t.arguments):r?.strict?JSON.parse(t.arguments):null}}function lv(e){let t=[];for(let r of e.output)if(r.type==="message")for(let n of r.content)n.type==="output_text"&&t.push(n.text);e.output_text=t.join("")}var Wl,dv,Wa,pv,S2,k2,E2,$2,fv=class e extends Da{constructor(t){super(),Wl.add(this),dv.set(this,void 0),Wa.set(this,void 0),pv.set(this,void 0),ue(this,dv,t,"f")}static createResponse(t,r,n){let i=new e(r);return i._run(()=>i._createOrRetrieveResponse(t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createOrRetrieveResponse(t,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),E(this,Wl,"m",S2).call(this);let o,a=null;"response_id"in r?(o=await t.responses.retrieve(r.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),a=r.starting_after??null):o=await t.responses.create({...r,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let s of o)E(this,Wl,"m",k2).call(this,s,a);if(o.controller.signal?.aborted)throw new xt;return E(this,Wl,"m",E2).call(this)}[(dv=new WeakMap,Wa=new WeakMap,pv=new WeakMap,Wl=new WeakSet,S2=function(){this.ended||ue(this,Wa,void 0,"f")},k2=function(r,n){if(this.ended)return;let i=(a,s)=>{(n==null||s.sequence_number>n)&&this._emit(a,s)},o=E(this,Wl,"m",$2).call(this,r);switch(i("event",r),r.type){case"response.output_text.delta":{let a=o.output[r.output_index];if(!a)throw new Q(`missing output at index ${r.output_index}`);if(a.type==="message"){let s=a.content[r.content_index];if(!s)throw new Q(`missing content at index ${r.content_index}`);if(s.type!=="output_text")throw new Q(`expected content to be 'output_text', got ${s.type}`);i("response.output_text.delta",{...r,snapshot:s.text})}break}case"response.function_call_arguments.delta":{let a=o.output[r.output_index];if(!a)throw new Q(`missing output at index ${r.output_index}`);a.type==="function_call"&&i("response.function_call_arguments.delta",{...r,snapshot:a.arguments});break}default:i(r.type,r);break}},E2=function(){if(this.ended)throw new Q("stream has ended, this shouldn't happen");let r=E(this,Wa,"f");if(!r)throw new Q("request ended without sending any events");ue(this,Wa,void 0,"f");let n=z7(r,E(this,dv,"f"));return ue(this,pv,n,"f"),n},$2=function(r){let n=E(this,Wa,"f");if(!n){if(r.type!=="response.created")throw new Q(`When snapshot hasn't been set yet, expected 'response.created' event, got ${r.type}`);return n=ue(this,Wa,r.response,"f"),n}switch(r.type){case"response.output_item.added":{n.output.push(r.item);break}case"response.content_part.added":{let i=n.output[r.output_index];if(!i)throw new Q(`missing output at index ${r.output_index}`);let o=i.type,a=r.part;o==="message"&&a.type!=="reasoning_text"?i.content.push(a):o==="reasoning"&&a.type==="reasoning_text"&&(i.content||(i.content=[]),i.content.push(a));break}case"response.output_text.delta":{let i=n.output[r.output_index];if(!i)throw new Q(`missing output at index ${r.output_index}`);if(i.type==="message"){let o=i.content[r.content_index];if(!o)throw new Q(`missing content at index ${r.content_index}`);if(o.type!=="output_text")throw new Q(`expected content to be 'output_text', got ${o.type}`);o.text+=r.delta}break}case"response.function_call_arguments.delta":{let i=n.output[r.output_index];if(!i)throw new Q(`missing output at index ${r.output_index}`);i.type==="function_call"&&(i.arguments+=r.delta);break}case"response.reasoning_text.delta":{let i=n.output[r.output_index];if(!i)throw new Q(`missing output at index ${r.output_index}`);if(i.type==="reasoning"){let o=i.content?.[r.content_index];if(!o)throw new Q(`missing content at index ${r.content_index}`);if(o.type!=="reasoning_text")throw new Q(`expected content to be 'reasoning_text', got ${o.type}`);o.text+=r.delta}break}case"response.completed":{ue(this,Wa,r.response,"f");break}}return n},Symbol.asyncIterator)](){let t=[],r=[],n=!1;return this.on("event",i=>{let o=r.shift();o?o.resolve(i):t.push(i)}),this.on("end",()=>{n=!0;for(let i of r)i.resolve(void 0);r.length=0}),this.on("abort",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),this.on("error",i=>{n=!0;for(let o of r)o.reject(i);r.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((o,a)=>r.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let t=E(this,pv,"f");if(!t)throw new Q("stream ended without producing a ChatCompletion");return t}};function z7(e,t){return I2(e,t)}var Jl=class extends N{list(t,r={},n){return this._client.getAPIList(T`/responses/${t}/input_items`,ke,{query:r,...n})}};var Xl=class extends N{count(t={},r){return this._client.post("/responses/input_tokens",{body:t,...r})}};var Do=class extends N{constructor(){super(...arguments),this.inputItems=new Jl(this._client),this.inputTokens=new Xl(this._client)}create(t,r){return this._client.post("/responses",{body:t,...r,stream:t.stream??!1})._thenUnwrap(n=>("object"in n&&n.object==="response"&&lv(n),n))}retrieve(t,r={},n){return this._client.get(T`/responses/${t}`,{query:r,...n,stream:r?.stream??!1})._thenUnwrap(i=>("object"in i&&i.object==="response"&&lv(i),i))}delete(t,r){return this._client.delete(T`/responses/${t}`,{...r,headers:G([{Accept:"*/*"},r?.headers])})}parse(t,r){return this._client.responses.create(t,r)._thenUnwrap(n=>mT(n,t))}stream(t,r){return fv.createResponse(this._client,t,r)}cancel(t,r){return this._client.post(T`/responses/${t}/cancel`,r)}compact(t,r){return this._client.post("/responses/compact",{body:t,...r})}};Do.InputItems=Jl;Do.InputTokens=Xl;var Yl=class extends N{retrieve(t,r){return this._client.get(T`/skills/${t}/content`,{...r,headers:G([{Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}};var Ql=class extends N{retrieve(t,r,n){let{skill_id:i}=r;return this._client.get(T`/skills/${i}/versions/${t}/content`,{...n,headers:G([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}};var $c=class extends N{constructor(){super(...arguments),this.content=new Ql(this._client)}create(t,r={},n){return this._client.post(T`/skills/${t}/versions`,za({body:r,...n},this._client))}retrieve(t,r,n){let{skill_id:i}=r;return this._client.get(T`/skills/${i}/versions/${t}`,n)}list(t,r={},n){return this._client.getAPIList(T`/skills/${t}/versions`,ke,{query:r,...n})}delete(t,r,n){let{skill_id:i}=r;return this._client.delete(T`/skills/${i}/versions/${t}`,n)}};$c.Content=Ql;var Lo=class extends N{constructor(){super(...arguments),this.content=new Yl(this._client),this.versions=new $c(this._client)}create(t={},r){return this._client.post("/skills",za({body:t,...r},this._client))}retrieve(t,r){return this._client.get(T`/skills/${t}`,r)}update(t,r,n){return this._client.post(T`/skills/${t}`,{body:r,...n})}list(t={},r){return this._client.getAPIList("/skills",ke,{query:t,...r})}delete(t,r){return this._client.delete(T`/skills/${t}`,r)}};Lo.Content=Yl;Lo.Versions=$c;var ed=class extends N{create(t,r,n){return this._client.post(T`/uploads/${t}/parts`,pr({body:r,...n},this._client))}};var Ja=class extends N{constructor(){super(...arguments),this.parts=new ed(this._client)}create(t,r){return this._client.post("/uploads",{body:t,...r})}cancel(t,r){return this._client.post(T`/uploads/${t}/cancel`,r)}complete(t,r,n){return this._client.post(T`/uploads/${t}/complete`,{body:r,...n})}};Ja.Parts=ed;var T2=async e=>{let t=await Promise.allSettled(e),r=t.filter(i=>i.status==="rejected");if(r.length){for(let i of r)console.error(i.reason);throw new Error(`${r.length} promise(s) failed - see the above errors`)}let n=[];for(let i of t)i.status==="fulfilled"&&n.push(i.value);return n};var td=class extends N{create(t,r,n){return this._client.post(T`/vector_stores/${t}/file_batches`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,r,n){let{vector_store_id:i}=r;return this._client.get(T`/vector_stores/${i}/file_batches/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}cancel(t,r,n){let{vector_store_id:i}=r;return this._client.post(T`/vector_stores/${i}/file_batches/${t}/cancel`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(t,r,n){let i=await this.create(t,r);return await this.poll(t,i.id,n)}listFiles(t,r,n){let{vector_store_id:i,...o}=r;return this._client.getAPIList(T`/vector_stores/${i}/file_batches/${t}/files`,ke,{query:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async poll(t,r,n){let i=G([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:o,response:a}=await this.retrieve(r,{vector_store_id:t},{...n,headers:i}).withResponse();switch(o.status){case"in_progress":let s=5e3;if(n?.pollIntervalMs)s=n.pollIntervalMs;else{let c=a.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(s=u)}}await Gi(s);break;case"failed":case"cancelled":case"completed":return o}}}async uploadAndPoll(t,{files:r,fileIds:n=[]},i){if(r==null||r.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let o=i?.maxConcurrency??5,a=Math.min(o,r.length),s=this._client,c=r.values(),u=[...n];async function l(f){for(let p of f){let m=await s.files.create({file:p,purpose:"assistants"},i);u.push(m.id)}}let d=Array(a).fill(c).map(l);return await T2(d),await this.createAndPoll(t,{file_ids:u})}};var rd=class extends N{create(t,r,n){return this._client.post(T`/vector_stores/${t}/files`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,r,n){let{vector_store_id:i}=r;return this._client.get(T`/vector_stores/${i}/files/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,r,n){let{vector_store_id:i,...o}=r;return this._client.post(T`/vector_stores/${i}/files/${t}`,{body:o,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t,r={},n){return this._client.getAPIList(T`/vector_stores/${t}/files`,ke,{query:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,r,n){let{vector_store_id:i}=r;return this._client.delete(T`/vector_stores/${i}/files/${t}`,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}async createAndPoll(t,r,n){let i=await this.create(t,r,n);return await this.poll(t,i.id,n)}async poll(t,r,n){let i=G([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let o=await this.retrieve(r,{vector_store_id:t},{...n,headers:i}).withResponse(),a=o.data;switch(a.status){case"in_progress":let s=5e3;if(n?.pollIntervalMs)s=n.pollIntervalMs;else{let c=o.response.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(s=u)}}await Gi(s);break;case"failed":case"completed":return a}}}async upload(t,r,n){let i=await this._client.files.create({file:r,purpose:"assistants"},n);return this.create(t,{file_id:i.id},n)}async uploadAndPoll(t,r,n){let i=await this.upload(t,r,n);return await this.poll(t,i.id,n)}content(t,r,n){let{vector_store_id:i}=r;return this._client.getAPIList(T`/vector_stores/${i}/files/${t}/content`,Ki,{...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};var Uo=class extends N{constructor(){super(...arguments),this.files=new rd(this._client),this.fileBatches=new td(this._client)}create(t,r){return this._client.post("/vector_stores",{body:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}retrieve(t,r){return this._client.get(T`/vector_stores/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}update(t,r,n){return this._client.post(T`/vector_stores/${t}`,{body:r,...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}list(t={},r){return this._client.getAPIList("/vector_stores",ke,{query:t,...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}delete(t,r){return this._client.delete(T`/vector_stores/${t}`,{...r,headers:G([{"OpenAI-Beta":"assistants=v2"},r?.headers])})}search(t,r,n){return this._client.getAPIList(T`/vector_stores/${t}/search`,Ki,{body:r,method:"post",...n,headers:G([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};Uo.Files=rd;Uo.FileBatches=td;var Tc=class extends N{create(t,r){return this._client.post("/videos",pr({body:t,...r},this._client))}retrieve(t,r){return this._client.get(T`/videos/${t}`,r)}list(t={},r){return this._client.getAPIList("/videos",ri,{query:t,...r})}delete(t,r){return this._client.delete(T`/videos/${t}`,r)}createCharacter(t,r){return this._client.post("/videos/characters",pr({body:t,...r},this._client))}downloadContent(t,r={},n){return this._client.get(T`/videos/${t}/content`,{query:r,...n,headers:G([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}edit(t,r){return this._client.post("/videos/edits",pr({body:t,...r},this._client))}extend(t,r){return this._client.post("/videos/extensions",pr({body:t,...r},this._client))}getCharacter(t,r){return this._client.get(T`/videos/characters/${t}`,r)}remix(t,r,n){return this._client.post(T`/videos/${t}/remix`,za({body:r,...n},this._client))}};var nd,A2,mv,Ac=class extends N{constructor(){super(...arguments),nd.add(this)}async unwrap(t,r,n=this._client.webhookSecret,i=300){return await this.verifySignature(t,r,n,i),JSON.parse(t)}async verifySignature(t,r,n=this._client.webhookSecret,i=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");E(this,nd,"m",A2).call(this,n);let o=G([r]).values,a=E(this,nd,"m",mv).call(this,o,"webhook-signature"),s=E(this,nd,"m",mv).call(this,o,"webhook-timestamp"),c=E(this,nd,"m",mv).call(this,o,"webhook-id"),u=parseInt(s,10);if(isNaN(u))throw new Zi("Invalid webhook timestamp format");let l=Math.floor(Date.now()/1e3);if(l-u>i)throw new Zi("Webhook timestamp is too old");if(u>l+i)throw new Zi("Webhook timestamp is too new");let d=a.split(" ").map(h=>h.startsWith("v1,")?h.substring(3):h),f=n.startsWith("whsec_")?Buffer.from(n.replace("whsec_",""),"base64"):Buffer.from(n,"utf-8"),p=c?`${c}.${s}.${t}`:`${s}.${t}`,m=await crypto.subtle.importKey("raw",f,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let h of d)try{let w=Buffer.from(h,"base64");if(await crypto.subtle.verify("HMAC",m,w,new TextEncoder().encode(p)))return}catch{continue}throw new Zi("The given webhook signature does not match the expected signature")}};nd=new WeakSet,A2=function(t){if(typeof t!="string"||t.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},mv=function(t,r){if(!t)throw new Error("Headers are required");let n=t.get(r);if(n==null)throw new Error(`Missing required header: ${r}`);return n};var hT,gT,hv,O2,fe=class{constructor({baseURL:t=Va("OPENAI_BASE_URL"),apiKey:r=Va("OPENAI_API_KEY"),organization:n=Va("OPENAI_ORG_ID")??null,project:i=Va("OPENAI_PROJECT_ID")??null,webhookSecret:o=Va("OPENAI_WEBHOOK_SECRET")??null,...a}={}){if(hT.add(this),hv.set(this,void 0),this.completions=new gc(this),this.chat=new Ua(this),this.embeddings=new yc(this),this.files=new bc(this),this.images=new Sc(this),this.audio=new Wi(this),this.moderations=new Ec(this),this.models=new kc(this),this.fineTuning=new oi(this),this.graders=new Ka(this),this.vectorStores=new Uo(this),this.webhooks=new Ac(this),this.beta=new ii(this),this.batches=new dc(this),this.uploads=new Ja(this),this.responses=new Do(this),this.realtime=new zo(this),this.conversations=new Ha(this),this.evals=new qa(this),this.containers=new Ga(this),this.skills=new Lo(this),this.videos=new Tc(this),r===void 0)throw new Q("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let s={apiKey:r,organization:n,project:i,webhookSecret:o,...a,baseURL:t||"https://api.openai.com/v1"};if(!s.dangerouslyAllowBrowser&&RU())throw new Q(`It looks like you're running in a browser-like environment.
|
|
326
|
+
|
|
327
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
328
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
329
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
330
|
+
|
|
331
|
+
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
332
|
+
|
|
333
|
+
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
334
|
+
`);this.baseURL=s.baseURL,this.timeout=s.timeout??gT.DEFAULT_TIMEOUT,this.logger=s.logger??console;let c="warn";this.logLevel=c,this.logLevel=G$(s.logLevel,"ClientOptions.logLevel",this)??G$(Va("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=s.fetchOptions,this.maxRetries=s.maxRetries??2,this.fetch=s.fetch??MU(),ue(this,hv,zU,"f"),this._options=s,this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(t){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){}async authHeaders(t){return G([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(t){return HU(t)}getUserAgent(){return`${this.constructor.name}/JS ${ja}`}defaultIdempotencyKey(){return`stainless-node-retry-${P$()}`}makeStatusError(t,r,n,i){return Dt.generate(t,r,n,i)}async _callApiKey(){let t=this._options.apiKey;if(typeof t!="function")return!1;let r;try{r=await t()}catch(n){throw n instanceof Q?n:new Q(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new Q(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(t,r,n){let i=!E(this,hT,"m",O2).call(this)&&n||this.baseURL,o=EU(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),a=this.defaultQuery(),s=Object.fromEntries(o.searchParams);return(!M$(a)||!M$(s))&&(r={...s,...a,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(t){await this._callApiKey()}async prepareRequest(t,{url:r,options:n}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,n){return this.request(Promise.resolve(n).then(i=>({method:t,path:r,...i})))}request(t,r=null){return new sc(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,n){let i=await t,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:a,url:s,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(a,{url:s,options:i});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),l=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if($t(this).debug(`[${u}] sending request`,Po({retryOfRequestLogID:n,method:i.method,url:s,options:i,headers:a.headers})),i.signal?.aborted)throw new xt;let f=new AbortController,p=await this.fetchWithTimeout(s,a,c,f).catch(xf),m=Date.now();if(p instanceof globalThis.Error){let _=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new xt;let y=wf(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return $t(this).info(`[${u}] connection ${y?"timed out":"failed"} - ${_}`),$t(this).debug(`[${u}] connection ${y?"timed out":"failed"} (${_})`,Po({retryOfRequestLogID:n,url:s,durationMs:m-d,message:p.message})),this.retryRequest(i,r,n??u);throw $t(this).info(`[${u}] connection ${y?"timed out":"failed"} - error; no more retries left`),$t(this).debug(`[${u}] connection ${y?"timed out":"failed"} (error; no more retries left)`,Po({retryOfRequestLogID:n,url:s,durationMs:m-d,message:p.message})),y?new Vi:new Ma({cause:p})}let h=[...p.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,y])=>", "+_+": "+JSON.stringify(y)).join(""),w=`[${u}${l}${h}] ${a.method} ${s} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${m-d}ms`;if(!p.ok){let _=await this.shouldRetry(p);if(r&&_){let C=`retrying, ${r} attempts remaining`;return await jU(p.body),$t(this).info(`${w} - ${C}`),$t(this).debug(`[${u}] response error (${C})`,Po({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),this.retryRequest(i,r,n??u,p.headers)}let y=_?"error; no more retries left":"error; not retryable";$t(this).info(`${w} - ${y}`);let x=await p.text().catch(C=>xf(C).message),S=AU(x),$=S?void 0:x;throw $t(this).debug(`[${u}] response error (${y})`,Po({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:$,durationMs:Date.now()-d})),this.makeStatusError(p.status,S,$,p.headers)}return $t(this).info(w),$t(this).debug(`[${u}] response start`,Po({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:m-d})),{response:p,options:i,controller:f,requestLogID:u,retryOfRequestLogID:n,startTime:d}}getAPIList(t,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:t,...i})):{method:"get",path:t,...n})}requestAPIList(t,r){let n=this.makeRequest(r,null,void 0);return new Tf(this,n,t)}async fetchWithTimeout(t,r,n,i){let{signal:o,method:a,...s}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let u=setTimeout(c,n),l=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body=="object"&&s.body!==null&&Symbol.asyncIterator in s.body,d={signal:i.signal,...l?{duplex:"half"}:{},method:"GET",...s};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,t,d)}finally{clearTimeout(u)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,n,i){let o,a=i?.get("retry-after-ms");if(a){let c=parseFloat(a);Number.isNaN(c)||(o=c)}let s=i?.get("retry-after");if(s&&!o){let c=parseFloat(s);Number.isNaN(c)?o=Date.parse(s)-Date.now():o=c*1e3}if(o===void 0){let c=t.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Gi(o),this.makeRequest(t,r-1,n)}calculateDefaultRetryTimeoutMillis(t,r){let o=r-t,a=Math.min(.5*Math.pow(2,o),8),s=1-Math.random()*.25;return a*s*1e3}async buildRequest(t,{retryCount:r=0}={}){let n={...t},{method:i,path:o,query:a,defaultBaseURL:s}=n,c=this.buildURL(o,a,s);"timeout"in n&&TU("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:u,body:l}=this.buildBody({options:n}),d=await this.buildHeaders({options:t,method:i,bodyHeaders:u,retryCount:r});return{req:{method:i,headers:d,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=t.idempotencyKey);let a=G([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...NU(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(t),this._options.defaultHeaders,n,t.headers]);return this.validateHeaders(a),a.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let n=G([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&n.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:Zy(t)}:typeof t=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t)}:E(this,hv,"f").call(this,{body:t,headers:n})}};gT=fe,hv=new WeakMap,hT=new WeakSet,O2=function(){return this.baseURL!=="https://api.openai.com/v1"};fe.OpenAI=gT;fe.DEFAULT_TIMEOUT=6e5;fe.OpenAIError=Q;fe.APIError=Dt;fe.APIConnectionError=Ma;fe.APIConnectionTimeoutError=Vi;fe.APIUserAbortError=xt;fe.NotFoundError=hl;fe.ConflictError=gl;fe.RateLimitError=yl;fe.BadRequestError=pl;fe.AuthenticationError=fl;fe.InternalServerError=vl;fe.PermissionDeniedError=ml;fe.UnprocessableEntityError=_l;fe.InvalidWebhookSignatureError=Zi;fe.toFile=Of;fe.Completions=gc;fe.Chat=Ua;fe.Embeddings=yc;fe.Files=bc;fe.Images=Sc;fe.Audio=Wi;fe.Moderations=Ec;fe.Models=kc;fe.FineTuning=oi;fe.Graders=Ka;fe.VectorStores=Uo;fe.Webhooks=Ac;fe.Beta=ii;fe.Batches=dc;fe.Uploads=Ja;fe.Responses=Do;fe.Realtime=zo;fe.Conversations=Ha;fe.Evals=qa;fe.Containers=Ga;fe.Skills=Lo;fe.Videos=Tc;function q7(e){return!!(String(e).includes("context_length_exceeded")||"message"in e&&typeof e.message=="string"&&(e.message.includes("Input tokens exceed the configured limit")||e.message.includes("exceeds the context window")))}function ai(e){if(!e||typeof e!="object")return e;let t;return e.constructor.name===Vi.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="TimeoutError"):e.constructor.name===xt.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="AbortError"):q7(e)?t=eb.fromError(e):"status"in e&&e.status===400&&"message"in e&&typeof e.message=="string"&&e.message.includes("tool_calls")?t=bf(e,"INVALID_TOOL_RESULTS"):"status"in e&&e.status===401?t=bf(e,"MODEL_AUTHENTICATION"):"status"in e&&e.status===429?t=bf(e,"MODEL_RATE_LIMIT"):"status"in e&&e.status===404?t=bf(e,"MODEL_NOT_FOUND"):t=e,t}var Fo=e=>e();function Bo(e){return e?!!(/^o\d/.test(e??"")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat")):!1}function K7(e){return e.role!=="system"&&e.role!=="developer"&&e.role!=="assistant"&&e.role!=="user"&&e.role!=="function"&&e.role!=="tool"&&console.warn(`Unknown message role: ${e.role}`),e.role}function yT(e){return e.metadata?.filename??e.metadata?.name??e.metadata?.title}function id(e){let t=e.metadata?.filename??e.metadata?.name??e.metadata?.title;if(!t)throw new Error("a filename or name or title is needed via meta-data for OpenAI when working with multimodal blocks");return t}function Vo(e){let t=e._getType();switch(t){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!mr.isInstance(e))throw new Error("Invalid generic chat message");return K7(e);default:throw new Error(`Unknown message type: ${t}`)}}function C2(e){return!!(e.includes("gpt-5.2-pro")||e.includes("gpt-5.4-pro")||e.includes("codex"))}function Zo(e){let{azureOpenAIApiDeploymentName:t,azureOpenAIApiInstanceName:r,azureOpenAIApiKey:n,azureOpenAIBasePath:i,baseURL:o,azureADTokenProvider:a,azureOpenAIEndpoint:s}=e;if((n||a)&&i&&t)return`${i}/${t}`;if((n||a)&&s&&t)return`${s}/openai/deployments/${t}`;if(n||a){if(!r)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!t)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${r}.openai.azure.com/openai/deployments/${t}`}return o}function vT(e){return typeof Headers<"u"&&e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Headers]"}function P2(e){let t=Fo(()=>{if(vT(e))return e;if(Array.isArray(e))return new Headers(e);if(typeof e=="object"&&e!==null&&"values"in e&&vT(e.values))return e.values;if(typeof e=="object"&&e!==null){let r=Object.entries(e).filter(([,n])=>typeof n=="string").map(([n,i])=>[n,i]);return new Headers(r)}return new Headers});return Object.fromEntries(t.entries())}function R2(){let e=pm();return(e==="node"||e==="deno")&&(e=`(${e}/${process.version}; ${process.platform}; ${process.arch})`),e}function Go(e,t=!1,r="1.0.0"){let n=P2(e),i=R2(),o=`langchainjs${t?"-azure":""}-openai`;return{...n,"User-Agent":n["User-Agent"]?`${o}/${r} (${i})${n["User-Agent"]}`:`${o}/${r} (${i})`}}function N2(e,t){let r;return So(e)?r=WE(e):r=e,t?.strict!==void 0&&(r.function.strict=t.strict),r}function W7(e){return e.anyOf!==void 0&&Array.isArray(e.anyOf)}function M2(e){let t=["namespace functions {",""];for(let r of e)r.description&&t.push(`// ${r.description}`),Object.keys(r.parameters.properties??{}).length>0?(t.push(`type ${r.name} = (_: {`),t.push(j2(r.parameters,0)),t.push("}) => any;")):t.push(`type ${r.name} = () => any;`),t.push("");return t.push("} // namespace functions"),t.join(`
|
|
335
|
+
`)}function j2(e,t){let r=[];for(let[n,i]of Object.entries(e.properties??{}))i.description&&t<2&&r.push(`// ${i.description}`),e.required?.includes(n)?r.push(`${n}: ${gv(i,t)},`):r.push(`${n}?: ${gv(i,t)},`);return r.map(n=>" ".repeat(t)+n).join(`
|
|
336
|
+
`)}function gv(e,t){if(W7(e))return e.anyOf.map(r=>gv(r,t)).join(" | ");switch(e.type){case"string":return e.enum?e.enum.map(r=>`"${r}"`).join(" | "):"string";case"number":return e.enum?e.enum.map(r=>`${r}`).join(" | "):"number";case"integer":return e.enum?e.enum.map(r=>`${r}`).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",j2(e,t+2),"}"].join(`
|
|
337
|
+
`);case"array":return e.items?`${gv(e.items,t)}[]`:"any[]";default:return""}}function _v(e){if(e)return e==="any"||e==="required"?"required":e==="auto"?"auto":e==="none"?"none":typeof e=="string"?{type:"function",function:{name:e}}:e}function od(e){return"type"in e&&e.type!=="function"}function z2(e){return typeof e=="object"&&e!==null&&"extras"in e&&typeof e.extras=="object"&&e.extras!==null&&"providerToolDefinition"in e.extras&&typeof e.extras.providerToolDefinition=="object"&&e.extras.providerToolDefinition!==null}function D2(e){return e!=null&&typeof e=="object"&&"type"in e&&e.type!=="function"}function Oc(e){return typeof e=="object"&&e!==null&&"metadata"in e&&typeof e.metadata=="object"&&e.metadata!==null&&"customTool"in e.metadata&&typeof e.metadata.customTool=="object"&&e.metadata.customTool!==null}function yv(e){return"type"in e&&e.type==="custom"&&"custom"in e&&typeof e.custom=="object"&&e.custom!==null}function L2(e){if(e.type==="custom_tool_call")return{...e,type:"tool_call",call_id:e.id,id:e.call_id,name:e.name,isCustomTool:!0,args:{input:e.input}}}function U2(e){if(e.type==="computer_call")return{...e,type:"tool_call",call_id:e.id,id:e.call_id,name:"computer_use",isComputerTool:!0,args:{action:e.action}}}function F2(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_call"&&"isComputerTool"in e&&e.isComputerTool===!0}function B2(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_call"&&"isCustomTool"in e&&e.isCustomTool===!0}function V2(e){let t=()=>{if(e.custom.format){if(e.custom.format.type==="grammar")return{type:"grammar",definition:e.custom.format.grammar.definition,syntax:e.custom.format.grammar.syntax};if(e.custom.format.type==="text")return{type:"text"}}};return{type:"custom",name:e.custom.name,description:e.custom.description,format:t()}}function Z2(e){let t=()=>{if(e.format){if(e.format.type==="grammar")return{type:"grammar",grammar:{definition:e.format.definition,syntax:e.format.syntax}};if(e.format.type==="text")return{type:"text"}}};return{type:"custom",custom:{name:e.name,description:e.description,format:t()}}}var H2=Symbol("Let zodToJsonSchema decide on which parser to use"),G2={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},q2=e=>typeof e=="string"?{...G2,basePath:["#"],definitions:{},name:e}:{...G2,basePath:["#"],definitions:{},...e};var Vf=e=>"_def"in e?e._def:e;function K2(e){if(!e)return!0;for(let t in e)return!1;return!0}var W2=e=>{let t=q2(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[Vf(i),{def:Vf(i),path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function bT(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function Fe(e,t,r,n,i){e[t]=r,bT(e,t,n,i)}function J2(){return{}}function X2(e,t){let r={type:"array"};return e.type?._def?.typeName!==O.ZodAny&&(r.items=he(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Fe(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Fe(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Fe(r,"minItems",e.exactLength.value,e.exactLength.message,t),Fe(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function Y2(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?Fe(r,"minimum",n.value,n.message,t):Fe(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Fe(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Fe(r,"maximum",n.value,n.message,t):Fe(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Fe(r,"maximum",n.value,n.message,t));break;case"multipleOf":Fe(r,"multipleOf",n.value,n.message,t);break}return r}function Q2(){return{type:"boolean"}}function e6(e,t){return he(e.type._def,t)}var t6=(e,t)=>he(e.innerType._def,t);function wT(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>wT(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return J7(e,t)}}var J7=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":Fe(r,"minimum",n.value,n.message,t);break;case"max":Fe(r,"maximum",n.value,n.message,t);break}return r};function r6(e,t){return{...he(e.innerType._def,t),default:e.defaultValue()}}function n6(e,t,r){return t.effectStrategy==="input"?he(e.schema._def,t,r):{}}function i6(e){return{type:"string",enum:[...e.values]}}var X7=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function o6(e,t){let r=[he(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),he(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(X7(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...c}=o;a=c}else n=void 0;i.push(a)}}),i.length?{allOf:i,...n}:void 0}function a6(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 xT,Cc={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:()=>(xT===void 0&&(xT=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),xT),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])$/,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})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function vv(e,t){let r={type:"string"};function n(i){return t.patternStrategy==="escape"?Y7(i):i}if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Fe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":Fe(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":si(r,"email",i.message,t);break;case"format:idn-email":si(r,"idn-email",i.message,t);break;case"pattern:zod":ci(r,Cc.email,i.message,t);break}break;case"url":si(r,"uri",i.message,t);break;case"uuid":si(r,"uuid",i.message,t);break;case"regex":ci(r,i.regex,i.message,t);break;case"cuid":ci(r,Cc.cuid,i.message,t);break;case"cuid2":ci(r,Cc.cuid2,i.message,t);break;case"startsWith":ci(r,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":ci(r,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":si(r,"date-time",i.message,t);break;case"date":si(r,"date",i.message,t);break;case"time":si(r,"time",i.message,t);break;case"duration":si(r,"duration",i.message,t);break;case"length":Fe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,t),Fe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":{ci(r,RegExp(n(i.value)),i.message,t);break}case"ip":{i.version!=="v6"&&si(r,"ipv4",i.message,t),i.version!=="v4"&&si(r,"ipv6",i.message,t);break}case"emoji":ci(r,Cc.emoji,i.message,t);break;case"ulid":{ci(r,Cc.ulid,i.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{si(r,"binary",i.message,t);break}case"contentEncoding:base64":{Fe(r,"contentEncoding","base64",i.message,t);break}case"pattern:zod":{ci(r,Cc.base64,i.message,t);break}}break}case"nanoid":ci(r,Cc.nanoid,i.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}var Y7=e=>Array.from(e).map(t=>/[a-zA-Z0-9]/.test(t)?t:`\\${t}`).join(""),si=(e,t,r,n)=>{e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.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&&n.errorMessages&&{errorMessage:{format:r}}})):Fe(e,"format",t,r,n)},ci=(e,t,r,n)=>{e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.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:s6(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Fe(e,"pattern",s6(t,n),r,n)},s6=(e,t)=>{let r=typeof e=="function"?e():e;if(!t.applyRegexFlags||!r.flags)return r.source;let n={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},i=n.i?r.source.toLowerCase():r.source,o="",a=!1,s=!1,c=!1;for(let u=0;u<i.length;u++){if(a){o+=i[u],a=!1;continue}if(n.i){if(s){if(i[u].match(/[a-z]/)){c?(o+=i[u],o+=`${i[u-2]}-${i[u]}`.toUpperCase(),c=!1):i[u+1]==="-"&&i[u+2]?.match(/[a-z]/)?(o+=i[u],c=!0):o+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){o+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(n.m){if(i[u]==="^"){o+=`(^|(?<=[\r
|
|
338
|
+
]))`;continue}else if(i[u]==="$"){o+=`($|(?=[\r
|
|
339
|
+
]))`;continue}}if(n.s&&i[u]==="."){o+=s?`${i[u]}\r
|
|
340
|
+
`:`[${i[u]}\r
|
|
341
|
+
]`;continue}o+=i[u],i[u]==="\\"?a=!0:s&&i[u]==="]"?s=!1:!s&&i[u]==="["&&(s=!0)}try{let u=new RegExp(o)}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`),r.source}return o};function bv(e,t){if(t.target==="openApi3"&&e.keyType?._def.typeName===O.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:he(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??{}}),{}),additionalProperties:!1};let r={type:"object",additionalProperties:he(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===O.ZodString&&e.keyType._def.checks?.length){let n=Object.entries(vv(e.keyType._def,t)).reduce((i,[o,a])=>o==="type"?i:{...i,[o]:a},{});return{...r,propertyNames:n}}else if(e.keyType?._def.typeName===O.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};return r}function c6(e,t){if(t.mapStrategy==="record")return bv(e,t);let r=he(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},n=he(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function u6(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function l6(){return{not:{}}}function d6(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Zf={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function f6(e,t){if(t.target==="openApi3")return p6(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Zf&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let a=Zf[o._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,a,s)=>s.indexOf(o)===a);return{type:i.length>1?i:i[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return p6(e,t)}var p6=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>he(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function m6(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"||t.nullableStrategy==="property"?{type:Zf[e.innerType._def.typeName],nullable:!0}:{type:[Zf[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=he(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=he(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function h6(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",bT(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?Fe(r,"minimum",n.value,n.message,t):Fe(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),Fe(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?Fe(r,"maximum",n.value,n.message,t):Fe(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),Fe(r,"maximum",n.value,n.message,t));break;case"multipleOf":Fe(r,"multipleOf",n.value,n.message,t);break}return r}function Q7(e,t){return t.removeAdditionalStrategy==="strict"?e.catchall._def.typeName==="ZodNever"?e.unknownKeys!=="strict":he(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:e.catchall._def.typeName==="ZodNever"?e.unknownKeys==="passthrough":he(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function g6(e,t){let r={type:"object",...Object.entries(e.shape()).reduce((n,[i,o])=>{if(o===void 0||o._def===void 0)return n;let a=[...t.currentPath,"properties",i],s=he(o._def,{...t,currentPath:a,propertyPath:a});if(s===void 0)return n;if(t.openaiStrictMode&&o.isOptional()&&!o.isNullable()&&typeof o._def?.defaultValue>"u")throw new Error(`Zod field at \`${a.join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);return{properties:{...n.properties,[i]:s},required:o.isOptional()&&!t.openaiStrictMode?n.required:[...n.required,i]}},{properties:{},required:[]}),additionalProperties:Q7(e,t)};return r.required.length||delete r.required,r}var _6=(e,t)=>{if(t.propertyPath&&t.currentPath.slice(0,t.propertyPath.length).toString()===t.propertyPath.toString())return he(e.innerType._def,{...t,currentPath:t.currentPath});let r=he(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:{}},r]}:{}};var y6=(e,t)=>{if(t.pipeStrategy==="input")return he(e.in._def,t);if(t.pipeStrategy==="output")return he(e.out._def,t);let r=he(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=he(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function v6(e,t){return he(e.type._def,t)}function b6(e,t){let n={type:"array",uniqueItems:!0,items:he(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Fe(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Fe(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function w6(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>he(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:he(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>he(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function x6(){return{not:{}}}function I6(){return{}}var S6=(e,t)=>he(e.innerType._def,t);function he(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==H2)return a}if(n&&!r){let a=eX(n,t);if(a!==void 0)return"$ref"in a&&t.seenRefs.add(a.$ref),a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=rX(e,e.typeName,t,r);return o&&nX(e,t,o),i.jsonSchema=o,o}var eX=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":let r=e.path.slice(t.basePath.length+1).join("_");return r!==t.name&&t.nameStrategy==="duplicate-ref"&&(t.definitions[r]=e.def),{$ref:[...t.basePath,t.definitionPath,r].join("/")};case"relative":return{$ref:tX(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,i)=>t.currentPath[i]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):t.$refStrategy==="seen"?{}:void 0}},tX=(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("/")},rX=(e,t,r,n)=>{switch(t){case O.ZodString:return vv(e,r);case O.ZodNumber:return h6(e,r);case O.ZodObject:return g6(e,r);case O.ZodBigInt:return Y2(e,r);case O.ZodBoolean:return Q2();case O.ZodDate:return wT(e,r);case O.ZodUndefined:return x6();case O.ZodNull:return d6(r);case O.ZodArray:return X2(e,r);case O.ZodUnion:case O.ZodDiscriminatedUnion:return f6(e,r);case O.ZodIntersection:return o6(e,r);case O.ZodTuple:return w6(e,r);case O.ZodRecord:return bv(e,r);case O.ZodLiteral:return a6(e,r);case O.ZodEnum:return i6(e);case O.ZodNativeEnum:return u6(e);case O.ZodNullable:return m6(e,r);case O.ZodOptional:return _6(e,r);case O.ZodMap:return c6(e,r);case O.ZodSet:return b6(e,r);case O.ZodLazy:return he(e.getter()._def,r);case O.ZodPromise:return v6(e,r);case O.ZodNaN:case O.ZodNever:return l6();case O.ZodEffects:return n6(e,r,n);case O.ZodAny:return J2();case O.ZodUnknown:return I6();case O.ZodDefault:return r6(e,r);case O.ZodBranded:return e6(e,r);case O.ZodReadonly:return S6(e,r);case O.ZodCatch:return t6(e,r);case O.ZodPipeline:return y6(e,r);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return(i=>{})(t)}},nX=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var IT=(e,t)=>{let r=W2(t),n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=he(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??{},o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(i.title=o);let a=(()=>{if(K2(r.definitions))return;let c={},u=new Set;for(let l=0;l<500;l++){let d=Object.entries(r.definitions).filter(([f])=>!u.has(f));if(d.length===0)break;for(let[f,p]of d)c[f]=he(Vf(p),{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0)??{},u.add(f)}return c})(),s=n===void 0?a?{...i,[r.definitionPath]:a}:i:r.nameStrategy==="duplicate-ref"?{...i,...a||r.seenRefs.size?{[r.definitionPath]:{...a,...r.seenRefs.size?{[n]:i}:void 0}}:void 0}:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...a,[n]:i}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s};function k6(e){if(e.type!=="object")throw new Error(`Root schema must have type: 'object' but got type: ${e.type?`'${e.type}'`:"undefined"}`);let t=structuredClone(e);return Ho(t,[],t)}function ST(e){if(typeof e=="boolean")return!1;if(e.type==="null")return!0;for(let t of e.oneOf??[])if(ST(t))return!0;for(let t of e.anyOf??[])if(ST(t))return!0;return!1}function Ho(e,t,r){if(typeof e=="boolean")throw new TypeError(`Expected object schema but got boolean; path=${t.join("/")}`);if(!Pc(e))throw new TypeError(`Expected ${JSON.stringify(e)} to be an object; path=${t.join("/")}`);let n=e.$defs;if(Pc(n))for(let[f,p]of Object.entries(n))Ho(p,[...t,"$defs",f],r);let i=e.definitions;if(Pc(i))for(let[f,p]of Object.entries(i))Ho(p,[...t,"definitions",f],r);e.type==="object"&&!("additionalProperties"in e)&&(e.additionalProperties=!1);let a=e.required??[],s=e.properties;if(Pc(s)){for(let[f,p]of Object.entries(s))if(!ST(p)&&!a.includes(f))throw new Error(`Zod field at \`${[...t,"properties",f].join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);e.required=Object.keys(s),e.properties=Object.fromEntries(Object.entries(s).map(([f,p])=>[f,Ho(p,[...t,"properties",f],r)]))}let c=e.items;Pc(c)&&(e.items=Ho(c,[...t,"items"],r));let u=e.anyOf;Array.isArray(u)&&(e.anyOf=u.map((f,p)=>Ho(f,[...t,"anyOf",String(p)],r)));let l=e.allOf;if(Array.isArray(l))if(l.length===1){let f=Ho(l[0],[...t,"allOf","0"],r);Object.assign(e,f),delete e.allOf}else e.allOf=l.map((f,p)=>Ho(f,[...t,"allOf",String(p)],r));e.default===null&&delete e.default;let d=e.$ref;if(d&&oX(e,1)){if(typeof d!="string")throw new TypeError(`Received non-string $ref - ${d}; path=${t.join("/")}`);let f=iX(r,d);if(typeof f=="boolean")throw new Error(`Expected \`$ref: ${d}\` to resolve to an object schema but got boolean`);if(!Pc(f))throw new Error(`Expected \`$ref: ${d}\` to resolve to an object but got ${JSON.stringify(f)}`);return Object.assign(e,{...f,...e}),delete e.$ref,Ho(e,t,r)}return e}function iX(e,t){if(!t.startsWith("#/"))throw new Error(`Unexpected $ref format ${JSON.stringify(t)}; Does not start with #/`);let r=t.slice(2).split("/"),n=e;for(let i of r){if(!Pc(n))throw new Error(`encountered non-object entry while resolving ${t} - ${JSON.stringify(n)}`);let o=n[i];if(o===void 0)throw new Error(`Key ${i} not found while resolving ${t}`);n=o}return n}function Pc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oX(e,t){let r=0;for(let n in e)if(r++,r>t)return!0;return!1}function aX(e,t){return IT(e,{openaiStrictMode:!0,name:t.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}function sX(e){return k6(mo(e,{target:"draft-7"}))}function cX(e){return"_zod"in e}function E6(e,t,r){return i2({type:"json_schema",json_schema:{...r,name:t,strict:!0,schema:cX(e)?sX(e):aX(e,{name:t})}},n=>e.parse(JSON.parse(n)))}var $6=["jsonSchema","functionCalling","jsonMode"];function T6(e,t){if(typeof t<"u"&&!$6.includes(t))throw new Error(`Invalid method: ${t}. Supported methods are: ${$6.join(", ")}`);let r=!e.startsWith("gpt-3")&&!e.startsWith("gpt-4-")&&e!=="gpt-4";if(r&&!t)return"jsonSchema";if(!r&&t==="jsonSchema")throw new Error(`JSON Schema is not supported for model "${e}". Please use a different method, e.g. "functionCalling" or "jsonMode".`);return t??"functionCalling"}function uX(e,t){let r={...e};return Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}function A6(e,t,r){if(mt(e))return E6(e,t,r);if(We(e))return uX({type:"json_schema",json_schema:{...r,name:t,strict:!0,schema:dt(e,{cycles:"ref",reused:"ref",override(n){n.jsonSchema.title=t}})}},n=>Ei(e,JSON.parse(n)));throw new Error("Unsupported schema response format")}function O6(e,t){if(t&&typeof t=="object"&&"images"in t&&Array.isArray(t.images)){let r=t.images.filter(n=>typeof n?.image_url?.url=="string").map(n=>({type:"image",url:n.image_url.url}));return[{type:"text",text:e},...r]}return e}var C6={"gpt-4o-2024-11-20":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.3-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-pro":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:272e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-mini":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-ada-002":{maxInputTokens:8192,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1536,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-chat-latest":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"codex-mini-latest":{maxInputTokens:2e5,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-codex-max":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-2024-05-13":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-chat-latest":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-deep-research":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},o1:{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o4-mini-deep-research":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.3-codex-spark":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},o3:{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-3-small":{maxInputTokens:8191,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1536,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1-nano":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"text-embedding-3-large":{maxInputTokens:8191,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-3.5-turbo":{maxInputTokens:16385,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1,imageUrlInputs:!1,pdfToolMessage:!1,imageToolMessage:!1,toolChoice:!0},"gpt-5.1-codex-mini":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-pro":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4-turbo":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:4096,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o4-mini":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4.1-mini":{maxInputTokens:1047576,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.4":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-preview":{maxInputTokens:128e3,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.4-pro":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-pro":{maxInputTokens:2e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-codex":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.2-pro":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o3-mini":{maxInputTokens:2e5,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:1e5,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o-2024-08-06":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-mini":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.1-chat-latest":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4":{maxInputTokens:8192,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5-nano":{maxInputTokens:4e5,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:128e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"o1-mini":{maxInputTokens:128e3,imageInputs:!1,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-4o":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:16384,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0}};function ad(e,t){return typeof e=="string"?{model:e,...t??{}}:e??t}var Rc=class extends zi{temperature;topP;frequencyPenalty;presencePenalty;n;logitBias;model="gpt-3.5-turbo";modelKwargs;stop;stopSequences;user;timeout;streaming=!1;streamUsage=!0;maxTokens;logprobs;topLogprobs;apiKey;organization;__includeRawResponse;client;clientConfig;supportsStrictToolCalling;audio;modalities;reasoning;zdrEnabled;service_tier;promptCacheKey;promptCacheRetention;verbosity;defaultOptions;_llmType(){return"openai"}static lc_name(){return"ChatOpenAI"}get callKeys(){return[...super.callKeys,"options","function_call","functions","tools","tool_choice","promptIndex","response_format","seed","reasoning","reasoning_effort","service_tier"]}lc_serializable=!0;get lc_secrets(){return{apiKey:"OPENAI_API_KEY",organization:"OPENAI_ORGANIZATION"}}get lc_aliases(){return{apiKey:"openai_api_key",modelName:"model"}}get lc_serializable_keys(){return["configuration","logprobs","topLogprobs","prefixMessages","supportsStrictToolCalling","modalities","audio","temperature","maxTokens","topP","frequencyPenalty","presencePenalty","n","logitBias","user","streaming","streamUsage","model","modelName","modelKwargs","stop","stopSequences","timeout","apiKey","cache","maxConcurrency","maxRetries","verbose","callbacks","tags","metadata","disableStreaming","zdrEnabled","reasoning","promptCacheKey","promptCacheRetention","verbosity"]}getLsParams(e){let t=this.invocationParams(e);return{ls_provider:"openai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:t.temperature??void 0,ls_max_tokens:t.max_tokens??void 0,ls_stop:e.stop}}_identifyingParams(){return{model_name:this.model,...this.invocationParams(),...this.clientConfig}}identifyingParams(){return this._identifyingParams()}constructor(e){super(e??{});let t=typeof e?.configuration?.apiKey=="string"||typeof e?.configuration?.apiKey=="function"?e?.configuration?.apiKey:void 0;this.apiKey=e?.apiKey??t??et("OPENAI_API_KEY"),this.organization=e?.configuration?.organization??et("OPENAI_ORGANIZATION"),this.model=e?.model??e?.modelName??this.model,this.modelKwargs=e?.modelKwargs??{},this.timeout=e?.timeout,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.logprobs=e?.logprobs,this.topLogprobs=e?.topLogprobs,this.n=e?.n??this.n,this.logitBias=e?.logitBias,this.stop=e?.stopSequences??e?.stop,this.stopSequences=this.stop,this.user=e?.user,this.__includeRawResponse=e?.__includeRawResponse,this.audio=e?.audio,this.modalities=e?.modalities,this.reasoning=e?.reasoning,this.maxTokens=e?.maxCompletionTokens??e?.maxTokens,this.promptCacheKey=e?.promptCacheKey??this.promptCacheKey,this.promptCacheRetention=e?.promptCacheRetention??this.promptCacheRetention,this.verbosity=e?.verbosity??this.verbosity,this.disableStreaming=e?.disableStreaming===!0,this.streaming=e?.streaming===!0,this.disableStreaming&&(this.streaming=!1),e?.streaming===!1&&(this.disableStreaming=!0),this.streamUsage=e?.streamUsage??this.streamUsage,this.disableStreaming&&(this.streamUsage=!1),this.clientConfig={apiKey:this.apiKey,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration},e?.supportsStrictToolCalling!==void 0&&(this.supportsStrictToolCalling=e.supportsStrictToolCalling),e?.service_tier!==void 0&&(this.service_tier=e.service_tier),this.zdrEnabled=e?.zdrEnabled??!1,this._addVersion("@langchain/openai","1.3.0")}_getReasoningParams(e){if(!Bo(this.model))return;let t;return this.reasoning!==void 0&&(t={...t,...this.reasoning}),e?.reasoning!==void 0&&(t={...t,...e.reasoning}),e?.reasoningEffort!==void 0&&t?.effort===void 0&&(t={...t,effort:e.reasoningEffort}),t}_getResponseFormat(e){return e&&e.type==="json_schema"&&e.json_schema.schema&&zt(e.json_schema.schema)?A6(e.json_schema.schema,e.json_schema.name,{description:e.json_schema.description}):e}_combineCallOptions(e){return{...this.defaultOptions,...e??{}}}_getClientOptions(e){if(!this.client){let t=Zo({baseURL:this.clientConfig.baseURL}),r={...this.clientConfig,baseURL:t,timeout:this.timeout,maxRetries:0};r.baseURL||delete r.baseURL,r.defaultHeaders=Go(r.defaultHeaders),this.client=new fe(r)}return{...this.clientConfig,...e}}_convertChatOpenAIToolToCompletionsTool(e,t){return Oc(e)?Z2(e.metadata.customTool):$p(e)?t?.strict!==void 0?{...e,function:{...e.function,strict:t.strict}}:e:N2(e,t)}bindTools(e,t){let r;return t?.strict!==void 0?r=t.strict:this.supportsStrictToolCalling!==void 0&&(r=this.supportsStrictToolCalling),this.withConfig({tools:e.map(n=>{if(od(n)||Oc(n))return n;if(z2(n))return n.extras.providerToolDefinition;let i=this._convertChatOpenAIToolToCompletionsTool(n,{strict:r});return So(n)&&n.extras?.defer_loading===!0?{...i,defer_loading:!0}:i}),...t})}async stream(e,t){return super.stream(e,this._combineCallOptions(t))}async invoke(e,t){return super.invoke(e,this._combineCallOptions(t))}_combineLLMOutput(...e){return e.reduce((t,r)=>(r&&r.tokenUsage&&(t.tokenUsage.completionTokens+=r.tokenUsage.completionTokens??0,t.tokenUsage.promptTokens+=r.tokenUsage.promptTokens??0,t.tokenUsage.totalTokens+=r.tokenUsage.totalTokens??0),t),{tokenUsage:{completionTokens:0,promptTokens:0,totalTokens:0}})}async getNumTokensFromMessages(e){let t=0,r=0,n=0;this.model==="gpt-3.5-turbo-0301"?(r=4,n=-1):(r=3,n=1);let i=await Promise.all(e.map(async o=>{let[a,s]=await Promise.all([this.getNumTokens(o.content),this.getNumTokens(Vo(o))]),c=o.name!==void 0?n+await this.getNumTokens(o.name):0,u=a+r+s+c,l=o;if(l._getType()==="function"&&(u-=2),l.additional_kwargs?.function_call&&(u+=3),l?.additional_kwargs.function_call?.name&&(u+=await this.getNumTokens(l.additional_kwargs.function_call?.name)),l.additional_kwargs.function_call?.arguments)try{u+=await this.getNumTokens(JSON.stringify(JSON.parse(l.additional_kwargs.function_call?.arguments)))}catch(d){console.error("Error parsing function arguments",d,JSON.stringify(l.additional_kwargs.function_call)),u+=await this.getNumTokens(l.additional_kwargs.function_call?.arguments)}return t+=u,u}));return t+=3,{totalCount:t,countPerMessage:i}}async _getNumTokensFromGenerations(e){return(await Promise.all(e.map(async t=>t.message.additional_kwargs?.function_call?(await this.getNumTokensFromMessages([t.message])).countPerMessage[0]:await this.getNumTokens(t.message.content)))).reduce((t,r)=>t+r,0)}async _getEstimatedTokenCountFromPrompt(e,t,r){let n=(await this.getNumTokensFromMessages(e)).totalCount;if(t&&r!=="auto"){let i=M2(t);n+=await this.getNumTokens(i),n+=9}return t&&e.find(i=>i._getType()==="system")&&(n-=4),r==="none"?n+=1:typeof r=="object"&&(n+=await this.getNumTokens(r.name)+4),n}async moderateContent(e,t){let r=this._getClientOptions(t?.options),n={input:e,model:t?.model??"omni-moderation-latest"};return this.caller.call(async()=>{try{return await this.client.moderations.create(n,r)}catch(i){throw ai(i)}})}get profile(){return C6[this.model]??{}}_getStructuredOutputMethod(e){let t={...e};if(!this.model.startsWith("gpt-3")&&!this.model.startsWith("gpt-4-")&&this.model!=="gpt-4"){if(t?.method===void 0)return"jsonSchema"}else t.method==="jsonSchema"&&console.warn(`[WARNING]: JSON Schema is not supported for model "${this.model}". Falling back to tool calling.`);return t.method}withStructuredOutput(e,t){let r,n,{schema:i,name:o,includeRaw:a}={...t,schema:e};if(t?.strict!==void 0&&t.method==="jsonMode")throw new Error("Argument `strict` is only supported for `method` = 'function_calling'");let s=T6(this.model,t?.method);if(s==="jsonMode"){n=g_(i);let c=dt(i);r=this.withConfig({outputVersion:"v0",response_format:{type:"json_object"},ls_structured_output_format:{kwargs:{method:"json_mode"},schema:{title:o??"extract",...c}}})}else if(s==="jsonSchema"){let c=dt(i),u={name:o??"extract",description:Un(c),schema:zt(i)?i:c,strict:t?.strict};if(r=this.withConfig({outputVersion:"v0",response_format:{type:"json_schema",json_schema:u},ls_structured_output_format:{kwargs:{method:"json_schema"},schema:{title:u.name,description:u.description,...c}}}),zt(i)||ki(i)){let l=g_(i);n=Zt.from(async d=>"parsed"in d.additional_kwargs?d.additional_kwargs.parsed:l.invoke(d.content))}else n=new Gu}else{let c=o??"extract",u=dt(i),l;zt(i)||ki(i)?l={name:c,description:u.description,parameters:u}:typeof i.name=="string"&&typeof i.parameters=="object"&&i.parameters!=null?(l=i,c=i.name):(c=i.title??c,l={name:c,description:i.description??"",parameters:i}),r=this.withConfig({outputVersion:"v0",tools:[{type:"function",function:l}],tool_choice:{type:"function",function:{name:c}},ls_structured_output_format:{kwargs:{method:"function_calling"},schema:{title:c,...u}},...t?.strict!==void 0?{strict:t.strict}:{}}),n=ik(i,c)}return Op(r,n,a)}};var wv={providerName:"ChatOpenAI",fromStandardTextBlock(e){return{type:"text",text:e.text}},fromStandardImageBlock(e){if(e.source_type==="url")return{type:"image_url",image_url:{url:e.url,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};if(e.source_type==="base64")return{type:"image_url",image_url:{url:`data:${e.mime_type??""};base64,${e.data}`,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};throw new Error(`Image content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardAudioBlock(e){if(e.source_type==="url"){let t=Wo({dataUrl:e.url});if(!t)throw new Error(`URL audio blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);let r=t.mime_type||e.mime_type||"",n;try{n=wd(r)}catch{throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(n.type!=="audio"||n.subtype!=="wav"&&n.subtype!=="mp3")throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:"input_audio",input_audio:{format:n.subtype,data:t.data}}}if(e.source_type==="base64"){let t;try{t=wd(e.mime_type??"")}catch{throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(t.type!=="audio"||t.subtype!=="wav"&&t.subtype!=="mp3")throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:"input_audio",input_audio:{format:t.subtype,data:e.data}}}throw new Error(`Audio content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardFileBlock(e){if(e.source_type==="url"){let t=Wo({dataUrl:e.url}),r=id(e);if(!t)throw new Error(`URL file blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);return{type:"file",file:{file_data:e.url,...e.metadata?.filename||e.metadata?.name?{filename:r}:{}}}}if(e.source_type==="base64"){let t=id(e);return{type:"file",file:{file_data:`data:${e.mime_type??""};base64,${e.data}`,...e.metadata?.filename||e.metadata?.name||e.metadata?.title?{filename:t}:{}}}}if(e.source_type==="id")return{type:"file",file:{file_id:e.id}};throw new Error(`File content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)}},kT=({message:e,rawResponse:t,includeRawResponse:r})=>{let n=e.tool_calls;switch(e.role){case"assistant":{let i=[],o=[];for(let c of n??[])try{i.push(qs(c,{returnId:!0}))}catch(u){o.push(Sa(c,u.message))}let a={function_call:e.function_call,tool_calls:n};r!==void 0&&(a.__raw_response=t);let s={model_provider:"openai",model_name:t.model,...t.system_fingerprint?{usage:{...t.usage},system_fingerprint:t.system_fingerprint}:{}};return e.audio&&(a.audio=e.audio),new be({content:O6(e.content||"",t.choices?.[0]?.message),tool_calls:i,invalid_tool_calls:o,additional_kwargs:a,response_metadata:s,id:t.id})}default:return new mr(e.content||"",e.role??"unknown")}},ET=({delta:e,rawResponse:t,includeRawResponse:r,defaultRole:n})=>{let i=e.role??n,o=e.content??"",a;e.function_call?a={function_call:e.function_call}:e.tool_calls?a={tool_calls:e.tool_calls}:a={},r&&(a.__raw_response=t),e.audio&&(a.audio={...e.audio,index:t.choices[0].index});let s={model_provider:"openai",usage:{...t.usage}};if(i==="user")return new co({content:o,response_metadata:s});if(i==="assistant"){let c=[];if(Array.isArray(e.tool_calls))for(let u of e.tool_calls)c.push({name:u.function?.name,args:u.function?.arguments,id:u.id,index:u.index,type:"tool_call_chunk"});return new at({content:o,tool_call_chunks:c,additional_kwargs:a,id:t.id,response_metadata:s})}else return i==="system"?new fn({content:o,response_metadata:s}):i==="developer"?new fn({content:o,response_metadata:s,additional_kwargs:{__openai_role__:"developer"}}):i==="function"?new so({content:o,additional_kwargs:a,name:e.name,response_metadata:s}):i==="tool"?new Xo({content:o,additional_kwargs:a,tool_call_id:e.tool_call_id,response_metadata:s}):new ao({content:o,role:i,response_metadata:s})},P6=e=>{if(e.type==="image"){if(e.url)return{type:"image_url",image_url:{url:e.url}};if(e.data)return{type:"image_url",image_url:{url:`data:${e.mimeType};base64,${e.data}`}}}if(e.type==="audio"&&e.data){let t=$m(()=>{let[,r]=e.mimeType.split("/");return r==="wav"||r==="mp3"?r:"wav"});return{type:"input_audio",input_audio:{data:e.data.toString(),format:t}}}if(e.type==="file"){if(e.data){let t=id(e);return{type:"file",file:{file_data:`data:${e.mimeType};base64,${e.data}`,filename:t}}}if(e.fileId)return{type:"file",file:{file_id:e.fileId}}}},R6=({message:e,model:t})=>{let r=Vo(e);if(r==="system"&&Bo(t)&&(r="developer"),r==="developer")return{role:"developer",content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="system")return{role:"system",content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="assistant")return{role:"assistant",content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="tool"&&jt.isInstance(e))return{role:"tool",tool_call_id:e.tool_call_id,content:e.contentBlocks.filter(i=>i.type==="text")};if(r==="function")return{role:"function",name:e.name??"",content:e.contentBlocks.filter(i=>i.type==="text").join("")};function*n(i){for(let o of i){o.type==="text"&&(yield{type:"text",text:o.text});let a=P6(o);a&&(yield a)}}return{role:"user",content:Array.from(n(e.contentBlocks))}},Gf=({messages:e,model:t})=>e.flatMap(r=>{if("output_version"in r.response_metadata&&r.response_metadata?.output_version==="v1")return R6({message:r});let n=Vo(r);n==="system"&&Bo(t)&&(n="developer");let i=typeof r.content=="string"?r.content:r.content.flatMap(a=>Or(a)?Hc(a,wv):typeof a=="object"&&a!==null&&"type"in a&&a.type==="tool_use"?[]:a),o={role:n,content:i};return r.name!=null&&(o.name=r.name),r.additional_kwargs.function_call!=null&&(o.function_call=r.additional_kwargs.function_call),be.isInstance(r)&&r.tool_calls?.length?o.tool_calls=r.tool_calls.map(m_):(r.additional_kwargs.tool_calls!=null&&(o.tool_calls=r.additional_kwargs.tool_calls),jt.isInstance(r)&&r.tool_call_id!=null&&(o.tool_call_id=r.tool_call_id)),r.additional_kwargs.audio&&typeof r.additional_kwargs.audio=="object"&&"id"in r.additional_kwargs.audio?[o,{role:"assistant",audio:{id:r.additional_kwargs.audio.id}}]:o});var xv=class extends Rc{constructor(e,t){super(ad(e,t))}invocationParams(e,t){let r;e?.strict!==void 0?r=e.strict:this.supportsStrictToolCalling!==void 0&&(r=this.supportsStrictToolCalling);let n={};e?.stream_options!==void 0?n={stream_options:e.stream_options}:this.streamUsage&&(this.streaming||t?.streaming)&&(n={stream_options:{include_usage:!0}});let i={model:this.model,temperature:this.temperature,top_p:this.topP,frequency_penalty:this.frequencyPenalty,presence_penalty:this.presencePenalty,logprobs:this.logprobs,top_logprobs:this.topLogprobs,n:this.n,logit_bias:this.logitBias,stop:e?.stop??this.stopSequences,user:this.user,stream:this.streaming,functions:e?.functions,function_call:e?.function_call,tools:e?.tools?.length?e.tools.map(a=>this._convertChatOpenAIToolToCompletionsTool(a,{strict:r})):void 0,tool_choice:_v(e?.tool_choice),response_format:this._getResponseFormat(e?.response_format),seed:e?.seed,...n,parallel_tool_calls:e?.parallel_tool_calls,...this.audio||e?.audio?{audio:this.audio||e?.audio}:{},...this.modalities||e?.modalities?{modalities:this.modalities||e?.modalities}:{},...this.modelKwargs,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,verbosity:e?.verbosity??this.verbosity};e?.prediction!==void 0&&(i.prediction=e.prediction),this.service_tier!==void 0&&(i.service_tier=this.service_tier),e?.service_tier!==void 0&&(i.service_tier=e.service_tier);let o=this._getReasoningParams(e);return o!==void 0&&o.effort!==void 0&&(i.reasoning_effort=o.effort),Bo(i.model)?i.max_completion_tokens=this.maxTokens===-1?void 0:this.maxTokens:i.max_tokens=this.maxTokens===-1?void 0:this.maxTokens,i}async _generate(e,t,r){t.signal?.throwIfAborted();let n={},i=this.invocationParams(t),o=Gf({messages:e,model:this.model});if(i.stream){let a=this._streamResponseChunks(e,t,r),s={};for await(let p of a){p.message.response_metadata={...p.generationInfo,...p.message.response_metadata};let m=p.generationInfo?.completion??0;s[m]===void 0?s[m]=p:s[m]=s[m].concat(p)}let c=Object.entries(s).sort(([p],[m])=>parseInt(p,10)-parseInt(m,10)).map(([p,m])=>m),{functions:u,function_call:l}=this.invocationParams(t),d=await this._getEstimatedTokenCountFromPrompt(e,u,l),f=await this._getNumTokensFromGenerations(c);return n.input_tokens=d,n.output_tokens=f,n.total_tokens=d+f,{generations:c,llmOutput:{estimatedTokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}else{let a=await this.completionWithRetry({...i,stream:!1,messages:o},{signal:t?.signal,...t?.options}),{completion_tokens:s,prompt_tokens:c,total_tokens:u,prompt_tokens_details:l,completion_tokens_details:d}=a?.usage??{};s&&(n.output_tokens=(n.output_tokens??0)+s),c&&(n.input_tokens=(n.input_tokens??0)+c),u&&(n.total_tokens=(n.total_tokens??0)+u),(l?.audio_tokens!==null||l?.cached_tokens!==null)&&(n.input_token_details={...l?.audio_tokens!==null&&{audio:l?.audio_tokens},...l?.cached_tokens!==null&&{cache_read:l?.cached_tokens}}),(d?.audio_tokens!==null||d?.reasoning_tokens!==null)&&(n.output_token_details={...d?.audio_tokens!==null&&{audio:d?.audio_tokens},...d?.reasoning_tokens!==null&&{reasoning:d?.reasoning_tokens}});let f=[];for(let p of a?.choices??[]){let m={text:p.message?.content??"",message:this._convertCompletionsMessageToBaseMessage(p.message??{role:"assistant"},a)};m.generationInfo={...p.finish_reason?{finish_reason:p.finish_reason}:{},...p.logprobs?{logprobs:p.logprobs}:{}},hi(m.message)&&(m.message.usage_metadata=n),m.message=new be(Object.fromEntries(Object.entries(m.message).filter(([h])=>!h.startsWith("lc_")))),f.push(m)}return{generations:f,llmOutput:{tokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}}async*_streamResponseChunks(e,t,r){let n=Gf({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:n,stream:!0},o,a=await this.completionWithRetry(i,t),s;for await(let c of a){if(t.signal?.aborted)return;let u=c?.choices?.[0];if(c.usage&&(s=c.usage),!u)continue;let{delta:l}=u;if(!l)continue;let d=this._convertCompletionsDeltaToBaseMessageChunk(l,c,o);o=l.role??o;let f={prompt:t.promptIndex??0,completion:u.index??0};if(typeof d.content!="string"){console.log("[WARNING]: Received non-string content from OpenAI. This is currently not supported.");continue}let p={...f};u.finish_reason!=null&&(p.finish_reason=u.finish_reason,p.system_fingerprint=c.system_fingerprint,p.model_name=c.model,p.service_tier=c.service_tier),this.logprobs&&(p.logprobs=u.logprobs);let m=new Xr({message:d,text:d.content,generationInfo:p});yield m,await r?.handleLLMNewToken(m.text??"",f,void 0,void 0,void 0,{chunk:m})}if(s){let c={...s.prompt_tokens_details?.audio_tokens!==null&&{audio:s.prompt_tokens_details?.audio_tokens},...s.prompt_tokens_details?.cached_tokens!==null&&{cache_read:s.prompt_tokens_details?.cached_tokens}},u={...s.completion_tokens_details?.audio_tokens!==null&&{audio:s.completion_tokens_details?.audio_tokens},...s.completion_tokens_details?.reasoning_tokens!==null&&{reasoning:s.completion_tokens_details?.reasoning_tokens}},l=new Xr({message:new at({content:"",response_metadata:{usage:{...s}},usage_metadata:{input_tokens:s.prompt_tokens,output_tokens:s.completion_tokens,total_tokens:s.total_tokens,...Object.keys(c).length>0&&{input_token_details:c},...Object.keys(u).length>0&&{output_token_details:u}}}),text:""});yield l,await r?.handleLLMNewToken(l.text??"",{prompt:0,completion:0},void 0,void 0,void 0,{chunk:l})}if(t.signal?.aborted)throw new Error("AbortError")}async completionWithRetry(e,t){let r=this._getClientOptions(t),n=e.response_format&&e.response_format.type==="json_schema";return this.caller.call(async()=>{try{return n&&!e.stream?await this.client.chat.completions.parse(e,r):await this.client.chat.completions.create(e,r)}catch(i){throw ai(i)}})}_convertCompletionsDeltaToBaseMessageChunk(e,t,r){return ET({delta:e,rawResponse:t,includeRawResponse:this.__includeRawResponse,defaultRole:r})}_convertCompletionsMessageToBaseMessage(e,t){return kT({message:e,rawResponse:t,includeRawResponse:this.__includeRawResponse})}};var Iv="__openai_function_call_ids__";function U6(e){return e.type==="url_citation"?{type:"citation",source:"url_citation",url:e.url,title:e.title,startIndex:e.start_index,endIndex:e.end_index}:e.type==="file_citation"?{type:"citation",source:"file_citation",title:e.filename,startIndex:e.index,file_id:e.file_id}:e.type==="container_file_citation"?{type:"citation",source:"container_file_citation",title:e.filename,startIndex:e.start_index,endIndex:e.end_index,file_id:e.file_id,container_id:e.container_id}:e.type==="file_path"?{type:"citation",source:"file_path",startIndex:e.index,file_id:e.file_id}:{type:"non_standard",value:e}}function dX(e){if(e.type==="url_citation"||e.type==="file_citation"||e.type==="container_file_citation"||e.type==="file_path")return e;if(e.type==="citation"){let t=e;if(t.source==="url_citation")return{type:"url_citation",url:t.url??"",title:t.title??"",start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source==="file_citation")return{type:"file_citation",file_id:t.file_id??"",filename:t.title??"",index:t.startIndex??0};if(t.source==="container_file_citation")return{type:"container_file_citation",file_id:t.file_id??"",filename:t.title??"",container_id:t.container_id??"",start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source==="file_path")return{type:"file_path",file_id:t.file_id??"",index:t.startIndex??0}}return e.type==="non_standard"?e.value:e}var $T=e=>{let t={...e?.input_tokens_details?.cached_tokens!=null&&{cache_read:e?.input_tokens_details?.cached_tokens}},r={...e?.output_tokens_details?.reasoning_tokens!=null&&{reasoning:e?.output_tokens_details?.reasoning_tokens}};return{input_tokens:e?.input_tokens??0,output_tokens:e?.output_tokens??0,total_tokens:e?.total_tokens??0,input_token_details:t,output_token_details:r}},Sv=e=>{if(e.error){let c=new Error(e.error.message);throw c.name=e.error.code,c}let t,r=[],n=[],i=[],o=e.output.map(c=>{if(c.type==="function_call"&&"parsed_arguments"in c){let u={...c};return delete u.parsed_arguments,u}return c}),a={model_provider:"openai",model:e.model,created_at:e.created_at,id:e.id,incomplete_details:e.incomplete_details,metadata:e.metadata,object:e.object,output:o,status:e.status,user:e.user,service_tier:e.service_tier,model_name:e.model},s={};for(let c of e.output)if(c.type==="message")t=c.id,r.push(...c.content.flatMap(u=>u.type==="output_text"?("parsed"in u&&u.parsed!=null&&(s.parsed=u.parsed),{type:"text",text:u.text,annotations:u.annotations.map(U6)}):u.type==="refusal"?(s.refusal=u.refusal,[]):u));else if(c.type==="function_call"){let u={function:{name:c.name,arguments:c.arguments},id:c.call_id};try{n.push(qs(u,{returnId:!0}))}catch(l){let d;typeof l=="object"&&l!=null&&"message"in l&&typeof l.message=="string"&&(d=l.message),i.push(Sa(u,d))}s[Iv]??={},c.id&&(s[Iv][c.call_id]=c.id)}else if(c.type==="reasoning"){s.reasoning=c;let u=c.summary?.map(l=>l.text).filter(Boolean).join("");u&&r.push({type:"reasoning",reasoning:u})}else if(c.type==="custom_tool_call"){let u=L2(c);u?n.push(u):i.push(Sa(c,"Malformed custom tool call"))}else if(c.type==="computer_call"){let u=U2(c);u?n.push(u):i.push(Sa(c,"Malformed computer call"))}else c.type==="image_generation_call"?(c.result&&r.push({type:"image",mimeType:"image/png",data:c.result,id:c.id,metadata:{status:c.status}}),s.tool_outputs??=[],s.tool_outputs.push(c)):(s.tool_outputs??=[],s.tool_outputs.push(c));return new be({id:t,content:r,tool_calls:n,invalid_tool_calls:i,usage_metadata:$T(e.usage),additional_kwargs:s,response_metadata:a})},F6=e=>{let t=(e.summary.length>1?e.summary.reduce((r,n)=>{let i=r[r.length-1];return i.index===n.index?i.text+=n.text:r.push(n),r},[{...e.summary[0]}]):e.summary).map(r=>Object.fromEntries(Object.entries(r).filter(([n])=>n!=="index")));return{...e,summary:t}},TT=e=>{let t=[],r={},n,i=[],o={model_provider:"openai"},a={},s;if(e.type==="response.output_text.delta")t.push({type:"text",text:e.delta,index:e.content_index});else if(e.type==="response.output_text.annotation.added")t.push({type:"text",text:"",annotations:[U6(e.annotation)],index:e.content_index});else if(e.type==="response.output_item.added"&&e.item.type==="message")s=e.item.id;else if(e.type==="response.output_item.added"&&e.item.type==="function_call")i.push({type:"tool_call_chunk",name:e.item.name,args:e.item.arguments,id:e.item.call_id,index:e.output_index}),a[Iv]={[e.item.call_id]:e.item.id};else if(e.type==="response.output_item.done"&&e.item.type==="computer_call")i.push({type:"tool_call_chunk",name:"computer_use",args:JSON.stringify({action:e.item.action}),id:e.item.call_id,index:e.output_index}),a.tool_outputs=[e.item];else if(e.type==="response.output_item.done"&&e.item.type==="image_generation_call")e.item.result&&t.push({type:"image",mimeType:"image/png",data:e.item.result,id:e.item.id,metadata:{status:e.item.status}}),a.tool_outputs=[e.item];else if(e.type==="response.output_item.done"&&["web_search_call","file_search_call","code_interpreter_call","shell_call","local_shell_call","mcp_call","mcp_list_tools","mcp_approval_request","custom_tool_call","tool_search_call","tool_search_output"].includes(e.item.type))a.tool_outputs=[e.item];else if(e.type==="response.created")o.id=e.response.id,o.model_name=e.response.model,o.model=e.response.model;else if(e.type==="response.completed"){let c=Sv(e.response);n=$T(e.response.usage),e.response.text?.format?.type==="json_schema"&&(a.parsed??=JSON.parse(c.text));for(let[u,l]of Object.entries(e.response))u!=="id"&&(u==="output"?o[u]=c.response_metadata.output:o[u]=l)}else if(e.type==="response.function_call_arguments.delta"||e.type==="response.custom_tool_call_input.delta")i.push({type:"tool_call_chunk",args:e.delta,index:e.output_index});else if(e.type==="response.web_search_call.completed"||e.type==="response.file_search_call.completed")r={tool_outputs:{id:e.item_id,type:e.type.replace("response.","").replace(".completed",""),status:"completed"}};else if(e.type==="response.refusal.done")a.refusal=e.refusal;else if(e.type==="response.output_item.added"&&"item"in e&&e.item.type==="reasoning"){let c=e.item.summary?e.item.summary.map((l,d)=>({...l,index:d})):void 0;a.reasoning={id:e.item.id,type:e.item.type,...c?{summary:c}:{}};let u=e.item.summary?.map(l=>l.text).filter(Boolean).join("");u&&t.push({type:"reasoning",reasoning:u})}else if(e.type==="response.reasoning_summary_part.added")a.reasoning={type:"reasoning",summary:[{...e.part,index:e.summary_index}]},e.part.text&&t.push({type:"reasoning",reasoning:e.part.text});else if(e.type==="response.reasoning_summary_text.delta")a.reasoning={type:"reasoning",summary:[{text:e.delta,type:"summary_text",index:e.summary_index}]},e.delta&&t.push({type:"reasoning",reasoning:e.delta});else return e.type==="response.image_generation_call.partial_image",null;return new Xr({text:t.map(c=>c.text).join(""),message:new at({id:s,content:t,tool_call_chunks:i,usage_metadata:n,additional_kwargs:a,response_metadata:o}),generationInfo:r})},B6=e=>{let t=be.isInstance(e)&&e.response_metadata?.model_provider==="openai";function*r(){let n=Fo(()=>{try{let _=Vo(e);return _==="system"||_==="developer"||_==="assistant"||_==="user"?_:"assistant"}catch{return"assistant"}}),i,o=new Set,a=new Set,s=new Map,c=new Map;function*u(){if(!i)return;let _=i.content;(typeof _=="string"&&_.length>0||Array.isArray(_)&&_.length>0)&&(yield i),i=void 0}let l=_=>{i||(i={type:"message",role:n,content:[]}),typeof i.content=="string"?i.content=i.content.length>0?[{type:"input_text",text:i.content},..._]:[..._]:i.content.push(..._)},d=_=>{if(typeof _=="string")return _;try{return JSON.stringify(_??{})}catch{return"{}"}},f=_=>{let y=Fo(()=>{let x=_.metadata?.detail;return x==="low"||x==="high"||x==="auto"?x:"auto"});if(_.fileId)return{type:"input_image",detail:y,file_id:_.fileId};if(_.url)return{type:"input_image",detail:y,image_url:_.url};if(_.data){let x=typeof _.data=="string"?_.data:Buffer.from(_.data).toString("base64");return{type:"input_image",detail:y,image_url:`data:${_.mimeType??"image/png"};base64,${x}`}}},p=_=>{if(_.fileId){let y=yT(_);return{type:"input_file",file_id:_.fileId,...y?{filename:y}:{}}}if(_.url){let y=yT(_);return{...y?{filename:y}:{},type:"input_file",file_url:_.url}}if(_.data){let y=id(_),x=typeof _.data=="string"?_.data:Buffer.from(_.data).toString("base64");return{type:"input_file",file_data:`data:${_.mimeType??"application/octet-stream"};base64,${x}`,...y?{filename:y}:{}}}},m=_=>{let y=Fo(()=>{if(Array.isArray(_.summary)){let $=_.summary?.map(j=>j?.text).filter(j=>typeof j=="string")??[];if($.length>0)return $}return _.reasoning?[_.reasoning]:[]}),x=y.length>0?y.map($=>({type:"summary_text",text:$})):[{type:"summary_text",text:""}],S={type:"reasoning",id:_.id??"",summary:x};return _.reasoning&&(S.content=[{type:"reasoning_text",text:_.reasoning}]),S},h=_=>({type:"function_call",name:_.name??"",call_id:_.id??"",arguments:d(_.args)}),w=_=>{let y=d(_.output),x=_.status==="success"?"completed":_.status==="error"?"incomplete":void 0;return{type:"function_call_output",call_id:_.toolCallId??"",output:y,...x?{status:x}:{}}};for(let _ of e.contentBlocks)if(_.type==="text")l([{type:"input_text",text:_.text}]);else if(_.type!=="invalid_tool_call"){if(_.type==="reasoning")yield*u(),yield m(_);else if(_.type==="tool_call"){yield*u();let y=_.id??"";y&&(o.add(y),s.delete(y)),yield h(_)}else if(_.type==="tool_call_chunk"){if(_.id){let y=s.get(_.id)??{name:_.name,args:[]};_.name&&(y.name=_.name),_.args&&y.args.push(_.args),s.set(_.id,y)}}else if(_.type==="server_tool_call"){yield*u();let y=_.id??"";y&&(a.add(y),c.delete(y)),yield h(_)}else if(_.type==="server_tool_call_chunk"){if(_.id){let y=c.get(_.id)??{name:_.name,args:[]};_.name&&(y.name=_.name),_.args&&y.args.push(_.args),c.set(_.id,y)}}else if(_.type==="server_tool_call_result")yield*u(),yield w(_);else if(_.type!=="audio")if(_.type==="file"){let y=p(_);y&&l([y])}else if(_.type==="image"){let y=f(_);y&&l([y])}else if(_.type==="video"){let y=p(_);y&&l([y])}else _.type==="text-plain"?_.text&&l([{type:"input_text",text:_.text}]):_.type==="non_standard"&&t&&(yield*u(),yield _.value)}yield*u();for(let[_,y]of s){if(!_||o.has(_))continue;let x=y.args.join("");!y.name&&!x||(yield{type:"function_call",call_id:_,name:y.name??"",arguments:x})}for(let[_,y]of c){if(!_||a.has(_))continue;let x=y.args.join("");!y.name&&!x||(yield{type:"function_call",call_id:_,name:y.name??"",arguments:x})}}return Array.from(r())},kv=({messages:e,zdrEnabled:t,model:r})=>e.flatMap(n=>{let i=n.response_metadata;if(i?.output_version==="v1")return B6(n);let o=n.additional_kwargs,a=Vo(n);if(a==="system"&&Bo(r)&&(a="developer"),a==="function")throw new Error("Function messages are not supported in Responses API");if(a==="tool"){let s=n;if(o?.type==="computer_call_output")return{type:"computer_call_output",output:(()=>{if(typeof s.content=="string")return{type:"input_image",image_url:s.content};if(Array.isArray(s.content)){let u=s.content.find(f=>f.type==="input_image");if(u)return u;let l=s.content.find(f=>f.type==="computer_screenshot");if(l)return l;let d=s.content.find(f=>f.type==="image_url");if(d)return{type:"input_image",image_url:typeof d.image_url=="string"?d.image_url:d.image_url.url}}throw new Error("Invalid computer call output")})(),call_id:s.tool_call_id};if(s.additional_kwargs?.customTool)return{type:"custom_tool_call_output",call_id:s.tool_call_id,output:s.content};let c=Array.isArray(s.content)&&s.content.every(u=>typeof u=="object"&&u!==null&&"type"in u&&(u.type==="input_file"||u.type==="input_image"||u.type==="input_text"));return{type:"function_call_output",call_id:s.tool_call_id,id:s.id?.startsWith("fc_")?s.id:void 0,output:c?s.content:typeof s.content!="string"?JSON.stringify(s.content):s.content}}if(a==="assistant"){if(!t&&i?.output!=null&&Array.isArray(i?.output)&&i?.output.length>0&&i?.output.every(m=>"type"in m))return i?.output;let s=[],c=o?.reasoning,u=!!c?.encrypted_content;if(c&&(!t||u)){let m=F6(c);s.push(m)}let{content:l}=n;o?.refusal&&(typeof l=="string"&&(l=[{type:"output_text",text:l,annotations:[]}]),l=[...l,{type:"refusal",refusal:o.refusal}]),(typeof l=="string"||l.length>0)&&s.push({type:"message",role:"assistant",...n.id&&!t&&n.id.startsWith("msg_")?{id:n.id}:{},content:Fo(()=>typeof l=="string"?l:l.flatMap(m=>{if(m.type==="text"){let h=m;return{type:"output_text",text:h.text,annotations:(h.annotations??[]).map(dX)}}return m.type==="output_text"||m.type==="refusal"?m:[]}))});let d=o?.[Iv];be.isInstance(n)&&n.tool_calls?.length?s.push(...n.tool_calls.map(m=>B2(m)?{type:"custom_tool_call",id:m.call_id,call_id:m.id??"",input:m.args.input,name:m.name}:F2(m)?{type:"computer_call",id:m.call_id,call_id:m.id??"",action:m.args.action}:{type:"function_call",name:m.name,arguments:JSON.stringify(m.args),call_id:m.id,...t?{}:{id:d?.[m.id]}})):o?.tool_calls&&s.push(...o.tool_calls.map(m=>({type:"function_call",name:m.function.name,call_id:m.id,arguments:m.function.arguments,...t?{}:{id:d?.[m.id]}})));let f=i?.output?.length?i?.output:o.tool_outputs,p=["computer_call","mcp_call","code_interpreter_call","image_generation_call","shell_call","local_shell_call"];if(f!=null){let m=f?.filter(h=>p.includes(h.type));m.length>0&&s.push(...m)}return s}if(a==="user"||a==="system"||a==="developer"){if(typeof n.content=="string")return{type:"message",role:a,content:n.content};let s=[],c=n.content.flatMap(u=>(u.type==="mcp_approval_response"&&s.push({type:"mcp_approval_response",approval_request_id:u.approval_request_id,approve:u.approve}),Or(u)?Hc(u,wv):u.type==="text"?{type:"input_text",text:u.text}:u.type==="image_url"?{type:"input_image",image_url:Fo(()=>{if(typeof u.image_url=="string")return u.image_url;if(typeof u.image_url=="object"&&u.image_url!==null&&"url"in u.image_url)return u.image_url.url}),detail:Fo(()=>{if(typeof u.image_url=="string")return"auto";if(typeof u.image_url=="object"&&u.image_url!==null&&"detail"in u.image_url)return u.image_url.detail})}:u.type==="input_text"||u.type==="input_image"||u.type==="input_file"?u:[]));return c.length>0&&s.push({type:"message",role:a,content:c}),s}return console.warn(`Unsupported role found when converting to OpenAI Responses API: ${a}`),[]});var Ev=class extends Rc{constructor(e,t){super(ad(e,t))}invocationParams(e){let t;e?.strict!==void 0&&(t=e.strict),t===void 0&&this.supportsStrictToolCalling!==void 0&&(t=this.supportsStrictToolCalling);let r={model:this.model,temperature:this.temperature,top_p:this.topP,user:this.user,service_tier:this.service_tier,stream:this.streaming,previous_response_id:e?.previous_response_id,truncation:e?.truncation,include:e?.include,tools:e?.tools?.length?this._reduceChatOpenAITools(e.tools,{stream:this.streaming,strict:t}):void 0,tool_choice:D2(e?.tool_choice)?e?.tool_choice:(()=>{let i=_v(e?.tool_choice);if(typeof i=="object"&&"type"in i){if(i.type==="function")return{type:"function",name:i.function.name};if(i.type==="allowed_tools")return{type:"allowed_tools",mode:i.allowed_tools.mode,tools:i.allowed_tools.tools};if(i.type==="custom")return{type:"custom",name:i.custom.name}}})(),text:(()=>{if(e?.text)return e.text;let i=this._getResponseFormat(e?.response_format);return i?.type==="json_schema"?i.json_schema.schema!=null?{format:{type:"json_schema",schema:i.json_schema.schema,description:i.json_schema.description,name:i.json_schema.name,strict:i.json_schema.strict},verbosity:e?.verbosity}:void 0:{format:i,verbosity:e?.verbosity}})(),parallel_tool_calls:e?.parallel_tool_calls,max_output_tokens:this.maxTokens===-1?void 0:this.maxTokens,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,...this.zdrEnabled?{store:!1}:{},...this.modelKwargs},n=this._getReasoningParams(e);return n!==void 0&&(r.reasoning=n),r}async _generate(e,t,r){t.signal?.throwIfAborted();let n=this.invocationParams(t);if(n.stream){let i=this._streamResponseChunks(e,t,r),o;for await(let a of i)a.message.response_metadata={...a.generationInfo,...a.message.response_metadata},o=o?.concat(a)??a;return{generations:o?[o]:[],llmOutput:{estimatedTokenUsage:o?.message?.usage_metadata}}}else{let i=await this.completionWithRetry({input:kv({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),...n,stream:!1},{signal:t?.signal,...t?.options});return{generations:[{text:i.output_text,message:Sv(i)}],llmOutput:{id:i.id,estimatedTokenUsage:i.usage?{promptTokens:i.usage.input_tokens,completionTokens:i.usage.output_tokens,totalTokens:i.usage.total_tokens}:void 0}}}}async*_streamResponseChunks(e,t,r){let n=await this.completionWithRetry({...this.invocationParams(t),input:kv({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t);for await(let i of n){if(t.signal?.aborted)return;let o=TT(i);o!=null&&(yield o,await r?.handleLLMNewToken(o.text||"",{prompt:t.promptIndex??0,completion:0},void 0,void 0,void 0,{chunk:o}))}}async completionWithRetry(e,t){return this.caller.call(async()=>{let r=this._getClientOptions(t);try{return e.text?.format?.type==="json_schema"&&!e.stream?await this.client.responses.parse(e,r):await this.client.responses.create(e,r)}catch(n){throw ai(n)}})}_reduceChatOpenAITools(e,t){let r=[];for(let n of e)if(od(n))n.type==="image_generation"&&t?.stream&&(n.partial_images=1),r.push(n);else if(Oc(n)){let i=n.metadata.customTool;r.push({type:"custom",name:i.name,description:i.description,format:i.format})}else if($p(n)){let i={};for(let[o,a]of Object.entries(n))o!=="type"&&o!=="function"&&(i[o]=a);r.push({type:"function",name:n.function.name,parameters:n.function.parameters,description:n.function.description,strict:t?.strict??null,...i})}else yv(n)&&r.push(V2(n));return r}};var $v=class V6 extends Rc{useResponsesApi=!1;responses;completions;get lc_serializable_keys(){return[...super.lc_serializable_keys,"useResponsesApi"]}get callKeys(){return[...super.callKeys,"useResponsesApi"]}fields;constructor(t,r){let n=ad(t,r);super(n),this.fields=n,this.useResponsesApi=n?.useResponsesApi??!1,this.responses=n?.responses??new Ev(n),this.completions=n?.completions??new xv(n)}_useResponsesApi(t){let r=t?.tools?.some(od),n=t?.previous_response_id!=null||t?.text!=null||t?.truncation!=null||t?.include!=null||t?.reasoning?.summary!=null||this.reasoning?.summary!=null,i=t?.tools?.some(yv)||t?.tools?.some(Oc);return this.useResponsesApi||r||n||i||C2(this.model)}getLsParams(t){let r=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.getLsParams(r):this.completions.getLsParams(r)}invocationParams(t){let r=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.invocationParams(r):this.completions.invocationParams(r)}async _generate(t,r,n){return this._useResponsesApi(r)?this.responses._generate(t,r,n):this.completions._generate(t,r,n)}async*_streamResponseChunks(t,r,n){if(this._useResponsesApi(r)){yield*this.responses._streamResponseChunks(t,this._combineCallOptions(r),n);return}yield*this.completions._streamResponseChunks(t,this._combineCallOptions(r),n)}withConfig(t){let r=new V6(this.fields);return r.defaultOptions={...this.defaultOptions,...t},r}};var Tv=class extends Fu{model="text-embedding-ada-002";modelName;batchSize=512;stripNewLines=!0;dimensions;timeout;organization;encodingFormat;client;clientConfig;apiKey;constructor(e){let t={maxConcurrency:2,...e};super(t);let r=t?.apiKey??t?.openAIApiKey??et("OPENAI_API_KEY");this.organization=t?.configuration?.organization??et("OPENAI_ORGANIZATION"),this.model=t?.model??t?.modelName??this.model,this.modelName=this.model,this.batchSize=t?.batchSize??this.batchSize,this.stripNewLines=t?.stripNewLines??this.stripNewLines,this.timeout=t?.timeout,this.dimensions=t?.dimensions,this.encodingFormat=t?.encodingFormat,this.clientConfig={apiKey:r,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration}}async embedDocuments(e){let t=sy(this.stripNewLines?e.map(o=>o.replace(/\n/g," ")):e,this.batchSize),r=t.map(o=>{let a={model:this.model,input:o};return this.dimensions&&(a.dimensions=this.dimensions),this.encodingFormat&&(a.encoding_format=this.encodingFormat),this.embeddingWithRetry(a)}),n=await Promise.all(r),i=[];for(let o=0;o<n.length;o+=1){let a=t[o],{data:s}=n[o];for(let c=0;c<a.length;c+=1)i.push(s[c].embedding)}return i}async embedQuery(e){let t={model:this.model,input:this.stripNewLines?e.replace(/\n/g," "):e};this.dimensions&&(t.dimensions=this.dimensions),this.encodingFormat&&(t.encoding_format=this.encodingFormat);let{data:r}=await this.embeddingWithRetry(t);return r[0].embedding}async embeddingWithRetry(e){if(!this.client){let r=Zo({baseURL:this.clientConfig.baseURL}),n={...this.clientConfig,baseURL:r,timeout:this.timeout,maxRetries:0};n.baseURL||delete n.baseURL,n.defaultHeaders=Go(n.defaultHeaders),this.client=new fe(n)}let t={};return this.caller.call(async()=>{try{return await this.client.embeddings.create(e,t)}catch(r){throw ai(r)}})}};var hX=M.object({type:M.literal("screenshot")}),gX=M.object({type:M.literal("click"),x:M.number(),y:M.number(),button:M.enum(["left","right","wheel","back","forward"]).default("left")}),_X=M.object({type:M.literal("double_click"),x:M.number(),y:M.number(),button:M.enum(["left","right","wheel","back","forward"]).default("left")}),yX=M.object({type:M.literal("drag"),path:M.array(M.object({x:M.number(),y:M.number()}))}),vX=M.object({type:M.literal("keypress"),keys:M.array(M.string())}),bX=M.object({type:M.literal("move"),x:M.number(),y:M.number()}),wX=M.object({type:M.literal("scroll"),x:M.number(),y:M.number(),scroll_x:M.number(),scroll_y:M.number()}),xX=M.object({type:M.literal("type"),text:M.string()}),IX=M.object({type:M.literal("wait"),duration:M.number().optional()}),SX=M.union([hX,gX,_X,yX,vX,bX,wX,xX,IX]),B6e=M.object({action:SX});var kX=M.object({type:M.literal("exec"),command:M.array(M.string()),env:M.record(M.string(),M.string()).optional(),working_directory:M.string().optional(),timeout_ms:M.number().optional(),user:M.string().optional()}),H6e=M.union([kX]);var J6e=M.object({commands:M.array(M.string()).describe("Array of shell commands to execute"),timeout_ms:M.number().optional().describe("Optional timeout in milliseconds for the commands"),max_output_length:M.number().optional().describe("Optional maximum number of characters to return from each command")});var EX=M.object({type:M.literal("create_file"),path:M.string(),diff:M.string()}),$X=M.object({type:M.literal("update_file"),path:M.string(),diff:M.string()}),TX=M.object({type:M.literal("delete_file"),path:M.string()}),eFe=M.union([EX,$X,TX]);var X6={advanced:"gpt-5.2",default:"gpt-5-mini",fast:"gpt-5.4-nano"},RT={default:"text-embedding-ada-002"},AT=new Map,Av=null,CX=()=>{let e=Ov.getDefault().helperServices;if(!e?.aiModels?.url)throw new Error("AI Models Service URL is not defined in the portal's helper services.");return e.aiModels.url},Y6=async e=>{let t=CX();AT.size===0&&(Av||(Av=(async()=>{try{let n=await fetch(`${t}/models`);if(!n.ok)throw new Error("Failed to fetch AI service discovery data.");(await n.json()).models.forEach(i=>AT.set(i.name,i))}catch(n){throw Av=null,n}})()),await Av);let r=AT.get(e);if(!r)throw new Error(`Model '${e}' is not available in the discovery service.`);return r.endpoint},PX=async(e="default")=>await Y6(X6[e]),Q6=async(e="default")=>await Y6(RT[e]),RX=async e=>{let t=await NX(),r=await Q6("default"),n=Ov.getDefault(),i=(await PT.getCredential(`${n.url}/sharing`)).token,o={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:r,token:i}};return t.postMessage(o),await new Promise((a,s)=>{let c=l=>{l.data==="completed"&&(t.removeEventListener("message",c),a())},u=l=>{t.removeEventListener("message",c),s(l instanceof Error?l:new Error("Embeddings worker error"))};t.addEventListener("message",c),t.addEventListener("error",u,{once:!0})}),t},NX=async()=>{{let e=(await import("./24MYCR6F.js")).default;return new e}},Z6=(e,t)=>t,MX=(e,t)=>({...e,...t}),jX=Xn.Root({agentExecutionContext:Xn({default:()=>({userRequest:"",assignedTask:"",priorSteps:[],messages:[]}),reducer:MX}),currentIntent:Xn({default:()=>"none",reducer:Z6}),requiresFollowUp:Xn({default:()=>!0,reducer:Z6}),stepCount:Xn({default:()=>0,reducer:(e,t)=>t??e+1})}),Xi=async(e,t)=>{await C$("trace_message",e,t)},vBe=async(e,t)=>{await C$("graph_ux_suggestion",e,t)},zX=e=>{e.currentIntent="none"},DX=async(e,t)=>{if(e.agentExecutionContext.userRequest){let n=new st(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,n],zX(e)}let r=t?.configurable?.services.agentRegistry.list().map(n=>n.agent.id)??[];return await Xi({text:`Available agents: ${[...r].join(", ")}`},t),await Xi({text:"Analyzing user input"},t),e},LX=async(e,t)=>(await Xi({text:"Exiting..."},t),e),G6=4e3,H6=e=>typeof e!="string"?void 0:e.trim()||void 0,q6=e=>e==="failed"||e==="partial"||e==="success",UX=e=>e==="failed"?"Agent failed without a summary.":e==="partial"?"Agent partially completed without a summary.":"Agent completed without a summary.",FX=(e,t)=>{let r=H6(t?.outputMessage),n=H6(t?.summary),i=t?.status;q6(i)||console.warn(`Registered agent "${e}" returned an invalid or missing status:`,i);let o=q6(i)?i:r||n?"partial":"failed";return{outputMessage:r,summary:n??r??UX(o),status:o}},BX=async(e,t)=>{let r=t?.configurable,{agentRegistry:n}=r.services,i=n?.get(e.currentIntent);if(!i)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await Xi({text:`Executing registered agent: ${i.agent.name}`},t);let o={...t??{},configurable:{...r??{},agentId:i.agent.id,context:i.getContext?await i.getContext():void 0}},a=await i.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:[...e.agentExecutionContext.priorSteps??[]]}},o);await Xi({text:`Finished executing registered agent: ${i.agent.name}`},t);let s=FX(i.agent.name,a),c=s.outputMessage,u=[...e.agentExecutionContext.messages];if(c){let l=c.length>G6?`${c.slice(0,G6-14)}
|
|
342
|
+
[truncated]`:c;u.push(new be(l))}return{...e,stepCount:e.stepCount+1,agentExecutionContext:{...e.agentExecutionContext,messages:u,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:i.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:s.summary,status:s.status}]}}},VX=(e,t,r)=>{let n=e[t];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((i,o)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(o.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ZX=async e=>(await VX(Object.assign({"./field_descriptions_prompt.md":()=>import("./W5CHGOOR.js"),"./intent_prompt.md":()=>import("./3D2FSGMT.js"),"./layer_descriptions_prompt.md":()=>import("./JDL3HFFX.js")}),`./${e}.md`,2)).default,GX=(e,t=3)=>e.filter(r=>r.type==="human").slice(-t),HX=e=>{let t=-1;for(let r=e.length-1;r>=0;r--)if(e[r]instanceof st){t=r;break}return t===-1?"":e.slice(t+1).filter(r=>r instanceof be).map(r=>r.content).join(`
|
|
343
|
+
`)},eF=e=>async(t,r)=>{let n=new Headers(r?.headers);return n.delete("Authorization"),n.delete("api-key"),e&&e.length>0&&(n.set("X-Esri-Authorization",`Bearer ${e}`),n.set("X-Esri-Request-Source","MapsSDK")),await fetch(t,{...r,headers:n})},NT=async(e="default",t=0)=>{let r=Ov.getDefault(),n=await PT.getCredential(`${r.url}/sharing`),i=X6[e],o=await PX(e);return new $v({modelName:i,apiKey:"dummy-key",...e!=="default"&&{temperature:t},configuration:{baseURL:o,fetch:eF(n.token)}})},qX=async(e="default")=>{let t=Ov.getDefault(),r=await PT.getCredential(`${t.url}/sharing`),n=RT[e],i=await Q6(e);return new Tv({modelName:n,apiKey:"dummy-key",configuration:{baseURL:i,fetch:eF(r.token)},batchSize:2048,maxConcurrency:10})},KX=e=>{let t=new Set;for(let r of e)if(hi(r)){let n=r;n.tool_calls&&n.tool_calls.length>0&&n.tool_calls.forEach(i=>{i.id&&t.add(i.id)})}return e.filter(r=>{if(as(r)){let n=r;return t.has(n.tool_call_id)}return!0})},MT=(e,t)=>{let r=Lp.fromTemplate(e);return Ea.fromMessages([r,...t])},WX=async e=>{let{promptText:t,modelTier:r,temperature:n,messages:i}=e,o=MT(t,i??[]),a=await NT(r,n);return o.pipe(a)},bBe=async e=>{let{promptText:t,modelTier:r="default",temperature:n=0,messages:i,inputVariables:o}=e,a=await(await WX({promptText:t,modelTier:r,temperature:n,messages:i})).invoke(o??{});if(typeof a=="string")return a;let s=a.content;return typeof s=="string"?s:JSON.stringify(s)},JX=async e=>{let{promptText:t,modelTier:r="default",temperature:n=0,messages:i,inputVariables:o,schema:a}=e,s=MT(t,i??[]),c=(await NT(r,n)).withStructuredOutput(a);return await s.pipe(c).invoke(o??{})},wBe=async e=>{let{promptText:t,modelTier:r="default",temperature:n=0,messages:i,inputVariables:o,tools:a}=e,s=a.length>0?KX(i??[]):i??[],c=MT(t,s),u=await NT(r,n);return await c.pipe(u.bindTools(a)).invoke(o??{})},XX=M.object({id:M.string().min(1),name:M.string().min(1),description:M.string().min(1)});M.array(XX);var YX=e=>{let t=e.map(n=>n.id),r=M.enum(t);return M.object({intent:r.nullable(),assignedTask:M.string().nullable(),requiresFollowUp:M.boolean()})},QX=async(e,t)=>{try{await Xi({text:"Asking LLM to detect intent"},t);let r=await ZX("intent_prompt"),n=(t?.configurable?.services.agentRegistry?.list()??[]).map(({agent:l})=>({id:l.id,name:l.name,description:l.description}));if(!n.length)return await Xi({text:"No agents registered; skipping intent detection"},t),{...e,currentIntent:"none"};let i=n.map(l=>JSON.stringify(l)).join(`
|
|
344
|
+
`),o=YX(n),a={registeredAgents:i,priorSteps:e.agentExecutionContext.priorSteps,userRequest:e.agentExecutionContext.userRequest},s=await JX({promptText:r,schema:o,messages:GX(e.agentExecutionContext.messages),inputVariables:a});console.log("Raw intent detection output:",s);let c=s.intent??"none",u={...e,currentIntent:c,requiresFollowUp:s.requiresFollowUp,agentExecutionContext:{...e.agentExecutionContext,assignedTask:s.assignedTask??""}};return await Xi({text:`Intent came back as: ${c}`},t),await Xi({text:`Agent picked: ${c}
|
|
345
|
+
Task Assigned: ${s.assignedTask??""}`},t),u}catch(r){throw await Xi({text:"Error during intent detection"},t),new Error(`Error during intent detection: ${r instanceof Error?r.message:String(r)}`)}},K6=3,eY=()=>new Vy(jX).addNode("ingestInput",DX).addNode("intentLLM",QX).addNode("executeRegisteredAgent",BX).addNode("exit",LX).addEdge(Ye,"ingestInput").addEdge("ingestInput","intentLLM").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",e=>(console.log("[Dispatcher][executeRegisteredAgent]",{intent:e.currentIntent,followUp:e.requiresFollowUp,step:e.stepCount,maxSteps:K6}),!e.requiresFollowUp||e.stepCount>=K6?"exit":"intentLLM")).addEdge("exit",it),OT=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:r}=t;if(this.agentRegistry.has(r.id))throw new Error(`Duplicate agent id: ${r.id}`);this.agentRegistry.set(r.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},CT=class{constructor(t,r){this.graph=t,this.config={...r}}async waitForUser(){return await new Promise((t,r)=>{this.resolveWait=t,this.rejectWait=r})}handle(t,r){try{let n={agentId:t.agentId,id:t.id,payload:r},i=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:n},subgraphs:!0,version:"v2"});this.resolveWait?.(i)}catch(n){this.rejectWait?.(n)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},tY=async e=>{try{return await(await qX()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},tF=async(e,t)=>{let r=t.get(e);if(r)return r;let n=await tY([e]);return t.set(e,n[0]),n[0]};async function rY(e,t,r,n){let i=`req-${Date.now()}`,o={type:"layerSearch",precomputedEmbedding:n?await tF(e,n):void 0,requestId:i,minScore:r};return await new Promise(a=>{let s=c=>{c.data.requestId===i&&a(c.data.results)};t.addEventListener("message",s,{once:!0}),t.postMessage(o)})}function nY(e){let{worker:t}=e;return{async searchLayers({text:r,minScore:n,embeddingCache:i}){return await rY(r,t,n,i)}}}var iY=async({combinedQuery:e,layerIds:t,embeddingsWorker:r,minScore:n,topResults:i,embeddingCache:o})=>{let a=`req-${Date.now()}`,s=o?await tF(e,o):void 0,c={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:s,requestId:a,minScore:n,topResults:i};return await new Promise(u=>{let l=d=>{if(d.data.requestId!==a)return;let f=d.data.results.map(({layerId:p,results:m})=>({layerId:p,results:m}));u(f)};r.addEventListener("message",l,{once:!0}),r.postMessage(c)})};function oY(e){let{worker:t}=e;return{async searchFields({text:r,layerIds:n,minScore:i,topResults:o,embeddingCache:a}){return await iY({combinedQuery:r,layerIds:n,embeddingsWorker:t,minScore:i,topResults:o,embeddingCache:a})}}}var aY="0.1",Hf=1536,sY="openai",cY=RT.default,uY=`Name: {name}
|
|
346
|
+
Title: {title}
|
|
347
|
+
Description: {description}`,lY=`Name: {name}
|
|
348
|
+
Alias: {alias}
|
|
349
|
+
Description: {description}`,dY=M.object({schemaVersion:M.literal(aY),modified:M.number().int().nonnegative(),embeddings:M.object({modelProvider:M.literal(sY),model:M.literal(cY),dimensions:M.literal(Hf),templates:M.object({layer:M.string().default(uY),field:M.string().default(lY)})}),layers:M.array(M.object({id:M.string().min(1),name:M.string().min(1),title:M.string().catch(""),description:M.string().catch(""),vector:M.array(M.number()).length(Hf,{message:`Layer vector must be exactly ${Hf} dimensions`}),fields:M.array(M.object({name:M.string().min(1),alias:M.string().catch(""),description:M.string().catch(""),vector:M.array(M.number()).length(Hf,{message:`Field vector must be exactly ${Hf} dimensions`})}))})).default([])}),pY=e=>{let t=dY.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},fY=(e,t)=>{let r=new Map,n=new Map;if(t.allLayers.forEach(i=>{i instanceof AX&&n.set(i.id,i)}),e.length!==n.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let i of e){let o=n.get(i.id);if(!o)throw new Error(`Layer with ID ${i.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(i.fields.length!==o.fields.length)throw new Error(`Field count mismatch for layer ID ${i.id} during registry restoration. Regenerate embeddings.`);let a={name:i.name,title:i.title,description:i.description},s=new Map;for(let c of i.fields){let u=o.fieldsIndex.get(c.name);if(!u)throw new Error(`Field with name ${c.name} not found in the original layer ${i.id} during registry restoration. Regenerate embeddings.`);s.set(c.name,{name:c.name,alias:c.alias,description:c.description,type:u.type||"unknown",valueType:u.valueType||"unknown",domain:o.getFieldDomain(c.name)??void 0})}r.set(i.id,{layerItem:a,fieldRegistry:s})}return r},mY=async e=>{try{return(await OX(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},hY=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:r}=await t.portalItem.fetchResources(),n=r.find(o=>o.resource.path==="embeddings-v01.json");if(!n?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let i=await mY(n.resource.url);return pY(i)},W6=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.threadId="",this.agentRegistry=new OT,this.streamEpoch=0}static async init(t){let r=new e;try{if(t.view?.map){await J6.whenOnce(()=>t.view.ready);let n=await hY(t.view),i=fY(n.layers,t.view.map);r.layersAndFieldsRegistry=i,r.embeddingsWorker=await RX(n)}return t.agents?.forEach(n=>{r.agentRegistry.register(n)}),r.orchestratorReady=!0,r}catch(n){throw console.error("Orchestrator initialization failed:",n),n}}async*ask(t){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");if(++this.streamEpoch,!t.trim())return;this.threadId=String(Date.now()),this.graph||(this.graph=eY().compile({checkpointer:new yy}));let r=this.embeddingsWorker?nY({worker:this.embeddingsWorker}):void 0,n=this.embeddingsWorker?oY({worker:this.embeddingsWorker}):void 0,i=new Map,o={version:"v2",streamMode:"custom",configurable:{thread_id:this.threadId,hitlResponse:null,services:{layerSearch:r,fieldSearch:n,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:this.agentRegistry,embeddingCache:i}},subgraphs:!0},a=this.graph?.streamEvents({agentExecutionContext:{userRequest:t,messages:this.chatHistory,priorSteps:this.priorSteps}},o),s=++this.streamEpoch;for(yield*this.pipeStream(a,s);;){let u=(await this.graph.getState(o,{subgraphs:!0})).tasks.find(l=>l.interrupts.length>0)?.interrupts[0]?.value;if(!u)break;this.currentInterrupt=u,this.interruptHandler=new CT(this.graph,o),yield{runId:this.threadId,timestamp:Date.now(),type:"interrupt",interrupt:u};try{let l=await this.interruptHandler.waitForUser(),d=++this.streamEpoch;yield*this.pipeStream(l,d)}catch(l){if(l){yield{runId:this.threadId,timestamp:Date.now(),type:"error",error:{message:l?.message}};return}yield{runId:this.threadId,timestamp:Date.now(),type:"cancelled"};return}}let c=(await this.graph.getState(o,{subgraphs:!0})).values;this.chatHistory=c.agentExecutionContext.messages.length?c.agentExecutionContext.messages:this.chatHistory,this.priorSteps=c.agentExecutionContext.priorSteps?.slice(-5)??[],yield{runId:this.threadId,timestamp:Date.now(),type:"completed",result:{content:HX(c.agentExecutionContext.messages)}}}newConversation(){this.chatHistory=[],this.priorSteps=[]}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}async*pipeStream(t,r){for await(let n of t){if(r!==this.streamEpoch){console.log("Stale stream detected, aborting.");break}n.event==="on_custom_event"&&n.name==="trace_message"?yield{runId:this.threadId,timestamp:Date.now(),type:"trace",data:n.data}:n.name==="graph_ux_suggestion"&&(yield{runId:this.threadId,timestamp:Date.now(),type:"ux-suggestion",suggestion:n.data})}}dispose(){this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}},gY=$n.object({name:$n.string(),description:$n.string(),valueType:$n.string(),alias:$n.string()}),xBe=$n.object({fields:$n.array(gY)});var IBe=$n.object({title:$n.string(),description:$n.string(),name:$n.string().nullable()});return{a:Ye,b:it,c:At,d:Ar,e:Nt,f:Qf,g:ro,h:ft,i:jt,j:be,k:hi,l:M,m:af,n:Xn,o:ur,p:ic,q:Vy,r:$n,s:Xi,t:vBe,u:bBe,v:JX,w:wBe,x:W6}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request")
|