@esri/solutions-components 5.1.0-next.11 → 5.1.0-next.111
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/2B4SGB3I.js +2 -0
- package/dist/cdn/{CEP54NLT.js → 2C4DK6YC.js} +1 -1
- package/dist/cdn/{QAVXLETM.js → 2DE4VFXQ.js} +1 -1
- package/dist/cdn/2JUKGS2K.js +2 -0
- package/dist/cdn/35JHUNE2.js +2 -0
- package/dist/cdn/37Z6XQVC.js +2 -0
- package/dist/cdn/3CDGBSG2.js +2 -0
- package/dist/cdn/{JMU5KKZH.js → 3FOUGCWY.js} +1 -1
- package/dist/cdn/3ITZDI72.js +4 -0
- package/dist/cdn/{4FBEUQIB.js → 3JVQG3QA.js} +19 -19
- package/dist/cdn/{KHHT54BU.js → 3OLSNMWN.js} +1 -1
- package/dist/cdn/{7DVOR4SY.js → 3WKKIXVT.js} +1 -1
- package/dist/cdn/3YKRLNDA.js +2 -0
- package/dist/cdn/42SCVEP5.js +2 -0
- package/dist/cdn/4DNXJC4H.js +2 -0
- package/dist/cdn/{NDUAEC62.js → 4F57JHMM.js} +1 -1
- package/dist/cdn/{4NMQFFJ5.js → 4LXJECAT.js} +1 -1
- package/dist/cdn/4SU2ROO4.js +2 -0
- package/dist/cdn/54AE7WD2.js +2 -0
- package/dist/cdn/5CONX4G5.js +2 -0
- package/dist/cdn/{BDXIKPLU.js → 5HZMUGQD.js} +1 -1
- package/dist/cdn/{26K4UTAF.js → 5IIGQVJO.js} +1 -1
- package/dist/cdn/{EYXOOK3V.js → 5MVIKBSS.js} +1 -1
- package/dist/cdn/{4HFHJOS3.js → 5O53T3SW.js} +1 -1
- package/dist/cdn/{G2ME4BAQ.js → 5VDDAINK.js} +1 -1
- package/dist/cdn/5X73H45I.js +2 -0
- package/dist/cdn/6F3ZITXR.js +2 -0
- package/dist/cdn/{TUGKPWRB.js → 6GSCRFFW.js} +1 -1
- package/dist/cdn/{T745GPG3.js → 6RTR35JT.js} +1 -1
- package/dist/cdn/6VMC6VU3.js +2 -0
- package/dist/cdn/{2BJD5X34.js → 6XHQDX4R.js} +1 -1
- package/dist/cdn/{AA7X6GKH.js → 6ZKZSCOA.js} +1 -1
- package/dist/cdn/{TER4MTK6.js → 7K2BSAIP.js} +1 -1
- package/dist/cdn/{GEKZO6V7.js → 7SDU3PS7.js} +1 -1
- package/dist/cdn/7X32DUXU.js +2 -0
- package/dist/cdn/{TZL2746B.js → A4NILC27.js} +1 -1
- package/dist/cdn/A4RZESK7.js +4 -0
- package/dist/cdn/A72KNPDC.js +2 -0
- package/dist/cdn/{VZPEYWYR.js → A75GYZAK.js} +1 -1
- package/dist/cdn/AC4RMGO6.js +2 -0
- package/dist/cdn/AGQHVMKE.js +2 -0
- package/dist/cdn/{45M33Q5G.js → AJZDBHB6.js} +1 -1
- package/dist/cdn/AN52NHQI.js +2 -0
- package/dist/cdn/ANJGKFNJ.js +2 -0
- package/dist/cdn/AVRGQSFV.js +2 -0
- package/dist/cdn/{BPAYAR53.js → AZ4JB3M3.js} +1 -1
- package/dist/cdn/{ELD2UQO4.js → B3BR2NG5.js} +1 -1
- package/dist/cdn/{3E6HSVYO.js → B7WKBO7P.js} +1 -1
- package/dist/cdn/{BPVYL3DJ.js → BJBUCNKW.js} +1 -1
- package/dist/cdn/BJDRTFKQ.js +2 -0
- package/dist/cdn/BJR4LFTB.js +2 -0
- package/dist/cdn/BKDURHMM.js +2 -0
- package/dist/cdn/BMF7MU4P.js +2 -0
- package/dist/cdn/{UK4O67GV.js → BQVD2BBH.js} +1 -1
- package/dist/cdn/{6XELM7OM.js → BSBNPUTI.js} +1 -1
- package/dist/cdn/BTGIA7F4.js +2 -0
- package/dist/cdn/{TVCG3ZCH.js → BXOH6SN4.js} +1 -1
- package/dist/cdn/BXRB7X5V.js +50 -0
- package/dist/cdn/BYX4GLKL.js +2 -0
- package/dist/cdn/{5UQRM2YJ.js → C4IFGE7P.js} +1 -1
- package/dist/cdn/{P2YLMWCT.js → C5AR5K23.js} +1 -1
- package/dist/cdn/{3XVYTVMS.js → C5QZMZX7.js} +1 -1
- package/dist/cdn/{3I5UIOSI.js → CCSQ3OEW.js} +1 -1
- package/dist/cdn/CCUDERJM.js +2 -0
- package/dist/cdn/{E7W2OZL3.js → CGFMGQ3A.js} +1 -1
- package/dist/cdn/CL2YRX2S.js +2 -0
- package/dist/cdn/{UF67SSGX.js → CN6TLQGH.js} +1 -1
- package/dist/cdn/{YMWYAWT6.js → CPV3ZZNT.js} +1 -1
- package/dist/cdn/{PJ5ORVU5.js → CQRK2NYK.js} +1 -1
- package/dist/cdn/CYOAGVBU.js +2 -0
- package/dist/cdn/D4YPSPYU.js +2 -0
- package/dist/cdn/{JALU4653.js → D5Y4JMF7.js} +1 -1
- package/dist/cdn/{JDVVMD4S.js → D66IBZZA.js} +1 -1
- package/dist/cdn/DFYZSN43.js +2 -0
- package/dist/cdn/DGUS2OKW.js +2 -0
- package/dist/cdn/{JYM2MD3W.js → DI2EBGJ3.js} +1 -1
- package/dist/cdn/DMAGF5NK.js +2 -0
- package/dist/cdn/DVIDBBJX.js +2 -0
- package/dist/cdn/{DLBZRD4H.js → E3C3HXK2.js} +1 -1
- package/dist/cdn/{U6ALIHIC.js → E4GB5Z4R.js} +1 -1
- package/dist/cdn/EKVVDMWB.js +2 -0
- package/dist/cdn/EMYFWPJ5.js +2 -0
- package/dist/cdn/{5KD4GK7Y.js → EOVYCA4H.js} +1 -1
- package/dist/cdn/{AM5URNYD.js → EUPJV6QI.js} +1 -1
- package/dist/cdn/{ANX2J4ID.js → EWUZF57U.js} +1 -1
- package/dist/cdn/{PFLQDK3I.js → FIDFM7GS.js} +1 -1
- package/dist/cdn/FKA4WB46.js +2 -0
- package/dist/cdn/FTOA3QJU.js +2 -0
- package/dist/cdn/FTVYIREU.js +2 -0
- package/dist/cdn/{3AQ7U2PF.js → FV3ILJ4J.js} +1 -1
- package/dist/cdn/G4RZYVWS.js +2 -0
- package/dist/cdn/{3FMOO3PJ.js → GF4QELNV.js} +1 -1
- package/dist/cdn/{QHYG6C3L.js → GIANH6D4.js} +1 -1
- package/dist/cdn/GQLCVOIO.js +2 -0
- package/dist/cdn/GQSGFD3A.js +2 -0
- package/dist/cdn/GWS7GDTT.js +2 -0
- package/dist/cdn/{XPIAEAK5.js → GWSB6X4X.js} +1 -1
- package/dist/cdn/GYL4W6ZG.js +33 -0
- package/dist/cdn/{C75PU7NQ.js → H2I34QW7.js} +1 -1
- package/dist/cdn/HG7ONXRZ.js +2 -0
- package/dist/cdn/HNF4PBGT.js +2 -0
- package/dist/cdn/{TXLUSSRB.js → HPJODZ44.js} +1 -1
- package/dist/cdn/{7CXQ3R3O.js → HS4FIDIG.js} +1 -1
- package/dist/cdn/{36HEIJAI.js → HS6NJWE7.js} +1 -1
- package/dist/cdn/I4N2RPKJ.js +2 -0
- package/dist/cdn/IRRMUFW7.js +2 -0
- package/dist/cdn/ISCTUP5U.js +2 -0
- package/dist/cdn/IVVJNDP6.js +7 -0
- package/dist/cdn/{NA7S3IMW.js → IVXHTNAZ.js} +1 -1
- package/dist/cdn/{B3R52L7H.js → JBNWEBAG.js} +1 -1
- package/dist/cdn/{I3D5WRYZ.js → JFJRHOAG.js} +1 -1
- package/dist/cdn/{HUF4HX5R.js → JLDT4MDK.js} +1 -1
- package/dist/cdn/{YMETU3CL.js → JLGYUZRP.js} +1 -1
- package/dist/cdn/JMO7ZFWL.js +26 -0
- package/dist/cdn/JQLLXM7G.js +11 -0
- package/dist/cdn/{7GPGKDLH.js → JR5GBFT2.js} +1 -1
- package/dist/cdn/{X4LKJTY5.js → K5MMGZY2.js} +1 -1
- package/dist/cdn/{SEDPMCMZ.js → KLK6VI3Y.js} +1 -1
- package/dist/cdn/{LPJHRY3Y.js → KP3AJBAI.js} +1 -1
- package/dist/cdn/KRK3HJKJ.js +2 -0
- package/dist/cdn/LES6DTSC.js +2 -0
- package/dist/cdn/{T2FOSTMH.js → LESMGBXJ.js} +1 -1
- package/dist/cdn/LL62WUTX.js +2 -0
- package/dist/cdn/LMSRZ4U3.js +2 -0
- package/dist/cdn/{ADR7DVCB.js → LQ2J6MVC.js} +1 -1
- package/dist/cdn/LS5WOH7V.js +2 -0
- package/dist/cdn/{ZDMOQS37.js → M6JBJMEG.js} +1 -1
- package/dist/cdn/{4JXVKICV.js → MBLK4P7W.js} +1 -1
- package/dist/cdn/{VIWNXKUP.js → MGAKD4WY.js} +1 -1
- package/dist/cdn/{GYPII3T6.js → MGEBTXZW.js} +1 -1
- package/dist/cdn/MJTM44UR.js +2 -0
- package/dist/cdn/{EYBEUSBG.js → MOK7GNOH.js} +1 -1
- package/dist/cdn/{H3LJVYII.js → MYPJ63EE.js} +1 -1
- package/dist/cdn/MZXUUA7G.js +16 -0
- package/dist/cdn/{LPBP7CBN.js → N2KSPEVT.js} +1 -1
- package/dist/cdn/{G7XCRE3X.js → NJAG5LJD.js} +1 -1
- package/dist/cdn/NSKVOAA7.js +2 -0
- package/dist/cdn/NUVJH534.js +2 -0
- package/dist/cdn/NYMSGGDH.js +2 -0
- package/dist/cdn/{T3JHAFWW.js → NYWKJJKK.js} +1 -1
- package/dist/cdn/OJ75PR7L.js +2 -0
- package/dist/cdn/P6OCRGFK.js +2 -0
- package/dist/cdn/PERCQYO6.js +18 -0
- package/dist/cdn/{Q5T633MH.js → PK6J4TA3.js} +1 -1
- package/dist/cdn/PRXFYNIG.js +19 -0
- package/dist/cdn/Q2I3FISB.js +2 -0
- package/dist/cdn/Q5XUSNQQ.js +2 -0
- package/dist/cdn/QCXFCAG2.js +2 -0
- package/dist/cdn/QGAFD25H.js +2 -0
- package/dist/cdn/QK5JWCPU.js +2 -0
- package/dist/cdn/QKKYYRVF.js +2 -0
- package/dist/cdn/QKVV2HDV.js +2 -0
- package/dist/cdn/{7JEVFHRJ.js → QLOWHDGX.js} +1 -1
- package/dist/cdn/{WFB4USZL.js → QQPHJ4FW.js} +1 -1
- package/dist/cdn/QSNXXNJX.js +2 -0
- package/dist/cdn/{KV4JOMXV.js → QZJGSWNM.js} +1 -1
- package/dist/cdn/R4CWTPJM.js +2 -0
- package/dist/cdn/RF3IQI3Z.js +423 -0
- package/dist/cdn/{NOIG2A4U.js → RH47YGDG.js} +1 -1
- package/dist/cdn/RTEEGE26.js +2 -0
- package/dist/cdn/RYETW3AF.js +6 -0
- package/dist/cdn/{S423P2GA.js → S3TMLXGP.js} +1 -1
- package/dist/cdn/{AI3I2TOG.js → SECIT3YS.js} +1 -1
- package/dist/cdn/{FTMEQQF5.js → SH72A5PB.js} +1 -1
- package/dist/cdn/{ZIAMLGUC.js → SJ2P5I4G.js} +1 -1
- package/dist/cdn/{CZKXDUOH.js → SMNWKCWR.js} +1 -1
- package/dist/cdn/{NH5526ON.js → SNBTGG5B.js} +1 -1
- package/dist/cdn/{LNLCO244.js → SNE4DYFB.js} +1 -1
- package/dist/cdn/SXVCHOTK.js +79 -0
- package/dist/cdn/{MS4ASDJL.js → T2CAAOQC.js} +1 -1
- package/dist/cdn/TCEWQ6AH.js +2 -0
- package/dist/cdn/{ZYRNI524.js → TJDAE43J.js} +1 -1
- package/dist/cdn/{XYOCI4UP.js → TWU3XHBQ.js} +1 -1
- package/dist/cdn/{NLTK53B2.js → TX6RNT22.js} +1 -1
- package/dist/cdn/{5EBHORLK.js → UNJV2PKC.js} +1 -1
- package/dist/cdn/{XVRRQMOP.js → UV6ETUNG.js} +1 -1
- package/dist/cdn/{UDGR2GC5.js → V52O7WYV.js} +1 -1
- package/dist/cdn/VEZDLO5O.js +2 -0
- package/dist/cdn/VJCNI3S6.js +2 -0
- package/dist/cdn/VLTIETO7.js +2 -0
- package/dist/cdn/{JLYGSQEC.js → VMSV2EDE.js} +1 -1
- package/dist/cdn/VPE3OYTO.js +2 -0
- package/dist/cdn/VUOLILJK.js +2 -0
- package/dist/cdn/{P4FX4W2X.js → VYAJBOTD.js} +1 -1
- package/dist/cdn/WCS5ISFW.js +2 -0
- package/dist/cdn/{MZDSTI7I.js → WEITLOQD.js} +1 -1
- package/dist/cdn/WFHPQFNH.js +2 -0
- package/dist/cdn/{DIDOZ4J6.js → WH2NFOMH.js} +5 -5
- package/dist/cdn/WNWWPP3L.js +2 -0
- package/dist/cdn/WNZGZMLN.js +2 -0
- package/dist/cdn/WPGT2HLS.js +2 -0
- package/dist/cdn/{EXMZUQW5.js → WRDDXISM.js} +1 -1
- package/dist/cdn/{RTUAITMO.js → WYWQJDHW.js} +1 -1
- package/dist/cdn/{XXQKFENH.js → X26QOEYN.js} +1 -1
- package/dist/cdn/X3AFBSXC.js +2 -0
- package/dist/cdn/{YIQVAISO.js → XC5GR7ET.js} +1 -1
- package/dist/cdn/XFIT6JYM.js +2 -0
- package/dist/cdn/XFSGLLBP.js +2 -0
- package/dist/cdn/{3TYPFWRB.js → XHV66O3B.js} +1 -1
- package/dist/cdn/XQQ52NKX.js +2 -0
- package/dist/cdn/Y2ROEEOX.js +3 -0
- package/dist/cdn/{WNI44LDP.js → Y36XZKHC.js} +1 -1
- package/dist/cdn/{VXMIT5WR.js → Y3CYPNEY.js} +1 -1
- package/dist/cdn/YERZQ5GL.js +4 -0
- package/dist/cdn/{KU62OLRE.js → YFXSWGXE.js} +1 -1
- package/dist/cdn/YJMN3BSG.js +2 -0
- package/dist/cdn/{3IHLJADI.js → YKB6256M.js} +1 -1
- package/dist/cdn/YN7GO7C7.js +2 -0
- package/dist/cdn/YOO4OQMD.js +2 -0
- package/dist/cdn/{AJY7XD7A.js → Z25OUDBP.js} +1 -1
- package/dist/cdn/{3BWIMFV4.js → Z54LP7Q3.js} +1 -1
- package/dist/cdn/Z7UB6Y73.js +2 -0
- package/dist/cdn/{7GNDNQTX.js → ZAMDHZSB.js} +1 -1
- package/dist/cdn/ZGAP3FGE.js +2 -0
- package/dist/cdn/ZHIIV7VJ.js +2 -0
- package/dist/cdn/ZUDEZGGC.js +102 -0
- package/dist/cdn/{T537IZUH.js → ZV6TCDGB.js} +1 -1
- package/dist/cdn/{3HALRHHO.js → ZWZJZRZF.js} +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/buffer-tools/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/card-manager/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/consent-manager/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/create-feature/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/create-feature/t9n/messages.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/create-related-feature/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/crowdsource-manager/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/crowdsource-reporter/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/edit-card/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/field-selection/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/info-card/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/layer-table/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/layer-table/t9n/messages.json +1 -1
- package/dist/cdn/assets/map-card/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/map-card/t9n/messages.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/map-picker/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/images/conduct-field-inspections.png +0 -0
- package/dist/cdn/assets/solution-builder-assistant/images/locate-points-of-interest.png +0 -0
- package/dist/cdn/assets/solution-builder-assistant/images/manage-spatial-data.png +0 -0
- package/dist/cdn/assets/solution-builder-assistant/images/solutions-builder-draft-thumbnail.png +0 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ar.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bg.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bs.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ca.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.cs.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.da.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.de.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.el.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.es.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.et.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fi.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fr.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.he.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hr.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hu.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.id.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.it.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ja.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ko.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lt.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lv.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.nl.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.no.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pl.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-BR.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-PT.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ro.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ru.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sk.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sl.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sr.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sv.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.th.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.tr.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.uk.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.vi.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-CN.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-HK.json +1 -0
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-TW.json +1 -0
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-deployed-card-panel/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-deploying-dialog/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-details-card/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-details-panel/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-item-accordion/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solutions-all-shell/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solutions-deploy-app/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solutions-deployed-list/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/solutions-deployed-list/t9n/messages.json +1 -0
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solutions-filter-panel/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/Auth.js +52 -33
- package/dist/chunks/CardsFetcher.js +287 -0
- package/dist/chunks/cardFetchingUtils.js +23 -304
- package/dist/chunks/cardsHelpers.js +10 -10
- package/dist/chunks/common.js +26 -0
- package/dist/chunks/converter.js +643 -0
- package/dist/chunks/deployAppContexts.js +4 -3
- package/dist/chunks/description.js +36 -0
- package/dist/chunks/designSolution.js +105 -0
- package/dist/chunks/downloadUtils.js +246 -235
- package/dist/chunks/findExistingSolution.js +22 -0
- package/dist/chunks/get.js +387 -0
- package/dist/chunks/getItemIcon.js +19 -10
- package/dist/chunks/helpers.js +140 -0
- package/dist/chunks/initialAssessment.js +82 -0
- package/dist/chunks/interfaces.js +198 -327
- package/dist/chunks/popupUtils.js +3 -3
- package/dist/chunks/queryUtils.js +3 -3
- package/dist/chunks/solution-deploy-dialog.js +112 -103
- package/dist/chunks/solutions-deploy-app-nav.js +111 -85
- package/dist/chunks/solutions_assistant_description.js +14 -0
- package/dist/chunks/solutions_assistant_prompts.js +29 -0
- package/dist/chunks/solutions_explorer_description.js +19 -0
- package/dist/chunks/templates.js +65 -0
- package/dist/chunks/updateDesign.js +5 -0
- package/dist/chunks/validators.js +127 -0
- package/dist/components/arcgis-solutions-assistant/customElement.d.ts +58 -83
- package/dist/components/arcgis-solutions-assistant/customElement.js +58375 -1531
- package/dist/components/arcgis-solutions-assistant/index.js +5 -8
- package/dist/components/buffer-tools/customElement.d.ts +6 -3
- package/dist/components/buffer-tools/customElement.js +5 -5
- package/dist/components/card-manager/customElement.d.ts +36 -3
- package/dist/components/card-manager/customElement.js +89 -21
- package/dist/components/card-manager/index.js +1 -0
- package/dist/components/consent-manager/customElement.d.ts +2 -2
- package/dist/components/consent-manager/customElement.js +1864 -2224
- package/dist/components/create-feature/customElement.d.ts +10 -2
- package/dist/components/create-feature/customElement.js +230 -259
- package/dist/components/create-feature/index.js +2 -0
- package/dist/components/create-related-feature/customElement.d.ts +13 -5
- package/dist/components/create-related-feature/customElement.js +8 -8
- package/dist/components/crowdsource-manager/customElement.d.ts +8 -0
- package/dist/components/crowdsource-manager/customElement.js +49 -40
- package/dist/components/crowdsource-reporter/customElement.d.ts +10 -2
- package/dist/components/crowdsource-reporter/customElement.js +12 -12
- package/dist/components/deduct-calculator/customElement.js +5 -5
- package/dist/components/delete-button/customElement.d.ts +2 -2
- package/dist/components/delete-button/customElement.js +1 -1
- package/dist/components/delete-dialog/customElement.d.ts +3 -3
- package/dist/components/edit-card/customElement.d.ts +15 -7
- package/dist/components/edit-card/customElement.js +37 -42
- package/dist/components/edit-card/index.js +1 -0
- package/dist/components/feature-details/customElement.d.ts +7 -6
- package/dist/components/feature-details/customElement.js +5 -5
- package/dist/components/feature-list/customElement.d.ts +4 -3
- package/dist/components/feature-list/customElement.js +5 -5
- package/dist/components/field-selection/customElement.d.ts +6 -4
- package/dist/components/field-selection/customElement.js +75 -67
- package/dist/components/info-card/customElement.d.ts +34 -10
- package/dist/components/info-card/customElement.js +93 -86
- package/dist/components/info-card/index.js +1 -0
- package/dist/components/layer-list/customElement.d.ts +2 -2
- package/dist/components/layer-list/customElement.js +4 -4
- package/dist/components/layer-list-widget/customElement.d.ts +6 -9
- package/dist/components/layer-list-widget/customElement.js +12 -29
- package/dist/components/layer-list-widget/index.js +1 -0
- package/dist/components/layer-table/customElement.d.ts +37 -3
- package/dist/components/layer-table/customElement.js +137 -74
- package/dist/components/map-basemap-gallery/customElement.d.ts +6 -8
- package/dist/components/map-basemap-gallery/customElement.js +31 -38
- package/dist/components/map-basemap-gallery/index.js +1 -0
- package/dist/components/map-card/customElement.d.ts +44 -10
- package/dist/components/map-card/customElement.js +64 -46
- package/dist/components/map-card/index.js +1 -0
- package/dist/components/map-draw-tools/customElement.d.ts +15 -11
- package/dist/components/map-draw-tools/customElement.js +80 -114
- package/dist/components/map-draw-tools/index.js +1 -0
- package/dist/components/map-floor-filter/customElement.d.ts +6 -8
- package/dist/components/map-floor-filter/customElement.js +22 -45
- package/dist/components/map-floor-filter/index.js +1 -0
- package/dist/components/map-fullscreen/customElement.d.ts +6 -4
- package/dist/components/map-fullscreen/customElement.js +14 -34
- package/dist/components/map-fullscreen/index.js +1 -0
- package/dist/components/map-layer-picker/customElement.d.ts +2 -2
- package/dist/components/map-layer-picker/customElement.js +15 -11
- package/dist/components/map-legend/customElement.d.ts +6 -8
- package/dist/components/map-legend/customElement.js +14 -30
- package/dist/components/map-legend/index.js +1 -0
- package/dist/components/map-picker/customElement.d.ts +7 -1
- package/dist/components/map-picker/customElement.js +3 -3
- package/dist/components/map-search/customElement.d.ts +8 -6
- package/dist/components/map-search/customElement.js +25 -52
- package/dist/components/map-search/index.js +1 -0
- package/dist/components/map-select-tools/customElement.d.ts +24 -12
- package/dist/components/map-select-tools/customElement.js +49 -60
- package/dist/components/map-select-tools/index.js +1 -0
- package/dist/components/map-tools/customElement.d.ts +15 -7
- package/dist/components/map-tools/customElement.js +95 -102
- package/dist/components/map-tools/index.js +1 -1
- package/dist/components/pci-calculator/customElement.js +5 -5
- package/dist/components/pdf-download/customElement.d.ts +3 -3
- package/dist/components/pdf-download/customElement.js +1 -1
- package/dist/components/public-notification/customElement.d.ts +15 -11
- package/dist/components/public-notification/customElement.js +158 -74
- package/dist/components/refine-selection/customElement.d.ts +15 -9
- package/dist/components/refine-selection/customElement.js +20 -20
- package/dist/components/selection-tool/customElement.d.ts +3 -3
- package/dist/components/selection-tool/customElement.js +3 -3
- package/dist/components/solution-builder-assistant/customElement.d.ts +247 -0
- package/dist/components/solution-builder-assistant/customElement.js +799 -0
- package/dist/components/solution-builder-assistant/index.d.ts +1 -0
- package/dist/components/solution-builder-assistant/index.js +27 -0
- package/dist/components/solution-configure-titles/customElement.js +80 -64
- package/dist/components/solution-delete-dialog/customElement.js +29 -27
- package/dist/components/solution-deploy-dialog/customElement.d.ts +3 -1
- package/dist/components/solution-deploy-dialog/customElement.js +5 -4
- package/dist/components/solution-deploy-dialog/index.js +1 -1
- package/dist/components/solution-deployed-card/customElement.js +4 -2
- package/dist/components/solution-deployed-card-panel/customElement.d.ts +6 -0
- package/dist/components/solution-deployed-card-panel/customElement.js +110 -51
- package/dist/components/solution-deployed-card-panel/index.js +0 -1
- package/dist/components/solution-deploying-dialog/customElement.js +8 -8
- package/dist/components/solution-details-card/customElement.d.ts +4 -0
- package/dist/components/solution-details-card/customElement.js +39 -27
- package/dist/components/solution-details-card/index.js +1 -0
- package/dist/components/solution-details-panel/customElement.d.ts +8 -0
- package/dist/components/solution-details-panel/customElement.js +150 -128
- package/dist/components/solution-details-panel/index.js +2 -0
- package/dist/components/solution-item-accordion/customElement.d.ts +17 -4
- package/dist/components/solution-item-accordion/customElement.js +69 -36
- package/dist/components/solution-item-accordion/index.js +1 -0
- package/dist/components/solution-item-diagram/customElement.js +173 -169
- package/dist/components/solution-item-icon/customElement.d.ts +6 -0
- package/dist/components/solution-item-icon/customElement.js +13 -12
- package/dist/components/solution-resource-card/customElement.js +8 -7
- package/dist/components/solution-snapshot-gallery/customElement.js +10 -9
- package/dist/components/solution-social-share/customElement.js +15 -14
- package/dist/components/solution-user-avatar/customElement.js +1 -1
- package/dist/components/solutions-all-panel/customElement.d.ts +2 -0
- package/dist/components/solutions-all-panel/customElement.js +57 -40
- package/dist/components/solutions-all-shell/customElement.d.ts +2 -0
- package/dist/components/solutions-all-shell/customElement.js +94 -40
- package/dist/components/solutions-deploy-app/customElement.d.ts +9 -0
- package/dist/components/solutions-deploy-app/customElement.js +639 -52
- package/dist/components/solutions-deploy-app/index.js +5 -0
- package/dist/components/solutions-deploy-app-nav/customElement.d.ts +6 -0
- package/dist/components/solutions-deploy-app-nav/customElement.js +2 -2
- package/dist/components/solutions-deployed-list/customElement.d.ts +43 -0
- package/dist/components/solutions-deployed-list/customElement.js +63 -0
- package/dist/components/solutions-deployed-list/index.d.ts +1 -0
- package/dist/components/solutions-deployed-list/index.js +3 -0
- package/dist/components/solutions-deployed-panel/customElement.js +43 -32
- package/dist/components/solutions-deployed-panel/index.js +0 -1
- package/dist/components/solutions-deployed-shell/customElement.js +22 -18
- package/dist/components/solutions-deployed-shell/index.js +0 -1
- package/dist/components/solutions-filter-panel/customElement.d.ts +6 -7
- package/dist/components/solutions-filter-panel/customElement.js +51 -63
- package/dist/components/solutions-filter-panel/index.js +0 -3
- package/dist/components/solutions-resources-section/customElement.js +10 -9
- package/dist/components/solutions-resources-shell/customElement.d.ts +6 -0
- package/dist/components/solutions-resources-shell/customElement.js +44 -44
- package/dist/components/solutions-searchsort-toolbar/customElement.d.ts +2 -2
- package/dist/components/solutions-searchsort-toolbar/customElement.js +12 -11
- 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 +14 -6
- package/dist/index.js +25 -24
- package/dist/loader.js +25 -23
- package/dist/solutions-components_commit.txt +8 -5
- package/dist/types/lumina.d.ts +44 -21
- package/dist/types/preact.d.ts +46 -21
- package/dist/types/react.d.ts +48 -21
- package/dist/types/stencil.d.ts +44 -21
- package/dist/utils/Auth.d.ts +10 -3
- package/dist/utils/getRelatedInfos.d.ts +4 -0
- package/dist/utils/interfaces.d.ts +187 -36
- package/package.json +27 -25
- package/dist/cdn/2CFQ6EQE.js +0 -2
- package/dist/cdn/2H3VIDNQ.js +0 -2
- package/dist/cdn/2RBKFT3Q.js +0 -2
- package/dist/cdn/2W6HTIBW.js +0 -2
- package/dist/cdn/32EJUXLB.js +0 -2
- package/dist/cdn/3JF5JLS4.js +0 -2
- package/dist/cdn/3P3PF3BO.js +0 -2
- package/dist/cdn/3PT5ULE3.js +0 -2
- package/dist/cdn/42736UND.js +0 -2
- package/dist/cdn/45ZS4SG7.js +0 -2
- package/dist/cdn/4HGP3Y4K.js +0 -2
- package/dist/cdn/4VFE4GPI.js +0 -174
- package/dist/cdn/5326HZ74.js +0 -2
- package/dist/cdn/57JYZYF5.js +0 -2
- package/dist/cdn/5QCBD6ZZ.js +0 -2
- package/dist/cdn/5S3WZLB5.js +0 -2
- package/dist/cdn/67NTSS6S.js +0 -2
- package/dist/cdn/73AX72WY.js +0 -2
- package/dist/cdn/743J5TBS.js +0 -2
- package/dist/cdn/7SIPKCWY.js +0 -2
- package/dist/cdn/7YIQXDUF.js +0 -2
- package/dist/cdn/ABTC2V7J.js +0 -2
- package/dist/cdn/AKDP6MCB.js +0 -2
- package/dist/cdn/AVNCYWKK.js +0 -2
- package/dist/cdn/B44OQSYO.js +0 -50
- package/dist/cdn/BEGKM3ZM.js +0 -2
- package/dist/cdn/BFXJESYN.js +0 -2
- package/dist/cdn/BJ6JU4AF.js +0 -2
- package/dist/cdn/BJMKDP4O.js +0 -2
- package/dist/cdn/BMJN3MIR.js +0 -2
- package/dist/cdn/CEKMYC3I.js +0 -2
- package/dist/cdn/CF35YGUK.js +0 -2
- package/dist/cdn/CI7CDZL3.js +0 -2
- package/dist/cdn/CPMMNWOL.js +0 -3
- package/dist/cdn/DIKAKOU5.js +0 -2
- package/dist/cdn/DQ4POWIJ.js +0 -2
- package/dist/cdn/E7HQ4JJ2.js +0 -2
- package/dist/cdn/EWCIPKTH.js +0 -21
- package/dist/cdn/F346YHSU.js +0 -2
- package/dist/cdn/F372CSCW.js +0 -2
- package/dist/cdn/FGS4PYIE.js +0 -2
- package/dist/cdn/GTDHYS64.js +0 -4
- package/dist/cdn/HBJZGW4L.js +0 -2
- package/dist/cdn/HBPD3T7H.js +0 -2
- package/dist/cdn/HBQN25RR.js +0 -4
- package/dist/cdn/HMB3LHBC.js +0 -2
- package/dist/cdn/HPQPI754.js +0 -2
- package/dist/cdn/HZ6P3WVH.js +0 -2
- package/dist/cdn/I4PUORX4.js +0 -2
- package/dist/cdn/ITRKZRX7.js +0 -2
- package/dist/cdn/J33ST6ZG.js +0 -2
- package/dist/cdn/J5VTBFGR.js +0 -2
- package/dist/cdn/JE4LGN6P.js +0 -2
- package/dist/cdn/JGU6J5IA.js +0 -2
- package/dist/cdn/JK75TUSP.js +0 -2
- package/dist/cdn/JUXXPW6I.js +0 -2
- package/dist/cdn/JYLXH6OM.js +0 -2
- package/dist/cdn/K344PR7N.js +0 -2
- package/dist/cdn/KD46EE7M.js +0 -2
- package/dist/cdn/KPBEUIQV.js +0 -2
- package/dist/cdn/KSXW3QKP.js +0 -2
- package/dist/cdn/KWCJDOZU.js +0 -2
- package/dist/cdn/LI4CAGAZ.js +0 -2
- package/dist/cdn/LPNQJBCN.js +0 -2
- package/dist/cdn/LR6VDEBR.js +0 -2
- package/dist/cdn/LWUSGNUB.js +0 -2
- package/dist/cdn/M7YK4K5M.js +0 -2
- package/dist/cdn/MQ7BT7PK.js +0 -2
- package/dist/cdn/MZ3QZD4K.js +0 -2
- package/dist/cdn/MZLEP53S.js +0 -2
- package/dist/cdn/N7HJKCUK.js +0 -2
- package/dist/cdn/N7OY2PSZ.js +0 -2
- package/dist/cdn/NIUMAAOQ.js +0 -2
- package/dist/cdn/NL67WU77.js +0 -2
- package/dist/cdn/NSITJP7B.js +0 -2
- package/dist/cdn/OQFRVQQZ.js +0 -2
- package/dist/cdn/OVKFYACI.js +0 -2
- package/dist/cdn/OYQYXNHJ.js +0 -2
- package/dist/cdn/P4KZ6OZF.js +0 -4
- package/dist/cdn/P6IYN2TS.js +0 -2
- package/dist/cdn/PFKPNZ5Q.js +0 -2
- package/dist/cdn/PJH3H7LZ.js +0 -2
- package/dist/cdn/PZOAAAVI.js +0 -2
- package/dist/cdn/Q7AXKKIB.js +0 -2
- package/dist/cdn/QHG54NVK.js +0 -2
- package/dist/cdn/QI5LXFA7.js +0 -2
- package/dist/cdn/QWRM254M.js +0 -2
- package/dist/cdn/R3TKXDOE.js +0 -6
- package/dist/cdn/RDXJFHLV.js +0 -2
- package/dist/cdn/REOO5ZGK.js +0 -2
- package/dist/cdn/RKMY6VWP.js +0 -2
- package/dist/cdn/RTPXDRZ7.js +0 -2
- package/dist/cdn/SOIGVOGA.js +0 -2
- package/dist/cdn/SSO3AN4U.js +0 -2
- package/dist/cdn/SZRONHSX.js +0 -2
- package/dist/cdn/T2WSMUVL.js +0 -2
- package/dist/cdn/TAYHORLE.js +0 -2
- package/dist/cdn/TBQQ6OPX.js +0 -2
- package/dist/cdn/TH52564W.js +0 -2
- package/dist/cdn/THKPPH7G.js +0 -2
- package/dist/cdn/TU5GZK4M.js +0 -2
- package/dist/cdn/TZ73WV5T.js +0 -2
- package/dist/cdn/TZHUM4R4.js +0 -2
- package/dist/cdn/U6NFJYPT.js +0 -2
- package/dist/cdn/UAQ3H67J.js +0 -2
- package/dist/cdn/UFJWRZWQ.js +0 -2
- package/dist/cdn/ULCILXSA.js +0 -2
- package/dist/cdn/ULU7JTHR.js +0 -2
- package/dist/cdn/UM2FREW7.js +0 -2
- package/dist/cdn/VCGFT6NM.js +0 -2
- package/dist/cdn/VDEFBT2N.js +0 -2
- package/dist/cdn/VJEG4LOG.js +0 -2
- package/dist/cdn/VPTZV5YV.js +0 -2
- package/dist/cdn/WCPWYPN2.js +0 -2
- package/dist/cdn/WHXMHZL4.js +0 -2
- package/dist/cdn/WIC2XPT4.js +0 -2
- package/dist/cdn/XAFSYKI2.js +0 -2
- package/dist/cdn/XBR2PGVO.js +0 -7
- package/dist/cdn/XGFCUKM7.js +0 -2
- package/dist/cdn/XK6Q5TUT.js +0 -2
- package/dist/cdn/XNH7HCKE.js +0 -2
- package/dist/cdn/XTEP3QJL.js +0 -2
- package/dist/cdn/XYFIAJPT.js +0 -2
- package/dist/cdn/YG7D2NB5.js +0 -2
- package/dist/cdn/YJMAWMEK.js +0 -2
- package/dist/cdn/YRRONGG3.js +0 -2
- package/dist/cdn/YTK4IGLJ.js +0 -2
- package/dist/cdn/ZC3SWVD4.js +0 -2
- package/dist/cdn/ZMNHA5KF.js +0 -2
- package/dist/cdn/ZSHMK5VX.js +0 -2
- /package/dist/cdn/{YVNP437O.js → WV7QX3ED.js} +0 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{c as Ls,d as lo,e as jm,f as fw,g as Rm}from"./54AE7WD2.js";import{a as Pm}from"./WPGT2HLS.js";import c from"./VEZDLO5O.js";import b from"./BMF7MU4P.js";import a from"./AVRGQSFV.js";import{b as cw,c as uw}from"./2B4SGB3I.js";import{b as Nm}from"./E3C3HXK2.js";import"./A4RZESK7.js";import{a as Us,c as Er,d as pw,e as hw,k as mw}from"./IRRMUFW7.js";import{a as ow}from"./FV3ILJ4J.js";import"./ANJGKFNJ.js";import"./S3TMLXGP.js";import"./TEHBW75B.js";import"./YFXSWGXE.js";import"./ZCU2WWVN.js";import"./WGO4EVOV.js";import"./YKB6256M.js";import"./JBNWEBAG.js";import"./5HZMUGQD.js";import"./5VDDAINK.js";import"./Z4F2NZOT.js";import"./KOIDWEP3.js";import"./3KXMYZCU.js";import"./N2KSPEVT.js";import"./GF4QELNV.js";import"./XQQ52NKX.js";import"./JUUVYK2H.js";import"./DKD2EGQP.js";import"./5O53T3SW.js";import"./AJZDBHB6.js";import"./FES7B3SJ.js";import{b as aw}from"./4F57JHMM.js";import{E as rw,F as iw,G as sw,K as Cm,h as X0,i as qi,k as Y0,l as Em,q as Q0,v as ew,w as tw,x as nw}from"./3ITZDI72.js";import{c as G0}from"./QPIMTXPL.js";export default $arcgis.t(([vw,B$,lh,,,,X4,{p:lw},,{o:dw}])=>{var po=class extends nw{constructor(t){if(super(t),this.it=Em,t.type!==ew.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===Em||t==null)return this._t=void 0,this.it=t;if(t===Y0)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};po.directiveName="unsafeHTML",po.resultType=1;var gw=tw(po);var Mm={};G0(Mm,{JsonPatchError:()=>nt,_areEquals:()=>fo,applyOperation:()=>Ji,applyPatch:()=>Ds,applyReducer:()=>Z4,deepClone:()=>D4,getValueByPointer:()=>Hu,validate:()=>_w,validator:()=>Vu});var L4=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),z4=Object.prototype.hasOwnProperty;function Bu(e,t){return z4.call(e,t)}function qu(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)Bu(e,i)&&r.push(i);return r}function St(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Ju(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function or(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function ho(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Zu(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(Zu(e[t]))return!0}else if(typeof e=="object"){for(var r=qu(e),i=r.length,s=0;s<i;s++)if(Zu(e[r[s]]))return!0}}return!1}function yw(e,t){var n=[e];for(var r in t){var i=typeof t[r]=="object"?JSON.stringify(t[r],null,2):t[r];typeof i<"u"&&n.push(r+": "+i)}return n.join(`
|
|
3
|
+
`)}var mo=(function(e){L4(t,e);function t(n,r,i,s,a){var o=this.constructor,c=e.call(this,yw(n,{name:r,index:i,operation:s,tree:a}))||this;return c.name=r,c.index=i,c.operation=s,c.tree=a,Object.setPrototypeOf(c,o.prototype),c.message=yw(n,{name:r,index:i,operation:s,tree:a}),c}return t})(Error);var nt=mo,D4=St,zs={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=Hu(n,this.path);r&&(r=St(r));var i=Ji(n,{op:"remove",path:this.from}).removed;return Ji(n,{op:"add",path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=Hu(n,this.from);return Ji(n,{op:"add",path:this.path,value:St(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:fo(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},F4={add:function(e,t,n){return Ju(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){var r=e.splice(t,1);return{newDocument:n,removed:r[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:zs.move,copy:zs.copy,test:zs.test,_get:zs._get};function Hu(e,t){if(t=="")return e;var n={op:"_get",path:t};return Ji(e,n),n.value}function Ji(e,t,n,r,i,s){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),s===void 0&&(s=0),n&&(typeof n=="function"?n(t,0,e,t.path):Vu(t,0)),t.path===""){var 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=Hu(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=fo(e,t.value),a.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",s,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(n)throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,t,e);return a}}else{r||(e=St(e));var o=t.path||"",c=o.split("/"),u=e,l=1,d=c.length,p=void 0,h=void 0,m=void 0;for(typeof n=="function"?m=n:m=Vu;;){if(h=c[l],h&&h.indexOf("~")!=-1&&(h=ho(h)),i&&(h=="__proto__"||h=="prototype"&&l>0&&c[l-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(n&&p===void 0&&(u[h]===void 0?p=c.slice(0,l).join("/"):l==d-1&&(p=t.path),p!==void 0&&m(t,0,e,p)),l++,Array.isArray(u)){if(h==="-")h=u.length;else{if(n&&!Ju(h))throw new nt("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",s,t,e);Ju(h)&&(h=~~h)}if(l>=d){if(n&&t.op==="add"&&h>u.length)throw new nt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,t,e);var a=F4[t.op].call(t,u,h,e);if(a.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return a}}else if(l>=d){var a=zs[t.op].call(t,u,h,e);if(a.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return a}if(u=u[h],n&&l<d&&(!u||typeof u!="object"))throw new nt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,t,e)}}}function Ds(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(e=St(e));for(var s=new Array(t.length),a=0,o=t.length;a<o;a++)s[a]=Ji(e,t[a],n,!0,i,a),e=s[a].newDocument;return s.newDocument=e,s}function Z4(e,t,n){var r=Ji(e,t);if(r.test===!1)throw new nt("Test operation failed","TEST_OPERATION_FAILED",n,t,e);return r.newDocument}function Vu(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))throw new nt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,n);if(zs[e.op]){if(typeof e.path!="string")throw new nt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,n);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new nt('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new nt("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Zu(e.value))throw new nt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var i=e.path.split("/").length,s=r.split("/").length;if(i!==s+1&&i!==s)throw new nt("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==r)throw new nt("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var a={op:"_get",path:e.from,value:void 0},o=_w([a],n);if(o&&o.name==="OPERATION_PATH_UNRESOLVABLE")throw new nt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new nt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function _w(e,t,n){try{if(!Array.isArray(e))throw new nt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Ds(St(t),St(e),n||!0);else{n=n||Vu;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(i){if(i instanceof nt)return i;throw i}}function fo(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=Array.isArray(e),r=Array.isArray(t),i,s,a;if(n&&r){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!fo(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var o=Object.keys(e);if(s=o.length,s!==Object.keys(t).length)return!1;for(i=s;i--!==0;)if(!t.hasOwnProperty(o[i]))return!1;for(i=s;i--!==0;)if(a=o[i],!fo(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}var Dm={};G0(Dm,{compare:()=>G4,generate:()=>Um,observe:()=>W4,unobserve:()=>K4});var Lm=new WeakMap,B4=(function(){function e(t){this.observers=new Map,this.obj=t}return e})(),q4=(function(){function e(t,n){this.callback=t,this.observer=n}return e})();function J4(e){return Lm.get(e)}function H4(e,t){return e.observers.get(t)}function V4(e,t){e.observers.delete(t.callback)}function K4(e,t){t.unobserve()}function W4(e,t){var n=[],r,i=J4(e);if(!i)i=new B4(e),Lm.set(e,i);else{var s=H4(i,t);r=s&&s.observer}if(r)return r;if(r={},i.value=St(e),t){r.callback=t,r.next=null;var a=function(){Um(r)},o=function(){clearTimeout(r.next),r.next=setTimeout(a)};typeof window<"u"&&(window.addEventListener("mouseup",o),window.addEventListener("keyup",o),window.addEventListener("mousedown",o),window.addEventListener("keydown",o),window.addEventListener("change",o))}return r.patches=n,r.object=e,r.unobserve=function(){Um(r),clearTimeout(r.next),V4(i,r),typeof window<"u"&&(window.removeEventListener("mouseup",o),window.removeEventListener("keyup",o),window.removeEventListener("mousedown",o),window.removeEventListener("keydown",o),window.removeEventListener("change",o))},i.observers.set(t,new q4(t,r)),r}function Um(e,t){t===void 0&&(t=!1);var n=Lm.get(e.object);zm(n.value,e.object,e.patches,"",t),e.patches.length&&Ds(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function zm(e,t,n,r,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var s=qu(t),a=qu(e),o=!1,c=!1,u=a.length-1;u>=0;u--){var l=a[u],d=e[l];if(Bu(t,l)&&!(t[l]===void 0&&d!==void 0&&Array.isArray(t)===!1)){var p=t[l];typeof d=="object"&&d!=null&&typeof p=="object"&&p!=null&&Array.isArray(d)===Array.isArray(p)?zm(d,p,n,r+"/"+or(l),i):d!==p&&(o=!0,i&&n.push({op:"test",path:r+"/"+or(l),value:St(d)}),n.push({op:"replace",path:r+"/"+or(l),value:St(p)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:"test",path:r+"/"+or(l),value:St(d)}),n.push({op:"remove",path:r+"/"+or(l)}),c=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:t}),o=!0)}if(!(!c&&s.length==a.length))for(var u=0;u<s.length;u++){var l=s[u];!Bu(e,l)&&t[l]!==void 0&&n.push({op:"add",path:r+"/"+or(l),value:St(t[l])})}}}function G4(e,t,n){n===void 0&&(n=!1);var r=[];return zm(e,t,r,"",n),r}var pG=Object.assign({},Mm,Dm,{JsonPatchError:mo,deepClone:St,escapePathComponent:or,unescapePathComponent:ho});var Y4=X0`:host{display:block;height:100%}.margin-lg{margin:var(--calcite-spacing-lg)}.display-flex-row{display:flex;flex-direction:row}.assistant-split-container{display:flex;width:100%;height:calc(100vh - 78px);overflow:hidden;border-radius:10px}.assistant-panel{display:flex;flex-direction:column;height:100%;border:1px solid var(--calcite-color-surface-3);background-color:var(--calcite-color-surface-2);overflow:hidden}.chat-panel{min-width:320px}.builder-panel{min-width:320px;max-width:100%;border-left:1px solid var(--calcite-color-surface-3)}.panel-actions{display:flex;gap:8px;padding:6px;align-items:center}.builder-header,.builder-footer{padding:10px;background:var(--calcite-color-surface-1);border-bottom:1px solid var(--calcite-color-surface-3)}.builder-content{flex:1;overflow:auto;padding:12px}.builder-content pre{white-space:pre-wrap;word-wrap:break-word;max-height:100%;overflow:auto}.builder-actions{display:flex;gap:6px;align-items:center}.padding-left-10{padding-left:10px}.chat-container{display:flex;flex-direction:column;gap:0px;max-width:600px;height:75%;background-color:var(--calcite-color-surface-4);padding:1px}.chat-container_expanded{display:flex;flex-direction:column;gap:0px;max-width:100%;height:95%;background-color:var(--calcite-color-surface-1);border-radius:10px;padding:10px}.chat-panel{--calcite-color-focus: var(--calcite-color-brand);--calcite-panel-border-color: var(--calcite-color-border-2);--calcite-internal-panel-header-vertical-padding: 0px;--calcite-panel-header-content-space: 0px;border:var(--calcite-border-width-sm) solid var(--calcite-color-border-2);height:100%}.header-content{display:flex;align-items:center;gap:var(--calcite-spacing-sm);height:65px;box-sizing:border-box;padding-inline-start:var(--calcite-space-2xl)}.header-title{font-size:var(--calcite-font-size-md);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1)}.beta-chip{--calcite-chip-corner-radius: var(--calcite-corner-radius-half)}.chat-panel calcite-card,.chat-panel calcite-text-area,.chat-panel calcite-button,.chat-panel .chat-messages,.chat-panel .chat-input{--calcite-color-focus: var(--calcite-color-brand)}.assistant-followup-chip:focus{outline:2px solid var(--calcite-color-brand)}.chat-panel-heading{font-size:var(--calcite-font-size-0);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-surface-1, var(--calcite-color-text-1))}.chat-messages{display:flex;flex-direction:column;gap:20px;padding:4px;height:100%;overflow-y:auto}.user-message{align-self:flex-end;background:var(--calcite-color-brand);border-radius:8px;max-width:90%;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-brand);--calcite-card-border-color: var(--calcite-color-brand);color:var(--calcite-color-text-inverse);text-align:left}.system-message{align-self:flex-start;background:var(--calcite-color-surface-3);border-radius:8px;max-width:90%;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-surface-4);--calcite-card-border-color: var(--calcite-color-surface-4);color:var(--calcite-color-inverse);text-align:left}.loader-message{align-self:flex-start;background:var(--calcite-color-surface-4);border-radius:8px;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-surface-4);--calcite-card-border-color: var(--calcite-color-surface-4)}.message-content{padding:0;font-size:14px}.response-message.message-content>p:first-of-type{margin-top:0}.message-content img{max-width:100%;height:auto;display:block;object-fit:contain}.message-content-pad{padding-bottom:10px;font-size:14px}.message-content-summary{padding-bottom:14px}.message-content-alignment{display:flex;align-items:center;gap:var(--calcite-spacing-md);font-size:var(--calcite-font-size--1);color:var(--calcite-color-text-1)}.padding-top-10{padding-top:10px}.padding-right-8{padding-right:8px}.padding-left-right-5{padding-right:5px;padding-left:5px}.chip-content{padding:5px 5px 5px 0}.chat-input{display:flex;flex-direction:row;flex-grow:1}.table-cell{--calcite-table-cell-background: var(--calcite-color-surface-4)}.cursor-pointer{cursor:pointer}.notice-border-color{--temp-initial-brand: var(--calcite-color-brand)}.notice-border-color calcite-notice{--calcite-color-brand: #ddd;--calcite-icon-color: var(--temp-initial-brand)}.notice-border-color calcite-notice *{--calcite-color-brand: var(--temp-initial-brand)}.solution-card{padding:5px 0;text-decoration:none;display:block;width:100%;cursor:pointer}.solution-card calcite-card{display:flex;flex-direction:column;max-width:520px;overflow:hidden;--calcite-card-corner-radius: var(--calcite-corner-radius-round) !important;--calcite-card-shadow: var(--calcite-shadow-sm);--calcite-card-background-color: var(--calcite-card-background-color) }.solution-card div[slot=thumbnail]{max-height:100%;width:100%;position:relative;&:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;transition:all .15s ease-in-out}}.solution-card div[slot=thumbnail] img{max-height:100%;width:100%;object-fit:cover}.solution-card span[slot=description]{padding-top:10px}.solution-card calcite-chip{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);visibility:hidden;pointer-events:none;opacity:0;transition:all .15s ease-in-out;z-index:9999}.solution-card:hover calcite-chip{visibility:visible;opacity:1}.solution-card:hover div[slot=thumbnail]:after{background-color:#00000080}.solution-card:hover h3{text-decoration:underline}.solution-card:focus{outline:2px solid var(--calcite-color-brand)}.references-container{padding-top:10px;display:block}.references-container.collapsed{display:none}.width-100{width:100%}.disclaimer-div{display:flex;align-items:center;gap:var(--calcite-spacing-sm);font-size:var(--calcite-font-size--0);color:var(--calcite-color-text-1)}.display-none{display:none}.chat-messages calcite-fab{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:999}.icon-color-background{--calcite-button-icon-color: var(--calcite-color-surface-1)}#closeAssistantButton{--calcite-action-text-color: var(--calcite-color-text-1)}.icon-color-background:focus{--calcite-color-focus: var(--calcite-color-surface-1)}@media(max-width:430px){.solution-card .solution-snippet{display:none}}.height-32-flex-auto{height:32px;flex:0 0 auto}.margin-top-0.message-content>p:first-of-type{margin-top:0}a:not(.solution-card){color:var(--calcite-link-text-color, var(--calcite-color-text-link));cursor:pointer;text-decoration:none;line-height:inherit;background-image:linear-gradient(currentColor,currentColor),linear-gradient(var(--calcite-color-brand-underline),var(--calcite-color-brand-underline));background-position-x:0%,100%;background-position-y:min(1.5em,100%);background-repeat:no-repeat,no-repeat;background-size:0% 1px,100% 1px;transition-property:background-size,color;transition-duration:var(--calcite-animation-timing, .15s);transition-timing-function:ease-in-out;outline-color:transparent;position:relative}a:not(.solution-card):hover{background-size:100% 1px,100% 1px}a:not(.solution-card):focus{outline:2px solid var(--calcite-color-brand);outline-offset:2px;outline-color:var(--calcite-color-brand)}a:not(.solution-card):active{color:var(--calcite-color-brand-press)}`,_t="__start__",dt="__end__",ci="__input__",dh="__error__",Fm="__pregel_ns_writes",hi="__pregel_send",h_="__pregel_call",as="__pregel_read",Fr="__pregel_checkpointer",ld="__pregel_resuming",jl="__pregel_task_id",m_="__pregel_stream",Q4="__pregel_resume_value",Rl="__pregel_resume_map",mi="__pregel_scratchpad",Ml="__pregel_previous",e2="__pregel_durability",Wf="checkpoint_id",Zr="checkpoint_ns",t2="__pregel_node_finished",Mr="checkpoint_map",n2="__pregel_abort_signals",yt="__interrupt__",ki="__resume__",f_="__no_writes__",ph="__return__",Zm="__previous__",rn="langsmith:hidden",bw="__self__",_a="__pregel_tasks",Br="__pregel_push",Gf="__pregel_pull",mr="00000000-0000-0000-0000-000000000000",r2=[rn,ci,yt,ki,dh,f_,hi,as,Fr,e2,m_,ld,jl,h_,Q4,mi,Ml,Mr,Zr,Wf],ww=Symbol.for("langgraph.command"),i2=class{[ww];constructor(e){this[ww]=e}};function Xf(e){let t=e;return t!=null&&typeof t.node=="string"&&t.args!==void 0}var Xo=class{lg_name="Send";node;args;constructor(e,t){this.node=e,this.args=Yo(t)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function cn(e){return e instanceof Xo}var s2="__overwrite__";function Yf(e){return typeof e=="object"&&e!==null&&"__overwrite__"in e?[!0,e[s2]]:[!1,void 0]}function a2(e){return Yf(e)[0]}function g_(e){return!e||typeof e!="object"||!("__interrupt__"in e)?!1:Array.isArray(e[yt])}var fr=class extends i2{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)?Yo(e.goto):[Yo(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:cn(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 Dt(e){return typeof e!="object"||e==null?!1:"lg_name"in e&&e.lg_name==="Command"}function Yo(e,t=new Map){if(e!=null&&typeof e=="object"){if(t.has(e))return t.get(e);let n;if(Array.isArray(e))n=[],t.set(e,n),e.forEach((r,i)=>{n[i]=Yo(r,t)});else if(Dt(e)&&!(e instanceof fr))n=new fr(e),t.set(e,n);else if(Xf(e)&&!(e instanceof Xo))n=new Xo(e.node,e.args),t.set(e,n);else if(Dt(e)||cn(e))n=e,t.set(e,n);else if("lc_serializable"in e&&e.lc_serializable)n=e,t.set(e,n);else{n={},t.set(e,n);for(let[r,i]of Object.entries(e))n[r]=Yo(i,t)}return n}return e}var Mi=class extends Error{lc_error_code;constructor(e,t){let n=e??"";t?.lc_error_code&&(n=`${n}
|
|
4
|
+
|
|
5
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${t.lc_error_code}/
|
|
6
|
+
`),super(n),this.lc_error_code=t?.lc_error_code}},q$=class extends Mi{get is_bubble_up(){return!0}},o2=class extends Mi{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},Ul=class extends Mi{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},pa=class extends q${interrupts;constructor(e,t){super(JSON.stringify(e,null,2),t),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}},hh=class extends pa{constructor(e,t){super([{value:e}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},J$=class extends q${command;constructor(e){super(),this.name="ParentCommand",this.command=e}static get unminifiable_name(){return"ParentCommand"}};function c2(e){return e!==void 0&&e.name===J$.unminifiable_name}function Ll(e){return e!==void 0&&e.is_bubble_up===!0}function na(e){return e!==void 0&&[pa.unminifiable_name,hh.unminifiable_name].includes(e.name)}var kw=class extends Mi{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},$t=class extends Mi{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},qe=class extends Mi{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}},u2=class extends Mi{constructor(e,t){super(e,t),this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}},Bm=class extends Mi{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"}},l2=/^(?:[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 Qf(e){return typeof e=="string"&&l2.test(e)}function H$(e){if(!Qf(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var Ot=[];for(Ku=0;Ku<256;++Ku)Ot.push((Ku+256).toString(16).slice(1));var Ku;function Hc(e,t=0){return(Ot[e[t+0]]+Ot[e[t+1]]+Ot[e[t+2]]+Ot[e[t+3]]+"-"+Ot[e[t+4]]+Ot[e[t+5]]+"-"+Ot[e[t+6]]+Ot[e[t+7]]+"-"+Ot[e[t+8]]+Ot[e[t+9]]+"-"+Ot[e[t+10]]+Ot[e[t+11]]+Ot[e[t+12]]+Ot[e[t+13]]+Ot[e[t+14]]+Ot[e[t+15]]).toLowerCase()}var Wu,d2=new Uint8Array(16);function V$(){if(!Wu&&(Wu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Wu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Wu(d2)}var qm,Gu,Jm=0,Hm=0;function p2(e,t,n){var r=0,i=t||new Array(16);e=e||{};var s=e.node,a=e.clockseq;if(e._v6||(s||(s=qm),a==null&&(a=Gu)),s==null||a==null){var o=e.random||(e.rng||V$)();s==null&&(s=[o[0],o[1],o[2],o[3],o[4],o[5]],!qm&&!e._v6&&(s[0]|=1,qm=s)),a==null&&(a=(o[6]<<8|o[7])&16383,Gu===void 0&&!e._v6&&(Gu=a))}var c=e.msecs!==void 0?e.msecs:Date.now(),u=e.nsecs!==void 0?e.nsecs:Hm+1,l=c-Jm+(u-Hm)/1e4;if(l<0&&e.clockseq===void 0&&(a=a+1&16383),(l<0||c>Jm)&&e.nsecs===void 0&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Jm=c,Hm=u,Gu=a,c+=122192928e5;var d=((c&268435455)*1e4+u)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var p=c/4294967296*1e4&268435455;i[r++]=p>>>8&255,i[r++]=p&255,i[r++]=p>>>24&15|16,i[r++]=p>>>16&255,i[r++]=a>>>8|128,i[r++]=a&255;for(var h=0;h<6;++h)i[r+h]=s[h];return t||Hc(i)}function h2(e){var t=typeof e=="string"?H$(e):e,n=m2(t);return typeof e=="string"?Hc(n):n}function m2(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 f2(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}var g2="6ba7b810-9dad-11d1-80b4-00c04fd430c8",y2="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _2(e,t,n){function r(i,s,a,o){var c;if(typeof i=="string"&&(i=f2(i)),typeof s=="string"&&(s=H$(s)),((c=s)===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(s),u.set(i,s.length),u=n(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,a){o=o||0;for(var l=0;l<16;++l)a[o+l]=u[l];return a}return Hc(u)}try{r.name=e}catch{}return r.DNS=g2,r.URL=y2,r}var v2=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xw={randomUUID:v2};function $w(e,t,n){if(xw.randomUUID&&!e)return xw.randomUUID();e=e||{};var r=e.random||(e.rng||V$)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Hc(r)}function b2(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function Vm(e,t){return e<<t|e>>>32-t}function w2(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var s=e.length/4+2,a=Math.ceil(s/16),o=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];o[c]=u}o[a-1][14]=(e.length-1)*8/Math.pow(2,32),o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<a;++d){for(var p=new Uint32Array(80),h=0;h<16;++h)p[h]=o[d][h];for(var m=16;m<80;++m)p[m]=Vm(p[m-3]^p[m-8]^p[m-14]^p[m-16],1);for(var f=n[0],v=n[1],g=n[2],y=n[3],w=n[4],x=0;x<80;++x){var O=Math.floor(x/20),z=Vm(f,5)+b2(O,v,g,y)+w+t[O]+p[x]>>>0;w=y,y=g,g=Vm(v,30)>>>0,v=f,f=z}n[0]=n[0]+f>>>0,n[1]=n[1]+v>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var k2=_2("v5",80,w2);function Iw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Sw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Iw(Object(n),!0).forEach(function(r){x2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Iw(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function x2(e,t,n){return(t=$2(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $2(e){var t=I2(e,"string");return typeof t=="symbol"?t:t+""}function I2(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function S2(e={},t,n=0){var r=p2(Sw(Sw({},e),{},{_v6:!0}),new Uint8Array(16));return r=h2(r),Hc(r)}function K$(e){return S2({clockseq:e})}function ra(e,t){let n=t.replace(/-/g,"").match(/.{2}/g).map(r=>parseInt(r,16));return k2(e,new Uint8Array(n))}var O2="__error__",zl="__scheduled__",A2="__interrupt__",T2="__resume__",Ow="[...]",E2="[Circular]",dd=[],ia=[];function C2(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function N2(e,t,n,r){typeof r>"u"&&(r=C2()),eg(e,"",0,[],void 0,0,r);var i;try{ia.length===0?i=JSON.stringify(e,t,n):i=JSON.stringify(e,P2(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;dd.length!==0;){var s=dd.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Km(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:e}),dd.push([r,n,t,i])):ia.push([t,n,e]):(r[n]=e,dd.push([r,n,t]))}function eg(e,t,n,r,i,s,a){s+=1;var o;if(typeof e=="object"&&e!==null){for(o=0;o<r.length;o++)if(r[o]===e){Km(E2,e,t,i);return}if(typeof a.depthLimit<"u"&&s>a.depthLimit){Km(Ow,e,t,i);return}if(typeof a.edgesLimit<"u"&&n+1>a.edgesLimit){Km(Ow,e,t,i);return}if(r.push(e),Array.isArray(e))for(o=0;o<e.length;o++)eg(e[o],o,o,r,e,s,a);else{var c=Object.keys(e);for(o=0;o<c.length;o++){var u=c[o];eg(e[u],u,o,r,e,s,a)}}r.pop()}}function P2(e){return e=typeof e<"u"?e:function(t,n){return n},function(t,n){if(ia.length>0)for(var r=0;r<ia.length;r++){var i=ia[r];if(i[1]===t&&i[0]===n){n=i[2],ia.splice(r,1);break}}return e.call(this,t,n)}}var Aw,Tw;function j2(){return Tw||(Tw=1,Aw=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()}),Aw}var R2=j2(),M2=Us(R2),Xu={exports:{}},Ew;function U2(){if(Ew)return Xu.exports;Ew=1;let e=/[\p{Lu}]/u,t=/[\p{Ll}]/u,n=/^[\p{Lu}](?![\p{Lu}])/gu,r=/([\p{Alpha}\p{N}_]|$)/u,i=/[_.\- ]+/,s=new RegExp("^"+i.source),a=new RegExp(i.source+r.source,"gu"),o=new RegExp("\\d+"+r.source,"gu"),c=(p,h,m)=>{let f=!1,v=!1,g=!1;for(let y=0;y<p.length;y++){let w=p[y];f&&e.test(w)?(p=p.slice(0,y)+"-"+p.slice(y),f=!1,g=v,v=!0,y++):v&&g&&t.test(w)?(p=p.slice(0,y-1)+"-"+p.slice(y-1),g=v,v=!1,f=!0):(f=h(w)===w&&m(w)!==w,g=v,v=m(w)===w&&h(w)!==w)}return p},u=(p,h)=>(n.lastIndex=0,p.replace(n,m=>h(m))),l=(p,h)=>(a.lastIndex=0,o.lastIndex=0,p.replace(a,(m,f)=>h(f)).replace(o,m=>h(m))),d=(p,h)=>{if(!(typeof p=="string"||Array.isArray(p)))throw new TypeError("Expected the input to be `string | string[]`");if(h={pascalCase:!1,preserveConsecutiveUppercase:!1,...h},Array.isArray(p)?p=p.map(v=>v.trim()).filter(v=>v.length).join("-"):p=p.trim(),p.length===0)return"";let m=h.locale===!1?v=>v.toLowerCase():v=>v.toLocaleLowerCase(h.locale),f=h.locale===!1?v=>v.toUpperCase():v=>v.toLocaleUpperCase(h.locale);return p.length===1?h.pascalCase?f(p):m(p):(p!==m(p)&&(p=c(p,m,f)),p=p.replace(s,""),h.preserveConsecutiveUppercase?p=u(p,m):p=m(p),h.pascalCase&&(p=f(p.charAt(0))+p.slice(1)),l(p,f))};return Xu.exports=d,Xu.exports.default=d,Xu.exports}var L2=U2(),z2=Us(L2);function D2(e,t){return t?.[e]||M2(e)}function F2(e,t){return t?.[e]||z2(e)}function W$(e,t,n){let r={};for(let i in e)Object.hasOwn(e,i)&&(r[t(i,n)]=e[i]);return r}var G$="__lc_escaped__";function Z2(e){return"lc"in e||Object.keys(e).length===1&&"__lc_escaped__"in e}function B2(e){return{[G$]:e}}function X$(e){return Object.keys(e).length===1&&"__lc_escaped__"in e}function q2(e){return e!==null&&typeof e=="object"&&"lc_serializable"in e&&typeof e.toJSON=="function"}function J2(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 tg(e,t=new WeakSet){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){if(t.has(e))return J2(e);if(q2(e))return e;t.add(e);let n=e;if(Z2(n))return t.delete(e),B2(n);let r={};for(let[i,s]of Object.entries(n))r[i]=tg(s,t);return t.delete(e),r}return Array.isArray(e)?e.map(n=>tg(n,t)):e}function ng(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(X$(t))return t[G$];let n={};for(let[r,i]of Object.entries(t))n[r]=ng(i);return n}return Array.isArray(e)?e.map(t=>ng(t)):e}var Cw=Object.defineProperty,G=(e,t)=>{let n={};for(var r in e)Cw(n,r,{get:e[r],enumerable:!0});return Cw(n,Symbol.toStringTag,{value:"Module"}),n},H2=G({Serializable:()=>Rn,get_lc_unique_name:()=>mh});function Nw(e){return Array.isArray(e)?[...e]:{...e}}function V2(e,t){let n=Nw(e);for(let[r,i]of Object.entries(t)){let[s,...a]=r.split(".").reverse(),o=n;for(let c of a.reverse()){if(o[c]===void 0)break;o[c]=Nw(o[c]),o=o[c]}o[s]!==void 0&&(o[s]={lc:1,type:"secret",id:[i]})}return n}function mh(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 Rn=class Y${lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,mh(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(t,...n){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(t||{}).filter(([r])=>this.lc_serializable_keys?.includes(r))):this.lc_kwargs=t??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof Y$||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},n={},r=Object.keys(this.lc_kwargs).reduce((o,c)=>(o[c]=c in this?this[c]:this.lc_kwargs[c],o),{});for(let o=Object.getPrototypeOf(this);o;o=Object.getPrototypeOf(o))Object.assign(t,Reflect.get(o,"lc_aliases",this)),Object.assign(n,Reflect.get(o,"lc_secrets",this)),Object.assign(r,Reflect.get(o,"lc_attributes",this));Object.keys(n).forEach(o=>{let c=this,u=r,[l,...d]=o.split(".").reverse();for(let p of d.reverse()){if(!(p in c)||c[p]===void 0)return;(!(p in u)||u[p]===void 0)&&(typeof c[p]=="object"&&c[p]!=null?u[p]={}:Array.isArray(c[p])&&(u[p]=[])),c=c[p],u=u[p]}l in c&&c[l]!==void 0&&(u[l]=u[l]||c[l])});let i={},s=new WeakSet;s.add(this);for(let[o,c]of Object.entries(r))i[o]=tg(c,s);let a=W$(Object.keys(n).length?V2(i,n):i,D2,t);return{lc:1,type:"constructor",id:this.lc_id,kwargs:a}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}},K2=G({getEnv:()=>y_,getEnvironmentVariable:()=>bn,getRuntimeEnvironment:()=>r1,isBrowser:()=>Q$,isDeno:()=>fh,isJsDom:()=>t1,isNode:()=>n1,isWebWorker:()=>e1}),Q$=()=>typeof window<"u"&&typeof window.document<"u",e1=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",t1=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),fh=()=>typeof Deno<"u",n1=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!fh(),y_=()=>{let e;return Q$()?e="browser":n1()?e="node":e1()?e="webworker":t1()?e="jsdom":fh()?e="deno":e="other",e},Wm;function r1(){return Wm===void 0&&(Wm={library:"langchain-js",runtime:y_()}),Wm}function bn(e){try{return typeof process<"u"?process.env?.[e]:fh()?Deno?.env.get(e):void 0}catch{return}}var W2=[],G2=G({}),X2=G({}),ne="0123456789abcdef".split(""),Y2=[-2147483648,8388608,32768,128],Dn=[24,16,8,0],Yu=[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],wt=[];function tr(e,t){t?(wt[0]=wt[16]=wt[1]=wt[2]=wt[3]=wt[4]=wt[5]=wt[6]=wt[7]=wt[8]=wt[9]=wt[10]=wt[11]=wt[12]=wt[13]=wt[14]=wt[15]=0,this.blocks=wt):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}tr.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if(n!=="string"){if(n==="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 r,i=0,s,a=e.length,o=this.blocks;i<a;){if(this.hashed&&(this.hashed=!1,o[0]=this.block,this.block=o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),t)for(s=this.start;i<a&&s<64;++i)o[s>>>2]|=e[i]<<Dn[s++&3];else for(s=this.start;i<a&&s<64;++i)r=e.charCodeAt(i),r<128?o[s>>>2]|=r<<Dn[s++&3]:r<2048?(o[s>>>2]|=(192|r>>>6)<<Dn[s++&3],o[s>>>2]|=(128|r&63)<<Dn[s++&3]):r<55296||r>=57344?(o[s>>>2]|=(224|r>>>12)<<Dn[s++&3],o[s>>>2]|=(128|r>>>6&63)<<Dn[s++&3],o[s>>>2]|=(128|r&63)<<Dn[s++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),o[s>>>2]|=(240|r>>>18)<<Dn[s++&3],o[s>>>2]|=(128|r>>>12&63)<<Dn[s++&3],o[s>>>2]|=(128|r>>>6&63)<<Dn[s++&3],o[s>>>2]|=(128|r&63)<<Dn[s++&3]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=o[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};tr.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=Y2[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()}};tr.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,s=this.h5,a=this.h6,o=this.h7,c=this.blocks,u,l,d,p,h,m,f,v,g,y,w;for(u=16;u<64;++u)h=c[u-15],l=(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3,h=c[u-2],d=(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10,c[u]=c[u-16]+l+c[u-7]+d<<0;for(w=t&n,u=0;u<64;u+=4)this.first?(this.is224?(v=300032,h=c[0]-1413257819,o=h-150054599<<0,r=h+24177077<<0):(v=704751109,h=c[0]-210244248,o=h-1521486534<<0,r=h+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),v=e&t,p=v^e&n^w,f=i&s^~i&a,h=o+d+f+Yu[u]+c[u],m=l+p,o=r+h<<0,r=h+m<<0),l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),d=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),g=r&e,p=g^r&t^v,f=a&o^~a&i,h=s+d+f+Yu[u+1]+c[u+1],m=l+p,a=n+h<<0,n=h+m<<0,l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),d=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),y=n&r,p=y^n&e^g,f=s&a^~s&o,h=i+d+f+Yu[u+2]+c[u+2],m=l+p,s=t+h<<0,t=h+m<<0,l=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),w=t&n,p=w^t&r^y,f=s&a^~s&o,h=i+d+f+Yu[u+3]+c[u+3],m=l+p,i=e+h<<0,e=h+m<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+i<<0,this.h5=this.h5+s<<0,this.h6=this.h6+a<<0,this.h7=this.h7+o<<0};tr.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,s=this.h5,a=this.h6,o=this.h7,c=ne[e>>>28&15]+ne[e>>>24&15]+ne[e>>>20&15]+ne[e>>>16&15]+ne[e>>>12&15]+ne[e>>>8&15]+ne[e>>>4&15]+ne[e&15]+ne[t>>>28&15]+ne[t>>>24&15]+ne[t>>>20&15]+ne[t>>>16&15]+ne[t>>>12&15]+ne[t>>>8&15]+ne[t>>>4&15]+ne[t&15]+ne[n>>>28&15]+ne[n>>>24&15]+ne[n>>>20&15]+ne[n>>>16&15]+ne[n>>>12&15]+ne[n>>>8&15]+ne[n>>>4&15]+ne[n&15]+ne[r>>>28&15]+ne[r>>>24&15]+ne[r>>>20&15]+ne[r>>>16&15]+ne[r>>>12&15]+ne[r>>>8&15]+ne[r>>>4&15]+ne[r&15]+ne[i>>>28&15]+ne[i>>>24&15]+ne[i>>>20&15]+ne[i>>>16&15]+ne[i>>>12&15]+ne[i>>>8&15]+ne[i>>>4&15]+ne[i&15]+ne[s>>>28&15]+ne[s>>>24&15]+ne[s>>>20&15]+ne[s>>>16&15]+ne[s>>>12&15]+ne[s>>>8&15]+ne[s>>>4&15]+ne[s&15]+ne[a>>>28&15]+ne[a>>>24&15]+ne[a>>>20&15]+ne[a>>>16&15]+ne[a>>>12&15]+ne[a>>>8&15]+ne[a>>>4&15]+ne[a&15];return this.is224||(c+=ne[o>>>28&15]+ne[o>>>24&15]+ne[o>>>20&15]+ne[o>>>16&15]+ne[o>>>12&15]+ne[o>>>8&15]+ne[o>>>4&15]+ne[o&15]),c};tr.prototype.toString=tr.prototype.hex;tr.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,s=this.h5,a=this.h6,o=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,n>>>24&255,n>>>16&255,n>>>8&255,n&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255];return this.is224||c.push(o>>>24&255,o>>>16&255,o>>>8&255,o&255),c};tr.prototype.array=tr.prototype.digest;tr.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 __=(...e)=>new tr(!1,!0).update(e.join("")).hex(),Q2=G({sha256:()=>__});function i1(e){let t=Symbol.for(e);return{brand(n,r){let i=r?Symbol.for(`${e}.${r}`):t;class s extends n{[i]=!0;constructor(...o){super(...o)}static isInstance(o){return typeof o=="object"&&o!==null&&i in o&&o[i]===!0}}return Object.defineProperty(s,"name",{value:n.name}),s},sub(n){return i1(`${e}.${n}`)},isInstance(n){return typeof n=="object"&&n!==null&&t in n&&n[t]===!0}}}var eR=i1("langchain"),tR=G({ContextOverflowError:()=>s1,LangChainError:()=>v_,ModelAbortError:()=>rg,addLangChainErrorFields:()=>Vc,ns:()=>gh});function Vc(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
7
|
+
|
|
8
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
9
|
+
`,e}var gh=eR.sub("error"),v_=class extends gh.brand(Error){name="LangChainError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},rg=class extends gh.brand(v_,"model-abort"){name="ModelAbortError";partialOutput;constructor(e,t){super(e),this.partialOutput=t}},s1=class a1 extends gh.brand(v_,"context-overflow"){name="ContextOverflowError";cause;constructor(t){super(t??"Input exceeded the model's context window.")}static fromError(t){let n=new a1(t.message);return n.cause=t,n}};function $r(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 b_(e){return $r(e)&&e.source_type==="url"&&"url"in e&&typeof e.url=="string"}function w_(e){return $r(e)&&e.source_type==="base64"&&"data"in e&&typeof e.data=="string"}function nR(e){return $r(e)&&e.source_type==="text"&&"text"in e&&typeof e.text=="string"}function o1(e){return $r(e)&&e.source_type==="id"&&"id"in e&&typeof e.id=="string"}function c1(e){if($r(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 ig(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 n=t[0].trim(),r=t[1].trim();if(n===""||r==="")throw new Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let s of e.split(";").slice(1)){let a=s.split("=");if(a.length!==2)throw new Error(`Invalid parameter syntax in mime type: "${e}".`);let o=a[0].trim(),c=a[1].trim();if(o==="")throw new Error(`Invalid parameter syntax in mime type: "${e}".`);i[o]=c}return{type:n,subtype:r,parameters:i}}function Qo({dataUrl:e,asTypedArray:t=!1}){let n=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),r;if(n){r=n[1].toLowerCase();let i=t?Uint8Array.from(atob(n[2]),s=>s.charCodeAt(0)):n[2];return{mime_type:r,data:i}}}function k_(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 Q(e,t){return oe(e)&&e.type===t}function oe(e){return typeof e=="object"&&e!==null}function sn(e){return Array.isArray(e)}function U(e){return typeof e=="string"}function Kn(e){return typeof e=="number"}function x_(e){return e instanceof Uint8Array}function Pw(e){try{return JSON.parse(e)}catch{return}}var fi=e=>e();function rR(e){if(e.type==="char_location"&&U(e.document_title)&&Kn(e.start_char_index)&&Kn(e.end_char_index)&&U(e.cited_text)){let{document_title:t,start_char_index:n,end_char_index:r,cited_text:i,...s}=e;return{...s,type:"citation",source:"char",title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type==="page_location"&&U(e.document_title)&&Kn(e.start_page_number)&&Kn(e.end_page_number)&&U(e.cited_text)){let{document_title:t,start_page_number:n,end_page_number:r,cited_text:i,...s}=e;return{...s,type:"citation",source:"page",title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type==="content_block_location"&&U(e.document_title)&&Kn(e.start_block_index)&&Kn(e.end_block_index)&&U(e.cited_text)){let{document_title:t,start_block_index:n,end_block_index:r,cited_text:i,...s}=e;return{...s,type:"citation",source:"block",title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type==="web_search_result_location"&&U(e.url)&&U(e.title)&&U(e.encrypted_index)&&U(e.cited_text)){let{url:t,title:n,encrypted_index:r,cited_text:i,...s}=e;return{...s,type:"citation",source:"url",url:t,title:n,startIndex:Number(r),endIndex:Number(r),citedText:i}}if(e.type==="search_result_location"&&U(e.source)&&U(e.title)&&Kn(e.start_block_index)&&Kn(e.end_block_index)&&U(e.cited_text)){let{source:t,title:n,start_block_index:r,end_block_index:i,cited_text:s,...a}=e;return{...a,type:"citation",source:"search",url:t,title:n??void 0,startIndex:r,endIndex:i,citedText:s}}}function u1(e){if(Q(e,"document")&&oe(e.source)&&"type"in e.source){if(e.source.type==="base64"&&U(e.source.media_type)&&U(e.source.data))return{type:"file",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&U(e.source.url))return{type:"file",url:e.source.url};if(e.source.type==="file"&&U(e.source.file_id))return{type:"file",fileId:e.source.file_id};if(e.source.type==="text"&&U(e.source.data))return{type:"file",mimeType:String(e.source.media_type??"text/plain"),data:e.source.data}}else if(Q(e,"image")&&oe(e.source)&&"type"in e.source){if(e.source.type==="base64"&&U(e.source.media_type)&&U(e.source.data))return{type:"image",mimeType:e.source.media_type,data:e.source.data};if(e.source.type==="url"&&U(e.source.url))return{type:"image",url:e.source.url};if(e.source.type==="file"&&U(e.source.file_id))return{type:"image",fileId:e.source.file_id}}}function iR(e){function*t(){for(let n of e){let r=u1(n);r?yield r:yield n}}return Array.from(t())}function jw(e){function*t(){let n=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let r of n){if(Q(r,"text")&&U(r.text)){let{text:i,citations:s,...a}=r;if(sn(s)&&s.length){let o=s.reduce((c,u)=>{let l=rR(u);return l?[...c,l]:c},[]);yield{...a,type:"text",text:i,annotations:o};continue}else{yield{...a,type:"text",text:i};continue}}else if(Q(r,"thinking")&&U(r.thinking)){let{thinking:i,signature:s,...a}=r;yield{...a,type:"reasoning",reasoning:i,signature:s};continue}else if(Q(r,"redacted_thinking")){yield{type:"non_standard",value:r};continue}else if(Q(r,"tool_use")&&U(r.name)&&U(r.id)){yield{type:"tool_call",id:r.id,name:r.name,args:r.input};continue}else if(Q(r,"input_json_delta")){if(aR(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(Q(r,"server_tool_use")&&U(r.name)&&U(r.id)){let{name:i,id:s}=r;if(i==="web_search"){yield{id:s,type:"server_tool_call",name:"web_search",args:{query:fi(()=>{if(typeof r.input=="string")return r.input;if(oe(r.input)&&U(r.input.query))return r.input.query;if(U(r.partial_json)){let a=Pw(r.partial_json);if(a?.query)return a.query}return""})}};continue}else if(r.name==="code_execution"){yield{id:s,type:"server_tool_call",name:"code_execution",args:{code:fi(()=>{if(typeof r.input=="string")return r.input;if(oe(r.input)&&U(r.input.code))return r.input.code;if(U(r.partial_json)){let a=Pw(r.partial_json);if(a?.code)return a.code}return""})}};continue}}else if(Q(r,"web_search_tool_result")&&U(r.tool_use_id)&&sn(r.content)){let{content:i,tool_use_id:s}=r;yield{type:"server_tool_call_result",name:"web_search",toolCallId:s,status:"success",output:{urls:i.reduce((a,o)=>Q(o,"web_search_result")?[...a,o.url]:a,[])}};continue}else if(Q(r,"code_execution_tool_result")&&U(r.tool_use_id)&&oe(r.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:r.tool_use_id,status:"success",output:r.content};continue}else if(Q(r,"mcp_tool_use")){yield{id:r.id,type:"server_tool_call",name:"mcp_tool_use",args:r.input};continue}else if(Q(r,"mcp_tool_result")&&U(r.tool_use_id)&&oe(r.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:r.tool_use_id,status:"success",output:r.content};continue}else if(Q(r,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:r.input};continue}else if(Q(r,"search_result")){yield{id:r.id,type:"non_standard",value:r};continue}else if(Q(r,"tool_result")){yield{id:r.id,type:"non_standard",value:r};continue}else{let i=u1(r);if(i){yield i;continue}}yield{type:"non_standard",value:r}}}return Array.from(t())}var sR={translateContent:jw,translateContentChunk:jw};function aR(e){return typeof e?._getType=="function"&&typeof e.concat=="function"&&e._getType()==="ai"}function oR(e){return b_(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:w_(e)?{type:e.type,mimeType:e.mime_type??"application/octet-stream",data:e.data,metadata:e.metadata}:o1(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function cR(e){return e.map(oR)}function uR(e){return!!(Q(e,"image_url")&&oe(e.image_url)||Q(e,"input_audio")&&oe(e.input_audio)||Q(e,"file")&&oe(e.file))}function lR(e){if(Q(e,"image_url")&&oe(e.image_url)&&U(e.image_url.url)){let t=Qo({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(Q(e,"input_audio")&&oe(e.input_audio)&&U(e.input_audio.data)&&U(e.input_audio.format))return{type:"audio",data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};if(Q(e,"file")&&oe(e.file)&&U(e.file.data)){let t=Qo({dataUrl:e.file.data});if(t)return{type:"file",data:t.data,mimeType:t.mime_type};if(U(e.file.file_id))return{type:"file",fileId:e.file.file_id}}}return e}function dR(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...$_(e.content));for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}function pR(e){let t=[];typeof e.content=="string"?e.content.length>0&&t.push({type:"text",text:e.content}):t.push(...$_(e.content));for(let n of e.tool_calls??[])t.push({type:"tool_call",id:n.id,name:n.name,args:n.args});return t}function $_(e){let t=[];for(let n of e)uR(n)?t.push(lR(n)):t.push(n);return t}function hR(e){if(e.type==="url_citation"){let{url:t,title:n,start_index:r,end_index:i}=e;return{type:"citation",url:t,title:n,startIndex:r,endIndex:i}}if(e.type==="file_citation"){let{file_id:t,filename:n,index:r}=e;return{type:"citation",title:n,startIndex:r,endIndex:r,fileId:t}}return e}function l1(e){function*t(){oe(e.additional_kwargs?.reasoning)&&sn(e.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:e.additional_kwargs.reasoning.summary.reduce((r,i)=>oe(i)&&U(i.text)?`${r}${i.text}`:r,"")});let n=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let r of n)if(Q(r,"text")){let{text:i,annotations:s,phase:a,extras:o,...c}=r,u=oe(o)?{...o}:{};U(a)&&(u.phase=a);let l=Object.keys(u).length>0?{extras:u}:{};Array.isArray(s)?yield{...c,...l,type:"text",text:String(i),annotations:s.map(hR)}:yield{...c,...l,type:"text",text:String(i)}}for(let r of e.tool_calls??[])yield{type:"tool_call",id:r.id,name:r.name,args:r.args};if(oe(e.additional_kwargs)&&sn(e.additional_kwargs.tool_outputs))for(let r of e.additional_kwargs.tool_outputs){if(Q(r,"web_search_call")){let i={};if(oe(r.action)&&U(r.action.query)&&(i.query=r.action.query),yield{id:r.id,type:"server_tool_call",name:"web_search",args:i},r.status==="completed"||r.status==="failed"){let s={};oe(r.action)&&(s.action=r.action),yield{type:"server_tool_call_result",toolCallId:U(r.id)?r.id:"",status:r.status==="completed"?"success":"error",output:s}}continue}else if(Q(r,"file_search_call")){yield{id:r.id,type:"server_tool_call",name:"file_search",args:{queries:sn(r.queries)?r.queries:[]}},(r.status==="completed"||r.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:U(r.id)?r.id:"",status:r.status==="completed"?"success":"error",output:sn(r.results)?{results:r.results}:{}});continue}else if(Q(r,"computer_call")){yield{type:"non_standard",value:r};continue}else if(Q(r,"code_interpreter_call")){if(U(r.code)&&(yield{id:r.id,type:"server_tool_call",name:"code_interpreter",args:{code:r.code}}),sn(r.outputs)){let i=fi(()=>{if(r.status!=="in_progress"){if(r.status==="completed")return 0;if(r.status==="incomplete")return 127;if(r.status!=="interpreting"&&r.status==="failed")return 1}});for(let s of r.outputs)if(Q(s,"logs")){yield{type:"server_tool_call_result",toolCallId:r.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:i??0,stderr:[0,void 0].includes(i)?void 0:String(s.logs),stdout:[0,void 0].includes(i)?String(s.logs):void 0}};continue}}continue}else if(Q(r,"mcp_call")){yield{id:r.id,type:"server_tool_call",name:"mcp_call",args:r.input};continue}else if(Q(r,"mcp_list_tools")){yield{id:r.id,type:"server_tool_call",name:"mcp_list_tools",args:r.input};continue}else if(Q(r,"mcp_approval_request")){yield{type:"non_standard",value:r};continue}else if(Q(r,"tool_search_call")){let i={};oe(r.arguments)&&Object.assign(i,r.arguments);let s={};U(r.execution)&&(s.execution=r.execution),U(r.status)&&(s.status=r.status),U(r.call_id)&&(s.call_id=r.call_id),yield{id:U(r.id)?r.id:"",type:"server_tool_call",name:"tool_search",args:i,...Object.keys(s).length>0?{extras:s}:{}};continue}else if(Q(r,"tool_search_output")){let i={name:"tool_search"};U(r.execution)&&(i.execution=r.execution),yield{type:"server_tool_call_result",toolCallId:U(r.id)?r.id:"",status:r.status==="completed"?"success":r.status==="failed"?"error":"success",output:{tools:sn(r.tools)?r.tools:[]},extras:i};continue}else if(Q(r,"image_generation_call")){U(r.result)&&(yield{type:"image",mimeType:"image/png",data:r.result,id:U(r.id)?r.id:void 0,metadata:{status:U(r.status)?r.status:void 0}}),yield{type:"non_standard",value:r};continue}oe(r)&&(yield{type:"non_standard",value:r})}}return Array.from(t())}function mR(e){function*t(){yield*l1(e);for(let n of e.tool_call_chunks??[])yield{type:"tool_call_chunk",id:n.id,name:n.name,args:n.args}}return Array.from(t())}var fR={translateContent:e=>typeof e.content=="string"?dR(e):l1(e),translateContentChunk:e=>typeof e.content=="string"?pR(e):mR(e)};function d1(e){return typeof e=="object"&&e!==null&&"type"in e&&"content"in e&&(typeof e.content=="string"||Array.isArray(e.content))}function gR(e,t="pretty"){return t==="pretty"?yR(e):JSON.stringify(e)}function yR(e){let t=[],n=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,r=Math.floor((80-n.length)/2),i="=".repeat(r),s=n.length%2===0?i:`${i}=`;if(t.push(`${i}${n}${s}`),e.type==="ai"){let a=e;if(a.tool_calls&&a.tool_calls.length>0){t.push("Tool Calls:");for(let o of a.tool_calls){t.push(` ${o.name} (${o.id})`),t.push(` Call ID: ${o.id}`),t.push(" Args:");for(let[c,u]of Object.entries(o.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(`
|
|
10
|
+
`)}var Gm=Symbol.for("langchain.message");function Rw(e){return Array.isArray(e)?e:typeof e=="string"?e===""?[]:[{type:"text",text:e}]:e==null?[]:[e]}function Vr(e,t){if(typeof e=="string")return e===""?t:typeof t=="string"?e+t:Array.isArray(t)&&t.length===0?e:Array.isArray(t)&&t.some(n=>$r(n))?[{type:"text",source_type:"text",text:e},...t]:[{type:"text",text:e},...t];if(Array.isArray(t)){let n=Rw(e);return va(n,t)??[...n,...t]}else return t===""?e:Array.isArray(e)&&e.some(n=>$r(n))?[...e,{type:"file",source_type:"text",text:t}]:[...Rw(e),{type:"text",text:t}]}function p1(e,t){return e==="error"||t==="error"?"error":"success"}function _R(e,t){function n(r,i){if(typeof r!="object"||r===null||r===void 0)return r;if(i>=t)return Array.isArray(r)?"[Array]":"[Object]";if(Array.isArray(r))return r.map(a=>n(a,i+1));let s={};for(let a of Object.keys(r))s[a]=n(r[a],i+1);return s}return JSON.stringify(n(e,0),null,2)}var Gt=class extends Rn{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[Gm]=!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[cR,$_,iR].reduce((t,n)=>n(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&&Gm in e&&e[Gm]===!0&&d1(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=_R(this._printableFields,Math.max(4,e));return`${this.constructor.lc_name()} ${t}`}toFormattedString(e="pretty"){return gR(this,e)}};function vR(e){return Array.isArray(e)&&e.every(t=>typeof t.index=="number")}var h1=["index","created","timestamp"];function Zt(e,t,n){let r=n?.ignoreKeys??h1;if(e==null&&t==null)return;if(e==null||t==null)return e??t;let i={...e};for(let[s,a]of Object.entries(t))if(i[s]==null)i[s]=a;else{if(a==null)continue;if(typeof i[s]!=typeof a||Array.isArray(i[s])!==Array.isArray(a))throw new Error(`field[${s}] already exists in the message chunk, but with a different type.`);if(typeof i[s]=="string"){if(s==="type")continue;if(["id","name","output_version","model_provider"].includes(s))a&&(i[s]=a);else{if(r.includes(s))continue;i[s]+=a}}else if(typeof i[s]=="number"){if(r.includes(s))continue;i[s]=i[s]+a}else if(typeof i[s]=="object"&&!Array.isArray(i[s]))i[s]=Zt(i[s],a,n);else if(Array.isArray(i[s]))i[s]=va(i[s],a,n);else{if(i[s]===a)continue;console.warn(`field[${s}] already exists in this message chunk and value has unsupported type.`)}}return i}function bR(e){return typeof e=="number"||typeof e=="string"}function Mw(e){return typeof e!="object"||e===null||!("index"in e)?!1:bR(e.index)}function Uw(e){if(typeof e!="object"||e===null||!("id"in e))return!1;let t=e.id;return t!=null&&t!==""}function wR(e,t){let n=Mw(t),r=Uw(t);return!n&&!r?-1:e.findIndex(i=>{let s=Mw(i),a=Uw(i);return n&&s?i.index!==t.index?!1:a&&r?i.id===t.id:!0:!n&&!s&&r&&a?i.id===t.id:!1})}function va(e,t,n){if(!(e==null&&t==null)){if(e==null||t==null)return e||t;{let r=[...e];for(let i of t){let s=wR(r,i);if(s!==-1)r[s]=Zt(r[s],i,n);else{if(typeof i=="object"&&i!==null&&"text"in i&&i.text==="")continue;r.push(i)}}return r}}}function m1(e,t,n){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.
|
|
11
|
+
Left ${typeof e}
|
|
12
|
+
Right ${typeof t}`);if(typeof e=="string"&&typeof t=="string")return e+t;if(Array.isArray(e)&&Array.isArray(t))return va(e,t,n);if(typeof e=="object"&&typeof t=="object")return Zt(e,t,n);if(e===t)return e;throw new Error(`Can not merge objects of different types.
|
|
13
|
+
Left ${e}
|
|
14
|
+
Right ${t}`)}}var Ui=class f1 extends Gt{static isInstance(t){if(!super.isInstance(t))return!1;let n=Object.getPrototypeOf(t);for(;n!==null;){if(n===f1.prototype)return!0;n=Object.getPrototypeOf(n)}return!1}};function g1(e){return typeof e.role=="string"}function it(e){return typeof e?._getType=="function"}function ms(e){return Ui.isInstance(e)}var kR=G({ToolMessage:()=>Mn,ToolMessageChunk:()=>Kc,defaultToolCallParser:()=>S_,isDirectToolOutput:()=>I_,isToolMessage:()=>ec,isToolMessageChunk:()=>y1});function I_(e){return e!=null&&typeof e=="object"&&"lc_direct_tool_output"in e&&e.lc_direct_tool_output===!0}var Mn=class extends Gt{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,n){let r=typeof e=="string"||Array.isArray(e)?{content:e,name:n,tool_call_id:t}:e;super(r),this.tool_call_id=r.tool_call_id,this.artifact=r.artifact,this.status=r.status,this.metadata=r.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}}},Kc=class extends Ui{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:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:Zt(this.response_metadata,e.response_metadata),artifact:m1(this.artifact,e.artifact),tool_call_id:this.tool_call_id,id:this.id??e.id,status:p1(this.status,e.status)})}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}};function S_(e){let t=[],n=[];for(let r of e)if(r.function){let i=r.function.name;try{let s=JSON.parse(r.function.arguments);t.push({name:i||"",args:s||{},id:r.id})}catch{n.push({name:i,args:r.function.arguments,id:r.id,error:"Malformed args."})}}else continue;return[t,n]}function ec(e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="tool"}function y1(e){return e._getType()==="tool"}function qo(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="tool_call")}function xR(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 pd=class extends Error{output;constructor(e,t){super(e),this.output=t}};function hd(e,t=ba){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
|
|
15
|
+
`)?r=r.substring(5):r.startsWith("json")?r=r.substring(4):r.startsWith(`
|
|
16
|
+
`)&&(r=r.substring(1));let i=r.indexOf("```"),s=r;return i!==-1&&(s=r.substring(0,i)),t(s.trim())}function $R(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw new Error("Unexpected end of JSON input");let n=0;function r(){for(;n<t.length&&/\s/.test(t[n]);)n+=1}function i(){if(t[n]!=='"')throw new Error(`Expected '"' at position ${n}, got '${t[n]}'`);n+=1;let l="",d=!1;for(;n<t.length;){let p=t[n];if(d){if(p==="n")l+=`
|
|
17
|
+
`;else if(p==="t")l+=" ";else if(p==="r")l+="\r";else if(p==="\\")l+="\\";else if(p==='"')l+='"';else if(p==="b")l+="\b";else if(p==="f")l+="\f";else if(p==="/")l+="/";else if(p==="u"){let h=t.substring(n+1,n+5);if(/^[0-9A-Fa-f]{0,4}$/.test(h))h.length===4?l+=String.fromCharCode(Number.parseInt(h,16)):l+=`u${h}`,n+=h.length;else throw new Error(`Invalid unicode escape sequence '\\u${h}' at position ${n}`)}else throw new Error(`Invalid escape sequence '\\${p}' at position ${n}`);d=!1}else if(p==="\\")d=!0;else{if(p==='"')return n+=1,l;l+=p}n+=1}return d&&(l+="\\"),l}function s(){let l=n,d="";if(t[n]==="-"&&(d+="-",n+=1),n<t.length&&t[n]==="0"&&(d+="0",n+=1,t[n]>="0"&&t[n]<="9"))throw new Error(`Invalid number at position ${l}`);if(n<t.length&&t[n]>="1"&&t[n]<="9")for(;n<t.length&&t[n]>="0"&&t[n]<="9";)d+=t[n],n+=1;if(n<t.length&&t[n]===".")for(d+=".",n+=1;n<t.length&&t[n]>="0"&&t[n]<="9";)d+=t[n],n+=1;if(n<t.length&&(t[n]==="e"||t[n]==="E"))for(d+=t[n],n+=1,n<t.length&&(t[n]==="+"||t[n]==="-")&&(d+=t[n],n+=1);n<t.length&&t[n]>="0"&&t[n]<="9";)d+=t[n],n+=1;if(d==="-")return-0;let p=Number.parseFloat(d);if(Number.isNaN(p))throw n=l,new Error(`Invalid number '${d}' at position ${l}`);return p}function a(){if(r(),n>=t.length)throw new Error(`Unexpected end of input at position ${n}`);let l=t[n];if(l==="{")return c();if(l==="[")return o();if(l==='"')return i();if("null".startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),null;if("true".startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),!0;if("false".startsWith(t.substring(n,n+5)))return n+=Math.min(5,t.length-n),!1;if(l==="-"||l>="0"&&l<="9")return s();throw new Error(`Unexpected character '${l}' at position ${n}`)}function o(){if(t[n]!=="[")throw new Error(`Expected '[' at position ${n}, got '${t[n]}'`);let l=[];if(n+=1,r(),n>=t.length)return l;if(t[n]==="]")return n+=1,l;for(;n<t.length;){if(r(),n>=t.length||(l.push(a()),r(),n>=t.length))return l;if(t[n]==="]")return n+=1,l;if(t[n]===","){n+=1;continue}throw new Error(`Expected ',' or ']' at position ${n}, got '${t[n]}'`)}return l}function c(){if(t[n]!=="{")throw new Error(`Expected '{' at position ${n}, got '${t[n]}'`);let l={};if(n+=1,r(),n>=t.length)return l;if(t[n]==="}")return n+=1,l;for(;n<t.length;){if(r(),n>=t.length)return l;let d=i();if(r(),n>=t.length)return l;if(t[n]!==":")throw new Error(`Expected ':' at position ${n}, got '${t[n]}'`);if(n+=1,r(),n>=t.length||(l[d]=a(),r(),n>=t.length))return l;if(t[n]==="}")return n+=1,l;if(t[n]===","){n+=1;continue}throw new Error(`Expected ',' or '}' at position ${n}, got '${t[n]}'`)}return l}let u=a();if(r(),n<t.length)throw new Error(`Unexpected character '${t[n]}' at position ${n}`);return u}function ba(e){try{return typeof e>"u"?null:$R(e)}catch{return null}}function O_(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 IR(e){if(oe(e.document)&&oe(e.document.source)){let t=O_(oe(e.document)&&U(e.document.format)?e.document.format:"");if(oe(e.document.source)){if(oe(e.document.source.s3Location)&&U(e.document.source.s3Location.uri))return{type:"file",mimeType:t,fileId:e.document.source.s3Location.uri};if(x_(e.document.source.bytes))return{type:"file",mimeType:t,data:e.document.source.bytes};if(U(e.document.source.text))return{type:"file",mimeType:t,data:Buffer.from(e.document.source.text).toString("base64")};if(sn(e.document.source.content))return{type:"file",mimeType:t,data:e.document.source.content.reduce((n,r)=>oe(r)&&U(r.text)?n+r.text:n,"")}}}return{type:"non_standard",value:e}}function SR(e){if(Q(e,"image")&&oe(e.image)){let t=O_(oe(e.image)&&U(e.image.format)?e.image.format:"");if(oe(e.image.source)){if(oe(e.image.source.s3Location)&&U(e.image.source.s3Location.uri))return{type:"image",mimeType:t,fileId:e.image.source.s3Location.uri};if(x_(e.image.source.bytes))return{type:"image",mimeType:t,data:e.image.source.bytes}}}return{type:"non_standard",value:e}}function OR(e){if(Q(e,"video")&&oe(e.video)){let t=O_(oe(e.video)&&U(e.video.format)?e.video.format:"");if(oe(e.video.source)){if(oe(e.video.source.s3Location)&&U(e.video.source.s3Location.uri))return{type:"video",mimeType:t,fileId:e.video.source.s3Location.uri};if(x_(e.video.source.bytes))return{type:"video",mimeType:t,data:e.video.source.bytes}}}return{type:"non_standard",value:e}}function Lw(e){function*t(){let n=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let r of n){if(Q(r,"cache_point")){yield{type:"non_standard",value:r};continue}else if(Q(r,"citations_content")&&oe(r.citationsContent)){yield{type:"text",text:sn(r.citationsContent.content)?r.citationsContent.content.reduce((i,s)=>oe(s)&&U(s.text)?i+s.text:i,""):"",annotations:sn(r.citationsContent.citations)?r.citationsContent.citations.reduce((i,s)=>{if(oe(s)){let a=sn(s.sourceContent)?s.sourceContent.reduce((c,u)=>oe(u)&&U(u.text)?c+u.text:c,""):"",o=fi(()=>{if(oe(s.location)){let c=s.location.documentChar||s.location.documentPage||s.location.documentChunk;if(oe(c))return{source:Kn(c.documentIndex)?c.documentIndex.toString():void 0,startIndex:Kn(c.start)?c.start:void 0,endIndex:Kn(c.end)?c.end:void 0}}return{}});i.push({type:"citation",citedText:a,...o})}return i},[]):[]};continue}else if(Q(r,"document")&&oe(r.document)){yield IR(r);continue}else if(Q(r,"guard_content")){yield{type:"non_standard",value:r};continue}else if(Q(r,"image")&&oe(r.image)){yield SR(r);continue}else if(Q(r,"reasoning_content")&&U(r.reasoningText)){yield{type:"reasoning",reasoning:r.reasoningText};continue}else if(Q(r,"text")&&U(r.text)){yield{type:"text",text:r.text};continue}else if(Q(r,"tool_result")){yield{type:"non_standard",value:r};continue}else{if(Q(r,"tool_call"))continue;if(Q(r,"video")&&oe(r.video)){yield OR(r);continue}}yield{type:"non_standard",value:r}}}return Array.from(t())}var AR={translateContent:Lw,translateContentChunk:Lw};function zw(e){let t=[],n=e.additional_kwargs?.reasoning_content;if(U(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let r of e.content)typeof r=="object"&&"type"in r&&r.type==="text"&&"text"in r&&U(r.text)&&t.push({type:"text",text:r.text});for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}var TR={translateContent:zw,translateContentChunk:zw};function Dw(e){function*t(){let n=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let r of n){if(Q(r,"text")&&U(r.text)){yield{type:"text",text:r.text};continue}else if(Q(r,"thinking")&&U(r.thinking)){yield{type:"reasoning",reasoning:r.thinking,...r.signature?{signature:r.signature}:{}};continue}else if(Q(r,"inlineData")&&oe(r.inlineData)&&U(r.inlineData.mimeType)&&U(r.inlineData.data)){yield{type:"file",mimeType:r.inlineData.mimeType,data:r.inlineData.data};continue}else if(Q(r,"functionCall")&&oe(r.functionCall)&&U(r.functionCall.name)&&oe(r.functionCall.args)){yield{type:"tool_call",id:e.id,name:r.functionCall.name,args:r.functionCall.args};continue}else if(Q(r,"functionResponse")){yield{type:"non_standard",value:r};continue}else if(Q(r,"fileData")&&oe(r.fileData)&&U(r.fileData.mimeType)&&U(r.fileData.fileUri)){yield{type:"file",mimeType:r.fileData.mimeType,fileId:r.fileData.fileUri};continue}else if(Q(r,"executableCode")){yield{type:"non_standard",value:r};continue}else if(Q(r,"codeExecutionResult")){yield{type:"non_standard",value:r};continue}yield{type:"non_standard",value:r}}}return Array.from(t())}var ER={translateContent:Dw,translateContentChunk:Dw};function Fw(e){function*t(){let n=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content;for(let r of n){if(Q(r,"reasoning")&&U(r.reasoning)){let i=fi(()=>{let s=n.indexOf(r);if(sn(e.additional_kwargs?.signatures)&&s>=0)return e.additional_kwargs.signatures.at(s)});U(i)?yield{type:"reasoning",reasoning:r.reasoning,signature:i}:yield{type:"reasoning",reasoning:r.reasoning};continue}else if(Q(r,"thinking")&&U(r.thinking)){yield{type:"reasoning",reasoning:r.thinking,...r.signature?{signature:r.signature}:{}};continue}else if(Q(r,"text")&&U(r.text)){yield{type:"text",text:r.text};continue}else if(Q(r,"image_url")){if(U(r.image_url))if(r.image_url.startsWith("data:")){let i=r.image_url.match(/^data:([^;]+);base64,(.+)$/);i?yield{type:"image",data:i[2],mimeType:i[1]}:yield{type:"image",url:r.image_url}}else yield{type:"image",url:r.image_url};continue}else if(Q(r,"media")&&U(r.mimeType)&&U(r.data)){yield{type:"file",mimeType:r.mimeType,data:r.data};continue}yield{type:"non_standard",value:r}}}return Array.from(t())}var CR={translateContent:Fw,translateContentChunk:Fw};function Zw(e){let t=[],n=e.additional_kwargs?.reasoning;if(U(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n}),typeof e.content=="string"){let r=e.content,i=r.match(/<think>([\s\S]*?)<\/think>/);if(i){let s=i[1].trim();s.length>0&&t.push({type:"reasoning",reasoning:s}),r=r.replace(/<think>[\s\S]*?<\/think>/,"").trim()}r.length>0&&t.push({type:"text",text:r})}else for(let r of e.content)if(typeof r=="object"&&"type"in r&&r.type==="text"&&"text"in r&&U(r.text)){let i=r.text,s=i.match(/<think>([\s\S]*?)<\/think>/);if(s){let a=s[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 r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}var NR={translateContent:Zw,translateContentChunk:Zw};function Bw(e){let t=[],n=e.additional_kwargs?.reasoning_content;if(U(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let r of e.content)typeof r=="object"&&"type"in r&&r.type==="text"&&"text"in r&&U(r.text)&&t.push({type:"text",text:r.text});for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}var PR={translateContent:Bw,translateContentChunk:Bw};function qw(e){let t=[];if(oe(e.additional_kwargs?.reasoning)){let r=e.additional_kwargs.reasoning;if(sn(r.summary)){let i=r.summary.reduce((s,a)=>oe(a)&&U(a.text)?`${s}${a.text}`:s,"");i.length>0&&t.push({type:"reasoning",reasoning:i})}}let n=e.additional_kwargs?.reasoning_content;if(U(n)&&n.length>0&&t.push({type:"reasoning",reasoning:n}),typeof e.content=="string")e.content.length>0&&t.push({type:"text",text:e.content});else for(let r of e.content)typeof r=="object"&&"type"in r&&r.type==="text"&&"text"in r&&U(r.text)&&t.push({type:"text",text:r.text});for(let r of e.tool_calls??[])t.push({type:"tool_call",id:r.id,name:r.name,args:r.args});return t}var jR={translateContent:qw,translateContentChunk:qw};function Jw(e){function*t(){let n=fi(()=>{if(typeof e.content=="string")return e.additional_kwargs.originalTextContentBlock?[{...e.additional_kwargs.originalTextContentBlock,type:"text"}]:[{type:"text",text:e.content}];{let r=e.additional_kwargs?.originalTextContentBlock;if(r?.thoughtSignature&&!e.content.some(i=>"thoughtSignature"in i)){let i=[...e.content];for(let s=i.length-1;s>=0;s--){let a=i[s];if(a.type==="text"&&!a.thought)return a.thoughtSignature=r.thoughtSignature,i}}return e.content}});for(let r of n){let i=fi(()=>Q(r,"text")&&U(r.text)?{type:"text",text:r.text}:Q(r,"inlineData")&&oe(r.inlineData)&&U(r.inlineData.mimeType)&&U(r.inlineData.data)?{type:"file",mimeType:r.inlineData.mimeType,data:r.inlineData.data}:Q(r,"functionCall")&&oe(r.functionCall)&&U(r.functionCall.name)&&oe(r.functionCall.args)?{type:"tool_call",id:e.id,name:r.functionCall.name,args:r.functionCall.args}:Q(r,"functionResponse")?{type:"non_standard",value:r}:Q(r,"fileData")&&oe(r.fileData)&&U(r.fileData.mimeType)&&U(r.fileData.fileUri)?{type:"file",mimeType:r.fileData.mimeType,fileId:r.fileData.fileUri}:Q(r,"executableCode")?{type:"non_standard",value:r}:Q(r,"codeExecutionResult")?{type:"non_standard",value:r}:{type:"non_standard",value:r}),s=fi(()=>"thought"in r&&r.thought?{type:"reasoning",reasoning:i.type==="text"?i.text:"",reasoningContentBlock:i}:i),a={thought:r.thought,thoughtSignature:r.thoughtSignature,partMetadata:r.partMetadata,...s};for(let o in a)a[o]===void 0&&delete a[o];yield a}}return Array.from(t())}var RR={translateContent:Jw,translateContentChunk:Jw};globalThis.lc_block_translators_registry??=new Map([["anthropic",sR],["bedrock-converse",AR],["deepseek",TR],["google",RR],["google-genai",ER],["google-vertexai",CR],["groq",NR],["ollama",PR],["openai",fR],["xai",jR]]);function _1(e){return globalThis.lc_block_translators_registry.get(e)}function v1(e,t){return Zt(e,t)??{}}function b1(e,t){let n={};return(e?.audio!==void 0||t?.audio!==void 0)&&(n.audio=(e?.audio??0)+(t?.audio??0)),(e?.image!==void 0||t?.image!==void 0)&&(n.image=(e?.image??0)+(t?.image??0)),(e?.video!==void 0||t?.video!==void 0)&&(n.video=(e?.video??0)+(t?.video??0)),(e?.document!==void 0||t?.document!==void 0)&&(n.document=(e?.document??0)+(t?.document??0)),(e?.text!==void 0||t?.text!==void 0)&&(n.text=(e?.text??0)+(t?.text??0)),n}function MR(e,t){let n={...b1(e,t)};return(e?.cache_read!==void 0||t?.cache_read!==void 0)&&(n.cache_read=(e?.cache_read??0)+(t?.cache_read??0)),(e?.cache_creation!==void 0||t?.cache_creation!==void 0)&&(n.cache_creation=(e?.cache_creation??0)+(t?.cache_creation??0)),n}function UR(e,t){let n={...b1(e,t)};return(e?.reasoning!==void 0||t?.reasoning!==void 0)&&(n.reasoning=(e?.reasoning??0)+(t?.reasoning??0)),n}function A_(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:MR(e?.input_token_details,t?.input_token_details),output_token_details:UR(e?.output_token_details,t?.output_token_details)}}var Le=class extends Gt{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 n=t.additional_kwargs?.tool_calls,r=t.tool_calls;n!=null&&n.length>0&&(r===void 0||r.length===0)&&console.warn(["New LangChain packages are available that more efficiently handle",`tool calling.
|
|
18
|
+
|
|
19
|
+
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(n!=null&&r===void 0){let[i,s]=S_(n);t.tool_calls=i??[],t.invalid_tool_calls=s??[]}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){if(t.tool_calls){let s=t.tool_calls.filter(a=>!t.contentBlocks?.some(o=>o.type==="tool_call"&&o.id===a.id&&o.name===a.name));t.contentBlocks.push(...s.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})))}let i=t.contentBlocks.filter(s=>s.type==="tool_call").filter(s=>!t.tool_calls?.some(a=>a.id===s.id&&a.name===s.name));i.length>0&&(t.tool_calls=[...t.tool_calls??[],...i.map(s=>({type:"tool_call",id:s.id,name:s.name,args:s.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=_1(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(n=>!e.some(r=>r.id===n.id&&r.name===n.name));e.push(...t.map(n=>({type:"tool_call",id:n.id,name:n.name,args:n.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 yh(e){return e._getType()==="ai"}function sg(e){return e._getType()==="ai"}var Pt=class extends Ui{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 n=x1(e.tool_call_chunks??[]);t={...e,tool_call_chunks:n.tool_call_chunks,tool_calls:n.tool_calls,invalid_tool_calls:n.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=_1(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(n=>n.type==="tool_call").map(n=>n.id);for(let n of this.tool_calls)n.id&&!t.includes(n.id)&&e.push({...n,type:"tool_call",id:n.id,name:n.name,args:n.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:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:v1(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 r=va(this.tool_call_chunks,e.tool_call_chunks);r!==void 0&&r.length>0&&(t.tool_call_chunks=r)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let r=va(this.tool_calls,e.tool_calls);r!==void 0&&r.length>0&&(t.tool_calls=r)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=A_(this.usage_metadata,e.usage_metadata));let n=this.constructor;return new n(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}},Qr=class w1 extends Gt{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return w1}constructor(t,n){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:n}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},Wc=class extends Ui{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:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:Zt(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 LR(e){return e._getType()==="generic"}function zR(e){return e._getType()==="generic"}var _h=class extends Gt{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},Gc=class extends Ui{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:Zt(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function DR(e){return e._getType()==="function"}function FR(e){return e._getType()==="function"}var $n=class extends Gt{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},Xc=class extends Ui{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:Zt(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function ZR(e){return e.getType()==="human"}function BR(e){return e.getType()==="human"}var os=class extends Gt{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"}},Ir=class Dl extends Gt{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Dl({content:Vr(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(Dl.isInstance(t))return new Dl({content:Vr(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},xi=class extends Ui{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Vr(this.content,e.content),additional_kwargs:Zt(this.additional_kwargs,e.additional_kwargs),response_metadata:Zt(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function qR(e){return e._getType()==="system"}function JR(e){return e._getType()==="system"}var k1=e=>e();function HR(e){return qo(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 VR(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function Xm(e){let t,n;if(VR(e)){let r=e.id.at(-1);r==="HumanMessage"||r==="HumanMessageChunk"?t="user":r==="AIMessage"||r==="AIMessageChunk"?t="assistant":r==="SystemMessage"||r==="SystemMessageChunk"?t="system":r==="FunctionMessage"||r==="FunctionMessageChunk"?t="function":r==="ToolMessage"||r==="ToolMessageChunk"?t="tool":t="unknown",n=e.kwargs}else{let{type:r,...i}=e;t=r,n=i}if(t==="human"||t==="user")return new $n(n);if(t==="ai"||t==="assistant"){let{tool_calls:r,...i}=n;if(!Array.isArray(r))return new Le(n);let s=r.map(HR);return new Le({...i,tool_calls:s})}else{if(t==="system")return new Ir(n);if(t==="developer")return new Ir({...n,additional_kwargs:{...n.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in n)return new Mn({...n,content:n.content,tool_call_id:n.tool_call_id,name:n.name});if(t==="remove"&&"id"in n&&typeof n.id=="string")return new os({...n,id:n.id});throw Vc(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
|
|
20
|
+
|
|
21
|
+
Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function br(e){if(typeof e=="string")return new $n(e);if(it(e))return e;if(Array.isArray(e)){let[t,n]=e;return Xm({type:t,content:n})}else if(g1(e)){let{role:t,...n}=e;return Xm({...n,type:t})}else return Xm(e)}function KR(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 T_(e,t="Human",n="AI"){let r=[];for(let i of e){let s;if(i.type==="human")s=t;else if(i.type==="ai")s=n;else if(i.type==="system")s="System";else if(i.type==="tool")s="Tool";else if(i.type==="generic")s=i.role;else throw new Error(`Got unsupported message type: ${i.type}`);let a=i.name?`${i.name}, `:"",o=typeof i.content=="string"?i.content:Array.isArray(i.content)?i.content.map(KR).filter(Boolean).join(""):"",c=`${s}: ${a}${o}`;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))}r.push(c)}return r.join(`
|
|
22
|
+
`)}function WR(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 E_(e){let t=WR(e);switch(t.type){case"human":return new $n(t.data);case"ai":return new Le(t.data);case"system":return new Ir(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new _h(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 Mn(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new Qr(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function GR(e){return e.map(E_)}function XR(e){return e.map(t=>t.toDict())}function md(e){let t=e._getType();if(t==="human")return new Xc({...e});if(t==="ai"){let n={...e};return"tool_calls"in n&&(n={...n,tool_call_chunks:n.tool_calls?.map(r=>({...r,type:"tool_call_chunk",index:void 0,args:JSON.stringify(r.args)}))}),new Pt({...n})}else{if(t==="system")return new xi({...e});if(t==="function")return new Gc({...e});if(Qr.isInstance(e))return new Wc({...e});throw new Error("Unknown message type.")}}function x1(e){let t=e.reduce((i,s)=>{let a=i.findIndex(([o])=>"id"in s&&s.id&&"index"in s&&s.index!==void 0?s.id===o.id&&s.index===o.index:"id"in s&&s.id?s.id===o.id:"index"in s&&s.index!==void 0?s.index===o.index:!1);return a!==-1?i[a].push(s):i.push([s]),i},[]),n=[],r=[];for(let i of t){let s=null,a=i[0]?.name??"",o=i.map(l=>l.args||"").join("").trim(),c=o.length?o:"{}",u=i[0]?.id;try{if(s=ba(c),!u||s===null||typeof s!="object"||Array.isArray(s))throw new Error("Malformed tool call chunk args.");n.push({name:a,args:s,id:u,type:"tool_call"})}catch{r.push({name:a,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:n,invalid_tool_calls:r}}var YR=G({BaseCache:()=>I1,InMemoryCache:()=>S1,defaultHashKeyEncoder:()=>$1,deserializeStoredGeneration:()=>QR,serializeGeneration:()=>e6}),$1=(...e)=>__(e.join("_"));function QR(e){return e.message!==void 0?{text:e.text,message:E_(e.message)}:{text:e.text}}function e6(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var I1=class{keyEncoder=$1;makeDefaultKeyEncoder(e){this.keyEncoder=e}},t6=new Map,S1=class O1 extends I1{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,n){return Promise.resolve(this.cache.get(this.keyEncoder(t,n))??null)}async update(t,n,r){this.cache.set(this.keyEncoder(t,n),r)}static global(){return new O1(t6)}},n6="ffffffff-ffff-ffff-ffff-ffffffffffff",r6="00000000-0000-0000-0000-000000000000",i6=/^(?:[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 gi(e){return typeof e=="string"&&i6.test(e)}function ag(e){if(!gi(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 At=[];for(let e=0;e<256;++e)At.push((e+256).toString(16).slice(1));function Yc(e,t=0){return(At[e[t+0]]+At[e[t+1]]+At[e[t+2]]+At[e[t+3]]+"-"+At[e[t+4]]+At[e[t+5]]+"-"+At[e[t+6]]+At[e[t+7]]+"-"+At[e[t+8]]+At[e[t+9]]+"-"+At[e[t+10]]+At[e[t+11]]+At[e[t+12]]+At[e[t+13]]+At[e[t+14]]+At[e[t+15]]).toLowerCase()}function s6(e,t=0){let n=Yc(e,t);if(!gi(n))throw TypeError("Stringified UUID is invalid");return n}var a6=new Uint8Array(16);function tc(){return crypto.getRandomValues(a6)}var go={};function o6(e,t,n){let r,i=e?._v6??!1;if(e){let s=Object.keys(e);s.length===1&&s[0]==="_v6"&&(e=void 0)}if(e)r=Hw(e.random??e.rng?.()??tc(),e.msecs,e.nsecs,e.clockseq,e.node,t,n);else{let s=Date.now(),a=tc();c6(go,s,a),r=Hw(a,go.msecs,go.nsecs,i?void 0:go.clockseq,i?void 0:go.node,t,n)}return t??Yc(r)}function c6(e,t,n){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=n.slice(10,16),e.node[0]|=1,e.clockseq=(n[8]<<8|n[9])&16383),e.msecs=t,e}function Hw(e,t,n,r,i,s,a=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),a=0;else if(a<0||a+16>s.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);t??=Date.now(),n??=0,r??=(e[8]<<8|e[9])&16383,i??=e.slice(10,16),t+=122192928e5;let o=((t&268435455)*1e4+n)%4294967296;s[a++]=o>>>24&255,s[a++]=o>>>16&255,s[a++]=o>>>8&255,s[a++]=o&255;let c=t/4294967296*1e4&268435455;s[a++]=c>>>8&255,s[a++]=c&255,s[a++]=c>>>24&15|16,s[a++]=c>>>16&255,s[a++]=r>>>8|128,s[a++]=r&255;for(let u=0;u<6;++u)s[a++]=i[u];return s}function A1(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():u6(e,t,n)}function u6(e,t,n){e=e||{};let r=e.random??e.rng?.()??tc();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[n+i]=r[i];return t}return Yc(r)}function l6(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function Ym(e,t){return e<<t|e>>>32-t}function d6(e){let t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520],r=new Uint8Array(e.length+1);r.set(e),r[e.length]=128,e=r;let i=e.length/4+2,s=Math.ceil(i/16),a=new Array(s);for(let o=0;o<s;++o){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[o*64+u*4]<<24|e[o*64+u*4+1]<<16|e[o*64+u*4+2]<<8|e[o*64+u*4+3];a[o]=c}a[s-1][14]=(e.length-1)*8/2**32,a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=(e.length-1)*8&4294967295;for(let o=0;o<s;++o){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[o][m];for(let m=16;m<80;++m)c[m]=Ym(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=n[0],l=n[1],d=n[2],p=n[3],h=n[4];for(let m=0;m<80;++m){let f=Math.floor(m/20),v=Ym(u,5)+l6(f,l,d,p)+h+t[f]+c[m]>>>0;h=p,p=d,d=Ym(l,30)>>>0,l=u,u=v}n[0]=n[0]+u>>>0,n[1]=n[1]+l>>>0,n[2]=n[2]+d>>>0,n[3]=n[3]+p>>>0,n[4]=n[4]+h>>>0}return Uint8Array.of(n[0]>>24,n[0]>>16,n[0]>>8,n[0],n[1]>>24,n[1]>>16,n[1]>>8,n[1],n[2]>>24,n[2]>>16,n[2]>>8,n[2],n[3]>>24,n[3]>>16,n[3]>>8,n[3],n[4]>>24,n[4]>>16,n[4]>>8,n[4])}function p6(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}var h6="6ba7b810-9dad-11d1-80b4-00c04fd430c8",m6="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function f6(e,t,n,r,i,s){let a=typeof n=="string"?p6(n):n,o=typeof r=="string"?ag(r):r;if(typeof r=="string"&&(r=ag(r)),r?.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(o),c.set(a,o.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(s??=0,s<0||s+16>i.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[s+u]=c[u];return i}return Yc(c)}function nc(e,t,n,r){return f6(80,d6,e,t,n,r)}nc.DNS=h6;nc.URL=m6;var Qm={};function Ur(e,t,n){let r;if(e)r=Vw(e.random??e.rng?.()??tc(),e.msecs,e.seq,t,n);else{let i=Date.now(),s=tc();g6(Qm,i,s),r=Vw(s,Qm.msecs,Qm.seq,t,n)}return t??Yc(r)}function g6(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Vw(e,t,n,r,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}function y6(e){if(!gi(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var _6=G({MAX:()=>n6,NIL:()=>r6,parse:()=>ag,stringify:()=>s6,v1:()=>o6,v4:()=>A1,v5:()=>nc,v7:()=>Ur,validate:()=>gi,version:()=>y6}),v6=G({BaseCallbackHandler:()=>Li,callbackHandlerPrefersChatModelStreamEvents:()=>T1,callbackHandlerPrefersStreaming:()=>C_,isBaseCallbackHandler:()=>E1}),b6=class{};function C_(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}function T1(e){return"lc_prefer_chat_model_stream_events"in e&&e.lc_prefer_chat_model_stream_events}var Li=class extends b6{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,mh(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=bn("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 Rn.prototype.toJSON.call(this)}toJSONNotImplemented(){return Rn.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Li{name=Ur();constructor(){super(),Object.assign(this,e)}}return new t}},E1=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"},w6=/^(?:[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 k6(e){return typeof e=="string"&&w6.test(e)}function Kw(e){if(!k6(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 Tt=[];for(let e=0;e<256;++e)Tt.push((e+256).toString(16).slice(1));function N_(e,t=0){return(Tt[e[t+0]]+Tt[e[t+1]]+Tt[e[t+2]]+Tt[e[t+3]]+"-"+Tt[e[t+4]]+Tt[e[t+5]]+"-"+Tt[e[t+6]]+Tt[e[t+7]]+"-"+Tt[e[t+8]]+Tt[e[t+9]]+"-"+Tt[e[t+10]]+Tt[e[t+11]]+Tt[e[t+12]]+Tt[e[t+13]]+Tt[e[t+14]]+Tt[e[t+15]]).toLowerCase()}var x6=new Uint8Array(16);function og(){return crypto.getRandomValues(x6)}function yo(e,t,n){return crypto.randomUUID?crypto.randomUUID():$6(e)}function $6(e,t,n){e=e||{};let r=e.random??e.rng?.()??og();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,N_(r)}function I6(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ef(e,t){return e<<t|e>>>32-t}function S6(e){let t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520],r=new Uint8Array(e.length+1);r.set(e),r[e.length]=128,e=r;let i=e.length/4+2,s=Math.ceil(i/16),a=new Array(s);for(let o=0;o<s;++o){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[o*64+u*4]<<24|e[o*64+u*4+1]<<16|e[o*64+u*4+2]<<8|e[o*64+u*4+3];a[o]=c}a[s-1][14]=(e.length-1)*8/2**32,a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=(e.length-1)*8&4294967295;for(let o=0;o<s;++o){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=a[o][m];for(let m=16;m<80;++m)c[m]=ef(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=n[0],l=n[1],d=n[2],p=n[3],h=n[4];for(let m=0;m<80;++m){let f=Math.floor(m/20),v=ef(u,5)+I6(f,l,d,p)+h+t[f]+c[m]>>>0;h=p,p=d,d=ef(l,30)>>>0,l=u,u=v}n[0]=n[0]+u>>>0,n[1]=n[1]+l>>>0,n[2]=n[2]+d>>>0,n[3]=n[3]+p>>>0,n[4]=n[4]+h>>>0}return Uint8Array.of(n[0]>>24,n[0]>>16,n[0]>>8,n[0],n[1]>>24,n[1]>>16,n[1]>>8,n[1],n[2]>>24,n[2]>>16,n[2]>>8,n[2],n[3]>>24,n[3]>>16,n[3]>>8,n[3],n[4]>>24,n[4]>>16,n[4]>>8,n[4])}function O6(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}var A6="6ba7b810-9dad-11d1-80b4-00c04fd430c8",T6="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function E6(e,t,n,r,i,s){let a=typeof n=="string"?O6(n):n,o=typeof r=="string"?Kw(r):r;if(typeof r=="string"&&(r=Kw(r)),r?.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(o),c.set(a,o.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){if(s??=0,s<0||s+16>i.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[s+u]=c[u];return i}return N_(c)}function P_(e,t,n,r){return E6(80,S6,e,t,n,r)}P_.DNS=A6;P_.URL=T6;var tf={};function C1(e,t,n){let r;if(e)r=Ww(e.random??e.rng?.()??og(),e.msecs,e.seq,t,n);else{let i=Date.now(),s=og();C6(tf,i,s),r=Ww(s,tf.msecs,tf.seq,t,n)}return t??N_(r)}function C6(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Ww(e,t,n,r,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}var N6="gen_ai.operation.name",P6="gen_ai.system",Gw="gen_ai.request.model",j6="gen_ai.response.model",Xw="gen_ai.usage.input_tokens",Yw="gen_ai.usage.output_tokens",Qw="gen_ai.usage.total_tokens",R6="gen_ai.request.max_tokens",M6="gen_ai.request.temperature",U6="gen_ai.request.top_p",L6="gen_ai.request.frequency_penalty",z6="gen_ai.request.presence_penalty",D6="gen_ai.response.finish_reasons",F6="gen_ai.prompt",Z6="gen_ai.completion",B6="gen_ai.request.extra_query",q6="gen_ai.request.extra_body",J6="gen_ai.serialized.name",H6="gen_ai.serialized.signature",V6="gen_ai.serialized.doc",K6="gen_ai.response.id",W6="gen_ai.response.service_tier",G6="gen_ai.response.system_fingerprint",X6="gen_ai.usage.input_token_details",Y6="gen_ai.usage.output_token_details",Q6="langsmith.trace.session_id",eM="langsmith.trace.session_name",tM="langsmith.span.kind",nM="langsmith.trace.name",rM="langsmith.metadata",ek="langsmith.span.tags",iM="langsmith.request.streaming",sM="langsmith.request.headers",tk="langsmith.usage_metadata",aM=(...e)=>fetch(...e),N1=Symbol.for("ls:fetch_implementation"),oM=()=>globalThis[N1]===void 0,cM=e=>async(...t)=>{if(e||gt("DEBUG")==="true"){let[r,i]=t;console.log(`\u2192 ${i?.method||"GET"} ${r}`)}let n=await(globalThis[N1]??aM)(...t);return(e||gt("DEBUG")==="true")&&console.log(`\u2190 ${n.status} ${n.statusText} ${n.url}`),n},P1=()=>gt("PROJECT")??wn("LANGCHAIN_SESSION")??"default",nk={};function Fl(e){nk[e]||(console.warn(e),nk[e]=!0)}var R=e=>BigInt(e),j1=R("0x9E3779B1"),R1=R("0x85EBCA77"),uM=R("0xC2B2AE3D"),$i=R("0x9E3779B185EBCA87"),fs=R("0xC2B2AE3D27D4EB4F"),M1=R("0x165667B19E3779F9"),j_=R("0x85EBCA77C2B2AE63"),lM=R("0x27D4EB2F165667C5"),dM=R("0x165667919E3779F9"),pM=R("0x9FB21C651E98DF25");function hM(e){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.substring(n,n+2),16);return t}var dr=hM("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),ha=(R(1)<<R(128))-R(1),be=(R(1)<<R(64))-R(1),fd=(R(1)<<R(32))-R(1),Lr=64,U1=Lr/8,mM=8,Qu=4;function Je(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function He(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function sa(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function nf(e,t=0){return e[t]}var fM=e=>(e&R(255))<<R(56)|(e&R(65280))<<R(40)|(e&R(16711680))<<R(24)|(e&R(4278190080))<<R(8)|(e&R(0xff00000000))>>R(8)|(e&R(0xff0000000000))>>R(24)|(e&R(0xff000000000000))>>R(40)|(e&R(0xff00000000000000))>>R(56),gM=e=>(e=(e&R(65535))<<R(16)|(e&R(4294901760))>>R(16),e=(e&R(16711935))<<R(8)|(e&R(4278255360))>>R(8),e),yM=(e,t)=>(e&fd)*(t&fd)&be,wa=e=>{if(!e)throw new Error("Assert failed")};function _M(e,t){return(e<<t|e>>R(32)-t)&fd}function L1(e,t,n){for(let r=0;r<U1;r++){let i=He(t,r*8),s=i^He(n,r*8);e[r^1]+=i,e[r]+=yM(s,s>>R(32))}return e}function rk(e,t,n,r){for(let i=0;i<r;i++)L1(e,Je(t,i*Lr),Je(n,i*8));return e}function vM(e,t){for(let n=0;n<U1;n++){let r=He(t,n*8),i=e[n];i=cg(i,R(47)),i^=r,i*=j1,e[n]=i&be}return e}function el(e,t){return z1(e[0]^He(t,0),e[1]^He(t,mM))}function ik(e,t,n){let r=n;return r+=el(e.slice(0),Je(t,0*Qu)),r+=el(e.slice(2),Je(t,4*Qu)),r+=el(e.slice(4),Je(t,8*Qu)),r+=el(e.slice(6),Je(t,12*Qu)),gr(r&be)}function bM(e,t,n,r,i){let s=Math.floor((n.byteLength-Lr)/8),a=Lr*s,o=Math.floor((t.byteLength-1)/a);for(let c=0;c<o;c++)e=rk(e,Je(t,c*a),n,s),e=i(e,Je(n,n.byteLength-Lr));{let c=Math.floor((t.byteLength-1-a*o)/Lr);e=rk(e,Je(t,o*a),n,c),e=r(e,Je(t,t.byteLength-Lr),Je(n,n.byteLength-Lr-7))}return e}function wM(e,t,n){let r=new BigUint64Array([uM,$i,fs,M1,j_,R1,lM,j1]);wa(e.length>128),r=bM(r,e,t,L1,vM),wa(r.length*8==64);{let i=ik(r,Je(t,11),R(e.byteLength)*$i&be);return ik(r,Je(t,t.byteLength-Lr-11),~(R(e.byteLength)*fs)&be)<<R(64)|i}}function z1(e,t){let n=e*t&ha;return n&be^n>>R(64)}function sk(e,t,n){return z1((He(e,0)^He(t,0)+n)&be,(He(e,8)^He(t,8)-n)&be)}function Zl(e,t,n,r,i){let s=e&be,a=e>>R(64)&be;return s+=sk(t,r,i),s^=He(n,0)+He(n,8),s&=be,a+=sk(n,Je(r,16),i),a^=He(t,0)+He(t,8),a&=be,a<<R(64)|s}function gr(e){return e^=e>>R(37),e*=dM,e&=be,e^=e>>R(32),e}function gd(e){return e^=e>>R(33),e*=fs,e&=be,e^=e>>R(29),e*=M1,e&=be,e^=e>>R(32),e}function kM(e,t,n){let r=e.byteLength;wa(r>0&&r<=3);let i=R(nf(e,r-1))|R(r<<8)|R(nf(e,0)<<16)|R(nf(e,r>>1)<<24),s=(R(sa(t,0))^R(sa(t,4)))+n,a=(i^s)&be,o=(R(sa(t,8))^R(sa(t,12)))-n,c=(_M(gM(i),R(13))^o)&be;return(gd(c)&be)<<R(64)|gd(a)}function cg(e,t){return e^e>>t}function xM(e,t,n){let r=e.byteLength;wa(r>=4&&r<=8);{let i=sa(e,0),s=sa(e,r-4),a=R(i)|R(s)<<R(32),o=(He(t,16)^He(t,24))+n&be,c=(a^o)*($i+(R(r)<<R(2)))&ha;return c+=(c&be)<<R(65),c&=ha,c^=c>>R(67),cg(cg(c&be,R(35))*pM&be,R(28))|gr(c>>R(64))<<R(64)}}function $M(e,t,n){let r=e.byteLength;wa(r>=9&&r<=16);{let i=(He(t,32)^He(t,40))+n&be,s=(He(t,48)^He(t,56))-n&be,a=He(e),o=He(e,r-8),c=(a^o^i)*$i,u=(c&be)+(R(r-1)<<R(54));c=c&(ha^be)|u,o^=s,c+=o+(o&fd)*(R1-R(1))<<R(64),c&=ha,c^=fM(c>>R(64));let l=(c&be)*fs;return l+=(c>>R(64))*fs<<R(64),l&=ha,gr(l&be)|gr(l>>R(64))<<R(64)}}function IM(e,t){let n=e.byteLength;return wa(n<=16),n>8?$M(e,dr,t):n>=4?xM(e,dr,t):n>0?kM(e,dr,t):gd(t^He(dr,64)^He(dr,72))|gd(t^He(dr,80)^He(dr,88))<<R(64)}function ug(e){return~e+R(1)&be}function SM(e,t,n){let r=R(e.byteLength)*$i&be,i=R(e.byteLength-1)/R(32);for(;i>=0;){let o=Number(i);r=Zl(r,Je(e,16*o),Je(e,e.byteLength-16*(o+1)),Je(t,32*o),n),i--}let s=r+(r>>R(64))&be;s=gr(s);let a=(r&be)*$i+(r>>R(64))*j_+(R(e.byteLength)-n&be)*fs;return a&=be,a=ug(gr(a)),s|a<<R(64)}function OM(e,t,n){let r=R(e.byteLength)*$i&be;for(let a=32;a<160;a+=32)r=Zl(r,Je(e,a-32),Je(e,a-16),Je(t,a-32),n);r=gr(r&be)|gr(r>>R(64))<<R(64);for(let a=160;a<=e.byteLength;a+=32)r=Zl(r,Je(e,a-32),Je(e,a-16),Je(t,3+a-160),n);r=Zl(r,Je(e,e.byteLength-16),Je(e,e.byteLength-32),Je(t,103),ug(n));let i=r+(r>>R(64))&be;i=gr(i);let s=(r&be)*$i+(r>>R(64))*j_+(R(e.byteLength)-n&be)*fs;return s&=be,s=ug(gr(s)),i|s<<R(64)}function AM(e,t=R(0)){let n=e.byteLength;return n<=16?IM(e,t):n<=128?SM(e,dr,t):n<=240?OM(e,dr,t):wM(e,dr)}function TM(e){let t=new Uint8Array(16),n=new DataView(t.buffer),r=e&be,i=e>>R(64);return n.setBigUint64(0,i,!1),n.setBigUint64(8,r,!1),t}var D1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function _e(e,t){if(!D1.test(e)){let n=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(n)}return e}function EM(e){let t=typeof e=="string"?Date.parse(e):e;return C1({msecs:t,seq:0})}function CM(e){if(!D1.test(e))return null;let t=e[14];return parseInt(t,16)}function NM(e){let t=e.replace(/-/g,""),n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=parseInt(t.slice(r*2,r*2+2),16);return n}function PM(e){let t=Array.from(e).map(n=>n.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 jM=new TextEncoder;function RM(e){let t=jM.encode(e),n=AM(t);return TM(n)}function tl(e,t){let n=`${e}:${t}`,r=RM(n),i=new Uint8Array(16);if(CM(e)===7){let s=NM(e);i.set(s.slice(0,6),0)}else{let s=Date.now();i[0]=s/1099511627776&255,i[1]=s/4294967296&255,i[2]=s/16777216&255,i[3]=s/65536&255,i[4]=s/256&255,i[5]=s&255}return i[6]=112|r[0]&15,i[7]=r[1],i[8]=128|r[2]&63,i.set(r.slice(3,10),9),PM(i)}var yd={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function MM(e){}async function F1(e,t){}async function UM(e){return[]}async function LM(e){return{size:0}}function zM(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var lg=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,n){if(this.maxSize===0)return;let r=this.cache.get(t);if(!r){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...r,refreshFunc:n}),this._metrics.hits+=1,r.value}set(t,n,r){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}let i={value:n,createdAt:Date.now(),refreshFunc:r};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 n={};for(let[i,s]of this.cache.entries())n[i]=s.value;yd.dirname(t);let r=`${t}.tmp`;try{JSON.stringify({entries:n},null,2)}catch(i){throw i}}load(t){return 0}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[n,r]of this.cache.entries())zM(r,this.ttlSeconds)&&t.push([n,r]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[n,r]of t)if(r.refreshFunc!==void 0)try{let i=await r.refreshFunc();this.set(n,i,r.refreshFunc),this._metrics.refreshes+=1}catch(i){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${n}:`,i)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},ak=new lg,Z1="0.6.2",Cr,DM=()=>typeof window<"u"&&typeof window.document<"u",FM=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",ZM=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),B1=()=>typeof Deno<"u",BM=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!B1(),R_=()=>Cr||(typeof Bun<"u"?Cr="bun":DM()?Cr="browser":BM()?Cr="node":FM()?Cr="webworker":ZM()?Cr="jsdom":B1()?Cr="deno":Cr="other",Cr),rf;function q1(){if(rf===void 0){let e=R_(),t=JM();rf={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:Z1,...t}}return rf}function J1(){let e=qM(),t={},n=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_CONFIG_FILE","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[r,i]of Object.entries(e))typeof i=="string"&&!n.includes(r)&&!r.toLowerCase().includes("key")&&!r.toLowerCase().includes("secret")&&!r.toLowerCase().includes("token")&&(r==="LANGCHAIN_REVISION_ID"?t.revision_id=i:t[r]=i);return t}function qM(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,n]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&n!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof n=="string"?e[t]=n.slice(0,2)+"*".repeat(n.length-4)+n.slice(-2):e[t]=n)}catch{}return e}function wn(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function gt(e){return wn(`LANGSMITH_${e}`)||wn(`LANGCHAIN_${e}`)}var sf;function JM(){if(sf!==void 0)return sf;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 n of e){let r=wn(n);r!==void 0&&(t[n]=r)}return sf=t,t}function ok(){return wn("OTEL_ENABLED")==="true"||gt("OTEL_ENABLED")==="true"}var ck=new Set(["langsmith","otel"]);function H1(e){if(e!==void 0)return e;let t=gt("TRACING_MODE");if(t!==void 0&&t!==""){let n=t.toLowerCase();if(!ck.has(n))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...ck].sort().join(", ")}`);return ok()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),n}return ok()?"otel":"langsmith"}var dg=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...n){!this.hasWarned&&H1()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let r;if(n.length===1&&typeof n[0]=="function"?r=n[0]:n.length===2&&typeof n[1]=="function"?r=n[1]:n.length===3&&typeof n[2]=="function"&&(r=n[2]),typeof r=="function")return r()}},pg=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new dg})}getTracer(t,n){return this.mockTracer}getActiveSpan(){}setSpan(t,n){return t}getSpan(t){}setSpanContext(t,n){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},hg=class{active(){return{}}with(t,n){return n()}},af=Symbol.for("ls:otel_trace"),of=Symbol.for("ls:otel_context"),uk=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),HM=new pg,VM=new hg,mg=class{getTraceInstance(){return globalThis[af]??HM}getContextInstance(){return globalThis[of]??VM}initializeGlobalInstances(t){globalThis[af]===void 0&&(globalThis[af]=t.trace),globalThis[of]===void 0&&(globalThis[of]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[uk]=t}getDefaultOTLPTracerComponents(){return globalThis[uk]??void 0}},M_=new mg;function V1(){return M_.getTraceInstance()}function KM(){return M_.getContextInstance()}function WM(){return M_.getDefaultOTLPTracerComponents()}var GM={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function XM(e){return GM[e]||e}function YM(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var fg=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,n){for(let r of t)try{if(!r.run)continue;if(r.operation==="post"){let i=this.createSpanForRun(r,r.run,n.get(r.id));i&&!r.run.end_time&&this.spans.set(r.id,i)}else this.updateSpanForRun(r,r.run)}catch(i){console.error(`Error processing operation ${r.id}:`,i)}}createSpanForRun(t,n,r){let i=r&&V1().getSpan(r);if(i)try{return this.finishSpanSetup(i,n,t)}catch(s){console.error(`Failed to create span for run ${t.id}:`,s);return}}finishSpanSetup(t,n,r){return this.setSpanAttributes(t,n,r),n.error?(t.setStatus({code:2}),t.recordException(new Error(n.error))):t.setStatus({code:1}),n.end_time&&t.end(new Date(n.end_time)),t}updateSpanForRun(t,n){try{let r=this.spans.get(t.id);if(!r){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(r,n,t),n.error?(r.setStatus({code:2}),r.recordException(new Error(n.error))):r.setStatus({code:1});let i=n.end_time;i&&(r.end(new Date(i)),this.spans.delete(t.id))}catch(r){console.error(`Failed to update span for run ${t.id}:`,r)}}extractModelName(t){if(t.extra?.metadata){let n=t.extra.metadata;if(n.ls_model_name)return n.ls_model_name;if(n.invocation_params){let r=n.invocation_params;if(r.model)return r.model;if(r.model_name)return r.model_name}}}setSpanAttributes(t,n,r){if("run_type"in n&&n.run_type){t.setAttribute(tM,n.run_type);let o=XM(n.run_type||"chain");t.setAttribute(N6,o)}"name"in n&&n.name&&t.setAttribute(nM,n.name),"session_id"in n&&n.session_id&&t.setAttribute(Q6,n.session_id),"session_name"in n&&n.session_name&&t.setAttribute(eM,n.session_name),this.setGenAiSystem(t,n);let i=this.extractModelName(n);i&&t.setAttribute(Gw,i),n.extra?.metadata?.usage_metadata&&typeof n.extra.metadata.usage_metadata=="object"&&t.setAttribute(tk,JSON.stringify(n.extra.metadata.usage_metadata)),"prompt_tokens"in n&&typeof n.prompt_tokens=="number"&&t.setAttribute(Xw,n.prompt_tokens),"completion_tokens"in n&&typeof n.completion_tokens=="number"&&t.setAttribute(Yw,n.completion_tokens),"total_tokens"in n&&typeof n.total_tokens=="number"&&t.setAttribute(Qw,n.total_tokens),this.setInvocationParameters(t,n);let s=n.extra?.metadata||{};for(let[o,c]of Object.entries(s))c!=null&&t.setAttribute(`${rM}.${o}`,YM(c)?String(c):JSON.stringify(c));let a=n.tags;if(a&&Array.isArray(a)?t.setAttribute(ek,a.join(", ")):a&&t.setAttribute(ek,String(a)),"serialized"in n&&typeof n.serialized=="object"){let o=n.serialized;o.name&&t.setAttribute(J6,String(o.name)),o.signature&&t.setAttribute(H6,String(o.signature)),o.doc&&t.setAttribute(V6,String(o.doc))}this.setIOAttributes(t,r)}setGenAiSystem(t,n){let r="langchain",i=this.extractModelName(n);if(i){let s=i.toLowerCase();s.includes("anthropic")||s.startsWith("claude")?r="anthropic":s.includes("bedrock")?r="aws.bedrock":s.includes("azure")&&s.includes("openai")?r="az.ai.openai":s.includes("azure")&&s.includes("inference")?r="az.ai.inference":s.includes("cohere")?r="cohere":s.includes("deepseek")?r="deepseek":s.includes("gemini")?r="gemini":s.includes("groq")?r="groq":s.includes("watson")||s.includes("ibm")?r="ibm.watsonx.ai":s.includes("mistral")?r="mistral_ai":s.includes("gpt")||s.includes("openai")?r="openai":s.includes("perplexity")||s.includes("sonar")?r="perplexity":s.includes("vertex")?r="vertex_ai":(s.includes("xai")||s.includes("grok"))&&(r="xai")}t.setAttribute(P6,r)}setInvocationParameters(t,n){if(!n.extra?.metadata?.invocation_params)return;let r=n.extra.metadata.invocation_params;r.max_tokens!==void 0&&t.setAttribute(R6,r.max_tokens),r.temperature!==void 0&&t.setAttribute(M6,r.temperature),r.top_p!==void 0&&t.setAttribute(U6,r.top_p),r.frequency_penalty!==void 0&&t.setAttribute(L6,r.frequency_penalty),r.presence_penalty!==void 0&&t.setAttribute(z6,r.presence_penalty)}setIOAttributes(t,n){if(n.run.inputs)try{let r=n.run.inputs;typeof r=="object"&&r!==null&&(r.model&&Array.isArray(r.messages)&&t.setAttribute(Gw,r.model),r.stream!==void 0&&t.setAttribute(iM,r.stream),r.extra_headers&&t.setAttribute(sM,JSON.stringify(r.extra_headers)),r.extra_query&&t.setAttribute(B6,JSON.stringify(r.extra_query)),r.extra_body&&t.setAttribute(q6,JSON.stringify(r.extra_body))),t.setAttribute(F6,JSON.stringify(r))}catch(r){console.debug(`Failed to process inputs for run ${n.id}`,r)}if(n.run.outputs)try{let r=n.run.outputs,i=this.getUnifiedRunTokens(r);if(i&&(t.setAttribute(Xw,i[0]),t.setAttribute(Yw,i[1]),t.setAttribute(Qw,i[0]+i[1])),r&&typeof r=="object"){if(r.model&&t.setAttribute(j6,String(r.model)),r.id&&t.setAttribute(K6,r.id),r.choices&&Array.isArray(r.choices)){let s=r.choices.map(a=>a.finish_reason).filter(a=>a).map(String);s.length>0&&t.setAttribute(D6,s.join(", "))}if(r.service_tier&&t.setAttribute(W6,r.service_tier),r.system_fingerprint&&t.setAttribute(G6,r.system_fingerprint),r.usage_metadata&&typeof r.usage_metadata=="object"){let s=r.usage_metadata;t.setAttribute(tk,JSON.stringify(s)),s.input_token_details&&t.setAttribute(X6,JSON.stringify(s.input_token_details)),s.output_token_details&&t.setAttribute(Y6,JSON.stringify(s.output_token_details))}}t.setAttribute(Z6,JSON.stringify(r))}catch(r){console.debug(`Failed to process outputs for run ${n.id}`,r)}}getUnifiedRunTokens(t){if(!t)return null;let n=this.extractUnifiedRunTokens(t.usage_metadata);if(n)return n;let r=Object.keys(t);for(let a of r){let o=t[a];if(!(!o||typeof o!="object")&&(n=this.extractUnifiedRunTokens(o.usage_metadata),n||o.lc===1&&o.kwargs&&typeof o.kwargs=="object"&&(n=this.extractUnifiedRunTokens(o.kwargs.usage_metadata),n)))return n}let i=t.generations||[];if(!Array.isArray(i))return null;let s=Array.isArray(i[0])?i.flat():i;for(let a of s)if(typeof a=="object"&&a.message&&typeof a.message=="object"&&a.message.kwargs&&typeof a.message.kwargs=="object"&&(n=this.extractUnifiedRunTokens(a.message.kwargs.usage_metadata),n))return n;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]}},QM=Object.prototype.toString,eU=e=>QM.call(e)==="[object Error]",tU=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 nU(e){if(!(e&&eU(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:n}=e;return t==="Load failed"?n===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:tU.has(t)}function rU(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 nl(e,t,{min:n=0,allowInfinity:r=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${r?" or Infinity":""}.`);if(!r&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<n)throw new TypeError(`Expected \`${e}\` to be \u2265 ${n}.`)}}var iU=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 sU(e,t){let n=Math.max(1,e+1),r=t.randomize?Math.random()+1:1,i=Math.round(r*t.minTimeout*t.factor**(n-1));return i=Math.min(i,t.maxTimeout),i}function lk(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function aU({error:e,attemptNumber:t,retriesConsumed:n,startTime:r,options:i}){let s=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(s instanceof iU)throw s.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-n):i.retries,o=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:s,attemptNumber:t,retriesLeft:a,retriesConsumed:n});if(await i.onFailedAttempt(c),lk(r,o)<=0)throw s;let u=await i.shouldConsumeRetry(c),l=lk(r,o);if(l<=0||a<=0)throw s;if(s instanceof TypeError&&!nU(s)){if(u)throw s;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw s;if(!u)return i.signal?.throwIfAborted(),!1;let d=sU(n,i),p=Math.min(d,l);return p>0&&await new Promise((h,m)=>{let f=()=>{clearTimeout(v),i.signal?.removeEventListener("abort",f),m(i.signal.reason)},v=setTimeout(()=>{i.signal?.removeEventListener("abort",f),h()},p);i.unref&&v.unref?.(),i.signal?.addEventListener("abort",f,{once:!0})}),i.signal?.throwIfAborted(),!0}async function oU(e,t={}){if(t={...t},rU(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,nl("factor",t.factor,{min:0,allowInfinity:!1}),nl("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),nl("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),nl("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let n=0,r=0,i=performance.now();for(;!Number.isFinite(t.retries)||r<=t.retries;){n++;try{t.signal?.throwIfAborted();let s=await e(n);return t.signal?.throwIfAborted(),s}catch(s){await aU({error:s,attemptNumber:n,retriesConsumed:r,startTime:i,options:t})&&r++}}throw new Error("Retry attempts exhausted without throwing an error.")}var rl={},dk={exports:{}},pk;function cU(){return pk||(pk=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,l){this.fn=c,this.context=u,this.once=l||!1}function s(c,u,l,d,p){if(typeof l!="function")throw new TypeError("The listener must be a function");var h=new i(l,d||c,p),m=n?n+u:u;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],h]:c._events[m].push(h):(c._events[m]=h,c._eventsCount++),c}function a(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,l;if(this._eventsCount===0)return c;for(l in u=this._events)t.call(u,l)&&c.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=n?n+c:c,l=this._events[u];if(!l)return[];if(l.fn)return[l.fn];for(var d=0,p=l.length,h=new Array(p);d<p;d++)h[d]=l[d].fn;return h},o.prototype.listenerCount=function(c){var u=n?n+c:c,l=this._events[u];return l?l.fn?1:l.length:0},o.prototype.emit=function(c,u,l,d,p,h){var m=n?n+c:c;if(!this._events[m])return!1;var f=this._events[m],v=arguments.length,g,y;if(f.fn){switch(f.once&&this.removeListener(c,f.fn,void 0,!0),v){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,u),!0;case 3:return f.fn.call(f.context,u,l),!0;case 4:return f.fn.call(f.context,u,l,d),!0;case 5:return f.fn.call(f.context,u,l,d,p),!0;case 6:return f.fn.call(f.context,u,l,d,p,h),!0}for(y=1,g=new Array(v-1);y<v;y++)g[y-1]=arguments[y];f.fn.apply(f.context,g)}else{var w=f.length,x;for(y=0;y<w;y++)switch(f[y].once&&this.removeListener(c,f[y].fn,void 0,!0),v){case 1:f[y].fn.call(f[y].context);break;case 2:f[y].fn.call(f[y].context,u);break;case 3:f[y].fn.call(f[y].context,u,l);break;case 4:f[y].fn.call(f[y].context,u,l,d);break;default:if(!g)for(x=1,g=new Array(v-1);x<v;x++)g[x-1]=arguments[x];f[y].fn.apply(f[y].context,g)}}return!0},o.prototype.on=function(c,u,l){return s(this,c,u,l,!1)},o.prototype.once=function(c,u,l){return s(this,c,u,l,!0)},o.prototype.removeListener=function(c,u,l,d){var p=n?n+c:c;if(!this._events[p])return this;if(!u)return a(this,p),this;var h=this._events[p];if(h.fn)h.fn===u&&(!d||h.once)&&(!l||h.context===l)&&a(this,p);else{for(var m=0,f=[],v=h.length;m<v;m++)(h[m].fn!==u||d&&!h[m].once||l&&h[m].context!==l)&&f.push(h[m]);f.length?this._events[p]=f.length===1?f[0]:f:a(this,p)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,e.exports=o})(dk)),dk.exports}var _o={exports:{}},hk,mk;function uU(){return mk||(mk=1,hk=(e,t)=>(t=t||(()=>{}),e.then(n=>new Promise(r=>{r(t())}).then(()=>n),n=>new Promise(r=>{r(t())}).then(()=>{throw n})))),hk}var fk;function lU(){if(fk)return _o.exports;fk=1;let e=uU();class t extends Error{constructor(i){super(i),this.name="TimeoutError"}}let n=(r,i,s)=>new Promise((a,o)=>{if(typeof i!="number"||i<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(i===1/0){a(r);return}let c=setTimeout(()=>{if(typeof s=="function"){try{a(s())}catch(d){o(d)}return}let u=typeof s=="string"?s:`Promise timed out after ${i} milliseconds`,l=s instanceof Error?s:new t(u);typeof r.cancel=="function"&&r.cancel(),o(l)},i);e(r.then(a,o),()=>{clearTimeout(c)})});return _o.exports=n,_o.exports.default=n,_o.exports.TimeoutError=t,_o.exports}var il={},sl={},gk;function dU(){if(gk)return sl;gk=1,Object.defineProperty(sl,"__esModule",{value:!0});function e(t,n,r){let i=0,s=t.length;for(;s>0;){let a=s/2|0,o=i+a;r(t[o],n)<=0?(i=++o,s-=a+1):s=a}return i}return sl.default=e,sl}var yk;function pU(){if(yk)return il;yk=1,Object.defineProperty(il,"__esModule",{value:!0});let e=dU();class t{constructor(){this._queue=[]}enqueue(r,i){i=Object.assign({priority:0},i);let s={priority:i.priority,run:r};if(this.size&&this._queue[this.size-1].priority>=i.priority){this._queue.push(s);return}let a=e.default(this._queue,s,(o,c)=>c.priority-o.priority);this._queue.splice(a,0,s)}dequeue(){return this._queue.shift()?.run}filter(r){return this._queue.filter(i=>i.priority===r.priority).map(i=>i.run)}get size(){return this._queue.length}}return il.default=t,il}var _k;function hU(){if(_k)return rl;_k=1,Object.defineProperty(rl,"__esModule",{value:!0});let e=cU(),t=lU(),n=pU(),r=()=>{},i=new t.TimeoutError;class s extends e{constructor(o){var c,u,l,d;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=r,this._resolveIdle=r,o=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:n.default},o),!(typeof o.intervalCap=="number"&&o.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(u=(c=o.intervalCap)===null||c===void 0?void 0:c.toString())!==null&&u!==void 0?u:""}\` (${typeof o.intervalCap})`);if(o.interval===void 0||!(Number.isFinite(o.interval)&&o.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(d=(l=o.interval)===null||l===void 0?void 0:l.toString())!==null&&d!==void 0?d:""}\` (${typeof o.interval})`);this._carryoverConcurrencyCount=o.carryoverConcurrencyCount,this._isIntervalIgnored=o.intervalCap===1/0||o.interval===0,this._intervalCap=o.intervalCap,this._interval=o.interval,this._queue=new o.queueClass,this._queueClass=o.queueClass,this.concurrency=o.concurrency,this._timeout=o.timeout,this._throwOnTimeout=o.throwOnTimeout===!0,this._isPaused=o.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=r,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=r,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let o=Date.now();if(this._intervalId===void 0){let c=this._intervalEnd-o;if(c<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},c)),!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 o=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let c=this._queue.dequeue();return c?(this.emit("active"),c(),o&&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(o){if(!(typeof o=="number"&&o>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${o}\` (${typeof o})`);this._concurrency=o,this._processQueue()}async add(o,c={}){return new Promise((u,l)=>{let d=async()=>{this._pendingCount++,this._intervalCount++;try{let p=this._timeout===void 0&&c.timeout===void 0?o():t.default(Promise.resolve(o()),c.timeout===void 0?this._timeout:c.timeout,()=>{(c.throwOnTimeout===void 0?this._throwOnTimeout:c.throwOnTimeout)&&l(i)});u(await p)}catch(p){l(p)}this._next()};this._queue.enqueue(d,c),this._tryToStartAnother(),this.emit("add")})}async addAll(o,c){return Promise.all(o.map(async u=>this.add(u,c)))}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(o=>{let c=this._resolveEmpty;this._resolveEmpty=()=>{c(),o()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(o=>{let c=this._resolveIdle;this._resolveIdle=()=>{c(),o()}})}get size(){return this._queue.size}sizeBy(o){return this._queue.filter(o).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(o){this._timeout=o}}return rl.default=s,rl}var mU=hU(),Jr=Us(mU),fU="default"in Jr?Jr.default:Jr,gU=[408,425,429,500,502,503,504],vk=class{constructor(e){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=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.maxQueueSizeBytes=e.maxQueueSizeBytes,this.queue=new fU({concurrency:this.maxConcurrency}),this.onFailedResponseHook=e?.onFailedResponseHook}call(e,...t){return this.callWithOptions({},e,...t)}callWithOptions(e,t,...n){let r=e.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&r>0&&this.queueSizeBytes+r>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${r} bytes.`));r>0&&(this.queueSizeBytes+=r);let i=this.onFailedResponseHook,s=this.queue.add(()=>oU(()=>t(...n).catch(a=>{throw a instanceof Error?a:new Error(a)}),{async onFailedAttempt({error:a}){if(typeof a!="object"||a==null)throw a;let o="message"in a&&typeof a.message=="string"?a.message:void 0;if(o?.startsWith("Cancel")||o?.startsWith("TimeoutError")||o?.startsWith("AbortError")||"name"in a&&a.name==="TimeoutError"||"code"in a&&a.code==="ECONNABORTED")throw a;let c="response"in a?a.response:void 0;if(i&&await i(c))return;let u=c?.status??("status"in a?a.status:void 0);if(u!=null&&(typeof u=="number"||typeof u=="string")&&!gU.includes(+u))throw a},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return r>0&&(s=s.finally(()=>{this.queueSizeBytes-=r})),e.signal?Promise.race([s,new Promise((a,o)=>{e.signal?.addEventListener("abort",()=>{o(new Error("AbortError"))})})]):s}};function bk(e){return typeof e?._getType=="function"}function wk(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function cf(e){return`Invalid prompt identifier format: "${e}". Expected one of:
|
|
23
|
+
- "prompt-name" (for private prompts)
|
|
24
|
+
- "owner/prompt-name" (for prompts with explicit owner)
|
|
25
|
+
- "prompt-name:commit-hash" (with commit reference)
|
|
26
|
+
- "owner/prompt-name:commit-hash" (with owner and commit)`}var gg=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}},yg=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 uf(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithNotFoundError"}function yU(e){return e!=null&&typeof e=="object"&&"name"in e&&e?.name==="LangSmithConflictError"}async function te(e,t,n){let r;if(e.ok){n&&(r=await e.text());return}if(e.status===403)try{(await e.json())?.error==="org_scoped_key_requires_workspace"&&(r="This API key is org-scoped and requires workspace specification. Please provide 'workspaceId' parameter, or set LANGSMITH_WORKSPACE_ID environment variable.")}catch{let a=new Error(`${e.status} ${e.statusText}`);throw a.status=e?.status,a}if(r===void 0)try{r=await e.text()}catch{r=""}let i=`Failed to ${t}. Received status [${e.status}]: ${e.statusText}. Message: ${r}`;if(e.status===404)throw new yg(i);if(e.status===409)throw new gg(i);let s=new Error(i);throw s.status=e.status,s}var K1="ERR_CONFLICTING_ENDPOINTS",_g=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:K1}),this.name="ConflictingEndpointsError"}};function _U(e){return typeof e=="object"&&e!==null&&e.code===K1}function Jt(e){if(!e||e.split("/").length>2||e.startsWith("/")||e.endsWith("/")||e.split(":").length>2)throw new Error(cf(e));let[t,n]=e.split(":"),r=n||"latest";if(t.includes("/")){let[i,s]=t.split("/",2);if(!i||!s)throw new Error(cf(e));return[i,s,r]}else{if(!t)throw new Error(cf(e));return["-",t,r]}}var vg="https://api.smith.langchain.com",vU="langsmith-cli",bU=6e4,wU=1e4;function kU(){let e=R_();return e==="browser"||e==="webworker"}function xU(){let e=wn("LANGSMITH_CONFIG_FILE");if(e)return e;let t=wn("HOME")??wn("USERPROFILE");if(t)return yd.join(t,".langsmith","config.json")}function $U(){kU()||xU()}function Fn(e){return e!=null&&e.trim()!==""}function yi(e){return e?.trim().replace(/^["']|["']$/g,"")}function IU(e){let t=e.oauth;if(!t?.refresh_token)return!1;if(!t.access_token)return!0;if(!t.expires_at)return!1;let n=Date.parse(t.expires_at);return Number.isNaN(n)?!1:n<=Date.now()+bU}function SU(e){let t=e;for(;t.endsWith("/");)t=t.slice(0,-1);let n="/api/v1";return t.endsWith(n)?t.slice(0,-n.length):t}function OU(e,t){e.oauth??={},t.access_token&&(e.oauth.access_token=t.access_token),t.refresh_token&&(e.oauth.refresh_token=t.refresh_token),typeof t.expires_in=="number"&&t.expires_in>0&&(e.oauth.expires_at=new Date(Date.now()+t.expires_in*1e3).toISOString())}function kk(e){return e.reason??new Error("The operation was aborted.")}async function AU(e,t){if(!t)return e;if(t.aborted)throw kk(t);let n,r=new Promise((i,s)=>{let a=()=>{s(kk(t))};t.addEventListener("abort",a,{once:!0}),n=()=>{t.removeEventListener("abort",a)}});try{return await Promise.race([e,r])}finally{n?.()}}function TU(){let e=$U(),t=e?.profile;if(!e||!t)return{};let n=yi(t.api_key),r=yi(t.oauth?.access_token),i=yi(t.oauth?.refresh_token);return{apiUrl:t.api_url,apiKey:n,workspaceId:t.workspace_id,oauthAccessToken:r,oauthRefreshToken:i,profileAuth:n||r||i?new bg(e):void 0}}var bg=class{constructor(t){Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"refreshPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"managedAuthorizationValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.rememberProfileAuthHeader(this.currentAuthHeader())}currentAuthHeader(){let t=EU(this.state.profile);return this.rememberProfileAuthHeader(t),t}async getAuthHeader(t,n){IU(this.state.profile)&&(this.refreshPromise||(this.refreshPromise=this.refreshOAuthToken(t).finally(()=>{this.refreshPromise=void 0})),await AU(this.refreshPromise,n));let r=W1(this.state.profile);return this.rememberProfileAuthHeader(r),r}isProfileAuthorizationHeader(t){return t===this.managedAuthorizationValue}async refreshOAuthToken(t){let n=this.state.profile.oauth?.refresh_token;if(!n)return;let r=yi(this.state.profile.api_url)??vg;try{let i=new URLSearchParams({grant_type:"refresh_token",client_id:vU,refresh_token:n}),s=await t(`${SU(r)}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i.toString(),signal:AbortSignal.timeout(wU)});if(!s.ok)return;let a=await s.json();if(!a.access_token)return;OU(this.state.profile,a),this.state.config.profiles??={},this.state.config.profiles[this.state.profileName]=this.state.profile,await F1(this.state.configPath,`${JSON.stringify(this.state.config,null,2)}
|
|
27
|
+
`)}catch{return}}rememberProfileAuthHeader(t){this.managedAuthorizationValue=t?.name==="Authorization"?t.value:void 0}};function EU(e){let t=yi(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};if(!yi(e.oauth?.refresh_token))return W1(e)}function W1(e){let t=yi(e.oauth?.access_token);if(t)return{name:"Authorization",value:`Bearer ${t}`};let n=yi(e.api_key);if(n)return{name:"x-api-key",value:n}}var xk="[...]",CU={result:"[Circular]"},_d=[],aa=[],NU=new TextEncoder;function PU(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function al(e){return NU.encode(e)}function G1(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 jU(e){return function(t,n){return G1(n)}}function RU(e){try{let t=function(u){let l=c(u);return l>o&&(o=l),l+2},n=function(u){return u===0?2:2+u*4},r=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"},i=function(u){return u===void 0||typeof u=="function"||typeof u=="symbol"?4:s(u)},s=function(u){if(u===null)return 4;if(u===void 0)return 0;let l=typeof u;if(l==="boolean")return 5;if(l==="number")return Number.isFinite(u)?u.toString().length:4;if(l==="bigint")return u.toString().length+2;if(l==="string")return t(u);if(l==="function"||l==="symbol")return 0;let d=u;if(d instanceof Date)return 26;if(d instanceof RegExp)return c(d.toString())+2;if(d instanceof Error){let h=d.name??"",m=d.message??"";return 22+c(h)+c(m)}if(typeof Buffer<"u"&&d instanceof Buffer)return 28+n(d.byteLength);if(ArrayBuffer.isView(d)){if(d instanceof DataView)return 2;let h=d.length??0,m=d instanceof Float32Array||d instanceof Float64Array?30:12;return 2+h*m}if(d instanceof ArrayBuffer)return 2;if(a.has(d))return 24;if(typeof d.toJSON=="function"){let h;try{h=d.toJSON("")}catch{return 16}a.add(d);let m=s(h);return a.delete(d),m}a.add(d);let p;if(Array.isArray(d)){p=2;let h=d.length;for(let m=0;m<h;m++)p+=i(d[m]),m<h-1&&(p+=1)}else if(d instanceof Map){p=2;let h=0;for(let[m,f]of d){if(r(f))continue;h>0&&(p+=1);let v=typeof m=="string"?m:String(m);p+=c(v)+3,p+=s(f),h++}}else if(d instanceof Set){p=2;let h=0;for(let m of d)h>0&&(p+=1),p+=i(m),h++}else{p=2;let h=0,m=Object.keys(d);for(let f=0;f<m.length;f++){let v=m[f],g=d[v];r(g)||(h>0&&(p+=1),p+=c(v)+3,p+=s(g),h++)}}return a.delete(d),p},a=new Set,o=0,c=typeof Buffer<"u"&&typeof Buffer.byteLength=="function"?u=>Buffer.byteLength(u,"utf8"):u=>u.length;return{size:s(e),maxStringLen:o}}catch{return{size:hn(e).length,maxStringLen:0}}}function hn(e,t,n,r,i){try{let s=JSON.stringify(e,jU(n),r);return al(s)}catch(s){if(!s.message?.includes("Converting circular structure to JSON"))return console.warn(`[WARNING]: LangSmith received unserializable value.${t?`
|
|
28
|
+
Context: ${t}`:""}`),al("[Unserializable]");gt("SUPPRESS_CIRCULAR_JSON_WARNINGS")!=="true"&&console.warn(`[WARNING]: LangSmith received circular JSON. This will decrease tracer performance. ${t?`
|
|
29
|
+
Context: ${t}`:""}`),typeof i>"u"&&(i=PU()),wg(e,"",0,[],void 0,0,i);let a;try{aa.length===0?a=JSON.stringify(e,n,r):a=JSON.stringify(e,MU(n),r)}catch{return al("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;_d.length!==0;){let o=_d.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return al(a)}}function lf(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:e}),_d.push([r,n,t,i])):aa.push([t,n,e]):(r[n]=e,_d.push([r,n,t]))}function wg(e,t,n,r,i,s,a){s+=1;var o;if(typeof e=="object"&&e!==null){for(o=0;o<r.length;o++)if(r[o]===e){lf(CU,e,t,i);return}if(typeof a.depthLimit<"u"&&s>a.depthLimit){lf(xk,e,t,i);return}if(typeof a.edgesLimit<"u"&&n+1>a.edgesLimit){lf(xk,e,t,i);return}if(r.push(e),Array.isArray(e))for(o=0;o<e.length;o++)wg(e[o],o,o,r,e,s,a);else{e=G1(e);var c=Object.keys(e);for(o=0;o<c.length;o++){var u=c[o];wg(e[u],u,o,r,e,s,a)}}r.pop()}}function MU(e){return e=typeof e<"u"?e:function(t,n){return n},function(t,n){if(aa.length>0)for(var r=0;r<aa.length;r++){var i=aa[r];if(i[1]===t&&i[0]===n){n=i[2],aa.splice(r,1);break}}return e.call(this,t,n)}}var kg=class{constructor(){Object.defineProperty(this,"worker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"pending",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"disabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startPromise",{enumerable:!0,configurable:!0,writable:!0,value:null})}async ensureStarted(){if(this.disabled)return!1;if(this.worker!==null)return!0;if(this.startPromise!==null)return this.startPromise;this.startPromise=this._start();try{return await this.startPromise}finally{this.startPromise=null}}async _start(){return this.disabled=!0,!1}async serialize(t){if(!await this.ensureStarted())return null;let n=this.nextId++;return new Promise((r,i)=>{this.pending.set(n,{resolve:r,reject:i});try{this.worker.postMessage({id:n,op:"serialize",payload:t})}catch(s){this.pending.delete(n),i(s)}})}async terminate(){this.worker&&(await this.worker.terminate(),this.worker=null);for(let[,t]of this.pending)t.reject(new Error("worker terminated"));this.pending.clear()}},df=null;function UU(){return df===null&&(df=new kg),df}var LU=64*1024,zU=2048;function DU(e,t=LU,n=zU){if(e===null||typeof e!="object")return typeof e=="string"&&e.length>=t;let r=[e],i=new Set,s=0;for(;r.length>0;){if(s++>=n)return!1;let a=r.pop();if(a==null)continue;let o=typeof a;if(o==="string"){if(a.length>=t)return!0;continue}if(o!=="object")continue;let c=a;if(i.has(c)||(i.add(c),c instanceof Date||c instanceof RegExp||c instanceof Error||c instanceof ArrayBuffer||ArrayBuffer.isView(c)))continue;if(Array.isArray(c)){for(let l=c.length-1;l>=0;l--)r.push(c[l]);continue}if(c instanceof Map){for(let[,l]of c)r.push(l);continue}if(c instanceof Set){for(let l of c)r.push(l);continue}let u=Object.keys(c);for(let l=u.length-1;l>=0;l--)r.push(c[u[l]])}return!1}function FU(e,t){let[n]=Jt(e);if(n!=="-"&&!t)throw new Error("Pulling a public prompt by owner/name is disabled by default because prompts may contain untrusted serialized LangChain objects. If you trust this prompt, set `dangerouslyPullPublicPrompt: true` to acknowledge the risk.")}function $k(e){return typeof e=="string"&&e.length>0&&!e.includes("Z")&&!e.includes("+")&&!e.includes("-",10)?e+"Z":e}function vo(e){return{...e,start_time:$k(e.start_time),end_time:$k(e.end_time)}}function Ik(e,t,n){if(n)return e;let r=q1(),i=t??J1(),s=e.extra??{},a=s.metadata;return e.extra={...s,runtime:{...r,...s?.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 ZU=e=>{let t=e?.toString()??gt("TRACING_SAMPLING_RATE");if(t===void 0)return;let n=parseFloat(t);if(n<0||n>1)throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${n}`);return n},BU=e=>{let t=e.replace("http://","").replace("https://","").split("/")[0].split(":")[0];return t==="localhost"||t==="127.0.0.1"||t==="::1"};async function qU(e){let t=[];for await(let n of e)t.push(n);return t}function ol(e){if(e!==void 0)return e.trim().replace(/^"(.*)"$/,"$1").replace(/^'(.*)'$/,"$1")}var JU=async e=>{if(e?.status===429){let t=parseInt(e.headers.get("retry-after")??"10",10)*1e3;if(t>0)return await new Promise(n=>setTimeout(n,t)),!0}return!1};function Sk(e){return typeof e=="number"?Number(e.toFixed(4)):e}var HU=24*1024*1024,X1=1024*1024*1024,VU=1e4,KU=100,xg=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??X1}peek(){return this.items[0]}push(t){let n,r=new Promise(s=>{n=s}),i=RU(t.item).size;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.`),n(),r):(this.items.push({action:t.action,payload:t.item,otelContext:t.otelContext,apiKey:t.apiKey,apiUrl:t.apiUrl,itemPromiseResolve:n,itemPromise:r,size:i}),this.sizeBytes+=i,r)}pop({upToSizeBytes:t,upToSize:n}){if(t<1)throw new Error("Number of bytes to pop off may not be less than 1.");let r=[],i=0;for(;i+(this.peek()?.size??0)<t&&this.items.length>0&&r.length<n;){let s=this.items.shift();s&&(r.push(s),i+=s.size,this.sizeBytes-=s.size)}if(r.length===0&&this.items.length>0){let s=this.items.shift();r.push(s),i+=s.size,this.sizeBytes-=s.size}return[r.map(s=>({action:s.action,item:s.payload,otelContext:s.otelContext,apiKey:s.apiKey,apiUrl:s.apiUrl,size:s.size})),()=>r.forEach(s=>s.itemPromiseResolve())]}},ka=class e{get tracingMode(){return this._tracingMode}get _fetch(){let t=this.fetchImplementation||cM(this.debug);return(async(n,r)=>{let i,s=this.getProfileManagedAuthorizationHeader(r);return this.apiKey!==void 0?i={name:"x-api-key",value:`${this.apiKey}`}:this.hasExplicitAuthHeader(r,s)||(i=await this.profileAuth?.getAuthHeader(t,r?.signal)),t(n,this.applyCurrentAuthHeaders(r,i,s))})}getProfileManagedAuthorizationHeader(t){if(!t?.headers||!this.profileAuth)return;let n=new Headers(t.headers).get("Authorization");if(Fn(n))return this.profileAuth.isProfileAuthorizationHeader(n??"")?n??void 0:void 0}isProfileManagedAuthorizationHeader(t,n){return t===n||this.profileAuth?.isProfileAuthorizationHeader(t)===!0}hasExplicitAuthHeader(t,n){if(!t?.headers)return!1;let r=new Headers(t.headers);if(Fn(r.get("x-api-key")))return!0;let i=r.get("Authorization");return Fn(i)?!this.isProfileManagedAuthorizationHeader(i??"",n):!1}applyCurrentAuthHeaders(t,n,r){if(!n)return t;let i=d=>{if(this.apiKey!==void 0&&n.name==="x-api-key")return d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",n.value),d;if(n.name==="Authorization"){if(Fn(d.get("x-api-key")))return d;let h=d.get("Authorization");return Fn(h)&&!this.isProfileManagedAuthorizationHeader(h??"",r)||d.set("Authorization",n.value),d}let p=d.get("Authorization");return Fn(p)&&!this.isProfileManagedAuthorizationHeader(p??"",r)||(Fn(p)&&d.delete("Authorization"),d.has("x-api-key")||d.set("x-api-key",n.value)),d};if(!t)return{headers:{[n.name]:n.value}};if(t.headers instanceof Headers)return{...t,headers:i(new Headers(t.headers))};if(Array.isArray(t.headers))return{...t,headers:i(new Headers(t.headers))};let s={...t.headers??{}},a=d=>Object.keys(s).find(p=>p.toLowerCase()===d),o=d=>{let p=a(d);return p?s[p]:void 0},c=Fn(o("x-api-key")),u=o("authorization"),l=Fn(u)&&!this.isProfileManagedAuthorizationHeader(u??"",r);if(this.apiKey!==void 0&&n.name==="x-api-key"){let d=a("authorization");return d&&delete s[d],c||(s["x-api-key"]=n.value),{...t,headers:s}}if(n.name==="Authorization"){if(!c&&!l){let d=a("authorization");d&&d!=="Authorization"&&delete s[d],s.Authorization=n.value}return{...t,headers:s}}if(!l){let d=a("authorization");d&&delete s[d],c||(s["x-api-key"]=n.value)}return{...t,headers:s}}_trackDrain(t){this._pendingDrains.add(t),t.finally(()=>{this._pendingDrains.delete(t)})}async _serializeBody(t,n){if(this.manualFlushMode||!DU(t)||(this._serializeWorker===void 0&&(this._serializeWorker=UU()),this._serializeWorker===null))return hn(t,n);try{let r=await this._serializeWorker.serialize(t);return r===null?(this._serializeWorker=null,hn(t,n)):r}catch{return hn(t,n)}}constructor(t={}){Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"webUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"workspaceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchIngestCaller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout_ms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tenantId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hideInputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideOutputs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"hideMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitTracedRuntimeInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tracingSampleRate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"filteredPostUuids",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"autoBatchTracing",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"autoBatchQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoBatchAggregationDelayMs",{enumerable:!0,configurable:!0,writable:!0,value:250}),Object.defineProperty(this,"batchSizeBytesLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"batchSizeLimit",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fetchOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockOnRootRunFinalization",{enumerable:!0,configurable:!0,writable:!0,value:wn("LANGSMITH_TRACING_BACKGROUND")==="false"}),Object.defineProperty(this,"traceBatchConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:5}),Object.defineProperty(this,"_serverInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_getServerInfoPromise",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manualFlushMode",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_serializeWorker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingDrains",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"langSmithToOTELTranslator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_tracingMode",{enumerable:!0,configurable:!0,writable:!0,value:"langsmith"}),Object.defineProperty(this,"fetchImplementation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cachedLSEnvVarsForMetadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_promptCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"profileAuth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"multipartStreamingDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_multipartDisabled",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_runCompressionDisabled",{enumerable:!0,configurable:!0,writable:!0,value: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,"_customHeaders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"debug",{enumerable:!0,configurable:!0,writable:!0,value:wn("LANGSMITH_DEBUG")==="true"});let n=e.getDefaultClientConfig();this.tracingSampleRate=ZU(t.tracingSamplingRate),this.apiUrl=ol(t.apiUrl??n.apiUrl)??"",this.apiUrl.endsWith("/")&&(this.apiUrl=this.apiUrl.slice(0,-1));let r=ol(t.apiKey??n.apiKey);if(this.apiKey=Fn(r)?r:void 0,this.profileAuth=this.apiKey!==void 0?void 0:n.profileAuth,this.webUrl=ol(t.webUrl??n.webUrl),this.webUrl?.endsWith("/")&&(this.webUrl=this.webUrl.slice(0,-1)),this.workspaceId=ol(t.workspaceId??n.workspaceId),this.timeout_ms=t.timeout_ms??9e4,this.caller=new vk({...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 i=gt("FAILED_TRACES_MAX_MB");if(i){let a=parseInt(i,10);Number.isFinite(a)&&a>0&&(this.failedTracesMaxBytes=a*1024*1024)}let s=t.maxIngestMemoryBytes??X1;this.batchIngestCaller=new vk({maxRetries:4,maxConcurrency:this.traceBatchConcurrency,maxQueueSizeBytes:s,...t.callerOptions??{},onFailedResponseHook:JU,debug:t.debug??this.debug}),this.hideInputs=t.hideInputs??t.anonymizer??n.hideInputs,this.hideOutputs=t.hideOutputs??t.anonymizer??n.hideOutputs,this.hideMetadata=t.hideMetadata??n.hideMetadata,this.omitTracedRuntimeInfo=t.omitTracedRuntimeInfo??!1,this.autoBatchTracing=t.autoBatchTracing??this.autoBatchTracing,this.autoBatchQueue=new xg(s),this.blockOnRootRunFinalization=t.blockOnRootRunFinalization??this.blockOnRootRunFinalization,this.batchSizeBytesLimit=t.batchSizeBytesLimit,this.batchSizeLimit=t.batchSizeLimit,this.fetchOptions=t.fetchOptions||{},this.manualFlushMode=t.manualFlushMode??this.manualFlushMode,this._tracingMode=H1(t.tracingMode),this._tracingMode==="otel"&&(this.langSmithToOTELTranslator=new fg),this.cachedLSEnvVarsForMetadata=J1(),t.cache!==void 0&&t.disablePromptCache&&Fl("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?(Fl("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=ak:this._promptCache=t.cache):t.disablePromptCache||(this._promptCache=ak),this._customHeaders=t.headers??{}}static getDefaultClientConfig(){let t=TU(),n=gt("API_KEY"),r=gt("ENDPOINT"),i=gt("WORKSPACE_ID"),s=Fn(n),a=r??t.apiUrl??vg,o=i??t.workspaceId,c=gt("HIDE_INPUTS")==="true",u=gt("HIDE_OUTPUTS")==="true",l=gt("HIDE_METADATA")==="true";return{apiUrl:a,apiKey:n,webUrl:void 0,hideInputs:c,hideOutputs:u,hideMetadata:l,workspaceId:o,oauthAccessToken:s?void 0:t.oauthAccessToken,oauthRefreshToken:s?void 0:t.oauthRefreshToken,profileAuth:s?void 0:t.profileAuth}}getHostUrl(){return this.webUrl?this.webUrl:BU(this.apiUrl)?(this.webUrl="http://localhost:3000",this.webUrl):this.apiUrl.endsWith("/api/v1")?(this.webUrl=this.apiUrl.replace("/api/v1",""),this.webUrl):this.apiUrl.includes("/api")&&!this.apiUrl.split(".",1)[0].endsWith("api")?(this.webUrl=this.apiUrl.replace("/api",""),this.webUrl):this.apiUrl.split(".",1)[0].includes("dev")?(this.webUrl="https://dev.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("eu")?(this.webUrl="https://eu.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("aws")?(this.webUrl="https://aws.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("apac")?(this.webUrl="https://apac.smith.langchain.com",this.webUrl):this.apiUrl.split(".",1)[0].includes("beta")?(this.webUrl="https://beta.smith.langchain.com",this.webUrl):(this.webUrl="https://smith.langchain.com",this.webUrl)}get _mergedHeaders(){let t={"User-Agent":`langsmith-js/${Z1}`,...this._customHeaders};if(this.apiKey!==void 0)t["x-api-key"]=`${this.apiKey}`;else{let n=this.profileAuth?.currentAuthHeader();n&&(t[n.name]=n.value)}return this.workspaceId&&(t["x-tenant-id"]=this.workspaceId),t}get headers(){return this._customHeaders}set headers(t){this._customHeaders=t??{}}_getPlatformEndpointPath(t){return this.apiUrl.slice(-3)!=="/v1"&&this.apiUrl.slice(-4)!=="/v1/"?`/v1/platform/${t}`:`/platform/${t}`}async processInputs(t){return this.hideInputs===!1?t:this.hideInputs===!0?{}:typeof this.hideInputs=="function"?this.hideInputs(t):t}async processOutputs(t){return this.hideOutputs===!1?t:this.hideOutputs===!0?{}:typeof this.hideOutputs=="function"?this.hideOutputs(t):t}async processMetadata(t){return this.hideMetadata===!1?t:this.hideMetadata===!0?{}:typeof this.hideMetadata=="function"?this.hideMetadata(t):t}_filterNewTokenEvents(t){return!t||t.length===0?t:t.map(n=>{if(n.name==="new_token"){let{kwargs:r,...i}=n;return i}return n})}async prepareRunCreateOrUpdateInputs(t){let n={...t};return n.inputs!==void 0&&(n.inputs=await this.processInputs(n.inputs)),n.outputs!==void 0&&(n.outputs=await this.processOutputs(n.outputs)),n.extra!=null&&"metadata"in n.extra&&(n.extra={...n.extra,metadata:await this.processMetadata(n.extra.metadata)}),n.events!==void 0&&(n.events=this._filterNewTokenEvents(n.events)),n}async _getResponse(t,n){let r=n?.toString()??"",i=`${this.apiUrl}${t}?${r}`;return await this.caller.call(async()=>{let s=await this._fetch(i,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(s,`fetch ${t}`),s})}async _get(t,n){return(await this._getResponse(t,n)).json()}async*_getPaginated(t,n=new URLSearchParams,r){let i=Number(n.get("offset"))||0,s=Number(n.get("limit"))||100;for(;;){n.set("offset",String(i)),n.set("limit",String(s));let a=`${this.apiUrl}${t}?${n}`,o=await this.caller.call(async()=>{let u=await this._fetch(a,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(u,`fetch ${t}`),u}),c=r?r(await o.json()):await o.json();if(c.length===0||(yield c,c.length<s))break;i+=c.length}}async*_getCursorPaginatedList(t,n=null,r="POST",i="runs"){let s=n?{...n}:{};for(;;){let a=JSON.stringify(s),o=await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}${t}`,{method:r,headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(u,`fetch ${t}`),u})).json();if(!o||!o[i])break;yield o[i];let c=o.cursors;if(!c||!c.next)break;s.cursor=c.next}}_shouldSample(){return this.tracingSampleRate===void 0?!0:Math.random()<this.tracingSampleRate}_filterForSampling(t,n=!1){if(this.tracingSampleRate===void 0)return t;if(n){let r=[];for(let i of t)this.filteredPostUuids.has(i.trace_id)?i.id===i.trace_id&&this.filteredPostUuids.delete(i.trace_id):r.push(i);return r}else{let r=[];for(let i of t){let s=i.trace_id??i.id;this.filteredPostUuids.has(s)||(i.id===s?this._shouldSample()?r.push(i):this.filteredPostUuids.add(s):r.push(i))}return r}}async _getBatchSizeLimitBytes(){let t=await this._ensureServerInfo();return this.batchSizeBytesLimit??t?.batch_ingest_config?.size_limit_bytes??HU}async _getBatchSizeLimit(){let t=await this._ensureServerInfo();return this.batchSizeLimit??t?.batch_ingest_config?.size_limit??KU}async _getDatasetExamplesMultiPartSupport(){return(await this._ensureServerInfo()).instance_flags?.dataset_examples_multipart_enabled??!1}drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:n}){let r=[];for(;this.autoBatchQueue.items.length>0;){let[i,s]=this.autoBatchQueue.pop({upToSizeBytes:t,upToSize:n});if(!i.length){s();break}let a=i.reduce((u,l)=>{let d=l.apiUrl??this.apiUrl,p=l.apiKey??this.apiKey,h=l.apiKey===this.apiKey&&l.apiUrl===this.apiUrl?"default":`${d}|${p}`;return u[h]||(u[h]=[]),u[h].push(l),u},{}),o=[];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]});o.push(d)}let c=Promise.all(o).finally(s);r.push(c)}return Promise.all(r)}static async _writeTraceToFallbackDir(t,n,r,i,s){try{let a=typeof n=="string"?Buffer.from(n,"utf8"):Buffer.from(n),o=JSON.stringify({version:1,endpoint:i,headers:r,body_base64:a.toString("base64")}),c=`trace_${Date.now()}_${yo().slice(0,8)}.json`,u=yd.join(t,c);if(e._fallbackDirsCreated.has(t)||(await MM(t),e._fallbackDirsCreated.add(t)),s!==void 0&&s>0)try{let l=(await UM(t)).filter(p=>p.startsWith("trace_")&&p.endsWith(".json")),d=0;for(let p of l){let{size:h}=await LM(yd.join(t,p));d+=h}if(d>=s){console.warn(`Could not write trace to fallback dir ${t} as it's already over size limit (${d} bytes >= ${s} bytes). Increase LANGSMITH_FAILED_TRACES_MAX_MB if possible.`);return}}catch{}await F1(u,o),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,n){if(!t.length)return;let r=t.reduce((i,s)=>i+(s.size??0),0);try{if(this.langSmithToOTELTranslator!==void 0)this._sendBatchToOTELTranslator(t);else{let i={runCreates:t.filter(a=>a.action==="create").map(a=>a.item),runUpdates:t.filter(a=>a.action==="update").map(a=>a.item)},s=await this._ensureServerInfo();if(!this._multipartDisabled&&(s?.batch_ingest_config?.use_multipart_endpoint??!0)){let a=!this._runCompressionDisabled&&s?.instance_flags?.gzip_body_enabled;try{await this.multipartIngestRuns(i,{...n,useGzip:a,sizeBytes:r})}catch(o){if(uf(o))this._multipartDisabled=!0,await this.batchIngestRuns(i,{...n,sizeBytes:r});else throw o}}else await this.batchIngestRuns(i,{...n,sizeBytes:r})}}catch(i){console.error("Error exporting batch:",i)}}_sendBatchToOTELTranslator(t){if(this.langSmithToOTELTranslator!==void 0){let n=new Map,r=[];for(let i of t)i.item.id&&i.otelContext&&(n.set(i.item.id,i.otelContext),i.action==="create"?r.push({operation:"post",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}):r.push({operation:"patch",id:i.item.id,trace_id:i.item.trace_id??i.item.id,run:i.item}));this.langSmithToOTELTranslator.exportBatch(r,n)}}async processRunOperation(t){clearTimeout(this.autoBatchTimeout),this.autoBatchTimeout=void 0,t.item=Ik(t.item,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);let n=this.autoBatchQueue.push(t);if(this.manualFlushMode)return n;let r=await this._getBatchSizeLimitBytes(),i=await this._getBatchSizeLimit();return(this.autoBatchQueue.sizeBytes>r||this.autoBatchQueue.items.length>i)&&this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:i})),this.autoBatchQueue.items.length>0&&(this.autoBatchTimeout=setTimeout(()=>{this.autoBatchTimeout=void 0,this._trackDrain(this.drainAutoBatchQueue({batchSizeLimitBytes:r,batchSizeLimit:i}))},this.autoBatchAggregationDelayMs)),n}async _getServerInfo(){let t=await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/info`,{method:"GET",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(VU),...this.fetchOptions});return await te(n,"get server info"),n})).json();return this.debug&&console.log(`
|
|
30
|
+
=== LangSmith Server Configuration ===
|
|
31
|
+
`+JSON.stringify(t,null,2)+`
|
|
32
|
+
`),t}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(),n=await this._getBatchSizeLimit();await this.drainAutoBatchQueue({batchSizeLimitBytes:t,batchSizeLimit:n})}_cloneCurrentOTELContext(){let t=V1(),n=KM();if(this.langSmithToOTELTranslator!==void 0){let r=t.getActiveSpan();if(r)return t.setSpan(n.active(),r)}}async createRun(t,n){if(!this._filterForSampling([t]).length)return;let r={...this._mergedHeaders,"Content-Type":"application/json"},i=t.project_name;delete t.project_name;let s=await this.prepareRunCreateOrUpdateInputs({session_name:i,...t,start_time:t.start_time??Date.now()});if(this.autoBatchTracing&&s.trace_id!==void 0&&s.dotted_order!==void 0){let c=this._cloneCurrentOTELContext();this.processRunOperation({action:"create",item:s,otelContext:c,apiKey:n?.apiKey,apiUrl:n?.apiUrl}).catch(console.error);return}let a=Ik(s,this.cachedLSEnvVarsForMetadata,this.omitTracedRuntimeInfo);n?.apiKey!==void 0&&(r["x-api-key"]=n.apiKey),n?.workspaceId!==void 0&&(r["x-tenant-id"]=n.workspaceId);let o=hn(a,`Creating run with id: ${a.id}`);await this.caller.call(async()=>{let c=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await te(c,"create run",!0),c})}async batchIngestRuns({runCreates:t,runUpdates:n},r){if(t===void 0&&n===void 0)return;let i=await Promise.all(t?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]),s=await Promise.all(n?.map(c=>this.prepareRunCreateOrUpdateInputs(c))??[]);if(i.length>0&&s.length>0){let c=i.reduce((l,d)=>(d.id&&(l[d.id]=d),l),{}),u=[];for(let l of s)l.id!==void 0&&c[l.id]?c[l.id]={...c[l.id],...l}:u.push(l);i=Object.values(c),s=u}let a={post:i,patch:s};if(!a.post.length&&!a.patch.length)return;let o={post:[],patch:[]};for(let c of["post","patch"]){let u=c,l=a[u].reverse(),d=l.pop();for(;d!==void 0;)o[u].push(d),d=l.pop()}if(o.post.length>0||o.patch.length>0){let c=o.post.map(u=>u.id).concat(o.patch.map(u=>u.id)).join(",");await this._postBatchIngestRuns(await this._serializeBody(o,`Ingesting runs with ids: ${c}`),r)}}async _postBatchIngestRuns(t,n){let r={...this._mergedHeaders,"Content-Type":"application/json",Accept:"application/json"};n?.apiKey!==void 0&&(r["x-api-key"]=n.apiKey),await this.batchIngestCaller.callWithOptions({sizeBytes:n?.sizeBytes},async()=>{let i=await this._fetch(`${n?.apiUrl??this.apiUrl}/runs/batch`,{method:"POST",headers:r,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:t});return await te(i,"batch create run",!0),i})}async multipartIngestRuns({runCreates:t,runUpdates:n},r){if(t===void 0&&n===void 0)return;let i={},s=[];for(let u of t??[]){let l=await this.prepareRunCreateOrUpdateInputs(u);l.id!==void 0&&l.attachments!==void 0&&(i[l.id]=l.attachments),delete l.attachments,s.push(l)}let a=[];for(let u of n??[])a.push(await this.prepareRunCreateOrUpdateInputs(u));if(s.find(u=>u.trace_id===void 0||u.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(u=>u.trace_id===void 0||u.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(s.length>0&&a.length>0){let u=s.reduce((d,p)=>(p.id&&(d[p.id]=p),d),{}),l=[];for(let d of a)d.id!==void 0&&u[d.id]?u[d.id]={...u[d.id],...d}:l.push(d);s=Object.values(u),a=l}if(s.length===0&&a.length===0)return;let o=[],c=[];for(let[u,l]of[["post",s],["patch",a]])for(let d of l){let{inputs:p,outputs:h,events:m,extra:f,error:v,serialized:g,attachments:y,...w}=d,x={inputs:p,outputs:h,events:m,extra:f,error:v,serialized:g},O=await this._serializeBody(w,`Serializing for multipart ingestion of run with id: ${w.id}`);c.push({name:`${u}.${w.id}`,payload:new Blob([O],{type:`application/json; length=${O.length}`})});for(let[z,T]of Object.entries(x)){if(T===void 0)continue;let k=await this._serializeBody(T,`Serializing ${z} for multipart ingestion of run with id: ${w.id}`);c.push({name:`${u}.${w.id}.${z}`,payload:new Blob([k],{type:`application/json; length=${k.length}`})})}if(w.id!==void 0){let z=i[w.id];if(z){delete i[w.id];for(let[T,k]of Object.entries(z)){let B,C;if(Array.isArray(k)?[B,C]=k:(B=k.mimeType,C=k.data),T.includes(".")){console.warn(`Skipping attachment '${T}' for run ${w.id}: Invalid attachment name. Attachment names must not contain periods ('.'). Please rename the attachment and try again.`);continue}c.push({name:`attachment.${w.id}.${T}`,payload:new Blob([C],{type:`${B}; length=${C.byteLength}`})})}}}o.push(`trace=${w.trace_id},id=${w.id}`)}await this._sendMultipartRequest(c,o.join("; "),r)}async _createNodeFetchBody(t,n){let r=[];for(let i of t)r.push(new Blob([`--${n}\r
|
|
33
|
+
`])),r.push(new Blob([`Content-Disposition: form-data; name="${i.name}"\r
|
|
34
|
+
`,`Content-Type: ${i.payload.type}\r
|
|
35
|
+
\r
|
|
36
|
+
`])),r.push(i.payload),r.push(new Blob([`\r
|
|
37
|
+
`]));return r.push(new Blob([`--${n}--\r
|
|
38
|
+
`])),await new Blob(r).arrayBuffer()}async _createMultipartStream(t,n){let r=new TextEncoder;return new ReadableStream({async start(i){let s=async a=>{typeof a=="string"?i.enqueue(r.encode(a)):i.enqueue(a)};for(let a of t){await s(`--${n}\r
|
|
39
|
+
`),await s(`Content-Disposition: form-data; name="${a.name}"\r
|
|
40
|
+
`),await s(`Content-Type: ${a.payload.type}\r
|
|
41
|
+
\r
|
|
42
|
+
`);let o=a.payload.stream().getReader();try{let c;for(;!(c=await o.read()).done;)i.enqueue(c.value)}finally{o.releaseLock()}await s(`\r
|
|
43
|
+
`)}await s(`--${n}--\r
|
|
44
|
+
`),i.close()}})}async _sendMultipartRequest(t,n,r){let i="----LangSmithFormBoundary"+Math.random().toString(36).slice(2),s=()=>this._createNodeFetchBody(t,i),a=()=>this._createMultipartStream(t,i),o=async c=>this.batchIngestCaller.callWithOptions({sizeBytes:r?.sizeBytes},async()=>{let u=await c(),l={...this._mergedHeaders,"Content-Type":`multipart/form-data; boundary=${i}`};r?.apiKey!==void 0&&(l["x-api-key"]=r.apiKey);let d=u;r?.useGzip&&typeof u=="object"&&"pipeThrough"in u&&(d=u.pipeThrough(new CompressionStream("gzip")),l["Content-Encoding"]="gzip");let p=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/multipart`,{method:"POST",headers:l,body:d,duplex:"half",signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(p,"Failed to send multipart request",!0),p});try{let c,u=!1;oM()&&!this.multipartStreamingDisabled&&R_()!=="bun"?(u=!0,c=await o(a)):c=await o(s),(!this.multipartStreamingDisabled||u)&&c.status===422&&(r?.apiUrl??this.apiUrl)!==vg&&(console.warn(`Streaming multipart upload to ${r?.apiUrl??this.apiUrl}/runs/multipart failed. This usually means the host does not support chunked uploads. Retrying with a buffered upload for operation "${n}".`),this.multipartStreamingDisabled=!0,c=await o(s))}catch(c){if(uf(c))throw c;if(console.warn(`${c.message.trim()}
|
|
45
|
+
|
|
46
|
+
Context: ${n}`),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,n,r){_e(t),n.inputs&&(n.inputs=await this.processInputs(n.inputs)),n.outputs&&(n.outputs=await this.processOutputs(n.outputs)),n.extra!=null&&"metadata"in n.extra&&(n.extra={...n.extra,metadata:await this.processMetadata(n.extra.metadata)}),n.events&&(n.events=this._filterNewTokenEvents(n.events));let i={...n,id:t};if(!this._filterForSampling([i],!0).length)return;if(this.autoBatchTracing&&i.trace_id!==void 0&&i.dotted_order!==void 0){let o=this._cloneCurrentOTELContext();if(n.end_time!==void 0&&i.parent_run_id===void 0&&this.blockOnRootRunFinalization&&!this.manualFlushMode){await this.processRunOperation({action:"update",item:i,otelContext:o,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}else this.processRunOperation({action:"update",item:i,otelContext:o,apiKey:r?.apiKey,apiUrl:r?.apiUrl}).catch(console.error);return}let s={...this._mergedHeaders,"Content-Type":"application/json"};r?.apiKey!==void 0&&(s["x-api-key"]=r.apiKey),r?.workspaceId!==void 0&&(s["x-tenant-id"]=r.workspaceId);let a=hn(n,`Serializing payload to update run with id: ${t}`);await this.caller.call(async()=>{let o=await this._fetch(`${r?.apiUrl??this.apiUrl}/runs/${t}`,{method:"PATCH",headers:s,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(o,"update run",!0),o})}async readRun(t,{loadChildRuns:n}={loadChildRuns:!1}){_e(t);let r=vo(await this._get(`/runs/${t}`));return n&&(r=await this._loadChildRuns(r)),r}async getRunUrl({runId:t,run:n,projectOpts:r}){if(n!==void 0){let i;n.session_id?i=n.session_id:r?.projectName?i=(await this.readProject({projectName:r?.projectName})).id:r?.projectId?i=r?.projectId:i=(await this.readProject({projectName:gt("PROJECT")||"default"})).id;let s=await this._getTenantId();return`${this.getHostUrl()}/o/${s}/projects/p/${i}/r/${n.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 n=await qU(this.listRuns({isRoot:!1,projectId:t.session_id,traceId:t.trace_id})),r={},i={};n.sort((s,a)=>(s?.dotted_order??"").localeCompare(a?.dotted_order??""));for(let s of n){if(s.parent_run_id===null||s.parent_run_id===void 0)throw new Error(`Child run ${s.id} has no parent`);s.dotted_order?.startsWith(t.dotted_order??"")&&s.id!==t.id&&(s.parent_run_id in r||(r[s.parent_run_id]=[]),r[s.parent_run_id].push(s),i[s.id]=s)}t.child_runs=r[t.id]||[];for(let s in r)s!==t.id&&(i[s].child_runs=r[s]);return t}async*listRuns(t){let{projectId:n,projectName:r,parentRunId:i,traceId:s,referenceExampleId:a,startTime:o,executionOrder:c,isRoot:u,runType:l,error:d,id:p,query:h,filter:m,traceFilter:f,treeFilter:v,limit:g,select:y,order:w}=t,x=[];if(n&&(x=Array.isArray(n)?n:[n]),r){let k=Array.isArray(r)?r:[r],B=await Promise.all(k.map(C=>this.readProject({projectName:C}).then(E=>E.id)));x.push(...B)}let O=["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"],z={session:x.length?x:null,run_type:l,reference_example:a,query:h,filter:m,trace_filter:f,tree_filter:v,execution_order:c,parent_run:i,start_time:o?o.toISOString():null,error:d,id:p,limit:g,trace:s,select:y||O,is_root:u,order:w};z.select.includes("child_run_ids")&&Fl("Deprecated: 'child_run_ids' in the listRuns select parameter is deprecated and will be removed in a future version.");let T=0;for await(let k of this._getCursorPaginatedList("/runs/query",z)){let B=k.map(vo);if(g){if(T>=g)break;if(B.length+T>g){yield*B.slice(0,g-T);break}T+=B.length,yield*B}else yield*B}}async*listGroupRuns(t){let{projectId:n,projectName:r,groupBy:i,filter:s,startTime:a,endTime:o,limit:c,offset:u}=t,l={session_id:n||(await this.readProject({projectName:r})).id,group_by:i,filter:s,start_time:a?a.toISOString():null,end_time:o?o.toISOString():null,limit:Number(c)||100},d=Number(u)||0,p="/runs/group",h=`${this.apiUrl}${p}`;for(;;){let m={...l,offset:d},f=Object.fromEntries(Object.entries(m).filter(([x,O])=>O!==void 0)),v=JSON.stringify(f),g=await(await this.caller.call(async()=>{let x=await this._fetch(h,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:v});return await te(x,`Failed to fetch ${p}`),x})).json(),{groups:y,total:w}=g;if(y.length===0)break;for(let x of y)yield x;if(d+=y.length,d>=w)break}}async*readThread(t){let{threadId:n,projectId:r,projectName:i,isRoot:s=!0,limit:a,filter:o,order:c="asc"}=t;if(!r&&!i)throw new Error("threadId requires projectId or projectName");let u=`eq(thread_id, ${JSON.stringify(n)})`,l=o?`and(${u}, ${o})`:u;yield*this.listRuns({projectId:r??void 0,projectName:i??void 0,isRoot:s,limit:a,filter:l,order:c})}async listThreads(t){let{projectId:n,projectName:r,limit:i,offset:s=0,filter:a,startTime:o,isRoot:c=!0}=t;if(!n&&!r)throw new Error("Either projectId or projectName must be provided");if(n&&r)throw new Error("Provide exactly one of projectId or projectName");let u=n??(await this.readProject({projectName:r})).id,l=o??new Date(Date.now()-1440*60*1e3),d={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&&(d.filter=a);let p=new Map;for await(let f of this._getCursorPaginatedList("/runs/query",d))for(let v of f){let g=vo(v),y=g.thread_id;if(y){let w=p.get(y)??[];w.push(g),p.set(y,w)}}let h=[];for(let[f,v]of p.entries()){v.sort((x,O)=>{let z=x,T=O,k=z.start_time??"",B=T.start_time??"";if(k!==B)return k.localeCompare(B);let C=z.dotted_order??"",E=T.dotted_order??"";return C.localeCompare(E)});let g=[...v.map(x=>x.start_time).filter(Boolean)].sort(),y=g.length?g[0]:"",w=g.length?g[g.length-1]:"";h.push({thread_id:f,runs:v,count:v.length,filter:"",total_tokens:0,total_cost:null,min_start_time:y,max_start_time:w,latency_p50:0,latency_p99:0,feedback_stats:null,first_inputs:"",last_outputs:"",last_error:null})}h.sort((f,v)=>{let g=f.max_start_time??"";return(v.max_start_time??"").localeCompare(g)});let m=s>0?h.slice(s):h;return i!==void 0?m.slice(0,i):m}async getRunStats({id:t,trace:n,parentRun:r,runType:i,projectNames:s,projectIds:a,referenceExampleIds:o,startTime:c,endTime:u,error:l,query:d,filter:p,traceFilter:h,treeFilter:m,isRoot:f,dataSourceType:v}){let g=a||[];s&&(g=[...a||[],...await Promise.all(s.map(x=>this.readProject({projectName:x}).then(O=>O.id)))]);let y=Object.fromEntries(Object.entries({id:t,trace:n,parent_run:r,run_type:i,session:g,reference_example:o,start_time:c,end_time:u,error:l,query:d,filter:p,trace_filter:h,tree_filter:m,is_root:f,data_source_type:v}).filter(([x,O])=>O!==void 0)),w=JSON.stringify(y);return await(await this.caller.call(async()=>{let x=await this._fetch(`${this.apiUrl}/runs/stats`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:w});return await te(x,"get run stats"),x})).json()}async shareRun(t,{shareId:n}={}){let r={run_id:t,share_token:n||yo()};_e(t);let i=JSON.stringify(r),s=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await te(a,"share run"),a})).json();if(s===null||!("share_token"in s))throw new Error("Invalid response from server");return`${this.getHostUrl()}/public/${s.share_token}/r`}async unshareRun(t){_e(t),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"unshare run",!0),n})}async readRunSharedLink(t){_e(t);let n=await(await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/runs/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,"read run shared link"),r})).json();if(!(n===null||!("share_token"in n)))return`${this.getHostUrl()}/public/${n.share_token}/r`}async listSharedRuns(t,{runIds:n}={}){let r=new URLSearchParams({share_token:t});if(n!==void 0)for(let i of n)r.append("id",i);return _e(t),(await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/public/${t}/runs${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,"list shared runs"),i})).json()).map(vo)}async readDatasetSharedSchema(t,n){if(!t&&!n)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:n})).id),_e(t);let r=await(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,"read dataset shared schema"),i})).json();return r.url=`${this.getHostUrl()}/public/${r.share_token}/d`,r}async shareDataset(t,n){if(!t&&!n)throw new Error("Either datasetId or datasetName must be given");t||(t=(await this.readDataset({datasetName:n})).id);let r={dataset_id:t};_e(t);let i=JSON.stringify(r),s=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"PUT",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:i});return await te(a,"share dataset"),a})).json();return s.url=`${this.getHostUrl()}/public/${s.share_token}/d`,s}async unshareDataset(t){_e(t),await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/datasets/${t}/share`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"unshare dataset",!0),n})}async readSharedDataset(t){return _e(t),await(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/public/${t}/datasets`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"read shared dataset"),n})).json()}async listSharedExamples(t,n){let r={};n?.exampleIds&&(r.id=n.exampleIds);let i=new URLSearchParams;Object.entries(r).forEach(([o,c])=>{Array.isArray(c)?c.forEach(u=>i.append(o,u)):i.append(o,c)});let s=await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/public/${t}/examples?${i.toString()}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(o,"list shared examples"),o}),a=await s.json();if(!s.ok)throw"detail"in a?new Error(`Failed to list shared examples.
|
|
47
|
+
Status: ${s.status}
|
|
48
|
+
Message: ${Array.isArray(a.detail)?a.detail.join(`
|
|
49
|
+
`):"Unspecified error"}`):new Error(`Failed to list shared examples: ${s.status} ${s.statusText}`);return a.map(o=>({...o,_hostUrl:this.getHostUrl()}))}async createProject({projectName:t,description:n=null,metadata:r=null,upsert:i=!1,projectExtra:s=null,referenceDatasetId:a=null}){let o=i?"?upsert=true":"",c=`${this.apiUrl}/sessions${o}`,u=s||{};r&&(u.metadata=r);let l={name:t,extra:u,description:n};a!==null&&(l.reference_dataset_id=a);let d=JSON.stringify(l);return await(await this.caller.call(async()=>{let p=await this._fetch(c,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:d});return await te(p,"create project"),p})).json()}async updateProject(t,{name:n=null,description:r=null,metadata:i=null,projectExtra:s=null,endTime:a=null}){let o=`${this.apiUrl}/sessions/${t}`,c=s;i&&(c={...c||{},metadata:i});let u=JSON.stringify({name:n,extra:c,description:r,end_time:a?new Date(a).toISOString():null});return await(await this.caller.call(async()=>{let l=await this._fetch(o,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await te(l,"update project"),l})).json()}async hasProject({projectId:t,projectName:n}){let r="/sessions",i=new URLSearchParams;if(t!==void 0&&n!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)_e(t),r+=`/${t}`;else if(n!==void 0)i.append("name",n);else throw new Error("Must provide projectName or projectId");let s=await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}${r}?${i}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(a,"has project"),a});try{let a=await s.json();return s.ok?Array.isArray(a)?a.length>0:!0:!1}catch{return!1}}async readProject({projectId:t,projectName:n,includeStats:r}){let i="/sessions",s=new URLSearchParams;if(t!==void 0&&n!==void 0)throw new Error("Must provide either projectName or projectId, not both");if(t!==void 0)_e(t),i+=`/${t}`;else if(n!==void 0)s.append("name",n);else throw new Error("Must provide projectName or projectId");r!==void 0&&s.append("include_stats",r.toString());let a=await this._get(i,s),o;if(Array.isArray(a)){if(a.length===0)throw new Error(`Project[id=${t}, name=${n}] not found`);o=a[0]}else o=a;return o}async getProjectUrl({projectId:t,projectName:n}){if(t===void 0&&n===void 0)throw new Error("Must provide either projectName or projectId");let r=await this.readProject({projectId:t,projectName:n}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/projects/p/${r.id}`}async getDatasetUrl({datasetId:t,datasetName:n}){if(t===void 0&&n===void 0)throw new Error("Must provide either datasetName or datasetId");let r=await this.readDataset({datasetId:t,datasetName:n}),i=await this._getTenantId();return`${this.getHostUrl()}/o/${i}/datasets/${r.id}`}async _getTenantId(){if(this._tenantId!==null)return this._tenantId;let t=new URLSearchParams({limit:"1"});for await(let n of this._getPaginated("/sessions",t))return this._tenantId=n[0].tenant_id,n[0].tenant_id;throw new Error("No projects found to resolve tenant.")}async*listProjects({projectIds:t,name:n,nameContains:r,referenceDatasetId:i,referenceDatasetName:s,includeStats:a,datasetVersion:o,referenceFree:c,metadata:u}={}){let l=new URLSearchParams;if(t!==void 0)for(let d of t)l.append("id",d);if(n!==void 0&&l.append("name",n),r!==void 0&&l.append("name_contains",r),i!==void 0)l.append("reference_dataset",i);else if(s!==void 0){let d=await this.readDataset({datasetName:s});l.append("reference_dataset",d.id)}a!==void 0&&l.append("include_stats",a.toString()),o!==void 0&&l.append("dataset_version",o),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:n}){let r;if(t===void 0&&n===void 0)throw new Error("Must provide projectName or projectId");if(t!==void 0&&n!==void 0)throw new Error("Must provide either projectName or projectId, not both");t===void 0?r=(await this.readProject({projectName:n})).id:r=t,_e(r),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/sessions/${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,`delete session ${r} (${n})`,!0),i})}async uploadCsv({csvFile:t,fileName:n,inputKeys:r,outputKeys:i,description:s,dataType:a,name:o}){let c=`${this.apiUrl}/datasets/upload`,u=new FormData,l=new Blob([t],{type:"text/csv"});return u.append("file",l,n),r.forEach(d=>{u.append("input_keys",d)}),i.forEach(d=>{u.append("output_keys",d)}),s&&u.append("description",s),a&&u.append("data_type",a),o&&u.append("name",o),await(await this.caller.call(async()=>{let d=await this._fetch(c,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await te(d,"upload CSV"),d})).json()}async createDataset(t,{description:n,dataType:r,inputsSchema:i,outputsSchema:s,metadata:a}={}){let o={name:t,description:n,extra:{source:"sdk",...a?{metadata:a}:{}}};r&&(o.data_type=r),i&&(o.inputs_schema_definition=i),s&&(o.outputs_schema_definition=s);let c=JSON.stringify(o);return await(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await te(u,"create dataset"),u})).json()}async readDataset({datasetId:t,datasetName:n}){let r="/datasets",i=new URLSearchParams({limit:"1"});if(t&&n)throw new Error("Must provide either datasetName or datasetId, not both");if(t)_e(t),r+=`/${t}`;else if(n)i.append("name",n);else throw new Error("Must provide datasetName or datasetId");let s=await this._get(r,i),a;if(Array.isArray(s)){if(s.length===0)throw new Error(`Dataset[id=${t}, name=${n}] not found`);a=s[0]}else a=s;return a}async hasDataset({datasetId:t,datasetName:n}){try{return await this.readDataset({datasetId:t,datasetName:n}),!0}catch(r){if(r instanceof Error&&r.message.toLocaleLowerCase().includes("not found"))return!1;throw r}}async diffDatasetVersions({datasetId:t,datasetName:n,fromVersion:r,toVersion:i}){let s=t;if(s===void 0&&n===void 0)throw new Error("Must provide either datasetName or datasetId");if(s!==void 0&&n!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");s===void 0&&(s=(await this.readDataset({datasetName:n})).id);let a=new URLSearchParams({from_version:typeof r=="string"?r:r.toISOString(),to_version:typeof i=="string"?i:i.toISOString()});return await this._get(`/datasets/${s}/versions/diff`,a)}async readDatasetOpenaiFinetuning({datasetId:t,datasetName:n}){let r="/datasets";if(t===void 0)if(n!==void 0)t=(await this.readDataset({datasetName:n})).id;else throw new Error("Must provide either datasetName or datasetId");return(await(await this._getResponse(`${r}/${t}/openai_ft`)).text()).trim().split(`
|
|
50
|
+
`).map(i=>JSON.parse(i))}async*listDatasets({limit:t=100,offset:n=0,datasetIds:r,datasetName:i,datasetNameContains:s,metadata:a}={}){let o="/datasets",c=new URLSearchParams({limit:t.toString(),offset:n.toString()});if(r!==void 0)for(let u of r)c.append("id",u);i!==void 0&&c.append("name",i),s!==void 0&&c.append("name_contains",s),a!==void 0&&c.append("metadata",JSON.stringify(a));for await(let u of this._getPaginated(o,c))yield*u}async updateDataset(t){let{datasetId:n,datasetName:r,...i}=t;if(!n&&!r)throw new Error("Must provide either datasetName or datasetId");let s=n??(await this.readDataset({datasetName:r})).id;_e(s);let a=JSON.stringify(i);return await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/datasets/${s}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(o,"update dataset"),o})).json()}async updateDatasetTag(t){let{datasetId:n,datasetName:r,asOf:i,tag:s}=t;if(!n&&!r)throw new Error("Must provide either datasetName or datasetId");let a=n??(await this.readDataset({datasetName:r})).id;_e(a);let o=JSON.stringify({as_of:typeof i=="string"?i:i.toISOString(),tag:s});await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/datasets/${a}/tags`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await te(c,"update dataset tags",!0),c})}async deleteDataset({datasetId:t,datasetName:n}){let r="/datasets",i=t;if(t!==void 0&&n!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(n!==void 0&&(i=(await this.readDataset({datasetName:n})).id),i!==void 0)_e(i),r+=`/${i}`;else throw new Error("Must provide datasetName or datasetId");await this.caller.call(async()=>{let s=await this._fetch(this.apiUrl+r,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(s,`delete ${r}`,!0),s})}async createExample(t,n,r){if(Ok(t)&&(n!==void 0||r!==void 0))throw new Error("Cannot provide outputs or options when using ExampleCreate object");let i=n?r?.datasetId:t.dataset_id,s=n?r?.datasetName:t.dataset_name;if(i===void 0&&s===void 0)throw new Error("Must provide either datasetName or datasetId");if(i!==void 0&&s!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");i===void 0&&(i=(await this.readDataset({datasetName:s})).id);let a=(n?r?.createdAt:t.created_at)||new Date,o;Ok(t)?o=t:o={inputs:t,outputs:n,created_at:a?.toISOString(),id:r?.exampleId,metadata:r?.metadata,split:r?.split,source_run_id:r?.sourceRunId,use_source_run_io:r?.useSourceRunIO,use_source_run_attachments:r?.useSourceRunAttachments,attachments:r?.attachments};let c=await this._uploadExamplesMultipart(i,[o]);return await this.readExample(c.example_ids?.[0]??yo())}async createExamples(t){if(Array.isArray(t)){if(t.length===0)return[];let g=t,y=g[0].dataset_id,w=g[0].dataset_name;if(y===void 0&&w===void 0)throw new Error("Must provide either datasetName or datasetId");if(y!==void 0&&w!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");y===void 0&&(y=(await this.readDataset({datasetName:w})).id);let x=await this._uploadExamplesMultipart(y,g);return await Promise.all(x.example_ids.map(O=>this.readExample(O)))}let{inputs:n,outputs:r,metadata:i,splits:s,sourceRunIds:a,useSourceRunIOs:o,useSourceRunAttachments:c,attachments:u,exampleIds:l,datasetId:d,datasetName:p}=t;if(n===void 0)throw new Error("Must provide inputs when using legacy parameters");let h=d,m=p;if(h===void 0&&m===void 0)throw new Error("Must provide either datasetName or datasetId");if(h!==void 0&&m!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");h===void 0&&(h=(await this.readDataset({datasetName:m})).id);let f=n.map((g,y)=>({dataset_id:h,inputs:g,outputs:r?.[y],metadata:i?.[y],split:s?.[y],id:l?.[y],attachments:u?.[y],source_run_id:a?.[y],use_source_run_io:o?.[y],use_source_run_attachments:c?.[y]})),v=await this._uploadExamplesMultipart(h,f);return await Promise.all(v.example_ids.map(g=>this.readExample(g)))}async createLLMExample(t,n,r){return this.createExample({input:t},{output:n},r)}async createChatExample(t,n,r){let i=t.map(a=>bk(a)?wk(a):a),s=bk(n)?wk(n):n;return this.createExample({input:i},{output:s},r)}async readExample(t){_e(t);let n=`/examples/${t}`,r=await this._get(n),{attachment_urls:i,...s}=r,a=s;return i&&(a.attachments=Object.entries(i).reduce((o,[c,u])=>(o[c.slice(11)]={presigned_url:u.presigned_url,mime_type:u.mime_type},o),{})),a}async*listExamples({datasetId:t,datasetName:n,exampleIds:r,asOf:i,splits:s,inlineS3Urls:a,metadata:o,limit:c,offset:u,filter:l,includeAttachments:d}={}){let p;if(t!==void 0&&n!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");if(t!==void 0)p=t;else if(n!==void 0)p=(await this.readDataset({datasetName:n})).id;else throw new Error("Must provide a datasetName or datasetId");let h=new URLSearchParams({dataset:p}),m=i?typeof i=="string"?i:i?.toISOString():void 0;m&&h.append("as_of",m);let f=a??!0;if(h.append("inline_s3_urls",f.toString()),r!==void 0)for(let g of r)h.append("id",g);if(s!==void 0)for(let g of s)h.append("splits",g);if(o!==void 0){let g=JSON.stringify(o);h.append("metadata",g)}c!==void 0&&h.append("limit",c.toString()),u!==void 0&&h.append("offset",u.toString()),l!==void 0&&h.append("filter",l),d===!0&&["attachment_urls","outputs","metadata"].forEach(g=>h.append("select",g));let v=0;for await(let g of this._getPaginated("/examples",h)){for(let y of g){let{attachment_urls:w,...x}=y,O=x;w&&(O.attachments=Object.entries(w).reduce((z,[T,k])=>(z[T.slice(11)]={presigned_url:k.presigned_url,mime_type:k.mime_type||void 0},z),{})),yield O,v++}if(c!==void 0&&v>=c)break}}async deleteExample(t){_e(t);let n=`/examples/${t}`;await this.caller.call(async()=>{let r=await this._fetch(this.apiUrl+n,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,`delete ${n}`,!0),r})}async deleteExamples(t,n){if(t.forEach(r=>_e(r)),n?.hardDelete){let r=this._getPlatformEndpointPath("datasets/examples/delete");await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${r}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},body:JSON.stringify({example_ids:t,hard_delete:!0}),signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,"hard delete examples",!0),i})}else{let r=new URLSearchParams;t.forEach(i=>r.append("example_ids",i)),await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/examples?${r.toString()}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,"delete examples",!0),i})}}async updateExample(t,n){let r;n?r=t:r=t.id,_e(r);let i;n?i={id:r,...n}:i=t;let s;return i.dataset_id!==void 0?s=i.dataset_id:s=(await this.readExample(r)).dataset_id,this._updateExamplesMultipart(s,[i])}async updateExamples(t){let n;return t[0].dataset_id===void 0?n=(await this.readExample(t[0].id)).dataset_id:n=t[0].dataset_id,this._updateExamplesMultipart(n,t)}async readDatasetVersion({datasetId:t,datasetName:n,asOf:r,tag:i}){let s;if(t?s=t:s=(await this.readDataset({datasetName:n})).id,_e(s),r&&i||!r&&!i)throw new Error("Exactly one of asOf and tag must be specified.");let a=new URLSearchParams;return r!==void 0&&a.append("as_of",typeof r=="string"?r:r.toISOString()),i!==void 0&&a.append("tag",i),await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/datasets/${s}/version?${a.toString()}`,{method:"GET",headers:{...this._mergedHeaders},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(o,"read dataset version"),o})).json()}async listDatasetSplits({datasetId:t,datasetName:n,asOf:r}){let i;if(t===void 0&&n===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&n!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?i=(await this.readDataset({datasetName:n})).id:i=t,_e(i);let s=new URLSearchParams,a=r?typeof r=="string"?r:r?.toISOString():void 0;return a&&s.append("as_of",a),await this._get(`/datasets/${i}/splits`,s)}async updateDatasetSplits({datasetId:t,datasetName:n,splitName:r,exampleIds:i,remove:s=!1}){let a;if(t===void 0&&n===void 0)throw new Error("Must provide dataset name or ID");if(t!==void 0&&n!==void 0)throw new Error("Must provide either datasetName or datasetId, not both");t===void 0?a=(await this.readDataset({datasetName:n})).id:a=t,_e(a);let o={split_name:r,examples:i.map(u=>(_e(u),u)),remove:s},c=JSON.stringify(o);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/datasets/${a}/splits`,{method:"PUT",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await te(u,"update dataset splits",!0),u})}async createFeedback(t,n,{score:r,value:i,correction:s,comment:a,sourceInfo:o,feedbackSourceType:c="api",sourceRunId:u,feedbackId:l,feedbackConfig:d,projectId:p,comparativeExperimentId:h,sessionId:m,startTime:f}){if(!t&&!p)throw new Error("One of runId or projectId must be provided");if(t&&p)throw new Error("Only one of runId or projectId can be provided");let v={type:c??"api",metadata:o??{}};u!==void 0&&v?.metadata!==void 0&&!v.metadata.__run&&(v.metadata.__run={run_id:u}),v?.metadata!==void 0&&v.metadata.__run?.run_id!==void 0&&_e(v.metadata.__run.run_id);let g={id:l??C1(),run_id:t,key:n,score:Sk(r),value:i,correction:s,comment:a,feedback_source:v,comparative_experiment_id:h,feedbackConfig:d,session_id:m??p,start_time:f},y=JSON.stringify(g),w=`${this.apiUrl}/feedback`;return await this.caller.call(async()=>{let x=await this._fetch(w,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:y});return await te(x,"create feedback",!0),x}),g}async updateFeedback(t,{score:n,value:r,correction:i,comment:s}){let a={};n!=null&&(a.score=Sk(n)),r!=null&&(a.value=r),i!=null&&(a.correction=i),s!=null&&(a.comment=s),_e(t);let o=JSON.stringify(a);await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/feedback/${t}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:o});return await te(c,"update feedback",!0),c})}async readFeedback(t){_e(t);let n=`/feedback/${t}`;return await this._get(n)}async deleteFeedback(t){_e(t);let n=`/feedback/${t}`;await this.caller.call(async()=>{let r=await this._fetch(this.apiUrl+n,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,`delete ${n}`,!0),r})}async*listFeedback({runIds:t,feedbackKeys:n,feedbackSourceTypes:r}={}){let i=new URLSearchParams;if(t)for(let s of t)_e(s),i.append("run",s);if(n)for(let s of n)i.append("key",s);if(r)for(let s of r)i.append("source",s);for await(let s of this._getPaginated("/feedback",i))yield*s}async createPresignedFeedbackToken(t,n,{expiration:r,feedbackConfig:i}={}){let s={run_id:t,feedback_key:n,feedback_config:i};r?typeof r=="string"?s.expires_at=r:(r?.hours||r?.minutes||r?.days)&&(s.expires_in=r):s.expires_in={hours:3};let a=JSON.stringify(s);return await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/feedback/tokens`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(o,"create presigned feedback token"),o})).json()}async createComparativeExperiment({name:t,experimentIds:n,referenceDatasetId:r,createdAt:i,description:s,metadata:a,id:o}){if(n.length===0)throw new Error("At least one experiment is required");if(r||(r=(await this.readProject({projectId:n[0]})).reference_dataset_id),!r==null)throw new Error("A reference dataset is required");let c={id:o,name:t,experiment_ids:n,reference_dataset_id:r,description:s,created_at:(i??new Date)?.toISOString(),extra:{}};a&&(c.extra.metadata=a);let u=JSON.stringify(c);return(await this.caller.call(async()=>{let l=await this._fetch(`${this.apiUrl}/datasets/comparative`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await te(l,"create comparative experiment"),l})).json()}async*listPresignedFeedbackTokens(t){_e(t);let n=new URLSearchParams({run_id:t});for await(let r of this._getPaginated("/feedback/tokens",n))yield*r}_selectEvalResults(t){let n;return"results"in t?n=t.results:Array.isArray(t)?n=t:n=[t],n}async _logEvaluationFeedback(t,n,r){let i=this._selectEvalResults(t),s=[];for(let a of i){let o=r||{};a.evaluatorInfo&&(o={...a.evaluatorInfo,...o});let c=null;a.targetRunId?c=a.targetRunId:n&&(c=n.id),s.push(await this.createFeedback(c,a.key,{score:a.score,value:a.value,comment:a.comment,correction:a.correction,sourceInfo:o,sourceRunId:a.sourceRunId,feedbackConfig:a.feedbackConfig,feedbackSourceType:"model",sessionId:n?.session_id,startTime:n?.start_time}))}return[i,s]}async logEvaluationFeedback(t,n,r){let[i]=await this._logEvaluationFeedback(t,n,r);return i}async createFeedbackConfig(t){let{feedbackKey:n,feedbackConfig:r,isLowerScoreBetter:i=!1}=t,s={feedback_key:n,feedback_config:r,is_lower_score_better:i};return(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(s)});return await te(a,"create feedback config"),a})).json()}async*listFeedbackConfigs(t={}){let{feedbackKeys:n,nameContains:r,limit:i}=t,s=new URLSearchParams;n&&n.forEach(o=>{s.append("key",o)}),r&&s.append("name_contains",r),s.append("limit",(i!==void 0?Math.min(i,100):100).toString());let a=0;for await(let o of this._getPaginated("/feedback-configs",s))if(yield*o,a+=o.length,i!==void 0&&a>=i)break}async updateFeedbackConfig(t,n={}){let{feedbackConfig:r,isLowerScoreBetter:i}=n,s={feedback_key:t};return r!==void 0&&(s.feedback_config=r),i!==void 0&&(s.is_lower_score_better=i),(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/feedback-configs`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(s)});return await te(a,"update feedback config"),a})).json()}async deleteFeedbackConfig(t){let n=new URLSearchParams({feedback_key:t});await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/feedback-configs?${n}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,"delete feedback config",!0),r})}async*listAnnotationQueues(t={}){let{queueIds:n,name:r,nameContains:i,limit:s}=t,a=new URLSearchParams;n&&n.forEach((c,u)=>{_e(c,`queueIds[${u}]`),a.append("ids",c)}),r&&a.append("name",r),i&&a.append("name_contains",i),a.append("limit",(s!==void 0?Math.min(s,100):100).toString());let o=0;for await(let c of this._getPaginated("/annotation-queues",a))if(yield*c,o++,s!==void 0&&o>=s)break}async createAnnotationQueue(t){let{name:n,description:r,queueId:i,rubricInstructions:s,rubricItems:a}=t,o={name:n,description:r,id:i||yo(),rubric_instructions:s,rubric_items:a},c=JSON.stringify(Object.fromEntries(Object.entries(o).filter(([u,l])=>l!==void 0)));return(await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await te(u,"create annotation queue"),u})).json()}async readAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"read annotation queue"),n})).json()}async updateAnnotationQueue(t,n){let{name:r,description:i,rubricInstructions:s,rubricItems:a}=n,o={};r!==void 0&&(o.name=r),i!==void 0&&(o.description=i),s!==void 0&&(o.rubric_instructions=s),a!==void 0&&(o.rubric_items=a);let c=JSON.stringify(o);await this.caller.call(async()=>{let u=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await te(u,"update annotation queue",!0),u})}async deleteAnnotationQueue(t){await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"delete annotation queue",!0),n})}async addRunsToAnnotationQueue(t,n){let r=JSON.stringify(n.map((i,s)=>_e(i,`runIds[${s}]`).toString()));await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}/runs`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await te(i,"add runs to annotation queue",!0),i})}async getRunFromAnnotationQueue(t,n){let r=`/annotation-queues/${_e(t,"queueId")}/run`,i=await(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}${r}/${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(s,"get run from annotation queue"),s})).json();return vo(i)}async deleteRunFromAnnotationQueue(t,n){await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}/runs/${_e(n,"queueRunId")}`,{method:"DELETE",headers:{...this._mergedHeaders,Accept:"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,"delete run from annotation queue",!0),r})}async getSizeFromAnnotationQueue(t){return(await this.caller.call(async()=>{let n=await this._fetch(`${this.apiUrl}/annotation-queues/${_e(t,"queueId")}/size`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(n,"get size from annotation queue"),n})).json()}async _currentTenantIsOwner(t){let n=await this._getSettings();return t=="-"||n.tenant_handle===t}async _ownerConflictError(t,n){let r=await this._getSettings();return new Error(`Cannot ${t} for another tenant.
|
|
51
|
+
|
|
52
|
+
Current tenant: ${r.tenant_handle}
|
|
53
|
+
|
|
54
|
+
Requested tenant: ${n}`)}async _getLatestCommitHash(t){let n=await(await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/commits/${t}/?limit=1&offset=0`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,"get latest commit hash"),r})).json();if(n.commits.length!==0)return n.commits[0].commit_hash}async _likeOrUnlikePrompt(t,n){let[r,i,s]=Jt(t),a=JSON.stringify({like:n});return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/likes/${r}/${i}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(o,`${n?"like":"unlike"} prompt`),o})).json()}async _getPromptUrl(t){let[n,r,i]=Jt(t);if(await this._currentTenantIsOwner(n)){let s=await this._getSettings();return i!=="latest"?`${this.getHostUrl()}/prompts/${r}/${i.substring(0,8)}?organizationId=${s.id}`:`${this.getHostUrl()}/prompts/${r}?organizationId=${s.id}`}else return i!=="latest"?`${this.getHostUrl()}/hub/${n}/${r}/${i.substring(0,8)}`:`${this.getHostUrl()}/hub/${n}/${r}`}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[n,r,i]=Jt(t);for await(let s of this._getPaginated(`/commits/${n}/${r}/`,new URLSearchParams,a=>a.commits))yield*s}async*listPrompts(t){let n=new URLSearchParams;n.append("sort_field",t?.sortField??"updated_at"),n.append("sort_direction","desc"),n.append("is_archived",(!!t?.isArchived).toString()),t?.isPublic!==void 0&&n.append("is_public",t.isPublic.toString()),t?.query&&n.append("query",t.query);for await(let r of this._getPaginated("/repos",n,i=>i.repos))yield*r}async getPrompt(t){let[n,r,i]=Jt(t),s=await(await this.caller.call(async()=>{let a=await this._fetch(`${this.apiUrl}/repos/${n}/${r}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return a?.status===404?null:(await te(a,"get prompt"),a)}))?.json();return s?.repo?s.repo:null}async createPrompt(t,n){let r=await this._getSettings();if(n?.isPublic&&!r.tenant_handle)throw new Error(`Cannot create a public prompt without first
|
|
55
|
+
|
|
56
|
+
creating a LangChain Hub handle.
|
|
57
|
+
You can add a handle by creating a public prompt at:
|
|
58
|
+
|
|
59
|
+
https://smith.langchain.com/prompts`);let[i,s,a]=Jt(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError("create a prompt",i);let o={repo_handle:s,...n?.description&&{description:n.description},...n?.readme&&{readme:n.readme},...n?.tags&&{tags:n.tags},is_public:!!n?.isPublic},c=JSON.stringify(o),u=await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:c});return await te(d,"create prompt"),d}),{repo:l}=await u.json();return l}async createCommit(t,n,r){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[i,s,a]=Jt(t),o=r?.parentCommitHash==="latest"||!r?.parentCommitHash?await this._getLatestCommitHash(`${i}/${s}`):r?.parentCommitHash,c={manifest:JSON.parse(JSON.stringify(n)),parent_commit:o,...r?.description!==void 0&&{description:r.description}},u=JSON.stringify(c),l=await(await this.caller.call(async()=>{let d=await this._fetch(`${this.apiUrl}/commits/${i}/${s}`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:u});return await te(d,"create commit"),d})).json();return this._getPromptUrl(`${i}/${s}${l.commit_hash?`:${l.commit_hash}`:""}`)}async updateExamplesMultipart(t,n=[]){return this._updateExamplesMultipart(t,n)}async _updateExamplesMultipart(t,n=[]){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 r=new FormData;for(let s of n){let a=s.id,o={...s.metadata&&{metadata:s.metadata},...s.split&&{split:s.split}},c=hn(o,`Serializing body for example with id: ${a}`),u=new Blob([c],{type:"application/json"});if(r.append(a,u),s.inputs){let l=hn(s.inputs,`Serializing inputs for example with id: ${a}`),d=new Blob([l],{type:"application/json"});r.append(`${a}.inputs`,d)}if(s.outputs){let l=hn(s.outputs,`Serializing outputs whle updating example with id: ${a}`),d=new Blob([l],{type:"application/json"});r.append(`${a}.outputs`,d)}if(s.attachments)for(let[l,d]of Object.entries(s.attachments)){let p,h;Array.isArray(d)?[p,h]=d:(p=d.mimeType,h=d.data);let m=new Blob([h],{type:`${p}; length=${h.byteLength}`});r.append(`${a}.attachment.${l}`,m)}if(s.attachments_operations){let l=hn(s.attachments_operations,`Serializing attachments while updating example with id: ${a}`),d=new Blob([l],{type:"application/json"});r.append(`${a}.attachments_operations`,d)}}let i=t??n[0]?.dataset_id;return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${i}/examples`)}`,{method:"PATCH",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await te(s,"update examples"),s})).json()}async uploadExamplesMultipart(t,n=[]){return this._uploadExamplesMultipart(t,n)}async _uploadExamplesMultipart(t,n=[]){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 r=new FormData;for(let i of n){let s=(i.id??yo()).toString(),a={created_at:i.created_at,...i.metadata&&{metadata:i.metadata},...i.split&&{split:i.split},...i.source_run_id&&{source_run_id:i.source_run_id},...i.use_source_run_io&&{use_source_run_io:i.use_source_run_io},...i.use_source_run_attachments&&{use_source_run_attachments:i.use_source_run_attachments}},o=hn(a,`Serializing body for uploaded example with id: ${s}`),c=new Blob([o],{type:"application/json"});if(r.append(s,c),i.inputs){let u=hn(i.inputs,`Serializing inputs for uploaded example with id: ${s}`),l=new Blob([u],{type:"application/json"});r.append(`${s}.inputs`,l)}if(i.outputs){let u=hn(i.outputs,`Serializing outputs for uploaded example with id: ${s}`),l=new Blob([u],{type:"application/json"});r.append(`${s}.outputs`,l)}if(i.attachments)for(let[u,l]of Object.entries(i.attachments)){let d,p;Array.isArray(l)?[d,p]=l:(d=l.mimeType,p=l.data);let h=new Blob([p],{type:`${d}; length=${p.byteLength}`});r.append(`${s}.attachment.${u}`,h)}}return(await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${t}/examples`)}`,{method:"POST",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:r});return await te(i,"upload examples"),i})).json()}async updatePrompt(t,n){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[r,i]=Jt(t);if(!await this._currentTenantIsOwner(r))throw await this._ownerConflictError("update a prompt",r);let s={};if(n?.description!==void 0&&(s.description=n.description),n?.readme!==void 0&&(s.readme=n.readme),n?.tags!==void 0&&(s.tags=n.tags),n?.isPublic!==void 0&&(s.is_public=n.isPublic),n?.isArchived!==void 0&&(s.is_archived=n.isArchived),Object.keys(s).length===0)throw new Error("No valid update options provided");let a=JSON.stringify(s);return(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/repos/${r}/${i}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:a});return await te(o,"update prompt"),o})).json()}async deletePrompt(t){if(!await this.promptExists(t))throw new Error("Prompt does not exist, you must create it first.");let[n,r,i]=Jt(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("delete a prompt",n);return(await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${n}/${r}`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(s,"delete prompt"),s})).json()}_getPromptCacheKey(t,n){return`${t}${n?":with_model":""}`}async _fetchPromptFromApi(t,n){let[r,i,s]=Jt(t),a=await(await this.caller.call(async()=>{let o=await this._fetch(`${this.apiUrl}/commits/${r}/${i}/${s}${n?.includeModel?"?include_model=true":""}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(o,"pull prompt commit"),o})).json();return{owner:r,repo:i,commit_hash:a.commit_hash,manifest:a.manifest,examples:a.examples,hub_model_config:a.model_config,hub_model_provider:a.model_provider}}async pullPromptCommit(t,n){FU(t,n?.dangerouslyPullPublicPrompt);let r=this._fetchPromptFromApi.bind(this,t,n);if(!n?.skipCache&&this._promptCache){let i=this._getPromptCacheKey(t,n?.includeModel),s=this._promptCache.get(i,r);if(s)return s;let a=await r();return this._promptCache.set(i,a,r),a}return this._fetchPromptFromApi(t,n)}async _pullPrompt(t,n){let r=await this.pullPromptCommit(t,{includeModel:n?.includeModel,skipCache:n?.skipCache,dangerouslyPullPublicPrompt:n?.dangerouslyPullPublicPrompt});return JSON.stringify(r.manifest)}async pushPrompt(t,n){return await this.promptExists(t)?n&&Object.keys(n).some(r=>r!=="object")&&await this.updatePrompt(t,{description:n?.description,readme:n?.readme,tags:n?.tags,isPublic:n?.isPublic}):await this.createPrompt(t,{description:n?.description,readme:n?.readme,tags:n?.tags,isPublic:n?.isPublic}),n?.object?await this.createCommit(t,n?.object,{parentCommitHash:n?.parentCommitHash,description:n?.commitDescription}):await this._getPromptUrl(t)}async agentExists(t){let[n,r]=Jt(t);return this._repoExists(n,r)}async skillExists(t){let[n,r]=Jt(t);return this._repoExists(n,r)}async pullAgent(t,n){return await this._pullDirectory(t,"agent",n?.version)}async pullSkill(t,n){return await this._pullDirectory(t,"skill",n?.version)}async pushAgent(t,n){return this._pushDirectory(t,"agent",n)}async pushSkill(t,n){return this._pushDirectory(t,"skill",n)}async deleteAgent(t){return this._deleteDirectory(t)}async deleteSkill(t){return this._deleteDirectory(t)}async*listAgents(t){yield*this._listReposByType("agent",t)}async*listSkills(t){yield*this._listReposByType("skill",t)}async*_listReposByType(t,n){let r=new URLSearchParams;r.append("repo_type",t),r.append("is_archived",(!!n?.isArchived).toString()),n?.isPublic!==void 0&&r.append("is_public",n.isPublic.toString()),n?.query&&r.append("query",n.query);for await(let i of this._getPaginated("/repos",r,s=>s.repos))yield*i}async _pullDirectory(t,n,r){let[i,s,a]=Jt(t),o=r??(a!=="latest"?a:void 0),c=new URL(`${this.apiUrl}/v1/platform/hub/repos/${i}/${s}/directories`);return c.searchParams.set("repo_type",n),o&&c.searchParams.set("commit",o),await(await this.caller.call(async()=>{let u=await this._fetch(c.toString(),{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(u,"pull directory"),u})).json()}async _pushDirectory(t,n,r){if(r.parentCommit!==void 0&&(r.parentCommit.length<8||r.parentCommit.length>64))throw new Error("parent_commit must be 8-64 characters");let[i,s]=Jt(t);if(!await this._currentTenantIsOwner(i))throw await this._ownerConflictError(`push ${n}`,i);if(await this._repoExists(i,s))(r.description!==void 0||r.readme!==void 0||r.tags!==void 0||r.isPublic!==void 0)&&await this._updateRepoMetadata(i,s,r);else{let c=/^[a-z][a-z0-9-_]*$/;if(!c.test(s))throw new Error(`Invalid repo_handle ${JSON.stringify(s)}: must match ${c}`);await this._createRepo(s,n,r)}let a={files:r.files};r.parentCommit&&(a.parent_commit=r.parentCommit);let o=(await(await this.caller.call(async()=>{let c=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${i}/${s}/directories/commits`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(a)});return await te(c,`push ${n}`),c})).json()).commit.commit_hash;return`${this.getHostUrl()}/hub/${i}/${s}:${o.slice(0,8)}`}async _deleteDirectory(t){let[n,r]=Jt(t);if(!await this._currentTenantIsOwner(n))throw await this._ownerConflictError("delete",n);await this.caller.call(async()=>{let i=await this._fetch(`${this.apiUrl}/v1/platform/hub/repos/${n}/${r}/directories`,{method:"DELETE",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(i,"delete directory"),i})}async _repoExists(t,n){try{return await this.caller.call(async()=>{let r=await this._fetch(`${this.apiUrl}/repos/${t}/${n}`,{method:"GET",headers:this._mergedHeaders,signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions});return await te(r,"check repo exists"),r}),!0}catch(r){if(uf(r))return!1;throw r}}async _createRepo(t,n,r){let i={repo_handle:t,repo_type:n,is_public:!!r.isPublic};r.description!==void 0&&(i.description=r.description),r.readme!==void 0&&(i.readme=r.readme),r.tags!==void 0&&(i.tags=r.tags);try{await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/`,{method:"POST",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(i)});return await te(s,`create ${n}`),s})}catch(s){if(yU(s))return;throw s}}async _updateRepoMetadata(t,n,r){let i={};r.description!==void 0&&(i.description=r.description),r.readme!==void 0&&(i.readme=r.readme),r.tags!==void 0&&(i.tags=r.tags),r.isPublic!==void 0&&(i.is_public=r.isPublic),Object.keys(i).length!==0&&await this.caller.call(async()=>{let s=await this._fetch(`${this.apiUrl}/repos/${t}/${n}`,{method:"PATCH",headers:{...this._mergedHeaders,"Content-Type":"application/json"},signal:AbortSignal.timeout(this.timeout_ms),...this.fetchOptions,body:JSON.stringify(i)});return await te(s,"update repo metadata"),s})}async clonePublicDataset(t,n={}){let{sourceApiUrl:r=this.apiUrl,datasetName:i}=n,[s,a]=this.parseTokenOrUrl(t,r),o=new e({apiUrl:s,apiKey:"placeholder"}),c=await o.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 o.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(p=>p.inputs),outputs:l.flatMap(p=>p.outputs?[p.outputs]:[]),datasetId:d.id})}catch(p){throw console.error(`An error occurred while creating dataset ${u}. You should delete it manually.`),p}}parseTokenOrUrl(t,n,r=2,i="dataset"){try{return _e(t),[n,t]}catch{}try{let s=new URL(t).pathname.split("/").filter(a=>a!=="");if(s.length>=r){let a=s[s.length-r];return[n,a]}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();for(await new Promise(t=>setTimeout(t,1));this._pendingDrains.size>0;)await Promise.all([...this._pendingDrains]);await Promise.all([...this.autoBatchQueue.items.map(({itemPromise:t})=>t),this.batchIngestCaller.queue.onIdle()]),this.langSmithToOTELTranslator!==void 0&&await WM()?.DEFAULT_LANGSMITH_SPAN_PROCESSOR?.forceFlush()}toString(){let t=[`apiUrl=${JSON.stringify(this.apiUrl)}`];return this.webUrl!==void 0&&t.push(`webUrl=${JSON.stringify(this.webUrl)}`),this.workspaceId!==void 0&&t.push(`workspaceId=${JSON.stringify(this.workspaceId)}`),`[LangSmithClient ${t.join(" ")}]`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};Object.defineProperty(ka,"_fallbackDirsCreated",{enumerable:!0,configurable:!0,writable:!0,value:new Set});function Ok(e){return"dataset_id"in e||"dataset_name"in e}var WU=e=>!!["TRACING_V2","TRACING"].find(t=>gt(t)==="true"),_i=Symbol.for("lc:context_variables"),pf=Symbol.for("langsmith:replica_trace_roots");function Ak(e,t){if(_i in e)return e[_i][t]}function GU(e,t,n){let r=_i in e?e[_i]:{};r[t]=n,e[_i]=r}var XU="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function Tk(e){let t=Object.keys(e).sort().map(n=>`${n}:${e[n]??""}`).join("|");return P_(t,XU)}function YU(e){return e.replace(/[-:.]/g,"")}function Y1(e,t=1){let n=t.toFixed(0).slice(0,3).padStart(3,"0");return`${new Date(e).toISOString().slice(0,-1)}${n}Z`}function Q1(e,t,n=1){let r=Y1(e,n);return{dottedOrder:YU(r)+t,microsecondPrecisionDatestring:r}}var QU=new Set(["projectName","updates","reroot"]);function eL(e){let t={};for(let n of Object.keys(e))QU.has(n)&&(t[n]=e[n]);return t}var vd=class e{constructor(t,n,r,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=n,this.project_name=r,this.replicas=i}static fromHeader(t){let n=t.split(","),r={},i=[],s,a;for(let o of n){let[c,u]=o.split("="),l=decodeURIComponent(u);c==="langsmith-metadata"?r=JSON.parse(l):c==="langsmith-tags"?i=l.split(","):c==="langsmith-project"?s=l:c==="langsmith-replicas"&&(a=JSON.parse(l).map(d=>Array.isArray(d)?d:eL(d)))}return new e(r,i,s,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(",")}},xa=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}),tL(t)){Object.assign(this,{...t});return}let n=e.getDefaultConfig(),{metadata:r,...i}=t,s=i.client??e.getSharedClient(),a={...r,...i?.extra?.metadata};if(i.extra={...i.extra,metadata:a},"id"in i&&i.id==null&&delete i.id,Object.assign(this,{...n,...i,client:s}),this.execution_order??=1,this.child_execution_order??=1,this.dotted_order||(this._serialized_start_time=Y1(this.start_time,this.execution_order)),this.id||(this.id=EM(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=sL(this.replicas),!this.dotted_order){let{dottedOrder:o}=Q1(this.start_time,this.id,this.execution_order);this.parent_run?this.dotted_order=this.parent_run.dotted_order+"."+o:this.dotted_order=o}}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:P1(),child_runs:[],api_url:wn("LANGCHAIN_ENDPOINT")??"http://localhost:1984",api_key:wn("LANGCHAIN_API_KEY"),caller_options:{},start_time:t,serialized:{},inputs:{},extra:{}}}static getSharedClient(){return e.sharedClient||(e.sharedClient=new ka),e.sharedClient}createChild(t){let n=this.child_execution_order+1,r=this.replicas?.map(p=>{let{reroot:h,...m}=p;return m}),i=t.replicas??r,s=new e({...t,parent_run:this,project_name:this.project_name,replicas:i,client:this.client,tracingEnabled:this.tracingEnabled,execution_order:n,child_execution_order:n}),a=this.extra?.metadata??{},o=s.extra?.metadata??{};Object.keys(a).length>0&&(s.extra={...s.extra,metadata:{...a,...o}}),_i in this&&(s[_i]=this[_i]);let c=Symbol.for("lc:child_config"),u=t.extra?.[c]??this.extra[c];if(rL(u)){let p={...u},h=nL(p.callbacks)?p.callbacks.copy?.():void 0;h&&(Object.assign(h,{_parentRunId:s.id}),h.handlers?.find(eI)?.updateFromRunTree?.(s),p.callbacks=h),s.extra[c]=p}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,n),d=d.parent_run;return this.child_runs.push(s),s}async end(t,n,r=Date.now(),i){this.outputs=this.outputs??t,this.error=this.error??n,this.end_time=this.end_time??r,i&&Object.keys(i).length>0&&(this.extra=this.extra?{...this.extra,metadata:{...this.extra.metadata,...i}}:{metadata:i})}_convertToCreate(t,n,r=!0){let i=t.extra??{};if(i?.runtime?.library===void 0&&(i.runtime||(i.runtime={}),n))for(let[o,c]of Object.entries(n))i.runtime[o]||(i.runtime[o]=c);let s=t.parent_run?.id??t.parent_run_id,a;return r?a=[]:a=t.child_runs.map(o=>this._convertToCreate(o,n,r)),{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:s,trace_id:t.trace_id,dotted_order:t.dotted_order,tags:t.tags,attachments:t.attachments,events:t.events}}_sliceParentId(t,n){if(n.dotted_order){let r=n.dotted_order.split("."),i=null;for(let s=0;s<r.length;s++)if(r[s].slice(-36)===t){i=s;break}if(i!==null){let s=r.slice(i+1);n.dotted_order=s.join("."),s.length>0?n.trace_id=s[0].slice(-36):n.trace_id=n.id}}n.parent_run_id===t&&(n.parent_run_id=void 0)}_setReplicaTraceRoot(t,n){let r=Ak(this,pf)??{};r[t]=n,GU(this,pf,r);for(let i of this.child_runs)i._setReplicaTraceRoot(t,n)}_remapForProject(t){let{projectName:n,runtimeEnv:r,excludeChildRuns:i=!0,reroot:s=!1,distributedParentId:a,apiUrl:o,apiKey:c,workspaceId:u}=t,l=this._convertToCreate(this,r,i);if(n===this.project_name)return{...l,session_name:n};if(s){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 g=Tk({projectName:n,apiUrl:o,apiKey:c,workspaceId:u});this._setReplicaTraceRoot(g,l.id)}let d;if(!s){let g=Ak(this,pf)??{},y=Tk({projectName:n,apiUrl:o,apiKey:c,workspaceId:u});if(d=g[y],d&&(l.trace_id=d,l.dotted_order)){let w=l.dotted_order.split("."),x=null;for(let O=0;O<w.length;O++)if(w[O].slice(-36)===d){x=O;break}if(x!==null){let O=w.slice(x);l.dotted_order=O.join(".")}}}let p=l.id,h=tl(p,n),m;l.trace_id?m=tl(l.trace_id,n):m=h;let f;l.parent_run_id&&(f=tl(l.parent_run_id,n));let v;return l.dotted_order&&(v=l.dotted_order.split(".").map(g=>{let y=g.slice(-36),w=tl(y,n);return g.slice(0,-36)+w}).join(".")),{...l,id:h,trace_id:m,parent_run_id:f,dotted_order:v,session_name:n}}async postRun(t=!0){this._awaitInputsOnPost&&(this.inputs=await this.inputs);try{let n=q1();if(this.replicas&&this.replicas.length>0)for(let{projectName:r,apiKey:i,apiUrl:s,workspaceId:a,reroot:o,client:c}of this.replicas){let u=this._remapForProject({projectName:r??this.project_name,runtimeEnv:n,excludeChildRuns:!0,reroot:o,distributedParentId:this.distributedParentId,apiUrl:s,apiKey:i,workspaceId:a});await(c??this.client).createRun(u,{apiKey:i,apiUrl:s,workspaceId:a})}else{let r=this._convertToCreate(this,n,t);await this.client.createRun(r)}if(!t){Fl("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");for(let r of this.child_runs)await r.postRun(!1)}this.child_runs=[]}catch(n){console.error(`Error in postRun for run ${this.id}:`,n)}}async patchRun(t){if(this.replicas&&this.replicas.length>0)for(let{projectName:n,apiKey:r,apiUrl:i,workspaceId:s,updates:a,reroot:o,client:c}of this.replicas){let u=this._remapForProject({projectName:n??this.project_name,runtimeEnv:void 0,excludeChildRuns:!0,reroot:o,distributedParentId:this.distributedParentId,apiUrl:i,apiKey:r,workspaceId:s}),l={id:u.id,name:u.name,run_type:u.run_type,start_time:u.start_time,outputs:u.outputs,error:u.error,parent_run_id:u.parent_run_id,session_name:u.session_name,reference_example_id:u.reference_example_id,end_time:u.end_time,dotted_order:u.dotted_order,trace_id:u.trace_id,events:u.events,tags:u.tags,extra:u.extra,attachments:this.attachments,...a};t?.excludeInputs||(l.inputs=u.inputs),await(c??this.client).updateRun(u.id,l,{apiKey:r,apiUrl:i,workspaceId:s})}else try{let n={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||(n.inputs=this.inputs),await this.client.updateRun(this.id,n)}catch(n){console.error(`Error in patchRun for run ${this.id}`,n)}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,n){let r=t?.callbacks,i,s,a,o=WU();if(r){let c=r?.getParentRunId?.()??"",u=r?.handlers?.find(l=>l?.name=="langchain_tracer");i=u?.getRun?.(c),s=u?.projectName,a=u?.client,o=o||!!u}return i?new e({name:i.name,id:i.id,trace_id:i.trace_id,dotted_order:i.dotted_order,client:a,tracingEnabled:o,project_name:s,tags:[...new Set((i?.tags??[]).concat(t?.tags??[]))],extra:{metadata:{...i?.extra?.metadata,...t?.metadata}}}).createChild(n):new e({...n,client:a,tracingEnabled:o,project_name:s})}static fromDottedOrder(t){return this.fromHeaders({"langsmith-trace":t})}static fromHeaders(t,n){let r="get"in t&&typeof t.get=="function"?{"langsmith-trace":t.get("langsmith-trace"),baggage:t.get("baggage")}:t,i=r["langsmith-trace"];if(!i||typeof i!="string")return;let s=i.trim(),a=s.split(".").map(l=>{let[d,p]=l.split("Z");return{strTime:d,time:Date.parse(d+"Z"),uuid:p}}),o=a[0].uuid,c={...n,name:n?.name??"parent",run_type:n?.run_type??"chain",start_time:n?.start_time??Date.now(),id:a.at(-1)?.uuid,trace_id:o,dotted_order:s};if(r.baggage&&typeof r.baggage=="string"){let l=vd.fromHeader(r.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 n={"langsmith-trace":this.dotted_order,baggage:new vd(this.extra?.metadata,this.tags,this.project_name,this.replicas).toHeader()};if(t)for(let[r,i]of Object.entries(n))t.set(r,i);return n}};Object.defineProperty(xa,"sharedClient",{enumerable:!0,configurable:!0,writable:!0,value:null});function tL(e){return e!=null&&typeof e.createChild=="function"&&typeof e.postRun=="function"}function eI(e){return typeof e=="object"&&e!=null&&typeof e.name=="string"&&e.name==="langchain_tracer"}function Ek(e){return Array.isArray(e)&&e.some(t=>eI(t))}function nL(e){return typeof e=="object"&&e!=null&&Array.isArray(e.handlers)}function rL(e){let t=e?.callbacks;return e!=null&&typeof t=="object"&&(Ek(t?.handlers)||Ek(t))}function iL(){let e=wn("LANGSMITH_RUNS_ENDPOINTS");if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){let n=[];for(let r of t){if(typeof r!="object"||r===null){console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof r}`);continue}if(typeof r.api_url!="string"){console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof r.api_url}`);continue}if(typeof r.api_key!="string"){console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof r.api_key}`);continue}n.push({apiUrl:r.api_url.replace(/\/$/,""),apiKey:r.api_key})}return n}else if(typeof t=="object"&&t!==null){aL(t);let n=[];for(let[r,i]of Object.entries(t)){let s=r.replace(/\/$/,"");if(typeof i=="string")n.push({apiUrl:s,apiKey:i});else{console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${r}: expected string, got ${typeof i}`);continue}}return n}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(_U(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 sL(e){return e?e.map(t=>Array.isArray(t)?{projectName:t[0],updates:t[1]}:t):iL()}function aL(e){if(Object.keys(e).length>0&>("ENDPOINT"))throw new _g}var oL=G({BaseTracer:()=>ei,isBaseTracer:()=>Ws}),cL=e=>{if(e)return e.events=e.events??[],e.child_runs=e.child_runs??[],e};function $g(e,t){if(e)return new xa({...e,start_time:e._serialized_start_time??e.start_time,parent_run:$g(t),child_runs:e.child_runs.map(n=>$g(n)).filter(n=>n!==void 0),extra:{...e.extra,runtime:r1()},tracingEnabled:!1})}function hf(e,t){return e&&!Array.isArray(e)&&typeof e=="object"?e:{[t]:e}}function Ws(e){return typeof e._addRunToRunMap=="function"}var ei=class extends Li{runMap=new Map;runTreeMap=new Map;usesRunTreeMap=!1;constructor(e){super(...arguments)}copy(){return this}getRunById(e){if(e!==void 0)return this.usesRunTreeMap?cL(this.runTreeMap.get(e)):this.runMap.get(e)}stringifyError(e){return e instanceof Error?e.message+(e?.stack?`
|
|
60
|
+
|
|
61
|
+
${e.stack}`:""):typeof e=="string"?e:`${e}`}_addChildRun(e,t){e.child_runs.push(t)}_addRunToRunMap(e){let{dottedOrder:t,microsecondPrecisionDatestring:n}=Q1(new Date(e.start_time).getTime(),e.id,e.execution_order),r={...e},i=this.getRunById(r.parent_run_id);if(r.parent_run_id!==void 0?i?(this._addChildRun(i,r),i.child_execution_order=Math.max(i.child_execution_order,r.child_execution_order),r.trace_id=i.trace_id,i.dotted_order!==void 0&&(r.dotted_order=[i.dotted_order,t].join("."),r._serialized_start_time=n)):r.parent_run_id=void 0:(r.trace_id=r.id,r.dotted_order=t,r._serialized_start_time=n),this.usesRunTreeMap){let s=$g(r,i);s!==void 0&&this.runTreeMap.set(r.id,s)}else this.runMap.set(r.id,r);return r}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,n,r,i,s,a,o){let c=this._getExecutionOrder(r),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:n,name:o??e.id[e.id.length-1],parent_run_id:r,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:s||[]};return this._addRunToRunMap(d)}async handleLLMStart(e,t,n,r,i,s,a,o){let c=this.getRunById(n)??this._createRunForLLMStart(e,t,n,r,i,s,a,o);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}_createRunForChatModelStart(e,t,n,r,i,s,a,o){let c=this._getExecutionOrder(r),u=Date.now(),l=a?{...i,metadata:a}:i,d={id:n,name:o??e.id[e.id.length-1],parent_run_id:r,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:s||[]};return this._addRunToRunMap(d)}async handleChatModelStart(e,t,n,r,i,s,a,o){let c=this.getRunById(n)??this._createRunForChatModelStart(e,t,n,r,i,s,a,o);return await this.onRunCreate?.(c),await this.onLLMStart?.(c),c}async handleLLMEnd(e,t,n,r,i){let s=this.getRunById(t);if(!s||s?.run_type!=="llm")throw new Error("No LLM run to end.");return s.end_time=Date.now(),s.outputs=e,s.events.push({name:"end",time:new Date(s.end_time).toISOString()}),s.extra={...s.extra,...i},await this.onLLMEnd?.(s),await this._endTrace(s),s}async handleLLMError(e,t,n,r,i){let s=this.getRunById(t);if(!s||s?.run_type!=="llm")throw new Error("No LLM run to end.");return s.end_time=Date.now(),s.error=this.stringifyError(e),s.events.push({name:"error",time:new Date(s.end_time).toISOString()}),s.extra={...s.extra,...i},await this.onLLMError?.(s),await this._endTrace(s),s}_createRunForChainStart(e,t,n,r,i,s,a,o,c){let u=this._getExecutionOrder(r),l=Date.now(),d={id:n,name:o??e.id[e.id.length-1],parent_run_id:r,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:s?{...c,metadata:s}:{...c},tags:i||[]};return this._addRunToRunMap(d)}async handleChainStart(e,t,n,r,i,s,a,o){let c=this.getRunById(n)??this._createRunForChainStart(e,t,n,r,i,s,a,o);return await this.onRunCreate?.(c),await this.onChainStart?.(c),c}async handleChainEnd(e,t,n,r,i){let s=this.getRunById(t);if(!s)throw new Error("No chain run to end.");return s.end_time=Date.now(),s.outputs=hf(e,"output"),s.events.push({name:"end",time:new Date(s.end_time).toISOString()}),i?.inputs!==void 0&&(s.inputs=hf(i.inputs,"input")),await this.onChainEnd?.(s),await this._endTrace(s),s}async handleChainError(e,t,n,r,i){let s=this.getRunById(t);if(!s)throw new Error("No chain run to end.");return s.end_time=Date.now(),s.error=this.stringifyError(e),s.events.push({name:"error",time:new Date(s.end_time).toISOString()}),i?.inputs!==void 0&&(s.inputs=hf(i.inputs,"input")),await this.onChainError?.(s),await this._endTrace(s),s}_createRunForToolStart(e,t,n,r,i,s,a){let o=this._getExecutionOrder(r),c=Date.now(),u={id:n,name:a??e.id[e.id.length-1],parent_run_id:r,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{input:t},execution_order:o,child_execution_order:o,run_type:"tool",child_runs:[],extra:s?{metadata:s}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleToolStart(e,t,n,r,i,s,a){let o=this.getRunById(n)??this._createRunForToolStart(e,t,n,r,i,s,a);return await this.onRunCreate?.(o),await this.onToolStart?.(o),o}async handleToolEnd(e,t){let n=this.getRunById(t);if(!n||n?.run_type!=="tool")throw new Error("No tool run to end");return n.end_time=Date.now(),n.outputs={output:e},n.events.push({name:"end",time:new Date(n.end_time).toISOString()}),await this.onToolEnd?.(n),await this._endTrace(n),n}async handleToolError(e,t){let n=this.getRunById(t);if(!n||n?.run_type!=="tool")throw new Error("No tool run to end");return n.end_time=Date.now(),n.error=this.stringifyError(e),n.events.push({name:"error",time:new Date(n.end_time).toISOString()}),await this.onToolError?.(n),await this._endTrace(n),n}async handleAgentAction(e,t){let n=this.getRunById(t);if(!n||n?.run_type!=="chain")return;let r=n;r.actions=r.actions||[],r.actions.push(e),r.events.push({name:"agent_action",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentAction?.(n)}async handleAgentEnd(e,t){let n=this.getRunById(t);!n||n?.run_type!=="chain"||(n.events.push({name:"agent_end",time:new Date().toISOString(),kwargs:{action:e}}),await this.onAgentEnd?.(n))}_createRunForRetrieverStart(e,t,n,r,i,s,a){let o=this._getExecutionOrder(r),c=Date.now(),u={id:n,name:a??e.id[e.id.length-1],parent_run_id:r,start_time:c,serialized:e,events:[{name:"start",time:new Date(c).toISOString()}],inputs:{query:t},execution_order:o,child_execution_order:o,run_type:"retriever",child_runs:[],extra:s?{metadata:s}:{},tags:i||[]};return this._addRunToRunMap(u)}async handleRetrieverStart(e,t,n,r,i,s,a){let o=this.getRunById(n)??this._createRunForRetrieverStart(e,t,n,r,i,s,a);return await this.onRunCreate?.(o),await this.onRetrieverStart?.(o),o}async handleRetrieverEnd(e,t){let n=this.getRunById(t);if(!n||n?.run_type!=="retriever")throw new Error("No retriever run to end");return n.end_time=Date.now(),n.outputs={documents:e},n.events.push({name:"end",time:new Date(n.end_time).toISOString()}),await this.onRetrieverEnd?.(n),await this._endTrace(n),n}async handleRetrieverError(e,t){let n=this.getRunById(t);if(!n||n?.run_type!=="retriever")throw new Error("No retriever run to end");return n.end_time=Date.now(),n.error=this.stringifyError(e),n.events.push({name:"error",time:new Date(n.end_time).toISOString()}),await this.onRetrieverError?.(n),await this._endTrace(n),n}async handleText(e,t){let n=this.getRunById(t);!n||n?.run_type!=="chain"||(n.events.push({name:"text",time:new Date().toISOString(),kwargs:{text:e}}),await this.onText?.(n))}async handleLLMNewToken(e,t,n,r,i,s){let a=this.getRunById(n);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:s?.chunk}}),await this.onLLMNewToken?.(a,e,{chunk:s?.chunk}),a}},Ig={exports:{}};Ig.exports;var Ck;function uL(){return Ck||(Ck=1,(function(e){let t=(i=0)=>s=>`\x1B[${38+i};5;${s}m`,n=(i=0)=>(s,a,o)=>`\x1B[${38+i};2;${s};${a};${o}m`;function r(){let i=new Map,s={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]}};s.color.gray=s.color.blackBright,s.bgColor.bgGray=s.bgColor.bgBlackBright,s.color.grey=s.color.blackBright,s.bgColor.bgGrey=s.bgColor.bgBlackBright;for(let[a,o]of Object.entries(s)){for(let[c,u]of Object.entries(o))s[c]={open:`\x1B[${u[0]}m`,close:`\x1B[${u[1]}m`},o[c]=s[c],i.set(u[0],u[1]);Object.defineProperty(s,a,{value:o,enumerable:!1})}return Object.defineProperty(s,"codes",{value:i,enumerable:!1}),s.color.close="\x1B[39m",s.bgColor.close="\x1B[49m",s.color.ansi256=t(),s.color.ansi16m=n(),s.bgColor.ansi256=t(10),s.bgColor.ansi16m=n(10),Object.defineProperties(s,{rgbToAnsi256:{value:(a,o,c)=>a===o&&o===c?a<8?16:a>248?231:Math.round((a-8)/247*24)+232:16+36*Math.round(a/255*5)+6*Math.round(o/255*5)+Math.round(c/255*5),enumerable:!1},hexToRgb:{value:a=>{let o=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(a.toString(16));if(!o)return[0,0,0];let{colorString:c}=o.groups;c.length===3&&(c=c.split("").map(l=>l+l).join(""));let u=Number.parseInt(c,16);return[u>>16&255,u>>8&255,u&255]},enumerable:!1},hexToAnsi256:{value:a=>s.rgbToAnsi256(...s.hexToRgb(a)),enumerable:!1}}),s}Object.defineProperty(e,"exports",{enumerable:!0,get:r})})(Ig)),Ig.exports}var lL=uL(),tI=Us(lL),dL=G({ConsoleCallbackHandler:()=>Sg});function Bt(e,t){return`${e.open}${t}${e.close}`}function Tn(e,t){try{return JSON.stringify(e,null,2)}catch{return t}}function Nk(e){return typeof e=="string"?e.trim():e==null?e:Tn(e,e.toString())}function ni(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:en}=tI,Sg=class extends ei{name="console_callback_handler";persistRun(e){return Promise.resolve()}getParents(e){let t=[],n=e;for(;n.parent_run_id;){let r=this.runMap.get(n.parent_run_id);if(r)t.push(r),n=r;else break}return t}getBreadcrumbs(e){let t=[...this.getParents(e).reverse(),e].map((n,r,i)=>{let s=`${n.execution_order}:${n.run_type}:${n.name}`;return r===i.length-1?Bt(tI.bold,s):s}).join(" > ");return Bt(en.grey,t)}onChainStart(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.green,"[chain/start]")} [${t}] Entering Chain run with input: ${Tn(e.inputs,"[inputs]")}`)}onChainEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.cyan,"[chain/end]")} [${t}] [${ni(e)}] Exiting Chain run with output: ${Tn(e.outputs,"[outputs]")}`)}onChainError(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.red,"[chain/error]")} [${t}] [${ni(e)}] Chain run errored with error: ${Tn(e.error,"[error]")}`)}onLLMStart(e){let t=this.getBreadcrumbs(e),n="prompts"in e.inputs?{prompts:e.inputs.prompts.map(r=>r.trim())}:e.inputs;console.log(`${Bt(en.green,"[llm/start]")} [${t}] Entering LLM run with input: ${Tn(n,"[inputs]")}`)}onLLMEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.cyan,"[llm/end]")} [${t}] [${ni(e)}] Exiting LLM run with output: ${Tn(e.outputs,"[response]")}`)}onLLMError(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.red,"[llm/error]")} [${t}] [${ni(e)}] LLM run errored with error: ${Tn(e.error,"[error]")}`)}onToolStart(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.green,"[tool/start]")} [${t}] Entering Tool run with input: "${Nk(e.inputs.input)}"`)}onToolEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.cyan,"[tool/end]")} [${t}] [${ni(e)}] Exiting Tool run with output: "${Nk(e.outputs?.output)}"`)}onToolError(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.red,"[tool/error]")} [${t}] [${ni(e)}] Tool run errored with error: ${Tn(e.error,"[error]")}`)}onRetrieverStart(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.green,"[retriever/start]")} [${t}] Entering Retriever run with input: ${Tn(e.inputs,"[inputs]")}`)}onRetrieverEnd(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.cyan,"[retriever/end]")} [${t}] [${ni(e)}] Exiting Retriever run with output: ${Tn(e.outputs,"[outputs]")}`)}onRetrieverError(e){let t=this.getBreadcrumbs(e);console.log(`${Bt(en.red,"[retriever/error]")} [${t}] [${ni(e)}] Retriever run errored with error: ${Tn(e.error,"[error]")}`)}onAgentAction(e){let t=e,n=this.getBreadcrumbs(e);console.log(`${Bt(en.blue,"[agent/action]")} [${n}] Agent selected action: ${Tn(t.actions[t.actions.length-1],"[action]")}`)}},mf,nI=()=>(mf===void 0&&(mf=new ka(bn("LANGCHAIN_CALLBACKS_BACKGROUND")==="false"?{blockOnRootRunFinalization:!0}:{})),mf),pL=class{getStore(){}run(e,t){return t()}},ff=Symbol.for("ls:tracing_async_local_storage"),hL=new pL,mL=class{getInstance(){return globalThis[ff]??hL}initializeGlobalInstance(e){globalThis[ff]===void 0&&(globalThis[ff]=e)}},fL=new mL;function gL(e=!1){let t=fL.getInstance().getStore();if(!e&&t===void 0)throw new Error(`Could not get the current run tree.
|
|
62
|
+
|
|
63
|
+
Please make sure you are calling this method within a traceable function and that tracing is enabled.`);return t}function U_(e){return typeof e=="function"&&"langsmith:traceable"in e}var yL=G({LangChainTracer:()=>So,OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS:()=>L_}),L_=new Set(["ls_agent_type"]);function _L(e){let t;for(let n of e)for(let r of n)Le.isInstance(r.message)&&r.message.usage_metadata!==void 0&&(t=A_(t,r.message.usage_metadata));return t}var So=class Og extends ei{name="langchain_tracer";projectName;exampleId;client;replicas;usesRunTreeMap=!0;tracingMetadata;tracingTags=[];constructor(t={}){super(t),this.fields=t;let{exampleId:n,projectName:r,client:i,replicas:s,metadata:a,tags:o}=t;this.projectName=r??P1(),this.replicas=s,this.exampleId=n,this.client=i??nI(),this.tracingMetadata=a?{...a}:void 0,this.tracingTags=o??[];let c=Og.getTraceableRunTree();c&&this.updateFromRunTree(c)}async persistRun(t){}async onRunCreate(t){Pk(this,t),t.extra?.lc_defers_inputs||await this.getRunTreeWithTracingConfig(t.id)?.postRun()}async onRunUpdate(t){Pk(this,t);let n=this.getRunTreeWithTracingConfig(t.id);t.extra?.lc_defers_inputs?await n?.postRun():await n?.patchRun()}onLLMEnd(t){let n=t.outputs;if(n?.generations){let r=_L(n.generations);if(r!==void 0){t.extra=t.extra??{};let i=t.extra.metadata??{};i.usage_metadata=r,t.extra.metadata=i}}}copyWithTracingConfig({metadata:t,tags:n}){let r;if(t===void 0)r=this.tracingMetadata?{...this.tracingMetadata}:void 0;else if(this.tracingMetadata===void 0)r={...t};else{r={...this.tracingMetadata};for(let[a,o]of Object.entries(t))(!Object.prototype.hasOwnProperty.call(r,a)||L_.has(a))&&(r[a]=o)}let i=n?Array.from(new Set([...this.tracingTags,...n])):[...this.tracingTags],s=new Og({...this.fields,metadata:r,tags:i});return s.runMap=this.runMap,s.runTreeMap=this.runTreeMap,s}getRun(t){return this.runTreeMap.get(t)}updateFromRunTree(t){this.runTreeMap.set(t.id,t);let n=t,r=new Set;for(;n.parent_run&&!(r.has(n.id)||(r.add(n.id),!n.parent_run));)n=n.parent_run;r.clear();let i=[n];for(;i.length>0;){let s=i.shift();!s||r.has(s.id)||(r.add(s.id),this.runTreeMap.set(s.id,s),s.child_runs&&i.push(...s.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,this.fields={...this.fields,client:this.client,replicas:this.replicas,projectName:this.projectName,exampleId:this.exampleId}}getRunTreeWithTracingConfig(t){let n=this.runTreeMap.get(t);if(n)return new xa({...n,client:this.client,project_name:this.projectName,replicas:this.replicas,reference_example_id:this.exampleId,tracingEnabled:!0})}static getTraceableRunTree(){try{return gL(!0)}catch{return}}static[Symbol.hasInstance](t){if(typeof t!="object"||t===null)return!1;let n=t;return"name"in n&&n.name==="langchain_tracer"&&"copyWithTracingConfig"in n&&typeof n.copyWithTracingConfig=="function"&&"getRunTreeWithTracingConfig"in n&&typeof n.getRunTreeWithTracingConfig=="function"}};function Pk(e,t){if(e.tracingMetadata){t.extra??={};let n=t.extra.metadata??{},r=!1;for(let[i,s]of Object.entries(e.tracingMetadata))(!Object.prototype.hasOwnProperty.call(n,i)||L_.has(i))&&n[i]!==s&&(n[i]=s,r=!0);r&&(t.extra.metadata=n)}e.tracingTags.length>0&&(t.tags=Array.from(new Set([...t.tags??[],...e.tracingTags])))}var rI=Symbol.for("ls:tracing_async_local_storage"),Jo=Symbol.for("lc:context_variables"),vL=e=>{globalThis[rI]=e},rc=()=>globalThis[rI],cs;function bL(){return new("default"in Jr?Jr.default:Jr)({autoStart:!0,concurrency:1})}function wL(){return typeof cs>"u"&&(cs=bL()),cs}async function st(e,t){if(t===!0){let n=rc();n!==void 0?await n.run(void 0,async()=>e()):await e()}else cs=wL(),cs.add(async()=>{let n=rc();n!==void 0?await n.run(void 0,async()=>e()):await e()})}async function kL(){let e=nI();await Promise.allSettled([typeof cs<"u"?cs.onIdle():Promise.resolve(),e.awaitPendingTraceBatches()])}var xL=G({awaitAllCallbacks:()=>kL,consumeCallback:()=>st}),$L=e=>!!["LANGSMITH_TRACING_V2","LANGCHAIN_TRACING_V2","LANGSMITH_TRACING","LANGCHAIN_TRACING"].find(t=>bn(t)==="true");function iI(e){let t=rc();if(t!==void 0)return t.getStore()?.[Jo]?.[e]}var IL=Symbol("lc:configure_hooks"),SL=()=>iI(IL)||[],OL=G({BaseCallbackManager:()=>sI,BaseRunManager:()=>eu,CallbackManager:()=>Ft,CallbackManagerForChainRun:()=>oI,CallbackManagerForLLMRun:()=>Ag,CallbackManagerForRetrieverRun:()=>aI,CallbackManagerForToolRun:()=>cI,ensureHandler:()=>ic,parseCallbackConfigArg:()=>Qc});function Qc(e){return e?Array.isArray(e)||"name"in e?{callbacks:e}:e:{}}var sI=class{setHandler(e){return this.setHandlers([e])}},eu=class{constructor(e,t,n,r,i,s,a,o){this.runId=e,this.handlers=t,this.inheritableHandlers=n,this.tags=r,this.inheritableTags=i,this.metadata=s,this.inheritableMetadata=a,this._parentRunId=o}get parentRunId(){return this._parentRunId}async handleText(e){await Promise.all(this.handlers.map(t=>st(async()=>{try{await t.handleText?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleText: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}async handleCustomEvent(e,t,n,r,i){await Promise.all(this.handlers.map(s=>st(async()=>{try{await s.handleCustomEvent?.(e,t,this.runId,this.tags,this.metadata)}catch(a){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleCustomEvent: ${a}`),s.raiseError)throw a}},s.awaitHandlers)))}},aI=class extends eu{getChild(e){let t=new Ft(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=>st(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetriever`),t.raiseError)throw n}},t.awaitHandlers)))}async handleRetrieverError(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreRetriever)try{await t.handleRetrieverError?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleRetrieverError: ${n}`),t.raiseError)throw e}},t.awaitHandlers)))}},Ag=class extends eu{async handleLLMNewToken(e,t,n,r,i,s){await Promise.all(this.handlers.map(a=>st(async()=>{if(!a.ignoreLLM)try{await a.handleLLMNewToken?.(e,t??{prompt:0,completion:0},this.runId,this._parentRunId,this.tags,s)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleLLMNewToken: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}async handleChatModelStreamEvent(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreLLM)try{await t.handleChatModelStreamEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleChatModelStreamEvent: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}async handleLLMError(e,t,n,r,i){await Promise.all(this.handlers.map(s=>st(async()=>{if(!s.ignoreLLM)try{await s.handleLLMError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleLLMError: ${a}`),s.raiseError)throw a}},s.awaitHandlers)))}async handleLLMEnd(e,t,n,r,i){await Promise.all(this.handlers.map(s=>st(async()=>{if(!s.ignoreLLM)try{await s.handleLLMEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleLLMEnd: ${a}`),s.raiseError)throw a}},s.awaitHandlers)))}},oI=class extends eu{getChild(e){let t=new Ft(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,n,r,i){await Promise.all(this.handlers.map(s=>st(async()=>{if(!s.ignoreChain)try{await s.handleChainError?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleChainError: ${a}`),s.raiseError)throw a}},s.awaitHandlers)))}async handleChainEnd(e,t,n,r,i){await Promise.all(this.handlers.map(s=>st(async()=>{if(!s.ignoreChain)try{await s.handleChainEnd?.(e,this.runId,this._parentRunId,this.tags,i)}catch(a){if((s.raiseError?console.error:console.warn)(`Error in handler ${s.constructor.name}, handleChainEnd: ${a}`),s.raiseError)throw a}},s.awaitHandlers)))}async handleAgentAction(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreAgent)try{await t.handleAgentAction?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentAction: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}async handleAgentEnd(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreAgent)try{await t.handleAgentEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleAgentEnd: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}},cI=class extends eu{getChild(e){let t=new Ft(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=>st(async()=>{if(!t.ignoreAgent)try{await t.handleToolError?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolError: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}async handleToolEvent(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreAgent)try{await t.handleToolEvent?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if(t.raiseError)throw n}},t.awaitHandlers)))}async handleToolEnd(e){await Promise.all(this.handlers.map(t=>st(async()=>{if(!t.ignoreAgent)try{await t.handleToolEnd?.(e,this.runId,this._parentRunId,this.tags)}catch(n){if((t.raiseError?console.error:console.warn)(`Error in handler ${t.constructor.name}, handleToolEnd: ${n}`),t.raiseError)throw n}},t.awaitHandlers)))}},Ft=class Oo extends sI{handlers=[];inheritableHandlers=[];tags=[];inheritableTags=[];metadata={};inheritableMetadata={};name="callback_manager";_parentRunId;constructor(t,n){super(),this.handlers=n?.handlers??this.handlers,this.inheritableHandlers=n?.inheritableHandlers??this.inheritableHandlers,this.tags=n?.tags??this.tags,this.inheritableTags=n?.inheritableTags??this.inheritableTags,this.metadata=n?.metadata??this.metadata,this.inheritableMetadata=n?.inheritableMetadata??this.inheritableMetadata,this._parentRunId=t}getParentRunId(){return this._parentRunId}async handleLLMStart(t,n,r=void 0,i=void 0,s=void 0,a=void 0,o=void 0,c=void 0){return Promise.all(n.map(async(u,l)=>{let d=l===0&&r?r:Ur();return await Promise.all(this.handlers.map(p=>{if(!p.ignoreLLM)return Ws(p)&&p._createRunForLLMStart(t,[u],d,this._parentRunId,s,this.tags,this.metadata,c),st(async()=>{try{await p.handleLLMStart?.(t,[u],d,this._parentRunId,s,this.tags,this.metadata,c)}catch(h){if((p.raiseError?console.error:console.warn)(`Error in handler ${p.constructor.name}, handleLLMStart: ${h}`),p.raiseError)throw h}},p.awaitHandlers)})),new Ag(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChatModelStart(t,n,r=void 0,i=void 0,s=void 0,a=void 0,o=void 0,c=void 0){return Promise.all(n.map(async(u,l)=>{let d=l===0&&r?r:Ur();return await Promise.all(this.handlers.map(p=>{if(!p.ignoreLLM)return Ws(p)&&p._createRunForChatModelStart(t,[u],d,this._parentRunId,s,this.tags,this.metadata,c),st(async()=>{try{if(p.handleChatModelStart)await p.handleChatModelStart?.(t,[u],d,this._parentRunId,s,this.tags,this.metadata,c);else if(p.handleLLMStart){let h=T_(u);await p.handleLLMStart?.(t,[h],d,this._parentRunId,s,this.tags,this.metadata,c)}}catch(h){if((p.raiseError?console.error:console.warn)(`Error in handler ${p.constructor.name}, handleLLMStart: ${h}`),p.raiseError)throw h}},p.awaitHandlers)})),new Ag(d,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}))}async handleChainStart(t,n,r=Ur(),i=void 0,s=void 0,a=void 0,o=void 0,c=void 0,u=void 0){return await Promise.all(this.handlers.map(l=>{if(!l.ignoreChain)return Ws(l)&&l._createRunForChainStart(t,n,r,this._parentRunId,this.tags,this.metadata,i,o,u),st(async()=>{try{await l.handleChainStart?.(t,n,r,this._parentRunId,this.tags,this.metadata,i,o,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 oI(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleToolStart(t,n,r=Ur(),i=void 0,s=void 0,a=void 0,o=void 0,c=void 0){return await Promise.all(this.handlers.map(u=>{if(!u.ignoreAgent)return Ws(u)&&u._createRunForToolStart(t,n,r,this._parentRunId,this.tags,this.metadata,o),st(async()=>{try{await u.handleToolStart?.(t,n,r,this._parentRunId,this.tags,this.metadata,o,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 cI(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleRetrieverStart(t,n,r=Ur(),i=void 0,s=void 0,a=void 0,o=void 0){return await Promise.all(this.handlers.map(c=>{if(!c.ignoreRetriever)return Ws(c)&&c._createRunForRetrieverStart(t,n,r,this._parentRunId,this.tags,this.metadata,o),st(async()=>{try{await c.handleRetrieverStart?.(t,n,r,this._parentRunId,this.tags,this.metadata,o)}catch(u){if((c.raiseError?console.error:console.warn)(`Error in handler ${c.constructor.name}, handleRetrieverStart: ${u}`),c.raiseError)throw u}},c.awaitHandlers)})),new aI(r,this.handlers,this.inheritableHandlers,this.tags,this.inheritableTags,this.metadata,this.inheritableMetadata,this._parentRunId)}async handleCustomEvent(t,n,r,i,s){await Promise.all(this.handlers.map(a=>st(async()=>{if(!a.ignoreCustomEvent)try{await a.handleCustomEvent?.(t,n,r,this.tags,this.metadata)}catch(o){if((a.raiseError?console.error:console.warn)(`Error in handler ${a.constructor.name}, handleCustomEvent: ${o}`),a.raiseError)throw o}},a.awaitHandlers)))}addHandler(t,n=!0){this.handlers.push(t),n&&this.inheritableHandlers.push(t)}removeHandler(t){this.handlers=this.handlers.filter(n=>n!==t),this.inheritableHandlers=this.inheritableHandlers.filter(n=>n!==t)}setHandlers(t,n=!0){this.handlers=[],this.inheritableHandlers=[];for(let r of t)this.addHandler(r,n)}addTags(t,n=!0){this.removeTags(t),this.tags.push(...t),n&&this.inheritableTags.push(...t)}removeTags(t){this.tags=this.tags.filter(n=>!t.includes(n)),this.inheritableTags=this.inheritableTags.filter(n=>!t.includes(n))}addMetadata(t,n=!0){this.metadata={...this.metadata,...t},n&&(this.inheritableMetadata={...this.inheritableMetadata,...t})}removeMetadata(t){for(let n of Object.keys(t))delete this.metadata[n],delete this.inheritableMetadata[n]}copy(t=[],n=!0){let r=new Oo(this._parentRunId);for(let i of this.handlers){let s=this.inheritableHandlers.includes(i);r.addHandler(i,s)}for(let i of this.tags){let s=this.inheritableTags.includes(i);r.addTags([i],s)}for(let i of Object.keys(this.metadata)){let s=Object.keys(this.inheritableMetadata).includes(i);r.addMetadata({[i]:this.metadata[i]},s)}for(let i of t)r.handlers.filter(s=>s.name==="console_callback_handler").some(s=>s.name===i.name)||r.addHandler(i,n);return r}static fromHandlers(t){class n extends Li{name=Ur();constructor(){super(),Object.assign(this,t)}}let r=new this;return r.addHandler(new n),r}static configure(t,n,r,i,s,a,o){return this._configureSync(t,n,r,i,s,a,o)}static _configureSync(t,n,r,i,s,a,o){let c;(t||n)&&(Array.isArray(t)||!t?(c=new Oo,c.setHandlers(t?.map(ic)??[],!0)):c=t,c=c.copy(Array.isArray(n)?n.map(ic):n?.handlers,!1));let u=bn("LANGCHAIN_VERBOSE")==="true"||o?.verbose,l=So.getTraceableRunTree(),d=l?.tracingEnabled??$L();if(l?.tracingEnabled===!1&&c){let f=c.handlers.filter(v=>v.name==="langchain_tracer");for(let v of f)c.removeHandler(v)}let p=d||(bn("LANGCHAIN_TRACING")??!1);if(u||p){if(c||(c=new Oo),u&&!c.handlers.some(f=>f.name===Sg.prototype.name)){let f=new Sg;c.addHandler(f,!0)}if(p&&!c.handlers.some(f=>f.name==="langchain_tracer")&&d){let f=new So;c.addHandler(f,!0)}d&&l&&c._parentRunId===void 0&&(c._parentRunId=l.id,c.handlers.find(f=>f.name==="langchain_tracer")?.updateFromRunTree(l))}for(let{contextVar:f,inheritable:v=!0,handlerClass:g,envVar:y}of SL()){let w=y&&bn(y)==="true"&&g,x,O=f!==void 0?iI(f):void 0;O&&E1(O)?x=O:w&&(x=new g({})),x!==void 0&&(c||(c=new Oo),c.handlers.some(z=>z.name===x.name)||c.addHandler(x,v))}(r||i)&&c&&(c.addTags(r??[]),c.addTags(i??[],!1)),(s||a)&&c&&(c.addMetadata(s??{}),c.addMetadata(a??{},!1));let h=o?.tracerInheritableMetadata,m=o?.tracerInheritableTags;return c&&(h||m)&&(c.handlers=c.handlers.map(f=>f instanceof So?f.copyWithTracingConfig({metadata:h,tags:m}):f),c.inheritableHandlers=c.inheritableHandlers.map(f=>f instanceof So?f.copyWithTracingConfig({metadata:h,tags:m}):f)),c}};function ic(e){return"name"in e?e:Li.fromMethods(e)}var uI=class{getStore(){}run(e,t){return t()}enterWith(e){}},AL=new uI,jk=Symbol.for("lc:child_config"),TL=class{getInstance(){return rc()??AL}getRunnableConfig(){return this.getInstance().getStore()?.extra?.[jk]}runWithConfig(e,t,n){let r=Ft._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),s=i.getStore(),a=r?.getParentRunId(),o=r?.handlers?.find(u=>u?.name==="langchain_tracer"),c;return o&&a?c=o.getRunTreeWithTracingConfig(a):n||(c=new xa({name:"<runnable_lambda>",tracingEnabled:!1})),c&&(c.extra={...c.extra,[jk]:e}),s!==void 0&&s[Jo]!==void 0&&(c===void 0&&(c={}),c[Jo]=s[Jo]),i.run(c,t)}initializeGlobalInstance(e){rc()===void 0&&vL(e)}},jt=new TL,EL=G({AsyncLocalStorageProviderSingleton:()=>jt,MockAsyncLocalStorage:()=>uI,_CONTEXT_VARIABLES_KEY:()=>Jo}),CL=new Set(["api_key"]),NL=new Set(["string","number","boolean"]);function PL(e){let t=e.configurable??{},n=e.metadata??{},r={};for(let[i,s]of Object.entries(t))!i.startsWith("__")&&!Object.prototype.hasOwnProperty.call(n,i)&&!CL.has(i)&&NL.has(typeof s)&&(r[i]=s);return Object.keys(r).length>0?r:void 0}async function on(e){return Ft._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata,void 0,{tracerInheritableMetadata:e?PL(e):void 0})}function Nn(...e){let t={};for(let n of e.filter(r=>!!r))for(let r of Object.keys(n))if(r==="metadata")t[r]={...t[r],...n[r]};else if(r==="tags"){let i=t[r]??[];t[r]=[...new Set(i.concat(n[r]??[]))]}else if(r==="configurable")t[r]={...t[r],...n[r]};else if(r==="timeout")t.timeout===void 0?t.timeout=n.timeout:n.timeout!==void 0&&(t.timeout=Math.min(t.timeout,n.timeout));else if(r==="signal")t.signal===void 0?t.signal=n.signal:n.signal!==void 0&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,n.signal]):t.signal=n.signal);else if(r==="callbacks"){let i=t.callbacks,s=n.callbacks;if(Array.isArray(s))if(!i)t.callbacks=s;else if(Array.isArray(i))t.callbacks=i.concat(s);else{let a=i.copy();for(let o of s)a.addHandler(ic(o),!0);t.callbacks=a}else if(s)if(!i)t.callbacks=s;else if(Array.isArray(i)){let a=s.copy();for(let o of i)a.addHandler(ic(o),!0);t.callbacks=a}else t.callbacks=new Ft(s._parentRunId,{handlers:i.handlers.concat(s.handlers),inheritableHandlers:i.inheritableHandlers.concat(s.inheritableHandlers),tags:Array.from(new Set(i.tags.concat(s.tags))),inheritableTags:Array.from(new Set(i.inheritableTags.concat(s.inheritableTags))),metadata:{...i.metadata,...s.metadata}})}else{let i=r;t[i]=n[i]??t[i]}return t}function Te(e){let t=jt.getRunnableConfig(),n={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){let{runId:r,runName:i,...s}=t;n=Object.entries(s).reduce((a,[o,c])=>(c!==void 0&&(a[o]=c),a),n)}if(e&&(n=Object.entries(e).reduce((r,[i,s])=>(s!==void 0&&(r[i]=s),r),n)),n?.configurable&&typeof n.configurable.model=="string"&&n.metadata?.model===void 0&&(n.metadata||(n.metadata={}),n.metadata.model=n.configurable.model),n.timeout!==void 0){if(n.timeout<=0)throw new Error("Timeout must be a positive number");let r=n.timeout,i=AbortSignal.timeout(r);n.metadata||(n.metadata={}),n.metadata.timeoutMs===void 0&&(n.metadata.timeoutMs=r),n.signal!==void 0?"any"in AbortSignal&&(n.signal=AbortSignal.any([n.signal,i])):n.signal=i,delete n.timeout}return n}function Re(e={},{callbacks:t,maxConcurrency:n,recursionLimit:r,runName:i,configurable:s,runId:a}={}){let o=Te(e);return t!==void 0&&(delete o.runName,o.callbacks=t),r!==void 0&&(o.recursionLimit=r),n!==void 0&&(o.maxConcurrency=n),i!==void 0&&(o.runName=i),s!==void 0&&(o.configurable={...o.configurable,...s}),a!==void 0&&delete o.runId,o}function Kr(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 Sr(e,t){if(t===void 0)return e;let n;return Promise.race([e.catch(r=>{if(!t?.aborted)throw r}),new Promise((r,i)=>{n=()=>{i(sc(t))},t.addEventListener("abort",n,{once:!0}),t.aborted&&i(sc(t))})]).finally(()=>t.removeEventListener("abort",n))}function sc(e){return e?.reason instanceof Error?e.reason:typeof e?.reason=="string"?new Error(e.reason):new Error("Aborted")}var jL=G({AsyncGeneratorWithSetup:()=>Ts,IterableReadableStream:()=>un,atee:()=>z_,concat:()=>Ii,pipeGeneratorWithSetup:()=>lI}),un=class Tg 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 n=this.reader.cancel();this.reader.releaseLock(),await n}throw t}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(t){let n=t.getReader();return new Tg({start(r){return i();function i(){return n.read().then(({done:s,value:a})=>{if(s){r.close();return}return r.enqueue(a),i()})}},cancel(){n.releaseLock()}})}static fromAsyncGenerator(t){return new Tg({async pull(n){let{value:r,done:i}=await t.next();i&&n.close(),n.enqueue(r)},async cancel(n){await t.return(n)}})}};function z_(e,t=2){let n=Array.from({length:t},()=>[]);return n.map(async function*(r){for(;;)if(r.length===0){let i=await e.next();for(let s of n)s.push(i)}else{if(r[0].done)return;yield r.shift().value}})}function Ii(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if(typeof e=="string"&&typeof t=="string"||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 n={...e};for(let[r,i]of Object.entries(t))r in n&&!Array.isArray(n[r])?n[r]=Ii(n[r],i):n[r]=i;return n}else throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}var Ts=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,n)=>{jt.runWithConfig(Kr(e.config),async()=>{this.firstResult=this.signal?Sr(e.generator.next(),this.signal):e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,n):this.firstResult.then(r=>t(void 0),n)},!0)})}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?jt.runWithConfig(Kr(this.config),this.signal?async()=>Sr(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 lI(e,t,n,r,...i){let s=new Ts({generator:t,startSetup:n,signal:r}),a=await s.setup;return{output:e(s,a,...i),setup:a}}var RL=Object.prototype.hasOwnProperty;function Eg(e,t){return RL.call(e,t)}function Cg(e){if(Array.isArray(e)){let n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=""+r;return n}if(Object.keys)return Object.keys(e);let t=[];for(let n in e)Eg(e,n)&&t.push(n);return t}function Yn(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Ng(e){let t=0,n=e.length,r;for(;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function Fs(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function ML(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Pg(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Pg(e[n]))return!0}else if(typeof e=="object"){let n=Cg(e),r=n.length;for(var t=0;t<r;t++)if(Pg(e[n[t]]))return!0}}return!1}function Rk(e,t){let n=[e];for(let r in t){let i=typeof t[r]=="object"?JSON.stringify(t[r],null,2):t[r];typeof i<"u"&&n.push(`${r}: ${i}`)}return n.join(`
|
|
64
|
+
`)}var UL=class extends Error{constructor(e,t,n,r,i){super(Rk(e,{name:t,index:n,operation:r,tree:i})),this.name=t,this.index=n,this.operation=r,this.tree=i,Object.setPrototypeOf(this,new.target.prototype),this.message=Rk(e,{name:t,index:n,operation:r,tree:i})}},LL=G({JsonPatchError:()=>rt,_areEquals:()=>ac,applyOperation:()=>us,applyPatch:()=>$a,applyReducer:()=>FL,deepClone:()=>zL,getValueByPointer:()=>bd,validate:()=>dI,validator:()=>wd}),rt=UL,zL=Yn,oa={add:function(e,t,n){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:n}},remove:function(e,t,n){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){if(t==="__proto__"||t==="constructor")throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor` prop is banned for security reasons");var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){let r=bd(n,this.path);r&&(r=Yn(r));let i=us(n,{op:"remove",path:this.from}).removed;return us(n,{op:"add",path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){let r=bd(n,this.from);return us(n,{op:"add",path:this.path,value:Yn(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:ac(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},DL={add:function(e,t,n){return Ng(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:oa.move,copy:oa.copy,test:oa.test,_get:oa._get};function bd(e,t){if(t=="")return e;var n={op:"_get",path:t};return us(e,n),n.value}function us(e,t,n=!1,r=!0,i=!0,s=0){if(n&&(typeof n=="function"?n(t,0,e,t.path):wd(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=bd(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=ac(e,t.value),a.test===!1)throw new rt("Test operation failed","TEST_OPERATION_FAILED",s,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(n)throw new rt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,t,e);return a}}else{r||(e=Yn(e));let a=(t.path||"").split("/"),o=e,c=1,u=a.length,l,d,p;for(typeof n=="function"?p=n:p=wd;;){if(d=a[c],d&&d.indexOf("~")!=-1&&(d=ML(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(n&&l===void 0&&(o[d]===void 0?l=a.slice(0,c).join("/"):c==u-1&&(l=t.path),l!==void 0&&p(t,0,e,l)),c++,Array.isArray(o)){if(d==="-")d=o.length;else{if(n&&!Ng(d))throw new rt("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",s,t,e);Ng(d)&&(d=~~d)}if(c>=u){if(n&&t.op==="add"&&d>o.length)throw new rt("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,t,e);let h=DL[t.op].call(t,o,d,e);if(h.test===!1)throw new rt("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return h}}else if(c>=u){let h=oa[t.op].call(t,o,d,e);if(h.test===!1)throw new rt("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return h}if(o=o[d],n&&c<u&&(!o||typeof o!="object"))throw new rt("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,t,e)}}}function $a(e,t,n,r=!0,i=!0){if(n&&!Array.isArray(t))throw new rt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(e=Yn(e));let s=new Array(t.length);for(let a=0,o=t.length;a<o;a++)s[a]=us(e,t[a],n,!0,i,a),e=s[a].newDocument;return s.newDocument=e,s}function FL(e,t,n){let r=us(e,t);if(r.test===!1)throw new rt("Test operation failed","TEST_OPERATION_FAILED",n,t,e);return r.newDocument}function wd(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))throw new rt("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,n);if(oa[e.op]){if(typeof e.path!="string")throw new rt("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,n);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new rt('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new rt("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new rt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Pg(e.value))throw new rt("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var i=e.path.split("/").length,s=r.split("/").length;if(i!==s+1&&i!==s)throw new rt("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==r)throw new rt("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var a=dI([{op:"_get",path:e.from,value:void 0}],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new rt("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new rt("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function dI(e,t,n){try{if(!Array.isArray(e))throw new rt("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)$a(Yn(t),Yn(e),n||!0);else{n=n||wd;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(i){if(i instanceof rt)return i;throw i}}function ac(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=Array.isArray(e),r=Array.isArray(t),i,s,a;if(n&&r){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!ac(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var o=Object.keys(e);if(s=o.length,s!==Object.keys(t).length)return!1;for(i=s;i--!==0;)if(!t.hasOwnProperty(o[i]))return!1;for(i=s;i--!==0;)if(a=o[i],!ac(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}function pI(e,t,n,r,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var s=Cg(t),a=Cg(e),o=!1,c=a.length-1;c>=0;c--){var u=a[c],l=e[u];if(Eg(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)?pI(l,d,n,r+"/"+Fs(u),i):l!==d&&(i&&n.push({op:"test",path:r+"/"+Fs(u),value:Yn(l)}),n.push({op:"replace",path:r+"/"+Fs(u),value:Yn(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:"test",path:r+"/"+Fs(u),value:Yn(l)}),n.push({op:"remove",path:r+"/"+Fs(u)}),o=!0):(i&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:t}))}if(!(!o&&s.length==a.length))for(var c=0;c<s.length;c++){var u=s[c];!Eg(e,u)&&t[u]!==void 0&&n.push({op:"add",path:r+"/"+Fs(u),value:Yn(t[u])})}}}function vh(e,t,n=!1){var r=[];return pI(e,t,r,"",n),r}({...LL});var ZL=G({LogStreamCallbackHandler:()=>Rg,RunLog:()=>D_,RunLogPatch:()=>zr,isLogStreamHandler:()=>hI}),zr=class{ops;constructor(e){this.ops=e.ops??[]}concat(e){let t=this.ops.concat(e.ops),n=$a({},t);return new D_({ops:t,state:n[n.length-1].newDocument})}},D_=class jg extends zr{state;constructor(t){super(t),this.state=t.state}concat(t){let n=this.ops.concat(t.ops),r=$a(this.state,t.ops);return new jg({ops:n,state:r[r.length-1].newDocument})}static fromRunLogPatch(t){let n=$a({},t.ops);return new jg({ops:t.ops,state:n[n.length-1].newDocument})}},hI=e=>e.name==="log_stream_tracer";async function Mk(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:n}=e;if(["retriever","llm","prompt"].includes(e.run_type))return n;if(!(Object.keys(n).length===1&&n?.input===""))return n.input}async function Uk(e,t){let{outputs:n}=e;return t==="original"||["retriever","llm","prompt"].includes(e.run_type)?n:n!==void 0&&Object.keys(n).length===1&&n?.output!==void 0?n.output:n}function BL(e){return e!==void 0&&e.message!==void 0}var Rg=class extends ei{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=un.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??[],n=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(n=n||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(n=n||this.includeTypes.includes(e.run_type)),this.includeTags!==void 0&&(n=n||t.find(r=>this.includeTags?.includes(r))!==void 0),this.excludeNames!==void 0&&(n=n&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(n=n&&!this.excludeTypes.includes(e.run_type)),this.excludeTags!==void 0&&(n=n&&t.every(r=>!this.excludeTags?.includes(r))),n}async*tapOutputIterable(e,t){for await(let n of t){if(e!==this.rootId){let r=this.keyMapByRunId[e];r&&await this.writer.write(new zr({ops:[{op:"add",path:`/logs/${r}/streamed_output/-`,value:n}]}))}yield n}}async onRunCreate(e){if(this.rootId===void 0&&(this.rootId=e.id,await this.writer.write(new zr({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 n={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"&&(n.inputs=await Mk(e,this._schemaFormat)),await this.writer.write(new zr({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:n}]}))}async onRunUpdate(e){try{let t=this.keyMapByRunId[e.id];if(t===void 0)return;let n=[];this._schemaFormat==="streaming_events"&&n.push({op:"replace",path:`/logs/${t}/inputs`,value:await Mk(e,this._schemaFormat)}),n.push({op:"add",path:`/logs/${t}/final_output`,value:await Uk(e,this._schemaFormat)}),e.end_time!==void 0&&n.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});let r=new zr({ops:n});await this.writer.write(r)}finally{if(e.id===this.rootId){let t=new zr({ops:[{op:"replace",path:"/final_output",value:await Uk(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,n){let r=this.keyMapByRunId[e.id];if(r===void 0)return;let i=e.inputs.messages!==void 0,s;i?BL(n?.chunk)?s=n?.chunk:s=new Pt({id:`run-${e.id}`,content:t}):s=t;let a=new zr({ops:[{op:"add",path:`/logs/${r}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${r}/streamed_output/-`,value:s}]});await this.writer.write(a)}},qL=G({ChatGenerationChunk:()=>Wr,GenerationChunk:()=>Ia,RUN_KEY:()=>oc}),oc="__run",Ia=class mI{text;generationInfo;constructor(t){this.text=t.text,this.generationInfo=t.generationInfo}concat(t){return new mI({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo}})}},Wr=class fI extends Ia{message;constructor(t){super(t),this.message=t.message}concat(t){return new fI({text:this.text+t.text,generationInfo:{...this.generationInfo,...t.generationInfo},message:this.message.concat(t.message)})}},JL=Object.prototype.toString,HL=e=>JL.call(e)==="[object Error]",VL=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 KL(e){if(!(e&&HL(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:t,stack:n}=e;return t==="Load failed"?n===void 0||"__sentry_captured__"in e:t.startsWith("error sending request for url")?!0:VL.has(t)}function WL(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 cl(e,t,{min:n=0,allowInfinity:r=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${r?" or Infinity":""}.`);if(!r&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<n)throw new TypeError(`Expected \`${e}\` to be \u2265 ${n}.`)}}var GL=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 XL(e,t){let n=Math.max(1,e+1),r=t.randomize?Math.random()+1:1,i=Math.round(r*t.minTimeout*t.factor**(n-1));return i=Math.min(i,t.maxTimeout),i}function Lk(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function YL({error:e,attemptNumber:t,retriesConsumed:n,startTime:r,options:i}){let s=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(s instanceof GL)throw s.originalError;let a=Number.isFinite(i.retries)?Math.max(0,i.retries-n):i.retries,o=i.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:s,attemptNumber:t,retriesLeft:a,retriesConsumed:n});if(await i.onFailedAttempt(c),Lk(r,o)<=0)throw s;let u=await i.shouldConsumeRetry(c),l=Lk(r,o);if(l<=0||a<=0)throw s;if(s instanceof TypeError&&!KL(s)){if(u)throw s;return i.signal?.throwIfAborted(),!1}if(!await i.shouldRetry(c))throw s;if(!u)return i.signal?.throwIfAborted(),!1;let d=XL(n,i),p=Math.min(d,l);return p>0&&await new Promise((h,m)=>{let f=()=>{clearTimeout(v),i.signal?.removeEventListener("abort",f),m(i.signal.reason)},v=setTimeout(()=>{i.signal?.removeEventListener("abort",f),h()},p);i.unref&&v.unref?.(),i.signal?.addEventListener("abort",f,{once:!0})}),i.signal?.throwIfAborted(),!0}async function Mg(e,t={}){if(t={...t},WL(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,cl("factor",t.factor,{min:0,allowInfinity:!1}),cl("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),cl("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),cl("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let n=0,r=0,i=performance.now();for(;!Number.isFinite(t.retries)||r<=t.retries;){n++;try{t.signal?.throwIfAborted();let s=await e(n);return t.signal?.throwIfAborted(),s}catch(s){await YL({error:s,attemptNumber:n,retriesConsumed:r,startTime:i,options:t})&&r++}}throw new Error("Retry attempts exhausted without throwing an error.")}var QL=G({AsyncCaller:()=>tu}),ez=[400,401,402,403,404,405,406,407,409],tz=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,n="status"in e&&typeof e.status=="number"?e.status:void 0,r=t??n;if(r&&ez.includes(+r))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}},tu=class{maxConcurrency;maxRetries;onFailedAttempt;queue;constructor(e){this.maxConcurrency=e.maxConcurrency??1/0,this.maxRetries=e.maxRetries??6,this.onFailedAttempt=e.onFailedAttempt??tz;let t="default"in Jr?Jr.default:Jr;this.queue=new t({concurrency:this.maxConcurrency})}async call(e,...t){return this.queue.add(()=>Mg(()=>e(...t).catch(n=>{throw n instanceof Error?n:new Error(n)}),{onFailedAttempt:({error:n})=>this.onFailedAttempt?.(n),retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0})}callWithOptions(e,t,...n){if(e.signal){let r;return Promise.race([this.call(t,...n),new Promise((i,s)=>{r=()=>{s(sc(e.signal))},e.signal?.addEventListener("abort",r,{once:!0})})]).finally(()=>{e.signal&&r&&e.signal.removeEventListener("abort",r)})}return this.call(t,...n)}fetch(...e){return this.call(()=>fetch(...e).then(t=>t.ok?t:Promise.reject(t)))}},nz=G({isSerializableSchema:()=>gs,isStandardJsonSchema:()=>F_,isStandardSchema:()=>gI});function gI(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 F_(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 gs(e){return gI(e)&&F_(e)}var zk,yI=Object.freeze({status:"aborted"});function $(e,t,n){function r(o,c){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in o||(o[p]=u[p].bind(o))}}let i=n?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var c;let u=n?.Parent?new s:this;r(u,o),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>n?.Parent&&o instanceof n.Parent?!0:o?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var _I=Symbol("zod_brand"),Hr=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Sa=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(zk=globalThis).__zod_globalConfig??(zk.__zod_globalConfig={});var cc=globalThis.__zod_globalConfig;function Rt(e){return e&&Object.assign(cc,e),cc}function rz(e){return e}function iz(e){return e}function sz(e){}function az(e){throw new Error("Unexpected value in exhaustive check")}function oz(e){}function Z_(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function M(e,t="|"){return e.map(n=>ce(n)).join(t)}function kd(e,t){return typeof t=="bigint"?t.toString():t}function nu(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Es(e){return e==null}function bh(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function vI(e,t){let n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Dk=Symbol("evaluating");function $e(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Dk)return r===void 0&&(r=Dk,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function cz(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function zi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ar(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function uz(e){return Ar(e._zod.def)}function lz(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function dz(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let i={};for(let s=0;s<t.length;s++)i[t[s]]=r[s];return i})}function pz(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Ug(e){return JSON.stringify(e)}function bI(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var B_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Oa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var wI=nu(()=>{if(cc.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function ys(e){if(Oa(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Oa(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function wh(e){return ys(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function hz(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var mz=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}`)}},xd=new Set(["string","number","symbol"]),kI=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function P(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 fz(e){let t;return new Proxy({},{get(n,r,i){return t??(t=e()),Reflect.get(t,r,i)},set(n,r,i,s){return t??(t=e()),Reflect.set(t,r,i,s)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??(t=e()),Reflect.defineProperty(t,r,i)}})}function ce(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function xI(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var $I={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]},II={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function SI(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Ar(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return zi(this,"shape",s),s},checks:[]});return ut(e,i)}function OI(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Ar(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return zi(this,"shape",s),s},checks:[]});return ut(e,i)}function q_(e,t){if(!ys(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=Ar(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return zi(this,"shape",i),i}});return ut(e,r)}function AI(e,t){if(!ys(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Ar(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return zi(this,"shape",r),r}});return ut(e,n)}function TI(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n=Ar(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return zi(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ut(e,n)}function J_(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=Ar(t._zod.def,{get shape(){let s=t._zod.def.shape,a={...s};if(n)for(let o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(a[o]=e?new e({type:"optional",innerType:s[o]}):s[o])}else for(let o in s)a[o]=e?new e({type:"optional",innerType:s[o]}):s[o];return zi(this,"shape",a),a},checks:[]});return ut(t,i)}function EI(e,t,n){let r=Ar(t._zod.def,{get shape(){let i=t._zod.def.shape,s={...i};if(n)for(let a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(let a in i)s[a]=new e({type:"nonoptional",innerType:i[a]});return zi(this,"shape",s),s}});return ut(t,r)}function es(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function CI(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Pn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ao(e){return typeof e=="string"?e:e?.message}function kn(e,t,n){let r=e.message?e.message:Ao(e.inst?._zod.def?.error?.(e))??Ao(t?.error?.(e))??Ao(n.customError?.(e))??Ao(n.localeError?.(e))??"Invalid input",{inst:i,continue:s,input:a,...o}=e;return o.path??(o.path=[]),o.message=r,t?.reportInput&&(o.input=a),o}function kh(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function xh(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ue(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 n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Aa(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function gz(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function NI(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function PI(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function yz(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return NI(t+n)}function _z(e){return PI(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vz(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function bz(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Lg=class{constructor(...t){}},jI=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:II,Class:Lg,NUMBER_FORMAT_RANGES:$I,aborted:es,allowsEval:wI,assert:oz,assertEqual:rz,assertIs:sz,assertNever:az,assertNotEqual:iz,assignProp:zi,base64ToUint8Array:NI,base64urlToUint8Array:yz,cached:nu,captureStackTrace:B_,cleanEnum:gz,cleanRegex:bh,clone:ut,cloneDef:uz,createTransparentProxy:fz,defineLazy:$e,esc:Ug,escapeRegex:Gr,explicitlyAborted:CI,extend:q_,finalizeIssue:kn,floatSafeRemainder:vI,getElementAtPath:lz,getEnumValues:Z_,getLengthableOrigin:xh,getParsedType:mz,getSizableOrigin:kh,hexToUint8Array:vz,isObject:Oa,isPlainObject:ys,issue:Aa,joinValues:M,jsonStringifyReplacer:kd,merge:TI,mergeDefs:Ar,normalizeParams:P,nullish:Es,numKeys:hz,objectClone:cz,omit:OI,optionalKeys:xI,parsedType:ue,partial:J_,pick:SI,prefixIssues:Pn,primitiveTypes:kI,promiseAllObject:dz,propertyKeyTypes:xd,randomString:pz,required:EI,safeExtend:AI,shallowClone:wh,slugify:bI,stringifyPrimitive:ce,uint8ArrayToBase64:PI,uint8ArrayToBase64url:_z,uint8ArrayToHex:bz,unwrapMessage:Ao},Symbol.toStringTag,{value:"Module"})),RI=(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,kd,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},H_=$("$ZodError",RI),In=$("$ZodError",RI,{Parent:Error});function V_(e,t=n=>n.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function K_(e,t=n=>n.message){let n={_errors:[]},r=(i,s=[])=>{for(let a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(o=>r({issues:o},[...s,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...s,...a.path]);else{let o=[...s,...a.path];if(o.length===0)n._errors.push(t(a));else{let c=n,u=0;for(;u<o.length;){let l=o[u];u===o.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(a))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return r(e),n}function MI(e,t=n=>n.message){let n={errors:[]},r=(i,s=[])=>{var a,o;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>r({issues:u},[...s,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...s,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...s,...c.path]);else{let u=[...s,...c.path];if(u.length===0){n.errors.push(t(c));continue}let l=n,d=0;for(;d<u.length;){let p=u[d],h=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),(a=l.properties)[p]??(a[p]={errors:[]}),l=l.properties[p]):(l.items??(l.items=[]),(o=l.items)[p]??(o[p]={errors:[]}),l=l.items[p]),h&&l.errors.push(t(c)),d++}}};return r(e),n}function UI(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function W_(e){let t=[],n=[...e.issues].sort((r,i)=>(r.path??[]).length-(i.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${UI(r.path)}`);return t.join(`
|
|
65
|
+
`)}var ru=e=>(t,n,r,i)=>{let s=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Hr;if(a.issues.length){let o=new(i?.Err??e)(a.issues.map(c=>kn(c,s,Rt())));throw B_(o,i?.callee),o}return a.value},_s=ru(In),iu=e=>async(t,n,r,i)=>{let s=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let o=new(i?.Err??e)(a.issues.map(c=>kn(c,s,Rt())));throw B_(o,i?.callee),o}return a.value},uc=iu(In),su=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Hr;return s.issues.length?{success:!1,error:new(e??H_)(s.issues.map(a=>kn(a,i,Rt())))}:{success:!0,data:s.value}},LI=su(In),au=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>kn(a,i,Rt())))}:{success:!0,data:s.value}},zI=au(In),G_=e=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ru(e)(t,n,i)},wz=G_(In),X_=e=>(t,n,r)=>ru(e)(t,n,r),kz=X_(In),Y_=e=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return iu(e)(t,n,i)},xz=Y_(In),Q_=e=>async(t,n,r)=>iu(e)(t,n,r),$z=Q_(In),ev=e=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return su(e)(t,n,i)},Iz=ev(In),tv=e=>(t,n,r)=>su(e)(t,n,r),Sz=tv(In),nv=e=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return au(e)(t,n,i)},Oz=nv(In),rv=e=>async(t,n,r)=>au(e)(t,n,r),Az=rv(In),DI=/^[cC][0-9a-z]{6,}$/,FI=/^[0-9a-z]+$/,ZI=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,BI=/^[0-9a-vA-V]{20}$/,qI=/^[A-Za-z0-9]{27}$/,JI=/^[a-zA-Z0-9_-]{21}$/,HI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Tz=/^[-+]?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)?)??$/,VI=/^([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})$/,Ta=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)$/,Ez=Ta(4),Cz=Ta(6),Nz=Ta(7),KI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Pz=/^[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])?)*$/,jz=/^(([^<>()\[\]\\.,;:\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,}))$/,WI=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Rz=WI,Mz=/^[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])?)*$/,Uz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function GI(){return new RegExp(Uz,"u")}var XI=/^(?:(?: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])$/,YI=/^(([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}|:))$/,QI=e=>{let t=Gr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},eS=/^((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])$/,tS=/^(([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])$/,nS=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,iv=/^[A-Za-z0-9_-]*$/,rS=/^(?=.{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])?)*\.?$/,iS=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,sv=/^https?$/,sS=/^\+[1-9]\d{6,14}$/,aS="(?:(?:\\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])))",oS=new RegExp(`^${aS}$`);function cS(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 uS(e){return new RegExp(`^${cS(e)}$`)}function lS(e){let t=cS({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${aS}T(?:${r})$`)}var dS=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pS=/^-?\d+n?$/,hS=/^-?\d+$/,av=/^-?\d+(?:\.\d+)?$/,mS=/^(?:true|false)$/i,fS=/^null$/i,gS=/^undefined$/i,yS=/^[^A-Z]*$/,_S=/^[^a-z]*$/,vS=/^[0-9a-fA-F]*$/;function ou(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function cu(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Lz=/^[0-9a-fA-F]{32}$/,zz=ou(22,"=="),Dz=cu(22),Fz=/^[0-9a-fA-F]{40}$/,Zz=ou(27,"="),Bz=cu(27),qz=/^[0-9a-fA-F]{64}$/,Jz=ou(43,"="),Hz=cu(43),Vz=/^[0-9a-fA-F]{96}$/,Kz=ou(64,""),Wz=cu(64),Gz=/^[0-9a-fA-F]{128}$/,Xz=ou(86,"=="),Yz=cu(86),ov=Object.freeze(Object.defineProperty({__proto__:null,base64:nS,base64url:iv,bigint:pS,boolean:mS,browserEmail:Mz,cidrv4:eS,cidrv6:tS,cuid:DI,cuid2:FI,date:oS,datetime:lS,domain:iS,duration:HI,e164:sS,email:KI,emoji:GI,extendedDuration:Tz,guid:VI,hex:vS,hostname:rS,html5Email:Pz,httpProtocol:sv,idnEmail:Rz,integer:hS,ipv4:XI,ipv6:YI,ksuid:qI,lowercase:yS,mac:QI,md5_base64:zz,md5_base64url:Dz,md5_hex:Lz,nanoid:JI,null:fS,number:av,rfc5322Email:jz,sha1_base64:Zz,sha1_base64url:Bz,sha1_hex:Fz,sha256_base64:Jz,sha256_base64url:Hz,sha256_hex:qz,sha384_base64:Kz,sha384_base64url:Wz,sha384_hex:Vz,sha512_base64:Xz,sha512_base64url:Yz,sha512_hex:Gz,string:dS,time:uS,ulid:ZI,undefined:gS,unicodeEmail:WI,uppercase:_S,uuid:Ta,uuid4:Ez,uuid6:Cz,uuid7:Nz,xid:BI},Symbol.toStringTag,{value:"Module"})),et=$("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bS={number:"number",bigint:"bigint",object:"date"},cv=$("$ZodCheckLessThan",(e,t)=>{et.init(e,t);let n=bS[typeof t.value];e._zod.onattach.push(r=>{let i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uv=$("$ZodCheckGreaterThan",(e,t)=>{et.init(e,t);let n=bS[typeof t.value];e._zod.onattach.push(r=>{let i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wS=$("$ZodCheckMultipleOf",(e,t)=>{et.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):vI(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),kS=$("$ZodCheckNumberFormat",(e,t)=>{et.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,s]=$I[t.format];e._zod.onattach.push(a=>{let o=a._zod.bag;o.format=t.format,o.minimum=i,o.maximum=s,n&&(o.pattern=hS)}),e._zod.check=a=>{let o=a.value;if(n){if(!Number.isInteger(o)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){o>0?a.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}o<i&&a.issues.push({origin:"number",input:o,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),o>s&&a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),xS=$("$ZodCheckBigIntFormat",(e,t)=>{et.init(e,t);let[n,r]=II[t.format];e._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,s.minimum=n,s.maximum=r}),e._zod.check=i=>{let s=i.value;s<n&&i.issues.push({origin:"bigint",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>r&&i.issues.push({origin:"bigint",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),$S=$("$ZodCheckMaxSize",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.size!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;i.size<=t.maximum||r.issues.push({origin:kh(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),IS=$("$ZodCheckMinSize",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.size!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;i.size>=t.minimum||r.issues.push({origin:kh(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),SS=$("$ZodCheckSizeEquals",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.size!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=r=>{let i=r.value,s=i.size;if(s===t.size)return;let a=s>t.size;r.issues.push({origin:kh(i),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),OS=$("$ZodCheckMaxLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let i=r.value;if(i.length<=t.maximum)return;let s=xh(i);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),AS=$("$ZodCheckMinLength",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let i=r.value;if(i.length>=t.minimum)return;let s=xh(i);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),TS=$("$ZodCheckLengthEquals",(e,t)=>{var n;et.init(e,t),(n=e._zod.def).when??(n.when=r=>{let i=r.value;return!Es(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{let i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{let i=r.value,s=i.length;if(s===t.length)return;let a=xh(i),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),uu=$("$ZodCheckStringFormat",(e,t)=>{var n,r;et.init(e,t),e._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=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})}):(r=e._zod).check??(r.check=()=>{})}),ES=$("$ZodCheckRegex",(e,t)=>{uu.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),CS=$("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yS),uu.init(e,t)}),NS=$("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_S),uu.init(e,t)}),PS=$("$ZodCheckIncludes",(e,t)=>{et.init(e,t);let n=Gr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{let s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),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})}}),jS=$("$ZodCheckStartsWith",(e,t)=>{et.init(e,t);let n=new RegExp(`^${Gr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),RS=$("$ZodCheckEndsWith",(e,t)=>{et.init(e,t);let n=new RegExp(`.*${Gr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function Fk(e,t,n){e.issues.length&&t.issues.push(...Pn(n,e.issues))}var MS=$("$ZodCheckProperty",(e,t)=>{et.init(e,t),e._zod.check=n=>{let r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(i=>Fk(i,n,t.property));Fk(r,n,t.property)}}),US=$("$ZodCheckMimeType",(e,t)=>{et.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),LS=$("$ZodCheckOverwrite",(e,t)=>{et.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}}),$d=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(`
|
|
66
|
+
`).filter(s=>s),r=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
67
|
+
`))}},zS={major:4,minor:4,patch:3},ge=$("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zS;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let i of r)for(let s of i._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,o,c)=>{let u=es(a),l;for(let d of o){if(d._zod.def.when){if(CI(a)||!d._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,h=d._zod.check(a);if(h instanceof Promise&&c?.async===!1)throw new Hr;if(l||h instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await h,a.issues.length!==p&&(u||(u=es(a,p)))});else{if(a.issues.length===p)continue;u||(u=es(a,p))}}return l?l.then(()=>a):a},s=(a,o,c)=>{if(es(a))return a.aborted=!0,a;let u=i(o,r,c);if(u instanceof Promise){if(c.async===!1)throw new Hr;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,a,o)):s(u,a,o)}let c=e._zod.parse(a,o);if(c instanceof Promise){if(o.async===!1)throw new Hr;return c.then(u=>i(u,r,o))}return i(c,r,o)}}$e(e,"~standard",()=>({validate:i=>{try{let s=LI(e,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return zI(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),lu=$("$ZodString",(e,t)=>{ge.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dS(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ze=$("$ZodStringFormat",(e,t)=>{uu.init(e,t),lu.init(e,t)}),DS=$("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=VI),Ze.init(e,t)}),FS=$("$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=Ta(n))}else t.pattern??(t.pattern=Ta());Ze.init(e,t)}),ZS=$("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=KI),Ze.init(e,t)}),BS=$("$ZodURL",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===sv.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),qS=$("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=GI()),Ze.init(e,t)}),JS=$("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=JI),Ze.init(e,t)}),HS=$("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=DI),Ze.init(e,t)}),VS=$("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=FI),Ze.init(e,t)}),KS=$("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ZI),Ze.init(e,t)}),WS=$("$ZodXID",(e,t)=>{t.pattern??(t.pattern=BI),Ze.init(e,t)}),GS=$("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qI),Ze.init(e,t)}),XS=$("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=lS(t)),Ze.init(e,t)}),YS=$("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=oS),Ze.init(e,t)}),QS=$("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=uS(t)),Ze.init(e,t)}),eO=$("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=HI),Ze.init(e,t)}),tO=$("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=XI),Ze.init(e,t),e._zod.bag.format="ipv4"}),nO=$("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=YI),Ze.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),rO=$("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=QI(t.delimiter)),Ze.init(e,t),e._zod.bag.format="mac"}),iO=$("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eS),Ze.init(e,t)}),sO=$("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tS),Ze.init(e,t),e._zod.check=n=>{let r=n.value.split("/");try{if(r.length!==2)throw new Error;let[i,s]=r;if(!s)throw new Error;let a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function lv(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var aO=$("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nS),Ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{lv(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function oO(e){if(!iv.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return lv(n)}var cO=$("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=iv),Ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{oO(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),uO=$("$ZodE164",(e,t)=>{t.pattern??(t.pattern=sS),Ze.init(e,t)});function lO(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var dO=$("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{lO(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),pO=$("$ZodCustomStringFormat",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),dv=$("$ZodNumber",(e,t)=>{ge.init(e,t),e._zod.pattern=e._zod.bag.pattern??av,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),hO=$("$ZodNumberFormat",(e,t)=>{kS.init(e,t),dv.init(e,t)}),pv=$("$ZodBoolean",(e,t)=>{ge.init(e,t),e._zod.pattern=mS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),hv=$("$ZodBigInt",(e,t)=>{ge.init(e,t),e._zod.pattern=pS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),mO=$("$ZodBigIntFormat",(e,t)=>{xS.init(e,t),hv.init(e,t)}),fO=$("$ZodSymbol",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;return typeof i=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),n}}),gO=$("$ZodUndefined",(e,t)=>{ge.init(e,t),e._zod.pattern=gS,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),yO=$("$ZodNull",(e,t)=>{ge.init(e,t),e._zod.pattern=fS,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),_O=$("$ZodAny",(e,t)=>{ge.init(e,t),e._zod.parse=n=>n}),mv=$("$ZodUnknown",(e,t)=>{ge.init(e,t),e._zod.parse=n=>n}),fv=$("$ZodNever",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),vO=$("$ZodVoid",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;return typeof i>"u"||n.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),n}}),bO=$("$ZodDate",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,s=i instanceof Date;return s&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...s?{received:"Invalid Date"}:{},inst:e}),n}});function Zk(e,t,n){e.issues.length&&t.issues.push(...Pn(n,e.issues)),t.value[n]=e.value}var wO=$("$ZodArray",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);let s=[];for(let a=0;a<i.length;a++){let o=i[a],c=t.element._zod.run({value:o,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Zk(u,n,a))):Zk(c,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Id(e,t,n,r,i,s){let a=n in r;if(e.issues.length){if(i&&s&&!a)return;t.issues.push(...Pn(n,e.issues))}if(!a&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function kO(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=xI(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xO(e,t,n,r,i,s){let a=[],o=i.keySet,c=i.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let p in t){if(p==="__proto__"||o.has(p))continue;if(u==="never"){a.push(p);continue}let h=c.run({value:t[p],issues:[]},r);h instanceof Promise?e.push(h.then(m=>Id(m,n,p,t,l,d))):Id(h,n,p,t,l,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var $O=$("$ZodObject",(e,t)=>{if(ge.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let o={...a};return Object.defineProperty(t,"shape",{value:o}),o}})}let n=nu(()=>kO(t));$e(e._zod,"propValues",()=>{let a=t.shape,o={};for(let c in a){let u=a[c]._zod;if(u.values){o[c]??(o[c]=new Set);for(let l of u.values)o[c].add(l)}}return o});let r=Oa,i=t.catchall,s;e._zod.parse=(a,o)=>{s??(s=n.value);let c=a.value;if(!r(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};let u=[],l=s.shape;for(let d of s.keys){let p=l[d],h=p._zod.optin==="optional",m=p._zod.optout==="optional",f=p._zod.run({value:c[d],issues:[]},o);f instanceof Promise?u.push(f.then(v=>Id(v,a,d,c,h,m))):Id(f,a,d,c,h,m)}return i?xO(u,c,a,o,n.value,e):u.length?Promise.all(u).then(()=>a):a}}),IO=$("$ZodObjectJIT",(e,t)=>{$O.init(e,t);let n=e._zod.parse,r=nu(()=>kO(t)),i=d=>{let p=new $d(["shape","payload","ctx"]),h=r.value,m=y=>{let w=Ug(y);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};p.write("const input = payload.value;");let f=Object.create(null),v=0;for(let y of h.keys)f[y]=`key_${v++}`;p.write("const newResult = {};");for(let y of h.keys){let w=f[y],x=Ug(y),O=d[y],z=O?._zod?.optin==="optional",T=O?._zod?.optout==="optional";p.write(`const ${w} = ${m(y)};`),z&&T?p.write(`
|
|
68
|
+
if (${w}.issues.length) {
|
|
69
|
+
if (${x} in input) {
|
|
70
|
+
payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
71
|
+
...iss,
|
|
72
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
73
|
+
})));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (${w}.value === undefined) {
|
|
78
|
+
if (${x} in input) {
|
|
79
|
+
newResult[${x}] = undefined;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
newResult[${x}] = ${w}.value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
`):z?p.write(`
|
|
86
|
+
if (${w}.issues.length) {
|
|
87
|
+
payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
88
|
+
...iss,
|
|
89
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
90
|
+
})));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (${w}.value === undefined) {
|
|
94
|
+
if (${x} in input) {
|
|
95
|
+
newResult[${x}] = undefined;
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
newResult[${x}] = ${w}.value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
`):p.write(`
|
|
102
|
+
const ${w}_present = ${x} in input;
|
|
103
|
+
if (${w}.issues.length) {
|
|
104
|
+
payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
105
|
+
...iss,
|
|
106
|
+
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
107
|
+
})));
|
|
108
|
+
}
|
|
109
|
+
if (!${w}_present && !${w}.issues.length) {
|
|
110
|
+
payload.issues.push({
|
|
111
|
+
code: "invalid_type",
|
|
112
|
+
expected: "nonoptional",
|
|
113
|
+
input: undefined,
|
|
114
|
+
path: [${x}]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (${w}_present) {
|
|
119
|
+
if (${w}.value === undefined) {
|
|
120
|
+
newResult[${x}] = undefined;
|
|
121
|
+
} else {
|
|
122
|
+
newResult[${x}] = ${w}.value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let g=p.compile();return(y,w)=>g(d,y,w)},s,a=Oa,o=!cc.jitless,c=o&&wI.value,u=t.catchall,l;e._zod.parse=(d,p)=>{l??(l=r.value);let h=d.value;return a(h)?o&&c&&p?.async===!1&&p.jitless!==!0?(s||(s=i(t.shape)),d=s(d,p),u?xO([],h,d,p,l,e):d):n(d,p):(d.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),d)}});function Bk(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let i=e.filter(s=>!es(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>kn(a,r,Rt())))}),t)}var $h=$("$ZodUnion",(e,t)=>{ge.init(e,t),$e(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$e(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$e(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),$e(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>bh(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1,a=[];for(let o of t.options){let c=o._zod.run({value:r.value,issues:[]},i);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}return s?Promise.all(a).then(o=>Bk(o,r,e,i)):Bk(a,r,e,i)}});function qk(e,t,n,r){let i=e.filter(s=>s.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:n,errors:e.map(s=>s.issues.map(a=>kn(a,r,Rt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}var SO=$("$ZodXor",(e,t)=>{$h.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1,a=[];for(let o of t.options){let c=o._zod.run({value:r.value,issues:[]},i);c instanceof Promise?(a.push(c),s=!0):a.push(c)}return s?Promise.all(a).then(o=>qk(o,r,e,i)):qk(a,r,e,i)}}),OO=$("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$h.init(e,t);let n=e._zod.parse;$e(e._zod,"propValues",()=>{let i={};for(let s of t.options){let a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[o,c]of Object.entries(a)){i[o]||(i[o]=new Set);for(let u of c)i[o].add(u)}}return i});let r=nu(()=>{let i=t.options,s=new Map;for(let a of i){let o=a._zod.propValues?.[t.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of o){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,a)}}return s});e._zod.parse=(i,s)=>{let a=i.value;if(!Oa(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let o=r.value.get(a?.[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback||s.direction==="backward"?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),i)}}),AO=$("$ZodIntersection",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([o,c])=>Jk(n,o,c)):Jk(n,s,a)}});function zg(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(ys(e)&&ys(t)){let n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(let s of r){let a=zg(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t[r],a=zg(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Jk(e,t,n){let r=new Map,i;for(let o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(let c of o.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(o);for(let o of n.issues)if(o.code==="unrecognized_keys")for(let c of o.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(o);let s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),es(e))return e;let a=zg(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var gv=$("$ZodTuple",(e,t)=>{ge.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let a=[],o=Hk(n,"optin"),c=Hk(n,"optout");if(!t.rest){if(s.length<o)return r.issues.push({code:"too_small",minimum:o,inclusive:!0,input:s,inst:e,origin:"array"}),r;s.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=new Array(n.length);for(let l=0;l<n.length;l++){let d=n[l]._zod.run({value:s[l],issues:[]},i);d instanceof Promise?a.push(d.then(p=>{u[l]=p})):u[l]=d}if(t.rest){let l=n.length-1,d=s.slice(n.length);for(let p of d){l++;let h=t.rest._zod.run({value:p,issues:[]},i);h instanceof Promise?a.push(h.then(m=>Vk(m,r,l))):Vk(h,r,l)}}return a.length?Promise.all(a).then(()=>Kk(u,r,n,s,c)):Kk(u,r,n,s,c)}});function Hk(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!=="optional")return n+1;return 0}function Vk(e,t,n){e.issues.length&&t.issues.push(...Pn(n,e.issues)),t.value[n]=e.value}function Kk(e,t,n,r,i){for(let s=0;s<n.length;s++){let a=e[s],o=s<r.length;if(a.issues.length){if(!o&&s>=i){t.value.length=s;break}t.issues.push(...Pn(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=r.length&&n[s]._zod.optout==="optional"&&t.value[s]===void 0;s--)t.value.length=s;return t}var TO=$("$ZodRecord",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ys(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let s=[],a=t.keyType._zod.values;if(a){n.value={};let o=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){o.add(typeof u=="number"?u.toString():u);let l=t.keyType._zod.run({value:u,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>kn(h,r,Rt())),input:u,path:[u],inst:e});continue}let d=l.value,p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&n.issues.push(...Pn(u,h.issues)),n.value[d]=h.value})):(p.issues.length&&n.issues.push(...Pn(u,p.issues)),n.value[d]=p.value)}let c;for(let u in i)o.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let c=t.keyType._zod.run({value:o,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&av.test(o)&&c.issues.length){let l=t.keyType._zod.run({value:Number(o),issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");l.issues.length===0&&(c=l)}if(c.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(l=>kn(l,r,Rt())),input:o,path:[o],inst:e});continue}let u=t.valueType._zod.run({value:i[o],issues:[]},r);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&n.issues.push(...Pn(o,l.issues)),n.value[c.value]=l.value})):(u.issues.length&&n.issues.push(...Pn(o,u.issues)),n.value[c.value]=u.value)}}return s.length?Promise.all(s).then(()=>n):n}}),EO=$("$ZodMap",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),n;let s=[];n.value=new Map;for(let[a,o]of i){let c=t.keyType._zod.run({value:a,issues:[]},r),u=t.valueType._zod.run({value:o,issues:[]},r);c instanceof Promise||u instanceof Promise?s.push(Promise.all([c,u]).then(([l,d])=>{Wk(l,d,n,a,i,e,r)})):Wk(c,u,n,a,i,e,r)}return s.length?Promise.all(s).then(()=>n):n}});function Wk(e,t,n,r,i,s,a){e.issues.length&&(xd.has(typeof r)?n.issues.push(...Pn(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:s,issues:e.issues.map(o=>kn(o,a,Rt()))})),t.issues.length&&(xd.has(typeof r)?n.issues.push(...Pn(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:s,key:r,issues:t.issues.map(o=>kn(o,a,Rt()))})),n.value.set(e.value,t.value)}var CO=$("$ZodSet",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),n;let s=[];n.value=new Set;for(let a of i){let o=t.valueType._zod.run({value:a,issues:[]},r);o instanceof Promise?s.push(o.then(c=>Gk(c,n))):Gk(o,n)}return s.length?Promise.all(s).then(()=>n):n}});function Gk(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var NO=$("$ZodEnum",(e,t)=>{ge.init(e,t);let n=Z_(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>xd.has(typeof i)).map(i=>typeof i=="string"?Gr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),PO=$("$ZodLiteral",(e,t)=>{if(ge.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Gr(r):r?Gr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{let s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),jO=$("$ZodFile",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;return i instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),n}}),RO=$("$ZodTransform",(e,t)=>{ge.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Sa(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n.fallback=!0,n));if(i instanceof Promise)throw new Hr;return n.value=i,n.fallback=!0,n}});function Xk(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var du=$("$ZodOptional",(e,t)=>{ge.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$e(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${bh(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let i=n.value,s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>Xk(a,i)):Xk(s,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),MO=$("$ZodExactOptional",(e,t)=>{du.init(e,t),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),UO=$("$ZodNullable",(e,t)=>{ge.init(e,t),$e(e._zod,"optin",()=>t.innerType._zod.optin),$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${bh(n.source)}|null)$`):void 0}),$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),LO=$("$ZodDefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Yk(s,t)):Yk(i,t)}});function Yk(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var zO=$("$ZodPrefault",(e,t)=>{ge.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),DO=$("$ZodNonOptional",(e,t)=>{ge.init(e,t),$e(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>Qk(s,e)):Qk(i,e)}});function Qk(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 FO=$("$ZodSuccess",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Sa("ZodSuccess");let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.issues.length===0,n)):(n.value=i.issues.length===0,n)}}),ZO=$("$ZodCatch",(e,t)=>{ge.init(e,t),e._zod.optin="optional",$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>kn(a,r,Rt()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>kn(s,r,Rt()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),BO=$("$ZodNaN",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),yv=$("$ZodPipe",(e,t)=>{ge.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),$e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>ul(a,t.in,r)):ul(s,t.in,r)}let i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>ul(s,t.out,r)):ul(i,t.out,r)}});function ul(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var _v=$("$ZodCodec",(e,t)=>{ge.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),$e(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){let i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>ll(s,t,r)):ll(i,t,r)}else{let i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>ll(s,t,r)):ll(i,t,r)}}});function ll(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(i=>dl(e,i,t.out,n)):dl(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(i=>dl(e,i,t.in,n)):dl(e,r,t.in,n)}}function dl(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}var qO=$("$ZodPreprocess",(e,t)=>{yv.init(e,t)}),JO=$("$ZodReadonly",(e,t)=>{ge.init(e,t),$e(e._zod,"propValues",()=>t.innerType._zod.propValues),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"optin",()=>t.innerType?._zod?.optin),$e(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(ex):ex(i)}});function ex(e){return e.value=Object.freeze(e.value),e}var HO=$("$ZodTemplateLiteral",(e,t)=>{ge.init(e,t);let n=[];for(let r of t.parts)if(typeof r=="object"&&r!==null){if(!r._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);let i=r._zod.pattern instanceof RegExp?r._zod.pattern.source:r._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${r._zod.traits}`);let s=i.startsWith("^")?1:0,a=i.endsWith("$")?i.length-1:i.length;n.push(i.slice(s,a))}else if(r===null||kI.has(typeof r))n.push(Gr(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),VO=$("$ZodFunction",(e,t)=>(ge.init(e,t),e._def=t,e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return function(...r){let i=e._def.input?_s(e._def.input,r):r,s=Reflect.apply(n,this,i);return e._def.output?_s(e._def.output,s):s}},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return async function(...r){let i=e._def.input?await uc(e._def.input,r):r,s=await Reflect.apply(n,this,i);return e._def.output?await uc(e._def.output,s):s}},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new gv({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),KO=$("$ZodPromise",(e,t)=>{ge.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),WO=$("$ZodLazy",(e,t)=>{ge.init(e,t),$e(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),$e(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),$e(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),$e(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),$e(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),GO=$("$ZodCustom",(e,t)=>{et.init(e,t),ge.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>tx(s,n,r,e));tx(i,n,r,e)}});function tx(e,t,n,r){if(!e){let i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Aa(i))}}var Qz=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${o}`}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 ${ce(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: ${M(i.values,"|")}`;case"too_big":{let s=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"} ${s} ${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"} ${s} ${i.maximum.toString()}`}case"too_small":{let s=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 ${s} ${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 ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`${n[s.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":""}: ${M(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 eD(){return{localeError:Qz()}}var tD=()=>{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 n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${i.expected}, daxil olan ${o}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${s}, daxil olan ${o}`}case"invalid_value":return i.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${ce(i.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${s}${i.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${i.origin??"d\u0259y\u0259r"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${s}${i.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${s.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:s.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${s.suffix}" il\u0259 bitm\u0259lidir`:s.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${s.includes}" daxil olmal\u0131d\u0131r`:s.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${s.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[s.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":""}: ${M(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 nD(){return{localeError:tD()}}function nx(e,t,n,r){let i=Math.abs(e),s=i%10,a=i%100;return a>=11&&a<=19?r:s===1?t:s>=2&&s<=4?n:r}var rD=()=>{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 n={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"},r={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${s}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);if(a){let o=Number(i.maximum),c=nx(o,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} ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);if(a){let o=Number(i.minimum),c=nx(o,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} ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[s.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"}: ${M(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 iD(){return{localeError:rD()}}var sD=()=>{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 n={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"},r={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${s}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=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 ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=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 ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.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 "${s.prefix}"`;if(s.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 "${s.suffix}"`;if(s.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 "${s.includes}"`;if(s.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 ${s.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return s.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),s.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),s.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${n[s.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":""}: ${M(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 aD(){return{localeError:sD()}}var oD=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${i.expected}, s'ha rebut ${o}`:`Tipus inv\xE0lid: s'esperava ${s}, s'ha rebut ${o}`}case"invalid_value":return i.values.length===1?`Valor inv\xE0lid: s'esperava ${ce(i.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${M(i.values," o ")}`;case"too_big":{let s=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 ${s} ${i.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${i.origin??"el valor"} fos ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(i.origin);return a?`Massa petit: s'esperava que ${i.origin} contingu\xE9s ${s} ${i.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${i.origin} fos ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${s.prefix}"`:s.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${s.suffix}"`:s.format==="includes"?`Format inv\xE0lid: ha d'incloure "${s.includes}"`:s.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${s.pattern}`:`Format inv\xE0lid per a ${n[s.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":""}: ${M(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 cD(){return{localeError:oD()}}var uD=()=>{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 n={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"},r={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${i.expected}, obdr\u017Eeno ${o}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${s}, obdr\u017Eeno ${o}`}case"invalid_value":return i.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${ce(i.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${s}${i.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED m\xEDt ${s}${i.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${i.origin??"hodnota"} mus\xED b\xFDt ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${s.prefix}"`:s.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${s.suffix}"`:s.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${s.includes}"`:s.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${s.pattern}`:`Neplatn\xFD form\xE1t ${n[s.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: ${M(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 lD(){return{localeError:uD()}}var dD=()=>{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 n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldigt input: forventede instanceof ${i.expected}, fik ${o}`:`Ugyldigt input: forventede ${s}, fik ${o}`}case"invalid_value":return i.values.length===1?`Ugyldig v\xE6rdi: forventede ${ce(i.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin),o=r[i.origin]??i.origin;return a?`For stor: forventede ${o??"value"} ${a.verb} ${s} ${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${o??"value"} havde ${s} ${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin),o=r[i.origin]??i.origin;return a?`For lille: forventede ${o} ${a.verb} ${s} ${i.minimum.toString()} ${a.unit}`:`For lille: forventede ${o} havde ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${s.pattern}`:`Ugyldig ${n[s.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"}: ${M(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 pD(){return{localeError:dD()}}var hD=()=>{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 n={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"},r={nan:"NaN",number:"Zahl",array:"Array"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${i.expected}, erhalten ${o}`:`Ung\xFCltige Eingabe: erwartet ${s}, erhalten ${o}`}case"invalid_value":return i.values.length===1?`Ung\xFCltige Eingabe: erwartet ${ce(i.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${s}${i.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${i.origin??"Wert"} ${s}${i.maximum.toString()} ist`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Zu klein: erwartet, dass ${i.origin} ${s}${i.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${i.origin} ${s}${i.minimum.toString()} ist`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ung\xFCltiger String: muss mit "${s.prefix}" beginnen`:s.format==="ends_with"?`Ung\xFCltiger String: muss mit "${s.suffix}" enden`:s.format==="includes"?`Ung\xFCltiger String: muss "${s.includes}" enthalten`:s.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${s.pattern} entsprechen`:`Ung\xFCltig: ${n[s.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"}: ${M(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 mD(){return{localeError:hD()}}var fD=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(i){return e[i]??null}let n={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return typeof i.expected=="string"&&/^[A-Z]/.test(i.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${i.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${o}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${s}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${o}`}case"invalid_value":return i.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${ce(i.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${s}${i.maximum.toString()} ${a.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${s}${i.minimum.toString()} ${a.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${s.prefix}"`:s.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${s.suffix}"`:s.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${s.includes}"`:s.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${s.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${n[s.format]??i.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${i.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${i.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${i.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${M(i.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${i.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${i.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function gD(){return{localeError:fD()}}var yD=()=>{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 n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return`Invalid input: expected ${s}, received ${o}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${ce(i.values[0])}`:`Invalid option: expected one of ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.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":""}: ${M(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(s=>`'${s}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function XO(){return{localeError:yD()}}var _D=()=>{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 n={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"},r={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${i.expected}, ricevi\u011Dis ${o}`:`Nevalida enigo: atendi\u011Dis ${s}, ricevi\u011Dis ${o}`}case"invalid_value":return i.values.length===1?`Nevalida enigo: atendi\u011Dis ${ce(i.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${s}${i.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${i.origin??"valoro"} havu ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Tro malgranda: atendi\u011Dis ke ${i.origin} havu ${s}${i.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${i.origin} estu ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${s.prefix}"`:s.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${s.suffix}"`:s.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${s.includes}"`:s.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${s.pattern}`:`Nevalida ${n[s.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":""}: ${M(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 vD(){return{localeError:_D()}}var bD=()=>{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 n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${i.expected}, recibido ${o}`:`Entrada inv\xE1lida: se esperaba ${s}, recibido ${o}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: se esperaba ${ce(i.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin),o=r[i.origin]??i.origin;return a?`Demasiado grande: se esperaba que ${o??"valor"} tuviera ${s}${i.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${o??"valor"} fuera ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin),o=r[i.origin]??i.origin;return a?`Demasiado peque\xF1o: se esperaba que ${o} tuviera ${s}${i.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${o} fuera ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inv\xE1lida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${s.pattern}`:`Inv\xE1lido ${n[s.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":""}: ${M(i.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${r[i.origin]??i.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${r[i.origin]??i.origin}`;default:return"Entrada inv\xE1lida"}}};function wD(){return{localeError:bD()}}var kD=()=>{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 n={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"},r={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o} \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 ${s} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${o} \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 ${ce(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 ${M(i.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let s=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 ${s}${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 ${s}${i.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${s.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:s.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${s.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:s.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${s.includes}" \u0628\u0627\u0634\u062F`:s.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${s.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[s.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: ${M(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 xD(){return{localeError:kD()}}var $D=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Virheellinen tyyppi: odotettiin instanceof ${i.expected}, oli ${o}`:`Virheellinen tyyppi: odotettiin ${s}, oli ${o}`}case"invalid_value":return i.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${ce(i.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${s}${i.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${s}${i.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${s.prefix}"`:s.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${s.suffix}"`:s.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${s.includes}"`:s.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${s.pattern}`:`Virheellinen ${n[s.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"}: ${M(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 ID(){return{localeError:$D()}}var SD=()=>{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 n={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"},r={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : instanceof ${i.expected} attendu, ${o} re\xE7u`:`Entr\xE9e invalide : ${s} attendu, ${o} re\xE7u`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : ${ce(i.values[0])} attendu`:`Option invalide : une valeur parmi ${M(i.values,"|")} attendue`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Trop grand : ${r[i.origin]??"valeur"} doit ${a.verb} ${s}${i.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${r[i.origin]??"valeur"} doit \xEAtre ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Trop petit : ${r[i.origin]??"valeur"} doit ${a.verb} ${s}${i.minimum.toString()} ${a.unit}`:`Trop petit : ${r[i.origin]??"valeur"} doit \xEAtre ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${s.prefix}"`:s.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${s.suffix}"`:s.format==="includes"?`Cha\xEEne invalide : doit inclure "${s.includes}"`:s.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${s.pattern}`:`${n[s.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":""} : ${M(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 OD(){return{localeError:SD()}}var AD=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Entr\xE9e invalide : attendu instanceof ${i.expected}, re\xE7u ${o}`:`Entr\xE9e invalide : attendu ${s}, re\xE7u ${o}`}case"invalid_value":return i.values.length===1?`Entr\xE9e invalide : attendu ${ce(i.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"\u2264":"<",a=t(i.origin);return a?`Trop grand : attendu que ${i.origin??"la valeur"} ait ${s}${i.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${i.origin??"la valeur"} soit ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?"\u2265":">",a=t(i.origin);return a?`Trop petit : attendu que ${i.origin} ait ${s}${i.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${i.origin} soit ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${s.prefix}"`:s.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${s.suffix}"`:s.format==="includes"?`Cha\xEEne invalide : doit inclure "${s.includes}"`:s.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${s.pattern}`:`${n[s.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":""} : ${M(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 TD(){return{localeError:AD()}}var ED=()=>{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"}},n=u=>u?e[u]:void 0,r=u=>{let l=n(u);return l?l.label:u??e.unknown.label},i=u=>`\u05D4${r(u)}`,s=u=>(n(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,o={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??""]??r(l),p=ue(u.input),h=c[p]??e[p]?.label??p;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 ${h}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`}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 ${ce(u.values[0])}`;let l=u.values.map(p=>ce(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",f=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 ${f}`.trim()}let p=u.inclusive?"<=":"<",h=s(u.origin??"value");return l?.unit?`${l.longLabel} \u05DE\u05D3\u05D9: ${d} ${h} ${p}${u.maximum.toString()} ${l.unit}`:`${l?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${h} ${p}${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 v=(u.origin,"\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${m} \u05DC\u05D4\u05DB\u05D9\u05DC ${v}`}let f=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 ${f}`.trim()}let p=u.inclusive?">=":">",h=s(u.origin??"value");return l?.unit?`${l.shortLabel} \u05DE\u05D3\u05D9: ${d} ${h} ${p}${u.minimum.toString()} ${l.unit}`:`${l?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${h} ${p}${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=o[l.format],p=d?.label??l.format,h=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${h}`}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"}: ${M(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 CD(){return{localeError:ED()}}var ND=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(i){return e[i]??null}let n={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},r={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${i.expected}, a primljeno je ${o}`:`Neispravan unos: o\u010Dekuje se ${s}, a primljeno je ${o}`}case"invalid_value":return i.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${ce(i.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin),o=r[i.origin]??i.origin;return a?`Preveliko: o\u010Dekivano da ${o??"vrijednost"} ima ${s}${i.maximum.toString()} ${a.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${o??"vrijednost"} bude ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin),o=r[i.origin]??i.origin;return a?`Premalo: o\u010Dekivano da ${o} ima ${s}${i.minimum.toString()} ${a.unit}`:`Premalo: o\u010Dekivano da ${o} bude ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${s.prefix}"`:s.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${s.suffix}"`:s.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${s.includes}"`:s.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${s.pattern}`:`Neispravna ${n[s.format]??i.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${i.divisor}`;case"unrecognized_keys":return`Neprepoznat${i.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${M(i.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${r[i.origin]??i.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${r[i.origin]??i.origin}`;default:return"Neispravan unos"}}};function PD(){return{localeError:ND()}}var jD=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(i){return e[i]??null}let n={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"},r={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${i.expected}, a kapott \xE9rt\xE9k ${o}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${s}, a kapott \xE9rt\xE9k ${o}`}case"invalid_value":return i.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${ce(i.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`T\xFAl nagy: ${i.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${s}${i.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${i.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} m\xE9rete t\xFAl kicsi ${s}${i.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${i.origin} t\xFAl kicsi ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\xC9rv\xE9nytelen string: "${s.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:s.format==="ends_with"?`\xC9rv\xE9nytelen string: "${s.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:s.format==="includes"?`\xC9rv\xE9nytelen string: "${s.includes}" \xE9rt\xE9ket kell tartalmaznia`:s.format==="regex"?`\xC9rv\xE9nytelen string: ${s.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[s.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":""}: ${M(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 RD(){return{localeError:jD()}}function rx(e,t,n){return Math.abs(e)===1?t:n}function Zs(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}var MD=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(i){return e[i]??null}let n={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"},r={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);if(a){let o=Number(i.maximum),c=rx(o,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 ${Zs(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${s}${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 ${Zs(i.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);if(a){let o=Number(i.minimum),c=rx(o,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 ${Zs(i.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${s}${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 ${Zs(i.origin)} \u056C\u056B\u0576\u056B ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${s.prefix}"-\u0578\u057E`:s.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${s.suffix}"-\u0578\u057E`:s.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${s.includes}"`:s.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 ${s.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[s.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":""}. ${M(i.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Zs(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 ${Zs(i.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function UD(){return{localeError:MD()}}var LD=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak valid: diharapkan instanceof ${i.expected}, diterima ${o}`:`Input tidak valid: diharapkan ${s}, diterima ${o}`}case"invalid_value":return i.values.length===1?`Input tidak valid: diharapkan ${ce(i.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: diharapkan ${i.origin??"value"} memiliki ${s}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${i.origin??"value"} menjadi ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: diharapkan ${i.origin} memiliki ${s}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${i.origin} menjadi ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`String tidak valid: harus dimulai dengan "${s.prefix}"`:s.format==="ends_with"?`String tidak valid: harus berakhir dengan "${s.suffix}"`:s.format==="includes"?`String tidak valid: harus menyertakan "${s.includes}"`:s.format==="regex"?`String tidak valid: harus sesuai pola ${s.pattern}`:`${n[s.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":""}: ${M(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 zD(){return{localeError:LD()}}var DD=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(i){return e[i]??null}let n={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"},r={nan:"NaN",number:"n\xFAmer",array:"fylki"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${o} \xFEar sem \xE1 a\xF0 vera instanceof ${i.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${o} \xFEar sem \xE1 a\xF0 vera ${s}`}case"invalid_value":return i.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${ce(i.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} hafi ${s}${i.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin??"gildi"} s\xE9 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} hafi ${s}${i.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${i.origin} s\xE9 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${s.prefix}"`:s.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${s.suffix}"`:s.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${s.includes}"`:s.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${s.pattern}`:`Rangt ${n[s.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"}: ${M(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 FD(){return{localeError:DD()}}var ZD=()=>{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 n={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"},r={nan:"NaN",number:"numero",array:"vettore"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Input non valido: atteso instanceof ${i.expected}, ricevuto ${o}`:`Input non valido: atteso ${s}, ricevuto ${o}`}case"invalid_value":return i.values.length===1?`Input non valido: atteso ${ce(i.values[0])}`:`Opzione non valida: atteso uno tra ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Troppo grande: ${i.origin??"valore"} deve avere ${s}${i.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${i.origin??"valore"} deve essere ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Troppo piccolo: ${i.origin} deve avere ${s}${i.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${i.origin} deve essere ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Stringa non valida: deve iniziare con "${s.prefix}"`:s.format==="ends_with"?`Stringa non valida: deve terminare con "${s.suffix}"`:s.format==="includes"?`Stringa non valida: deve includere "${s.includes}"`:s.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${s.pattern}`:`Input non valido: ${n[s.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"}: ${M(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 BD(){return{localeError:ZD()}}var qD=()=>{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 n={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"},r={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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${o}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${s}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${o}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return i.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${ce(i.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${M(i.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let s=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"}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${i.origin??"\u5024"}\u306F${i.maximum.toString()}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let s=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}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${i.origin}\u306F${i.minimum.toString()}${s}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${s.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:s.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${s.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[s.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":""}: ${M(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 JD(){return{localeError:qD()}}var HD=()=>{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 n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},r={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${o}`}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 ${ce(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 ${M(i.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let s=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} ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=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} ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${s.prefix}"-\u10D8\u10D7`:s.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${s.suffix}"-\u10D8\u10D7`:s.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${s.includes}"-\u10E1`:s.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${s.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[s.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"}: ${M(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 VD(){return{localeError:HD()}}var KD=()=>{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 n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=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"} ${s} ${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"} ${s} ${i.maximum.toString()}`}case"too_small":{let s=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} ${s} ${i.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i.origin} ${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[s.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 ${M(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 YO(){return{localeError:KD()}}function WD(){return YO()}var GD=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${s}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${o}\uC785\uB2C8\uB2E4`}case"invalid_value":return i.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${ce(i.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${M(i.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let s=i.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=s==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",o=t(i.origin),c=o?.unit??"\uC694\uC18C";return o?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()}${c} ${s}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${i.maximum.toString()} ${s}${a}`}case"too_small":{let s=i.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=s==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",o=t(i.origin),c=o?.unit??"\uC694\uC18C";return o?`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()}${c} ${s}${a}`:`${i.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${i.minimum.toString()} ${s}${a}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:s.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:s.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${s.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:s.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${s.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[s.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: ${M(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 XD(){return{localeError:GD()}}var bo=e=>e.charAt(0).toUpperCase()+e.slice(1);function ix(e){let t=Math.abs(e),n=t%10,r=t%100;return r>=11&&r<=19||n===0?"many":n===1?"one":"few"}var YD=()=>{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,s,a,o){let c=e[i]??null;return c===null?c:{unit:c.unit[s],verb:c.verb[o][a?"inclusive":"notInclusive"]}}let n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Gautas tipas ${o}, o tik\u0117tasi - instanceof ${i.expected}`:`Gautas tipas ${o}, o tik\u0117tasi - ${s}`}case"invalid_value":return i.values.length===1?`Privalo b\u016Bti ${ce(i.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${M(i.values,"|")} pasirinkim\u0173`;case"too_big":{let s=r[i.origin]??i.origin,a=t(i.origin,ix(Number(i.maximum)),i.inclusive??!1,"smaller");if(a?.verb)return`${bo(s??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.maximum.toString()} ${a.unit??"element\u0173"}`;let o=i.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${bo(s??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${o} ${i.maximum.toString()} ${a?.unit}`}case"too_small":{let s=r[i.origin]??i.origin,a=t(i.origin,ix(Number(i.minimum)),i.inclusive??!1,"bigger");if(a?.verb)return`${bo(s??i.origin??"reik\u0161m\u0117")} ${a.verb} ${i.minimum.toString()} ${a.unit??"element\u0173"}`;let o=i.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${bo(s??i.origin??"reik\u0161m\u0117")} turi b\u016Bti ${o} ${i.minimum.toString()} ${a?.unit}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${s.prefix}"`:s.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${s.suffix}"`:s.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${s.includes}"`:s.format==="regex"?`Eilut\u0117 privalo atitikti ${s.pattern}`:`Neteisingas ${n[s.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"}: ${M(i.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let s=r[i.origin]??i.origin;return`${bo(s??i.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function QD(){return{localeError:YD()}}var e5=()=>{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 n={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"},r={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${s}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${o}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=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 ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=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 ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`Invalid ${n[s.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"}: ${M(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 t5(){return{localeError:e5()}}var n5=()=>{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 n={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"},r={nan:"NaN",number:"nombor"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Input tidak sah: dijangka instanceof ${i.expected}, diterima ${o}`:`Input tidak sah: dijangka ${s}, diterima ${o}`}case"invalid_value":return i.values.length===1?`Input tidak sah: dijangka ${ce(i.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Terlalu besar: dijangka ${i.origin??"nilai"} ${a.verb} ${s}${i.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${i.origin??"nilai"} adalah ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Terlalu kecil: dijangka ${i.origin} ${a.verb} ${s}${i.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${i.origin} adalah ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`String tidak sah: mesti bermula dengan "${s.prefix}"`:s.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${s.suffix}"`:s.format==="includes"?`String tidak sah: mesti mengandungi "${s.includes}"`:s.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${s.pattern}`:`${n[s.format]??i.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${i.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${M(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 r5(){return{localeError:n5()}}var i5=()=>{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 n={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"},r={nan:"NaN",number:"getal"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ongeldige invoer: verwacht instanceof ${i.expected}, ontving ${o}`:`Ongeldige invoer: verwacht ${s}, ontving ${o}`}case"invalid_value":return i.values.length===1?`Ongeldige invoer: verwacht ${ce(i.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin),o=i.origin==="date"?"laat":i.origin==="string"?"lang":"groot";return a?`Te ${o}: verwacht dat ${i.origin??"waarde"} ${s}${i.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${o}: verwacht dat ${i.origin??"waarde"} ${s}${i.maximum.toString()} is`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin),o=i.origin==="date"?"vroeg":i.origin==="string"?"kort":"klein";return a?`Te ${o}: verwacht dat ${i.origin} ${s}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${o}: verwacht dat ${i.origin} ${s}${i.minimum.toString()} is`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ongeldige tekst: moet met "${s.prefix}" beginnen`:s.format==="ends_with"?`Ongeldige tekst: moet op "${s.suffix}" eindigen`:s.format==="includes"?`Ongeldige tekst: moet "${s.includes}" bevatten`:s.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${s.pattern}`:`Ongeldig: ${n[s.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":""}: ${M(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 s5(){return{localeError:i5()}}var a5=()=>{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 n={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"},r={nan:"NaN",number:"tall",array:"liste"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ugyldig input: forventet instanceof ${i.expected}, fikk ${o}`:`Ugyldig input: forventet ${s}, fikk ${o}`}case"invalid_value":return i.values.length===1?`Ugyldig verdi: forventet ${ce(i.values[0])}`:`Ugyldig valg: forventet en av ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${s}${i.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${i.origin??"value"} til \xE5 ha ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`For lite(n): forventet ${i.origin} til \xE5 ha ${s}${i.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${i.origin} til \xE5 ha ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${s.pattern}`:`Ugyldig ${n[s.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"}: ${M(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 o5(){return{localeError:a5()}}var c5=()=>{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 n={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"},r={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`F\xE2sit giren: umulan instanceof ${i.expected}, al\u0131nan ${o}`:`F\xE2sit giren: umulan ${s}, al\u0131nan ${o}`}case"invalid_value":return i.values.length===1?`F\xE2sit giren: umulan ${ce(i.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${s}${i.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${i.origin??"value"}, ${s}${i.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${s}${i.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${i.origin}, ${s}${i.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let s=i;return s.format==="starts_with"?`F\xE2sit metin: "${s.prefix}" ile ba\u015Flamal\u0131.`:s.format==="ends_with"?`F\xE2sit metin: "${s.suffix}" ile bitmeli.`:s.format==="includes"?`F\xE2sit metin: "${s.includes}" ihtiv\xE2 etmeli.`:s.format==="regex"?`F\xE2sit metin: ${s.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[s.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":""}: ${M(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 u5(){return{localeError:c5()}}var l5=()=>{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 n={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"},r={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${s} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${o} \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 ${ce(i.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${M(i.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let s=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 ${s}${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 ${s}${i.maximum.toString()} \u0648\u064A`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${i.origin} \u0628\u0627\u06CC\u062F ${s}${i.minimum.toString()} \u0648\u064A`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${s.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:s.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${s.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:s.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${s.includes}" \u0648\u0644\u0631\u064A`:s.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${s.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[s.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"}: ${M(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 d5(){return{localeError:l5()}}var p5=()=>{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 n={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"},r={nan:"NaN",number:"liczba",array:"tablica"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${i.expected}, otrzymano ${o}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${s}, otrzymano ${o}`}case"invalid_value":return i.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${ce(i.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${M(i.values,"|")}`;case"too_big":{let s=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 ${s}${i.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${s}${i.maximum.toString()}`}case"too_small":{let s=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 ${s}${i.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${i.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${s.prefix}"`:s.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${s.suffix}"`:s.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${s.includes}"`:s.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${s.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[s.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":""}: ${M(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 h5(){return{localeError:p5()}}var m5=()=>{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 n={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"},r={nan:"NaN",number:"n\xFAmero",null:"nulo"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Tipo inv\xE1lido: esperado instanceof ${i.expected}, recebido ${o}`:`Tipo inv\xE1lido: esperado ${s}, recebido ${o}`}case"invalid_value":return i.values.length===1?`Entrada inv\xE1lida: esperado ${ce(i.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Muito grande: esperado que ${i.origin??"valor"} tivesse ${s}${i.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${i.origin??"valor"} fosse ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Muito pequeno: esperado que ${i.origin} tivesse ${s}${i.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${i.origin} fosse ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`${n[s.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":""}: ${M(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 f5(){return{localeError:m5()}}var g5=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(i){return e[i]??null}let n={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},r={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return`Intrare invalid\u0103: a\u0219teptat ${s}, primit ${o}`}case"invalid_value":return i.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${ce(i.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} ${a.verb} ${s}${i.maximum.toString()} ${a.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${i.origin??"valoarea"} s\u0103 fie ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Prea mic: a\u0219teptat ca ${i.origin} ${a.verb} ${s}${i.minimum.toString()} ${a.unit}`:`Prea mic: a\u0219teptat ca ${i.origin} s\u0103 fie ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${s.prefix}"`:s.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${s.suffix}"`:s.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${s.includes}"`:s.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${s.pattern}`:`Format invalid: ${n[s.format]??i.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${i.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${M(i.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${i.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${i.origin}`;default:return"Intrare invalid\u0103"}}};function y5(){return{localeError:g5()}}function sx(e,t,n,r){let i=Math.abs(e),s=i%10,a=i%100;return a>=11&&a<=19?r:s===1?t:s>=2&&s<=4?n:r}var _5=()=>{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 n={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"},r={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${s}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);if(a){let o=Number(i.maximum),c=sx(o,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 ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);if(a){let o=Number(i.minimum),c=sx(o,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 ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[s.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":""}: ${M(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 v5(){return{localeError:_5()}}var b5=()=>{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 n={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"},r={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${i.expected}, prejeto ${o}`:`Neveljaven vnos: pri\u010Dakovano ${s}, prejeto ${o}`}case"invalid_value":return i.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${ce(i.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} imelo ${s}${i.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${i.origin??"vrednost"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${i.origin} imelo ${s}${i.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${s.prefix}"`:s.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${s.suffix}"`:s.format==="includes"?`Neveljaven niz: mora vsebovati "${s.includes}"`:s.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${s.pattern}`:`Neveljaven ${n[s.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"}: ${M(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 w5(){return{localeError:b5()}}var k5=()=>{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 n={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"},r={nan:"NaN",number:"antal",array:"lista"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${i.expected}, fick ${o}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${s}, fick ${o}`}case"invalid_value":return i.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${ce(i.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${i.origin??"v\xE4rdet"} att ha ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${i.origin??"v\xE4rdet"} att ha ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${s.prefix}"`:s.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${s.suffix}"`:s.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${s.includes}"`:s.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${s.pattern}"`:`Ogiltig(t) ${n[s.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"}: ${M(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 x5(){return{localeError:k5()}}var $5=()=>{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 n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}`}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 ${ce(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 ${M(i.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let s=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"} ${s}${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"} ${s}${i.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let s=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} ${s}${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} ${s}${i.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${s.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:s.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${s.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 ${n[s.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":""}: ${M(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 I5(){return{localeError:$5()}}var S5=()=>{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 n={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"},r={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 s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=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${s} ${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${s} ${i.maximum.toString()}`}case"too_small":{let s=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${s} ${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${s} ${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:s.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 ${s.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[s.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: ${M(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 O5(){return{localeError:S5()}}var A5=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${i.expected}, al\u0131nan ${o}`:`Ge\xE7ersiz de\u011Fer: beklenen ${s}, al\u0131nan ${o}`}case"invalid_value":return i.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${ce(i.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${s}${i.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${i.origin??"de\u011Fer"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${s}${i.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Ge\xE7ersiz metin: "${s.prefix}" ile ba\u015Flamal\u0131`:s.format==="ends_with"?`Ge\xE7ersiz metin: "${s.suffix}" ile bitmeli`:s.format==="includes"?`Ge\xE7ersiz metin: "${s.includes}" i\xE7ermeli`:s.format==="regex"?`Ge\xE7ersiz metin: ${s.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[s.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":""}: ${M(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 T5(){return{localeError:A5()}}var E5=()=>{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 n={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"},r={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\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 ${s}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${o}`}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 ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=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} ${s}${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 ${s}${i.maximum.toString()}`}case"too_small":{let s=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} ${s}${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 ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.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 "${s.suffix}"`:s.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 "${s.includes}"`:s.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 ${s.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[s.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":""}: ${M(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 QO(){return{localeError:E5()}}function C5(){return QO()}var N5=()=>{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 n={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"},r={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${s} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${o} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return i.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${ce(i.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${M(i.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${i.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${s}${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 ${s}${i.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${i.origin} \u06A9\u06D2 ${s}${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 ${s}${i.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${s.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:s.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${s.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[s.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":""}: ${M(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 P5(){return{localeError:N5()}}var j5=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(i){return e[i]??null}let n={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"},r={nan:"NaN",number:"raqam",array:"massiv"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${i.expected}, qabul qilingan ${o}`:`Noto\u2018g\u2018ri kirish: kutilgan ${s}, qabul qilingan ${o}`}case"invalid_value":return i.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${ce(i.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Juda katta: kutilgan ${i.origin??"qiymat"} ${s}${i.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${i.origin??"qiymat"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Juda kichik: kutilgan ${i.origin} ${s}${i.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${s.prefix}" bilan boshlanishi kerak`:s.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${s.suffix}" bilan tugashi kerak`:s.format==="includes"?`Noto\u2018g\u2018ri satr: "${s.includes}" ni o\u2018z ichiga olishi kerak`:s.format==="regex"?`Noto\u2018g\u2018ri satr: ${s.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[s.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":""}: ${M(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 R5(){return{localeError:j5()}}var M5=()=>{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 n={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"},r={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${s}, nh\u1EADn \u0111\u01B0\u1EE3c ${o}`}case"invalid_value":return i.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${ce(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 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${s}${i.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${i.origin??"gi\xE1 tr\u1ECB"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${a.verb} ${s}${i.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${s.prefix}"`:s.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${s.suffix}"`:s.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${s.includes}"`:s.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${s.pattern}`:`${n[s.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: ${M(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 U5(){return{localeError:M5()}}var L5=()=>{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 n={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"},r={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[a]??a;return/^[A-Z]/.test(i.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${i.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${o}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${s}\uFF0C\u5B9E\u9645\u63A5\u6536 ${o}`}case"invalid_value":return i.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${ce(i.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${s}${i.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${i.origin??"\u503C"} ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${s}${i.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${i.origin} ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${s.prefix}" \u5F00\u5934`:s.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${s.suffix}" \u7ED3\u5C3E`:s.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${s.includes}"`:s.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${s.pattern}`:`\u65E0\u6548${n[s.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): ${M(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 z5(){return{localeError:L5()}}var D5=()=>{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 n={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"},r={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${s}\uFF0C\u4F46\u6536\u5230 ${o}`}case"invalid_value":return i.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${ce(i.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${M(i.values,"|")}`;case"too_big":{let s=i.inclusive?"<=":"<",a=t(i.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${s}${i.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${i.origin??"\u503C"} \u61C9\u70BA ${s}${i.maximum.toString()}`}case"too_small":{let s=i.inclusive?">=":">",a=t(i.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${s}${i.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${i.origin} \u61C9\u70BA ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${s.prefix}" \u958B\u982D`:s.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${s.suffix}" \u7D50\u5C3E`:s.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${s.includes}"`:s.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${s.pattern}`:`\u7121\u6548\u7684 ${n[s.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${M(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 F5(){return{localeError:D5()}}var Z5=()=>{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 n={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"},r={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return i=>{switch(i.code){case"invalid_type":{let s=r[i.expected]??i.expected,a=ue(i.input),o=r[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 ${o}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${s}, \xE0m\u1ECD\u0300 a r\xED ${o}`}case"invalid_value":return i.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${ce(i.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${M(i.values,"|")}`;case"too_big":{let s=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} ${s}${i.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${s}${i.maximum}`}case"too_small":{let s=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} ${s}${i.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${s}${i.minimum}`}case"invalid_format":{let s=i;return s.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 "${s.prefix}"`:s.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${s.suffix}"`:s.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${s.includes}"`:s.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${s.pattern}`:`A\u1E63\xEC\u1E63e: ${n[s.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: ${M(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 B5(){return{localeError:Z5()}}var eA=Object.freeze(Object.defineProperty({__proto__:null,ar:eD,az:nD,be:iD,bg:aD,ca:cD,cs:lD,da:pD,de:mD,el:gD,en:XO,eo:vD,es:wD,fa:xD,fi:ID,fr:OD,frCA:TD,he:CD,hr:PD,hu:RD,hy:UD,id:zD,is:FD,it:BD,ja:JD,ka:VD,kh:WD,km:YO,ko:XD,lt:QD,mk:t5,ms:r5,nl:s5,no:o5,ota:u5,pl:h5,ps:d5,pt:f5,ro:y5,ru:v5,sl:w5,sv:x5,ta:I5,th:O5,tr:T5,ua:C5,uk:QO,ur:P5,uz:R5,vi:U5,yo:B5,zhCN:z5,zhTW:F5},Symbol.toStringTag,{value:"Module"})),ax,tA=Symbol("ZodOutput"),nA=Symbol("ZodInput"),lc=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let r={...this.get(n)??{}};delete r.id;let i={...r,...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 vv(){return new lc}(ax=globalThis).__zod_globalRegistry??(ax.__zod_globalRegistry=vv());var Ve=globalThis.__zod_globalRegistry;function rA(e,t){return new e({type:"string",...P(t)})}function iA(e,t){return new e({type:"string",coerce:!0,...P(t)})}function bv(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function Sd(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function wv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function kv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function xv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function $v(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Ih(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function Iv(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Sv(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Ov(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Av(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function Tv(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Ev(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function Cv(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Nv(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Pv(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function sA(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function jv(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Rv(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Mv(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Uv(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function Lv(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function zv(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}var aA={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function oA(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function cA(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function uA(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function lA(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function dA(e,t){return new e({type:"number",checks:[],...P(t)})}function pA(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function hA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function mA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function fA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function gA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function yA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function _A(e,t){return new e({type:"boolean",...P(t)})}function vA(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function bA(e,t){return new e({type:"bigint",...P(t)})}function wA(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function kA(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function xA(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function $A(e,t){return new e({type:"symbol",...P(t)})}function IA(e,t){return new e({type:"undefined",...P(t)})}function SA(e,t){return new e({type:"null",...P(t)})}function OA(e){return new e({type:"any"})}function Dv(e){return new e({type:"unknown"})}function Fv(e,t){return new e({type:"never",...P(t)})}function AA(e,t){return new e({type:"void",...P(t)})}function TA(e,t){return new e({type:"date",...P(t)})}function EA(e,t){return new e({type:"date",coerce:!0,...P(t)})}function CA(e,t){return new e({type:"nan",...P(t)})}function Si(e,t){return new cv({check:"less_than",...P(t),value:e,inclusive:!1})}function jn(e,t){return new cv({check:"less_than",...P(t),value:e,inclusive:!0})}function Oi(e,t){return new uv({check:"greater_than",...P(t),value:e,inclusive:!1})}function an(e,t){return new uv({check:"greater_than",...P(t),value:e,inclusive:!0})}function Zv(e){return Oi(0,e)}function Bv(e){return Si(0,e)}function qv(e){return jn(0,e)}function Jv(e){return an(0,e)}function Ea(e,t){return new wS({check:"multiple_of",...P(t),value:e})}function eo(e,t){return new $S({check:"max_size",...P(t),maximum:e})}function Ai(e,t){return new IS({check:"min_size",...P(t),minimum:e})}function pu(e,t){return new SS({check:"size_equals",...P(t),size:e})}function hu(e,t){return new OS({check:"max_length",...P(t),maximum:e})}function vs(e,t){return new AS({check:"min_length",...P(t),minimum:e})}function mu(e,t){return new TS({check:"length_equals",...P(t),length:e})}function Sh(e,t){return new ES({check:"string_format",format:"regex",...P(t),pattern:e})}function Oh(e){return new CS({check:"string_format",format:"lowercase",...P(e)})}function Ah(e){return new NS({check:"string_format",format:"uppercase",...P(e)})}function Th(e,t){return new PS({check:"string_format",format:"includes",...P(t),includes:e})}function Eh(e,t){return new jS({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Ch(e,t){return new RS({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Hv(e,t,n){return new MS({check:"property",property:e,schema:t,...P(n)})}function Nh(e,t){return new US({check:"mime_type",mime:e,...P(t)})}function ti(e){return new LS({check:"overwrite",tx:e})}function Ph(e){return ti(t=>t.normalize(e))}function jh(){return ti(e=>e.trim())}function Rh(){return ti(e=>e.toLowerCase())}function Mh(){return ti(e=>e.toUpperCase())}function Uh(){return ti(e=>bI(e))}function NA(e,t,n){return new e({type:"array",element:t,...P(n)})}function q5(e,t,n){return new e({type:"union",options:t,...P(n)})}function J5(e,t,n){return new e({type:"union",options:t,inclusive:!1,...P(n)})}function H5(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...P(r)})}function V5(e,t,n){return new e({type:"intersection",left:t,right:n})}function K5(e,t,n,r){let i=n instanceof ge,s=i?r:n,a=i?n:null;return new e({type:"tuple",items:t,rest:a,...P(s)})}function W5(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...P(r)})}function G5(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...P(r)})}function X5(e,t,n){return new e({type:"set",valueType:t,...P(n)})}function Y5(e,t,n){let r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...P(n)})}function Q5(e,t,n){return new e({type:"enum",entries:t,...P(n)})}function e9(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(n)})}function PA(e,t){return new e({type:"file",...P(t)})}function t9(e,t){return new e({type:"transform",transform:t})}function n9(e,t){return new e({type:"optional",innerType:t})}function r9(e,t){return new e({type:"nullable",innerType:t})}function i9(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():wh(n)}})}function s9(e,t,n){return new e({type:"nonoptional",innerType:t,...P(n)})}function a9(e,t){return new e({type:"success",innerType:t})}function o9(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function c9(e,t,n){return new e({type:"pipe",in:t,out:n})}function u9(e,t){return new e({type:"readonly",innerType:t})}function l9(e,t,n){return new e({type:"template_literal",parts:t,...P(n)})}function d9(e,t){return new e({type:"lazy",getter:t})}function p9(e,t){return new e({type:"promise",innerType:t})}function jA(e,t,n){let r=P(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function RA(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function MA(e,t){let n=UA(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Aa(i,r.value,n._zod.def));else{let s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(Aa(s))}},e(r.value,r)),t);return n}function UA(e,t){let n=new et({check:"custom",...P(t)});return n._zod.check=e,n}function LA(e){let t=new et({check:"describe"});return t._zod.onattach=[n=>{let r=Ve.get(n)??{};Ve.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function zA(e){let t=new et({check:"meta"});return t._zod.onattach=[n=>{let r=Ve.get(n)??{};Ve.add(n,{...r,...e})}],t._zod.check=()=>{},t}function DA(e,t){let n=P(t),r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(h=>typeof h=="string"?h.toLowerCase():h),i=i.map(h=>typeof h=="string"?h.toLowerCase():h));let s=new Set(r),a=new Set(i),o=e.Codec??_v,c=e.Boolean??pv,u=e.String??lu,l=new u({type:"string",error:n.error}),d=new c({type:"boolean",error:n.error}),p=new o({type:"pipe",in:l,out:d,transform:((h,m)=>{let f=h;return n.case!=="sensitive"&&(f=f.toLowerCase()),s.has(f)?!0:a.has(f)?!1:(m.issues.push({code:"invalid_value",expected:"stringbool",values:[...s,...a],input:m.value,inst:p,continue:!1}),{})}),reverseTransform:((h,m)=>h===!0?r[0]||"true":i[0]||"false"),error:n.error});return p}function fu(e,t,n,r={}){let i=P(r),s={...P(r),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...i};return n instanceof RegExp&&(s.pattern=n),new e(s)}function Ca(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??Ve,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 Fe(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let d=a.schema,p=t.processors[i.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);p(e,t,d,u)}let l=e._zod.parent;l&&(a.ref||(a.ref=l),Fe(l,t,u),t.seen.get(l).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&Ht(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Na(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let a of e.seen.entries()){let o=e.metadataRegistry.get(a[0])?.id;if(o){let c=r.get(o);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(o,a[0])}}let i=a=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(a[0])?.id,d=e.external.uri??(h=>h);if(l)return{ref:d(l)};let p=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=p,{defId:p,ref:`${d("__shared")}#/${o}/${p}`}}if(a[1]===n)return{ref:"#"};let c=`#/${o}/`,u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},s=a=>{if(a[1].schema.$ref)return;let o=a[1],{ref:c,defId:u}=i(a);o.def={...o.schema},u&&(o.defId=u);let l=o.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let o=a[1];if(o.cycle)throw new Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
|
|
127
|
+
|
|
128
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let o=a[1];if(t===a[0]){s(a);continue}if(e.external){let c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(o.cycle){s(a);continue}if(o.count>1&&e.reused==="ref"){s(a);continue}}}function Pa(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=o=>{let c=e.seen.get(o);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){r(d);let h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),o._zod.parent===d)for(let f in u)f==="$ref"||f==="allOf"||f in l||delete u[f];if(m.$ref&&h.def)for(let f in u)f==="$ref"||f==="allOf"||f in h.def&&JSON.stringify(u[f])===JSON.stringify(h.def[f])&&delete u[f]}let p=o._zod.parent;if(p&&p!==d){r(p);let h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(let m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:o,jsonSchema:u,path:c.path??[]})};for(let o of[...e.seen.entries()].reverse())r(o[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 o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(o)}Object.assign(i,n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&i.id===s&&delete i.id;let a=e.external?.defs??{};for(let o of e.seen.entries()){let c=o[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?i.$defs=a:i.definitions=a);try{let o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:dc(t,"input",e.processors),output:dc(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function Ht(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ht(r.element,n);if(r.type==="set")return Ht(r.valueType,n);if(r.type==="lazy")return Ht(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Ht(r.innerType,n);if(r.type==="intersection")return Ht(r.left,n)||Ht(r.right,n);if(r.type==="record"||r.type==="map")return Ht(r.keyType,n)||Ht(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ht(r.in,n)||Ht(r.out,n);if(r.type==="object"){for(let i in r.shape)if(Ht(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(let i of r.options)if(Ht(i,n))return!0;return!1}if(r.type==="tuple"){for(let i of r.items)if(Ht(i,n))return!0;return!!(r.rest&&Ht(r.rest,n))}return!1}var FA=(e,t={})=>n=>{let r=Ca({...n,processors:t});return Fe(e,r),Na(r,e),Pa(r,e)},dc=(e,t,n={})=>r=>{let{libraryOptions:i,target:s}=r??{},a=Ca({...i??{},target:s,io:t,processors:n});return Fe(e,a),Na(a,e),Pa(a,e)},h9={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ZA=(e,t,n,r)=>{let i=n;i.type="string";let{minimum:s,maximum:a,format:o,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=h9[o]??o,i.format===""&&delete i.format,o==="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}))])}},BA=(e,t,n,r)=>{let i=n,{minimum:s,maximum:a,format:o,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";d?h?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof s=="number"&&(i.minimum=s),p?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof a=="number"&&(i.maximum=a),typeof c=="number"&&(i.multipleOf=c)},qA=(e,t,n,r)=>{n.type="boolean"},JA=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},HA=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},VA=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},KA=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},WA=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},GA=(e,t,n,r)=>{n.not={}},XA=(e,t,n,r)=>{},YA=(e,t,n,r)=>{},QA=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},eT=(e,t,n,r)=>{let i=e._zod.def,s=Z_(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},tT=(e,t,n,r)=>{let i=e._zod.def,s=[];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");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){let a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},nT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},rT=(e,t,n,r)=>{let i=n,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},iT=(e,t,n,r)=>{let i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:c}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),c?c.length===1?(s.contentMediaType=c[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,s)},sT=(e,t,n,r)=>{n.type="boolean"},aT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},oT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},cT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},uT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},lT=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},dT=(e,t,n,r)=>{let i=n,s=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof o=="number"&&(i.maxItems=o),i.type="array",i.items=Fe(s.element,t,{...r,path:[...r.path,"items"]})},pT=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="object",i.properties={};let a=s.shape;for(let u in a)i.properties[u]=Fe(a[u],t,{...r,path:[...r.path,"properties",u]});let o=new Set(Object.keys(a)),c=new Set([...o].filter(u=>{let l=s.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Fe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Vv=(e,t,n,r)=>{let i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,c)=>Fe(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=a:n.anyOf=a},hT=(e,t,n,r)=>{let i=e._zod.def,s=Fe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Fe(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=u=>"allOf"in u&&Object.keys(u).length===1,c=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=c},mT=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((p,h)=>Fe(p,t,{...r,path:[...r.path,a,h]})),u=s.rest?Fe(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.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)},fT=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="object";let a=s.keyType,o=a._zod.bag?.patterns;if(s.mode==="loose"&&o&&o.size>0){let u=Fe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let l of o)i.patternProperties[l.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Fe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Fe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let c=a._zod.values;if(c){let u=[...c].filter(l=>typeof l=="string"||typeof l=="number");u.length>0&&(i.required=u)}},gT=(e,t,n,r)=>{let i=e._zod.def,s=Fe(i.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},yT=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},_T=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},vT=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},bT=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},wT=(e,t,n,r)=>{let i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?i.out:i.in:i.out;Fe(a,t,r);let o=t.seen.get(e);o.ref=a},kT=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},xT=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},Kv=(e,t,n,r)=>{let i=e._zod.def;Fe(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},$T=(e,t,n,r)=>{let i=e._zod.innerType;Fe(i,t,r);let s=t.seen.get(e);s.ref=i},Dg={string:ZA,number:BA,boolean:qA,bigint:JA,symbol:HA,null:VA,undefined:KA,void:WA,never:GA,any:XA,unknown:YA,date:QA,enum:eT,literal:tT,nan:nT,template_literal:rT,file:iT,success:sT,custom:aT,function:oT,transform:cT,map:uT,set:lT,array:dT,object:pT,union:Vv,intersection:hT,tuple:mT,record:fT,nullable:gT,nonoptional:yT,default:_T,prefault:vT,catch:bT,pipe:wT,readonly:kT,promise:xT,optional:Kv,lazy:$T};function pc(e,t){if("_idmap"in e){let r=e,i=Ca({...t,processors:Dg}),s={};for(let c of r._idmap.entries()){let[u,l]=c;Fe(l,i)}let a={},o={registry:r,uri:t?.uri,defs:s};i.external=o;for(let c of r._idmap.entries()){let[u,l]=c;Na(i,l),a[u]=Pa(i,l)}if(Object.keys(s).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:s}}return{schemas:a}}let n=Ca({...t,processors:Dg});return Fe(e,n),Na(n,e),Pa(n,e)}var Fg=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 n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Ca({processors:Dg,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return Fe(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),Na(this.ctx,t);let r=Pa(this.ctx,t),{"~standard":i,...s}=r;return s}},m9=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f9=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:_O,$ZodArray:wO,$ZodAsyncError:Hr,$ZodBase64:aO,$ZodBase64URL:cO,$ZodBigInt:hv,$ZodBigIntFormat:mO,$ZodBoolean:pv,$ZodCIDRv4:iO,$ZodCIDRv6:sO,$ZodCUID:HS,$ZodCUID2:VS,$ZodCatch:ZO,$ZodCheck:et,$ZodCheckBigIntFormat:xS,$ZodCheckEndsWith:RS,$ZodCheckGreaterThan:uv,$ZodCheckIncludes:PS,$ZodCheckLengthEquals:TS,$ZodCheckLessThan:cv,$ZodCheckLowerCase:CS,$ZodCheckMaxLength:OS,$ZodCheckMaxSize:$S,$ZodCheckMimeType:US,$ZodCheckMinLength:AS,$ZodCheckMinSize:IS,$ZodCheckMultipleOf:wS,$ZodCheckNumberFormat:kS,$ZodCheckOverwrite:LS,$ZodCheckProperty:MS,$ZodCheckRegex:ES,$ZodCheckSizeEquals:SS,$ZodCheckStartsWith:jS,$ZodCheckStringFormat:uu,$ZodCheckUpperCase:NS,$ZodCodec:_v,$ZodCustom:GO,$ZodCustomStringFormat:pO,$ZodDate:bO,$ZodDefault:LO,$ZodDiscriminatedUnion:OO,$ZodE164:uO,$ZodEmail:ZS,$ZodEmoji:qS,$ZodEncodeError:Sa,$ZodEnum:NO,$ZodError:H_,$ZodExactOptional:MO,$ZodFile:jO,$ZodFunction:VO,$ZodGUID:DS,$ZodIPv4:tO,$ZodIPv6:nO,$ZodISODate:YS,$ZodISODateTime:XS,$ZodISODuration:eO,$ZodISOTime:QS,$ZodIntersection:AO,$ZodJWT:dO,$ZodKSUID:GS,$ZodLazy:WO,$ZodLiteral:PO,$ZodMAC:rO,$ZodMap:EO,$ZodNaN:BO,$ZodNanoID:JS,$ZodNever:fv,$ZodNonOptional:DO,$ZodNull:yO,$ZodNullable:UO,$ZodNumber:dv,$ZodNumberFormat:hO,$ZodObject:$O,$ZodObjectJIT:IO,$ZodOptional:du,$ZodPipe:yv,$ZodPrefault:zO,$ZodPreprocess:qO,$ZodPromise:KO,$ZodReadonly:JO,$ZodRealError:In,$ZodRecord:TO,$ZodRegistry:lc,$ZodSet:CO,$ZodString:lu,$ZodStringFormat:Ze,$ZodSuccess:FO,$ZodSymbol:fO,$ZodTemplateLiteral:HO,$ZodTransform:RO,$ZodTuple:gv,$ZodType:ge,$ZodULID:KS,$ZodURL:BS,$ZodUUID:FS,$ZodUndefined:gO,$ZodUnion:$h,$ZodUnknown:mv,$ZodVoid:vO,$ZodXID:WS,$ZodXor:SO,$brand:_I,$constructor:$,$input:nA,$output:tA,Doc:$d,JSONSchema:m9,JSONSchemaGenerator:Fg,NEVER:yI,TimePrecision:aA,_any:OA,_array:NA,_base64:Mv,_base64url:Uv,_bigint:bA,_boolean:_A,_catch:o9,_check:UA,_cidrv4:jv,_cidrv6:Rv,_coercedBigint:wA,_coercedBoolean:vA,_coercedDate:EA,_coercedNumber:pA,_coercedString:iA,_cuid:Ov,_cuid2:Av,_custom:jA,_date:TA,_decode:X_,_decodeAsync:Q_,_default:i9,_discriminatedUnion:H5,_e164:Lv,_email:bv,_emoji:Iv,_encode:G_,_encodeAsync:Y_,_endsWith:Ch,_enum:Y5,_file:PA,_float32:mA,_float64:fA,_gt:Oi,_gte:an,_guid:Sd,_includes:Th,_int:hA,_int32:gA,_int64:kA,_intersection:V5,_ipv4:Nv,_ipv6:Pv,_isoDate:cA,_isoDateTime:oA,_isoDuration:lA,_isoTime:uA,_jwt:zv,_ksuid:Cv,_lazy:d9,_length:mu,_literal:e9,_lowercase:Oh,_lt:Si,_lte:jn,_mac:sA,_map:G5,_max:jn,_maxLength:hu,_maxSize:eo,_mime:Nh,_min:an,_minLength:vs,_minSize:Ai,_multipleOf:Ea,_nan:CA,_nanoid:Sv,_nativeEnum:Q5,_negative:Bv,_never:Fv,_nonnegative:Jv,_nonoptional:s9,_nonpositive:qv,_normalize:Ph,_null:SA,_nullable:r9,_number:dA,_optional:n9,_overwrite:ti,_parse:ru,_parseAsync:iu,_pipe:c9,_positive:Zv,_promise:p9,_property:Hv,_readonly:u9,_record:W5,_refine:RA,_regex:Sh,_safeDecode:tv,_safeDecodeAsync:rv,_safeEncode:ev,_safeEncodeAsync:nv,_safeParse:su,_safeParseAsync:au,_set:X5,_size:pu,_slugify:Uh,_startsWith:Eh,_string:rA,_stringFormat:fu,_stringbool:DA,_success:a9,_superRefine:MA,_symbol:$A,_templateLiteral:l9,_toLowerCase:Rh,_toUpperCase:Mh,_transform:t9,_trim:jh,_tuple:K5,_uint32:yA,_uint64:xA,_ulid:Tv,_undefined:IA,_union:q5,_unknown:Dv,_uppercase:Ah,_url:Ih,_uuid:wv,_uuidv4:kv,_uuidv6:xv,_uuidv7:$v,_void:AA,_xid:Ev,_xor:J5,clone:ut,config:Rt,createStandardJSONSchemaMethod:dc,createToJSONSchemaMethod:FA,decode:kz,decodeAsync:$z,describe:LA,encode:wz,encodeAsync:xz,extractDefs:Na,finalize:Pa,flattenError:V_,formatError:K_,globalConfig:cc,globalRegistry:Ve,initializeContext:Ca,isValidBase64:lv,isValidBase64URL:oO,isValidJWT:lO,locales:eA,meta:zA,parse:_s,parseAsync:uc,prettifyError:W_,process:Fe,regexes:ov,registry:vv,safeDecode:Sz,safeDecodeAsync:Az,safeEncode:Iz,safeEncodeAsync:Oz,safeParse:LI,safeParseAsync:zI,toDotPath:UI,toJSONSchema:pc,treeifyError:MI,util:jI,version:zS},Symbol.toStringTag,{value:"Module"}));function We(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_zod"in t))return!1;let n=t._zod;return typeof n=="object"&&n!==null&&"def"in n}function pt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(!("_def"in t)||"_zod"in t)return!1;let n=t._def;return typeof n=="object"&&n!=null&&"typeName"in n}function g9(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."),pt(e)}function _n(e){return!e||typeof e!="object"||Array.isArray(e)?!1:!!(We(e)||pt(e))}function IT(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 ST(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 y9(e){return!!(IT(e)||ST(e))}async function OT(e,t){if(We(e))try{return{success:!0,data:await uc(e,t)}}catch(n){return{success:!1,error:n}}if(pt(e))return await e.safeParseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}async function Lh(e,t){if(We(e))return await uc(e,t);if(pt(e))return await e.parseAsync(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function _9(e,t){if(We(e))try{return{success:!0,data:_s(e,t)}}catch(n){return{success:!1,error:n}}if(pt(e))return e.safeParse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function Bl(e,t){if(We(e))return _s(e,t);if(pt(e))return e.parse(t);throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function ja(e){if(We(e))return Ve.get(e)?.description;if(pt(e)||"description"in e&&typeof e.description=="string")return e.description}function v9(e){if(!_n(e))return!1;if(pt(e)){let t=e._def;if(t.typeName==="ZodObject"){let n=e;return!n.shape||Object.keys(n.shape).length===0}if(t.typeName==="ZodRecord")return!0}if(We(e)){let t=e._zod.def;if(t.type==="object"){let n=e;return!n.shape||Object.keys(n.shape).length===0}if(t.type==="record")return!0}return typeof e=="object"&&e!==null&&!("shape"in e)}function Wv(e){return _n(e)?pt(e)?e._def.typeName==="ZodString":We(e)?e._zod.def.type==="string":!1:!1}function zh(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 wr(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 Dh(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 AT(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 TT(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 En(e){return!!(zh(e)||wr(e))}function hc(e){if(pt(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 ET(e,t){if(pt(e))return e.extend(t);if(We(e))return q_(e,t);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Gv(e){if(pt(e))return e.partial();if(We(e))return J_(du,e,void 0);throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Od(e,t=!1){if(zh(e))return e.strict();if(wr(e)){let n=e._zod.def.shape;if(t)for(let[s,a]of Object.entries(e._zod.def.shape)){if(wr(a))n[s]=Od(a,t);else if(Dh(a)){let c=a._zod.def.element;wr(c)&&(c=Od(c,t)),n[s]=ut(a,{...a._zod.def,element:c})}else n[s]=a;let o=Ve.get(a);o&&Ve.add(n[s],o)}let r=ut(e,{...e._zod.def,shape:n,catchall:Fv(fv)}),i=Ve.get(e);return i&&Ve.add(r,i),r}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Zg(e,t=!1){if(zh(e))return e.passthrough();if(wr(e)){let n=e._zod.def.shape;if(t)for(let[s,a]of Object.entries(e._zod.def.shape)){if(wr(a))n[s]=Zg(a,t);else if(Dh(a)){let c=a._zod.def.element;wr(c)&&(c=Zg(c,t)),n[s]=ut(a,{...a._zod.def,element:c})}else n[s]=a;let o=Ve.get(a);o&&Ve.add(n[s],o)}let r=ut(e,{...e._zod.def,shape:n,catchall:Dv(mv)}),i=Ve.get(e);return i&&Ve.add(r,i),r}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function Fh(e){if(pt(e))try{let t=e.parse(void 0);return()=>t}catch{return}if(We(e))try{let t=_s(e,void 0);return()=>t}catch{return}}function b9(e){return pt(e)&&"typeName"in e._def&&e._def.typeName==="ZodEffects"}function w9(e){return We(e)&&e._zod.def.type==="pipe"}function Ki(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(pt(e))return b9(e)?Ki(e._def.schema,t,n):e;if(We(e)){let i=e;if(w9(e)&&(i=Ki(e._zod.def.in,t,n)),t){if(wr(i)){let a={};for(let[o,c]of Object.entries(i._zod.def.shape))a[o]=Ki(c,t,n);i=ut(i,{...i._zod.def,shape:a})}else if(Dh(i)){let a=Ki(i._zod.def.element,t,n);i=ut(i,{...i._zod.def,element:a})}else if(AT(i)){let a=Ki(i._zod.def.innerType,t,n);i=ut(i,{...i._zod.def,innerType:a})}else if(TT(i)){let a=Ki(i._zod.def.innerType,t,n);i=ut(i,{...i._zod.def,innerType:a})}}let s=Ve.get(e);return s&&Ve.add(i,s),n.set(e,i),i}throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType")}function CT(e,t=!1){return Ki(e,t,new WeakMap)}function k9(e,t){if(pt(e)){let n=hc(e),r={};for(let[i,s]of Object.entries(n))t(i,s)?r[i]=s.optional():r[i]=s;return e.extend(r)}if(We(e)){let n=hc(e),r={...e._zod.def.shape};for(let[a,o]of Object.entries(n))t(a,o)&&(r[a]=new du({type:"optional",innerType:o}));let i=ut(e,{...e._zod.def,shape:r}),s=Ve.get(e);return s&&Ve.add(i,s),i}throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject")}function NT(e){return e instanceof Error&&(e.constructor.name==="ZodError"||e.constructor.name==="$ZodError")}var x9=Symbol("Let zodToJsonSchema decide on which parser to use"),$9={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"},I9=e=>({...$9,...e}),S9=e=>{let t=I9(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},PT=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function ln(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?PT(t,e.currentPath):t.join("/")}}function jT(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Me(e,t,n,r,i){e[t]=n,jT(e,t,r,i)}var Ee;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{let s={};for(let a of i)s[a]=a;return s},e.getValidEnumValues=i=>{let s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(let o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(let a of i)if(s(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 r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ee||(Ee={}));var ox;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ox||(ox={}));var Y=Ee.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 Y.undefined;case"string":return Y.string;case"number":return Number.isNaN(e)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(e)?Y.array:e===null?Y.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Y.promise:typeof Map<"u"&&e instanceof Map?Y.map:typeof Set<"u"&&e instanceof Set?Y.set:typeof Date<"u"&&e instanceof Date?Y.date:Y.object;default:return Y.unknown}},L=Ee.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"]),kr=class RT extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(let a of s.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)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),r}static assert(t){if(!(t instanceof RT))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n=Object.create(null),r=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};kr.create=e=>new kr(e);var mc=(e,t)=>{let n;switch(e.code){case L.invalid_type:e.received===Y.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case L.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ee.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ee.joinValues(e.keys,", ")}`;break;case L.invalid_union:n="Invalid input";break;case L.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ee.joinValues(e.options)}`;break;case L.invalid_enum_value:n=`Invalid enum value. Expected ${Ee.joinValues(e.options)}, received '${e.received}'`;break;case L.invalid_arguments:n="Invalid function arguments";break;case L.invalid_return_type:n="Invalid function return type";break;case L.invalid_date:n="Invalid date";break;case L.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ee.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case L.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case L.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case L.custom:n="Invalid input";break;case L.invalid_intersection_types:n="Intersection results could not be merged";break;case L.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case L.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ee.assertNever(e)}return{message:n}},O9=mc;function Bg(){return O9}var qg=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)o=u(a,{data:t,defaultError:o}).message;return{...i,path:s,message:o}};function J(e,t){let n=Bg(),r=qg({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===mc?void 0:mc].filter(i=>!!i)});e.common.issues.push(r)}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,n){let r=[];for(let i of n){if(i.status==="aborted")return me;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){let r=[];for(let i of n){let s=await i.key,a=await i.value;r.push({key:s,value:a})}return e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return me;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:t.value,value:r}}},me=Object.freeze({status:"aborted"}),Jg=e=>({status:"dirty",value:e}),dn=e=>({status:"valid",value:e}),cx=e=>e.status==="aborted",ux=e=>e.status==="dirty",Ra=e=>e.status==="valid",Ad=e=>typeof Promise<"u"&&e instanceof Promise,re;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(re||(re={}));var Un=class{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,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}},lx=(e,t)=>{if(Ra(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 n=new kr(e.common.issues);return this._error=n,this._error}}};function we(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))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:(s,a)=>{let{message:o}=e;return s.code==="invalid_enum_value"?{message:o??a.defaultError}:typeof a.data>"u"?{message:o??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:o??n??a.defaultError}},description:i}}var Se=class{get description(){return this._def.description}_getType(e){return oi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:oi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Xt,ctx:{common:e.parent.common,data:e.data,parsedType:oi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ad(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oi(e)},r=this._parseSync({data:e,path:n.path,parent:n});return lx(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oi(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ra(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>Ra(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oi(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(Ad(r)?r:Promise.resolve(r));return lx(n,i)}refine(e,t){let n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,i)=>{let s=e(r),a=()=>i.addIssue({code:L.custom,...n(r)});return typeof Promise<"u"&&s instanceof Promise?s.then(o=>o?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Ei({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return vi.create(this,this._def)}nullable(){return Ua.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ma.create(this)}promise(){return gc.create(this,this._def)}or(e){return Ed.create([this,e],this._def)}and(e){return Cd.create(this,e,this._def)}transform(e){return new Ei({...we(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ty({...we(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new ry({typeName:N.ZodBranded,type:this,...we(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ny({...we(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return iy.create(this,e)}readonly(){return sy.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},A9=/^c[^\s-]{8,}$/i,T9=/^[0-9a-z]+$/,E9=/^[0-9A-HJKMNP-TV-Z]{26}$/i,C9=/^[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,N9=/^[a-z0-9_-]{21}$/i,P9=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,j9=/^[-+]?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)?)??$/,R9=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,M9="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gf,U9=/^(?:(?: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])$/,L9=/^(?:(?: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])$/,z9=/^(([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]))$/,D9=/^(([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])$/,F9=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Z9=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,MT="((\\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])))",B9=new RegExp(`^${MT}$`);function UT(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function q9(e){return new RegExp(`^${UT(e)}$`)}function J9(e){let t=`${MT}T${UT(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function H9(e,t){return!!((t==="v4"||!t)&&U9.test(e)||(t==="v6"||!t)&&z9.test(e))}function V9(e,t){if(!P9.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function K9(e,t){return!!((t==="v4"||!t)&&L9.test(e)||(t==="v6"||!t)&&D9.test(e))}var Td=class To extends Se{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Y.string){let i=this._getOrReturnCtx(t);return J(i,{code:L.invalid_type,expected:Y.string,received:i.parsedType}),me}let n=new Xt,r;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(r=this._getOrReturnCtx(t,r),J(r,{code:L.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(r=this._getOrReturnCtx(t,r),J(r,{code:L.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let s=t.data.length>i.value,a=t.data.length<i.value;(s||a)&&(r=this._getOrReturnCtx(t,r),s?J(r,{code:L.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&J(r,{code:L.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")R9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"email",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")gf||(gf=new RegExp(M9,"u")),gf.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"emoji",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")C9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"uuid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")N9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"nanoid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")A9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"cuid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")T9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"cuid2",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")E9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"ulid",code:L.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),J(r,{validation:"url",code:L.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"regex",code:L.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?J9(i).test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?B9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?q9(i).test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{code:L.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?j9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"duration",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?H9(t.data,i.version)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"ip",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?V9(t.data,i.alg)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"jwt",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?K9(t.data,i.version)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"cidr",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?F9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"base64",code:L.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Z9.test(t.data)||(r=this._getOrReturnCtx(t,r),J(r,{validation:"base64url",code:L.invalid_string,message:i.message}),n.dirty()):Ee.assertNever(i);return{status:n.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:L.invalid_string,...re.errToObj(r)})}_addCheck(t){return new To({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...re.errToObj(t)})}url(t){return this._addCheck({kind:"url",...re.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...re.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...re.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...re.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...re.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...re.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...re.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...re.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...re.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...re.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...re.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...re.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,...re.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,...re.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...re.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...re.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...re.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...re.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...re.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...re.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...re.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...re.errToObj(n)})}nonempty(t){return this.min(1,re.errToObj(t))}trim(){return new To({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new To({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new To({...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 n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Td.create=e=>new Td({checks:[],typeName:N.ZodString,coerce:e?.coerce??!1,...we(e)});function W9(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}var Hg=class Vg extends Se{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)!==Y.number){let i=this._getOrReturnCtx(t);return J(i,{code:L.invalid_type,expected:Y.number,received:i.parsedType}),me}let n,r=new Xt;for(let i of this._def.checks)i.kind==="int"?Ee.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),J(n,{code:L.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?W9(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),J(n,{code:L.not_finite,message:i.message}),r.dirty()):Ee.assertNever(i);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,re.toString(n))}gt(t,n){return this.setLimit("min",t,!1,re.toString(n))}lte(t,n){return this.setLimit("max",t,!0,re.toString(n))}lt(t,n){return this.setLimit("max",t,!1,re.toString(n))}setLimit(t,n,r,i){return new Vg({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:re.toString(i)}]})}_addCheck(t){return new Vg({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:re.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:re.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:re.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:re.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:re.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ee.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Hg.create=e=>new Hg({checks:[],typeName:N.ZodNumber,coerce:e?.coerce||!1,...we(e)});var dx=class Kg extends Se{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)!==Y.bigint)return this._getInvalidInput(t);let n,r=new Xt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),J(n,{code:L.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):Ee.assertNever(i);return{status:r.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return J(n,{code:L.invalid_type,expected:Y.bigint,received:n.parsedType}),me}gte(t,n){return this.setLimit("min",t,!0,re.toString(n))}gt(t,n){return this.setLimit("min",t,!1,re.toString(n))}lte(t,n){return this.setLimit("max",t,!0,re.toString(n))}lt(t,n){return this.setLimit("max",t,!1,re.toString(n))}setLimit(t,n,r,i){return new Kg({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:re.toString(i)}]})}_addCheck(t){return new Kg({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:re.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:re.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:re.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:re.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:re.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};dx.create=e=>new dx({checks:[],typeName:N.ZodBigInt,coerce:e?.coerce??!1,...we(e)});var Wg=class extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.boolean,received:t.parsedType}),me}return dn(e.data)}};Wg.create=e=>new Wg({typeName:N.ZodBoolean,coerce:e?.coerce||!1,...we(e)});var px=class LT extends Se{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Y.date){let i=this._getOrReturnCtx(t);return J(i,{code:L.invalid_type,expected:Y.date,received:i.parsedType}),me}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return J(i,{code:L.invalid_date}),me}let n=new Xt,r;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(r=this._getOrReturnCtx(t,r),J(r,{code:L.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(r=this._getOrReturnCtx(t,r),J(r,{code:L.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Ee.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new LT({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:re.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:re.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};px.create=e=>new px({checks:[],coerce:e?.coerce||!1,typeName:N.ZodDate,...we(e)});var hx=class extends Se{_parse(e){if(this._getType(e)!==Y.symbol){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.symbol,received:t.parsedType}),me}return dn(e.data)}};hx.create=e=>new hx({typeName:N.ZodSymbol,...we(e)});var mx=class extends Se{_parse(e){if(this._getType(e)!==Y.undefined){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.undefined,received:t.parsedType}),me}return dn(e.data)}};mx.create=e=>new mx({typeName:N.ZodUndefined,...we(e)});var fx=class extends Se{_parse(e){if(this._getType(e)!==Y.null){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.null,received:t.parsedType}),me}return dn(e.data)}};fx.create=e=>new fx({typeName:N.ZodNull,...we(e)});var fc=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}};fc.create=e=>new fc({typeName:N.ZodAny,...we(e)});var ma=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}};ma.create=e=>new ma({typeName:N.ZodUnknown,...we(e)});var Ti=class extends Se{_parse(e){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.never,received:t.parsedType}),me}};Ti.create=e=>new Ti({typeName:N.ZodNever,...we(e)});var gx=class extends Se{_parse(e){if(this._getType(e)!==Y.undefined){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.void,received:t.parsedType}),me}return dn(e.data)}};gx.create=e=>new gx({typeName:N.ZodVoid,...we(e)});var Ma=class ql extends Se{_parse(t){let{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==Y.array)return J(n,{code:L.invalid_type,expected:Y.array,received:n.parsedType}),me;if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(J(n,{code:a?L.too_big:L.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(J(n,{code:L.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(J(n,{code:L.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new Un(n,a,n.path,o)))).then(a=>Xt.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new Un(n,a,n.path,o)));return Xt.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ql({...this._def,minLength:{value:t,message:re.toString(n)}})}max(t,n){return new ql({...this._def,maxLength:{value:t,message:re.toString(n)}})}length(t,n){return new ql({...this._def,exactLength:{value:t,message:re.toString(n)}})}nonempty(t){return this.min(1,t)}};Ma.create=(e,t)=>new Ma({type:e,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...we(t)});function Gs(e){if(e instanceof Xr){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=vi.create(Gs(r))}return new Xr({...e._def,shape:()=>t})}else return e instanceof Ma?new Ma({...e._def,type:Gs(e.element)}):e instanceof vi?vi.create(Gs(e.unwrap())):e instanceof Ua?Ua.create(Gs(e.unwrap())):e instanceof bs?bs.create(e.items.map(t=>Gs(t))):e}var Xr=class Hn extends Se{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(),n=Ee.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Y.object){let c=this._getOrReturnCtx(t);return J(c,{code:L.invalid_type,expected:Y.object,received:c.parsedType}),me}let{status:n,ctx:r}=this._processInputParams(t),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ti&&this._def.unknownKeys==="strip"))for(let c in r.data)s.includes(c)||a.push(c);let o=[];for(let c of s){let u=i[c],l=r.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Un(r,l,r.path,c)),alwaysSet:c in r.data})}if(this._def.catchall instanceof Ti){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(c==="strict")a.length>0&&(J(r,{code:L.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of a){let l=r.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Un(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of o){let l=await u.key,d=await u.value;c.push({key:l,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>Xt.mergeObjectSync(n,c)):Xt.mergeObjectSync(n,o)}get shape(){return this._def.shape()}strict(t){return re.errToObj,new Hn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:re.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Hn({...this._def,unknownKeys:"strip"})}passthrough(){return new Hn({...this._def,unknownKeys:"passthrough"})}extend(t){return new Hn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Hn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:N.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Hn({...this._def,catchall:t})}pick(t){let n={};for(let r of Ee.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Hn({...this._def,shape:()=>n})}omit(t){let n={};for(let r of Ee.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Hn({...this._def,shape:()=>n})}deepPartial(){return Gs(this)}partial(t){let n={};for(let r of Ee.objectKeys(this.shape)){let i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Hn({...this._def,shape:()=>n})}required(t){let n={};for(let r of Ee.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof vi;)i=i._def.innerType;n[r]=i}return new Hn({...this._def,shape:()=>n})}keyof(){return DT(Ee.objectKeys(this.shape))}};Xr.create=(e,t)=>new Xr({shape:()=>e,unknownKeys:"strip",catchall:Ti.create(),typeName:N.ZodObject,...we(t)});Xr.strictCreate=(e,t)=>new Xr({shape:()=>e,unknownKeys:"strict",catchall:Ti.create(),typeName:N.ZodObject,...we(t)});Xr.lazycreate=(e,t)=>new Xr({shape:e,unknownKeys:"strip",catchall:Ti.create(),typeName:N.ZodObject,...we(t)});var Ed=class extends Se{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new kr(a.ctx.common.issues));return J(t,{code:L.invalid_union,unionErrors:s}),me}if(t.common.async)return Promise.all(n.map(async i=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(r);{let i,s=[];for(let o of n){let c={...t,common:{...t.common,issues:[]},parent:null},u=o._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(o=>new kr(o));return J(t,{code:L.invalid_union,unionErrors:a}),me}}get options(){return this._def.options}};Ed.create=(e,t)=>new Ed({options:e,typeName:N.ZodUnion,...we(t)});function Gg(e,t){let n=oi(e),r=oi(t);if(e===t)return{valid:!0,data:e};if(n===Y.object&&r===Y.object){let i=Ee.objectKeys(t),s=Ee.objectKeys(e).filter(o=>i.indexOf(o)!==-1),a={...e,...t};for(let o of s){let c=Gg(e[o],t[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===Y.array&&r===Y.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<e.length;s++){let a=e[s],o=t[s],c=Gg(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===Y.date&&r===Y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Cd=class extends Se{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(i,s)=>{if(cx(i)||cx(s))return me;let a=Gg(i.value,s.value);return a.valid?((ux(i)||ux(s))&&t.dirty(),{status:t.value,value:a.data}):(J(n,{code:L.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(([i,s])=>r(i,s)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Cd.create=(e,t,n)=>new Cd({left:e,right:t,typeName:N.ZodIntersection,...we(n)});var bs=class zT extends Se{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Y.array)return J(r,{code:L.invalid_type,expected:Y.array,received:r.parsedType}),me;if(r.data.length<this._def.items.length)return J(r,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&r.data.length>this._def.items.length&&(J(r,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((s,a)=>{let o=this._def.items[a]||this._def.rest;return o?o._parse(new Un(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>Xt.mergeArray(n,s)):Xt.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new zT({...this._def,rest:t})}};bs.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bs({items:e,typeName:N.ZodTuple,rest:null,...we(t)})};var G9=class Xg extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Y.object)return J(r,{code:L.invalid_type,expected:Y.object,received:r.parsedType}),me;let i=[],s=this._def.keyType,a=this._def.valueType;for(let o in r.data)i.push({key:s._parse(new Un(r,o,r.path,o)),value:a._parse(new Un(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Xt.mergeObjectAsync(n,i):Xt.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Se?new Xg({keyType:t,valueType:n,typeName:N.ZodRecord,...we(r)}):new Xg({keyType:Td.create(),valueType:t,typeName:N.ZodRecord,...we(n)})}},yx=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.map)return J(n,{code:L.invalid_type,expected:Y.map,received:n.parsedType}),me;let r=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([a,o],c)=>({key:r._parse(new Un(n,a,n.path,[c,"key"])),value:i._parse(new Un(n,o,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let o of s){let c=await o.key,u=await o.value;if(c.status==="aborted"||u.status==="aborted")return me;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}})}else{let a=new Map;for(let o of s){let c=o.key,u=o.value;if(c.status==="aborted"||u.status==="aborted")return me;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),a.set(c.value,u.value)}return{status:t.value,value:a}}}};yx.create=(e,t,n)=>new yx({valueType:t,keyType:e,typeName:N.ZodMap,...we(n)});var _x=class Yg extends Se{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Y.set)return J(r,{code:L.invalid_type,expected:Y.set,received:r.parsedType}),me;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(J(r,{code:L.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(J(r,{code:L.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return me;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let o=[...r.data.values()].map((c,u)=>s._parse(new Un(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(t,n){return new Yg({...this._def,minSize:{value:t,message:re.toString(n)}})}max(t,n){return new Yg({...this._def,maxSize:{value:t,message:re.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};_x.create=(e,t)=>new _x({valueType:e,minSize:null,maxSize:null,typeName:N.ZodSet,...we(t)});var X9=class Jl extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==Y.function)return J(n,{code:L.invalid_type,expected:Y.function,received:n.parsedType}),me;function r(o,c){return qg({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Bg(),mc].filter(u=>!!u),issueData:{code:L.invalid_arguments,argumentsError:c}})}function i(o,c){return qg({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Bg(),mc].filter(u=>!!u),issueData:{code:L.invalid_return_type,returnTypeError:c}})}let s={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof gc){let o=this;return dn(async function(...c){let u=new kr([]),l=await o._def.args.parseAsync(c,s).catch(p=>{throw u.addIssue(r(c,p)),u}),d=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(d,s).catch(p=>{throw u.addIssue(i(d,p)),u})})}else{let o=this;return dn(function(...c){let u=o._def.args.safeParse(c,s);if(!u.success)throw new kr([r(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=o._def.returns.safeParse(l,s);if(!d.success)throw new kr([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Jl({...this._def,args:bs.create(t).rest(ma.create())})}returns(t){return new Jl({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new Jl({args:t||bs.create([]).rest(ma.create()),returns:n||ma.create(),typeName:N.ZodFunction,...we(r)})}},vx=class extends Se{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};vx.create=(e,t)=>new vx({getter:e,typeName:N.ZodLazy,...we(t)});var Qg=class extends Se{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return J(t,{received:t.data,code:L.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qg.create=(e,t)=>new Qg({value:e,typeName:N.ZodLiteral,...we(t)});function DT(e,t){return new Xv({values:e,typeName:N.ZodEnum,...we(t)})}var Xv=class ey extends Se{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),r=this._def.values;return J(n,{expected:Ee.joinValues(r),received:n.parsedType,code:L.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),r=this._def.values;return J(n,{received:n.data,code:L.invalid_enum_value,options:r}),me}return dn(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return ey.create(t,{...this._def,...n})}exclude(t,n=this._def){return ey.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};Xv.create=DT;var Nd=class extends Se{_parse(t){let n=Ee.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Y.string&&r.parsedType!==Y.number){let i=Ee.objectValues(n);return J(r,{expected:Ee.joinValues(i),received:r.parsedType,code:L.invalid_type}),me}if(this._cache||(this._cache=new Set(Ee.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=Ee.objectValues(n);return J(r,{received:r.data,code:L.invalid_enum_value,options:i}),me}return dn(t.data)}get enum(){return this._def.values}};Nd.create=(e,t)=>new Nd({values:e,typeName:N.ZodNativeEnum,...we(t)});var gc=class extends Se{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.promise&&t.common.async===!1)return J(t,{code:L.invalid_type,expected:Y.promise,received:t.parsedType}),me;let n=t.parsedType===Y.promise?t.data:Promise.resolve(t.data);return dn(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};gc.create=(e,t)=>new gc({type:e,typeName:N.ZodPromise,...we(t)});var Ei=class extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:a=>{J(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let a=i.transform(r.data,s);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return me;let c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?me:c.status==="dirty"||n.value==="dirty"?Jg(c.value):c});{if(n.value==="aborted")return me;let o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?me:o.status==="dirty"||n.value==="dirty"?Jg(o.value):o}}if(i.type==="refinement"){let a=o=>{let c=i.refinement(o,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?me:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(i.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ra(a))return me;let o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Ra(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:n.value,value:o})):me);Ee.assertNever(i)}};Ei.create=(e,t,n)=>new Ei({schema:e,typeName:N.ZodEffects,effect:t,...we(n)});Ei.createWithPreprocess=(e,t,n)=>new Ei({schema:t,effect:{type:"preprocess",transform:e},typeName:N.ZodEffects,...we(n)});var vi=class extends Se{_parse(e){return this._getType(e)===Y.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vi.create=(e,t)=>new vi({innerType:e,typeName:N.ZodOptional,...we(t)});var Ua=class extends Se{_parse(e){return this._getType(e)===Y.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ua.create=(e,t)=>new Ua({innerType:e,typeName:N.ZodNullable,...we(t)});var ty=class extends Se{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===Y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ty.create=(e,t)=>new ty({innerType:e,typeName:N.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...we(t)});var ny=class extends Se{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ad(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ny.create=(e,t)=>new ny({innerType:e,typeName:N.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...we(t)});var bx=class extends Se{_parse(e){if(this._getType(e)!==Y.nan){let t=this._getOrReturnCtx(e);return J(t,{code:L.invalid_type,expected:Y.nan,received:t.parsedType}),me}return{status:"valid",value:e.data}}};bx.create=e=>new bx({typeName:N.ZodNaN,...we(e)});var ry=class extends Se{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},iy=class e extends Se{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?me:i.status==="dirty"?(n.dirty(),Jg(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?me:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new e({in:t,out:n,typeName:N.ZodPipeline})}},sy=class extends Se{_parse(e){let t=this._def.innerType._parse(e),n=r=>(Ra(r)&&(r.value=Object.freeze(r.value)),r);return Ad(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}};sy.create=(e,t)=>new sy({innerType:e,typeName:N.ZodReadonly,...we(t)});function wx(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function xr(e,t={},n){return e?fc.create().superRefine((r,i)=>{let s=e(r);if(s instanceof Promise)return s.then(a=>{if(!a){let o=wx(t,r),c=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:c})}});if(!s){let a=wx(t,r),o=a.fatal??n??!0;i.addIssue({code:"custom",...a,fatal:o})}}):fc.create()}var N;(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"})(N||(N={}));var gu=(e,t={message:`Input not instance of ${e.name}`})=>xr(n=>n instanceof e,t),lt=Td.create,Ke=Hg.create,ls=Wg.create,ay=fc.create;ma.create;Ti.create;var Cs=Ma.create,tt=Xr.create,Yr=Ed.create;Cd.create;bs.create;var yc=G9.create,yu=X9.create,ca=Qg.create,La=Xv.create,FT=gc.create;vi.create;Ua.create;function Y9(e,t){let n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==N.ZodAny&&(n.items=Pe(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Me(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Me(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Me(n,"minItems",e.exactLength.value,e.exactLength.message,t),Me(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}function Q9(e,t){let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"min":t.target==="jsonSchema7"?r.inclusive?Me(n,"minimum",r.value,r.message,t):Me(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Me(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?Me(n,"maximum",r.value,r.message,t):Me(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Me(n,"maximum",r.value,r.message,t));break;case"multipleOf":Me(n,"multipleOf",r.value,r.message,t);break}return n}function e3(){return{type:"boolean"}}function ZT(e,t){return Pe(e.type._def,t)}var t3=(e,t)=>Pe(e.innerType._def,t);function BT(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(i=>BT(e,t,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return n3(e,t)}}var n3=(e,t)=>{let n={type:"integer",format:"unix-time"};if(t.target==="openApi3")return n;for(let r of e.checks)switch(r.kind){case"min":Me(n,"minimum",r.value,r.message,t);break;case"max":Me(n,"maximum",r.value,r.message,t);break}return n};function r3(e,t){return{...Pe(e.innerType._def,t),default:e.defaultValue()}}function i3(e,t){return t.effectStrategy==="input"?Pe(e.schema._def,t):ln(t)}function s3(e){return{type:"string",enum:Array.from(e.values)}}var a3=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function o3(e,t){let n=[Pe(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Pe(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),r=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(a3(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:o,...c}=s;a=c}else r=void 0;i.push(a)}}),i.length?{allOf:i,...r}:void 0}function c3(e,t){let n=typeof e.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[e.value]}:{type:n==="bigint"?"integer":n,const:e.value}}var yf,Zn={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:()=>(yf===void 0&&(yf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),yf),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 qT(e,t){let n={type:"string"};if(e.checks)for(let r of e.checks)switch(r.kind){case"min":Me(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t);break;case"max":Me(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Bn(n,"email",r.message,t);break;case"format:idn-email":Bn(n,"idn-email",r.message,t);break;case"pattern:zod":qt(n,Zn.email,r.message,t);break}break;case"url":Bn(n,"uri",r.message,t);break;case"uuid":Bn(n,"uuid",r.message,t);break;case"regex":qt(n,r.regex,r.message,t);break;case"cuid":qt(n,Zn.cuid,r.message,t);break;case"cuid2":qt(n,Zn.cuid2,r.message,t);break;case"startsWith":qt(n,RegExp(`^${_f(r.value,t)}`),r.message,t);break;case"endsWith":qt(n,RegExp(`${_f(r.value,t)}$`),r.message,t);break;case"datetime":Bn(n,"date-time",r.message,t);break;case"date":Bn(n,"date",r.message,t);break;case"time":Bn(n,"time",r.message,t);break;case"duration":Bn(n,"duration",r.message,t);break;case"length":Me(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t),Me(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"includes":qt(n,RegExp(_f(r.value,t)),r.message,t);break;case"ip":r.version!=="v6"&&Bn(n,"ipv4",r.message,t),r.version!=="v4"&&Bn(n,"ipv6",r.message,t);break;case"base64url":qt(n,Zn.base64url,r.message,t);break;case"jwt":qt(n,Zn.jwt,r.message,t);break;case"cidr":r.version!=="v6"&&qt(n,Zn.ipv4Cidr,r.message,t),r.version!=="v4"&&qt(n,Zn.ipv6Cidr,r.message,t);break;case"emoji":qt(n,Zn.emoji(),r.message,t);break;case"ulid":qt(n,Zn.ulid,r.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":Bn(n,"binary",r.message,t);break;case"contentEncoding:base64":Me(n,"contentEncoding","base64",r.message,t);break;case"pattern:zod":qt(n,Zn.base64,r.message,t);break}break;case"nanoid":qt(n,Zn.nanoid,r.message,t);break}return n}function _f(e,t){return t.patternStrategy==="escape"?l3(e):e}var u3=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function l3(e){let t="";for(let n=0;n<e.length;n++)u3.has(e[n])||(t+="\\"),t+=e[n];return t}function Bn(e,t,n,r){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.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,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Me(e,"format",t,n,r)}function qt(e,t,n,r){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.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:kx(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Me(e,"pattern",kx(t,r),n,r)}function kx(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=n.i?e.source.toLowerCase():e.source,i="",s=!1,a=!1,o=!1;for(let c=0;c<r.length;c++){if(s){i+=r[c],s=!1;continue}if(n.i){if(a){if(r[c].match(/[a-z]/)){o?(i+=r[c],i+=`${r[c-2]}-${r[c]}`.toUpperCase(),o=!1):r[c+1]==="-"&&r[c+2]?.match(/[a-z]/)?(i+=r[c],o=!0):i+=`${r[c]}${r[c].toUpperCase()}`;continue}}else if(r[c].match(/[a-z]/)){i+=`[${r[c]}${r[c].toUpperCase()}]`;continue}}if(n.m){if(r[c]==="^"){i+=`(^|(?<=[\r
|
|
129
|
+
]))`;continue}else if(r[c]==="$"){i+=`($|(?=[\r
|
|
130
|
+
]))`;continue}}if(n.s&&r[c]==="."){i+=a?`${r[c]}\r
|
|
131
|
+
`:`[${r[c]}\r
|
|
132
|
+
]`;continue}i+=r[c],r[c]==="\\"?s=!0:a&&r[c]==="]"?a=!1:!a&&r[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 JT(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===N.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??ln(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:"object",additionalProperties:Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return n;if(e.keyType?._def.typeName===N.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=qT(e.keyType._def,t);return{...n,propertyNames:i}}else{if(e.keyType?._def.typeName===N.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===N.ZodBranded&&e.keyType._def.type._def.typeName===N.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=ZT(e.keyType._def,t);return{...n,propertyNames:i}}}return n}function d3(e,t){return t.mapStrategy==="record"?JT(e,t):{type:"array",maxItems:125,items:{type:"array",items:[Pe(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||ln(t),Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||ln(t)],minItems:2,maxItems:2}}}function p3(e){let t=e.values,n=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(n.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:n}}function h3(e){return e.target==="openAi"?void 0:{not:ln({...e,currentPath:[...e.currentPath,"not"]})}}function m3(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Pd={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function f3(e,t){if(t.target==="openApi3")return xx(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Pd&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=Pd[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":return s._def.value===null?[...i,"null"]:i;default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return xx(e,t)}var xx=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Pe(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function g3(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:Pd[e.innerType._def.typeName],nullable:!0}:{type:[Pd[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let r=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function y3(e,t){let n={type:"number"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"int":n.type="integer",jT(n,"type",r.message,t);break;case"min":t.target==="jsonSchema7"?r.inclusive?Me(n,"minimum",r.value,r.message,t):Me(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Me(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?Me(n,"maximum",r.value,r.message,t):Me(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Me(n,"maximum",r.value,r.message,t));break;case"multipleOf":Me(n,"multipleOf",r.value,r.message,t);break}return n}function _3(e,t){let n=t.target==="openAi",r={type:"object",properties:{}},i=[],s=e.shape();for(let o in s){let c=s[o];if(c===void 0||c._def===void 0)continue;let u=b3(c);u&&n&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=Pe(c._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});l!==void 0&&(r.properties[o]=l,u||i.push(o))}i.length&&(r.required=i);let a=v3(e,t);return a!==void 0&&(r.additionalProperties=a),r}function v3(e,t){if(e.catchall._def.typeName!=="ZodNever")return Pe(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 b3(e){try{return e.isOptional()}catch{return!0}}var w3=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Pe(e.innerType._def,t);let n=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:ln(t)},n]}:ln(t)},k3=(e,t)=>{if(t.pipeStrategy==="input")return Pe(e.in._def,t);if(t.pipeStrategy==="output")return Pe(e.out._def,t);let n=Pe(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[n,Pe(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]})].filter(r=>r!==void 0)}};function x3(e,t){return Pe(e.type._def,t)}function $3(e,t){let n={type:"array",uniqueItems:!0,items:Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Me(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Me(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function I3(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Pe(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function S3(e){return{not:ln(e)}}function O3(e){return ln(e)}var A3=(e,t)=>Pe(e.innerType._def,t),T3=(e,t,n)=>{switch(t){case N.ZodString:return qT(e,n);case N.ZodNumber:return y3(e,n);case N.ZodObject:return _3(e,n);case N.ZodBigInt:return Q9(e,n);case N.ZodBoolean:return e3();case N.ZodDate:return BT(e,n);case N.ZodUndefined:return S3(n);case N.ZodNull:return m3(n);case N.ZodArray:return Y9(e,n);case N.ZodUnion:case N.ZodDiscriminatedUnion:return f3(e,n);case N.ZodIntersection:return o3(e,n);case N.ZodTuple:return I3(e,n);case N.ZodRecord:return JT(e,n);case N.ZodLiteral:return c3(e,n);case N.ZodEnum:return s3(e);case N.ZodNativeEnum:return p3(e);case N.ZodNullable:return g3(e,n);case N.ZodOptional:return w3(e,n);case N.ZodMap:return d3(e,n);case N.ZodSet:return $3(e,n);case N.ZodLazy:return()=>e.getter()._def;case N.ZodPromise:return x3(e,n);case N.ZodNaN:case N.ZodNever:return h3(n);case N.ZodEffects:return i3(e,n);case N.ZodAny:return ln(n);case N.ZodUnknown:return O3(n);case N.ZodDefault:return r3(e,n);case N.ZodBranded:return ZT(e,n);case N.ZodReadonly:return A3(e,n);case N.ZodCatch:return t3(e,n);case N.ZodPipeline:return k3(e,n);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return(r=>{})()}};function Pe(e,t,n=!1){let r=t.seen.get(e);if(t.override){let o=t.override?.(e,t,r,n);if(o!==x9)return o}if(r&&!n){let o=E3(r,t);if(o!==void 0)return o}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let s=T3(e,e.typeName,t),a=typeof s=="function"?Pe(s(),t):s;if(a&&C3(e,t,a),t.postProcess){let o=t.postProcess(a,e,t);return i.jsonSchema=a,o}return i.jsonSchema=a,a}var E3=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:PT(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),ln(t)):t.$refStrategy==="seen"?ln(t):void 0}},C3=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),N3=(e,t)=>{let n=S9(t),r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((o,[c,u])=>({...o,[c]:Pe(u._def,{...n,currentPath:[...n.basePath,n.definitionPath,c]},!0)??ln(n)}),{}):void 0,i=typeof t=="string"?t:t?.name,s=Pe(e._def,n,!1)??ln(n);n.flags.hasReferencedOpenAiAnyType&&(r||(r={}),r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:n.$refStrategy==="relative"?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let a=i===void 0?r?{...s,[n.definitionPath]:r}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:{...r,[i]:s}};return n.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(n.target==="jsonSchema2019-09"||n.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),n.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function ds(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(!ds(e[i],t[i]))return!1;return!0}if(n==="object"){if(!e||!t)return e===t;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let s of r)if(!ds(e[s],t[s]))return!1;return!0}return e===t}function Vn(e){return encodeURI(P3(e))}function P3(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var j3={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},R3={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},M3={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},U3=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 li(e,t=Object.create(null),n=U3,r=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.$id||e.id;if(s){let a=new URL(s,n.href);a.hash.length>1?t[a.href]=e:(a.hash="",r===""?n=a:li(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?"#"+r:"");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 s=new URL(e.$ref,n.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:s.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let s=new URL(e.$recursiveRef,n.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:s.href})}if(e.$anchor){let s=new URL("#"+e.$anchor,n.href);t[s.href]=e}for(let s in e){if(M3[s])continue;let a=`${r}/${Vn(s)}`,o=e[s];if(Array.isArray(o)){if(j3[s]){let c=o.length;for(let u=0;u<c;u++)li(o[u],t,n,`${a}/${u}`)}}else if(R3[s])for(let c in o)li(o[c],t,n,`${a}/${Vn(c)}`);else li(o,t,n,a)}return t}var L3=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,z3=[0,31,28,31,30,31,30,31,31,30,31,30,31],D3=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,F3=/^(?=.{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,Z3=/^(?:[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,B3=/^(?:(?:[^\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,q3=/^(?:(?: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,J3=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,H3=/^(?:\/(?:[^~/]|~0|~1)*)*$/,V3=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,K3=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,W3=e=>{if(e[0]==='"')return!1;let[t,n,...r]=e.split("@");return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(".").every(i=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},G3=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,X3=/^((([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,Y3=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 cr(e){return e.test.bind(e)}var $x={date:HT,time:VT.bind(void 0,!1),"date-time":tF,duration:Y3,uri:iF,"uri-reference":cr(Z3),"uri-template":cr(B3),url:cr(q3),email:W3,hostname:cr(F3),ipv4:cr(G3),ipv6:cr(X3),regex:aF,uuid:cr(J3),"json-pointer":cr(H3),"json-pointer-uri-fragment":cr(V3),"relative-json-pointer":cr(K3)};function Q3(e){return e%4===0&&(e%100!==0||e%400===0)}function HT(e){let t=e.match(L3);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Q3(n)?29:z3[r])}function VT(e,t){let n=t.match(D3);if(!n)return!1;let r=+n[1],i=+n[2],s=+n[3],a=!!n[5];return(r<=23&&i<=59&&s<=59||r==23&&i==59&&s==60)&&(!e||a)}var eF=/t|\s/i;function tF(e){let t=e.split(eF);return t.length==2&&HT(t[0])&&VT(!0,t[1])}var nF=/\/|:/,rF=/^(?:[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 iF(e){return nF.test(e)&&rF.test(e)}var sF=/[^\\]\\Z/;function aF(e){if(sF.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function oF(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function Xe(e,t,n="2019-09",r=li(t),i=!0,s=null,a="#",o="#",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:p,$recursiveAnchor:h,type:m,const:f,enum:v,required:g,not:y,anyOf:w,allOf:x,oneOf:O,if:z,then:T,else:k,format:B,properties:C,patternProperties:E,additionalProperties:Z,unevaluatedProperties:X,minProperties:ae,maxProperties:Ne,propertyNames:ve,dependentRequired:sr,dependentSchemas:On,dependencies:Zi,prefixItems:Ln,items:Tr,additionalItems:oo,unevaluatedItems:co,contains:uo,minContains:zn,maxContains:b,minItems:_,maxItems:j,uniqueItems:I,minimum:Ie,maximum:ze,exclusiveMinimum:ht,exclusiveMaximum:ot,multipleOf:Ut,minLength:An,maxLength:ct,pattern:ar,__absolute_ref__:Ms,__absolute_recursive_ref__:Fu}=t,H=[];if(h===!0&&s===null&&(s=t),p==="#"){let le=s===null?r[Fu]:s,ie=`${o}/$recursiveRef`,xe=Xe(e,s===null?t:s,n,r,i,le,a,ie,c);xe.valid||H.push({instanceLocation:a,keyword:"$recursiveRef",keywordLocation:ie,error:"A subschema had errors."},...xe.errors)}if(d!==void 0){let le=r[Ms||d];if(le===void 0){let ee=`Unresolved $ref "${d}".`;throw Ms&&Ms!==d&&(ee+=` Absolute URI "${Ms}".`),ee+=`
|
|
133
|
+
Known schemas:
|
|
134
|
+
- ${Object.keys(r).join(`
|
|
135
|
+
- `)}`,new Error(ee)}let ie=`${o}/$ref`,xe=Xe(e,le,n,r,i,s,a,ie,c);if(xe.valid||H.push({instanceLocation:a,keyword:"$ref",keywordLocation:ie,error:"A subschema had errors."},...xe.errors),n==="4"||n==="7")return{valid:H.length===0,errors:H}}if(Array.isArray(m)){let le=m.length,ie=!1;for(let xe=0;xe<le;xe++)if(l===m[xe]||m[xe]==="integer"&&l==="number"&&e%1===0&&e===e){ie=!0;break}ie||H.push({instanceLocation:a,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${l}" is invalid. Expected "${m.join('", "')}".`})}else m==="integer"?(l!=="number"||e%1||e!==e)&&H.push({instanceLocation:a,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`}):m!==void 0&&l!==m&&H.push({instanceLocation:a,keyword:"type",keywordLocation:`${o}/type`,error:`Instance type "${l}" is invalid. Expected "${m}".`});if(f!==void 0&&(l==="object"||l==="array"?ds(e,f)||H.push({instanceLocation:a,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(f)}.`}):e!==f&&H.push({instanceLocation:a,keyword:"const",keywordLocation:`${o}/const`,error:`Instance does not match ${JSON.stringify(f)}.`})),v!==void 0&&(l==="object"||l==="array"?v.some(le=>ds(e,le))||H.push({instanceLocation:a,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(le=>e===le)||H.push({instanceLocation:a,keyword:"enum",keywordLocation:`${o}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),y!==void 0){let le=`${o}/not`;Xe(e,y,n,r,i,s,a,le).valid&&H.push({instanceLocation:a,keyword:"not",keywordLocation:le,error:'Instance matched "not" schema.'})}let Bi=[];if(w!==void 0){let le=`${o}/anyOf`,ie=H.length,xe=!1;for(let ee=0;ee<w.length;ee++){let K=w[ee],he=Object.create(c),pe=Xe(e,K,n,r,i,h===!0?s:null,a,`${le}/${ee}`,he);H.push(...pe.errors),xe=xe||pe.valid,pe.valid&&Bi.push(he)}xe?H.length=ie:H.splice(ie,0,{instanceLocation:a,keyword:"anyOf",keywordLocation:le,error:"Instance does not match any subschemas."})}if(x!==void 0){let le=`${o}/allOf`,ie=H.length,xe=!0;for(let ee=0;ee<x.length;ee++){let K=x[ee],he=Object.create(c),pe=Xe(e,K,n,r,i,h===!0?s:null,a,`${le}/${ee}`,he);H.push(...pe.errors),xe=xe&&pe.valid,pe.valid&&Bi.push(he)}xe?H.length=ie:H.splice(ie,0,{instanceLocation:a,keyword:"allOf",keywordLocation:le,error:"Instance does not match every subschema."})}if(O!==void 0){let le=`${o}/oneOf`,ie=H.length,xe=O.filter((ee,K)=>{let he=Object.create(c),pe=Xe(e,ee,n,r,i,h===!0?s:null,a,`${le}/${K}`,he);return H.push(...pe.errors),pe.valid&&Bi.push(he),pe.valid}).length;xe===1?H.length=ie:H.splice(ie,0,{instanceLocation:a,keyword:"oneOf",keywordLocation:le,error:`Instance does not match exactly one subschema (${xe} matches).`})}if((l==="object"||l==="array")&&Object.assign(c,...Bi),z!==void 0){let le=`${o}/if`;if(Xe(e,z,n,r,i,s,a,le,c).valid){if(T!==void 0){let ie=Xe(e,T,n,r,i,s,a,`${o}/then`,c);ie.valid||H.push({instanceLocation:a,keyword:"if",keywordLocation:le,error:'Instance does not match "then" schema.'},...ie.errors)}}else if(k!==void 0){let ie=Xe(e,k,n,r,i,s,a,`${o}/else`,c);ie.valid||H.push({instanceLocation:a,keyword:"if",keywordLocation:le,error:'Instance does not match "else" schema.'},...ie.errors)}}if(l==="object"){if(g!==void 0)for(let ee of g)ee in e||H.push({instanceLocation:a,keyword:"required",keywordLocation:`${o}/required`,error:`Instance does not have required property "${ee}".`});let le=Object.keys(e);if(ae!==void 0&&le.length<ae&&H.push({instanceLocation:a,keyword:"minProperties",keywordLocation:`${o}/minProperties`,error:`Instance does not have at least ${ae} properties.`}),Ne!==void 0&&le.length>Ne&&H.push({instanceLocation:a,keyword:"maxProperties",keywordLocation:`${o}/maxProperties`,error:`Instance does not have at least ${Ne} properties.`}),ve!==void 0){let ee=`${o}/propertyNames`;for(let K in e){let he=`${a}/${Vn(K)}`,pe=Xe(K,ve,n,r,i,s,he,ee);pe.valid||H.push({instanceLocation:a,keyword:"propertyNames",keywordLocation:ee,error:`Property name "${K}" does not match schema.`},...pe.errors)}}if(sr!==void 0){let ee=`${o}/dependantRequired`;for(let K in sr)if(K in e){let he=sr[K];for(let pe of he)pe in e||H.push({instanceLocation:a,keyword:"dependentRequired",keywordLocation:ee,error:`Instance has "${K}" but does not have "${pe}".`})}}if(On!==void 0)for(let ee in On){let K=`${o}/dependentSchemas`;if(ee in e){let he=Xe(e,On[ee],n,r,i,s,a,`${K}/${Vn(ee)}`,c);he.valid||H.push({instanceLocation:a,keyword:"dependentSchemas",keywordLocation:K,error:`Instance has "${ee}" but does not match dependant schema.`},...he.errors)}}if(Zi!==void 0){let ee=`${o}/dependencies`;for(let K in Zi)if(K in e){let he=Zi[K];if(Array.isArray(he))for(let pe of he)pe in e||H.push({instanceLocation:a,keyword:"dependencies",keywordLocation:ee,error:`Instance has "${K}" but does not have "${pe}".`});else{let pe=Xe(e,he,n,r,i,s,a,`${ee}/${Vn(K)}`);pe.valid||H.push({instanceLocation:a,keyword:"dependencies",keywordLocation:ee,error:`Instance has "${K}" but does not match dependant schema.`},...pe.errors)}}}let ie=Object.create(null),xe=!1;if(C!==void 0){let ee=`${o}/properties`;for(let K in C){if(!(K in e))continue;let he=`${a}/${Vn(K)}`,pe=Xe(e[K],C[K],n,r,i,s,he,`${ee}/${Vn(K)}`);if(pe.valid)c[K]=ie[K]=!0;else if(xe=i,H.push({instanceLocation:a,keyword:"properties",keywordLocation:ee,error:`Property "${K}" does not match schema.`},...pe.errors),xe)break}}if(!xe&&E!==void 0){let ee=`${o}/patternProperties`;for(let K in E){let he=new RegExp(K,"u"),pe=E[K];for(let Qt in e){if(!he.test(Qt))continue;let U4=`${a}/${Vn(Qt)}`,W0=Xe(e[Qt],pe,n,r,i,s,U4,`${ee}/${Vn(K)}`);W0.valid?c[Qt]=ie[Qt]=!0:(xe=i,H.push({instanceLocation:a,keyword:"patternProperties",keywordLocation:ee,error:`Property "${Qt}" matches pattern "${K}" but does not match associated schema.`},...W0.errors))}}}if(!xe&&Z!==void 0){let ee=`${o}/additionalProperties`;for(let K in e){if(ie[K])continue;let he=`${a}/${Vn(K)}`,pe=Xe(e[K],Z,n,r,i,s,he,ee);pe.valid?c[K]=!0:(xe=i,H.push({instanceLocation:a,keyword:"additionalProperties",keywordLocation:ee,error:`Property "${K}" does not match additional properties schema.`},...pe.errors))}}else if(!xe&&X!==void 0){let ee=`${o}/unevaluatedProperties`;for(let K in e)if(!c[K]){let he=`${a}/${Vn(K)}`,pe=Xe(e[K],X,n,r,i,s,he,ee);pe.valid?c[K]=!0:H.push({instanceLocation:a,keyword:"unevaluatedProperties",keywordLocation:ee,error:`Property "${K}" does not match unevaluated properties schema.`},...pe.errors)}}}else if(l==="array"){j!==void 0&&e.length>j&&H.push({instanceLocation:a,keyword:"maxItems",keywordLocation:`${o}/maxItems`,error:`Array has too many items (${e.length} > ${j}).`}),_!==void 0&&e.length<_&&H.push({instanceLocation:a,keyword:"minItems",keywordLocation:`${o}/minItems`,error:`Array has too few items (${e.length} < ${_}).`});let le=e.length,ie=0,xe=!1;if(Ln!==void 0){let ee=`${o}/prefixItems`,K=Math.min(Ln.length,le);for(;ie<K;ie++){let he=Xe(e[ie],Ln[ie],n,r,i,s,`${a}/${ie}`,`${ee}/${ie}`);if(c[ie]=!0,!he.valid&&(xe=i,H.push({instanceLocation:a,keyword:"prefixItems",keywordLocation:ee,error:"Items did not match schema."},...he.errors),xe))break}}if(Tr!==void 0){let ee=`${o}/items`;if(Array.isArray(Tr)){let K=Math.min(Tr.length,le);for(;ie<K;ie++){let he=Xe(e[ie],Tr[ie],n,r,i,s,`${a}/${ie}`,`${ee}/${ie}`);if(c[ie]=!0,!he.valid&&(xe=i,H.push({instanceLocation:a,keyword:"items",keywordLocation:ee,error:"Items did not match schema."},...he.errors),xe))break}}else for(;ie<le;ie++){let K=Xe(e[ie],Tr,n,r,i,s,`${a}/${ie}`,ee);if(c[ie]=!0,!K.valid&&(xe=i,H.push({instanceLocation:a,keyword:"items",keywordLocation:ee,error:"Items did not match schema."},...K.errors),xe))break}if(!xe&&oo!==void 0){let K=`${o}/additionalItems`;for(;ie<le;ie++){let he=Xe(e[ie],oo,n,r,i,s,`${a}/${ie}`,K);c[ie]=!0,he.valid||(xe=i,H.push({instanceLocation:a,keyword:"additionalItems",keywordLocation:K,error:"Items did not match additional items schema."},...he.errors))}}}if(uo!==void 0)if(le===0&&zn===void 0)H.push({instanceLocation:a,keyword:"contains",keywordLocation:`${o}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(zn!==void 0&&le<zn)H.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array has less items (${le}) than minContains (${zn}).`});else{let ee=`${o}/contains`,K=H.length,he=0;for(let pe=0;pe<le;pe++){let Qt=Xe(e[pe],uo,n,r,i,s,`${a}/${pe}`,ee);Qt.valid?(c[pe]=!0,he++):H.push(...Qt.errors)}he>=(zn||0)&&(H.length=K),zn===void 0&&b===void 0&&he===0?H.splice(K,0,{instanceLocation:a,keyword:"contains",keywordLocation:ee,error:"Array does not contain item matching schema."}):zn!==void 0&&he<zn?H.push({instanceLocation:a,keyword:"minContains",keywordLocation:`${o}/minContains`,error:`Array must contain at least ${zn} items matching schema. Only ${he} items were found.`}):b!==void 0&&he>b&&H.push({instanceLocation:a,keyword:"maxContains",keywordLocation:`${o}/maxContains`,error:`Array may contain at most ${b} items matching schema. ${he} items were found.`})}if(!xe&&co!==void 0){let ee=`${o}/unevaluatedItems`;for(ie;ie<le;ie++){if(c[ie])continue;let K=Xe(e[ie],co,n,r,i,s,`${a}/${ie}`,ee);c[ie]=!0,K.valid||H.push({instanceLocation:a,keyword:"unevaluatedItems",keywordLocation:ee,error:"Items did not match unevaluated items schema."},...K.errors)}}if(I)for(let ee=0;ee<le;ee++){let K=e[ee],he=typeof K=="object"&&K!==null;for(let pe=0;pe<le;pe++){if(ee===pe)continue;let Qt=e[pe];(K===Qt||he&&typeof Qt=="object"&&Qt!==null&&ds(K,Qt))&&(H.push({instanceLocation:a,keyword:"uniqueItems",keywordLocation:`${o}/uniqueItems`,error:`Duplicate items at indexes ${ee} and ${pe}.`}),ee=Number.MAX_SAFE_INTEGER,pe=Number.MAX_SAFE_INTEGER)}}}else if(l==="number"){if(n==="4"?(Ie!==void 0&&(ht===!0&&e<=Ie||e<Ie)&&H.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${e} is less than ${ht?"or equal to ":""} ${Ie}.`}),ze!==void 0&&(ot===!0&&e>=ze||e>ze)&&H.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${e} is greater than ${ot?"or equal to ":""} ${ze}.`})):(Ie!==void 0&&e<Ie&&H.push({instanceLocation:a,keyword:"minimum",keywordLocation:`${o}/minimum`,error:`${e} is less than ${Ie}.`}),ze!==void 0&&e>ze&&H.push({instanceLocation:a,keyword:"maximum",keywordLocation:`${o}/maximum`,error:`${e} is greater than ${ze}.`}),ht!==void 0&&e<=ht&&H.push({instanceLocation:a,keyword:"exclusiveMinimum",keywordLocation:`${o}/exclusiveMinimum`,error:`${e} is less than ${ht}.`}),ot!==void 0&&e>=ot&&H.push({instanceLocation:a,keyword:"exclusiveMaximum",keywordLocation:`${o}/exclusiveMaximum`,error:`${e} is greater than or equal to ${ot}.`})),Ut!==void 0){let le=e%Ut;Math.abs(0-le)>=11920929e-14&&Math.abs(Ut-le)>=11920929e-14&&H.push({instanceLocation:a,keyword:"multipleOf",keywordLocation:`${o}/multipleOf`,error:`${e} is not a multiple of ${Ut}.`})}}else if(l==="string"){let le=An===void 0&&ct===void 0?0:oF(e);An!==void 0&&le<An&&H.push({instanceLocation:a,keyword:"minLength",keywordLocation:`${o}/minLength`,error:`String is too short (${le} < ${An}).`}),ct!==void 0&&le>ct&&H.push({instanceLocation:a,keyword:"maxLength",keywordLocation:`${o}/maxLength`,error:`String is too long (${le} > ${ct}).`}),ar!==void 0&&!new RegExp(ar,"u").test(e)&&H.push({instanceLocation:a,keyword:"pattern",keywordLocation:`${o}/pattern`,error:"String does not match pattern."}),B!==void 0&&$x[B]&&!$x[B](e)&&H.push({instanceLocation:a,keyword:"format",keywordLocation:`${o}/format`,error:`String does not match format "${B}".`})}return{valid:H.length===0,errors:H}}var oy=class{schema;draft;shortCircuit;lookup;constructor(t,n="2019-09",r=!0){this.schema=t,this.draft=n,this.shortCircuit=r,this.lookup=li(t)}validate(t){return Xe(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,n){n&&(t={...t,$id:n}),li(t,this.lookup)}},cF=G({Validator:()=>oy,deepCompareStrict:()=>ds,toJsonSchema:()=>xt,validatesOnlyStrings:()=>Ho}),Ix=new WeakMap;function xt(e,t){let n=!t&&e!=null&&typeof e=="object";if(n){let i=Ix.get(e);if(i)return i}let r;if(F_(e)&&!We(e))r=e["~standard"].jsonSchema.input({target:"draft-07"});else if(We(e)){let i=CT(e,!0);wr(i)?r=pc(Od(i,!0),t):r=pc(e,t)}else pt(e)?r=N3(e):r=e;return n&&r!=null&&typeof r=="object"&&Ix.set(e,r),r}function Ho(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=>Ho(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(n=>Ho(n))}if("not"in e)return!1;if("$ref"in e&&typeof e.$ref=="string"){let t=e.$ref,n=li(e);return n[t]?Ho(n[t]):!1}return!1}function Yv(e){return e?e.lc_runnable:!1}var uF=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 n=this.includeNames===void 0&&this.includeTypes===void 0&&this.includeTags===void 0,r=e.tags??[];return this.includeNames!==void 0&&(n=n||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(n=n||this.includeTypes.includes(t)),this.includeTags!==void 0&&(n=n||r.some(i=>this.includeTags?.includes(i))),this.excludeNames!==void 0&&(n=n&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(n=n&&!this.excludeTypes.includes(t)),this.excludeTags!==void 0&&(n=n&&r.every(i=>!this.excludeTags?.includes(i))),n}},lF=e=>btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function vf(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}var dF=["*","_","`"];function pF(e){let t="";for(let[n,r]of Object.entries(e))t+=` classDef ${n} ${r};
|
|
136
|
+
`;return t}function hF(e,t,n){let{firstNode:r,lastNode:i,nodeColors:s,withStyles:a=!0,curveStyle:o="linear",wrapLabelNWords:c=9}=n??{},u=a?`%%{init: {'flowchart': {'curve': '${o}'}}}%%
|
|
137
|
+
graph TD;
|
|
138
|
+
`:`graph TD;
|
|
139
|
+
`;if(a){let m="default",f={[m]:"{0}({1})"};r!==void 0&&(f[r]="{0}([{1}]):::first"),i!==void 0&&(f[i]="{0}([{1}]):::last");for(let[v,g]of Object.entries(e)){let y=g.name.split(":").pop()??"",w=dF.some(O=>y.startsWith(O)&&y.endsWith(O))?`<p>${y}</p>`:y;Object.keys(g.metadata??{}).length&&(w+=`<hr/><small><em>${Object.entries(g.metadata??{}).map(([O,z])=>`${O} = ${z}`).join(`
|
|
140
|
+
`)}</em></small>`);let x=(f[v]??f[m]).replace("{0}",vf(v)).replace("{1}",w);u+=` ${x}
|
|
141
|
+
`}}let l={};for(let m of t){let f=m.source.split(":"),v=m.target.split(":"),g=f.filter((y,w)=>y===v[w]).join(":");l[g]||(l[g]=[]),l[g].push(m)}let d=new Set;function p(m){return[...m].sort((f,v)=>f.split(":").length-v.split(":").length)}function h(m,f){let v=m.length===1&&m[0].source===m[0].target;if(f&&!v){let y=f.split(":").pop();if(d.has(f))throw new Error(`Found duplicate subgraph '${y}' at '${f} -- 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(f),u+=` subgraph ${y}
|
|
142
|
+
`}let g=p(Object.keys(l).filter(y=>y.startsWith(`${f}:`)&&y!==f&&y.split(":").length===f.split(":").length+1));for(let y of g)h(l[y],y);for(let y of m){let{source:w,target:x,data:O,conditional:z}=y,T="";if(O!==void 0){let k=O,B=k.split(" ");B.length>c&&(k=Array.from({length:Math.ceil(B.length/c)},(C,E)=>B.slice(E*c,(E+1)*c).join(" ")).join(" <br> ")),T=z?` -. ${k} .-> `:` -- ${k} --> `}else T=z?" -.-> ":" --> ";u+=` ${vf(w)}${T}${vf(x)};
|
|
143
|
+
`}f&&!v&&(u+=` end
|
|
144
|
+
`)}h(l[""]??[],"");for(let m in l)!m.includes(":")&&m!==""&&h(l[m],m);return a&&(u+=pF(s??{})),u}async function mF(e,t){let n=t?.backgroundColor??"white",r=t?.imageType??"png",i=lF(e);n!==void 0&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(n)||(n=`!${n}`));let s=`https://mermaid.ink/img/${i}?bgColor=${n}&type=${r}`,a=await fetch(s);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(`
|
|
145
|
+
`));return await a.blob()}var fF=G({Graph:()=>_c});function gF(e,t){if(e!==void 0&&!gi(e))return e;if(Yv(t))try{let n=t.getName();return n=n.startsWith("Runnable")?n.slice(8):n,n}catch{return t.getName()}else return t.name??"UnknownSchema"}function yF(e){return Yv(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...xt(e.data.schema),title:e.data.name}}}var _c=class KT{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((n,r)=>{t[n.id]=gi(n.id)?r:n.id}),{nodes:Object.values(this.nodes).map(n=>({id:t[n.id],...yF(n)})),edges:this.edges.map(n=>{let r={source:t[n.source],target:t[n.target]};return typeof n.data<"u"&&(r.data=n.data),typeof n.conditional<"u"&&(r.conditional=n.conditional),r})}}addNode(t,n,r){if(n!==void 0&&this.nodes[n]!==void 0)throw new Error(`Node with id ${n} already exists`);let i=n??A1(),s={id:i,data:t,name:gF(n,t),metadata:r};return this.nodes[i]=s,s}removeNode(t){delete this.nodes[t.id],this.edges=this.edges.filter(n=>n.source!==t.id&&n.target!==t.id)}addEdge(t,n,r,i){if(this.nodes[t.id]===void 0)throw new Error(`Source node ${t.id} not in graph`);if(this.nodes[n.id]===void 0)throw new Error(`Target node ${n.id} not in graph`);let s={source:t.id,target:n.id,data:r,conditional:i};return this.edges.push(s),s}firstNode(){return Sx(this)}lastNode(){return Ox(this)}extend(t,n=""){let r=n;Object.values(t.nodes).map(c=>c.id).every(gi)&&(r="");let i=c=>r?`${r}:${c}`:c;Object.entries(t.nodes).forEach(([c,u])=>{this.nodes[i(c)]={...u,id:i(c)}});let s=t.edges.map(c=>({...c,source:i(c.source),target:i(c.target)}));this.edges=[...this.edges,...s];let a=t.firstNode(),o=t.lastNode();return[a?{id:i(a.id),data:a.data}:void 0,o?{id:i(o.id),data:o.data}:void 0]}trimFirstNode(){let t=this.firstNode();t&&Sx(this,[t.id])&&this.removeNode(t)}trimLastNode(){let t=this.lastNode();t&&Ox(this,[t.id])&&this.removeNode(t)}reid(){let t=Object.fromEntries(Object.values(this.nodes).map(i=>[i.id,i.name])),n=new Map;Object.values(t).forEach(i=>{n.set(i,(n.get(i)||0)+1)});let r=i=>{let s=t[i];return gi(i)&&n.get(s)===1?s:i};return new KT({nodes:Object.fromEntries(Object.entries(this.nodes).map(([i,s])=>[r(i),{...s,id:r(i)}])),edges:this.edges.map(i=>({...i,source:r(i.source),target:r(i.target)}))})}drawMermaid(t){let{withStyles:n,curveStyle:r,nodeColors:i={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:s}=t??{},a=this.reid(),o=a.firstNode(),c=a.lastNode();return hF(a.nodes,a.edges,{firstNode:o?.id,lastNode:c?.id,withStyles:n,curveStyle:r,nodeColors:i,wrapLabelNWords:s})}async drawMermaidPng(t){return mF(this.drawMermaid(t),{backgroundColor:t?.backgroundColor})}};function Sx(e,t=[]){let n=new Set(e.edges.filter(i=>!t.includes(i.source)).map(i=>i.target)),r=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!n.has(i.id)&&r.push(i);return r.length===1?r[0]:void 0}function Ox(e,t=[]){let n=new Set(e.edges.filter(i=>!t.includes(i.target)).map(i=>i.source)),r=[];for(let i of Object.values(e.nodes))!t.includes(i.id)&&!n.has(i.id)&&r.push(i);return r.length===1?r[0]:void 0}function pl({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 _F=e=>e.name==="event_stream_tracer",vF=class extends ei{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=un.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){let t=e.tags??[],n=this.includeNames===void 0&&this.includeTags===void 0&&this.includeTypes===void 0;return this.includeNames!==void 0&&(n=n||this.includeNames.includes(e.name)),this.includeTypes!==void 0&&(n=n||this.includeTypes.includes(e.runType)),this.includeTags!==void 0&&(n=n||t.find(r=>this.includeTags?.includes(r))!==void 0),this.excludeNames!==void 0&&(n=n&&!this.excludeNames.includes(e.name)),this.excludeTypes!==void 0&&(n=n&&!this.excludeTypes.includes(e.runType)),this.excludeTags!==void 0&&(n=n&&t.every(r=>!this.excludeTags?.includes(r))),n}async*tapOutputIterable(e,t){let n=await t.next();if(n.done)return;let r=this.runInfoMap.get(e);if(r===void 0){yield n.value;return}function i(a,o){return a==="llm"&&typeof o=="string"?new Ia({text:o}):o}let s=this.tappedPromises.get(e);if(s===void 0){let a;s=new Promise(o=>{a=o}),this.tappedPromises.set(e,s);try{let o={event:`on_${r.runType}_stream`,run_id:e,name:r.name,tags:r.tags,metadata:r.metadata,data:{}};await this.send({...o,data:{chunk:i(r.runType,n.value)}},r),yield n.value;for await(let c of t)r.runType!=="tool"&&r.runType!=="retriever"&&await this.send({...o,data:{chunk:i(r.runType,c)}},r),yield c}finally{a?.()}}else{yield n.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 n=this.tappedPromises.get(e.run_id);n!==void 0?n.then(()=>{this.send(e,t)}):await this.send(e,t)}async onLLMStart(e){let t=pl(e),n=e.inputs.messages!==void 0?"chat_model":"llm",r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:n,inputs:e.inputs};this.runInfoMap.set(e.id,r);let i=`on_${n}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}async onLLMNewToken(e,t,n){let r=this.runInfoMap.get(e.id),i,s;if(r===void 0)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(this.runInfoMap.size!==1){if(r.runType==="chat_model")s="on_chat_model_stream",n?.chunk===void 0?i=new Pt({content:t,id:`run-${e.id}`}):i=n.chunk.message;else if(r.runType==="llm")s="on_llm_stream",n?.chunk===void 0?i=new Ia({text:t}):i=n.chunk;else throw new Error(`Unexpected run type ${r.runType}`);await this.send({event:s,data:{chunk:i},run_id:e.id,name:r.name,tags:r.tags,metadata:r.metadata},r)}}async onLLMEnd(e){let t=this.runInfoMap.get(e.id);this.runInfoMap.delete(e.id);let n;if(t===void 0)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);let r=e.outputs?.generations,i;if(t.runType==="chat_model"){for(let s of r??[]){if(i!==void 0)break;i=s[0]?.message}n="on_chat_model_end"}else if(t.runType==="llm")i={generations:r?.map(s=>s.map(a=>({text:a.text,generationInfo:a.generationInfo}))),llmOutput:e.outputs?.llmOutput??{}},n="on_llm_end";else throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);await this.sendEndEvent({event:n,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=pl(e),n=e.run_type??"chain",r={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type},i={};e.inputs.input===""&&Object.keys(e.inputs).length===1?(i={},r.inputs={}):e.inputs.input!==void 0?(i.input=e.inputs.input,r.inputs=e.inputs.input):(i.input=e.inputs,r.inputs=e.inputs),this.runInfoMap.set(e.id,r),await this.send({event:`on_${n}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},r)}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 n=`on_${e.run_type}_end`,r=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:r};r.input&&Object.keys(r).length===1&&(i.input=r.input,t.inputs=r.input),await this.sendEndEvent({event:n,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){let t=pl(e),n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,n),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},n)}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 n=e.outputs?.output===void 0?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:n,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=pl(e),n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,n),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??{}},n)}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,n){let r=this.runInfoMap.get(n);if(r===void 0)throw new Error(`handleCustomEvent: Run ID ${n} not found in run map.`);await this.send({event:"on_custom_event",run_id:n,name:e,tags:r.tags,metadata:r.metadata,data:t},r)}async finish(){let e=[...this.tappedPromises.values()];Promise.all(e).finally(()=>{this.writer.close()})}},WT=class extends ei{name="RootListenersTracer";rootId;config;argOnStart;argOnEnd;argOnError;constructor({config:e,onStart:t,onEnd:n,onError:r}){super({_awaitHandler:!0}),this.config=e,this.argOnStart=t,this.argOnEnd=n,this.argOnError=r}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 bF(e){let t=new TextEncoder,n=new ReadableStream({async start(r){for await(let i of e)r.enqueue(t.encode(`event: data
|
|
146
|
+
data: ${JSON.stringify(i)}
|
|
147
|
+
|
|
148
|
+
`));r.enqueue(t.encode(`event: end
|
|
149
|
+
|
|
150
|
+
`)),r.close()}});return un.fromReadableStream(n)}function Ax(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.iterator]=="function"&&typeof e.next=="function"}var wF=e=>e!=null&&typeof e=="object"&&"next"in e&&typeof e.next=="function";function cy(e){return typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function"}function GT(e){return e!=null&&typeof e=="object"&&typeof e.next=="function"}async function kF(e,t){try{let n=await e.next();for(;!n.done;)await t?.(n.value),n=await e.next();return n.value}finally{await e.return?.(void 0)}}function*Tx(e,t){for(;;){let{value:n,done:r}=jt.runWithConfig(Kr(e),t.next.bind(t),!0);if(r)break;yield n}}async function*uy(e,t){let n=t[Symbol.asyncIterator]();for(;;){let{value:r,done:i}=await jt.runWithConfig(Kr(e),n.next.bind(t),!0);if(i)break;yield r}}function vt(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}var Ae=class extends Rn{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 Qv({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new Ci({bound:this,config:e,kwargs:{}})}withFallbacks(e){let t=Array.isArray(e)?e:e.fallbacks;return new nE({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(Te);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");let n=Object.fromEntries(Object.entries(e).filter(([r])=>r!=="runId"));return Array.from({length:t},(r,i)=>Te(i===0?e:n))}return Array.from({length:t},()=>Te(e))}async batch(e,t,n){let r=this._getOptionsList(t??{},e.length),i=new tu({maxConcurrency:r[0]?.maxConcurrency??n?.maxConcurrency,onFailedAttempt:a=>{throw a}}),s=e.map((a,o)=>i.call(async()=>{try{return await this.invoke(a,r[o])}catch(c){if(n?.returnExceptions)return c;throw c}}));return Promise.all(s)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){let n=Te(t),r=new Ts({generator:this._streamIterator(e,n),config:n});return await r.setup,un.fromAsyncGenerator(r)}_separateRunnableConfigFromCallOptions(e){let t;e===void 0?t=Te(e):t=Te({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 n={...e};return delete n.callbacks,delete n.tags,delete n.metadata,delete n.runName,delete n.configurable,delete n.recursionLimit,delete n.maxConcurrency,delete n.runId,delete n.timeout,delete n.signal,[t,n]}async _callWithConfig(e,t,n){let r=Te(n),i=await(await on(r))?.handleChainStart(this.toJSON(),vt(t,"input"),r.runId,r?.runType,void 0,void 0,r?.runName??this.getName());delete r.runId;let s;try{s=await Sr(e.call(this,t,r,i),r.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(vt(s,"output")),s}async _batchWithConfig(e,t,n,r){let i=this._getOptionsList(n??{},t.length),s=await Promise.all(i.map(on)),a=await Promise.all(s.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),vt(t[u],"input"),i[u].runId,i[u].runType,void 0,void 0,i[u].runName??this.getName());return delete i[u].runId,l})),o;try{o=await Sr(e.call(this,t,i,a,r),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(vt(o,"output")))),o}_concatOutputChunks(e,t){return Ii(e,t)}async*_transformStreamWithConfig(e,t,n){let r,i=!0,s,a=!0,o=Te(n),c=await on(o),u=this;async function*l(){for await(let p of e){if(i)if(r===void 0)r=p;else try{r=u._concatOutputChunks(r,p)}catch{r=void 0,i=!1}yield p}}let d;try{let p=await lI(t.bind(this),l(),async()=>c?.handleChainStart(this.toJSON(),{input:""},o.runId,o.runType,void 0,void 0,o.runName??this.getName(),void 0,{lc_defers_inputs:!0}),o.signal,o);delete o.runId,d=p.setup;let h=d?.handlers.find(_F),m=p.output;h!==void 0&&d!==void 0&&(m=h.tapOutputIterable(d.runId,m));let f=d?.handlers.find(hI);f!==void 0&&d!==void 0&&(m=f.tapOutputIterable(d.runId,m));for await(let v of m)if(yield v,a)if(s===void 0)s=v;else try{s=this._concatOutputChunks(s,v)}catch{s=void 0,a=!1}}catch(p){throw await d?.handleChainError(p,void 0,void 0,void 0,{inputs:vt(r,"input")}),p}await d?.handleChainEnd(s??{},void 0,void 0,void 0,{inputs:vt(r,"input")})}getGraph(e){let t=new _c,n=t.addNode({name:`${this.getName()}Input`,schema:ay()}),r=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:ay()});return t.addEdge(n,r),t.addEdge(r,i),t}pipe(e){return new Ni({first:this,last:Nt(e)})}pick(e){return this.pipe(new rE(e))}assign(e){return this.pipe(new eb(new to({steps:e})))}async*transform(e,t){let n;for await(let r of e)n===void 0?n=r:n=this._concatOutputChunks(n,r);yield*this._streamIterator(n,Te(t))}async*streamLog(e,t,n){let r=new Rg({...n,autoClose:!1,_schemaFormat:"original"}),i=Te(t);yield*this._streamLog(e,r,i)}async*_streamLog(e,t,n){let{callbacks:r}=n;if(r===void 0)n.callbacks=[t];else if(Array.isArray(r))n.callbacks=r.concat([t]);else{let o=r.copy();o.addHandler(t,!0),n.callbacks=o}let i=this.stream(e,n);async function s(){try{let o=await i;for await(let c of o){let u=new zr({ops:[{op:"add",path:"/streamed_output/-",value:c}]});await t.writer.write(u)}}finally{await t.writer.close()}}let a=s();try{for await(let o of t)yield o}finally{await a}}streamEvents(e,t,n){let r;if(t.version==="v1")r=this._streamEventsV1(e,t,n);else if(t.version==="v2")r=this._streamEventsV2(e,t,n);else throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');return t.encoding==="text/event-stream"?bF(r):un.fromAsyncGenerator(r)}async*_streamEventsV2(e,t,n){let r=new vF({...n,autoClose:!1}),i=Te(t),s=i.runId??Ur();i.runId=s;let a=i.callbacks;if(a===void 0)i.callbacks=[r];else if(Array.isArray(a))i.callbacks=a.concat(r);else{let h=a.copy();h.addHandler(r,!0),i.callbacks=h}let o=new AbortController,c=this;async function u(){let h;try{if(i.signal)if("any"in AbortSignal)h=AbortSignal.any([o.signal,i.signal]);else{let v=new AbortController;i.signal.addEventListener("abort",()=>v.abort(),{once:!0}),o.signal.addEventListener("abort",()=>v.abort(),{once:!0}),h=v.signal}else h=o.signal;let m=await c.stream(e,{...i,signal:h}),f=r.tapOutputIterable(s,m);for await(let v of f)if(o.signal.aborted)break}finally{await r.finish()}}let l=u(),d=!1,p;try{for await(let h of r){if(!d){h.data.input=e,d=!0,p=h.run_id,yield h;continue}h.run_id===p&&h.event.endsWith("_end")&&h.data?.input&&delete h.data.input,yield h}}finally{o.abort(),await l}}async*_streamEventsV1(e,t,n){let r,i=!1,s=Te(t),a=s.tags??[],o=s.metadata??{},c=s.runName??this.getName(),u=new Rg({...n,autoClose:!1,_schemaFormat:"streaming_events"}),l=new uF({...n}),d=this._streamLog(e,u,s);for await(let h of d){if(r?r=r.concat(h):r=D_.fromRunLogPatch(h),r.state===void 0)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;let g={...r.state},y={run_id:g.id,event:`on_${g.type}_start`,name:c,tags:a,metadata:o,data:{input:e}};l.includeEvent(y,g.type)&&(yield y)}let m=h.ops.filter(g=>g.path.startsWith("/logs/")).map(g=>g.path.split("/")[2]),f=[...new Set(m)];for(let g of f){let y,w={},x=r.state.logs[g];if(x.end_time===void 0?x.streamed_output.length>0?y="stream":y="start":y="end",y==="start")x.inputs!==void 0&&(w.input=x.inputs);else if(y==="end")x.inputs!==void 0&&(w.input=x.inputs),w.output=x.final_output;else if(y==="stream"){let O=x.streamed_output.length;if(O!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${O} instead. Encountered in: "${x.name}"`);w={chunk:x.streamed_output[0]},x.streamed_output=[]}yield{event:`on_${x.type}_${y}`,name:x.name,run_id:x.id,tags:x.tags,metadata:x.metadata,data:w}}let{state:v}=r;if(v.streamed_output.length>0){let g=v.streamed_output.length;if(g!==1)throw new Error(`Expected exactly one chunk of streamed output, got ${g} instead. Encountered in: "${v.name}"`);let y={chunk:v.streamed_output[0]};v.streamed_output=[];let w={event:`on_${v.type}_stream`,run_id:v.id,tags:a,metadata:o,name:c,data:y};l.includeEvent(w,v.type)&&(yield w)}}let p=r?.state;if(p!==void 0){let h={event:`on_${p.type}_end`,name:c,run_id:p.id,tags:a,metadata:o,data:{output:p.final_output}};l.includeEvent(h,p.type)&&(yield h)}}static isRunnable(e){return Yv(e)}withListeners({onStart:e,onEnd:t,onError:n}){return new Ci({bound:this,config:{},configFactories:[r=>({callbacks:[new WT({config:r,onStart:e,onEnd:t,onError:n})]})]})}asTool(e){return OF(this,e)}},Ci=class XT extends Ae{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 n=Nn(this.config,...t);return Nn(n,...this.configFactories?await Promise.all(this.configFactories.map(async r=>await r(n))):[])}withConfig(t){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...t}})}withRetry(t){return new Qv({bound:this.bound,kwargs:this.kwargs,config:this.config,maxAttemptNumber:t?.stopAfterAttempt,...t})}async invoke(t,n){return this.bound.invoke(t,await this._mergeConfig(n,this.kwargs))}async batch(t,n,r){let i=Array.isArray(n)?await Promise.all(n.map(async s=>this._mergeConfig(Te(s),this.kwargs))):await this._mergeConfig(Te(n),this.kwargs);return this.bound.batch(t,i,r)}_concatOutputChunks(t,n){return this.bound._concatOutputChunks(t,n)}async*_streamIterator(t,n){yield*this.bound._streamIterator(t,await this._mergeConfig(Te(n),this.kwargs))}async stream(t,n){return this.bound.stream(t,await this._mergeConfig(Te(n),this.kwargs))}async*transform(t,n){yield*this.bound.transform(t,await this._mergeConfig(Te(n),this.kwargs))}streamEvents(t,n,r){let i=this,s=async function*(){yield*i.bound.streamEvents(t,{...await i._mergeConfig(Te(n),i.kwargs),version:n.version},r)};return un.fromAsyncGenerator(s())}static isRunnableBinding(t){return t.bound&&Ae.isRunnable(t.bound)}withListeners({onStart:t,onEnd:n,onError:r}){return new XT({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[i=>({callbacks:[new WT({config:i,onStart:t,onEnd:n,onError:r})]})]})}},xF=class YT extends Ae{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,n){return this._callWithConfig(this._invoke.bind(this),t,n)}async _invoke(t,n,r){return this.bound.batch(t,Re(n,{callbacks:r?.getChild()}))}withListeners({onStart:t,onEnd:n,onError:r}){return new YT({bound:this.bound.withListeners({onStart:t,onEnd:n,onError:r})})}},Qv=class extends Ci{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,n){let r=e>1?`retry:attempt:${e}`:void 0;return Re(t,{callbacks:n?.getChild(r)})}async _invoke(e,t,n){return Mg(r=>super.invoke(e,this._patchConfigForRetry(r,t,n)),{onFailedAttempt:({error:r})=>this.onFailedAttempt(r,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,n,r){let i={};try{await Mg(async s=>{let a=e.map((d,p)=>p).filter(d=>i[d.toString()]===void 0||i[d.toString()]instanceof Error),o=a.map(d=>e[d]),c=a.map(d=>this._patchConfigForRetry(s,t?.[d],n?.[d])),u=await super.batch(o,c,{...r,returnExceptions:!0}),l;for(let d=0;d<u.length;d+=1){let p=u[d],h=a[d];p instanceof Error&&l===void 0&&(l=p,l.input=o[d]),i[h.toString()]=p}if(l)throw l;return u},{onFailedAttempt:({error:s})=>this.onFailedAttempt(s,s.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(s){if(r?.returnExceptions!==!0)throw s}return Object.keys(i).sort((s,a)=>parseInt(s,10)-parseInt(a,10)).map(s=>i[parseInt(s,10)])}async batch(e,t,n){return this._batchWithConfig(this._batch.bind(this),e,t,n)}},Ni=class Eo extends Ae{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,n){let r=Te(n),i=await(await on(r))?.handleChainStart(this.toJSON(),vt(t,"input"),r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;let s=t,a;try{let o=[this.first,...this.middle];for(let c=0;c<o.length;c+=1)s=await Sr(o[c].invoke(s,Re(r,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`)})),r.signal);if(r.signal?.aborted)throw sc(r.signal);a=await this.last.invoke(s,Re(r,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(o){throw await i?.handleChainError(o),o}return await i?.handleChainEnd(vt(a,"output")),a}async batch(t,n,r){let i=this._getOptionsList(n??{},t.length),s=await Promise.all(i.map(on)),a=await Promise.all(s.map(async(c,u)=>{let l=await c?.handleChainStart(this.toJSON(),vt(t[u],"input"),i[u].runId,void 0,void 0,void 0,i[u].runName);return delete i[u].runId,l})),o=t;try{for(let c=0;c<this.steps.length;c+=1)o=await Sr(this.steps[c].batch(o,a.map((u,l)=>{let d=u?.getChild(this.omitSequenceTags?void 0:`seq:step:${c+1}`);return Re(i[l],{callbacks:d})}),r),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(vt(o,"output")))),o}_concatOutputChunks(t,n){return this.last._concatOutputChunks(t,n)}async*_streamIterator(t,n){let r=await on(n),{runId:i,...s}=n??{},a=await r?.handleChainStart(this.toJSON(),vt(t,"input"),i,void 0,void 0,void 0,s?.runName),o=[this.first,...this.middle,this.last],c=!0,u;async function*l(){yield t}try{let d=o[0].transform(l(),Re(s,{callbacks:a?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let p=1;p<o.length;p+=1)d=await o[p].transform(d,Re(s,{callbacks:a?.getChild(this.omitSequenceTags?void 0:`seq:step:${p+1}`)}));for await(let p of d)if(n?.signal?.throwIfAborted(),yield p,c)if(u===void 0)u=p;else try{u=this._concatOutputChunks(u,p)}catch{u=void 0,c=!1}}catch(d){throw await a?.handleChainError(d),d}await a?.handleChainEnd(vt(u,"output"))}getGraph(t){let n=new _c,r=null;return this.steps.forEach((i,s)=>{let a=i.getGraph(t);s!==0&&a.trimFirstNode(),s!==this.steps.length-1&&a.trimLastNode(),n.extend(a);let o=a.firstNode();if(!o)throw new Error(`Runnable ${i} has no first node`);r&&n.addEdge(r,o),r=a.lastNode()}),n}pipe(t){return Eo.isRunnableSequence(t)?new Eo({first:this.first,middle:this.middle.concat([this.last,t.first,...t.middle]),last:t.last,name:this.name??t.name}):new Eo({first:this.first,middle:[...this.middle,this.last],last:Nt(t),name:this.name})}static isRunnableSequence(t){return Array.isArray(t.middle)&&Ae.isRunnable(t)}static from([t,...n],r){let i={};return typeof r=="string"?i.name=r:r!==void 0&&(i=r),new Eo({...i,first:Nt(t),middle:n.slice(0,-1).map(Nt),last:Nt(n[n.length-1])})}},to=class QT extends Ae{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[n,r]of Object.entries(t.steps))this.steps[n]=Nt(r)}static from(t){return new QT({steps:t})}async invoke(t,n){let r=Te(n),i=await(await on(r))?.handleChainStart(this.toJSON(),{input:t},r.runId,void 0,void 0,void 0,r?.runName);delete r.runId;let s={};try{let a=Object.entries(this.steps).map(async([o,c])=>{s[o]=await c.invoke(t,Re(r,{callbacks:i?.getChild(`map:key:${o}`)}))});await Sr(Promise.all(a),r.signal)}catch(a){throw await i?.handleChainError(a),a}return await i?.handleChainEnd(s),s}async*_transform(t,n,r){let i={...this.steps},s=z_(t,Object.keys(i).length),a=new Map(Object.entries(i).map(([o,c],u)=>{let l=c.transform(s[u],Re(r,{callbacks:n?.getChild(`map:key:${o}`)}));return[o,l.next().then(d=>({key:o,gen:l,result:d}))]}));for(;a.size;){let{key:o,result:c,gen:u}=await Sr(Promise.race(a.values()),r?.signal);a.delete(o),c.done||(yield{[o]:c.value},a.set(o,u.next().then(l=>({key:o,gen:u,result:l}))))}}transform(t,n){return this._transformStreamWithConfig(t,this._transform.bind(this),n)}async stream(t,n){async function*r(){yield t}let i=Te(n),s=new Ts({generator:this.transform(r(),i),config:i});return await s.setup,un.fromAsyncGenerator(s)}},$F=class eE extends Ae{lc_serializable=!1;lc_namespace=["langchain_core","runnables"];func;constructor(t){if(super(t),!U_(t.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=t.func}async invoke(t,n){let[r]=this._getOptionsList(n??{},1),i=await on(r);return Sr(this.func(Re(r,{callbacks:i}),t),r?.signal)}async*_streamIterator(t,n){let[r]=this._getOptionsList(n??{},1),i=await this.invoke(t,n);if(cy(i)){for await(let s of i)r?.signal?.throwIfAborted(),yield s;return}if(wF(i)){for(;;){r?.signal?.throwIfAborted();let s=i.next();if(s.done)break;yield s.value}return}yield i}static from(t){return new eE({func:t})}};function IF(e){if(U_(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}var ir=class tE extends Ae{static lc_name(){return"RunnableLambda"}lc_namespace=["langchain_core","runnables"];func;constructor(t){if(U_(t.func))return $F.from(t.func);super(t),IF(t.func),this.func=t.func}static from(t){return new tE({func:t})}async _invoke(t,n,r){return new Promise((i,s)=>{let a=Re(n,{callbacks:r?.getChild(),recursionLimit:(n?.recursionLimit??25)-1});jt.runWithConfig(Kr(a),async()=>{try{let o=await this.func(t,{...a});if(o&&Ae.isRunnable(o)){if(n?.recursionLimit===0)throw new Error("Recursion limit reached.");o=await o.invoke(t,{...a,recursionLimit:(a.recursionLimit??25)-1})}else if(cy(o)){let c;for await(let u of uy(a,o))if(n?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}o=c}else if(Ax(o)){let c;for(let u of Tx(a,o))if(n?.signal?.throwIfAborted(),c===void 0)c=u;else try{c=this._concatOutputChunks(c,u)}catch{c=u}o=c}i(o)}catch(o){s(o)}})})}async invoke(t,n){return this._callWithConfig(this._invoke.bind(this),t,n)}async*_transform(t,n,r){let i;for await(let o of t)if(i===void 0)i=o;else try{i=this._concatOutputChunks(i,o)}catch{i=o}let s=Re(r,{callbacks:n?.getChild(),recursionLimit:(r?.recursionLimit??25)-1}),a=await new Promise((o,c)=>{jt.runWithConfig(Kr(s),async()=>{try{o(await this.func(i,{...s,config:s}))}catch(u){c(u)}})});if(a&&Ae.isRunnable(a)){if(r?.recursionLimit===0)throw new Error("Recursion limit reached.");let o=await a.stream(i,s);for await(let c of o)yield c}else if(cy(a))for await(let o of uy(s,a))r?.signal?.throwIfAborted(),yield o;else if(Ax(a))for(let o of Tx(s,a))r?.signal?.throwIfAborted(),yield o;else yield a}transform(t,n){return this._transformStreamWithConfig(t,this._transform.bind(this),n)}async stream(t,n){async function*r(){yield t}let i=Te(n),s=new Ts({generator:this.transform(r(),i),config:i});return await s.setup,un.fromAsyncGenerator(s)}},SF=class extends to{},nE=class extends Ae{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 n=Te(t),r=await on(n),{runId:i,...s}=n,a=await r?.handleChainStart(this.toJSON(),vt(e,"input"),i,void 0,void 0,void 0,s?.runName),o=Re(s,{callbacks:a?.getChild()});return await jt.runWithConfig(o,async()=>{let c;for(let u of this.runnables()){n?.signal?.throwIfAborted();try{let l=await u.invoke(e,o);return await a?.handleChainEnd(vt(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 n=Te(t),r=await on(n),{runId:i,...s}=n,a=await r?.handleChainStart(this.toJSON(),vt(e,"input"),i,void 0,void 0,void 0,s?.runName),o,c;for(let l of this.runnables()){n?.signal?.throwIfAborted();let d=Re(s,{callbacks:a?.getChild()});try{c=uy(d,await l.stream(e,d));break}catch(p){o===void 0&&(o=p)}}if(c===void 0){let l=o??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(vt(u,"output"))}async batch(e,t,n){if(n?.returnExceptions)throw new Error("Not implemented.");let r=this._getOptionsList(t??{},e.length),i=await Promise.all(r.map(o=>on(o))),s=await Promise.all(i.map(async(o,c)=>{let u=await o?.handleChainStart(this.toJSON(),vt(e[c],"input"),r[c].runId,void 0,void 0,void 0,r[c].runName);return delete r[c].runId,u})),a;for(let o of this.runnables()){r[0].signal?.throwIfAborted();try{let c=await o.batch(e,s.map((u,l)=>Re(r[l],{callbacks:u?.getChild()})),n);return await Promise.all(s.map((u,l)=>u?.handleChainEnd(vt(c[l],"output")))),c}catch(c){a===void 0&&(a=c)}}throw a?(await Promise.all(s.map(o=>o?.handleChainError(a))),a):new Error("No error stored at end of fallbacks.")}};function Nt(e){if(typeof e=="function")return new ir({func:e});if(Ae.isRunnable(e))return e;if(!Array.isArray(e)&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))t[n]=Nt(r);return new to({steps:t})}else throw new Error(`Expected a Runnable, function or object.
|
|
151
|
+
Instead got an unsupported type.`)}var eb=class extends Ae{static lc_name(){return"RunnableAssign"}lc_namespace=["langchain_core","runnables"];lc_serializable=!0;mapper;constructor(e){e instanceof to&&(e={mapper:e}),super(e),this.mapper=e.mapper}async invoke(e,t){let n=await this.mapper.invoke(e,t);return{...e,...n}}async*_transform(e,t,n){let r=this.mapper.getStepsKeys(),[i,s]=z_(e),a=this.mapper.transform(s,Re(n,{callbacks:t?.getChild()})),o=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])=>!r.includes(l)));Object.keys(u).length>0&&(yield u)}yield(await o).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*n(){yield e}let r=Te(t),i=new Ts({generator:this.transform(n(),r),config:r});return await i.setup,un.fromAsyncGenerator(i)}},rE=class extends Ae{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(n=>[n,e[n]]).filter(n=>n[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 n=await this._pick(t);n!==void 0&&(yield n)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){async function*n(){yield e}let r=Te(t),i=new Ts({generator:this.transform(n(),r),config:r});return await i.setup,un.fromAsyncGenerator(i)}},ly=class extends Ci{name;description;schema;constructor(e){let t=Ni.from([ir.from(async n=>{let r;if(qo(n))try{r=await Lh(this.schema,n.args)}catch{throw new pd("Received tool input did not match expected schema",JSON.stringify(n.args))}else r=n;return r}).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 OF(e,t){let n=t.name??e.getName(),r=t.description??ja(t.schema);return Wv(t.schema)?new ly({name:n,description:r,schema:tt({input:lt()}).transform(i=>i.input),bound:e}):new ly({name:n,description:r,schema:t.schema,bound:e})}var jd=(e,t)=>{let n=[...new Set(t?.map(i=>{if(typeof i=="string")return i;let s=new i({});if(!("getType"in s)||typeof s.getType!="function")throw new Error("Invalid type provided.");return s.getType()}))],r=e.getType();return n.some(i=>i===r)};function AF(e,t){return Array.isArray(e)?Ex(e,t):ir.from(n=>Ex(n,e))}function Ex(e,t={}){let{includeNames:n,excludeNames:r,includeTypes:i,excludeTypes:s,includeIds:a,excludeIds:o}=t,c=[];for(let u of e)if(!(r&&u.name&&r.includes(u.name))){if(s&&jd(u,s)||o&&u.id&&o.includes(u.id))continue;i||a||n?(n&&u.name&&n.some(l=>l===u.name)||i&&jd(u,i)||a&&u.id&&a.some(l=>l===u.id))&&c.push(u):c.push(u)}return c}function TF(e){return Array.isArray(e)?Cx(e):ir.from(Cx)}function Cx(e){if(!e.length)return[];let t=[];for(let n of e){let r=n,i=t.pop();if(!i)t.push(r);else if(r.getType()==="tool"||r.getType()!==i.getType())t.push(i,r);else{let s=md(i),a=md(r),o=s.concat(a);typeof s.content=="string"&&typeof a.content=="string"&&(o.content=`${s.content}
|
|
152
|
+
${a.content}`),t.push(NF(o))}}return t}function EF(e,t){if(Array.isArray(e)){let n=e;if(!t)throw new Error("Options parameter is required when providing messages.");return Nx(n,t)}else{let n=e;return ir.from(r=>Nx(r,n)).withConfig({runName:"trim_messages"})}}async function Nx(e,t){let{maxTokens:n,tokenCounter:r,strategy:i="last",allowPartial:s=!1,endOn:a,startOn:o,includeSystem:c=!1,textSplitter:u}=t;if(o&&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 r?l=async p=>(await Promise.all(p.map(h=>r.getNumTokens(h.content)))).reduce((h,m)=>h+m,0):l=async p=>r(p);let d=sE;if(u&&("splitText"in u?d=u.splitText:d=async p=>u(p)),i==="first")return iE(e,{maxTokens:n,tokenCounter:l,textSplitter:d,partialStrategy:s?"first":void 0,endOn:a});if(i==="last")return CF(e,{maxTokens:n,tokenCounter:l,textSplitter:d,allowPartial:s,includeSystem:c,startOn:o,endOn:a});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function iE(e,t){let{maxTokens:n,tokenCounter:r,textSplitter:i,partialStrategy:s,endOn:a}=t,o=[...e],c=0;for(let u=0;u<o.length;u+=1)if(await r(u>0?o.slice(0,-u):o)<=n){c=o.length-u;break}if(c<o.length&&s){let u=!1;if(Array.isArray(o[c].content)){let l=o[c];if(typeof l.content=="string")throw new Error("Expected content to be an array.");let d=l.content.length,p=s==="last"?[...l.content].reverse():l.content;for(let h=1;h<=d;h+=1){let m=s==="first"?p.slice(0,h):p.slice(-h),f=Object.fromEntries(Object.entries(l).filter(([y])=>y!=="type"&&!y.startsWith("lc_"))),v=tb(l.getType(),{...f,content:m}),g=[...o.slice(0,c),v];if(await r(g)<=n)o=g,c+=1,u=!0;else break}u&&s==="last"&&(l.content=[...p].reverse())}if(!u){let l=o[c],d;if(Array.isArray(l.content)&&l.content.some(p=>typeof p=="string"||p.type==="text")?d=l.content.find(p=>p.type==="text"&&p.text)?.text:typeof l.content=="string"&&(d=l.content),d){let p=await i(d),h=p.length;s==="last"&&p.reverse();for(let m=0;m<h-1;m+=1)if(p.pop(),l.content=p.join(""),await r([...o.slice(0,c),l])<=n){s==="last"&&(l.content=[...p].reverse().join("")),o=[...o.slice(0,c),l],c+=1;break}}}}if(a){let u=Array.isArray(a)?a:[a];for(;c>0&&!jd(o[c-1],u);)c-=1}return o.slice(0,c)}async function CF(e,t){let{allowPartial:n=!1,includeSystem:r=!1,endOn:i,startOn:s,...a}=t,o=e.map(l=>{let d=Object.fromEntries(Object.entries(l).filter(([p])=>p!=="type"&&!p.startsWith("lc_")));return tb(l.getType(),d,ms(l))});if(i){let l=Array.isArray(i)?i:[i];for(;o.length>0&&!jd(o[o.length-1],l);)o=o.slice(0,-1)}let c=r&&o[0]?.getType()==="system",u=c?o.slice(0,1).concat(o.slice(1).reverse()):o.reverse();return u=await iE(u,{...a,partialStrategy:n?"last":void 0,endOn:s}),c?[u[0],...u.slice(1).reverse()]:u.reverse()}var Px={human:{message:$n,messageChunk:Xc},ai:{message:Le,messageChunk:Pt},system:{message:Ir,messageChunk:xi},developer:{message:Ir,messageChunk:xi},tool:{message:Mn,messageChunk:Kc},function:{message:_h,messageChunk:Gc},generic:{message:Qr,messageChunk:Wc},remove:{message:os,messageChunk:os}};function tb(e,t,n){let r,i;switch(e){case"human":n?r=new Xc(t):i=new $n(t);break;case"ai":if(n){let s={...t};"tool_calls"in s&&(s={...s,tool_call_chunks:s.tool_calls?.map(a=>({...a,type:"tool_call_chunk",index:void 0,args:JSON.stringify(a.args)}))}),r=new Pt(s)}else i=new Le(t);break;case"system":n?r=new xi(t):i=new Ir(t);break;case"developer":n?r=new xi({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}}):i=new Ir({...t,additional_kwargs:{...t.additional_kwargs,__openai_role__:"developer"}});break;case"tool":if("tool_call_id"in t)n?r=new Kc(t):i=new Mn(t);else throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");break;case"function":if(n)r=new Gc(t);else{if(!t.name)throw new Error("FunctionMessage must have a 'name' field");i=new _h(t)}break;case"generic":if("role"in t)n?r=new Wc(t):i=new Qr(t);else throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");break;default:throw new Error(`Unrecognized message type ${e}`)}if(n&&r)return r;if(i)return i;throw new Error(`Unrecognized message type ${e}`)}function NF(e){let t=e.getType(),n,r=Object.fromEntries(Object.entries(e).filter(([i])=>!["type","tool_call_chunks"].includes(i)&&!i.startsWith("lc_")));if(t in Px&&(n=tb(t,r)),!n)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(Px)}`);return n}function sE(e){let t=e.split(`
|
|
153
|
+
`);return Promise.resolve([...t.slice(0,-1).map(n=>`${n}
|
|
154
|
+
`),t[t.length-1]])}var PF=["tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result"],jF=["image","video","audio","text-plain","file"],RF=["text","reasoning",...PF,...jF],MF=G({AIMessage:()=>Le,AIMessageChunk:()=>Pt,BaseMessage:()=>Gt,BaseMessageChunk:()=>Ui,ChatMessage:()=>Qr,ChatMessageChunk:()=>Wc,DEFAULT_MERGE_IGNORE_KEYS:()=>h1,FunctionMessage:()=>_h,FunctionMessageChunk:()=>Gc,HumanMessage:()=>$n,HumanMessageChunk:()=>Xc,KNOWN_BLOCK_TYPES:()=>RF,RemoveMessage:()=>os,SystemMessage:()=>Ir,SystemMessageChunk:()=>xi,ToolMessage:()=>Mn,ToolMessageChunk:()=>Kc,_isMessageFieldWithRole:()=>g1,_mergeDicts:()=>Zt,_mergeLists:()=>va,_mergeObj:()=>m1,_mergeStatus:()=>p1,coerceMessageLikeToMessage:()=>br,collapseToolCallChunks:()=>x1,convertToChunk:()=>md,convertToOpenAIImageBlock:()=>c1,convertToProviderContentBlock:()=>k_,defaultTextSplitter:()=>sE,defaultToolCallParser:()=>S_,filterMessages:()=>AF,getBufferString:()=>T_,iife:()=>k1,isAIMessage:()=>yh,isAIMessageChunk:()=>sg,isBase64ContentBlock:()=>w_,isBaseMessage:()=>it,isBaseMessageChunk:()=>ms,isChatMessage:()=>LR,isChatMessageChunk:()=>zR,isDataContentBlock:()=>$r,isDirectToolOutput:()=>I_,isFunctionMessage:()=>DR,isFunctionMessageChunk:()=>FR,isHumanMessage:()=>ZR,isHumanMessageChunk:()=>BR,isIDContentBlock:()=>o1,isMessage:()=>d1,isOpenAIToolCallArray:()=>vR,isPlainTextContentBlock:()=>nR,isSystemMessage:()=>qR,isSystemMessageChunk:()=>JR,isToolMessage:()=>ec,isToolMessageChunk:()=>y1,isURLContentBlock:()=>b_,mapChatMessagesToStoredMessages:()=>XR,mapStoredMessageToChatMessage:()=>E_,mapStoredMessagesToChatMessages:()=>GR,mergeContent:()=>Vr,mergeMessageRuns:()=>TF,mergeResponseMetadata:()=>v1,mergeUsageMetadata:()=>A_,parseBase64DataUrl:()=>Qo,parseMimeType:()=>ig,trimMessages:()=>EF}),UF=G({BaseChatMessageHistory:()=>aE,BaseListChatMessageHistory:()=>nb,InMemoryChatMessageHistory:()=>LF}),aE=class extends Rn{async addMessages(e){for(let t of e)await this.addMessage(t)}},nb=class extends Rn{addUserMessage(e){return this.addMessage(new $n(e))}addAIMessage(e){return this.addMessage(new Le(e))}async addMessages(e){for(let t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}},LF=class extends nb{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=[]}},bi=class{pageContent;metadata;id;constructor(e){this.pageContent=e.pageContent!==void 0?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}},oE=class extends Ae{lc_namespace=["langchain_core","documents","transformers"];invoke(e,t){return this.transformDocuments(e)}},zF=class extends oE{async transformDocuments(e){let t=[];for(let n of e){let r=await this._transformDocument(n);t.push(r)}return t}},DF=G({BaseDocumentTransformer:()=>oE,Document:()=>bi,MappingDocumentTransformer:()=>zF}),FF=G({BaseDocumentLoader:()=>cE}),cE=class{},ZF=G({LangSmithLoader:()=>BF}),BF=class extends cE{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 ka(e?.clientConfig),this.contentKey=e.contentKey?e.contentKey.split("."):[],this.formatContent=e.formatContent??qF,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 n=t.inputs;for(let s of this.contentKey)n=n[s];let r=this.formatContent(n),i=t;["created_at","modified_at"].forEach(s=>{s in i&&typeof i[s]=="object"&&(i[s]=i[s].toString())}),e.push({pageContent:r,metadata:i})}return e}};function qF(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}var JF=G({Embeddings:()=>Zh}),Zh=class{caller;constructor(e){this.caller=new tu(e??{})}},rb=class extends Rn{lc_namespace=["langchain_core","example_selectors","base"]},uE=class{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}},HF=class extends uE{defaultPrompt;conditionals;constructor(e,t=[]){super(),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(let[t,n]of this.conditionals)if(t(e))return n;return this.defaultPrompt}};function VF(e){return e._modelType()==="base_llm"}function KF(e){return e._modelType()==="base_chat_model"}function jx(e){return e.split(/\n| /).length}var WF=class lE extends rb{examples=[];examplePrompt;getTextLength=jx;maxLength=2048;exampleTextLengths=[];constructor(t){super(t),this.examplePrompt=t.examplePrompt,this.maxLength=t.maxLength??2048,this.getTextLength=t.getTextLength??jx}async addExample(t){this.examples.push(t);let n=await this.examplePrompt.format(t);this.exampleTextLengths.push(this.getTextLength(n))}async calculateExampleTextLengths(t,n){if(t.length>0)return t;let{examples:r,examplePrompt:i}=n;return(await Promise.all(r.map(s=>i.format(s)))).map(s=>this.getTextLength(s))}async selectExamples(t){let n=Object.values(t).join(" "),r=this.maxLength-this.getTextLength(n),i=0,s=[];for(;r>0&&i<this.examples.length;){let a=r-this.exampleTextLengths[i];if(a<0)break;s.push(this.examples[i]),r=a,i+=1}return s}static async fromExamples(t,n){let r=new lE(n);return await Promise.all(t.map(i=>r.addExample(i))),r}};function bf(e){return Object.keys(e).sort().map(t=>e[t])}var GF=class dE extends rb{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 n=bf((this.inputKeys??Object.keys(t)).reduce((r,i)=>({...r,[i]:t[i]}),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new bi({pageContent:n,metadata:t})])}async selectExamples(t){let n=bf((this.inputKeys??Object.keys(t)).reduce((i,s)=>({...i,[s]:t[s]}),{})).join(" "),r=(await this.vectorStoreRetriever.invoke(n)).map(i=>i.metadata);return this.exampleKeys?r.map(i=>this.exampleKeys.reduce((s,a)=>({...s,[a]:i[a]}),{})):r}static async fromExamples(t,n,r,i={}){let s=i.inputKeys??null,a=t.map(o=>bf(s?s.reduce((c,u)=>({...c,[u]:o[u]}),{}):o).join(" "));return new dE({vectorStore:await r.fromTexts(a,t,n,i),k:i.k??4,exampleKeys:i.exampleKeys,inputKeys:i.inputKeys})}},XF=G({BaseExampleSelector:()=>rb,BasePromptSelector:()=>uE,ConditionalPromptSelector:()=>HF,LengthBasedExampleSelector:()=>WF,SemanticSimilarityExampleSelector:()=>GF,isChatModel:()=>KF,isLLM:()=>VF}),dy="10f90ea3-90a4-4962-bf75-83a0f3c1c62a",YF=class extends Rn{lc_namespace=["langchain","recordmanagers"]},pE=class{uid;hash_;contentHash;metadataHash;pageContent;metadata;keyEncoder=__;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 n of e)if(n in this.metadata)throw new Error(`Metadata cannot contain key ${n} as it is reserved for internal use. Restricted keys: [${e.join(", ")}]`);let t=this._hashStringToUUID(this.pageContent);try{let n=this._hashNestedDictToUUID(this.metadata);this.contentHash=t,this.metadataHash=n}catch(n){throw new Error(`Failed to hash metadata: ${n}. 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 bi({pageContent:this.pageContent,metadata:this.metadata})}static fromDocument(e,t){let n=new this({pageContent:e.pageContent,metadata:e.metadata,uid:t||e.uid});return n.calculateHashes(),n}_hashStringToUUID(e){return nc(this.keyEncoder(e),dy)}_hashNestedDictToUUID(e){let t=JSON.stringify(e,Object.keys(e).sort());return nc(this.keyEncoder(t),dy)}};function hE(e,t){let n=[],r=[];return t.forEach(i=>{r.push(i),r.length>=e&&(n.push(r),r=[])}),r.length>0&&n.push(r),n}function mE(e){let t=new Set,n=[];for(let r of e){if(!r.hash_)throw new Error("Hashed document does not have a hash");t.has(r.hash_)||(t.add(r.hash_),n.push(r))}return n}function fE(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 gE=e=>"load"in e&&typeof e.load=="function"&&"loadAndSplit"in e&&typeof e.loadAndSplit=="function";async function QF(e){let{docsSource:t,recordManager:n,vectorStore:r,options:i}=e,{batchSize:s=100,cleanup:a,sourceIdKey:o,cleanupBatchSize:c=1e3,forceUpdate:u=!1}=i??{};if(a==="incremental"&&!o)throw new Error("sourceIdKey is required when cleanup mode is incremental. Please provide through 'options.sourceIdKey'.");let l=gE(t)?await t.load():t,d=fE(o??null),p=await n.getTime(),h=0,m=0,f=0,v=0,g=hE(s??100,l);for(let y of g){let w=mE(y.map(C=>pE.fromDocument(C))),x=w.map(C=>d(C));a==="incremental"&&w.forEach((C,E)=>{if(x[E]===null)throw new Error("sourceIdKey must be provided when cleanup is incremental")});let O=await n.exists(w.map(C=>C.uid)),z=[],T=[],k=[],B=new Set;if(w.forEach((C,E)=>{if(O[E])if(u)B.add(C.uid);else{k.push(C.uid);return}z.push(C.uid),T.push(C.toDocument())}),k.length>0&&(await n.update(k,{timeAtLeast:p}),v+=k.length),T.length>0&&(await r.addDocuments(T,{ids:z}),h+=T.length-B.size,f+=B.size),await n.update(w.map(C=>C.uid),{timeAtLeast:p,groupIds:x}),a==="incremental"){x.forEach(E=>{if(!E)throw new Error("Source id cannot be null")});let C=await n.listKeys({before:p,groupIds:x});C.length>0&&(await r.delete({ids:C}),await n.deleteKeys(C),m+=C.length)}}if(a==="full"){let y=await n.listKeys({before:p,limit:c});for(;y.length>0;)await r.delete({ids:y}),await n.deleteKeys(y),m+=y.length,y=await n.listKeys({before:p,limit:c})}return{numAdded:h,numDeleted:m,numUpdated:f,numSkipped:v}}var eZ=G({RecordManager:()=>YF,UUIDV5_NAMESPACE:()=>dy,_HashedDocument:()=>pE,_batch:()=>hE,_deduplicateInOrder:()=>mE,_getSourceIdAssigner:()=>fE,_isBaseDocumentLoader:()=>gE,index:()=>QF}),tZ=G({BasePromptValue:()=>Bh,ChatPromptValue:()=>sb,ImagePromptValue:()=>yE,StringPromptValue:()=>ib}),Bh=class extends Rn{},ib=class extends Bh{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 $n(this.value)]}},sb=class extends Bh{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 T_(this.messages)}toChatMessages(){return this.messages}},yE=class extends Bh{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 $n({content:[{type:"image_url",image_url:{detail:this.imageUrl.detail,url:this.imageUrl.url}}]})]}},wo={},Rx;function nZ(){if(Rx)return wo;Rx=1,wo.byteLength=o,wo.toByteArray=u,wo.fromByteArray=p;for(var e=[],t=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,s=r.length;i<s;++i)e[i]=r[i],t[r.charCodeAt(i)]=i;t[45]=62,t[95]=63;function a(h){var m=h.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=h.indexOf("=");f===-1&&(f=m);var v=f===m?0:4-f%4;return[f,v]}function o(h){var m=a(h),f=m[0],v=m[1];return(f+v)*3/4-v}function c(h,m,f){return(m+f)*3/4-f}function u(h){var m,f=a(h),v=f[0],g=f[1],y=new n(c(h,v,g)),w=0,x=g>0?v-4:v,O;for(O=0;O<x;O+=4)m=t[h.charCodeAt(O)]<<18|t[h.charCodeAt(O+1)]<<12|t[h.charCodeAt(O+2)]<<6|t[h.charCodeAt(O+3)],y[w++]=m>>16&255,y[w++]=m>>8&255,y[w++]=m&255;return g===2&&(m=t[h.charCodeAt(O)]<<2|t[h.charCodeAt(O+1)]>>4,y[w++]=m&255),g===1&&(m=t[h.charCodeAt(O)]<<10|t[h.charCodeAt(O+1)]<<4|t[h.charCodeAt(O+2)]>>2,y[w++]=m>>8&255,y[w++]=m&255),y}function l(h){return e[h>>18&63]+e[h>>12&63]+e[h>>6&63]+e[h&63]}function d(h,m,f){for(var v,g=[],y=m;y<f;y+=3)v=(h[y]<<16&16711680)+(h[y+1]<<8&65280)+(h[y+2]&255),g.push(l(v));return g.join("")}function p(h){for(var m,f=h.length,v=f%3,g=[],y=16383,w=0,x=f-v;w<x;w+=y)g.push(d(h,w,w+y>x?x:w+y));return v===1?(m=h[f-1],g.push(e[m>>2]+e[m<<4&63]+"==")):v===2&&(m=(h[f-2]<<8)+h[f-1],g.push(e[m>>10]+e[m>>4&63]+e[m<<2&63]+"=")),g.join("")}return wo}var rZ=nZ(),iZ=Us(rZ),sZ=Object.defineProperty,aZ=(e,t,n)=>t in e?sZ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oZ=(e,t,n)=>(aZ(e,t+"",n),n);function cZ(e,t){let n=Array.from({length:e.length},(r,i)=>({start:i,end:i+1}));for(;n.length>1;){let r=null;for(let i=0;i<n.length-1;i++){let s=e.slice(n[i].start,n[i+1].end),a=t.get(s.join(","));a!=null&&(r==null||a<r[0])&&(r=[a,i])}if(r!=null){let i=r[1];n[i]={start:n[i].start,end:n[i+1].end},n.splice(i+1,1)}else break}return n}function uZ(e,t){return e.length===1?[t.get(e.join(","))]:cZ(e,t).map(n=>t.get(e.slice(n.start,n.end).join(","))).filter(n=>n!=null)}function lZ(e){return e.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}var py=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 n=e.bpe_ranks.split(`
|
|
155
|
+
`).filter(Boolean).reduce((r,i)=>{let[s,a,...o]=i.split(" "),c=Number.parseInt(a,10);return o.forEach((u,l)=>r[u]=c+l),r},{});for(let[r,i]of Object.entries(n)){let s=iZ.toByteArray(r);this.rankMap.set(s.join(","),i),this.textMap.set(i,s)}this.specialTokens={...e.special_tokens,...t},this.inverseSpecialTokens=Object.entries(this.specialTokens).reduce((r,[i,s])=>(r[s]=this.textEncoder.encode(i),r),{})}encode(e,t=[],n="all"){let r=new RegExp(this.patStr,"ug"),i=py.specialTokenRegex(Object.keys(this.specialTokens)),s=[],a=new Set(t==="all"?Object.keys(this.specialTokens):t),o=new Set(n==="all"?Object.keys(this.specialTokens).filter(u=>!a.has(u)):n);if(o.size>0){let u=py.specialTokenRegex([...o]),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 h of e.substring(c,d).matchAll(r)){let m=this.textEncoder.encode(h[0]),f=this.rankMap.get(m.join(","));if(f!=null){s.push(f);continue}s.push(...uZ(m,this.rankMap))}if(u==null)break;let p=this.specialTokens[u[0]];s.push(p),c=u.index+u[0].length}return s}decode(e){let t=[],n=0;for(let s=0;s<e.length;++s){let a=e[s],o=this.textMap.get(a)??this.inverseSpecialTokens[a];o!=null&&(t.push(o),n+=o.length)}let r=new Uint8Array(n),i=0;for(let s of t)r.set(s,i),i+=s.length;return this.textDecoder.decode(r)}},_E=py;oZ(_E,"specialTokenRegex",e=>new RegExp(e.map(t=>lZ(t)).join("|"),"g"));function dZ(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 pZ=G({encodingForModel:()=>ab,getEncoding:()=>vE}),hl={},hZ=new tu({});async function vE(e){return e in hl||(hl[e]=hZ.fetch(`https://tiktoken.pages.dev/js/${e}.json`).then(t=>t.json()).then(t=>new _E(t)).catch(t=>{throw delete hl[e],t})),await hl[e]}async function ab(e){return vE(dZ(e))}var mZ=G({BaseLangChain:()=>cb,BaseLanguageModel:()=>Jh,calculateMaxTokens:()=>gZ,getEmbeddingContextSize:()=>fZ,getModelContextSize:()=>bE,getModelNameForTiktoken:()=>qh,isOpenAITool:()=>ob}),qh=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,fZ=e=>e==="text-embedding-ada-002"?8191:2046,bE=e=>{switch(qh(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 ob(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 gZ=async({prompt:e,modelName:t})=>{let n;try{n=(await ab(qh(t))).encode(e).length}catch{console.warn("Failed to calculate number of tokens, falling back to approximate count"),n=Math.ceil(e.length/4)}return bE(t)-n},yZ=()=>!1,cb=class extends Ae{verbose;callbacks;tags;metadata;get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),this.verbose=e.verbose??yZ(),this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{},this._addVersion("@langchain/core","1.1.45")}_addVersion(e,t){let n=this.metadata?.versions;this.metadata={...this.metadata,versions:{...typeof n=="object"&&n!==null?n:{},[e]:t}}}},Jh=class extends cb{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}caller;cache;constructor({callbacks:e,callbackManager:t,...n}){let{cache:r,...i}=n;super({callbacks:e??t,...i}),typeof r=="object"?this.cache=r:r?this.cache=S1.global():this.cache=void 0,this.caller=new tu(n??{})}_encoding;async getNumTokens(e){let t;typeof e=="string"?t=e:t=e.map(r=>typeof r=="string"?r:r.type==="text"&&"text"in r?r.text:"").join("");let n=Math.ceil(t.length/4);if(!this._encoding)try{this._encoding=await ab("modelName"in this?qh(this.modelName):"gpt2")}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}if(this._encoding)try{n=this._encoding.encode(t).length}catch(r){console.warn("Failed to calculate number of tokens, falling back to approximate count",r)}return n}static _convertInputToPromptValue(e){return typeof e=="string"?new ib(e):Array.isArray(e)?new sb(e.map(br)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){let n={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()};return Object.entries(n).filter(([r,i])=>i!==void 0).map(([r,i])=>`${r}:${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{}}_filterInvocationParamsForTracing(e){let{tools:t,functions:n,messages:r,response_format:i,...s}=e;return s}},vc=class extends Ae{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 n=Te(t);return this.func&&await this.func(e,n),this._callWithConfig(r=>Promise.resolve(r),e,n)}async*transform(e,t){let n=Te(t),r,i=!0;for await(let s of this._transformStreamWithConfig(e,a=>a,n))if(yield s,i)if(r===void 0)r=s;else try{r=Ii(r,s)}catch{r=void 0,i=!1}this.func&&r!==void 0&&await this.func(r,n)}static assign(e){return new eb(new to({steps:e}))}},_Z=class extends Ae{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:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.invoke(r,Te(t))}async batch(e,t,n){let r=e.map(l=>l.key),i=e.map(l=>l.input);if(r.find(l=>this.runnables[l]===void 0)!==void 0)throw new Error("One or more keys do not have a corresponding runnable.");let s=r.map(l=>this.runnables[l]),a=this._getOptionsList(t??{},e.length),o=a[0]?.maxConcurrency??n?.maxConcurrency,c=o&&o>0?o:e.length,u=[];for(let l=0;l<i.length;l+=c){let d=i.slice(l,l+c).map((h,m)=>s[m].invoke(h,a[m])),p=await Promise.all(d);u.push(p)}return u.flat()}async stream(e,t){let{key:n,input:r}=e,i=this.runnables[n];if(i===void 0)throw new Error(`No runnable associated with key "${n}".`);return i.stream(r,t)}},vZ=class extends Ae{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(([r,i])=>[Nt(r),Nt(i)]),n=Nt(e[e.length-1]);return new this({branches:t,default:n})}async _invoke(e,t,n){let r;for(let i=0;i<this.branches.length;i+=1){let[s,a]=this.branches[i];if(await s.invoke(e,Re(t,{callbacks:n?.getChild(`condition:${i+1}`)}))){r=await a.invoke(e,Re(t,{callbacks:n?.getChild(`branch:${i+1}`)}));break}}return r||(r=await this.default.invoke(e,Re(t,{callbacks:n?.getChild("branch:default")}))),r}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){let n=await(await on(t))?.handleChainStart(this.toJSON(),vt(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName),r,i=!0,s;try{for(let a=0;a<this.branches.length;a+=1){let[o,c]=this.branches[a];if(await o.invoke(e,Re(t,{callbacks:n?.getChild(`condition:${a+1}`)}))){s=await c.stream(e,Re(t,{callbacks:n?.getChild(`branch:${a+1}`)}));for await(let u of s)if(yield u,i)if(r===void 0)r=u;else try{r=Ii(r,u)}catch{r=void 0,i=!1}break}}if(s===void 0){s=await this.default.stream(e,Re(t,{callbacks:n?.getChild("branch:default")}));for await(let a of s)if(yield a,i)if(r===void 0)r=a;else try{r=Ii(r,a)}catch{r=void 0,i=!1}}}catch(a){throw await n?.handleChainError(a),a}await n?.handleChainEnd(r??{})}},bZ=class extends Ci{runnable;inputMessagesKey;outputMessagesKey;historyMessagesKey;getMessageHistory;constructor(e){let t=ir.from((s,a)=>this._enterHistory(s,a??{})).withConfig({runName:"loadHistory"}),n=e.historyMessagesKey??e.inputMessagesKey;n&&(t=vc.assign({[n]:t}).withConfig({runName:"insertHistory"}));let r=t.pipe(e.runnable.withListeners({onEnd:(s,a)=>this._exitHistory(s,a??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:r}),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)&&!it(e)){let n;this.inputMessagesKey?n=this.inputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="input",Array.isArray(e[n])&&Array.isArray(e[n][0])?t=e[n][0]:t=e[n]}else t=e;if(typeof t=="string")return[new $n(t)];if(Array.isArray(t))return t;if(it(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.
|
|
156
|
+
Got ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(!Array.isArray(e)&&!it(e)&&typeof e!="string"){let n;this.outputMessagesKey!==void 0?n=this.outputMessagesKey:Object.keys(e).length===1?n=Object.keys(e)[0]:n="output",e.generations!==void 0?t=e.generations[0][0].message:t=e[n]}else t=e;if(typeof t=="string")return[new Le(t)];if(Array.isArray(t))return t;if(it(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 n=await(t?.configurable?.messageHistory).getMessages();return this.historyMessagesKey===void 0?n.concat(this._getInputMessages(e)):n}async _exitHistory(e,t){let n=t.configurable?.messageHistory,r;Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?r=e.inputs[0]:r=e.inputs;let i=this._getInputMessages(r);if(this.historyMessagesKey===void 0){let o=await n.getMessages();i=i.slice(o.length)}let s=e.outputs;if(!s)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);let a=this._getOutputMessages(s);await n.addMessages([...i,...a])}async _mergeConfig(...e){let t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){let r={[this.inputMessagesKey??"input"]:"foo"};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()
|
|
157
|
+
eg. chain.invoke(${JSON.stringify(r)}, ${JSON.stringify({configurable:{sessionId:"123"}})})`)}let{sessionId:n}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(n),t}},wZ=G({RouterRunnable:()=>_Z,Runnable:()=>Ae,RunnableAssign:()=>eb,RunnableBinding:()=>Ci,RunnableBranch:()=>vZ,RunnableEach:()=>xF,RunnableLambda:()=>ir,RunnableMap:()=>to,RunnableParallel:()=>SF,RunnablePassthrough:()=>vc,RunnablePick:()=>rE,RunnableRetry:()=>Qv,RunnableSequence:()=>Ni,RunnableToolLike:()=>ly,RunnableWithFallbacks:()=>nE,RunnableWithMessageHistory:()=>bZ,_coerceToRunnable:()=>Nt,ensureConfig:()=>Te,getCallbackManagerForConfig:()=>on,mergeConfigs:()=>Nn,patchConfig:()=>Re,pickRunnableConfigKeys:()=>Kr,raceWithSignal:()=>Sr}),kZ=G({applyPatch:()=>$a,compare:()=>vh}),Hh=class extends Ae{parseResultWithPrompt(e,t,n){return this.parseResult(e,n)}_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(n,r)=>this.parseResult([{text:n}],r?.callbacks),e,{...t,runType:"parser"}):this._callWithConfig(async(n,r)=>this.parseResult([{message:n,text:this._baseMessageToString(n)}],r?.callbacks),e,{...t,runType:"parser"})}},no=class extends Hh{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,n){return this.parse(e,n)}_type(){throw new Error("_type not implemented")}},er=class extends Error{llmOutput;observation;sendToLLM;constructor(e,t,n,r=!1){if(super(e),this.llmOutput=t,this.observation=n,this.sendToLLM=r,r&&(n===void 0||t===void 0))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Vc(this,"OUTPUT_PARSING_FAILURE")}},_u=class extends no{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"})}},vu=class extends _u{diff=!1;constructor(e){super(e),this.diff=e?.diff??this.diff}async*_transform(e){let t,n;for await(let r of e){if(typeof r!="string"&&typeof r.content!="string")throw new Error("Cannot handle non-string output.");let i;if(ms(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Wr({message:r,text:r.content})}else if(it(r)){if(typeof r.content!="string")throw new Error("Cannot handle non-string message output.");i=new Wr({message:md(r),text:r.content})}else i=new Ia({text:r});n===void 0?n=i:n=n.concat(i);let s=await this.parsePartialResult([n]);s!=null&&!ds(s,t)&&(this.diff?yield this._diff(t,s):yield s,t=s)}}getFormatInstructions(){return""}},xZ=class extends _u{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""}},bu=class extends _u{re;async*_transform(e){let t="";for await(let n of e)if(typeof n=="string"?t+=n:t+=n.content,this.re){let r=[...t.matchAll(this.re)];if(r.length>1){let i=0;for(let s of r.slice(0,-1))yield[s[1]],i+=(s.index??0)+s[0].length;t=t.slice(i)}}else{let r=await this.parse(t);if(r.length>1){for(let i of r.slice(0,-1))yield[i];t=r[r.length-1]}}for(let n of await this.parse(t))yield[n]}},$Z=class extends bu{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 er(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},IZ=class extends bu{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(n=>n.trim());if(this.length!==void 0&&t.length!==this.length)throw new er(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){throw Object.getPrototypeOf(t)===er.prototype?t:new er(`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\`)`}},SZ=class extends bu{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:
|
|
158
|
+
|
|
159
|
+
1. foo
|
|
160
|
+
|
|
161
|
+
2. bar
|
|
162
|
+
|
|
163
|
+
3. baz`}re=/\d+\.\s([^\n]+)/g;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},OZ=class extends bu{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:
|
|
164
|
+
|
|
165
|
+
1. foo
|
|
166
|
+
|
|
167
|
+
2. bar
|
|
168
|
+
|
|
169
|
+
3. baz`}re=/^\s*[-*]\s([^\n]+)$/gm;async parse(e){return[...e.matchAll(this.re)??[]].map(t=>t[1])}},AZ=class extends _u{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,n)=>t+this._messageContentToString(n),"")}},ub=class extends vu{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?vh(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return hd(e[0].text)}async parse(e){return hd(e,JSON.parse)}getFormatInstructions(){return""}_baseMessageToString(e){return e.text}},wE=class extends no{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=hd(e,JSON.parse),n=await this.schema["~standard"].validate(t);if(n.issues)throw new Error(`Validation failed: ${JSON.stringify(n.issues)}`);return n.value}catch(t){throw new er(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}getFormatInstructions(){return""}},lb=class extends no{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=tt(Object.fromEntries(Object.entries(e).map(([n,r])=>[n,lt().describe(r)])));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.
|
|
170
|
+
|
|
171
|
+
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
|
|
172
|
+
|
|
173
|
+
For example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
|
|
174
|
+
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.
|
|
175
|
+
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.
|
|
176
|
+
|
|
177
|
+
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!
|
|
178
|
+
|
|
179
|
+
Here is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:
|
|
180
|
+
\`\`\`json
|
|
181
|
+
${JSON.stringify(xt(this.schema))}
|
|
182
|
+
\`\`\`
|
|
183
|
+
`}async parse(e){try{let t=e.trim(),n=(t.match(/^```(?:json)?\s*([\s\S]*?)```/)?.[1]||t.match(/```json\s*([\s\S]*?)```/)?.[1]||t).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,(r,i)=>`"${i.replace(/\n/g,"\\n")}"`).replace(/\n/g,"");return await Lh(this.schema,JSON.parse(n))}catch(t){throw new er(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}_baseMessageToString(e){return e.text}},kE=class extends lb{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:
|
|
184
|
+
\`\`\`json
|
|
185
|
+
${this._schemaToInstruction(xt(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}
|
|
186
|
+
\`\`\``}_schemaToInstruction(e,t=2){let n=e;if("type"in n){let r=!1,i;if(Array.isArray(n.type)){let o=n.type.findIndex(c=>c==="null");o!==-1&&(r=!0,n.type.splice(o,1)),i=n.type.join(" | ")}else i=n.type;if(n.type==="object"&&n.properties){let o=n.description?` // ${n.description}`:"";return`{
|
|
187
|
+
${Object.entries(n.properties).map(([c,u])=>{let l=n.required?.includes(c)?"":" (optional)";return`${" ".repeat(t)}"${c}": ${this._schemaToInstruction(u,t+2)}${l}`}).join(`
|
|
188
|
+
`)}
|
|
189
|
+
${" ".repeat(t-2)}}${o}`}if(n.type==="array"&&n.items){let o=n.description?` // ${n.description}`:"";return`array[
|
|
190
|
+
${" ".repeat(t)}${this._schemaToInstruction(n.items,t+2)}
|
|
191
|
+
${" ".repeat(t-2)}] ${o}`}let s=r?" (nullable)":"",a=n.description?` // ${n.description}`:"";return`${i}${a}${s}`}if("anyOf"in n)return n.anyOf.map(r=>this._schemaToInstruction(r,t)).join(`
|
|
192
|
+
${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){let t=tt(Object.fromEntries(Object.entries(e).map(([n,r])=>[n,lt().describe(r)])));return new this(t)}},TZ=class extends no{structuredInputParser;constructor({inputSchema:e}){super(...arguments),this.structuredInputParser=new kE(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(n){throw new er(`Failed to parse. Text: "${e}". Error: ${n}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}},EZ=function(){let e={};e.parser=function(b,_){return new n(b,_)},e.SAXParser=n,e.SAXStream=u,e.createStream=c,e.MAX_BUFFER_LENGTH=64*1024;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 n(b,_){if(!(this instanceof n))return new n(b,_);var j=this;i(j),j.q=j.c="",j.bufferCheckPosition=e.MAX_BUFFER_LENGTH,j.opt=_||{},j.opt.lowercase=j.opt.lowercase||j.opt.lowercasetags,j.looseCase=j.opt.lowercase?"toLowerCase":"toUpperCase",j.tags=[],j.closed=j.closedRoot=j.sawRoot=!1,j.tag=j.error=null,j.strict=!!b,j.noscript=!!(b||j.opt.noscript),j.state=k.BEGIN,j.strictEntities=j.opt.strictEntities,j.ENTITIES=j.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),j.attribList=[],j.opt.xmlns&&(j.ns=Object.create(m)),j.trackPosition=j.opt.position!==!1,j.trackPosition&&(j.position=j.line=j.column=0),C(j,"onready")}Object.create||(Object.create=function(b){function _(){}return _.prototype=b,new _}),Object.keys||(Object.keys=function(b){var _=[];for(var j in b)b.hasOwnProperty(j)&&_.push(j);return _});function r(b){for(var _=Math.max(e.MAX_BUFFER_LENGTH,10),j=0,I=0,Ie=t.length;I<Ie;I++){var ze=b[t[I]].length;if(ze>_)switch(t[I]){case"textNode":Z(b);break;case"cdata":E(b,"oncdata",b.cdata),b.cdata="";break;case"script":E(b,"onscript",b.script),b.script="";break;default:ae(b,"Max buffer length exceeded: "+t[I])}j=Math.max(j,ze)}b.bufferCheckPosition=e.MAX_BUFFER_LENGTH-j+b.position}function i(b){for(var _=0,j=t.length;_<j;_++)b[t[_]]=""}function s(b){Z(b),b.cdata!==""&&(E(b,"oncdata",b.cdata),b.cdata=""),b.script!==""&&(E(b,"onscript",b.script),b.script="")}n.prototype={end:function(){Ne(this)},write:zn,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var a=ReadableStream;a||(a=function(){});var o=e.EVENTS.filter(function(b){return b!=="error"&&b!=="end"});function c(b,_){return new u(b,_)}function u(b,_){if(!(this instanceof u))return new u(b,_);a.apply(this),this._parser=new n(b,_),this.writable=!0,this.readable=!0;var j=this;this._parser.onend=function(){j.emit("end")},this._parser.onerror=function(I){j.emit("error",I),j._parser.error=null},this._decoder=null,o.forEach(function(I){Object.defineProperty(j,"on"+I,{get:function(){return j._parser["on"+I]},set:function(Ie){if(!Ie)return j.removeAllListeners(I),j._parser["on"+I]=Ie,Ie;j.on(I,Ie)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(a.prototype,{constructor:{value:u}}),u.prototype.write=function(b){return this._parser.write(b.toString()),this.emit("data",b),!0},u.prototype.end=function(b){return b&&b.length&&this.write(b),this._parser.end(),!0},u.prototype.on=function(b,_){var j=this;return!j._parser["on"+b]&&o.indexOf(b)!==-1&&(j._parser["on"+b]=function(){var I=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);I.splice(0,0,b),j.emit.apply(j,I)}),a.prototype.on.call(j,b,_)};var l="[CDATA[",d="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",h="http://www.w3.org/2000/xmlns/",m={xml:p,xmlns:h},f=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,v=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,g=/[#:_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 w(b){return b===" "||b===`
|
|
193
|
+
`||b==="\r"||b===" "}function x(b){return b==='"'||b==="'"}function O(b){return b===">"||w(b)}function z(b,_){return b.test(_)}function T(b,_){return!z(b,_)}var k=0;e.STATE={BEGIN:k++,BEGIN_WHITESPACE:k++,TEXT:k++,TEXT_ENTITY:k++,OPEN_WAKA:k++,SGML_DECL:k++,SGML_DECL_QUOTED:k++,DOCTYPE:k++,DOCTYPE_QUOTED:k++,DOCTYPE_DTD:k++,DOCTYPE_DTD_QUOTED:k++,COMMENT_STARTING:k++,COMMENT:k++,COMMENT_ENDING:k++,COMMENT_ENDED:k++,CDATA:k++,CDATA_ENDING:k++,CDATA_ENDING_2:k++,PROC_INST:k++,PROC_INST_BODY:k++,PROC_INST_ENDING:k++,OPEN_TAG:k++,OPEN_TAG_SLASH:k++,ATTRIB:k++,ATTRIB_NAME:k++,ATTRIB_NAME_SAW_WHITE:k++,ATTRIB_VALUE:k++,ATTRIB_VALUE_QUOTED:k++,ATTRIB_VALUE_CLOSED:k++,ATTRIB_VALUE_UNQUOTED:k++,ATTRIB_VALUE_ENTITY_Q:k++,ATTRIB_VALUE_ENTITY_U:k++,CLOSE_TAG:k++,CLOSE_TAG_SAW_WHITE:k++,SCRIPT:k++,SCRIPT_ENDING:k++},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(b){var _=e.ENTITIES[b],j=typeof _=="number"?String.fromCharCode(_):_;e.ENTITIES[b]=j});for(var B in e.STATE)e.STATE[e.STATE[B]]=B;k=e.STATE;function C(b,_,j){b[_]&&b[_](j)}function E(b,_,j){b.textNode&&Z(b),C(b,_,j)}function Z(b){b.textNode=X(b.opt,b.textNode),b.textNode&&C(b,"ontext",b.textNode),b.textNode=""}function X(b,_){return b.trim&&(_=_.trim()),b.normalize&&(_=_.replace(/\s+/g," ")),_}function ae(b,_){return Z(b),b.trackPosition&&(_+=`
|
|
194
|
+
Line: `+b.line+`
|
|
195
|
+
Column: `+b.column+`
|
|
196
|
+
Char: `+b.c),_=new Error(_),b.error=_,C(b,"onerror",_),b}function Ne(b){return b.sawRoot&&!b.closedRoot&&ve(b,"Unclosed root tag"),b.state!==k.BEGIN&&b.state!==k.BEGIN_WHITESPACE&&b.state!==k.TEXT&&ae(b,"Unexpected end"),Z(b),b.c="",b.closed=!0,C(b,"onend"),n.call(b,b.strict,b.opt),b}function ve(b,_){if(typeof b!="object"||!(b instanceof n))throw new Error("bad call to strictFail");b.strict&&ae(b,_)}function sr(b){b.strict||(b.tagName=b.tagName[b.looseCase]());var _=b.tags[b.tags.length-1]||b,j=b.tag={name:b.tagName,attributes:{}};b.opt.xmlns&&(j.ns=_.ns),b.attribList.length=0,E(b,"onopentagstart",j)}function On(b,_){var j=b.indexOf(":")<0?["",b]:b.split(":"),I=j[0],Ie=j[1];return _&&b==="xmlns"&&(I="xmlns",Ie=""),{prefix:I,local:Ie}}function Zi(b){if(b.strict||(b.attribName=b.attribName[b.looseCase]()),b.attribList.indexOf(b.attribName)!==-1||b.tag.attributes.hasOwnProperty(b.attribName)){b.attribName=b.attribValue="";return}if(b.opt.xmlns){var _=On(b.attribName,!0),j=_.prefix,I=_.local;if(j==="xmlns")if(I==="xml"&&b.attribValue!==p)ve(b,"xml: prefix must be bound to "+p+`
|
|
197
|
+
Actual: `+b.attribValue);else if(I==="xmlns"&&b.attribValue!==h)ve(b,"xmlns: prefix must be bound to "+h+`
|
|
198
|
+
Actual: `+b.attribValue);else{var Ie=b.tag,ze=b.tags[b.tags.length-1]||b;Ie.ns===ze.ns&&(Ie.ns=Object.create(ze.ns)),Ie.ns[I]=b.attribValue}b.attribList.push([b.attribName,b.attribValue])}else b.tag.attributes[b.attribName]=b.attribValue,E(b,"onattribute",{name:b.attribName,value:b.attribValue});b.attribName=b.attribValue=""}function Ln(b,_){if(b.opt.xmlns){var j=b.tag,I=On(b.tagName);j.prefix=I.prefix,j.local=I.local,j.uri=j.ns[I.prefix]||"",j.prefix&&!j.uri&&(ve(b,"Unbound namespace prefix: "+JSON.stringify(b.tagName)),j.uri=I.prefix);var Ie=b.tags[b.tags.length-1]||b;j.ns&&Ie.ns!==j.ns&&Object.keys(j.ns).forEach(function(Bi){E(b,"onopennamespace",{prefix:Bi,uri:j.ns[Bi]})});for(var ze=0,ht=b.attribList.length;ze<ht;ze++){var ot=b.attribList[ze],Ut=ot[0],An=ot[1],ct=On(Ut,!0),ar=ct.prefix,Ms=ct.local,Fu=ar===""?"":j.ns[ar]||"",H={name:Ut,value:An,prefix:ar,local:Ms,uri:Fu};ar&&ar!=="xmlns"&&!Fu&&(ve(b,"Unbound namespace prefix: "+JSON.stringify(ar)),H.uri=ar),b.tag.attributes[Ut]=H,E(b,"onattribute",H)}b.attribList.length=0}b.tag.isSelfClosing=!!_,b.sawRoot=!0,b.tags.push(b.tag),E(b,"onopentag",b.tag),_||(!b.noscript&&b.tagName.toLowerCase()==="script"?b.state=k.SCRIPT:b.state=k.TEXT,b.tag=null,b.tagName=""),b.attribName=b.attribValue="",b.attribList.length=0}function Tr(b){if(!b.tagName){ve(b,"Weird empty close tag."),b.textNode+="</>",b.state=k.TEXT;return}if(b.script){if(b.tagName!=="script"){b.script+="</"+b.tagName+">",b.tagName="",b.state=k.SCRIPT;return}E(b,"onscript",b.script),b.script=""}var _=b.tags.length,j=b.tagName;b.strict||(j=j[b.looseCase]());for(var I=j;_--&&b.tags[_].name!==I;)ve(b,"Unexpected close tag");if(_<0){ve(b,"Unmatched closing tag: "+b.tagName),b.textNode+="</"+b.tagName+">",b.state=k.TEXT;return}b.tagName=j;for(var Ie=b.tags.length;Ie-- >_;){var ze=b.tag=b.tags.pop();b.tagName=b.tag.name,E(b,"onclosetag",b.tagName);var ht={};for(var ot in ze.ns)ht[ot]=ze.ns[ot];var Ut=b.tags[b.tags.length-1]||b;b.opt.xmlns&&ze.ns!==Ut.ns&&Object.keys(ze.ns).forEach(function(An){var ct=ze.ns[An];E(b,"onclosenamespace",{prefix:An,uri:ct})})}_===0&&(b.closedRoot=!0),b.tagName=b.attribValue=b.attribName="",b.attribList.length=0,b.state=k.TEXT}function oo(b){var _=b.entity,j=_.toLowerCase(),I,Ie="";return b.ENTITIES[_]?b.ENTITIES[_]:b.ENTITIES[j]?b.ENTITIES[j]:(_=j,_.charAt(0)==="#"&&(_.charAt(1)==="x"?(_=_.slice(2),I=parseInt(_,16),Ie=I.toString(16)):(_=_.slice(1),I=parseInt(_,10),Ie=I.toString(10))),_=_.replace(/^0+/,""),isNaN(I)||Ie.toLowerCase()!==_?(ve(b,"Invalid character entity"),"&"+b.entity+";"):String.fromCodePoint(I))}function co(b,_){_==="<"?(b.state=k.OPEN_WAKA,b.startTagPosition=b.position):w(_)||(ve(b,"Non-whitespace before first tag."),b.textNode=_,b.state=k.TEXT)}function uo(b,_){var j="";return _<b.length&&(j=b.charAt(_)),j}function zn(b){var _=this;if(this.error)throw this.error;if(_.closed)return ae(_,"Cannot write after close. Assign an onready handler.");if(b===null)return Ne(_);typeof b=="object"&&(b=b.toString());for(var j=0,I="";I=uo(b,j++),_.c=I,!!I;)switch(_.trackPosition&&(_.position++,I===`
|
|
199
|
+
`?(_.line++,_.column=0):_.column++),_.state){case k.BEGIN:if(_.state=k.BEGIN_WHITESPACE,I==="\uFEFF")continue;co(_,I);continue;case k.BEGIN_WHITESPACE:co(_,I);continue;case k.TEXT:if(_.sawRoot&&!_.closedRoot){for(var Ie=j-1;I&&I!=="<"&&I!=="&";)I=uo(b,j++),I&&_.trackPosition&&(_.position++,I===`
|
|
200
|
+
`?(_.line++,_.column=0):_.column++);_.textNode+=b.substring(Ie,j-1)}I==="<"&&!(_.sawRoot&&_.closedRoot&&!_.strict)?(_.state=k.OPEN_WAKA,_.startTagPosition=_.position):(!w(I)&&(!_.sawRoot||_.closedRoot)&&ve(_,"Text data outside of root node."),I==="&"?_.state=k.TEXT_ENTITY:_.textNode+=I);continue;case k.SCRIPT:I==="<"?_.state=k.SCRIPT_ENDING:_.script+=I;continue;case k.SCRIPT_ENDING:I==="/"?_.state=k.CLOSE_TAG:(_.script+="<"+I,_.state=k.SCRIPT);continue;case k.OPEN_WAKA:if(I==="!")_.state=k.SGML_DECL,_.sgmlDecl="";else if(!w(I))if(z(f,I))_.state=k.OPEN_TAG,_.tagName=I;else if(I==="/")_.state=k.CLOSE_TAG,_.tagName="";else if(I==="?")_.state=k.PROC_INST,_.procInstName=_.procInstBody="";else{if(ve(_,"Unencoded <"),_.startTagPosition+1<_.position){var ze=_.position-_.startTagPosition;I=new Array(ze).join(" ")+I}_.textNode+="<"+I,_.state=k.TEXT}continue;case k.SGML_DECL:(_.sgmlDecl+I).toUpperCase()===l?(E(_,"onopencdata"),_.state=k.CDATA,_.sgmlDecl="",_.cdata=""):_.sgmlDecl+I==="--"?(_.state=k.COMMENT,_.comment="",_.sgmlDecl=""):(_.sgmlDecl+I).toUpperCase()===d?(_.state=k.DOCTYPE,(_.doctype||_.sawRoot)&&ve(_,"Inappropriately located doctype declaration"),_.doctype="",_.sgmlDecl=""):I===">"?(E(_,"onsgmldeclaration",_.sgmlDecl),_.sgmlDecl="",_.state=k.TEXT):(x(I)&&(_.state=k.SGML_DECL_QUOTED),_.sgmlDecl+=I);continue;case k.SGML_DECL_QUOTED:I===_.q&&(_.state=k.SGML_DECL,_.q=""),_.sgmlDecl+=I;continue;case k.DOCTYPE:I===">"?(_.state=k.TEXT,E(_,"ondoctype",_.doctype),_.doctype=!0):(_.doctype+=I,I==="["?_.state=k.DOCTYPE_DTD:x(I)&&(_.state=k.DOCTYPE_QUOTED,_.q=I));continue;case k.DOCTYPE_QUOTED:_.doctype+=I,I===_.q&&(_.q="",_.state=k.DOCTYPE);continue;case k.DOCTYPE_DTD:_.doctype+=I,I==="]"?_.state=k.DOCTYPE:x(I)&&(_.state=k.DOCTYPE_DTD_QUOTED,_.q=I);continue;case k.DOCTYPE_DTD_QUOTED:_.doctype+=I,I===_.q&&(_.state=k.DOCTYPE_DTD,_.q="");continue;case k.COMMENT:I==="-"?_.state=k.COMMENT_ENDING:_.comment+=I;continue;case k.COMMENT_ENDING:I==="-"?(_.state=k.COMMENT_ENDED,_.comment=X(_.opt,_.comment),_.comment&&E(_,"oncomment",_.comment),_.comment=""):(_.comment+="-"+I,_.state=k.COMMENT);continue;case k.COMMENT_ENDED:I!==">"?(ve(_,"Malformed comment"),_.comment+="--"+I,_.state=k.COMMENT):_.state=k.TEXT;continue;case k.CDATA:I==="]"?_.state=k.CDATA_ENDING:_.cdata+=I;continue;case k.CDATA_ENDING:I==="]"?_.state=k.CDATA_ENDING_2:(_.cdata+="]"+I,_.state=k.CDATA);continue;case k.CDATA_ENDING_2:I===">"?(_.cdata&&E(_,"oncdata",_.cdata),E(_,"onclosecdata"),_.cdata="",_.state=k.TEXT):I==="]"?_.cdata+="]":(_.cdata+="]]"+I,_.state=k.CDATA);continue;case k.PROC_INST:I==="?"?_.state=k.PROC_INST_ENDING:w(I)?_.state=k.PROC_INST_BODY:_.procInstName+=I;continue;case k.PROC_INST_BODY:if(!_.procInstBody&&w(I))continue;I==="?"?_.state=k.PROC_INST_ENDING:_.procInstBody+=I;continue;case k.PROC_INST_ENDING:I===">"?(E(_,"onprocessinginstruction",{name:_.procInstName,body:_.procInstBody}),_.procInstName=_.procInstBody="",_.state=k.TEXT):(_.procInstBody+="?"+I,_.state=k.PROC_INST_BODY);continue;case k.OPEN_TAG:z(v,I)?_.tagName+=I:(sr(_),I===">"?Ln(_):I==="/"?_.state=k.OPEN_TAG_SLASH:(w(I)||ve(_,"Invalid character in tag name"),_.state=k.ATTRIB));continue;case k.OPEN_TAG_SLASH:I===">"?(Ln(_,!0),Tr(_)):(ve(_,"Forward-slash in opening tag not followed by >"),_.state=k.ATTRIB);continue;case k.ATTRIB:if(w(I))continue;I===">"?Ln(_):I==="/"?_.state=k.OPEN_TAG_SLASH:z(f,I)?(_.attribName=I,_.attribValue="",_.state=k.ATTRIB_NAME):ve(_,"Invalid attribute name");continue;case k.ATTRIB_NAME:I==="="?_.state=k.ATTRIB_VALUE:I===">"?(ve(_,"Attribute without value"),_.attribValue=_.attribName,Zi(_),Ln(_)):w(I)?_.state=k.ATTRIB_NAME_SAW_WHITE:z(v,I)?_.attribName+=I:ve(_,"Invalid attribute name");continue;case k.ATTRIB_NAME_SAW_WHITE:if(I==="=")_.state=k.ATTRIB_VALUE;else{if(w(I))continue;ve(_,"Attribute without value"),_.tag.attributes[_.attribName]="",_.attribValue="",E(_,"onattribute",{name:_.attribName,value:""}),_.attribName="",I===">"?Ln(_):z(f,I)?(_.attribName=I,_.state=k.ATTRIB_NAME):(ve(_,"Invalid attribute name"),_.state=k.ATTRIB)}continue;case k.ATTRIB_VALUE:if(w(I))continue;x(I)?(_.q=I,_.state=k.ATTRIB_VALUE_QUOTED):(ve(_,"Unquoted attribute value"),_.state=k.ATTRIB_VALUE_UNQUOTED,_.attribValue=I);continue;case k.ATTRIB_VALUE_QUOTED:if(I!==_.q){I==="&"?_.state=k.ATTRIB_VALUE_ENTITY_Q:_.attribValue+=I;continue}Zi(_),_.q="",_.state=k.ATTRIB_VALUE_CLOSED;continue;case k.ATTRIB_VALUE_CLOSED:w(I)?_.state=k.ATTRIB:I===">"?Ln(_):I==="/"?_.state=k.OPEN_TAG_SLASH:z(f,I)?(ve(_,"No whitespace between attributes"),_.attribName=I,_.attribValue="",_.state=k.ATTRIB_NAME):ve(_,"Invalid attribute name");continue;case k.ATTRIB_VALUE_UNQUOTED:if(!O(I)){I==="&"?_.state=k.ATTRIB_VALUE_ENTITY_U:_.attribValue+=I;continue}Zi(_),I===">"?Ln(_):_.state=k.ATTRIB;continue;case k.CLOSE_TAG:if(_.tagName)I===">"?Tr(_):z(v,I)?_.tagName+=I:_.script?(_.script+="</"+_.tagName,_.tagName="",_.state=k.SCRIPT):(w(I)||ve(_,"Invalid tagname in closing tag"),_.state=k.CLOSE_TAG_SAW_WHITE);else{if(w(I))continue;T(f,I)?_.script?(_.script+="</"+I,_.state=k.SCRIPT):ve(_,"Invalid tagname in closing tag."):_.tagName=I}continue;case k.CLOSE_TAG_SAW_WHITE:if(w(I))continue;I===">"?Tr(_):ve(_,"Invalid characters in closing tag");continue;case k.TEXT_ENTITY:case k.ATTRIB_VALUE_ENTITY_Q:case k.ATTRIB_VALUE_ENTITY_U:var ht,ot;switch(_.state){case k.TEXT_ENTITY:ht=k.TEXT,ot="textNode";break;case k.ATTRIB_VALUE_ENTITY_Q:ht=k.ATTRIB_VALUE_QUOTED,ot="attribValue";break;case k.ATTRIB_VALUE_ENTITY_U:ht=k.ATTRIB_VALUE_UNQUOTED,ot="attribValue";break}if(I===";")if(_.opt.unparsedEntities){var Ut=oo(_);_.entity="",_.state=ht,_.write(Ut)}else _[ot]+=oo(_),_.entity="",_.state=ht;else z(_.entity.length?y:g,I)?_.entity+=I:(ve(_,"Invalid character in entity name"),_[ot]+="&"+_.entity+I,_.entity="",_.state=ht);continue;default:throw new Error(_,"Unknown state: "+_.state)}return _.position>=_.bufferCheckPosition&&r(_),_}return String.fromCodePoint||(function(){var b=String.fromCharCode,_=Math.floor,j=function(){var I=16384,Ie=[],ze,ht,ot=-1,Ut=arguments.length;if(!Ut)return"";for(var An="";++ot<Ut;){var ct=Number(arguments[ot]);if(!isFinite(ct)||ct<0||ct>1114111||_(ct)!==ct)throw RangeError("Invalid code point: "+ct);ct<=65535?Ie.push(ct):(ct-=65536,ze=(ct>>10)+55296,ht=ct%1024+56320,Ie.push(ze,ht)),(ot+1===Ut||Ie.length>I)&&(An+=b.apply(null,Ie),Ie.length=0)}return An};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:j,configurable:!0,writable:!0}):String.fromCodePoint=j})(),e},CZ=EZ(),hy=`The output should be formatted as a XML file.
|
|
201
|
+
1. Output should conform to the tags below.
|
|
202
|
+
2. If tags are not given, make them on your own.
|
|
203
|
+
3. Remember to always open and close all the tags.
|
|
204
|
+
|
|
205
|
+
As an example, for the tags ["foo", "bar", "baz"]:
|
|
206
|
+
1. String "<foo>
|
|
207
|
+
<bar>
|
|
208
|
+
<baz></baz>
|
|
209
|
+
</bar>
|
|
210
|
+
</foo>" is a well-formatted instance of the schema.
|
|
211
|
+
2. String "<foo>
|
|
212
|
+
<bar>
|
|
213
|
+
</foo>" is a badly-formatted instance.
|
|
214
|
+
3. String "<foo>
|
|
215
|
+
<tag>
|
|
216
|
+
</tag>
|
|
217
|
+
</foo>" is a badly-formatted instance.
|
|
218
|
+
|
|
219
|
+
Here are the output tags:
|
|
220
|
+
\`\`\`
|
|
221
|
+
{tags}
|
|
222
|
+
\`\`\``,NZ=class extends vu{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?vh(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return my(e[0].text)}async parse(e){return my(e)}getFormatInstructions(){return this.tags&&this.tags.length>0?hy.replace("{tags}",this.tags?.join(", ")??""):hy}},PZ=e=>e.split(`
|
|
223
|
+
`).map(t=>t.replace(/^\s+/,"")).join(`
|
|
224
|
+
`).trim(),xE=e=>{if(Object.keys(e).length===0)return{};let t={};return e.children.length>0?(t[e.name]=e.children.map(xE),t):(t[e.name]=e.text??void 0,t)};function my(e){let t=PZ(e),n=CZ.parser(!0),r={},i=[];n.onopentag=o=>{let c={name:o.name,attributes:o.attributes,children:[],text:"",isSelfClosing:o.isSelfClosing};i.length>0?i[i.length-1].children.push(c):r=c,o.isSelfClosing||i.push(c)},n.onclosetag=()=>{if(i.length>0){let o=i.pop();i.length===0&&o&&(r=o)}},n.ontext=o=>{if(i.length>0){let c=i[i.length-1];c.text+=o}},n.onattribute=o=>{if(i.length>0){let c=i[i.length-1];c.attributes[o.name]=o.value}};let s=/```(xml)?(.*)```/s.exec(t),a=s?s[2]:t;return n.write(a).close(),r&&r.name==="?xml"&&(r=r.children[0]),xE(r)}var jZ=G({AsymmetricStructuredOutputParser:()=>TZ,BaseCumulativeTransformOutputParser:()=>vu,BaseLLMOutputParser:()=>Hh,BaseOutputParser:()=>no,BaseTransformOutputParser:()=>_u,BytesOutputParser:()=>xZ,CommaSeparatedListOutputParser:()=>$Z,CustomListOutputParser:()=>IZ,JsonMarkdownStructuredOutputParser:()=>kE,JsonOutputParser:()=>ub,ListOutputParser:()=>bu,MarkdownListOutputParser:()=>OZ,NumberedListOutputParser:()=>SZ,OutputParserException:()=>er,StandardSchemaOutputParser:()=>wE,StringOutputParser:()=>AZ,StructuredOutputParser:()=>lb,XMLOutputParser:()=>NZ,XML_FORMAT_INSTRUCTIONS:()=>hy,parseJsonMarkdown:()=>hd,parsePartialJson:()=>ba,parseXMLMarkdown:()=>my}),RZ=G({extendInteropZodObject:()=>ET,getInteropZodDefaultGetter:()=>Fh,getInteropZodObjectShape:()=>hc,getSchemaDescription:()=>ja,interopParse:()=>Bl,interopParseAsync:()=>Lh,interopSafeParse:()=>_9,interopSafeParseAsync:()=>OT,interopZodObjectMakeFieldsOptional:()=>k9,interopZodObjectPartial:()=>Gv,interopZodObjectPassthrough:()=>Zg,interopZodObjectStrict:()=>Od,interopZodTransformInputSchema:()=>CT,isInteropZodError:()=>NT,isInteropZodLiteral:()=>y9,isInteropZodObject:()=>En,isInteropZodSchema:()=>_n,isShapelessZodSchema:()=>v9,isSimpleStringZodSchema:()=>Wv,isZodArrayV4:()=>Dh,isZodLiteralV3:()=>IT,isZodLiteralV4:()=>ST,isZodNullableV4:()=>TT,isZodObjectV3:()=>zh,isZodObjectV4:()=>wr,isZodOptionalV4:()=>AT,isZodSchema:()=>g9,isZodSchemaV3:()=>pt,isZodSchemaV4:()=>We});function Vh(e,t){if(e.function===void 0)return;let n;if(t?.partial)try{n=ba(e.function.arguments??"{}")}catch{return}else try{n=JSON.parse(e.function.arguments)}catch(i){throw new er([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${i.message}`].join(`
|
|
225
|
+
`))}let r={name:e.function.name,args:n,type:"tool_call"};return t?.returnId&&(r.id=e.id),r}function $E(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 Vo(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}var IE=class extends vu{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 n=e[0].message,r;if(yh(n)&&n.tool_calls?.length?r=n.tool_calls.map(s=>{let{id:a,...o}=s;return this.returnId?{id:a,...o}:o}):n.additional_kwargs.tool_calls!==void 0&&(r=JSON.parse(JSON.stringify(n.additional_kwargs.tool_calls)).map(s=>Vh(s,{returnId:this.returnId,partial:t}))),!r)return[];let i=[];for(let s of r)if(s!==void 0){let a={type:s.name,args:s.args,id:s.id};i.push(a)}return i}},SE=class extends IE{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 n=await this.serializableSchema["~standard"].validate(e);if(n.issues)throw new er(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(n.issues)}`,JSON.stringify(e,null,2));return n.value}if(this.zodSchema===void 0)return e;let t=await OT(this.zodSchema,e);if(t.success)return t.data;throw new er(`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(r=>r.type===this.keyName),n=t;if(t.length)return this.returnId||(n=t.map(r=>r.args)),this.returnSingle?n[0]:n}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(r=>r.type===this.keyName),n=t;if(t.length)return this.returnId||(n=t.map(r=>r.args)),this.returnSingle?this._validateResult(n[0]):await Promise.all(n.map(r=>this._validateResult(r)))}},MZ=G({assembleStructuredOutputPipeline:()=>db,createContentParser:()=>fy,createFunctionCallingParser:()=>OE});function fy(e){return _n(e)?lb.fromZodSchema(e):gs(e)?wE.fromSerializableSchema(e):new ub}function OE(e,t,n){let r=n??SE;return _n(e)?new r({returnSingle:!0,keyName:t,zodSchema:e}):gs(e)?new r({returnSingle:!0,keyName:t,serializableSchema:e}):new r({returnSingle:!0,keyName:t})}function db(e,t,n,r){if(!n){let c=e.pipe(t);return r?c.withConfig({runName:r}):c}let i=vc.assign({parsed:(c,u)=>t.invoke(c.raw,u)}),s=vc.assign({parsed:()=>null}),a=i.withFallbacks({fallbacks:[s]}),o=Ni.from([{raw:e},a]);return r?o.withConfig({runName:r}):o}var UZ=G({ChatModelStream:()=>Rd,ReasoningContentStream:()=>EE,TextContentStream:()=>AE,ToolCallsStream:()=>TE,UsageMetadataStream:()=>CE}),LZ=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let n of t)n()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let n of t)n()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function zZ(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function bc(e){if(e.event!=="content-block-delta")return;if("delta"in e&&e.delta)return e.delta;let t=e.content;if(t==null||typeof t!="object")return;let n=t;if(n.type==="text"&&typeof n.text=="string")return{type:"text-delta",text:n.text};if(n.type==="reasoning"&&typeof n.reasoning=="string")return{type:"reasoning-delta",reasoning:n.reasoning};if(n.type==="thinking"&&typeof n.thinking=="string")return{type:"reasoning-delta",reasoning:n.thinking};if(typeof n.data=="string")return{type:"data-delta",data:n.data,encoding:"base64"};if(typeof n.type=="string")return{type:"block-delta",fields:{...n,type:n.type}}}function Mx(e){if(e==null||typeof e!="object")return;let t=e;if(t.type==="reasoning"&&typeof t.reasoning=="string")return t.reasoning;if(t.type==="thinking"&&typeof t.thinking=="string")return t.thinking}function ml(e){if(e==null||typeof e!="object")return!1;let t=e.type;return t==="reasoning"||t==="thinking"}function fa(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function DZ(e){if(e!=null&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function FZ(e){let t=e;if(e.type==="tool_call"||e.type!=="tool_call_chunk"&&e.type!=="tool_use"&&e.type!=="input_json_delta")return e;let n=typeof t.name=="string"?t.name:void 0;if(n==null)return e;let r=t.args??t.input;return{...t,type:"tool_call",name:n,args:DZ(r)}}var AE=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="";for await(let n of e.iterate()){let r=bc(n);r?.type==="text-delta"&&(t+=r.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let n of e.iterate()){let r=bc(n);r?.type==="text-delta"&&(yield r.text)}}return t()}then(e,t){return(async()=>{let n="";for await(let r of this)n+=r;return n})().then(e,t)}},TE=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let n of e.iterate())n.event==="content-block-finish"&&n.content.type==="tool_call"&&(t.push(n.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let n of e.iterate())n.event==="content-block-finish"&&n.content.type==="tool_call"&&(yield n.content)}return t()}then(e,t){return(async()=>{let n=[];for await(let r of this)n.push(r);return n})().then(e,t)}},EE=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t="",n=!1;for await(let r of e.iterate())if(r.event==="content-block-start"){if(!ml(r.content)){if(n)return;continue}n=!0;let i=Mx(r.content);if(i==null||i.length===0)continue;t+=i,yield t}else if(r.event==="content-block-delta"){let i=bc(r);if(i?.type!=="reasoning-delta")continue;n=!0;let s=i.reasoning;if(s==null||s.length===0)continue;t+=s,yield t}else if(r.event==="content-block-finish"&&ml(r.content)||r.event==="message-finish")return}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let n=!1;for await(let r of e.iterate())if(r.event==="content-block-start"){if(!ml(r.content)){if(n)return;continue}n=!0;let i=Mx(r.content);i!=null&&i.length>0&&(yield i)}else if(r.event==="content-block-delta"){let i=bc(r);if(i?.type!=="reasoning-delta")continue;n=!0;let s=i.reasoning;s!=null&&s.length>0&&(yield s)}else if(r.event==="content-block-finish"&&ml(r.content)||r.event==="message-finish")return}return t()}then(e,t){return(async()=>{let n="";for await(let r of this)n+=r;return n})().then(e,t)}},CE=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let n of e.iterate())if(n.event==="usage"){let r=fa(n.usage);r&&(yield r)}else if(n.event==="message-start"&&n.usage){let r=fa(n.usage);r&&(yield r)}else if(n.event==="message-finish"&&n.usage){let r=fa(n.usage);r&&(yield r)}}return t()}then(e,t){return(async()=>{let n;for await(let r of this)n=r;return n})().then(e,t)}},Rd=class{_buffer;constructor(e){this._buffer=new LZ,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(t){this._buffer.setError(t instanceof Error?t:new Error(String(t)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new AE(this._buffer)}get toolCalls(){return new TE(this._buffer)}get reasoning(){return new EE(this._buffer)}get usage(){return new CE(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,n,r={},i;for await(let a of this._buffer.iterate())switch(a.event){case"message-start":t=a.id??t,a.usage&&(n=fa(a.usage));break;case"content-block-start":e[a.index]=a.content;break;case"content-block-delta":{let o=e[a.index],c=bc(a);o&&c&&(e[a.index]=zZ(o,c));break}case"content-block-finish":e[a.index]=a.content;break;case"usage":n=fa(a.usage);break;case"message-finish":i=a.reason,a.usage&&(n=fa(a.usage)),a.responseMetadata&&(r={...r,...a.responseMetadata});break}let s=e.filter(a=>a!=null).map(FZ);return new Le({id:t,content:s,usage_metadata:n,response_metadata:{...r,...i?{finish_reason:i}:{},output_version:"v1"}})}},ZZ=G({convertChunksToEvents:()=>PE,finalizeContentBlock:()=>jE}),BZ={wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",opus:"audio/opus",aac:"audio/aac",pcm16:"audio/pcm"},qZ={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif"};function Ux(e){let t=0;for(let n of e.keys())n>=t&&(t=n+1);return t}function NE(e){let t=e.additional_kwargs;return t!=null&&typeof t=="object"?t:{}}function JZ(e){let t=NE(e).tool_outputs;if(!Array.isArray(t))return[];let n=[];for(let r of t){if(r==null||typeof r!="object")continue;let i=r;if(i.type!=="image_generation_call")continue;let s=typeof i.result=="string"?i.result:void 0,a=typeof i.url=="string"?i.url:void 0;if(s==null&&a==null)continue;let o=typeof i.output_format=="string"?i.output_format.toLowerCase():void 0,c=(o!=null?qZ[o]:void 0)??"image/png";n.push({type:"image",...typeof i.id=="string"?{id:i.id}:{},...a!=null?{url:a}:{},...s!=null?{data:s}:{},mimeType:c})}return n}function HZ(e){let t=NE(e).audio;if(t==null||typeof t!="object")return;let n=t,r=typeof n.data=="string"?n.data:void 0,i=typeof n.url=="string"?n.url:void 0,s=typeof n.transcript=="string"?n.transcript:void 0;if(r==null&&i==null&&s==null)return;let a=typeof n.mime_type=="string"?n.mime_type:typeof n.mimeType=="string"?n.mimeType:void 0,o=typeof n.format=="string"?n.format.toLowerCase():void 0,c=a??(o!=null?BZ[o]:void 0)??(r!=null?"audio/wav":"audio/pcm");return{...typeof n.id=="string"?{id:n.id}:{},...r!=null?{data:r}:{},...i!=null?{url:i}:{},...s!=null?{transcript:s}:{},mimeType:c}}async function*PE(e,t){let n=new Map,r=!1,i,s,a=new Set;for await(let o of e){t?.signal?.throwIfAborted();let c=o.message,u=!1;if(!r){r=!0;let p={event:"message-start",id:c.id??void 0};Pt.isInstance(c)&&c.usage_metadata&&(p.usage=c.usage_metadata,i={...c.usage_metadata},u=!0),yield p}let l=c.content;if(typeof l=="string"){if(l!==""){if(!n.has(0)){let h={type:"text",text:""};n.set(0,{type:"text",accumulated:h}),yield{event:"content-block-start",index:0,content:h}}let p=n.get(0);p.accumulated={...p.accumulated,text:(p.accumulated.text??"")+l},yield{event:"content-block-delta",index:0,delta:{type:"text-delta",text:l}}}}else if(Array.isArray(l))for(let p of l){let h=typeof p.index=="number"?p.index:n.size;if(!n.has(h))n.set(h,{type:p.type,accumulated:{...p}}),yield{event:"content-block-start",index:h,content:{...p}};else{let m=n.get(h),f=KZ(p);m.accumulated=VZ(m.accumulated,f),yield{event:"content-block-delta",index:h,delta:f}}}if(Pt.isInstance(c)&&c.tool_call_chunks&&c.tool_call_chunks.length>0)for(let p of c.tool_call_chunks){let h=typeof p.index=="number"?p.index:n.size;if(!n.has(h)){let f={type:"tool_call_chunk",id:p.id,name:p.name,args:"",index:h};n.set(h,{type:"tool_call_chunk",accumulated:f}),yield{event:"content-block-start",index:h,content:f}}let m=n.get(h).accumulated;p.id!=null&&(m.id=p.id),p.name!=null&&(m.name=p.name),m.args=(m.args??"")+(p.args??""),yield{event:"content-block-delta",index:h,delta:{type:"block-delta",fields:{type:"tool_call_chunk",..."id"in m&&m.id!=null?{id:m.id}:{},..."name"in m&&m.name!=null?{name:m.name}:{},args:m.args}}}}let d=HZ(c);if(d!=null){if(s==null){let h=Ux(n);s={index:h,id:d.id,mimeType:d.mimeType,transcript:""};let m={type:"audio",...d.id!=null?{id:d.id}:{},...d.url!=null?{url:d.url}:{},data:"",mimeType:d.mimeType};n.set(h,{type:"audio",accumulated:m}),yield{event:"content-block-start",index:h,content:m}}let p=n.get(s.index);if(p!=null){let h=p.accumulated;d.id!=null&&s.id==null&&(s.id=d.id,h.id=d.id),d.transcript!=null&&(s.transcript+=d.transcript,h.transcript=s.transcript,yield{event:"content-block-delta",index:s.index,delta:{type:"block-delta",fields:{type:"audio",transcript:s.transcript}}}),d.data!=null&&d.data.length>0&&(h.data=(h.data??"")+d.data,yield{event:"content-block-delta",index:s.index,delta:{type:"data-delta",data:d.data,encoding:"base64"}})}}for(let p of JZ(c)){let h=p,m=h.id??h.url??(h.data!=null?`${h.data.length}:${h.data.slice(0,32)}`:void 0);if(m!=null&&a.has(m))continue;m!=null&&a.add(m);let f=Ux(n);n.set(f,{type:"image",accumulated:p}),yield{event:"content-block-start",index:f,content:p}}if(!u&&Pt.isInstance(c)&&c.usage_metadata){let p=c.usage_metadata;i?i={input_tokens:i.input_tokens+p.input_tokens,output_tokens:i.output_tokens+p.output_tokens,total_tokens:i.total_tokens+p.total_tokens}:i={...p},yield{event:"usage",usage:{...i}}}}for(let[o,c]of n)yield{event:"content-block-finish",index:o,content:jE(c.accumulated)};yield{event:"message-finish",reason:"stop",...i?{usage:i}:{}}}function VZ(e,t){switch(t.type){case"text-delta":return e.type==="text"?{...e,text:(e.text??"")+t.text}:e;case"reasoning-delta":return e.type==="thinking"?{...e,thinking:(e.thinking??"")+t.reasoning}:e.type==="reasoning"?{...e,reasoning:(e.reasoning??"")+t.reasoning}:e;case"data-delta":return{...e,data:(e.data??"")+t.data};case"block-delta":return{...e,...t.fields};default:throw new Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function KZ(e){if(e.type==="text")return{type:"text-delta",text:e.text};if(e.type==="reasoning")return{type:"reasoning-delta",reasoning:e.reasoning};if(e.type==="thinking"&&typeof e.thinking=="string")return{type:"reasoning-delta",reasoning:e.thinking};if(typeof e.data=="string")return{type:"data-delta",data:e.data,encoding:"base64"};if(typeof e.type=="string")return{type:"block-delta",fields:{...e}};throw new Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function jE(e){if(e.type==="tool_call_chunk"){let t=e,n;try{n=JSON.parse(t.args??"{}")}catch{return{type:"invalid_tool_call",id:t.id,name:t.name,args:t.args,error:"Failed to parse tool call arguments as JSON"}}return{type:"tool_call",id:t.id,name:t.name,args:n}}return e}var WZ=e=>e();function wf(e){let t=e.constructor;return new t({...e,content:e.contentBlocks,response_metadata:{...e.response_metadata,output_version:"v1"}})}var GZ=G({BaseChatModel:()=>Ns,SimpleChatModel:()=>XZ});function kf(e){let t=[];for(let n of e){let r=n;if(Array.isArray(n.content))for(let i=0;i<n.content.length;i++){let s=n.content[i];(b_(s)||w_(s))&&r===n&&(r=new n.constructor({...r,content:[...n.content.slice(0,i),c1(s),...n.content.slice(i+1)]}))}t.push(r)}return t}var Ns=class lr extends Jh{lc_namespace=["langchain","chat_models",this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,"outputVersion"]}constructor(t){super(t),this.outputVersion=WZ(()=>{let n=t.outputVersion??bn("LC_OUTPUT_VERSION");return n&&["v0","v1"].includes(n)?n:"v0"})}_separateRunnableConfigFromCallOptionsCompat(t){let[n,r]=super._separateRunnableConfigFromCallOptions(t);return r.signal=n.signal,[n,r]}async invoke(t,n){let r=lr._convertInputToPromptValue(t);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(t,n,r){throw new Error("Not implemented.")}async*_streamChatModelEvents(t,n,r){yield*PE(this._streamResponseChunks(t,n,r),{signal:n.signal})}streamV2(t,n){let r=lr._convertInputToPromptValue(t).toChatMessages(),[,i]=this._separateRunnableConfigFromCallOptionsCompat(n);return new Rd(this._streamChatModelEvents(r,i))}async*_streamIterator(t,n){if(this._streamResponseChunks===lr.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,n);else{let r=lr._convertInputToPromptValue(t).toChatMessages(),[i,s]=this._separateRunnableConfigFromCallOptionsCompat(n),a={...i.metadata,...this.getLsParamsWithDefaults(s)},o=this.invocationParams(s),c=await Ft.configure(i.callbacks,this.callbacks,i.tags,this.tags,a,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(o)}),u={options:s,invocation_params:o,batch_size:1},l=s.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[kf(r)],i.runId,void 0,u,void 0,void 0,i.runName),p,h;try{for await(let m of this._streamResponseChunks(r,s,d?.[0])){if(s.signal?.throwIfAborted(),m.message.id==null){let f=d?.at(0)?.runId;f!=null&&m.message._updateId(`run-${f}`)}m.message.response_metadata={...m.generationInfo,...m.message.response_metadata},l==="v1"?yield wf(m.message):yield m.message,p?p=p.concat(m):p=m,sg(m.message)&&m.message.usage_metadata!==void 0&&(h={tokenUsage:{promptTokens:m.message.usage_metadata.input_tokens,completionTokens:m.message.usage_metadata.output_tokens,totalTokens:m.message.usage_metadata.total_tokens}})}s.signal?.throwIfAborted()}catch(m){throw await Promise.all((d??[]).map(f=>f?.handleLLMError(m))),m}await Promise.all((d??[]).map(m=>m?.handleLLMEnd({generations:[[p]],llmOutput:h})))}}getLsParams(t){let n=this.getName().startsWith("Chat")?this.getName().replace("Chat",""):this.getName();return{ls_model_type:"chat",ls_stop:t.stop,ls_provider:n}}getLsParamsWithDefaults(t){return{...this.getLsParams(t),ls_integration:"langchain_chat_model"}}async _generateUncached(t,n,r,i){let s=t.map(h=>h.map(br)),a;if(i!==void 0&&i.length===s.length)a=i;else{let h={...r.metadata,...this.getLsParamsWithDefaults(n)},m=this.invocationParams(n),f=await Ft.configure(r.callbacks,this.callbacks,r.tags,this.tags,h,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(m)}),v={options:n,invocation_params:m,batch_size:1};a=await f?.handleChatModelStart(this.toJSON(),s.map(kf),r.runId,void 0,v,void 0,void 0,r.runName)}let o=n.outputVersion??this.outputVersion,c=[],u=[],l=!!a?.[0].handlers.find(T1),d=!!a?.[0].handlers.find(C_);if(l&&!this.disableStreaming&&s.length===1&&(this._streamChatModelEvents!==lr.prototype._streamChatModelEvents||this._streamResponseChunks!==lr.prototype._streamResponseChunks))try{let h=!1,m=a?.[0],f=this._streamChatModelEvents(s[0],n),v=await new Rd({async*[Symbol.asyncIterator](){for await(let w of f){n.signal?.throwIfAborted(),h=!0;let x=w.event==="message-start"&&w.id==null&&m?.runId!=null?{...w,id:`run-${m.runId}`}:w;await m?.handleChatModelStreamEvent(x),yield x}}});if(n.signal?.throwIfAborted(),!h)throw new Error("Received empty response from chat model call.");if(v.id==null){let w=a?.at(0)?.runId;w!=null&&v._updateId(`run-${w}`)}let g={text:v.text,message:v};c.push([g]);let y=v.usage_metadata!==void 0?{tokenUsage:{promptTokens:v.usage_metadata.input_tokens,completionTokens:v.usage_metadata.output_tokens,totalTokens:v.usage_metadata.total_tokens}}:void 0;await a?.[0].handleLLMEnd({generations:c,llmOutput:y})}catch(h){throw await a?.[0].handleLLMError(h),h}else if(d&&!this.disableStreaming&&s.length===1&&this._streamResponseChunks!==lr.prototype._streamResponseChunks)try{let h=await this._streamResponseChunks(s[0],n,a?.[0]),m,f;for await(let v of h){if(n.signal?.aborted){let g=m?.message;throw new rg("Model invocation was aborted.",g)}if(v.message.id==null){let g=a?.at(0)?.runId;g!=null&&v.message._updateId(`run-${g}`)}m===void 0?m=v:m=Ii(m,v),sg(v.message)&&v.message.usage_metadata!==void 0&&(f={tokenUsage:{promptTokens:v.message.usage_metadata.input_tokens,completionTokens:v.message.usage_metadata.output_tokens,totalTokens:v.message.usage_metadata.total_tokens}})}if(n.signal?.aborted){let v=m?.message;throw new rg("Model invocation was aborted.",v)}if(m===void 0)throw new Error("Received empty response from chat model call.");c.push([m]),await a?.[0].handleLLMEnd({generations:c,llmOutput:f})}catch(h){throw await a?.[0].handleLLMError(h),h}else{let h=await Promise.allSettled(s.map(async(m,f)=>{let v=await this._generate(m,{...n,promptIndex:f},a?.[f]);if(o==="v1")for(let g of v.generations)g.message=wf(g.message);return v}));await Promise.all(h.map(async(m,f)=>{if(m.status==="fulfilled"){let v=m.value;for(let g of v.generations){if(g.message.id==null){let y=a?.at(0)?.runId;y!=null&&g.message._updateId(`run-${y}`)}g.message.response_metadata={...g.generationInfo,...g.message.response_metadata}}return v.generations.length===1&&(v.generations[0].message.response_metadata={...v.llmOutput,...v.generations[0].message.response_metadata}),c[f]=v.generations,u[f]=v.llmOutput,a?.[f]?.handleLLMEnd({generations:[v.generations],llmOutput:v.llmOutput})}else return await a?.[f]?.handleLLMError(m.reason),Promise.reject(m.reason)}))}let p={generations:c,llmOutput:u.length?this._combineLLMOutput?.(...u):void 0};return Object.defineProperty(p,oc,{value:a?{runIds:a?.map(h=>h.runId)}:void 0,configurable:!0}),p}async _generateCached({messages:t,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:s}){let a=t.map(g=>g.map(br)),o={...s.metadata,...this.getLsParamsWithDefaults(i)},c=this.invocationParams(i),u=await Ft.configure(s.callbacks,this.callbacks,s.tags,this.tags,o,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),l={options:i,invocation_params:c,batch_size:1},d=await u?.handleChatModelStart(this.toJSON(),a.map(kf),s.runId,void 0,l,void 0,void 0,s.runName),p=[],h=(await Promise.allSettled(a.map(async(g,y)=>{let w=lr._convertInputToPromptValue(g).toString(),x=await n.lookup(w,r);return x==null&&p.push(y),x}))).map((g,y)=>({result:g,runManager:d?.[y]})).filter(({result:g})=>g.status==="fulfilled"&&g.value!=null||g.status==="rejected"),m=i.outputVersion??this.outputVersion,f=[];await Promise.all(h.map(async({result:g,runManager:y},w)=>{if(g.status==="fulfilled"){let x=g.value;return f[w]=x.map(O=>("message"in O&&it(O.message)&&yh(O.message)&&(O.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m==="v1"&&(O.message=wf(O.message))),O.generationInfo={...O.generationInfo,tokenUsage:{}},O)),x.length&&await y?.handleLLMNewToken(x[0].text),y?.handleLLMEnd({generations:[x]},void 0,void 0,void 0,{cached:!0})}else return await y?.handleLLMError(g.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(g.reason)}));let v={generations:f,missingPromptIndices:p,startedRunManagers:d};return Object.defineProperty(v,oc,{value:d?{runIds:d?.map(g=>g.runId)}:void 0,configurable:!0}),v}async generate(t,n,r){let i;Array.isArray(n)?i={stop:n}:i=n;let s=t.map(m=>m.map(br)),[a,o]=this._separateRunnableConfigFromCallOptionsCompat(i);if(a.callbacks=a.callbacks??r,!this.cache)return this._generateUncached(s,o,a);let{cache:c}=this,u=this._getSerializedCacheKeyParametersForCall(o),{generations:l,missingPromptIndices:d,startedRunManagers:p}=await this._generateCached({messages:s,cache:c,llmStringKey:u,parsedOptions:o,handledOptions:a}),h={};if(d.length>0){let m=await this._generateUncached(d.map(f=>s[f]),o,a,p!==void 0?d.map(f=>p?.[f]):void 0);await Promise.all(m.generations.map(async(f,v)=>{let g=d[v];l[g]=f;let y=lr._convertInputToPromptValue(s[g]).toString();return c.update(y,u,f)})),h=m.llmOutput??{}}return{generations:l,llmOutput:h}}invocationParams(t){return{}}_modelType(){return"base_chat_model"}async generatePrompt(t,n,r){let i=t.map(s=>s.toChatMessages());return this.generate(i,n,r)}withStructuredOutput(t,n){if(typeof this.bindTools!="function")throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');if(n?.strict)throw new Error('"strict" mode is not supported for this model by default.');let r=t,i=n?.name,s=ja(r)??"A function available to call.",a=n?.method,o=n?.includeRaw;if(a==="jsonMode")throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let c=i??"extract";!_n(r)&&!gs(r)&&"name"in r&&(c=r.name);let u=_n(r)||gs(r)?xt(r):r,l=[{type:"function",function:{name:c,description:s,parameters:u}}];return db(this.bindTools(l),ir.from(d=>{if(!Pt.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 p=d.tool_calls.find(h=>h.name===c);if(!p)throw new Error(`No tool call found with name ${c}.`);return p.args}),o,o?"StructuredOutputRunnable":"StructuredOutput")}},XZ=class extends Ns{async _generate(e,t,n){let r=new Le(await this._call(e,t,n));if(typeof r.content!="string")throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:r.content,message:r}]}}},YZ=G({}),QZ=G({BaseLLM:()=>RE,LLM:()=>pb}),RE=class Co extends Jh{lc_namespace=["langchain","llms",this._llmType()];async invoke(t,n){let r=Co._convertInputToPromptValue(t);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].text}async*_streamResponseChunks(t,n,r){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(t){let[n,r]=super._separateRunnableConfigFromCallOptions(t);return r.signal=n.signal,[n,r]}async*_streamIterator(t,n){if(this._streamResponseChunks===Co.prototype._streamResponseChunks)yield this.invoke(t,n);else{let r=Co._convertInputToPromptValue(t),[i,s]=this._separateRunnableConfigFromCallOptionsCompat(n),a=this.invocationParams(s),o=await Ft.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(a)}),c={options:s,invocation_params:a,batch_size:1},u=await o?.handleLLMStart(this.toJSON(),[r.toString()],i.runId,void 0,c,void 0,void 0,i.runName),l=new Ia({text:""});try{for await(let d of this._streamResponseChunks(r.toString(),s,u?.[0]))l?l=l.concat(d):l=d,typeof d.text=="string"&&(yield d.text)}catch(d){throw await Promise.all((u??[]).map(p=>p?.handleLLMError(d))),d}await Promise.all((u??[]).map(d=>d?.handleLLMEnd({generations:[[l]]})))}}async generatePrompt(t,n,r){let i=t.map(s=>s.toString());return this.generate(i,n,r)}invocationParams(t){return{}}_flattenLLMResult(t){let n=[];for(let r=0;r<t.generations.length;r+=1){let i=t.generations[r];if(r===0)n.push({generations:[i],llmOutput:t.llmOutput});else{let s=t.llmOutput?{...t.llmOutput,tokenUsage:{}}:void 0;n.push({generations:[i],llmOutput:s})}}return n}async _generateUncached(t,n,r,i){let s;if(i!==void 0&&i.length===t.length)s=i;else{let u=this.invocationParams(n),l=await Ft.configure(r.callbacks,this.callbacks,r.tags,this.tags,r.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(u)}),d={options:n,invocation_params:u,batch_size:t.length};s=await l?.handleLLMStart(this.toJSON(),t,r.runId,void 0,d,void 0,void 0,r?.runName)}let a=!!s?.[0].handlers.find(C_),o;if(a&&t.length===1&&this._streamResponseChunks!==Co.prototype._streamResponseChunks)try{let u=await this._streamResponseChunks(t[0],n,s?.[0]),l;for await(let d of u)l===void 0?l=d:l=Ii(l,d);if(l===void 0)throw new Error("Received empty response from chat model call.");o={generations:[[l]],llmOutput:{}},await s?.[0].handleLLMEnd(o)}catch(u){throw await s?.[0].handleLLMError(u),u}else{try{o=await this._generate(t,n,s?.[0])}catch(l){throw await Promise.all((s??[]).map(d=>d?.handleLLMError(l))),l}let u=this._flattenLLMResult(o);await Promise.all((s??[]).map((l,d)=>l?.handleLLMEnd(u[d])))}let c=s?.map(u=>u.runId)||void 0;return Object.defineProperty(o,oc,{value:c?{runIds:c}:void 0,configurable:!0}),o}async _generateCached({prompts:t,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:s,runId:a}){let o=this.invocationParams(i),c=await Ft.configure(s.callbacks,this.callbacks,s.tags,this.tags,s.metadata,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(o)}),u={options:i,invocation_params:o,batch_size:t.length},l=await c?.handleLLMStart(this.toJSON(),t,a,void 0,u,void 0,void 0,s?.runName),d=[],p=(await Promise.allSettled(t.map(async(f,v)=>{let g=await n.lookup(f,r);return g==null&&d.push(v),g}))).map((f,v)=>({result:f,runManager:l?.[v]})).filter(({result:f})=>f.status==="fulfilled"&&f.value!=null||f.status==="rejected"),h=[];await Promise.all(p.map(async({result:f,runManager:v},g)=>{if(f.status==="fulfilled"){let y=f.value;return h[g]=y.map(w=>(w.generationInfo={...w.generationInfo,tokenUsage:{}},w)),y.length&&await v?.handleLLMNewToken(y[0].text),v?.handleLLMEnd({generations:[y]},void 0,void 0,void 0,{cached:!0})}else return await v?.handleLLMError(f.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(f.reason)}));let m={generations:h,missingPromptIndices:d,startedRunManagers:l};return Object.defineProperty(m,oc,{value:l?{runIds:l?.map(f=>f.runId)}:void 0,configurable:!0}),m}async generate(t,n,r){if(!Array.isArray(t))throw new Error("Argument 'prompts' is expected to be a string[]");let i;Array.isArray(n)?i={stop:n}:i=n;let[s,a]=this._separateRunnableConfigFromCallOptionsCompat(i);if(s.callbacks=s.callbacks??r,!this.cache)return this._generateUncached(t,a,s);let{cache:o}=this,c=this._getSerializedCacheKeyParametersForCall(a),{generations:u,missingPromptIndices:l,startedRunManagers:d}=await this._generateCached({prompts:t,cache:o,llmStringKey:c,parsedOptions:a,handledOptions:s,runId:s.runId}),p={};if(l.length>0){let h=await this._generateUncached(l.map(m=>t[m]),a,s,d!==void 0?l.map(m=>d?.[m]):void 0);await Promise.all(h.generations.map(async(m,f)=>{let v=l[f];return u[v]=m,o.update(t[v],c,m)})),p=h.llmOutput??{}}return{generations:u,llmOutput:p}}_identifyingParams(){return{}}_modelType(){return"base_llm"}},pb=class extends RE{async _generate(e,t,n){return{generations:await Promise.all(e.map((r,i)=>this._call(r,{...t,promptIndex:i},n).then(s=>[{text:s}])))}}},eB=G({}),tB=G({BaseMemory:()=>nB,getInputValue:()=>rB,getOutputValue:()=>iB,getPromptInputKey:()=>sB}),nB=class{},ME=(e,t)=>{if(t!==void 0)return e[t];let n=Object.keys(e);if(n.length===1)return e[n[0]]},rB=(e,t)=>{let n=ME(e,t);if(!n)throw new Error(`input values have ${Object.keys(e).length} keys, you must specify an input key or pass only 1 key as input`);return n},iB=(e,t)=>{let n=ME(e,t);if(!n&&n!=="")throw new Error(`output values have ${Object.keys(e).length} keys, you must specify an output key or pass only 1 key as output`);return n};function sB(e,t){let n=Object.keys(e).filter(r=>!t.includes(r)&&r!=="stop");if(n.length!==1)throw new Error(`One input key expected, but got ${n.length}`);return n[0]}var UE=class extends Hh{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)}`)}},LE=class extends vu{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 UE(e)}_diff(e,t){if(t)return vh(e??{},t)}async parsePartialResult(e){let t=e[0];if(!t.message)return;let{message:n}=t,r=n.additional_kwargs.function_call;if(r)return this.argsOnly?ba(r.arguments):{...r,arguments:ba(r.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""}},aB=class extends Hh{static lc_name(){return"JsonKeyOutputFunctionsParser"}lc_namespace=["langchain","output_parsers","openai_functions"];lc_serializable=!0;outputParser=new LE;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]}},oB=G({JsonKeyOutputFunctionsParser:()=>aB,JsonOutputFunctionsParser:()=>LE,OutputFunctionsParser:()=>UE}),cB=G({JsonOutputKeyToolsParser:()=>SE,JsonOutputToolsParser:()=>IE,convertLangChainToolCallToOpenAI:()=>$E,makeInvalidToolCall:()=>Vo,parseToolCall:()=>Vh}),wu=class extends Ae{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??{},n={};for(let[r,i]of Object.entries(t))typeof i=="string"?n[r]=i:n[r]=await i();return{...n,...e}}async invoke(e,t){let n={...this.metadata,...t?.metadata},r=[...this.tags??[],...t?.tags??[]];return this._callWithConfig(i=>this.formatPromptValue(i),e,{...t,tags:r,metadata:n,runType:"prompt"})}},wc=class extends wu{async formatPromptValue(e){return new ib(await this.format(e))}},uB=Object.prototype.toString,ro=Array.isArray||function(e){return uB.call(e)==="[object Array]"};function hb(e){return typeof e=="function"}function lB(e){return ro(e)?"array":typeof e}function xf(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Lx(e,t){return e!=null&&typeof e=="object"&&t in e}function dB(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var pB=RegExp.prototype.test;function hB(e,t){return pB.call(e,t)}var mB=/\S/;function fB(e){return!hB(mB,e)}var gB={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function yB(e){return String(e).replace(/[&<>"'`=\/]/g,function(t){return gB[t]})}var _B=/\s*/,vB=/\s+/,zx=/\s*=/,bB=/\s*\}/,wB=/#|\^|\/|>|\{|&|=|!/;function kB(e,t){if(!e)return[];var n=!1,r=[],i=[],s=[],a=!1,o=!1,c="",u=0;function l(){if(a&&!o)for(;s.length;)delete i[s.pop()];else s=[];a=!1,o=!1}var d,p,h;function m(k){if(typeof k=="string"&&(k=k.split(vB,2)),!ro(k)||k.length!==2)throw new Error("Invalid tags: "+k);d=new RegExp(xf(k[0])+"\\s*"),p=new RegExp("\\s*"+xf(k[1])),h=new RegExp("\\s*"+xf("}"+k[1]))}m(t||pn.tags);for(var f=new ku(e),v,g,y,w,x,O;!f.eos();){if(v=f.pos,y=f.scanUntil(d),y)for(var z=0,T=y.length;z<T;++z)w=y.charAt(z),fB(w)?(s.push(i.length),c+=w):(o=!0,n=!0,c+=" "),i.push(["text",w,v,v+1]),v+=1,w===`
|
|
226
|
+
`&&(l(),c="",u=0,n=!1);if(!f.scan(d))break;if(a=!0,g=f.scan(wB)||"name",f.scan(_B),g==="="?(y=f.scanUntil(zx),f.scan(zx),f.scanUntil(p)):g==="{"?(y=f.scanUntil(h),f.scan(bB),f.scanUntil(p),g="&"):y=f.scanUntil(p),!f.scan(p))throw new Error("Unclosed tag at "+f.pos);if(g==">"?x=[g,y,v,f.pos,c,u,n]:x=[g,y,v,f.pos],u++,i.push(x),g==="#"||g==="^")r.push(x);else if(g==="/"){if(O=r.pop(),!O)throw new Error('Unopened section "'+y+'" at '+v);if(O[1]!==y)throw new Error('Unclosed section "'+O[1]+'" at '+v)}else g==="name"||g==="{"||g==="&"?o=!0:g==="="&&m(y)}if(l(),O=r.pop(),O)throw new Error('Unclosed section "'+O[1]+'" at '+f.pos);return $B(xB(i))}function xB(e){for(var t=[],n,r,i=0,s=e.length;i<s;++i)n=e[i],n&&(n[0]==="text"&&r&&r[0]==="text"?(r[1]+=n[1],r[3]=n[3]):(t.push(n),r=n));return t}function $B(e){for(var t=[],n=t,r=[],i,s,a=0,o=e.length;a<o;++a)switch(i=e[a],i[0]){case"#":case"^":n.push(i),r.push(i),n=i[4]=[];break;case"/":s=r.pop(),s[5]=i[2],n=r.length>0?r[r.length-1][4]:t;break;default:n.push(i)}return t}function ku(e){this.string=e,this.tail=e,this.pos=0}ku.prototype.eos=function(){return this.tail===""};ku.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};ku.prototype.scanUntil=function(e){var t=this.tail.search(e),n;switch(t){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=n.length,n};function za(e,t){this.view=e,this.cache={".":this.view},this.parent=t}za.prototype.push=function(e){return new za(e,this)};za.prototype.lookup=function(e){var t=this.cache,n;if(t.hasOwnProperty(e))n=t[e];else{for(var r=this,i,s,a,o=!1;r;){if(e.indexOf(".")>0)for(i=r.view,s=e.split("."),a=0;i!=null&&a<s.length;)a===s.length-1&&(o=Lx(i,s[a])||dB(i,s[a])),i=i[s[a++]];else i=r.view[e],o=Lx(r.view,e);if(o){n=i;break}r=r.parent}t[e]=n}return hb(n)&&(n=n.call(this.view)),n};function Yt(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}Yt.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};Yt.prototype.parse=function(e,t){var n=this.templateCache,r=e+":"+(t||pn.tags).join(":"),i=typeof n<"u",s=i?n.get(r):void 0;return s==null&&(s=kB(e,t),i&&n.set(r,s)),s};Yt.prototype.render=function(e,t,n,r){var i=this.getConfigTags(r),s=this.parse(e,i),a=t instanceof za?t:new za(t,void 0);return this.renderTokens(s,a,n,e,r)};Yt.prototype.renderTokens=function(e,t,n,r,i){for(var s="",a,o,c,u=0,l=e.length;u<l;++u)c=void 0,a=e[u],o=a[0],o==="#"?c=this.renderSection(a,t,n,r,i):o==="^"?c=this.renderInverted(a,t,n,r,i):o===">"?c=this.renderPartial(a,t,n,i):o==="&"?c=this.unescapedValue(a,t):o==="name"?c=this.escapedValue(a,t,i):o==="text"&&(c=this.rawValue(a)),c!==void 0&&(s+=c);return s};Yt.prototype.renderSection=function(e,t,n,r,i){var s=this,a="",o=t.lookup(e[1]);function c(d){return s.render(d,t,n,i)}if(o){if(ro(o))for(var u=0,l=o.length;u<l;++u)a+=this.renderTokens(e[4],t.push(o[u]),n,r,i);else if(typeof o=="object"||typeof o=="string"||typeof o=="number")a+=this.renderTokens(e[4],t.push(o),n,r,i);else if(hb(o)){if(typeof r!="string")throw new Error("Cannot use higher-order sections without the original template");o=o.call(t.view,r.slice(e[3],e[5]),c),o!=null&&(a+=o)}else a+=this.renderTokens(e[4],t,n,r,i);return a}};Yt.prototype.renderInverted=function(e,t,n,r,i){var s=t.lookup(e[1]);if(!s||ro(s)&&s.length===0)return this.renderTokens(e[4],t,n,r,i)};Yt.prototype.indentPartial=function(e,t,n){for(var r=t.replace(/[^ \t]/g,""),i=e.split(`
|
|
227
|
+
`),s=0;s<i.length;s++)i[s].length&&(s>0||!n)&&(i[s]=r+i[s]);return i.join(`
|
|
228
|
+
`)};Yt.prototype.renderPartial=function(e,t,n,r){if(n){var i=this.getConfigTags(r),s=hb(n)?n(e[1]):n[e[1]];if(s!=null){var a=e[6],o=e[5],c=e[4],u=s;o==0&&c&&(u=this.indentPartial(s,c,a));var l=this.parse(u,i);return this.renderTokens(l,t,n,u,r)}}};Yt.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(n!=null)return n};Yt.prototype.escapedValue=function(e,t,n){var r=this.getConfigEscape(n)||pn.escape,i=t.lookup(e[1]);if(i!=null)return typeof i=="number"&&r===pn.escape?String(i):r(i)};Yt.prototype.rawValue=function(e){return e[1]};Yt.prototype.getConfigTags=function(e){return ro(e)?e:e&&typeof e=="object"?e.tags:void 0};Yt.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!ro(e))return e.escape};var pn={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){kc.templateCache=e},get templateCache(){return kc.templateCache}},kc=new Yt;pn.clearCache=function(){return kc.clearCache()};pn.parse=function(e,t){return kc.parse(e,t)};pn.render=function(e,t,n,r){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+lB(e)+'" was given as the first argument for mustache#render(template, view, partials)');return kc.render(e,t,n,r)};pn.escape=yB;pn.Scanner=ku;pn.Context=za;pn.Writer=Yt;function zE(){pn.escape=e=>e}var xc=e=>{let t=e.split(""),n=[],r=(s,a)=>{for(let o=a;o<t.length;o+=1)if(s.includes(t[o]))return o;return-1},i=0;for(;i<t.length;)if(t[i]==="{"&&i+1<t.length&&t[i+1]==="{")n.push({type:"literal",text:"{"}),i+=2;else if(t[i]==="}"&&i+1<t.length&&t[i+1]==="}")n.push({type:"literal",text:"}"}),i+=2;else if(t[i]==="{"){let s=r("}",i);if(s<0)throw new Error("Unclosed '{' in template.");n.push({type:"variable",name:t.slice(i+1,s).join("")}),i=s+1}else{if(t[i]==="}")throw new Error("Single '}' in template.");{let s=r("{}",i),a=(s<0?t.slice(i):t.slice(i,s)).join("");n.push({type:"literal",text:a}),i=s<0?t.length:s}}return n},DE=(e,t=[])=>{let n=[];for(let r of e)if(r[0]==="name"){let i=r[1].includes(".")?r[1].split(".")[0]:r[1];n.push({type:"variable",name:i})}else if(["#","&","^",">"].includes(r[0])){if(n.push({type:"variable",name:r[1]}),r[0]==="#"&&r.length>4&&Array.isArray(r[4])){let i=[...t,r[1]],s=DE(r[4],i);n.push(...s)}}else n.push({type:"literal",text:r[1]});return n},Md=e=>(zE(),DE(pn.parse(e))),FE=(e,t)=>xc(e).reduce((n,r)=>{if(r.type==="variable"){if(r.name in t)return n+(typeof t[r.name]=="string"?t[r.name]:JSON.stringify(t[r.name]));throw new Error(`(f-string) Missing value for input ${r.name}`)}return n+r.text},""),ZE=(e,t)=>(zE(),pn.render(e,t)),Ud={"f-string":FE,mustache:ZE},BE={"f-string":xc,mustache:Md},Qn=(e,t,n)=>{try{return Ud[t](e,n)}catch(r){throw Vc(r,"INVALID_PROMPT_INPUT")}},Ld=(e,t)=>BE[t](e),xu=(e,t,n)=>{if(!(t in Ud))throw new Error(`Invalid template format. Got \`${t}\`;
|
|
229
|
+
should be one of ${Object.keys(Ud)}`);try{let r=Object.fromEntries(n.map(i=>[i,"foo"]));Array.isArray(e)?e.forEach(i=>{if(i.type==="text"&&"text"in i&&typeof i.text=="string")Qn(i.text,t,r);else if(i.type==="image_url"){if(typeof i.image_url=="string")Qn(i.image_url,t,r);else if(typeof i.image_url=="object"&&i.image_url!==null&&"url"in i.image_url&&typeof i.image_url.url=="string"){let s=i.image_url.url;Qn(s,t,r)}}else throw new Error(`Invalid message template received. ${JSON.stringify(i,null,2)}`)}):Qn(e,t,r)}catch(r){throw new Error(`Invalid prompt schema: ${r.message}`)}},wi=class No extends wc{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 n=this.inputVariables;this.partialVariables&&(n=n.concat(Object.keys(this.partialVariables))),xu(this.template,this.templateFormat,n)}}_getPromptType(){return"prompt"}async format(t){let n=await this.mergePartialAndUserVariables(t);return Qn(this.template,this.templateFormat,n)}static fromExamples(t,n,r,i=`
|
|
230
|
+
|
|
231
|
+
`,s=""){return new No({inputVariables:r,template:[s,...t,n].join(i)})}static fromTemplate(t,n){let{templateFormat:r="f-string",...i}=n??{},s=new Set;return Ld(t,r).forEach(a=>{a.type==="variable"&&s.add(a.name)}),new No({inputVariables:[...s],templateFormat:r,template:t,...i})}async partial(t){let n=this.inputVariables.filter(i=>!(i in t)),r={...this.partialVariables??{},...t};return new No({...this,inputVariables:n,partialVariables:r})}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 No({inputVariables:t.input_variables,template:t.template,templateFormat:t.template_format})}},Hl=class qE extends wu{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 n=this.inputVariables;this.partialVariables&&(n=n.concat(Object.keys(this.partialVariables))),xu([{type:"image_url",image_url:this.template}],this.templateFormat,n)}}_getPromptType(){return"prompt"}async partial(t){let n=this.inputVariables.filter(i=>!(i in t)),r={...this.partialVariables??{},...t};return new qE({...this,inputVariables:n,partialVariables:r})}async format(t){let n={};for(let[a,o]of Object.entries(this.template))typeof o=="string"?n[a]=Qn(o,this.templateFormat,t):n[a]=o;let r=t.url||n.url,i=t.detail||n.detail;if(!r)throw new Error("Must provide either an image URL.");if(typeof r!="string")throw new Error("url must be a string.");let s={url:r};return i&&(s.detail=i),s}async formatPromptValue(t){return new yE(await this.format(t))}},gy=class extends Ae{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",n=yy(e.template,t);super({inputVariables:n,...e}),this.template=e.template,this.templateFormat=t,this.inputVariables=n}async format(e){return _y(this.template,e,this.templateFormat)}async invoke(e){return await this._callWithConfig(this.format.bind(this),e,{runType:"prompt"})}};function yy(e,t){let n=[];for(let r of Object.values(e))if(typeof r=="string")Ld(r,t).forEach(i=>{i.type==="variable"&&n.push(i.name)});else if(Array.isArray(r))for(let i of r)typeof i=="string"?Ld(i,t).forEach(s=>{s.type==="variable"&&n.push(s.name)}):typeof i=="object"&&n.push(...yy(i,t));else typeof r=="object"&&r!==null&&n.push(...yy(r,t));return Array.from(new Set(n))}function _y(e,t,n){let r={};for(let[i,s]of Object.entries(e))if(typeof s=="string")r[i]=Qn(s,n,t);else if(Array.isArray(s)){let a=[];for(let o of s)typeof o=="string"?a.push(Qn(o,n,t)):typeof o=="object"&&a.push(_y(o,t,n));r[i]=a}else typeof s=="object"&&s!==null?r[i]=_y(s,t,n):r[i]=s;return r}var Kh=class extends Ae{lc_namespace=["langchain_core","prompts","chat"];lc_serializable=!0;async invoke(e,t){return this._callWithConfig(n=>this.formatMessages(n),e,{...t,runType:"prompt"})}},vy=class extends Kh{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 r=new Error(`Field "${this.variableName}" in prompt uses a MessagesPlaceholder, which expects an array of BaseMessages as an input value. Received: undefined`);throw r.name="InputFormatError",r}let n;try{Array.isArray(t)?n=t.map(br):n=[br(t)]}catch(r){let i=typeof t=="string"?t:JSON.stringify(t,null,2),s=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: ${r.message}`].join(`
|
|
232
|
+
|
|
233
|
+
`));throw s.name="InputFormatError",s.lc_error_code=r.lc_error_code,s}return n}},JE=class extends Kh{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)]}},mb=class extends wu{constructor(e){super(e)}async format(e){return(await this.formatPromptValue(e)).toString()}async formatPromptValue(e){return new sb(await this.formatMessages(e))}},HE=class extends JE{static lc_name(){return"ChatMessagePromptTemplate"}role;constructor(e,t){"prompt"in e||(e={prompt:e,role:t}),super(e),this.role=e.role}async format(e){return new Qr(await this.prompt.format(e),this.role)}static fromTemplate(e,t,n){return new this(wi.fromTemplate(e,{templateFormat:n?.templateFormat}),t)}};function IB(e){return e===null||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).length===1&&"text"in e&&typeof e.text=="string"}function SB(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 fb=class extends Kh{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 n=[];this.prompt.forEach(r=>{"inputVariables"in r&&(n=n.concat(r.inputVariables))}),this.inputVariables=n}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 n=t.chatMessageClass();return new n({content:e,role:this.getRoleFromMessageClass(n.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(wi.fromTemplate(e,t));let n=[];for(let r of e)if(typeof r=="string")n.push(wi.fromTemplate(r,t));else if(r!==null)if(IB(r)){let i="";typeof r.text=="string"&&(i=r.text??"");let s={...t,additionalContentFields:r};n.push(wi.fromTemplate(i,s))}else if(SB(r)){let i=r.image_url??"",s,a=[];if(typeof i=="string"){let o;t?.templateFormat==="mustache"?o=Md(i):o=xc(i);let c=o.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.
|
|
234
|
+
Got: ${c}
|
|
235
|
+
From: ${i}`);a=[c[0]]}else a=[];i={url:i},s=new Hl({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:r})}else if(typeof i=="object"){if("url"in i){let o;t?.templateFormat==="mustache"?o=Md(i.url):o=xc(i.url),a=o.flatMap(c=>c.type==="variable"?[c.name]:[])}else a=[];s=new Hl({template:i,inputVariables:a,templateFormat:t?.templateFormat,additionalContentFields:r})}else throw new Error("Invalid image template");n.push(s)}else typeof r=="object"&&n.push(new gy({template:r,templateFormat:t?.templateFormat}));return new this({prompt:n,additionalOptions:t})}async format(e){if(this.prompt instanceof wc){let t=await this.prompt.format(e);return this.createMessage(t)}else{let t=[];for(let n of this.prompt){let r={};if(!("inputVariables"in n))throw new Error(`Prompt ${n} does not have inputVariables defined.`);for(let i of n.inputVariables)r||(r={[i]:e[i]}),r={...r,[i]:e[i]};if(n instanceof wc){let i=await n.format(r),s;"additionalContentFields"in n&&(s=n.additionalContentFields),i!==""&&t.push({...s,type:"text",text:i})}else if(n instanceof Hl){let i=await n.format(r),s;"additionalContentFields"in n&&(s=n.additionalContentFields),t.push({...s,type:"image_url",image_url:i})}else if(n instanceof gy){let i=await n.format(r),s;"additionalContentFields"in n&&(s=n.additionalContentFields),t.push({...s,...i})}}return this.createMessage(t)}}async formatMessages(e){return[await this.format(e)]}},gb=class extends fb{static _messageClass(){return $n}static lc_name(){return"HumanMessagePromptTemplate"}},VE=class extends fb{static _messageClass(){return Le}static lc_name(){return"AIMessagePromptTemplate"}},yb=class extends fb{static _messageClass(){return Ir}static lc_name(){return"SystemMessagePromptTemplate"}};function OB(e){return typeof e.formatMessages=="function"}function AB(e,t){if(OB(e)||it(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 vy({variableName:i.slice(2,-2),optional:!0});if(typeof i=="string"&&i[0]==="{"&&i[i.length-1]==="}")return new vy({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 n=br(e),r;if(typeof n.content=="string"?r=n.content:r=n.content.map(i=>"text"in i?{...i,text:i.text}:"image_url"in i?{...i,image_url:i.image_url}:i),n._getType()==="human")return gb.fromTemplate(r,t);if(n._getType()==="ai")return VE.fromTemplate(r,t);if(n._getType()==="system")return yb.fromTemplate(r,t);if(Qr.isInstance(n))return HE.fromTemplate(n.content,n.role,t);throw new Error(`Could not coerce message prompt template from input. Received message type: "${n._getType()}".`)}function TB(e){return e.constructor.lc_name()==="MessagesPlaceholder"}var Wh=class Vl extends mb{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 n=new Set;for(let o of this.promptMessages)if(!(o instanceof Gt))for(let c of o.inputVariables)n.add(c);let r=this.inputVariables,i=new Set(this.partialVariables?r.concat(Object.keys(this.partialVariables)):r),s=new Set([...i].filter(o=>!n.has(o)));if(s.size>0)throw new Error(`Input variables \`${[...s]}\` are not used in any of the prompt messages.`);let a=new Set([...n].filter(o=>!i.has(o)));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,n){return typeof t.content=="string"||(t.content=await Promise.all(t.content.map(async r=>{if(r.type!=="image_url")return r;let i="";typeof r.image_url=="string"?i=r.image_url:typeof r.image_url=="object"&&r.image_url!==null&&"url"in r.image_url&&typeof r.image_url.url=="string"&&(i=r.image_url.url);let s=await wi.fromTemplate(i,{templateFormat:this.templateFormat}).format(n);return typeof r.image_url=="object"&&r.image_url!==null&&"url"in r.image_url?r.image_url.url=s:r.image_url=s,r}))),t}async formatMessages(t){let n=await this.mergePartialAndUserVariables(t),r=[];for(let i of this.promptMessages)if(i instanceof Gt)r.push(await this._parseImagePrompts(i,n));else{let s;this.templateFormat==="mustache"?s={...n}:s=i.inputVariables.reduce((o,c)=>{if(!(c in n)&&!(TB(i)&&i.optional))throw Vc(new Error(`Missing value for input variable \`${c.toString()}\``),"INVALID_PROMPT_INPUT");return o[c]=n[c],o},{});let a=await i.formatMessages(s);r=r.concat(a)}return r}async partial(t){let n=this.inputVariables.filter(i=>!(i in t)),r={...this.partialVariables??{},...t};return new Vl({...this,inputVariables:n,partialVariables:r})}static fromTemplate(t,n){let r=new gb({prompt:wi.fromTemplate(t,n)});return this.fromMessages([r])}static fromMessages(t,n){let r=t.reduce((a,o)=>a.concat(o instanceof Vl?o.promptMessages:[AB(o,n)]),[]),i=t.reduce((a,o)=>o instanceof Vl?Object.assign(a,o.partialVariables):a,Object.create(null)),s=new Set;for(let a of r)if(!(a instanceof Gt))for(let o of a.inputVariables)o in i||s.add(o);return new this({...n,inputVariables:[...s],promptMessages:r,partialVariables:i,templateFormat:n?.templateFormat})}},EB=class by extends wc{lc_serializable=!1;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
236
|
+
|
|
237
|
+
`;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 n=this.inputVariables;this.partialVariables&&(n=n.concat(Object.keys(this.partialVariables))),xu(this.prefix+this.suffix,this.templateFormat,n)}}_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 n=this.inputVariables.filter(i=>!(i in t)),r={...this.partialVariables??{},...t};return new by({...this,inputVariables:n,partialVariables:r})}async format(t){let n=await this.mergePartialAndUserVariables(t),r=await this.getExamples(n),i=await Promise.all(r.map(s=>this.examplePrompt.format(s)));return Qn([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,n)}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:n}=t;if(!n)throw new Error("Missing example prompt");let r=await wi.deserialize(n),i;if(Array.isArray(t.examples))i=t.examples;else throw new Error("Invalid examples format. Only list or string are supported.");return new by({inputVariables:t.input_variables,examplePrompt:r,examples:i,exampleSeparator:t.example_separator,prefix:t.prefix,suffix:t.suffix,templateFormat:t.template_format})}},CB=class KE extends mb{lc_serializable=!0;examples;exampleSelector;examplePrompt;suffix="";exampleSeparator=`
|
|
238
|
+
|
|
239
|
+
`;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??`
|
|
240
|
+
|
|
241
|
+
`,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 n=this.inputVariables;this.partialVariables&&(n=n.concat(Object.keys(this.partialVariables))),xu(this.prefix+this.suffix,this.templateFormat,n)}}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 n=await this.mergePartialAndUserVariables(t),r=await this.getExamples(n);r=r.map(s=>{let a={};return this.examplePrompt.inputVariables.forEach(o=>{a[o]=s[o]}),a});let i=[];for(let s of r){let a=await this.examplePrompt.formatMessages(s);i.push(...a)}return i}async format(t){let n=await this.mergePartialAndUserVariables(t),r=await this.getExamples(n),i=(await Promise.all(r.map(s=>this.examplePrompt.formatMessages(s)))).flat().map(s=>s.content);return Qn([this.prefix,...i,this.suffix].join(this.exampleSeparator),this.templateFormat,n)}async partial(t){let n=this.inputVariables.filter(i=>!(i in t)),r={...this.partialVariables??{},...t};return new KE({...this,inputVariables:n,partialVariables:r})}},NB=class Kl extends wu{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(r=>r.name),n=this.pipelinePrompts.map(r=>r.prompt.inputVariables.filter(i=>!t.includes(i))).flat();return[...new Set(n)]}static extractRequiredInputValues(t,n){return n.reduce((r,i)=>(r[i]=t[i],r),{})}async formatPipelinePrompts(t){let n=await this.mergePartialAndUserVariables(t);for(let{name:r,prompt:i}of this.pipelinePrompts){let s=Kl.extractRequiredInputValues(n,i.inputVariables);i instanceof Wh?n[r]=await i.formatMessages(s):n[r]=await i.format(s)}return Kl.extractRequiredInputValues(n,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 n={...this};return n.inputVariables=this.inputVariables.filter(r=>!(r in t)),n.partialVariables={...this.partialVariables??{},...t},new Kl(n)}serialize(){throw new Error("Not implemented.")}_getPromptType(){return"pipeline"}};function Dx(e){return typeof e=="object"&&e!=null&&"withStructuredOutput"in e&&typeof e.withStructuredOutput=="function"}function PB(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 jB=class WE extends Wh{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(Dx(t))return super.pipe(t.withStructuredOutput(this.schema));if(PB(t)&&Dx(t.bound))return super.pipe(new Ci({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,n,r){return WE.fromMessages(t,{schema:n,method:r})}},RB=G({AIMessagePromptTemplate:()=>VE,BaseChatPromptTemplate:()=>mb,BaseMessagePromptTemplate:()=>Kh,BaseMessageStringPromptTemplate:()=>JE,BasePromptTemplate:()=>wu,BaseStringPromptTemplate:()=>wc,ChatMessagePromptTemplate:()=>HE,ChatPromptTemplate:()=>Wh,DEFAULT_FORMATTER_MAPPING:()=>Ud,DEFAULT_PARSER_MAPPING:()=>BE,DictPromptTemplate:()=>gy,FewShotChatMessagePromptTemplate:()=>CB,FewShotPromptTemplate:()=>EB,HumanMessagePromptTemplate:()=>gb,ImagePromptTemplate:()=>Hl,MessagesPlaceholder:()=>vy,PipelinePromptTemplate:()=>NB,PromptTemplate:()=>wi,StructuredPrompt:()=>jB,SystemMessagePromptTemplate:()=>yb,checkValidTemplate:()=>xu,interpolateFString:()=>FE,interpolateMustache:()=>ZE,parseFString:()=>xc,parseMustache:()=>Md,parseTemplate:()=>Ld,renderTemplate:()=>Qn}),MB=G({BaseDocumentCompressor:()=>UB}),UB=class{static isBaseDocumentCompressor(e){return e?.compressDocuments!==void 0}},LB=G({BaseRetriever:()=>_b}),_b=class extends Ae{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 n=Te(Qc(t)),r=await(await Ft.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose}))?.handleRetrieverStart(this.toJSON(),e,n.runId,void 0,void 0,void 0,n.runName);try{let i=await this._getRelevantDocuments(e,r);return await r?.handleRetrieverEnd(i),i}catch(i){throw await r?.handleRetrieverError(i),i}}},zB=G({BaseStore:()=>GE,InMemoryStore:()=>DB}),GE=class extends Rn{},DB=class extends GE{lc_namespace=["langchain","storage"];store={};async mget(e){return e.map(t=>this.store[t])}async mset(e){for(let[t,n]of e)this.store[t]=n}async mdelete(e){for(let t of e)delete this.store[t]}async*yieldKeys(e){let t=Object.keys(this.store);for(let n of t)(e===void 0||n.startsWith(e))&&(yield n)}},di={and:"and",or:"or",not:"not"},Oe={eq:"eq",ne:"ne",lt:"lt",gt:"gt",lte:"lte",gte:"gte"},XE=class{},vb=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")}},bb=class extends vb{},FB=class extends bb{exprName="Comparison";constructor(e,t,n){super(),this.comparator=e,this.attribute=t,this.value=n}},ZB=class extends bb{exprName="Operation";constructor(e,t){super(),this.operator=e,this.args=t}},BB=class extends vb{exprName="StructuredQuery";constructor(e,t){super(),this.query=e,this.filter=t}};function YE(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Xn(e){return e?typeof e=="string"&&e.length>0||typeof e=="function"?!1:YE(e)&&Object.keys(e).length===0:!0}function QE(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 eC(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 tC(e){return typeof e=="string"&&(Number.isNaN(parseFloat(e))||parseFloat(e).toString()!==e)}function nC(e){return typeof e=="boolean"}function wb(e){let t;if(tC(e))t=e;else if(QE(e))t=parseInt(e,10);else if(eC(e))t=parseFloat(e);else if(nC(e))t=!!e;else throw new Error("Unsupported value type");return t}var kb=class extends XE{},qB=class extends kb{allowedOperators;allowedComparators;constructor(e){super(),this.allowedOperators=e?.allowedOperators??[di.and,di.or],this.allowedComparators=e?.allowedComparators??[Oe.eq,Oe.ne,Oe.gt,Oe.gte,Oe.lt,Oe.lte]}formatFunction(e){if(e in Oe){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 di){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(n=>n.accept(this));return{[this.formatFunction(e.operator)]:t}}visitComparison(e){return{[e.attribute]:{[this.formatFunction(e.comparator)]:wb(e.value)}}}visitStructuredQuery(e){let t={};return e.filter&&(t={filter:e.filter.accept(this)}),t}mergeFilters(e,t,n="and",r=!1){if(!(Xn(e)&&Xn(t))){if(Xn(e)||n==="replace")return Xn(t)?void 0:t;if(Xn(t))return r?e:n==="and"?void 0:e;if(n==="and")return{$and:[e,t]};if(n==="or")return{$or:[e,t]};throw new Error("Unknown merge type")}}},JB=class extends kb{allowedOperators=[di.and,di.or];allowedComparators=[Oe.eq,Oe.ne,Oe.gt,Oe.gte,Oe.lt,Oe.lte];formatFunction(){throw new Error("Not implemented")}getAllowedComparatorsForType(e){switch(e){case"string":return[Oe.eq,Oe.ne,Oe.gt,Oe.gte,Oe.lt,Oe.lte];case"number":return[Oe.eq,Oe.ne,Oe.gt,Oe.gte,Oe.lt,Oe.lte];case"boolean":return[Oe.eq,Oe.ne];default:throw new Error(`Unsupported data type: ${e}`)}}getComparatorFunction(e){switch(e){case Oe.eq:return(t,n)=>t===n;case Oe.ne:return(t,n)=>t!==n;case Oe.gt:return(t,n)=>t>n;case Oe.gte:return(t,n)=>t>=n;case Oe.lt:return(t,n)=>t<n;case Oe.lte:return(t,n)=>t<=n;default:throw new Error("Unknown comparator")}}getOperatorFunction(e){switch(e){case di.and:return(t,n)=>t&&n;case di.or:return(t,n)=>t||n;default:throw new Error("Unknown operator")}}visitOperation(e){let{operator:t,args:n}=e;if(this.allowedOperators.includes(t)){let r=this.getOperatorFunction(t);return i=>n?n.reduce((s,a)=>{let o=a.accept(this);if(typeof o=="function")return r(s,o(i));throw new Error("Filter is not a function")},!0):!0}else throw new Error("Operator not allowed")}visitComparison(e){let{comparator:t,attribute:n,value:r}=e,i=[Oe.ne];if(this.allowedComparators.includes(t)){if(!this.getAllowedComparatorsForType(typeof r).includes(t))throw new Error(`'${t}' comparator not allowed to be used with ${typeof r}`);let s=this.getComparatorFunction(t);return a=>{let o=a.metadata[n];return o===void 0?!!i.includes(t):s(o,wb(r))}}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,n="and"){if(!(Xn(e)&&Xn(t))){if(Xn(e)||n==="replace")return Xn(t)?void 0:t;if(Xn(t))return n==="and"?void 0:e;if(n==="and")return r=>e(r)&&t(r);if(n==="or")return r=>e(r)||t(r);throw new Error("Unknown merge type")}}},HB=G({BaseTranslator:()=>kb,BasicTranslator:()=>qB,Comparators:()=>Oe,Comparison:()=>FB,Expression:()=>vb,FilterDirective:()=>bb,FunctionalTranslator:()=>JB,Operation:()=>ZB,Operators:()=>di,StructuredQuery:()=>BB,Visitor:()=>XE,castValue:()=>wb,isBoolean:()=>nC,isFilterEmpty:()=>Xn,isFloat:()=>eC,isInt:()=>QE,isObject:()=>YE,isString:()=>tC});function $c(e){return Gt.isInstance(e)?e.constructor.name||e.type:typeof e}function Gh(e,t){return function(n,r){let{isNot:i,utils:s}=this;if(!t(n))return{pass:!1,message:()=>`${s.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
242
|
+
|
|
243
|
+
Expected: ${i?"not ":""}${e}
|
|
244
|
+
Received: ${$c(n)}`,actual:$c(n),expected:e};if(r===void 0)return{pass:!0,message:()=>`${s.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
245
|
+
|
|
246
|
+
Expected: not ${e}
|
|
247
|
+
Received: ${e}`};let a=n;return typeof r=="string"?{pass:a.content===r,message:()=>`${s.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
248
|
+
|
|
249
|
+
Expected: ${e} with content ${s.printExpected(r)}
|
|
250
|
+
Received: ${e} with content ${s.printReceived(a.content)}`,actual:a.content,expected:r}:{pass:Object.entries(r).every(([o,c])=>this.equals(a[o],c)),message:()=>{let o={};for(let c of Object.keys(r))o[c]=a[c];return`${s.matcherHint(`toBe${e}`,void 0,void 0)}
|
|
251
|
+
|
|
252
|
+
Expected: ${e} matching ${s.printExpected(r)}
|
|
253
|
+
Received: ${e} with ${s.printReceived(o)}`},actual:(()=>{let o={};for(let c of Object.keys(r))o[c]=a[c];return o})(),expected:r}}}var rC=Gh("HumanMessage",$n.isInstance),iC=Gh("AIMessage",Le.isInstance),sC=Gh("SystemMessage",Ir.isInstance),aC=Gh("ToolMessage",Mn.isInstance);function oC(e,t){let{isNot:n,utils:r}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${r.matcherHint("toHaveToolCalls")}
|
|
254
|
+
|
|
255
|
+
Expected: AIMessage
|
|
256
|
+
Received: ${$c(e)}`};let i=e.tool_calls??[];if(i.length!==t.length)return{pass:!1,message:()=>`${r.matcherHint("toHaveToolCalls")}
|
|
257
|
+
|
|
258
|
+
Expected ${n?"not ":""}${t.length} tool call(s), received ${i.length}`,actual:i.length,expected:t.length};let s=t.filter(a=>!i.some(o=>Object.entries(a).every(([c,u])=>this.equals(o[c],u))));return s.length>0?{pass:!1,message:()=>`${r.matcherHint("toHaveToolCalls")}
|
|
259
|
+
|
|
260
|
+
Could not find matching tool call(s) for:
|
|
261
|
+
${r.printExpected(s)}
|
|
262
|
+
Received tool calls: ${r.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:()=>`${r.matcherHint("toHaveToolCalls")}
|
|
263
|
+
|
|
264
|
+
Expected AIMessage not to have matching tool calls`}}function cC(e,t){let{isNot:n,utils:r}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${r.matcherHint("toHaveToolCallCount")}
|
|
265
|
+
|
|
266
|
+
Expected: AIMessage
|
|
267
|
+
Received: ${$c(e)}`};let i=e.tool_calls?.length??0;return{pass:i===t,message:()=>`${r.matcherHint("toHaveToolCallCount")}
|
|
268
|
+
|
|
269
|
+
Expected ${n?"not ":""}${t} tool call(s)
|
|
270
|
+
Received: ${i}`,actual:i,expected:t}}function uC(e,t){let{isNot:n,utils:r}=this;if(!Le.isInstance(e))return{pass:!1,message:()=>`${r.matcherHint("toContainToolCall")}
|
|
271
|
+
|
|
272
|
+
Expected: AIMessage
|
|
273
|
+
Received: ${$c(e)}`};let i=e.tool_calls??[];return{pass:i.some(s=>Object.entries(t).every(([a,o])=>this.equals(s[a],o))),message:()=>`${r.matcherHint("toContainToolCall")}
|
|
274
|
+
|
|
275
|
+
Expected AIMessage ${n?"not ":""}to contain a tool call matching ${r.printExpected(t)}
|
|
276
|
+
Received tool calls: ${r.printReceived(i.map(s=>({name:s.name,id:s.id})))}`,actual:i.map(s=>({name:s.name,id:s.id})),expected:t}}function lC(e,t){let{isNot:n,utils:r}=this;if(!Array.isArray(e))return{pass:!1,message:()=>`${r.matcherHint("toHaveToolMessages")}
|
|
277
|
+
|
|
278
|
+
Expected an array of messages
|
|
279
|
+
Received: ${typeof e}`};let i=e.filter(Mn.isInstance);if(i.length!==t.length)return{pass:!1,message:()=>`${r.matcherHint("toHaveToolMessages")}
|
|
280
|
+
|
|
281
|
+
Expected ${n?"not ":""}${t.length} tool message(s), found ${i.length}`,actual:i.length,expected:t.length};for(let s=0;s<t.length;s++)if(!Object.entries(t[s]).every(([a,o])=>this.equals(i[s][a],o)))return{pass:!1,message:()=>{let a={};for(let o of Object.keys(t[s]))a[o]=i[s][o];return`${r.matcherHint("toHaveToolMessages")}
|
|
282
|
+
|
|
283
|
+
Tool message at index ${s} did not match:
|
|
284
|
+
Expected: ${r.printExpected(t[s])}
|
|
285
|
+
Received: ${r.printReceived(a)}`},actual:i[s],expected:t[s]};return{pass:!0,message:()=>`${r.matcherHint("toHaveToolMessages")}
|
|
286
|
+
|
|
287
|
+
Expected messages not to contain matching tool messages`}}function dC(e,t){let{isNot:n,utils:r}=this,i=e?.__interrupt__;if(!(Array.isArray(i)&&i.length>0))return{pass:!1,message:()=>`${r.matcherHint("toHaveBeenInterrupted")}
|
|
288
|
+
|
|
289
|
+
Expected result ${n?"not ":""}to have been interrupted
|
|
290
|
+
Received __interrupt__: ${r.printReceived(i)}`};if(t===void 0)return{pass:!0,message:()=>`${r.matcherHint("toHaveBeenInterrupted")}
|
|
291
|
+
|
|
292
|
+
Expected result not to have been interrupted
|
|
293
|
+
Received ${i.length} interrupt(s)`};let s=i[0]?.value;return{pass:this.equals(s,t),message:()=>`${r.matcherHint("toHaveBeenInterrupted")}
|
|
294
|
+
|
|
295
|
+
Expected interrupt value: ${r.printExpected(t)}
|
|
296
|
+
Received interrupt value: ${r.printReceived(s)}`,actual:s,expected:t}}function pC(e,t){let{isNot:n,utils:r}=this,i=e?.structuredResponse;return i===void 0?{pass:!1,message:()=>`${r.matcherHint("toHaveStructuredResponse")}
|
|
297
|
+
|
|
298
|
+
Expected result ${n?"not ":""}to have a structured response
|
|
299
|
+
Received structuredResponse: undefined`}:t===void 0?{pass:!0,message:()=>`${r.matcherHint("toHaveStructuredResponse")}
|
|
300
|
+
|
|
301
|
+
Expected result not to have a structured response`}:{pass:Object.entries(t).every(([s,a])=>this.equals(i[s],a)),message:()=>`${r.matcherHint("toHaveStructuredResponse")}
|
|
302
|
+
|
|
303
|
+
Expected structured response: ${r.printExpected(t)}
|
|
304
|
+
Received structured response: ${r.printReceived(i)}`,actual:i,expected:t}}var VB={toBeHumanMessage:rC,toBeAIMessage:iC,toBeSystemMessage:sC,toBeToolMessage:aC,toHaveToolCalls:oC,toHaveToolCallCount:cC,toContainToolCall:uC,toHaveToolMessages:lC,toHaveBeenInterrupted:dC,toHaveStructuredResponse:pC};function KB(e){return e.map(t=>t.text).filter(Boolean).join("-")}var Fx=0;function WB(){return Fx+=1,`fake_tc_${Fx}`}var hC=class mC extends Ns{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}):Gt.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(n=>({name:n.name,args:n.args,id:n.id??WB(),type:"tool_call"}))}),this}alwaysThrow(t){return this._alwaysThrowError=t,this}structuredResponse(t){return this._structuredResponseValue=t,this}bindTools(t){let n=[...this._tools,...t],r=new mC;return r.queue=this.queue,r._alwaysThrowError=this._alwaysThrowError,r._structuredResponseValue=this._structuredResponseValue,r._tools=n,r._calls=this._calls,r._callIndex=this._callIndex,r.withConfig({})}withStructuredOutput(t,n){let{_structuredResponseValue:r}=this;return ir.from(async()=>r)}async _generate(t,n,r){this._calls.push({messages:[...t],options:n});let i=this._callIndex;if(this._callIndex+=1,this._alwaysThrowError)throw this._alwaysThrowError;let s=this.queue[i];if(!s)throw new Error(`FakeModel: no response queued for invocation ${i} (${this.queue.length} total queued).`);if(s.kind==="error")throw s.error;if(s.kind==="factory"){let o=s.factory(t);if(!Gt.isInstance(o))throw o;return{generations:[{text:"",message:o}]}}if(s.kind==="message")return{generations:[{text:"",message:s.message}]};let a=KB(t);return{generations:[{text:a,message:new Le({content:a,id:i.toString(),tool_calls:s.toolCalls.length>0?s.toolCalls.map(o=>({...o,type:"tool_call"})):void 0})}],llmOutput:{}}}};function GB(){return new hC}var XB=G({FakeBuiltModel:()=>hC,fakeModel:()=>GB,langchainMatchers:()=>VB,toBeAIMessage:()=>iC,toBeHumanMessage:()=>rC,toBeSystemMessage:()=>sC,toBeToolMessage:()=>aC,toContainToolCall:()=>uC,toHaveBeenInterrupted:()=>dC,toHaveStructuredResponse:()=>pC,toHaveToolCallCount:()=>cC,toHaveToolCalls:()=>oC,toHaveToolMessages:()=>lC});function xb(e){return e!==void 0&&Array.isArray(e.lc_namespace)}function $b(e){return e!==void 0&&Ae.isRunnable(e)&&"lc_name"in e.constructor&&typeof e.constructor.lc_name=="function"&&e.constructor.lc_name()==="RunnableToolLike"}function Ib(e){return!!e&&typeof e=="object"&&"name"in e&&"schema"in e&&(_n(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 $u(e){return Ib(e)||$b(e)||xb(e)}var YB=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Ch,gt:Oi,gte:an,includes:Th,length:mu,lowercase:Oh,lt:Si,lte:jn,maxLength:hu,maxSize:eo,mime:Nh,minLength:vs,minSize:Ai,multipleOf:Ea,negative:Bv,nonnegative:Jv,nonpositive:qv,normalize:Ph,overwrite:ti,positive:Zv,property:Hv,regex:Sh,size:pu,slugify:Uh,startsWith:Eh,toLowerCase:Rh,toUpperCase:Mh,trim:jh,uppercase:Ah},Symbol.toStringTag,{value:"Module"})),Sb=$("ZodISODateTime",(e,t)=>{XS.init(e,t),Be.init(e,t)});function fC(e){return oA(Sb,e)}var Ob=$("ZodISODate",(e,t)=>{YS.init(e,t),Be.init(e,t)});function gC(e){return cA(Ob,e)}var Ab=$("ZodISOTime",(e,t)=>{QS.init(e,t),Be.init(e,t)});function yC(e){return uA(Ab,e)}var Tb=$("ZodISODuration",(e,t)=>{eO.init(e,t),Be.init(e,t)});function _C(e){return lA(Tb,e)}var vC=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Ob,ZodISODateTime:Sb,ZodISODuration:Tb,ZodISOTime:Ab,date:gC,datetime:fC,duration:_C,time:yC},Symbol.toStringTag,{value:"Module"})),bC=(e,t)=>{H_.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>K_(e,n)},flatten:{value:n=>V_(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,kd,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,kd,2)}},isEmpty:{get(){return e.issues.length===0}}})},QB=$("ZodError",bC),Sn=$("ZodError",bC,{Parent:Error}),wC=ru(Sn),kC=iu(Sn),xC=su(Sn),$C=au(Sn),IC=G_(Sn),SC=X_(Sn),OC=Y_(Sn),AC=Q_(Sn),TC=ev(Sn),EC=tv(Sn),CC=nv(Sn),NC=rv(Sn),Zx=new WeakMap;function Iu(e,t,n){let r=Object.getPrototypeOf(e),i=Zx.get(r);if(i||(i=new Set,Zx.set(r,i)),!i.has(t)){i.add(t);for(let s in n){let a=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let o=a.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:o}),o},set(o){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:o})}})}}}var ye=$("ZodType",(e,t)=>(ge.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:dc(e,"input"),output:dc(e,"output")}}),e.toJSONSchema=FA(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>wC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>xC(e,n,r),e.parseAsync=async(n,r)=>kC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>$C(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>IC(e,n,r),e.decode=(n,r)=>SC(e,n,r),e.encodeAsync=async(n,r)=>OC(e,n,r),e.decodeAsync=async(n,r)=>AC(e,n,r),e.safeEncode=(n,r)=>TC(e,n,r),e.safeDecode=(n,r)=>EC(e,n,r),e.safeEncodeAsync=async(n,r)=>CC(e,n,r),e.safeDecodeAsync=async(n,r)=>NC(e,n,r),Iu(e,"ZodType",{check(...n){let r=this.def;return this.clone(Ar(r,{checks:[...r.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ut(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(_0(n,r))},superRefine(n,r){return this.check(v0(n,r))},overwrite(n){return this.check(ti(n))},optional(){return Sc(this)},exactOptional(){return Qb(this)},nullable(){return Oc(this)},nullish(){return Sc(Oc(this))},nonoptional(n){return s0(this,n)},array(){return vn(this)},or(n){return js([this,n])},and(n){return qb(this,n)},transform(n){return Dd(this,_m(n))},default(n){return n0(this,n)},prefault(n){return i0(this,n)},catch(n){return c0(this,n)},pipe(n){return Dd(this,n)},readonly(){return p0(this)},describe(n){let r=this.clone();return Ve.add(r,{description:n}),r},meta(...n){if(n.length===0)return Ve.get(this);let r=this.clone();return Ve.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Ve.get(e)?.description},configurable:!0}),e)),Xh=$("_ZodString",(e,t)=>{lu.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,s)=>ZA(e,r,i);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Iu(e,"_ZodString",{regex(...r){return this.check(Sh(...r))},includes(...r){return this.check(Th(...r))},startsWith(...r){return this.check(Eh(...r))},endsWith(...r){return this.check(Ch(...r))},min(...r){return this.check(vs(...r))},max(...r){return this.check(hu(...r))},length(...r){return this.check(mu(...r))},nonempty(...r){return this.check(vs(1,...r))},lowercase(r){return this.check(Oh(r))},uppercase(r){return this.check(Ah(r))},trim(){return this.check(jh())},normalize(...r){return this.check(Ph(...r))},toLowerCase(){return this.check(Rh())},toUpperCase(){return this.check(Mh())},slugify(){return this.check(Uh())}})}),Su=$("ZodString",(e,t)=>{lu.init(e,t),Xh.init(e,t),e.email=n=>e.check(bv(Yh,n)),e.url=n=>e.check(Ih(Ou,n)),e.jwt=n=>e.check(zv(hm,n)),e.emoji=n=>e.check(Iv(Qh,n)),e.guid=n=>e.check(Sd(Ic,n)),e.uuid=n=>e.check(wv(yr,n)),e.uuidv4=n=>e.check(kv(yr,n)),e.uuidv6=n=>e.check(xv(yr,n)),e.uuidv7=n=>e.check($v(yr,n)),e.nanoid=n=>e.check(Sv(em,n)),e.guid=n=>e.check(Sd(Ic,n)),e.cuid=n=>e.check(Ov(tm,n)),e.cuid2=n=>e.check(Av(nm,n)),e.ulid=n=>e.check(Tv(rm,n)),e.base64=n=>e.check(Mv(lm,n)),e.base64url=n=>e.check(Uv(dm,n)),e.xid=n=>e.check(Ev(im,n)),e.ksuid=n=>e.check(Cv(sm,n)),e.ipv4=n=>e.check(Nv(am,n)),e.ipv6=n=>e.check(Pv(om,n)),e.cidrv4=n=>e.check(jv(cm,n)),e.cidrv6=n=>e.check(Rv(um,n)),e.e164=n=>e.check(Lv(pm,n)),e.datetime=n=>e.check(fC(n)),e.date=n=>e.check(gC(n)),e.time=n=>e.check(yC(n)),e.duration=n=>e.check(_C(n))});function je(e){return rA(Su,e)}var Be=$("ZodStringFormat",(e,t)=>{Ze.init(e,t),Xh.init(e,t)}),Yh=$("ZodEmail",(e,t)=>{ZS.init(e,t),Be.init(e,t)});function PC(e){return bv(Yh,e)}var Ic=$("ZodGUID",(e,t)=>{DS.init(e,t),Be.init(e,t)});function jC(e){return Sd(Ic,e)}var yr=$("ZodUUID",(e,t)=>{FS.init(e,t),Be.init(e,t)});function RC(e){return wv(yr,e)}function MC(e){return kv(yr,e)}function UC(e){return xv(yr,e)}function LC(e){return $v(yr,e)}var Ou=$("ZodURL",(e,t)=>{BS.init(e,t),Be.init(e,t)});function zC(e){return Ih(Ou,e)}function DC(e){return Ih(Ou,{protocol:sv,hostname:iS,...P(e)})}var Qh=$("ZodEmoji",(e,t)=>{qS.init(e,t),Be.init(e,t)});function FC(e){return Iv(Qh,e)}var em=$("ZodNanoID",(e,t)=>{JS.init(e,t),Be.init(e,t)});function ZC(e){return Sv(em,e)}var tm=$("ZodCUID",(e,t)=>{HS.init(e,t),Be.init(e,t)});function BC(e){return Ov(tm,e)}var nm=$("ZodCUID2",(e,t)=>{VS.init(e,t),Be.init(e,t)});function qC(e){return Av(nm,e)}var rm=$("ZodULID",(e,t)=>{KS.init(e,t),Be.init(e,t)});function JC(e){return Tv(rm,e)}var im=$("ZodXID",(e,t)=>{WS.init(e,t),Be.init(e,t)});function HC(e){return Ev(im,e)}var sm=$("ZodKSUID",(e,t)=>{GS.init(e,t),Be.init(e,t)});function VC(e){return Cv(sm,e)}var am=$("ZodIPv4",(e,t)=>{tO.init(e,t),Be.init(e,t)});function KC(e){return Nv(am,e)}var Eb=$("ZodMAC",(e,t)=>{rO.init(e,t),Be.init(e,t)});function WC(e){return sA(Eb,e)}var om=$("ZodIPv6",(e,t)=>{nO.init(e,t),Be.init(e,t)});function GC(e){return Pv(om,e)}var cm=$("ZodCIDRv4",(e,t)=>{iO.init(e,t),Be.init(e,t)});function XC(e){return jv(cm,e)}var um=$("ZodCIDRv6",(e,t)=>{sO.init(e,t),Be.init(e,t)});function YC(e){return Rv(um,e)}var lm=$("ZodBase64",(e,t)=>{aO.init(e,t),Be.init(e,t)});function QC(e){return Mv(lm,e)}var dm=$("ZodBase64URL",(e,t)=>{cO.init(e,t),Be.init(e,t)});function eN(e){return Uv(dm,e)}var pm=$("ZodE164",(e,t)=>{uO.init(e,t),Be.init(e,t)});function tN(e){return Lv(pm,e)}var hm=$("ZodJWT",(e,t)=>{dO.init(e,t),Be.init(e,t)});function nN(e){return zv(hm,e)}var io=$("ZodCustomStringFormat",(e,t)=>{pO.init(e,t),Be.init(e,t)});function rN(e,t,n={}){return fu(io,e,t,n)}function iN(e){return fu(io,"hostname",rS,e)}function sN(e){return fu(io,"hex",vS,e)}function aN(e,t){let n=t?.enc??"hex",r=`${e}_${n}`,i=ov[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return fu(io,r,i,t)}var Au=$("ZodNumber",(e,t)=>{dv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,s)=>BA(e,r,i),Iu(e,"ZodNumber",{gt(r,i){return this.check(Oi(r,i))},gte(r,i){return this.check(an(r,i))},min(r,i){return this.check(an(r,i))},lt(r,i){return this.check(Si(r,i))},lte(r,i){return this.check(jn(r,i))},max(r,i){return this.check(jn(r,i))},int(r){return this.check(zd(r))},safe(r){return this.check(zd(r))},positive(r){return this.check(Oi(0,r))},nonnegative(r){return this.check(an(0,r))},negative(r){return this.check(Si(0,r))},nonpositive(r){return this.check(jn(0,r))},multipleOf(r,i){return this.check(Ea(r,i))},step(r,i){return this.check(Ea(r,i))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function at(e){return dA(Au,e)}var Ps=$("ZodNumberFormat",(e,t)=>{hO.init(e,t),Au.init(e,t)});function zd(e){return hA(Ps,e)}function oN(e){return mA(Ps,e)}function cN(e){return fA(Ps,e)}function uN(e){return gA(Ps,e)}function lN(e){return yA(Ps,e)}var Tu=$("ZodBoolean",(e,t)=>{pv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qA(e,n,r)});function Cb(e){return _A(Tu,e)}var Eu=$("ZodBigInt",(e,t)=>{hv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,s)=>JA(e,r),e.gte=(r,i)=>e.check(an(r,i)),e.min=(r,i)=>e.check(an(r,i)),e.gt=(r,i)=>e.check(Oi(r,i)),e.gte=(r,i)=>e.check(an(r,i)),e.min=(r,i)=>e.check(an(r,i)),e.lt=(r,i)=>e.check(Si(r,i)),e.lte=(r,i)=>e.check(jn(r,i)),e.max=(r,i)=>e.check(jn(r,i)),e.positive=r=>e.check(Oi(BigInt(0),r)),e.negative=r=>e.check(Si(BigInt(0),r)),e.nonpositive=r=>e.check(jn(BigInt(0),r)),e.nonnegative=r=>e.check(an(BigInt(0),r)),e.multipleOf=(r,i)=>e.check(Ea(r,i));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function dN(e){return bA(Eu,e)}var mm=$("ZodBigIntFormat",(e,t)=>{mO.init(e,t),Eu.init(e,t)});function pN(e){return kA(mm,e)}function hN(e){return xA(mm,e)}var Nb=$("ZodSymbol",(e,t)=>{fO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>HA(e,n)});function mN(e){return $A(Nb,e)}var Pb=$("ZodUndefined",(e,t)=>{gO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>KA(e,n)});function fN(e){return IA(Pb,e)}var jb=$("ZodNull",(e,t)=>{yO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VA(e,n,r)});function Rb(e){return SA(jb,e)}var Mb=$("ZodAny",(e,t)=>{_O.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>XA()});function ua(){return OA(Mb)}var Ub=$("ZodUnknown",(e,t)=>{mv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>YA()});function ws(){return Dv(Ub)}var Lb=$("ZodNever",(e,t)=>{fv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>GA(e,n,r)});function fm(e){return Fv(Lb,e)}var zb=$("ZodVoid",(e,t)=>{vO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>WA(e,n)});function gN(e){return AA(zb,e)}var gm=$("ZodDate",(e,t)=>{bO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,s)=>QA(e,r),e.min=(r,i)=>e.check(an(r,i)),e.max=(r,i)=>e.check(jn(r,i));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function yN(e){return TA(gm,e)}var Db=$("ZodArray",(e,t)=>{wO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dT(e,n,r,i),e.element=t.element,Iu(e,"ZodArray",{min(n,r){return this.check(vs(n,r))},nonempty(n){return this.check(vs(1,n))},max(n,r){return this.check(hu(n,r))},length(n,r){return this.check(mu(n,r))},unwrap(){return this.element}})});function vn(e,t){return NA(Db,e,t)}function _N(e){let t=e._zod.def.shape;return so(Object.keys(t))}var Cu=$("ZodObject",(e,t)=>{IO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pT(e,n,r,i),$e(e,"shape",()=>t.shape),Iu(e,"ZodObject",{keyof(){return so(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:ws()})},loose(){return this.clone({...this._zod.def,catchall:ws()})},strict(){return this.clone({...this._zod.def,catchall:fm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return q_(this,n)},safeExtend(n){return AI(this,n)},merge(n){return TI(this,n)},pick(n){return SI(this,n)},omit(n){return OI(this,n)},partial(...n){return J_(vm,this,n[0])},required(...n){return EI(bm,this,n[0])}})});function Qe(e,t){let n={type:"object",shape:e??{},...P(t)};return new Cu(n)}function vN(e,t){return new Cu({type:"object",shape:e,catchall:fm(),...P(t)})}function bN(e,t){return new Cu({type:"object",shape:e,catchall:ws(),...P(t)})}var Nu=$("ZodUnion",(e,t)=>{$h.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r,i),e.options=t.options});function js(e,t){return new Nu({type:"union",options:e,...P(t)})}var Fb=$("ZodXor",(e,t)=>{Nu.init(e,t),SO.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r,i),e.options=t.options});function wN(e,t){return new Fb({type:"union",options:e,inclusive:!1,...P(t)})}var Zb=$("ZodDiscriminatedUnion",(e,t)=>{Nu.init(e,t),OO.init(e,t)});function kN(e,t,n){return new Zb({type:"union",options:t,discriminator:e,...P(n)})}var Bb=$("ZodIntersection",(e,t)=>{AO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hT(e,n,r,i)});function qb(e,t){return new Bb({type:"intersection",left:e,right:t})}var Jb=$("ZodTuple",(e,t)=>{gv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mT(e,n,r,i),e.rest=n=>e.clone({...e._zod.def,rest:n})});function Hb(e,t,n){let r=t instanceof ge,i=r?n:t,s=r?t:null;return new Jb({type:"tuple",items:e,rest:s,...P(i)})}var Da=$("ZodRecord",(e,t)=>{TO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fT(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ym(e,t,n){return!t||!t._zod?new Da({type:"record",keyType:je(),valueType:e,...P(t)}):new Da({type:"record",keyType:e,valueType:t,...P(n)})}function xN(e,t,n){let r=ut(e);return r._zod.values=void 0,new Da({type:"record",keyType:r,valueType:t,...P(n)})}function $N(e,t,n){return new Da({type:"record",keyType:e,valueType:t,mode:"loose",...P(n)})}var Vb=$("ZodMap",(e,t)=>{EO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uT(e,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Ai(...n)),e.nonempty=n=>e.check(Ai(1,n)),e.max=(...n)=>e.check(eo(...n)),e.size=(...n)=>e.check(pu(...n))});function IN(e,t,n){return new Vb({type:"map",keyType:e,valueType:t,...P(n)})}var Kb=$("ZodSet",(e,t)=>{CO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lT(e,n),e.min=(...n)=>e.check(Ai(...n)),e.nonempty=n=>e.check(Ai(1,n)),e.max=(...n)=>e.check(eo(...n)),e.size=(...n)=>e.check(pu(...n))});function SN(e,t){return new Kb({type:"set",valueType:e,...P(t)})}var Fa=$("ZodEnum",(e,t)=>{NO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,s)=>eT(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{let s={};for(let a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Fa({...t,checks:[],...P(i),entries:s})},e.exclude=(r,i)=>{let s={...t.entries};for(let a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new Fa({...t,checks:[],...P(i),entries:s})}});function so(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Fa({type:"enum",entries:n,...P(t)})}function ON(e,t){return new Fa({type:"enum",entries:e,...P(t)})}var Wb=$("ZodLiteral",(e,t)=>{PO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tT(e,n,r),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 bt(e,t){return new Wb({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}var Gb=$("ZodFile",(e,t)=>{jO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>iT(e,n,r),e.min=(n,r)=>e.check(Ai(n,r)),e.max=(n,r)=>e.check(eo(n,r)),e.mime=(n,r)=>e.check(Nh(Array.isArray(n)?n:[n],r))});function AN(e){return PA(Gb,e)}var Xb=$("ZodTransform",(e,t)=>{RO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cT(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Sa(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Aa(s,n.value,t));else{let a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Aa(a))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function _m(e){return new Xb({type:"transform",transform:e})}var vm=$("ZodOptional",(e,t)=>{du.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new vm({type:"optional",innerType:e})}var Yb=$("ZodExactOptional",(e,t)=>{MO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Qb(e){return new Yb({type:"optional",innerType:e})}var e0=$("ZodNullable",(e,t)=>{UO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Oc(e){return new e0({type:"nullable",innerType:e})}function TN(e){return Sc(Oc(e))}var t0=$("ZodDefault",(e,t)=>{LO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_T(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function n0(e,t){return new t0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():wh(t)}})}var r0=$("ZodPrefault",(e,t)=>{zO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function i0(e,t){return new r0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():wh(t)}})}var bm=$("ZodNonOptional",(e,t)=>{DO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function s0(e,t){return new bm({type:"nonoptional",innerType:e,...P(t)})}var a0=$("ZodSuccess",(e,t)=>{FO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sT(e,n,r),e.unwrap=()=>e._zod.def.innerType});function EN(e){return new a0({type:"success",innerType:e})}var o0=$("ZodCatch",(e,t)=>{ZO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function c0(e,t){return new o0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var u0=$("ZodNaN",(e,t)=>{BO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nT(e,n)});function CN(e){return CA(u0,e)}var Pu=$("ZodPipe",(e,t)=>{yv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wT(e,n,r,i),e.in=t.in,e.out=t.out});function Dd(e,t){return new Pu({type:"pipe",in:e,out:t})}var ju=$("ZodCodec",(e,t)=>{Pu.init(e,t),_v.init(e,t)});function NN(e,t,n){return new ju({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function PN(e){let t=e._zod.def;return new ju({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var l0=$("ZodPreprocess",(e,t)=>{Pu.init(e,t),qO.init(e,t)}),d0=$("ZodReadonly",(e,t)=>{JO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function p0(e){return new d0({type:"readonly",innerType:e})}var h0=$("ZodTemplateLiteral",(e,t)=>{HO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rT(e,n,r)});function jN(e,t){return new h0({type:"template_literal",parts:e,...P(t)})}var m0=$("ZodLazy",(e,t)=>{WO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$T(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function f0(e){return new m0({type:"lazy",getter:e})}var g0=$("ZodPromise",(e,t)=>{KO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xT(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function RN(e){return new g0({type:"promise",innerType:e})}var y0=$("ZodFunction",(e,t)=>{VO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oT(e,n)});function Fd(e){return new y0({type:"function",input:Array.isArray(e?.input)?Hb(e?.input):e?.input??vn(ws()),output:e?.output??ws()})}var Ru=$("ZodCustom",(e,t)=>{GO.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aT(e,n)});function MN(e){let t=new et({check:"custom"});return t._zod.check=e,t}function Zd(e,t){return jA(Ru,e??(()=>!0),t)}function _0(e,t={}){return RA(Ru,e,t)}function v0(e,t){return MA(e,t)}var UN=LA,LN=zA;function zN(e,t={}){let n=new Ru({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...P(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var DN=(...e)=>DA({Codec:ju,Boolean:Tu,String:Su},...e);function FN(e){let t=f0(()=>js([je(e),at(),Cb(),Rb(),vn(t),ym(je(),t)]));return t}function ZN(e,t){return new l0({type:"pipe",in:_m(e),out:t})}var e8=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Mb,ZodArray:Db,ZodBase64:lm,ZodBase64URL:dm,ZodBigInt:Eu,ZodBigIntFormat:mm,ZodBoolean:Tu,ZodCIDRv4:cm,ZodCIDRv6:um,ZodCUID:tm,ZodCUID2:nm,ZodCatch:o0,ZodCodec:ju,ZodCustom:Ru,ZodCustomStringFormat:io,ZodDate:gm,ZodDefault:t0,ZodDiscriminatedUnion:Zb,ZodE164:pm,ZodEmail:Yh,ZodEmoji:Qh,ZodEnum:Fa,ZodExactOptional:Yb,ZodFile:Gb,ZodFunction:y0,ZodGUID:Ic,ZodIPv4:am,ZodIPv6:om,ZodIntersection:Bb,ZodJWT:hm,ZodKSUID:sm,ZodLazy:m0,ZodLiteral:Wb,ZodMAC:Eb,ZodMap:Vb,ZodNaN:u0,ZodNanoID:em,ZodNever:Lb,ZodNonOptional:bm,ZodNull:jb,ZodNullable:e0,ZodNumber:Au,ZodNumberFormat:Ps,ZodObject:Cu,ZodOptional:vm,ZodPipe:Pu,ZodPrefault:r0,ZodPreprocess:l0,ZodPromise:g0,ZodReadonly:d0,ZodRecord:Da,ZodSet:Kb,ZodString:Su,ZodStringFormat:Be,ZodSuccess:a0,ZodSymbol:Nb,ZodTemplateLiteral:h0,ZodTransform:Xb,ZodTuple:Jb,ZodType:ye,ZodULID:rm,ZodURL:Ou,ZodUUID:yr,ZodUndefined:Pb,ZodUnion:Nu,ZodUnknown:Ub,ZodVoid:zb,ZodXID:im,ZodXor:Fb,_ZodString:Xh,_default:n0,_function:Fd,any:ua,array:vn,base64:QC,base64url:eN,bigint:dN,boolean:Cb,catch:c0,check:MN,cidrv4:XC,cidrv6:YC,codec:NN,cuid:BC,cuid2:qC,custom:Zd,date:yN,describe:UN,discriminatedUnion:kN,e164:tN,email:PC,emoji:FC,enum:so,exactOptional:Qb,file:AN,float32:oN,float64:cN,function:Fd,guid:jC,hash:aN,hex:sN,hostname:iN,httpUrl:DC,instanceof:zN,int:zd,int32:uN,int64:pN,intersection:qb,invertCodec:PN,ipv4:KC,ipv6:GC,json:FN,jwt:nN,keyof:_N,ksuid:VC,lazy:f0,literal:bt,looseObject:bN,looseRecord:$N,mac:WC,map:IN,meta:LN,nan:CN,nanoid:ZC,nativeEnum:ON,never:fm,nonoptional:s0,null:Rb,nullable:Oc,nullish:TN,number:at,object:Qe,optional:Sc,partialRecord:xN,pipe:Dd,prefault:i0,preprocess:ZN,promise:RN,readonly:p0,record:ym,refine:_0,set:SN,strictObject:vN,string:je,stringFormat:rN,stringbool:DN,success:EN,superRefine:v0,symbol:mN,templateLiteral:jN,transform:_m,tuple:Hb,uint32:lN,uint64:hN,ulid:JC,undefined:fN,union:js,unknown:ws,url:zC,uuid:RC,uuidv4:MC,uuidv6:UC,uuidv7:LC,void:gN,xid:HC,xor:wN},Symbol.toStringTag,{value:"Module"})),t8={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 n8(e){Rt({customError:e})}function r8(){return Rt().customError}var wy;wy||(wy={});var q={...e8,...YB,iso:vC},i8=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 s8(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function a8(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){let i=n[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 BN(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return q.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 q.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);let s=a8(i,t),a=zt(s,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 q.null();if(i.length===0)return q.never();if(i.length===1)return q.literal(i[0]);if(i.every(a=>typeof a=="string"))return q.enum(i);let s=i.map(a=>q.literal(a));return s.length<2?s[0]:q.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return q.literal(e.const);let n=e.type;if(Array.isArray(n)){let i=n.map(s=>{let a={...e,type:s};return BN(a,t)});return i.length===0?q.never():i.length===1?i[0]:q.union(i)}if(!n)return q.any();let r;switch(n){case"string":{let i=q.string();if(e.format){let s=e.format;s==="email"?i=i.check(q.email()):s==="uri"||s==="uri-reference"?i=i.check(q.url()):s==="uuid"||s==="guid"?i=i.check(q.uuid()):s==="date-time"?i=i.check(q.iso.datetime()):s==="date"?i=i.check(q.iso.date()):s==="time"?i=i.check(q.iso.time()):s==="duration"?i=i.check(q.iso.duration()):s==="ipv4"?i=i.check(q.ipv4()):s==="ipv6"?i=i.check(q.ipv6()):s==="mac"?i=i.check(q.mac()):s==="cidr"?i=i.check(q.cidrv4()):s==="cidr-v6"?i=i.check(q.cidrv6()):s==="base64"?i=i.check(q.base64()):s==="base64url"?i=i.check(q.base64url()):s==="e164"?i=i.check(q.e164()):s==="jwt"?i=i.check(q.jwt()):s==="emoji"?i=i.check(q.emoji()):s==="nanoid"?i=i.check(q.nanoid()):s==="cuid"?i=i.check(q.cuid()):s==="cuid2"?i=i.check(q.cuid2()):s==="ulid"?i=i.check(q.ulid()):s==="xid"?i=i.check(q.xid()):s==="ksuid"&&(i=i.check(q.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))),r=i;break}case"number":case"integer":{let i=n==="integer"?q.number().int():q.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)),r=i;break}case"boolean":{r=q.boolean();break}case"null":{r=q.null();break}case"object":{let i={},s=e.properties||{},a=new Set(e.required||[]);for(let[c,u]of Object.entries(s)){let l=zt(u,t);i[c]=a.has(c)?l:l.optional()}if(e.propertyNames){let c=zt(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?zt(e.additionalProperties,t):q.any();if(Object.keys(i).length===0){r=q.record(c,u);break}let l=q.object(i).passthrough(),d=q.looseRecord(c,u);r=q.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let h=zt(c[p],t),m=q.string().regex(new RegExp(p));l.push(q.looseRecord(m,h))}let d=[];if(Object.keys(i).length>0&&d.push(q.object(i).passthrough()),d.push(...l),d.length===0)r=q.object({}).passthrough();else if(d.length===1)r=d[0];else{let p=q.intersection(d[0],d[1]);for(let h=2;h<d.length;h++)p=q.intersection(p,d[h]);r=p}break}let o=q.object(i);e.additionalProperties===!1?r=o.strict():typeof e.additionalProperties=="object"?r=o.catchall(zt(e.additionalProperties,t)):r=o.passthrough();break}case"array":{let i=e.prefixItems,s=e.items;if(i&&Array.isArray(i)){let a=i.map(c=>zt(c,t)),o=s&&typeof s=="object"&&!Array.isArray(s)?zt(s,t):void 0;o?r=q.tuple(a).rest(o):r=q.tuple(a),typeof e.minItems=="number"&&(r=r.check(q.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(q.maxLength(e.maxItems)))}else if(Array.isArray(s)){let a=s.map(c=>zt(c,t)),o=e.additionalItems&&typeof e.additionalItems=="object"?zt(e.additionalItems,t):void 0;o?r=q.tuple(a).rest(o):r=q.tuple(a),typeof e.minItems=="number"&&(r=r.check(q.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(q.maxLength(e.maxItems)))}else if(s!==void 0){let a=zt(s,t),o=q.array(a);typeof e.minItems=="number"&&(o=o.min(e.minItems)),typeof e.maxItems=="number"&&(o=o.max(e.maxItems)),r=o}else r=q.array(q.any());break}default:throw new Error(`Unsupported type: ${n}`)}return r}function zt(e,t){if(typeof e=="boolean")return e?q.any():q.never();let n=BN(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let o=e.anyOf.map(u=>zt(u,t)),c=q.union(o);n=r?q.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let o=e.oneOf.map(u=>zt(u,t)),c=q.xor(o);n=r?q.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:q.any();else{let o=r?n:zt(e.allOf[0],t),c=r?0:1;for(let u=c;u<e.allOf.length;u++)o=q.intersection(o,zt(e.allOf[u],t));n=o}e.nullable===!0&&t.version==="openapi-3.0"&&(n=q.nullable(n)),e.readOnly===!0&&(n=q.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let o of s)o in e&&(i[o]=e[o]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let o of a)o in e&&(i[o]=e[o]);for(let o of Object.keys(e))i8.has(o)||(i[o]=e[o]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function o8(e,t){if(typeof e=="boolean")return e?q.any():q.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=s8(n,t?.defaultTarget),i=n.$defs||n.definitions||{},s={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Ve};return zt(n,s)}function c8(e){return iA(Su,e)}function u8(e){return pA(Au,e)}function l8(e){return vA(Tu,e)}function d8(e){return wA(Eu,e)}function p8(e){return EA(gm,e)}var h8=Object.freeze(Object.defineProperty({__proto__:null,bigint:d8,boolean:l8,date:p8,number:u8,string:c8},Symbol.toStringTag,{value:"Module"}));Rt(XO());var W=Object.freeze(Object.defineProperty({__proto__:null,$brand:_I,$input:nA,$output:tA,NEVER:yI,TimePrecision:aA,ZodAny:Mb,ZodArray:Db,ZodBase64:lm,ZodBase64URL:dm,ZodBigInt:Eu,ZodBigIntFormat:mm,ZodBoolean:Tu,ZodCIDRv4:cm,ZodCIDRv6:um,ZodCUID:tm,ZodCUID2:nm,ZodCatch:o0,ZodCodec:ju,ZodCustom:Ru,ZodCustomStringFormat:io,ZodDate:gm,ZodDefault:t0,ZodDiscriminatedUnion:Zb,ZodE164:pm,ZodEmail:Yh,ZodEmoji:Qh,ZodEnum:Fa,ZodError:QB,ZodExactOptional:Yb,ZodFile:Gb,get ZodFirstPartyTypeKind(){return wy},ZodFunction:y0,ZodGUID:Ic,ZodIPv4:am,ZodIPv6:om,ZodISODate:Ob,ZodISODateTime:Sb,ZodISODuration:Tb,ZodISOTime:Ab,ZodIntersection:Bb,ZodIssueCode:t8,ZodJWT:hm,ZodKSUID:sm,ZodLazy:m0,ZodLiteral:Wb,ZodMAC:Eb,ZodMap:Vb,ZodNaN:u0,ZodNanoID:em,ZodNever:Lb,ZodNonOptional:bm,ZodNull:jb,ZodNullable:e0,ZodNumber:Au,ZodNumberFormat:Ps,ZodObject:Cu,ZodOptional:vm,ZodPipe:Pu,ZodPrefault:r0,ZodPreprocess:l0,ZodPromise:g0,ZodReadonly:d0,ZodRealError:Sn,ZodRecord:Da,ZodSet:Kb,ZodString:Su,ZodStringFormat:Be,ZodSuccess:a0,ZodSymbol:Nb,ZodTemplateLiteral:h0,ZodTransform:Xb,ZodTuple:Jb,ZodType:ye,ZodULID:rm,ZodURL:Ou,ZodUUID:yr,ZodUndefined:Pb,ZodUnion:Nu,ZodUnknown:Ub,ZodVoid:zb,ZodXID:im,ZodXor:Fb,_ZodString:Xh,_default:n0,_function:Fd,any:ua,array:vn,base64:QC,base64url:eN,bigint:dN,boolean:Cb,catch:c0,check:MN,cidrv4:XC,cidrv6:YC,clone:ut,codec:NN,coerce:h8,config:Rt,core:f9,cuid:BC,cuid2:qC,custom:Zd,date:yN,decode:SC,decodeAsync:AC,describe:UN,discriminatedUnion:kN,e164:tN,email:PC,emoji:FC,encode:IC,encodeAsync:OC,endsWith:Ch,enum:so,exactOptional:Qb,file:AN,flattenError:V_,float32:oN,float64:cN,formatError:K_,fromJSONSchema:o8,function:Fd,getErrorMap:r8,globalRegistry:Ve,gt:Oi,gte:an,guid:jC,hash:aN,hex:sN,hostname:iN,httpUrl:DC,includes:Th,instanceof:zN,int:zd,int32:uN,int64:pN,intersection:qb,invertCodec:PN,ipv4:KC,ipv6:GC,iso:vC,json:FN,jwt:nN,keyof:_N,ksuid:VC,lazy:f0,length:mu,literal:bt,locales:eA,looseObject:bN,looseRecord:$N,lowercase:Oh,lt:Si,lte:jn,mac:WC,map:IN,maxLength:hu,maxSize:eo,meta:LN,mime:Nh,minLength:vs,minSize:Ai,multipleOf:Ea,nan:CN,nanoid:ZC,nativeEnum:ON,negative:Bv,never:fm,nonnegative:Jv,nonoptional:s0,nonpositive:qv,normalize:Ph,null:Rb,nullable:Oc,nullish:TN,number:at,object:Qe,optional:Sc,overwrite:ti,parse:wC,parseAsync:kC,partialRecord:xN,pipe:Dd,positive:Zv,prefault:i0,preprocess:ZN,prettifyError:W_,promise:RN,property:Hv,readonly:p0,record:ym,refine:_0,regex:Sh,regexes:ov,registry:vv,safeDecode:EC,safeDecodeAsync:NC,safeEncode:TC,safeEncodeAsync:CC,safeParse:xC,safeParseAsync:$C,set:SN,setErrorMap:n8,size:pu,slugify:Uh,startsWith:Eh,strictObject:vN,string:je,stringFormat:rN,stringbool:DN,success:EN,superRefine:v0,symbol:mN,templateLiteral:jN,toJSONSchema:pc,toLowerCase:Rh,toUpperCase:Mh,transform:_m,treeifyError:MI,trim:jh,tuple:Hb,uint32:lN,uint64:hN,ulid:JC,undefined:fN,union:js,unknown:ws,uppercase:Ah,url:zC,util:jI,uuid:RC,uuidv4:MC,uuidv6:UC,uuidv7:LC,void:gN,xid:HC,xor:wN},Symbol.toStringTag,{value:"Module"})),m8=G({BaseToolkit:()=>f8,DynamicStructuredTool:()=>HN,DynamicTool:()=>JN,StructuredTool:()=>wm,Tool:()=>qN,ToolInputParsingException:()=>pd,isLangChainTool:()=>$u,isRunnableToolLike:()=>$b,isStructuredTool:()=>xb,isStructuredToolParams:()=>Ib,tool:()=>g8}),wm=class extends cb{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 n,r=Te(Nn(this.defaultConfig,t));return qo(e)?(n=e.args,r={...r,toolCall:e}):n=e,this.call(n,r)}async call(e,t,n){let r=qo(e)?e.args:e,i;if(_n(this.schema))try{i=await Lh(this.schema,r)}catch(h){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
305
|
+
Details: ${h.message}`),NT(h)&&(m=`${m}
|
|
306
|
+
|
|
307
|
+
${W_(h)}`),new pd(m,JSON.stringify(e))}else{let h=Xe(r,this.schema);if(!h.valid){let m="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(m=`${m}
|
|
308
|
+
Details: ${h.errors.map(f=>`${f.keywordLocation}: ${f.error}`).join(`
|
|
309
|
+
`)}`),new pd(m,JSON.stringify(e))}i=r}let s=Qc(t),a=Ft.configure(s.callbacks,this.callbacks,s.tags||n,this.tags,s.metadata,this.metadata,{verbose:this.verbose}),o;qo(e)&&(o=e.id),!o&&xR(s)&&(o=s.toolCall.id);let c=await a?.handleToolStart(this.toJSON(),typeof e=="string"?e:JSON.stringify(e),s.runId,void 0,void 0,void 0,s.runName,o);delete s.runId;let u;try{let h=await this._call(i,c,s);u=GT(h)?await kF(h,async m=>{try{await c?.handleToolEvent(m)}catch(f){await c?.handleToolError(f)}}):h}catch(h){throw await c?.handleToolError(h),h}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.
|
|
310
|
+
Result: ${JSON.stringify(u)}`);else l=u;let p=y8({content:l,artifact:d,toolCallId:o,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(p),p}},qN=class extends wm{schema=tt({input:lt().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let n=typeof e=="string"||e==null?{input:e}:e;return super.call(n,t)}},JN=class extends qN{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 n=Qc(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n)}_call(e,t,n){return this.func(e,t,n)}},HN=class extends wm{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,n){let r=Qc(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r,n)}_call(e,t,n){return this.func(e,t,n)}},f8=class{getTools(){return this.tools}};function g8(e,t){let n=Wv(t.schema),r=Ho(t.schema);if(!t.schema||n||r)return new JN({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(a,o,c)=>new Promise((u,l)=>{let d=Re(c,{callbacks:o?.getChild()});jt.runWithConfig(Kr(d),async()=>{try{u(e(a,d))}catch(p){l(p)}})})});let i=t.schema,s=t.description??t.schema.description??`${t.name} tool`;return new HN({...t,description:s,schema:i,func:async(a,o,c)=>new Promise((u,l)=>{let d,p=()=>{c?.signal&&d&&c.signal.removeEventListener("abort",d)};c?.signal&&(d=()=>{p(),l(sc(c.signal))},c.signal.addEventListener("abort",d,{once:!0}));let h=Re(c,{callbacks:o?.getChild()});jt.runWithConfig(Kr(h),async()=>{try{let m=await e(a,h);if(GT(m)){u(m);return}if(c?.signal?.aborted){p();return}p(),u(m)}catch(m){p(),l(m)}})})})}function y8(e){let{content:t,artifact:n,toolCallId:r,metadata:i}=e;return r&&!I_(t)?typeof t=="string"||Array.isArray(t)&&t.every(s=>typeof s=="object")?new Mn({status:"success",content:t,artifact:n,tool_call_id:r,name:e.name,metadata:i}):new Mn({status:"success",content:_8(t),artifact:n,tool_call_id:r,name:e.name,metadata:i}):t}function _8(e){try{return JSON.stringify(e)??""}catch{return`${e}`}}var v8=G({RunCollectorCallbackHandler:()=>b8}),b8=class extends ei{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)}},w8=G({}),k8=G({chunkArray:()=>VN}),VN=(e,t)=>e.reduce((n,r,i)=>{let s=Math.floor(i/t);return n[s]=(n[s]||[]).concat([r]),n},[]),x8=G({context:()=>$8});function $8(e,...t){let n=e.raw,r="";for(let i=0;i<n.length;i++){let s=n[i].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(r+=s,i<t.length){let a=I8(t[i],r);r+=typeof a=="string"?a:JSON.stringify(a)}}return r=S8(r),r=r.trim(),r=r.replace(/\\n/g,`
|
|
311
|
+
`),r}function I8(e,t){if(typeof e!="string"||!e.includes(`
|
|
312
|
+
`))return e;let n=t.slice(t.lastIndexOf(`
|
|
313
|
+
`)+1).match(/^(\s+)/);if(n){let r=n[1];return e.replace(/\n/g,`
|
|
314
|
+
${r}`)}return e}function S8(e){let t=e.split(`
|
|
315
|
+
`),n=null;for(let r of t){let i=r.match(/^(\s+)\S+/);if(i){let s=i[1].length;n===null?n=s:n=Math.min(n,s)}}return n===null?e:t.map(r=>r[0]===" "||r[0]===" "?r.slice(n):r).join(`
|
|
316
|
+
`)}var O8=G({EventStreamContentType:()=>A8,convertEventStreamToIterableReadableDataStream:()=>E8,getBytes:()=>KN,getLines:()=>WN,getMessages:()=>GN}),A8="text/event-stream";async function KN(e,t){if(e instanceof ReadableStream){let n=e.getReader();for(;;){let r=await n.read();if(r.done){t(new Uint8Array,!0);break}t(r.value)}}else try{for await(let n of e)t(new Uint8Array(n));t(new Uint8Array,!0)}catch(n){throw new Error(["Parsing event source stream failed.","Ensure your implementation of fetch returns a web or Node readable stream.",`Error: ${n.message}`].join(`
|
|
317
|
+
`))}}function WN(e){let t,n,r,i=!1;return function(s,a){if(a){e(s,0,!0);return}t===void 0?(t=s,n=0,r=-1):t=T8(t,s);let o=t.length,c=0;for(;n<o;){i&&(t[n]===10&&(c=++n),i=!1);let u=-1;for(;n<o&&u===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-c);break;case 13:i=!0;case 10:u=n;break}if(u===-1)break;e(t.subarray(c,u),r),c=n,r=-1}c===o?t=void 0:c!==0&&(t=t.subarray(c),n-=c)}}function GN(e,t,n){let r=$f(),i=new TextDecoder;return function(s,a,o){if(o){C8(r)||(e?.(r),r=$f());return}if(s.length===0)e?.(r),r=$f();else if(a>0){let c=i.decode(s.subarray(0,a)),u=a+(s[a+1]===32?2:1),l=i.decode(s.subarray(u));switch(c){case"data":r.data=r.data?r.data+`
|
|
318
|
+
`+l:l;break;case"event":r.event=l;break;case"id":t?.(r.id=l);break;case"retry":{let d=parseInt(l,10);Number.isNaN(d)||n?.(r.retry=d);break}}}}}function T8(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function $f(){return{data:"",event:"",id:"",retry:void 0}}function E8(e,t){let n=new ReadableStream({async start(r){let i=GN(s=>{if(s.event==="error")throw new Error(s.data??"Unspecified event streaming error.");s.event==="metadata"?t?.(s):s.data&&r.enqueue(s.data)});await KN(e,WN((s,a,o)=>{i(s,a,o),o&&r.close()}))}});return un.fromReadableStream(n)}function C8(e){return e.data===""&&e.event===""&&e.id===""&&e.retry===void 0}var N8=G({}),P8=G({convertToOpenAIFunction:()=>XN,convertToOpenAITool:()=>YN,isLangChainTool:()=>$u,isRunnableToolLike:()=>$b,isStructuredTool:()=>xb,isStructuredToolParams:()=>Ib});function XN(e,t){let n=typeof t=="number"?void 0:t;return{name:e.name,description:e.description,parameters:xt(e.schema),...n?.strict!==void 0?{strict:n.strict}:{}}}function YN(e,t){let n=typeof t=="number"?void 0:t,r;return $u(e)?r={type:"function",function:XN(e)}:r=e,n?.strict!==void 0&&(r.function.strict=n.strict),r}function QN(e,t){let n=0,r=0,i=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s],r+=e[s]*e[s],i+=t[s]*t[s];return n/(Math.sqrt(r)*Math.sqrt(i))}function j8(e,t){let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}function R8(e,t){let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t[r])*(e[r]-t[r]);return n}function M8(e,t){return Math.sqrt(R8(e,t))}var U8=G({cosineSimilarity:()=>ky,euclideanDistance:()=>D8,innerProduct:()=>z8,matrixFunc:()=>km,maximalMarginalRelevance:()=>F8,normalize:()=>L8});function km(e,t,n){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(r=>t.map(i=>n(r,i)).map(i=>Number.isNaN(i)?0:i))}function L8(e,t=!1){let n=Z8(e);return e.map(r=>r.map(i=>t?1-i/n:i/n))}function ky(e,t){return km(e,t,QN)}function z8(e,t){return km(e,t,j8)}function D8(e,t){return km(e,t,M8)}function F8(e,t,n=.5,r=4){if(Math.min(r,t.length)<=0)return[];let i=ky(Array.isArray(e[0])?e:[e],t)[0],s=eP(i).maxIndex,a=[t[s]],o=[s];for(;o.length<Math.min(r,t.length);){let c=-1/0,u=-1,l=ky(t,a);i.forEach((d,p)=>{if(o.includes(p))return;let h=Math.max(...l[p]),m=n*d-(1-n)*h;m>c&&(c=m,u=p)}),a.push(t[u]),o.push(u)}return o}function eP(e){if(e.length===0)return{maxIndex:-1,maxValue:NaN};let t=e[0],n=0;for(let r=1;r<e.length;r+=1)e[r]>t&&(n=r,t=e[r]);return{maxIndex:n,maxValue:t}}function Z8(e){return e.reduce((t,n)=>Math.max(t,eP(n).maxValue),0)}var B8=G({isCloudMetadata:()=>xy,isLocalhost:()=>$y,isPrivateIp:()=>sP,isSafeUrl:()=>X8,isSameOrigin:()=>Y8,validateSafeUrl:()=>aP}),q8=["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"],J8=["169.254.169.254","169.254.170.2","100.100.100.200"],H8=["metadata.google.internal","metadata","instance-data"],V8=["localhost","localhost.localdomain"],K8=/^(?:(?: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 tP(e){return K8.test(e)}function xm(e){return iP(e)!==null}function nP(e){return tP(e)||xm(e)}function rP(e){if(tP(e))return e.split(".").map(t=>parseInt(t,10));if(xm(e)){let t=iP(e);if(!t)return null;let n=t.split(":"),r=[];for(let i of n)r.push(parseInt(i,16));return r}return null}function iP(e){if(!e||typeof e!="string"||!e.includes(":")||!/^[0-9a-fA-F:]+$/.test(e))return null;let t=e;if(t.includes("::")){let r=t.split("::");if(r.length>2)return null;let[i,s]=r,a=i?i.split(":"):[],o=s?s.split(":"):[],c=8-(a.length+o.length);if(c<0)return null;let u=Array(c).fill("0");t=[...a,...u,...o].filter(l=>l!=="").join(":")}let n=t.split(":");if(n.length!==8)return null;for(let r of n)if(r.length===0||r.length>4||!/^[0-9a-fA-F]+$/.test(r))return null;return n.map(r=>r.padStart(4,"0").toLowerCase()).join(":")}function W8(e){let[t,n]=e.split("/");if(!t||!n)return null;let r=rP(t);if(!r)return null;let i=parseInt(n,10);if(isNaN(i))return null;let s=xm(t);return s&&i>128||!s&&i>32?null:{addr:r,prefixLen:i,isIpv6:s}}function G8(e,t){let n=rP(e);if(!n)return!1;let r=W8(t);if(!r)return!1;let i=xm(e);if(i!==r.isIpv6)return!1;let{addr:s,prefixLen:a}=r;if(i)for(let o=0;o<Math.ceil(a/16);o++){let c=65535<<16-Math.min(16,a-o*16)&65535;if((n[o]&c)!==(s[o]&c))return!1}else for(let o=0;o<Math.ceil(a/8);o++){let c=255<<8-Math.min(8,a-o*8)&255;if((n[o]&c)!==(s[o]&c))return!1}return!0}function sP(e){if(!nP(e))return!1;for(let t of q8)if(G8(e,t))return!0;return!1}function xy(e,t){if(J8.includes(t||""))return!0;let n=e.toLowerCase();return!!H8.includes(n)}function $y(e,t){if(t&&(t==="127.0.0.1"||t==="::1"||t==="0.0.0.0"||t.startsWith("127.")))return!0;let n=e.toLowerCase();return!!V8.includes(n)}function aP(e,t){let n=t?.allowPrivate??!1,r=t?.allowHttp??!1;try{let i;try{i=new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}let s=i.hostname;if(!s)throw new Error("URL missing hostname.");if(xy(s))throw new Error(`URL points to cloud metadata endpoint: ${s}`);if($y(s)){if(!n)throw new Error(`URL points to localhost: ${s}`);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:"&&!r)throw new Error("HTTP scheme not allowed. Use HTTPS or set allowHttp: true.");if(nP(s)){let o=s;if($y(s,o)){if(!n)throw new Error(`URL points to localhost: ${s}`);return e}if(xy(s,o))throw new Error(`URL resolves to cloud metadata IP: ${o} (${s})`);if(sP(o)&&!n)throw new Error(`URL resolves to private IP: ${o} (${s}). 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 X8(e,t){try{return aP(e,t),!0}catch{return!1}}function Y8(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}var Q8=G({SaveableVectorStore:()=>eq,VectorStore:()=>b0,VectorStoreRetriever:()=>Wl}),Wl=class extends _b{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)}},b0=class extends Rn{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,n=void 0,r=void 0){return(await this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,n)).map(i=>i[0])}async similaritySearchWithScore(e,t=4,n=void 0,r=void 0){return this.similaritySearchVectorWithScore(await this.embeddings.embedQuery(e),t,n)}static fromTexts(e,t,n,r){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}static fromDocuments(e,t,n){throw new Error("the Langchain vectorstore implementation you are using forgot to override this, please report a bug")}asRetriever(e,t,n,r,i,s){if(typeof e=="number")return new Wl({vectorStore:this,k:e,filter:t,tags:[...r??[],this._vectorstoreType()],metadata:i,verbose:s,callbacks:n});{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 Wl({...a,searchKwargs:e.searchKwargs}):new Wl({...a})}}},eq=class extends b0{static load(e,t){throw new Error("Not implemented")}},tq=class extends Ns{_combineLLMOutput(){return[]}_llmType(){return"fake"}async _generate(e,t,n){if(t?.stop?.length)return{generations:[{message:new Le(t.stop[0]),text:t.stop[0]}]};let r=e.map(i=>typeof i.content=="string"?i.content:JSON.stringify(i.content,null,2)).join(`
|
|
319
|
+
`);return await n?.handleLLMNewToken(r),{generations:[{message:new Le(r),text:r}],llmOutput:{}}}},nq=class oP extends Ns{sleep=50;responses=[];chunks=[];toolStyle="openai";thrownErrorString;tools=[];constructor({sleep:t=50,responses:n=[],chunks:r=[],toolStyle:i="openai",thrownErrorString:s,...a}){super(a),this.sleep=t,this.responses=n,this.chunks=r,this.toolStyle=i,this.thrownErrorString=s}_llmType(){return"fake"}bindTools(t){let n=[...this.tools,...t],r=n.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:xt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:xt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:xt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:xt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:r}]:r,s=new oP({sleep:this.sleep,responses:this.responses,chunks:this.chunks,toolStyle:this.toolStyle,thrownErrorString:this.thrownErrorString});return s.tools=n,s.withConfig({tools:i})}async _generate(t,n,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);return{generations:[{text:"",message:new Le({content:this.responses?.[0]?.content??t[0].content??"",tool_calls:this.chunks?.[0]?.tool_calls})}]}}async*_streamResponseChunks(t,n,r){if(this.thrownErrorString)throw new Error(this.thrownErrorString);if(this.chunks?.length){for(let a of this.chunks){let o=new Wr({message:new Pt({content:a.content,tool_calls:a.tool_calls,additional_kwargs:a.additional_kwargs??{}}),text:a.content?.toString()??""});if(n.signal?.aborted)break;yield o,await r?.handleLLMNewToken(a.content,void 0,void 0,void 0,void 0,{chunk:o})}return}let i=this.responses?.[0]??new Le(typeof t[0].content=="string"?t[0].content:""),s=typeof i.content=="string"?i.content:"";for(let a of s){await new Promise(c=>setTimeout(c,this.sleep));let o=new Wr({message:new Pt({content:a}),text:a});if(n.signal?.aborted)break;yield o,await r?.handleLLMNewToken(a,void 0,void 0,void 0,void 0,{chunk:o})}}},rq=class cP extends Ns{static lc_name(){return"FakeListChatModel"}lc_serializable=!0;responses;i=0;sleep;emitCustomEvent=!1;generationInfo;tools=[];toolStyle="openai";constructor(t){super(t);let{responses:n,sleep:r,emitCustomEvent:i,generationInfo:s}=t;this.responses=n,this.sleep=r,this.emitCustomEvent=i??this.emitCustomEvent,this.generationInfo=s}_combineLLMOutput(){return[]}_llmType(){return"fake-list"}async _generate(t,n,r){if(await this._sleepIfRequested(),n?.thrownErrorString)throw new Error(n.thrownErrorString);if(this.emitCustomEvent&&await r?.handleCustomEvent("some_test_event",{someval:!0}),n?.stop?.length)return{generations:[this._formatGeneration(n.stop[0])]};{let i=this._currentResponse();return this._incrementResponse(),{generations:[this._formatGeneration(i)],llmOutput:{}}}}_formatGeneration(t){return{message:new Le(t),text:t}}async*_streamResponseChunks(t,n,r){let i=this._currentResponse();this._incrementResponse(),this.emitCustomEvent&&await r?.handleCustomEvent("some_test_event",{someval:!0});let s=[...i];for(let a=0;a<s.length;a++){let o=s[a],c=a===s.length-1;if(await this._sleepIfRequested(),n?.thrownErrorString)throw new Error(n.thrownErrorString);let u=this._createResponseChunk(o,c?this.generationInfo:void 0);if(n.signal?.aborted)break;yield u,r?.handleLLMNewToken(o)}}async _sleepIfRequested(){this.sleep!==void 0&&await this._sleep()}async _sleep(){return new Promise(t=>{setTimeout(()=>t(),this.sleep)})}_createResponseChunk(t,n){return new Wr({message:new Pt({content:t}),text:t,generationInfo:n})}_currentResponse(){return this.responses[this.i]}_incrementResponse(){this.i<this.responses.length-1?this.i+=1:this.i=0}bindTools(t){let n=[...this.tools,...t],r=n.map(a=>{switch(this.toolStyle){case"openai":return{type:"function",function:{name:a.name,description:a.description,parameters:xt(a.schema)}};case"anthropic":return{name:a.name,description:a.description,input_schema:xt(a.schema)};case"bedrock":return{toolSpec:{name:a.name,description:a.description,inputSchema:xt(a.schema)}};case"google":return{name:a.name,description:a.description,parameters:xt(a.schema)};default:throw new Error(`Unsupported tool style: ${this.toolStyle}`)}}),i=this.toolStyle==="google"?[{functionDeclarations:r}]:r,s=new cP({responses:this.responses,sleep:this.sleep,emitCustomEvent:this.emitCustomEvent,generationInfo:this.generationInfo});return s.tools=n,s.toolStyle=this.toolStyle,s.i=this.i,s.withConfig({tools:i})}withStructuredOutput(t,n){return ir.from(async r=>{let i=await this.invoke(r);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")})}},iq=class extends Zh{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 n=t.length%this.vectorSize,r=n===0?0:this.vectorSize-n,i=t.length+r;t=t.padEnd(i," ");let s=t.length/this.vectorSize,a=[];for(let o=0;o<t.length;o+=s)a.push(t.slice(o,o+s));return a.map(o=>{let c=0;for(let u=0;u<o.length;u+=1)c+=o===" "?0:o.charCodeAt(u);return c%26/26})}},sq=class extends Zh{constructor(e){super(e??{})}embedDocuments(e){return Promise.resolve(e.map(()=>[.1,.2,.3,.4]))}embedQuery(e){return Promise.resolve([.1,.2,.3,.4])}},aq=class extends pb{response;thrownErrorString;constructor(e){super(e),this.response=e.response,this.thrownErrorString=e.thrownErrorString}_llmType(){return"fake"}async _call(e,t,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let r=this.response??e;return await n?.handleLLMNewToken(r),r}},oq=class extends pb{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,n){if(this.thrownErrorString)throw new Error(this.thrownErrorString);let r=this.responses?.[0];this.responses=this.responses?.slice(1);for(let i of r??e)await new Promise(s=>setTimeout(s,this.sleep)),yield{text:i,generationInfo:{}},await n?.handleLLMNewToken(i)}},cq=class extends aE{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 $n(e))}async addAIMessage(e){this.messages.push(new Le(e))}async clear(){this.messages=[]}},uq=class extends nb{lc_namespace=["langchain_core","message","fake"];messages=[];constructor(){super()}async addMessage(e){this.messages.push(e)}async getMessages(){return this.messages}},lq=class extends ei{name="fake_tracer";runs=[];constructor(){super()}persistRun(e){return this.runs.push(e),Promise.resolve()}},dq=class extends no{lc_namespace=["tests","fake"];getFormatInstructions(){return""}async parse(e){return e.split(",").map(t=>t.trim())}},pq=class extends _b{lc_namespace=["test","fake"];output=[new bi({pageContent:"foo"}),new bi({pageContent:"bar"})];constructor(e){super(),this.output=e?.output??this.output}async _getRelevantDocuments(e){return this.output}},hq=class extends Ae{lc_namespace=["tests","fake"];returnOptions;constructor(e){super(e),this.returnOptions=e.returnOptions}async invoke(e,t){return this.returnOptions?t??{}:{input:e}}},mq=class extends wm{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)}},fq=class extends ei{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}},gq=class uP extends b0{memoryVectors=[];similarity;_vectorstoreType(){return"memory"}constructor(t,{similarity:n,...r}={}){super(t,r),this.similarity=n??QN}async addDocuments(t){let n=t.map(({pageContent:r})=>r);return this.addVectors(await this.embeddings.embedDocuments(n),t)}async addVectors(t,n){let r=t.map((i,s)=>({content:n[s].pageContent,embedding:i,metadata:n[s].metadata}));this.memoryVectors=this.memoryVectors.concat(r)}async similaritySearchVectorWithScore(t,n,r){let i=a=>r?r(new bi({metadata:a.metadata,pageContent:a.content})):!0,s=this.memoryVectors.filter(i);return s.map((a,o)=>({similarity:this.similarity(t,a.embedding),index:o})).sort((a,o)=>a.similarity>o.similarity?-1:0).slice(0,n).map(a=>[new bi({metadata:s[a.index].metadata,pageContent:s[a.index].content}),a.similarity])}static async fromTexts(t,n,r,i){let s=[];for(let a=0;a<t.length;a+=1){let o=Array.isArray(n)?n[a]:n,c=new bi({pageContent:t[a],metadata:o});s.push(c)}return uP.fromDocuments(s,r,i)}static async fromDocuments(t,n,r){let i=new this(n,r);return await i.addDocuments(t),i}static async fromExistingIndex(t,n){return new this(t,n)}},yq=G({FakeChatMessageHistory:()=>cq,FakeChatModel:()=>tq,FakeEmbeddings:()=>sq,FakeLLM:()=>aq,FakeListChatMessageHistory:()=>uq,FakeListChatModel:()=>rq,FakeRetriever:()=>pq,FakeRunnable:()=>hq,FakeSplitIntoListParser:()=>dq,FakeStreamingChatModel:()=>nq,FakeStreamingLLM:()=>oq,FakeTool:()=>mq,FakeTracer:()=>lq,FakeVectorStore:()=>gq,SingleRunExtractor:()=>fq,SyntheticEmbeddings:()=>iq}),_q=G({agents:()=>X2,caches:()=>YR,callbacks__base:()=>v6,callbacks__manager:()=>OL,callbacks__promises:()=>xL,chat_history:()=>UF,document_loaders__base:()=>FF,document_loaders__langsmith:()=>ZF,documents:()=>DF,embeddings:()=>JF,errors:()=>tR,example_selectors:()=>XF,index:()=>G2,indexing:()=>eZ,language_models__base:()=>mZ,language_models__chat_models:()=>GZ,language_models__compat:()=>ZZ,language_models__event:()=>YZ,language_models__llms:()=>QZ,language_models__profile:()=>eB,language_models__stream:()=>UZ,language_models__structured_output:()=>MZ,load__serializable:()=>H2,memory:()=>tB,messages:()=>MF,messages__tool:()=>kR,output_parsers:()=>jZ,output_parsers__openai_functions:()=>oB,output_parsers__openai_tools:()=>cB,outputs:()=>qL,prompt_values:()=>tZ,prompts:()=>RB,retrievers:()=>LB,retrievers__document_compressors:()=>MB,runnables:()=>wZ,runnables__graph:()=>fF,singletons:()=>EL,stores:()=>zB,structured_query:()=>HB,testing:()=>XB,tools:()=>m8,tracers__base:()=>oL,tracers__console:()=>dL,tracers__log_stream:()=>ZL,tracers__run_collector:()=>v8,tracers__tracer_langchain:()=>yL,types__stream:()=>w8,utils__async_caller:()=>QL,utils__chunk_array:()=>k8,utils__context:()=>x8,utils__env:()=>K2,utils__event_source_parse:()=>O8,utils__format:()=>N8,utils__function_calling:()=>P8,utils__hash:()=>Q2,utils__json_patch:()=>kZ,utils__json_schema:()=>cF,utils__math:()=>U8,utils__ssrf:()=>B8,utils__standard_schema:()=>nz,utils__stream:()=>jL,utils__testing:()=>yq,utils__tiktoken:()=>pZ,utils__types:()=>RZ,utils__uuid:()=>_6,vectorstores:()=>Q8}),vq=50;function bq(e){let t={};for(let n=e;n&&n.prototype;n=Object.getPrototypeOf(n))Object.assign(t,Reflect.get(n.prototype,"lc_aliases"));return Object.entries(t).reduce((n,[r,i])=>(n[i]=r,n),{})}async function Gl(e){let{optionalImportsMap:t,optionalImportEntrypoints:n,importMap:r,secretsMap:i,secretsFromEnv:s,path:a,depth:o,maxDepth:c}=this,u=a.join(".");if(o>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((p,h)=>Gl.call({...this,path:[...a,`${h}`],depth:o+1},p)));let l=e;if(X$(l))return ng(l);if("lc"in l&&"type"in l&&"id"in l&&l.lc===1&&l.type==="secret"){let[p]=l.id;if(p in i)return i[p];if(s){let h=bn(p);if(h)return h}throw new Error(`Missing secret "${p}" 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 p=l,h=JSON.stringify(p),[m,...f]=p.id.slice().reverse(),v=f.reverse(),g={langchain_core:_q,langchain:r},y=null,w=[v.join("/")];v[0]==="langchain_community"&&w.push(["langchain",...v.slice(1)].join("/"));let x=w.find(T=>T in t);if(W2.concat(n).includes(v.join("/"))||x)if(x!==void 0)y=await t[x];else throw new Error(`Missing key "${v.join("/")}" for ${u} in load(optionalImportsMap={})`);else{let T;if(v[0]==="langchain"||v[0]==="langchain_core")T=g[v[0]],v.shift();else throw new Error(`Invalid namespace: ${u} -> ${h}`);if(v.length===0)throw new Error(`Invalid namespace: ${u} -> ${h}`);let k;do{if(k=v.join("__"),k in T)break;v.pop()}while(v.length>0);k in T&&(y=T[k])}if(typeof y!="object"||y===null)throw new Error(`Invalid namespace: ${u} -> ${h}`);let O=y[m]??Object.values(y).find(T=>typeof T=="function"&&mh(T)===m);if(typeof O!="function")throw new Error(`Invalid identifer: ${u} -> ${h}`);let z=new O(W$(await Gl.call({...this,path:[...a,"kwargs"],depth:o+1},p.kwargs),F2,bq(O)));return Object.defineProperty(z.constructor,"name",{value:m}),z}let d={};for(let[p,h]of Object.entries(l))d[p]=await Gl.call({...this,path:[...a,p],depth:o+1},h);return d}async function wq(e,t){let n=JSON.parse(e),r={optionalImportsMap:{},optionalImportEntrypoints:[],secretsMap:{},secretsFromEnv:!1,importMap:{},path:["$"],depth:0,maxDepth:vq};return Gl.call(r,n)}function kq(e){return e!==null&&e.lc===1&&e.type==="constructor"&&Array.isArray(e.id)}async function Iy(e){if(e&&typeof e=="object"){if(Array.isArray(e))return await Promise.all(e.map(t=>Iy(t)));{let t={};for(let[n,r]of Object.entries(e))t[n]=await Iy(r);if(t.lc===2&&t.type==="undefined")return;if(t.lc===2&&t.type==="constructor"&&Array.isArray(t.id))try{let n=t.id[t.id.length-1],r;switch(n){case"Set":r=Set;break;case"Map":r=Map;break;case"RegExp":r=RegExp;break;case"Error":r=Error;break;case"Uint8Array":r=Uint8Array;break;default:return t}return t.method?r[t.method](...t.args||[]):new r(...t.args||[])}catch{return t}else if(kq(t))return wq(JSON.stringify(t));return t}}return e}function fl(e,t,n,r){return{lc:2,type:"constructor",id:[e.name],method:t??null,args:n??[],kwargs:r??{}}}function xq(e){return e===void 0?{lc:2,type:"undefined"}:e instanceof Set||e instanceof Map?fl(e.constructor,void 0,[Array.from(e)]):e instanceof RegExp?fl(RegExp,void 0,[e.source,e.flags]):e instanceof Error?fl(e.constructor,void 0,[e.message]):e?.lg_name==="Send"?{node:e.node,args:e.args}:e instanceof Uint8Array?fl(Uint8Array,"from",[Array.from(e)]):e}var $q=class{_dumps(e){return new TextEncoder().encode(N2(e,(t,n)=>xq(n)))}async dumpsTyped(e){return e instanceof Uint8Array?["bytes",e]:["json",this._dumps(e)]}async _loads(e){return Iy(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 lP(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[]:{};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=lP(e[n]));return t}function dP(){return{v:4,id:K$(-2),ts:new Date().toISOString(),channel_values:{},channel_versions:{},versions_seen:{}}}function Bd(e){return{v:e.v,id:e.id,ts:e.ts,channel_values:{...e.channel_values},channel_versions:{...e.channel_versions},versions_seen:lP(e.versions_seen)}}function pP(e,t){return typeof e=="number"&&typeof t=="number"?Math.sign(e-t):String(e).localeCompare(String(t))}function Iq(...e){return e.reduce((t,n,r)=>r===0?n:pP(t,n)>=0?t:n)}var Sq={[O2]:-1,[zl]:-2,[A2]:-3,[T2]:-4},ko=class extends Error{constructor(e){super(e),this.name="InvalidNamespaceError"}};function Oq(e){if(e.length===0)throw new ko("Namespace cannot be empty.");for(let t of e){if(typeof t!="string")throw new ko(`Invalid namespace label '${t}' found in ${e}. Namespace labels must be strings, but got ${typeof t}.`);if(t.includes("."))throw new ko(`Invalid namespace label '${t}' found in ${e}. Namespace labels cannot contain periods ('.').`);if(t==="")throw new ko(`Namespace labels cannot be empty strings. Got ${t} in ${e}`)}if(e[0]==="langgraph")throw new ko(`Root label for namespace cannot be "langgraph". Got: ${e}`)}var Aq=class{async get(e,t){return(await this.batch([{namespace:e,key:t}]))[0]}async search(e,t={}){let{filter:n,limit:r=10,offset:i=0,query:s}=t;return(await this.batch([{namespacePrefix:e,filter:n,limit:r,offset:i,query:s}]))[0]}async put(e,t,n,r){Oq(e),await this.batch([{namespace:e,key:t,value:n,index:r}])}async delete(e,t){await this.batch([{namespace:e,key:t,value:null}])}async listNamespaces(e={}){let{prefix:t,suffix:n,maxDepth:r,limit:i=100,offset:s=0}=e,a=[];return t&&a.push({matchType:"prefix",path:t}),n&&a.push({matchType:"suffix",path:n}),(await this.batch([{matchConditions:a.length?a:void 0,maxDepth:r,limit:i,offset:s}]))[0]}start(){}stop(){}},Tq=e=>"lg_name"in e&&e.lg_name==="AsyncBatchedStore"?e.store:e,Eq=class extends Aq{lg_name="AsyncBatchedStore";store;queue=new Map;nextKey=0;running=!1;processingTask=null;constructor(e){super(),this.store=Tq(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:n,limit:r=10,offset:i=0,query:s}=t||{};return this.enqueueOperation({namespacePrefix:e,filter:n,limit:r,offset:i,query:s})}async put(e,t,n){return this.enqueueOperation({namespace:e,key:t,value:n})}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,n)=>{let r=this.nextKey;this.nextKey+=1,this.queue.set(r,{operation:e,resolve:t,reject:n})})}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:r})=>r),n=await this.store.batch(t);e.forEach(({resolve:r},i)=>{r(n[Array.from(e.keys()).indexOf(i)])})}catch(t){e.forEach(({reject:n})=>{n(t)})}}}toJSON(){return{queue:this.queue,nextKey:this.nextKey,running:this.running,store:"[LangGraphStore]"}}},Cq=class{serde=new $q;constructor(e){this.serde=e||this.serde}};function hP(e){return e!=null&&e.lg_is_channel===!0}var Di=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(e){if(e.name===$t.unminifiable_name)return!1;throw e}}equals(e){return this===e}},Sy=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function w0(e){if(e[Sy]===!0)return e;let t={};for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=e[n];hP(r)&&(t[n]=r)}return Object.assign(t,{[Sy]:!0}),t}function qd(e,t){let n=w0(e),r={};for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let s=t.channel_values[i];r[i]=n[i].fromCheckpoint(s)}return Object.assign(r,{[Sy]:!0}),r}function Yi(e,t,n,r){let i;if(t===void 0)i=e.channel_values;else{i={};for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s))try{i[s]=t[s].checkpoint()}catch(a){if(a.name!==$t.unminifiable_name)throw a}}return{v:4,id:r?.id??K$(n),ts:new Date().toISOString(),channel_values:i,channel_versions:e.channel_versions,versions_seen:e.versions_seen}}var Nq=e=>e!=null&&e.lc_graph_name==="BinaryOperatorAggregate",Jd=class mP extends Di{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor(t,n){super(),this.operator=t,this.initialValueFactory=n,this.value=n?.()}fromCheckpoint(t){let n=new mP(this.operator,this.initialValueFactory);return typeof t<"u"&&(n.value=t),n}update(t){let n=t;if(!n.length)return!1;if(this.value===void 0){let i=n[0],[s,a]=Yf(i);s?this.value=a:this.value=i,n=n.slice(1)}let r=!1;for(let i of n)if(a2(i)){if(r)throw new qe("Can receive only one Overwrite value per step.");let[,s]=Yf(i);this.value=s,r=!0;continue}else!r&&this.value!==void 0&&(this.value=this.operator(this.value,i));return!0}get(){if(this.value===void 0)throw new $t;return this.value}checkpoint(){if(this.value===void 0)throw new $t;return this.value}isAvailable(){return this.value!==void 0}equals(t){return this===t?!0:Nq(t)?this.operator===t.operator:!1}},$m=class fP extends Di{lc_graph_name="LastValue";value=[];constructor(t){super(),this.initialValueFactory=t,t&&(this.value=[t()])}fromCheckpoint(t){let n=new fP(this.initialValueFactory);return typeof t<"u"&&(n.value=[t]),n}update(t){if(t.length===0)return!1;if(t.length!==1)throw new qe("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 $t;return this.value[0]}checkpoint(){if(this.value.length===0)throw new $t;return this.value[0]}isAvailable(){return this.value.length!==0}},Pq=class gP extends Di{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint(t){let n=new gP;if(typeof t<"u"){let[r,i]=t;n.value=[r],n.finished=i}return n}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 $t;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}},Oy=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"}},Ye=function(e){return e?yP(e):new $m};Ye.Root=e=>new Oy(e);function yP(e){return typeof e=="object"&&e&&"reducer"in e&&e.reducer?new Jd(e.reducer,e.default):typeof e=="object"&&e&&"value"in e&&e.value?new Jd(e.value,e.default):new $m}var jq=["tags","metadata","callbacks","configurable"],Rq=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal","executionInfo","serverInfo"],Mq=25,Uq=new Set(["thread_id","checkpoint_id","checkpoint_ns","task_id","run_id","assistant_id","graph_id"]);function Lq(e,t){if(!e)return t;let n=t??{};for(let r of Uq){if(r in n)continue;let i=e[r];i!==void 0&&(n[r]=i)}return n}function _P(...e){let t={tags:[],metadata:{},callbacks:void 0,recursionLimit:Mq,configurable:{}},n=jt.getRunnableConfig();if(n!==void 0){for(let[r,i]of Object.entries(n))if(i!==void 0)if(jq.includes(r)){let s;Array.isArray(i)?s=[...i]:typeof i=="object"?r==="callbacks"&&"copy"in i&&typeof i.copy=="function"?s=i.copy():s={...i}:s=i,t[r]=s}else t[r]=i}for(let r of e)if(r!==void 0)for(let[i,s]of Object.entries(r))s!==void 0&&Rq.includes(i)&&(t[i]=s);return t.metadata=Lq(t.configurable,t.metadata)??{},t}function zq(){return jt.getRunnableConfig()}function If(e){return e.split("|").filter(t=>!t.match(/^\d+$/)).map(t=>t.split(":")[0]).join("|")}function Dq(e){let t=e.split("|");for(;t.length>1&&t[t.length-1].match(/^\d+$/);)t.pop();return t.slice(0,-1).join("|")}var Sf=Symbol.for("langgraph.stream_channel"),ks=class Ay{[Sf]=!0;channelName;#e=[];#a=[];#n=!1;#i;#r;constructor(t){this.channelName=t}static local(){return new Ay}static remote(t){return new Ay(t)}static isInstance(t){return typeof t=="object"&&t!==null&&Sf in t&&t[Sf]===!0}push(t){this.#e.push(t),this.#t(),this.#r?.(t)}iterate(t=0){let n=t;return{next:async()=>{for(;;){if(n<this.#e.length)return{value:this.#e[n++],done:!1};if(this.#n){if(this.#i)throw this.#i;return{value:void 0,done:!0}}await new Promise(r=>this.#a.push(r))}}}}toAsyncIterable(t=0){return{[Symbol.asyncIterator]:()=>this.iterate(t)}}toEventStream(t={}){let n=new TextEncoder,r=this.iterate(t.startAt),i=t.event??this.channelName,s=t.serialize??(a=>JSON.stringify(a)??"null");return new ReadableStream({async pull(a){try{let o=await r.next();if(o.done){a.close();return}let c=[];i!=null&&c.push(`event: ${i}`);for(let u of s(o.value).split(/\r\n|\r|\n/))c.push(`data: ${u}`);a.enqueue(n.encode(`${c.join(`
|
|
320
|
+
`)}
|
|
321
|
+
|
|
322
|
+
`))}catch(o){a.error(o)}},async cancel(){await r.return?.()}})}get(t){if(t<0||t>=this.#e.length)throw new RangeError(`StreamChannel index ${t} out of bounds (size=${this.#e.length})`);return this.#e[t]}get size(){return this.#e.length}get done(){return this.#n}close(){this.#n=!0,this.#t()}fail(t){this.#i=t,this.#n=!0,this.#t()}_wire(t){this.#r=t}_close(){this.close()}_fail(t){this.fail(t)}[Symbol.asyncIterator](){return this.iterate()}#t(){let t=this.#a.splice(0);for(let n of t)n()}};function Fq(e){return ks.isInstance(e)}var Zq=["values","updates","messages","tools","custom","tasks"];function Bq(e){if(!Array.isArray(e)||e.length!==2)return{data:e};let[t,n]=e;if(n==null||typeof n!="object")return{data:e};let r=n,i=typeof r.langgraph_node=="string"?r.langgraph_node:void 0,s=typeof r.run_id=="string"?r.run_id:void 0;return{data:s!=null&&t!=null&&typeof t=="object"?{...t,run_id:s}:t,node:i}}function qq({namespace:e,mode:t,payload:n,seq:r,meta:i}){let s=Date.now(),a={type:"event"};switch(t){case"messages":{let{data:o,node:c}=Bq(n);return[{...a,seq:r,method:"messages",params:{namespace:e,timestamp:s,...c?{node:c}:{},data:o}}]}case"tools":return[{...a,seq:r,method:"tools",params:{namespace:e,timestamp:s,data:Jq(n)}}];case"values":{let o=[];return i?.checkpoint!=null&&o.push({...a,seq:r,method:"checkpoints",params:{namespace:e,timestamp:s,data:i.checkpoint}}),o.push({...a,seq:i?.checkpoint!=null?r+1:r,method:"values",params:{namespace:e,timestamp:s,data:n}}),o}case"updates":{let o=Hq(n);return[{...a,seq:r,method:"updates",params:{namespace:e,timestamp:s,...typeof o.node=="string"?{node:o.node}:{},data:o}}]}case"custom":{let o=typeof n=="object"&&n!==null&&!Array.isArray(n)&&"name"in n?n:{payload:n};return[{...a,seq:r,method:"custom",params:{namespace:e,timestamp:s,data:o}}]}case"tasks":return[{...a,seq:r,method:"tasks",params:{namespace:e,timestamp:s,data:n}}];default:return[]}}function Jq(e){if(typeof e!="object"||e===null)return{event:"tool-error",tool_call_id:"",message:"Unexpected tools payload shape"};let t=e,n=String(t.toolCallId??"");switch(t.event){case"on_tool_start":return{event:"tool-started",tool_call_id:n,tool_name:String(t.name??"unknown"),input:t.input};case"on_tool_event":return{event:"tool-output-delta",tool_call_id:n,delta:typeof t.data=="string"?t.data:JSON.stringify(t.data??"")};case"on_tool_end":return{event:"tool-finished",tool_call_id:n,output:t.output};case"on_tool_error":{let r=t.error;return{event:"tool-error",tool_call_id:n,message:typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"?r.message:String(r??"unknown error")}}default:return{event:"tool-error",tool_call_id:"",message:`Unknown tool event: ${String(t.event)}`}}}function Hq(e){if(typeof e!="object"||e===null)return{values:{}};let t=Object.entries(e);if(t.length===0)return{values:{}};let[n,r]=t[0];return{node:n,values:typeof r=="object"&&r!==null?r:{value:r}}}function Vq(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}var Ty=Symbol("resolveValues"),vP=Symbol("rejectValues"),Kq=class{_events=ks.local();_discoveries=ks.local();#e=0;#a=!1;#n;#i=!1;#r=[];#t=[];#o=[];#s=new Map;#u=new Map;#c=[];#l=[];register(e,t){this.#s.set(tn(e),t)}addTransformer(e){let t=this._events.size;this.#t.push(e),e.onRegister&&e.onRegister({push:(n,r)=>this.push(n,r)});for(let n=0;n<t;n+=1)e.process(this._events.get(n));this.#a&&(this.#n!==void 0?e.fail?.(this.#n):e.finalize?.())}wireChannels(e){for(let[t,n]of Object.entries(e)){if(Fq(n)){if(this.#o.push(n),typeof n.channelName!="string")continue;n._wire(r=>{this._events.push({type:"event",seq:this.#e++,method:n.channelName,params:{namespace:this.#r,timestamp:Date.now(),data:r}})});continue}Vq(n)&&this.#l.push({name:t,promise:Promise.resolve(n)})}}push(e,t){t.method==="values"&&this.#u.set(tn(e),t.params.data);let n=this.#r;this.#r=e;let r=!0;for(let i of this.#t)i.process(t)||(r=!1);this.#r=n,r&&this._events.push({...t,seq:this.#e++})}close(){this.#a=!0;for(let[n,r]of this.#u.entries()){let i=n?n.split("\0"):[];this.#s.get(tn(i))?.[Ty](r)}let e=[];for(let n of this.#t){let r=n.finalize?.();r!=null&&typeof r.then=="function"&&e.push(r)}for(let n of this.#o)n._close();let t=this.#l;t.length===0&&e.length===0?(this._events.close(),this._discoveries.close()):Promise.allSettled([...e,...t.map(async({name:n,promise:r})=>{try{let i=await r;this._events.done||this._events.push({type:"event",seq:this.#e++,method:"custom",params:{namespace:[],timestamp:Date.now(),data:{name:n,payload:i}}})}catch{}})]).then(()=>{this._events.close(),this._discoveries.close()});for(let n of this.#s.values())n[Ty](void 0)}fail(e){this.#a=!0,this.#n=e;for(let t of this.#t)t.fail?.(e);for(let t of this.#o)t._fail(e);this._events.fail(e),this._discoveries.fail(e);for(let t of this.#s.values())t[vP](e)}markInterrupted(e){this.#i=!0,this.#c.push(...e)}get interrupted(){return this.#i}get interrupts(){return this.#c}subscribeEvents(e,t=0){let n=this._events.iterate(t);return{async next(){for(;;){let r=await n.next();if(r.done||ao(r.value.params.namespace,e))return r}}}}};async function Wq(e,t){let n=0;try{for await(let r of e){let[i,s,a,o]=r;if(s==="values"&&g_(a)){let u=a[yt];t.markInterrupted(u.map(l=>({interruptId:l.id??"",payload:l.value})))}let c=qq({namespace:i,mode:s,payload:a,seq:n,meta:o});n+=c.length;for(let u of c)t.push(i,u)}}catch(r){t.fail(r);return}t.close()}function tn(e){return e.join("\0")}function ao(e,t){if(t.length>e.length)return!1;for(let n=0;n<t.length;n+=1)if(e[n]!==t[n])return!1;return!0}function bP(e,t,n=0){return{[Symbol.asyncIterator](){let r=e.iterate(n);return{async next(){for(;;){let i=await r.next();if(i.done)return{value:void 0,done:!0};if(ao(i.value.namespace,t))return{value:i.value,done:!1}}}}}}}var wP="root";function Gq(e){if(e.length===0)return wP;let t=e[e.length-1],n=t.indexOf(":");return n===-1?t:t.slice(0,n)}function Xq(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Hd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yq(e){if(!Hd(e)||e.event!=="started")return;let t=e.cause;if(Hd(t)&&typeof t.type=="string")return t}function Qq(e){if(Hd(e)&&"result"in e&&typeof e.name=="string"&&typeof e.id=="string"&&!e.name.startsWith("__"))return{name:e.name,id:e.id}}function eJ(e={}){let t=e.rootGraphName??wP,n=e.initialStatus??"running",r=e.emitRootOnRegister??!0,i=e.getGraphName??Gq,s=e.serializeError??Xq,a=e.getTerminalStatusOverride,o=ks.local(),c=new Map,u=new Map,l=new Set,d=[],p,h=0,m=!1,f=E=>E.length===0?t:i(E),v=(E,Z,X)=>{let ae=tn(E),Ne=c.get(ae),ve=Ne?.graphName??f(E);if(Ne!=null&&Ne.status===Z&&Ne.graphName===ve&&X?.error==null)return;Ne==null?(Ne={namespace:E,graphName:ve,status:Z},c.set(ae,Ne)):Ne.status=Z;let sr={event:Z,graph_name:ve,...X?.cause!=null?{cause:X.cause}:{},...X?.error!=null?{error:X.error}:{}},On=Date.now();if(o.push({namespace:E,timestamp:On,...sr}),!(E.length===0&&!r)&&p!=null){h+=1;try{p.push(E,{type:"event",seq:0,method:"lifecycle",params:{namespace:E,timestamp:On,data:sr}})}finally{h-=1}}},g=E=>{let Z=tn(E),X=c.get(Z);return X==null&&(X={namespace:E,graphName:f(E),status:void 0},c.set(Z,X)),X},y=()=>{if(d.length===0)return;let E=d.splice(0,d.length);for(let Z of E){let X=tn(Z.namespace),ae=c.get(X);ae==null||ae.status!=="started"||v(Z.namespace,"completed")}},w=E=>{let Z=tn(E.namespace),X=c.get(Z);X==null||X.status!=="started"||d.some(ae=>tn(ae.namespace)===Z)||d.push(E)},x=(E,Z)=>{for(let X=d.length-1;X>=0;X-=1){let ae=d[X];ae.source.type==="node"&&ae.source.node===Z&&tn(ae.source.parent)===tn(E)&&d.splice(X,1)}},O=E=>{for(let Z=1;Z<=E.length;Z+=1){let X=E.slice(0,Z),ae=tn(X);if(c.has(ae))continue;g(X);let Ne=u.get(ae);v(X,"started",Ne!=null?{cause:Ne}:void 0)}},z=()=>l.size>0?"interrupted":"completed",T=E=>{for(let Z of c.values())Z.namespace.length!==0&&Z.status==="started"&&v(Z.namespace,E);v([],E),o.close()},k=async()=>{if(a==null)return z();try{return await a()??z()}catch{return z()}},B=(E,Z)=>{let X=`${Z}:`;for(let ae of c.values()){if(ae.namespace.length!==E.length+1||ae.status!=="started"||!ao(ae.namespace,E))continue;let Ne=ae.namespace[ae.namespace.length-1];if(Ne===Z||Ne.startsWith(X))return ae.namespace}},C=(E,Z)=>{let X=[...E,`${Z.name}:${Z.id}`];return c.get(tn(X))?.status==="started"?X:void 0};return{__native:!0,init(){return{_lifecycleLog:o,lifecycle:bP(o,[],0)}},onRegister(E){p=E,g([]),r&&v([],n)},process(E){let Z=E.params.namespace;if(h>0)return!0;let X=E.method==="tasks"?Qq(E.params.data):void 0;if(X!=null&&x(Z,X.name),y(),E.method==="lifecycle"){let ae=Yq(E.params.data);return ae!=null&&u.set(tn(Z),ae),O(Z),!1}if(O(Z),E.method==="input"&&Hd(E.params.data)&&E.params.data.event==="requested"){let ae=E.params.data.id;typeof ae=="string"&&l.add(ae)}if(X!=null){let ae=C(Z,X);ae!=null&&w({namespace:ae,source:{type:"task"}})}if(E.method==="updates"){let ae=E.params.node;if(typeof ae=="string"&&!ae.startsWith("__")){let Ne=B(Z,ae);Ne!=null&&w({namespace:Ne,source:{type:"node",parent:Z,node:ae}})}}return!0},finalize(){if(!m){if(m=!0,y(),a==null){T(z());return}return k().then(T).catch(E=>{o.fail(E)})}},fail(E){if(m)return;m=!0;let Z=s(E);for(let X of c.values())X.namespace.length!==0&&X.status==="started"&&v(X.namespace,"failed");v([],"failed",{error:Z}),o.fail(E)}}}function gl(e){let t=e;return typeof t.run_id=="string"?`run:${t.run_id}`:e.event==="message-start"&&typeof t.id=="string"?`message:${t.id}`:"__default__"}function Ey(e,t){let n=ks.local(),r=new Map;return{init:()=>({messages:n.toAsyncIterable()}),process(i){if(i.method!=="messages"||!ao(i.params.namespace,e)||i.params.namespace.length!==e.length+1||t!==void 0&&i.params.node!==t)return!0;let s=i.params.data;switch(s.event){case"message-start":{let a=gl(s),o=ks.local(),c=Object.assign(new Rd(o.toAsyncIterable()),{namespace:i.params.namespace,node:i.params.node});r.set(a,{source:o,stream:c}),o.push(s),n.push(c);break}case"content-block-start":case"content-block-delta":case"content-block-finish":r.get(gl(s))?.source.push(s);break;case"message-finish":{let a=gl(s),o=r.get(a);o&&(o.source.push(s),o.source.close(),r.delete(a));break}case"error":r.get(gl(s))?.source.push(s);break}return!0},finalize(){for(let[i,s]of r)s.source.push({event:"message-finish"}),s.source.close(),r.delete(i);n.close()},fail(i){for(let[s,a]of r)a.source.fail(i),r.delete(s);n.fail(i)}}}function k0(e,t,n=0){let r=t.length+1;return{[Symbol.asyncIterator](){let i=e.iterate(n);return{async next(){for(;;){let s=await i.next();if(s.done)return{value:void 0,done:!0};let{ns:a,stream:o}=s.value;if(a.length===r&&ao(a,t))return{value:o,done:!1}}}}}}}function tJ(e,t){let{createStream:n}=t,r=new Set;return{__native:!0,init(){return{_discoveries:e._discoveries,subgraphs:k0(e._discoveries,[],0)}},process(i){let s=i.params.namespace;if(s.length===0)return!0;let a=s.slice(0,1),o=tn(a);if(r.has(o))return!0;r.add(o);let c=n(a,e._discoveries.size,e._events.size);return e.register(a,c),e._discoveries.push({ns:a,stream:c}),!0}}}function nJ(e){let t=ks.local();return{init:()=>({_valuesLog:t}),process(n){return n.method!=="values"||n.params.namespace.length!==e.length||!ao(n.params.namespace,e)||t.push(n.params.data),!0},finalize(){t.close()},fail(n){t.fail(n)}}}function Bx(e){return"__native"in e&&e.__native===!0}var kP=Symbol("setValuesLog"),xP=Symbol("setMessagesIterable"),Cy=Symbol("setLifecycleIterable"),Ny=Symbol("setSubgraphsIterable"),rJ={[Symbol.asyncIterator](){return{next:()=>Promise.resolve({value:void 0,done:!0})}}},$P=class{path;extensions;_mux;#e;#a;#n;#i;#r;#t;#o;#s;#u;#c;constructor(e,t,n=0,r=0,i,s){this.path=e,this._mux=t,this.#a=n,this.#e=r,this.extensions=i??{},this.#n=s??new AbortController,this.#t=new Promise((a,o)=>{this.#i=a,this.#r=o}),this.#t.catch(()=>{})}[Symbol.asyncIterator](){return this._mux.subscribeEvents(this.path,this.#e)}get subgraphs(){return this.#c?this.#c:k0(this._mux._discoveries,this.path,this.#a)}get values(){let e=this.#o,t=this.#t,n=this._mux,r=this.#e,i=this.path,s=e?e.toAsyncIterable():{[Symbol.asyncIterator]:()=>{let a=n.subscribeEvents(i,r);return{async next(){for(;;){let o=await a.next();if(o.done)return{value:void 0,done:!0};if(o.value.method==="values"&&o.value.params.namespace.length===i.length)return{value:o.value.params.data,done:!1}}}}}};return{[Symbol.asyncIterator]:()=>s[Symbol.asyncIterator](),then:t.then.bind(t)}}get messages(){if(this.#s)return this.#s;let e=Ey(this.path),t=e.init();return this._mux.addTransformer(e),this.#s=t.messages,this.#s}get lifecycle(){return this.#u??rJ}messagesFrom(e){let t=Ey(this.path,e),n=t.init();return this._mux.addTransformer(t),n.messages}get output(){return this.#t}get interrupted(){return this._mux.interrupted}get interrupts(){return this._mux.interrupts}abort(e){this.#n.abort(e)}get signal(){return this.#n.signal}[Ty](e){this.#i?.(e),this.#i=void 0}[vP](e){this.#r?.(e),this.#r=void 0}[kP](e){this.#o=e}[xP](e){this.#s=e}[Cy](e){this.#u=e}[Ny](e){this.#c=e}},iJ=class extends $P{name;index;constructor(e,t,n=0,r=0,i,s){super(e,t,n,r,i,s);let a=e[e.length-1]??"",o=a.lastIndexOf(":");if(o>=0){this.name=a.slice(0,o);let c=a.slice(o+1);this.index=/^\d+$/.test(c)?Number(c):0}else this.name=a,this.index=0}};function sJ(e,t=[],n){let{abortController:r}=n instanceof AbortController?{abortController:n}:{},i=new Kq,s=eJ(),a=s.init(),o=a._lifecycleLog,c=tJ(i,{createStream:(g,y,w)=>{let x=new iJ(g,i,y,w);return x[Ny](k0(i._discoveries,g,y)),x[Cy](bP(o,g,o.size)),x}}),u=c.init();i.addTransformer(c),i.addTransformer(s);let l=nJ([]),d=Ey([]);i.addTransformer(l),i.addTransformer(d);let p={},h=[];for(let g of t){let y=g();i.addTransformer(y);let w=y.init();Bx(y)?h.push(w):Object.assign(p,w),typeof w=="object"&&w!==null&&!Bx(y)&&i.wireChannels(w)}let m=new $P([],i,0,0,p,r);for(let g of h)Object.assign(m,g);let f=l.init();m[kP](f._valuesLog);let v=d.init();return m[xP](v.messages),m[Cy](a.lifecycle),m[Ny](u.subgraphs),i.register([],m),Wq(e,i).catch(g=>{}),m}var D=e=>BigInt(e),De=(e,t=0)=>new DataView(e.buffer,e.byteOffset+t,e.byteLength-t),IP=D("0x9E3779B1"),SP=D("0x85EBCA77"),aJ=D("0xC2B2AE3D"),Pi=D("0x9E3779B185EBCA87"),xs=D("0xC2B2AE3D27D4EB4F"),OP=D("0x165667B19E3779F9"),x0=D("0x85EBCA77C2B2AE63"),oJ=D("0x27D4EB2F165667C5"),cJ=D("0x165667919E3779F9"),uJ=D("0x9FB21C651E98DF25"),lJ=e=>{let t=e.length;if(t%2!==0)throw new Error("String should have an even number of characters");let n=t/2,r=new Uint8Array(n),i=0,s=0;for(;s<n;){let a=e.slice(i,i+=2);r[s]=Number.parseInt(a,16),s+=1}return De(r)},pr=lJ("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),ga=(D(1)<<D(128))-D(1),ke=(D(1)<<D(64))-D(1),Vd=(D(1)<<D(32))-D(1),Dr=64,AP=Dr/8,dJ=8,yl=4;function Za(e){if(!e)throw new Error("Assert failed")}function pJ(e){let t=new DataView(new ArrayBuffer(8));return t.setBigUint64(0,e,!0),t.getBigUint64(0,!1)}function hJ(e){let t=e;return t=(t&D(65535))<<D(16)|(t&D(4294901760))>>D(16),t=(t&D(16711935))<<D(8)|(t&D(4278255360))>>D(8),t}function mJ(e,t){return(e&Vd)*(t&Vd)&ke}function fJ(e,t){return(e<<t|e>>D(32)-t)&Vd}function TP(e,t,n){for(let r=0;r<AP;r+=1){let i=t.getBigUint64(r*8,!0),s=i^n.getBigUint64(r*8,!0);e[r^1]+=i,e[r]+=mJ(s,s>>D(32))}return e}function qx(e,t,n,r){for(let i=0;i<r;i+=1)TP(e,De(t,i*Dr),De(n,i*8));return e}function gJ(e,t){for(let n=0;n<AP;n+=1){let r=t.getBigUint64(n*8,!0),i=e[n];i=Py(i,D(47)),i^=r,i*=IP,e[n]=i&ke}return e}function _l(e,t){return EP(e[0]^t.getBigUint64(0,!0),e[1]^t.getBigUint64(dJ,!0))}function Jx(e,t,n){let r=n;return r+=_l(e.slice(0),De(t,0*yl)),r+=_l(e.slice(2),De(t,4*yl)),r+=_l(e.slice(4),De(t,8*yl)),r+=_l(e.slice(6),De(t,12*yl)),_r(r&ke)}function yJ(e,t,n,r,i){let s=e,a=Math.floor((n.byteLength-Dr)/8),o=Dr*a,c=Math.floor((t.byteLength-1)/o);for(let u=0;u<c;u+=1)s=qx(s,De(t,u*o),n,a),s=i(s,De(n,n.byteLength-Dr));{let u=Math.floor((t.byteLength-1-o*c)/Dr);s=qx(s,De(t,c*o),n,u),s=r(s,De(t,t.byteLength-Dr),De(n,n.byteLength-Dr-7))}return s}function _J(e,t){let n=new BigUint64Array([aJ,Pi,xs,OP,x0,SP,oJ,IP]);Za(e.byteLength>128),n=yJ(n,e,t,TP,gJ),Za(n.length*8===64);{let r=Jx(n,De(t,11),D(e.byteLength)*Pi&ke);return Jx(n,De(t,t.byteLength-Dr-11),~(D(e.byteLength)*xs)&ke)<<D(64)|r}}function EP(e,t){let n=e*t&ga;return n&ke^n>>D(64)}function Hx(e,t,n){return EP((e.getBigUint64(0,!0)^t.getBigUint64(0,!0)+n)&ke,(e.getBigUint64(8,!0)^t.getBigUint64(8,!0)-n)&ke)}function Xl(e,t,n,r,i){let s=e&ke,a=e>>D(64)&ke;return s+=Hx(t,r,i),s^=n.getBigUint64(0,!0)+n.getBigUint64(8,!0),s&=ke,a+=Hx(n,De(r,16),i),a^=t.getBigUint64(0,!0)+t.getBigUint64(8,!0),a&=ke,a<<D(64)|s}function _r(e){let t=e;return t^=t>>D(37),t*=cJ,t&=ke,t^=t>>D(32),t}function Kd(e){let t=e;return t^=t>>D(33),t*=xs,t&=ke,t^=t>>D(29),t*=OP,t&=ke,t^=t>>D(32),t}function vJ(e,t,n){let r=e.byteLength;Za(r>0&&r<=3);let i=D(e.getUint8(r-1))|D(r<<8)|D(e.getUint8(0)<<16)|D(e.getUint8(r>>1)<<24),s=(i^(D(t.getUint32(0,!0))^D(t.getUint32(4,!0)))+n)&ke,a=(D(t.getUint32(8,!0))^D(t.getUint32(12,!0)))-n;return(Kd((fJ(hJ(i),D(13))^a)&ke)&ke)<<D(64)|Kd(s)}function Py(e,t){return e^e>>t}function bJ(e,t,n){let r=e.byteLength;Za(r>=4&&r<=8);{let i=e.getUint32(0,!0),s=e.getUint32(r-4,!0),a=((D(i)|D(s)<<D(32))^(t.getBigUint64(16,!0)^t.getBigUint64(24,!0))+n&ke)*(Pi+(D(r)<<D(2)))&ga;return a+=(a&ke)<<D(65),a&=ga,a^=a>>D(67),Py(Py(a&ke,D(35))*uJ&ke,D(28))|_r(a>>D(64))<<D(64)}}function wJ(e,t,n){let r=e.byteLength;Za(r>=9&&r<=16);{let i=(t.getBigUint64(32,!0)^t.getBigUint64(40,!0))+n&ke,s=(t.getBigUint64(48,!0)^t.getBigUint64(56,!0))-n&ke,a=e.getBigUint64(0,!0),o=e.getBigUint64(r-8,!0),c=(a^o^i)*Pi,u=(c&ke)+(D(r-1)<<D(54));c=c&(ga^ke)|u,o^=s,c+=o+(o&Vd)*(SP-D(1))<<D(64),c&=ga,c^=pJ(c>>D(64));let l=(c&ke)*xs;return l+=(c>>D(64))*xs<<D(64),l&=ga,_r(l&ke)|_r(l>>D(64))<<D(64)}}function kJ(e,t){let n=e.byteLength;return Za(n<=16),n>8?wJ(e,pr,t):n>=4?bJ(e,pr,t):n>0?vJ(e,pr,t):Kd(t^pr.getBigUint64(64,!0)^pr.getBigUint64(72,!0))|Kd(t^pr.getBigUint64(80,!0)^pr.getBigUint64(88,!0))<<D(64)}function jy(e){return~e+D(1)&ke}function xJ(e,t,n){let r=D(e.byteLength)*Pi&ke,i=D(e.byteLength-1)/D(32);for(;i>=0;){let o=Number(i);r=Xl(r,De(e,16*o),De(e,e.byteLength-16*(o+1)),De(t,32*o),n),i-=D(1)}let s=r+(r>>D(64))&ke;s=_r(s);let a=(r&ke)*Pi+(r>>D(64))*x0+(D(e.byteLength)-n&ke)*xs;return a&=ke,a=jy(_r(a)),s|a<<D(64)}function $J(e,t,n){let r=D(e.byteLength)*Pi&ke;for(let a=32;a<160;a+=32)r=Xl(r,De(e,a-32),De(e,a-16),De(t,a-32),n);r=_r(r&ke)|_r(r>>D(64))<<D(64);for(let a=160;a<=e.byteLength;a+=32)r=Xl(r,De(e,a-32),De(e,a-16),De(t,3+a-160),n);r=Xl(r,De(e,e.byteLength-16),De(e,e.byteLength-32),De(t,103),jy(n));let i=r+(r>>D(64))&ke;i=_r(i);let s=(r&ke)*Pi+(r>>D(64))*x0+(D(e.byteLength)-n&ke)*xs;return s&=ke,s=jy(_r(s)),i|s<<D(64)}function Wi(e,t=D(0)){let n=new TextEncoder,r=De(typeof e=="string"?n.encode(e):e),i=r.byteLength,s=a=>a.toString(16).padStart(32,"0");return i<=16?s(kJ(r,t)):i<=128?s(xJ(r,pr,t)):i<=240?s($J(r,pr,t)):s(_J(r,pr))}function CP(e){return/^[0-9a-f]{32}$/.test(e)}function IJ(e){let t=jt.getRunnableConfig();if(!t)throw new Error("Called interrupt() outside the context of a graph.");let n=t.configurable;if(!n)throw new Error("No configurable found in config");if(!n.__pregel_checkpointer)throw new Ul("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let r=n[mi];r.interruptCounter+=1;let i=r.interruptCounter;if(r.resume.length>0&&i<r.resume.length)return n[hi]?.([[ki,r.resume]]),r.resume[i];if(r.nullResume!==void 0){if(r.resume.length!==i)throw new Error(`Resume length mismatch: ${r.resume.length} !== ${i}`);let a=r.consumeNullResume();return r.resume.push(a),n[hi]?.([[ki,r.resume]]),a}let s=n[Zr]?.split("|");throw new pa([{id:s?Wi(s.join("|")):void 0,value:e}])}var Rs=class extends Ae{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,n){return new Promise((r,i)=>{let s=Re(t,{callbacks:n?.getChild()});jt.runWithConfig(s,async()=>{try{r(await this.func(e,s))}catch(a){i(a)}})})}async invoke(e,t){let n,r=_P(t),i=Nn(this.config,r);return this.trace?n=await this._callWithConfig(this._tracedInvoke,e,i):n=await jt.runWithConfig(i,async()=>this.func(e,i)),Ae.isRunnable(n)&&this.recurse?await jt.runWithConfig(i,async()=>n.invoke(e,i)):n}};function*ri(e,t){if(t===void 0)yield*e;else for(let n of e)yield[t,n]}async function ui(e){let t=[];for await(let n of await e)t.push(n);return t}function Po(e){let t=[];for(let n of e)t.push(n);return t}function Bs(e,t){return e?"configurable"in e?{...e,configurable:{...e.configurable,...t}}:{...e,configurable:t}:{configurable:t}}function SJ(e){return typeof e=="object"&&e?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var ps={[Symbol.for("LG_PASSTHROUGH")]:!0};function vl(e){return typeof e=="object"&&e?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var Of=Symbol("IS_WRITER"),Kt=class Ry extends Rs{writes;constructor(t,n){let r=`ChannelWrite<${t.map(i=>cn(i)?i.node:"channel"in i?i.channel:"...").join(",")}>`;super({writes:t,name:r,tags:n,trace:!1,func:async(i,s)=>this._write(i,s??{})}),this.writes=t}async _write(t,n){let r=this.writes.map(i=>Af(i)&&vl(i.value)?{mapper:i.mapper,value:t}:Yl(i)&&vl(i.value)?{channel:i.channel,value:t,skipNone:i.skipNone,mapper:i.mapper}:i);return await Ry.doWrite(n,r),t}static async doWrite(t,n){for(let s of n){if(Yl(s)){if(s.channel==="__pregel_tasks")throw new qe("Cannot write to the reserved channel TASKS");if(vl(s.value))throw new qe("PASSTHROUGH value must be replaced")}if(Af(s)&&vl(s.value))throw new qe("PASSTHROUGH value must be replaced")}let r=[];for(let s of n)if(cn(s))r.push([_a,s]);else if(Af(s)){let a=await s.mapper.invoke(s.value,t);a!=null&&a.length>0&&r.push(...a)}else if(Yl(s)){let a=s.mapper!==void 0?await s.mapper.invoke(s.value,t):s.value;if(SJ(a)||s.skipNone&&a===void 0)continue;r.push([s.channel,a])}else throw new Error(`Invalid write entry: ${JSON.stringify(s)}`);let i=t.configurable?.[hi];i(r)}static isWriter(t){return t instanceof Ry||Of in t&&!!t[Of]}static registerWriter(t){return Object.defineProperty(t,Of,{value:!0})}};function Yl(e){return e!==void 0&&typeof e.channel=="string"}function Af(e){return e!==void 0&&!Yl(e)&&Ae.isRunnable(e.mapper)}var OJ=class NP extends Rs{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor(t,n,r=!1){super({trace:!1,func:(i,s)=>NP.doRead(s,this.channel,this.fresh,this.mapper)}),this.fresh=r,this.mapper=n,this.channel=t,this.name=Array.isArray(t)?`ChannelRead<${t.join(",")}>`:`ChannelRead<${t}>`}static doRead(t,n,r,i){let s=t.configurable?.[as];if(!s)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(s(n,r)):s(n,r)}},qs=new vc,Ac=class jo extends Ci{lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=qs;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor(t){let{channels:n,triggers:r,mapper:i,writers:s,bound:a,kwargs:o,metadata:c,retryPolicy:u,cachePolicy:l,tags:d,subgraphs:p,ends:h}=t,m=[...t.config?.tags?t.config.tags:[],...d??[]];super({...t,bound:t.bound??qs,config:{...t.config?t.config:{},tags:m}}),this.channels=n,this.triggers=r,this.mapper=i,this.writers=s??this.writers,this.bound=a??this.bound,this.kwargs=o??this.kwargs,this.metadata=c??this.metadata,this.tags=m,this.retryPolicy=u,this.cachePolicy=l,this.subgraphs=p,this.ends=h}getWriters(){let t=[...this.writers];for(;t.length>1&&t[t.length-1]instanceof Kt&&t[t.length-2]instanceof Kt;){let n=t.slice(-2),r=n[0].writes.concat(n[1].writes);t[t.length-2]=new Kt(r,n[0].config?.tags),t.pop()}return t}getNode(){let t=this.getWriters();if(!(this.bound===qs&&t.length===0))return this.bound===qs&&t.length===1?t[0]:this.bound===qs?new Ni({first:t[0],middle:t.slice(1,t.length-1),last:t[t.length-1],omitSequenceTags:!0}):t.length>0?new Ni({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 jo({channels:{...this.channels,...Object.fromEntries(t.map(n=>[n,n]))},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 Kt.isWriter(t)?new jo({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===qs?new jo({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:Nt(t),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy}):new jo({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 AJ(e){return"steps"in e&&Array.isArray(e.steps)}function $0(e){return"lg_is_pregel"in e&&e.lg_is_pregel===!0}function PP(e){let t=[e];for(let n of t){if($0(n))return n;AJ(n)&&t.push(...n.steps)}}function ya(e,t,n=!0,r=!1){try{return e[t].get()}catch(i){if(i.name===$t.unminifiable_name){if(r)return i;if(n)return null}throw i}}function $s(e,t,n=!0){if(Array.isArray(t)){let r={};for(let i of t)try{r[i]=ya(e,i,!n)}catch(s){if(s.name===$t.unminifiable_name)continue}return r}else return ya(e,t)}function*TJ(e,t){if(e.graph===fr.PARENT)throw new qe("There is no parent graph.");if(e.goto){let n;Array.isArray(e.goto)?n=e.goto:n=[e.goto];for(let r of n)if(cn(r))yield[mr,_a,r];else if(typeof r=="string")yield[mr,`branch:to:${r}`,"__start__"];else throw new Error(`In Command.send, expected Send or string, got ${typeof r}`)}if(e.resume)if(typeof e.resume=="object"&&Object.keys(e.resume).length&&Object.keys(e.resume).every(CP))for(let[n,r]of Object.entries(e.resume)){let i=t.filter(s=>s[0]===n&&s[1]==="__resume__").map(s=>s[2]).slice(0,1)??[];i.push(r),yield[n,ki,i]}else yield[mr,ki,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[n,r]of e.update)yield[mr,n,r];else for(let[n,r]of Object.entries(e.update))yield[mr,n,r]}}function*jP(e,t){if(t!=null)if(Array.isArray(e)&&typeof t=="object"&&!Array.isArray(t))for(let n in t)e.includes(n)&&(yield[n,t[n]]);else{if(Array.isArray(e))throw new Error('Input chunk must be an object when "inputChannels" is an array');yield[e,t]}}function*Tf(e,t,n){Array.isArray(e)?(t===!0||t.find(([r,i])=>e.includes(r)))&&(yield $s(n,e)):(t===!0||t.some(([r,i])=>r===e))&&(yield ya(n,e))}function*EJ(e,t,n){let r=t.filter(([o,c])=>(o.config===void 0||!o.config.tags?.includes("langsmith:hidden"))&&c[0][0]!=="__error__"&&c[0][0]!=="__interrupt__");if(!r.length)return;let i;r.some(([o])=>o.writes.some(([c,u])=>c==="__return__"))?i=r.flatMap(([o])=>o.writes.filter(([c,u])=>c===ph).map(([c,u])=>[o.name,u])):Array.isArray(e)?i=r.flatMap(([o])=>{let{writes:c}=o,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])=>[o.name,{[l]:d}]):[[o.name,Object.fromEntries(c.filter(([l])=>e.includes(l)))]]}):i=r.flatMap(([o])=>o.writes.filter(([c,u])=>c===e).map(([c,u])=>[o.name,u]));let s={};for(let[o,c]of i)o in s||(s[o]=[]),s[o].push(c);let a={};for(let o in s)if(s[o].length===1){let[c]=s[o];a[o]=c}else a[o]=s[o];n&&(a.__metadata__={cached:n}),yield a}function I0(e){let t=typeof e[_t];if(t==="number")return 0;if(t==="string")return"";for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=typeof e[n];if(r==="number")return 0;if(r==="string")return"";break}}function Ql(e,t){if(Object.keys(e).length>0){let n=I0(t);return Object.fromEntries(Object.entries(t).filter(([r,i])=>i>(e[r]??n)))}else return t}function CJ(e,t){return e&&!Array.isArray(e)&&!(e instanceof Date)&&typeof e=="object"?e:{[t]:e}}function Gn(e,t){return e===null?{configurable:t}:e?.configurable===void 0?{...e,configurable:t}:{...e,configurable:{...e.configurable,...t}}}function Hi(e,t){let n=t?.parents??{};return Object.keys(n).length>0?Gn(e,{[Mr]:{...n,[e.configurable?.checkpoint_ns??""]:e.configurable?.checkpoint_id}}):e}function Wd(...e){let t=[...new Set(e.filter(Boolean))];if(t.length===0)return{signal:void 0,dispose:void 0};if(t.length===1)return{signal:t[0],dispose:void 0};let n=new AbortController,r=()=>{let s=t.find(a=>a.aborted)?.reason;n.abort(s),t.forEach(a=>a.removeEventListener("abort",r))};t.forEach(s=>s.addEventListener("abort",r,{once:!0}));let i=t.find(s=>s.aborted);return i&&n.abort(i.reason),{signal:n.signal,dispose:()=>{t.forEach(s=>s.removeEventListener("abort",r))}}}var NJ=(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},PJ=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:e,name:t,input:n,retry:r,cache:i,callbacks:s}){this.func=e,this.name=t,this.input=n,this.retry=r,this.cache=i,this.callbacks=s}};function jJ(e){return typeof e=="object"&&e!==null&&"__lg_type"in e&&e.__lg_type==="call"}function RJ(e,t){return new Ni({name:e,first:new Rs({func:n=>t(...n),name:e,trace:!1,recurse:!1}),last:new Kt([{channel:ph,value:ps}],[rn])})}var MJ=e=>e!==void 0?e+1:1;function UJ(e,t){if(t==null)return!1;for(let n of e)if(t[n])return!0;return!1}function LJ(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t==null?t=e[n]:t=Iq(t,e[n]));return t}function bl(e,t,n){let r=I0(e.channel_versions),i=e.versions_seen.__interrupt__??{},s=!1;if((e.channel_versions.__start__??r)>(i.__start__??r))s=!0;else for(let o in e.channel_versions)if(Object.prototype.hasOwnProperty.call(e.channel_versions,o)&&e.channel_versions[o]>(i[o]??r)){s=!0;break}let a=n.some(o=>t==="*"?!o.config?.tags?.includes(rn):t.includes(o.name));return s&&a}function ed(e,t,n,r,i=!1){let s=new Set;if(Array.isArray(r))s=new Set(r.filter(o=>n.writes.some(([c,u])=>c===o)));else{for(let[o]of n.writes)if(o===r){s=new Set([o]);break}s=s||new Set}let a;if(i&&s.size>0){let o=Object.fromEntries(Object.entries(t).filter(([l,d])=>s.has(l))),c=Yi(e,o,-1),u=qd(o,c);yn(Bd(c),u,[n],void 0,void 0),a=$s({...t,...u},r)}else a=$s(t,r);return a}function Ef(e,t,n){for(let[r,i]of n)if(["__pregel_push","__pregel_tasks"].includes(r)&&i!=null){if(!cn(i))throw new qe(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(i)}`);if(!(i.node in t))throw new qe(`Invalid node name "${i.node}" in Send packet`)}e(n)}var zJ=new Set([f_,Br,ki,yt,ph,dh]);function yn(e,t,n,r,i){n.sort((p,h)=>{let m=p.path?.slice(0,3)||[],f=h.path?.slice(0,3)||[];for(let v=0;v<Math.min(m.length,f.length);v+=1){if(m[v]<f[v])return-1;if(m[v]>f[v])return 1}return m.length-f.length});let s=n.some(p=>p.triggers.length>0),a=w0(t);for(let p of n){e.versions_seen[p.name]??={};for(let h of p.triggers)h in e.channel_versions&&(e.versions_seen[p.name][h]=e.channel_versions[h])}let o=LJ(e.channel_versions),c=new Set(n.flatMap(p=>p.triggers).filter(p=>!r2.includes(p))),u=!1;for(let p of c)p in a&&a[p].consume()&&r!==void 0&&(e.channel_versions[p]=r(o),u=!0);let l={};for(let p of n)for(let[h,m]of p.writes)zJ.has(h)||h in a&&(l[h]??=[],l[h].push(m));o!=null&&r!=null&&(o=u?r(o):o);let d=new Set;for(let[p,h]of Object.entries(l))if(p in a){let m=a[p],f;try{f=m.update(h)}catch(v){if(v.name===qe.unminifiable_name){let g=new qe(`Invalid update for channel "${p}" with values ${JSON.stringify(h)}: ${v.message}`);throw g.lc_error_code=v.lc_error_code,g}else throw v}f&&r!==void 0&&(e.channel_versions[p]=r(o),m.isAvailable()&&d.add(p))}if(s)for(let p in a){if(!Object.prototype.hasOwnProperty.call(a,p))continue;let h=a[p];h.isAvailable()&&!d.has(p)&&h.update([])&&r!==void 0&&(e.channel_versions[p]=r(o),h.isAvailable()&&d.add(p))}if(s&&!UJ(d,i))for(let p in a){if(!Object.prototype.hasOwnProperty.call(a,p))continue;let h=a[p];h.finish()&&r!==void 0&&(e.channel_versions[p]=r(o),h.isAvailable()&&d.add(p))}return d}function*DJ(e,t,n){if(n.updatedChannels!=null&&n.triggerToNodes!=null){let r=new Set;for(let i of n.updatedChannels){let s=n.triggerToNodes[i];for(let a of s??[])r.add(a)}yield*[...r].sort();return}if(!(()=>{for(let r in e.channel_versions)if(e.channel_versions[r]!==null)return!1;return!0})())for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(yield r)}function la(e,t,n,r,i,s,a){let o={},c=r[_a];if(c?.isAvailable()){let u=c.get().length;for(let l=0;l<u;l+=1){let d=My([Br,l],e,t,n,r,i,s,a);d!==void 0&&(o[d.id]=d)}}for(let u of DJ(e,n,a)){let l=My([Gf,u],e,t,n,r,i,s,a);l!==void 0&&(o[l.id]=l)}return o}function My(e,t,n,r,i,s,a,o){let{step:c,checkpointer:u,manager:l}=o,d=s.configurable??{},p=d.checkpoint_ns??"";if(e[0]==="__pregel_push"&&jJ(e[e.length-1])){let h=e[e.length-1],m=RJ(h.name,h.func),f=[Br],v=p===""?h.name:`${p}|${h.name}`,g=ra(JSON.stringify([v,c.toString(),h.name,Br,e[1],e[2]]),t.id),y=`${v}:${g}`,w=[...e.slice(0,3),!0],x={langgraph_step:c,langgraph_node:h.name,langgraph_triggers:f,langgraph_path:w,langgraph_checkpoint_ns:y,checkpoint_ns:y};if(a){let O=[],z={checkpointId:t.id,checkpointNs:y,taskId:g,threadId:d.thread_id,runId:s.runId!=null?String(s.runId):void 0,nodeAttempt:1};return{name:h.name,input:h.input,proc:m,writes:O,config:{...Re(Nn(s,{metadata:x,store:o.store??s.store}),{runName:h.name,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[jl]:g,[hi]:T=>Ef(k=>O.push(...k),r,T),[as]:(T,k=!1)=>ed(t,i,{name:h.name,writes:O,triggers:f,path:w},T,k),[Fr]:u??d.__pregel_checkpointer,[Mr]:{...d[Mr],[p]:t.id},[mi]:Cf({pendingWrites:n??[],taskId:g,currentTaskInput:h.input,resumeMap:s.configurable?.[Rl],namespaceHash:Wi(y)}),[Ml]:t.channel_values[Zm],checkpoint_id:void 0,checkpoint_ns:y}}),executionInfo:z},triggers:f,retry_policy:h.retry,cache_key:h.cache?{key:Wi((h.cache.keyFunc??JSON.stringify)([h.input])),ns:[Fm,h.name??"__dynamic__"],ttl:h.cache.ttl}:void 0,id:g,path:w,writers:[]}}else return{id:g,name:h.name,interrupts:[],path:w}}else if(e[0]==="__pregel_push"){let h=typeof e[1]=="number"?e[1]:parseInt(e[1],10);if(!i.__pregel_tasks?.isAvailable())return;let m=i[_a].get();if(h<0||h>=m.length)return;let f=Xf(m[h])&&!cn(m[h])?new Xo(m[h].node,m[h].args):m[h];if(!Xf(f)){console.warn(`Ignoring invalid packet ${JSON.stringify(f)} in pending sends.`);return}if(!(f.node in r)){console.warn(`Ignoring unknown node name ${f.node} in pending sends.`);return}let v=[Br],g=p===""?f.node:`${p}|${f.node}`,y=ra(JSON.stringify([g,c.toString(),f.node,Br,h.toString()]),t.id),w=`${g}:${y}`,x={langgraph_step:c,langgraph_node:f.node,langgraph_triggers:v,langgraph_path:e.slice(0,3),langgraph_checkpoint_ns:w,checkpoint_ns:w};if(a){let O=r[f.node],z=O.getNode();if(z!==void 0){O.metadata!==void 0&&(x={...x,...O.metadata});let T=[],k={checkpointId:t.id,checkpointNs:w,taskId:y,threadId:d.thread_id,runId:s.runId!=null?String(s.runId):void 0,nodeAttempt:1};return{name:f.node,input:f.args,proc:z,subgraphs:O.subgraphs,writes:T,config:{...Re(Nn(s,{metadata:x,tags:O.tags,store:o.store??s.store}),{runName:f.node,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[jl]:y,[hi]:B=>Ef(C=>T.push(...C),r,B),[as]:(B,C=!1)=>ed(t,i,{name:f.node,writes:T,triggers:v,path:e},B,C),[Fr]:u??d.__pregel_checkpointer,[Mr]:{...d[Mr],[p]:t.id},[mi]:Cf({pendingWrites:n??[],taskId:y,currentTaskInput:f.args,resumeMap:s.configurable?.[Rl],namespaceHash:Wi(w)}),[Ml]:t.channel_values[Zm],checkpoint_id:void 0,checkpoint_ns:w}}),executionInfo:k},triggers:v,retry_policy:O.retryPolicy,cache_key:O.cachePolicy?{key:Wi((O.cachePolicy.keyFunc??JSON.stringify)([f.args])),ns:[Fm,O.name??"__dynamic__",f.node],ttl:O.cachePolicy.ttl}:void 0,id:y,path:e,writers:O.getWriters()}}}else return{id:y,name:f.node,interrupts:[],path:e}}else if(e[0]==="__pregel_pull"){let h=e[1].toString(),m=r[h];if(m===void 0)return;if(n?.length){let y=p===""?h:`${p}|${h}`,w=ra(JSON.stringify([y,c.toString(),h,Gf,h]),t.id);if(n.some(x=>x[0]===w&&x[1]!=="__error__"))return}let f=I0(t.channel_versions);if(f===void 0)return;let v=t.versions_seen[h]??{},g=m.triggers.find(y=>i[y].isAvailable()?(t.channel_versions[y]??f)>(v[y]??f):!1);if(g!==void 0){let y=FJ(m,i,a);if(y===void 0)return;let w=p===""?h:`${p}|${h}`,x=ra(JSON.stringify([w,c.toString(),h,Gf,[g]]),t.id),O=`${w}:${x}`,z={langgraph_step:c,langgraph_node:h,langgraph_triggers:[g],langgraph_path:e,langgraph_checkpoint_ns:O,checkpoint_ns:O};if(a){let T=m.getNode();if(T!==void 0){m.metadata!==void 0&&(z={...z,...m.metadata});let k=[],B={checkpointId:t.id,checkpointNs:O,taskId:x,threadId:d.thread_id,runId:s.runId!=null?String(s.runId):void 0,nodeAttempt:1};return{name:h,input:y,proc:T,subgraphs:m.subgraphs,writes:k,config:{...Re(Nn(s,{metadata:z,tags:m.tags,store:o.store??s.store}),{runName:h,callbacks:l?.getChild(`graph:step:${c}`),configurable:{[jl]:x,[hi]:C=>Ef(E=>{k.push(...E)},r,C),[as]:(C,E=!1)=>ed(t,i,{name:h,writes:k,triggers:[g],path:e},C,E),[Fr]:u??d.__pregel_checkpointer,[Mr]:{...d[Mr],[p]:t.id},[mi]:Cf({pendingWrites:n??[],taskId:x,currentTaskInput:y,resumeMap:s.configurable?.[Rl],namespaceHash:Wi(O)}),[Ml]:t.channel_values[Zm],checkpoint_id:void 0,checkpoint_ns:O}}),executionInfo:B},triggers:[g],retry_policy:m.retryPolicy,cache_key:m.cachePolicy?{key:Wi((m.cachePolicy.keyFunc??JSON.stringify)([y])),ns:[Fm,m.name??"__dynamic__",h],ttl:m.cachePolicy.ttl}:void 0,id:x,path:e,writers:m.getWriters()}}}else return{id:x,name:h,interrupts:[],path:e}}}}function FJ(e,t,n){let r;if(typeof e.channels=="object"&&!Array.isArray(e.channels)){r={};for(let[i,s]of Object.entries(e.channels))if(e.triggers.includes(s))try{r[i]=ya(t,s,!1)}catch(a){if(a.name===$t.unminifiable_name)return;throw a}else if(s in t)try{r[i]=ya(t,s,!1)}catch(a){if(a.name===$t.unminifiable_name)continue;throw a}}else if(Array.isArray(e.channels)){let i=!1;for(let s of e.channels)try{r=ya(t,s,!1),i=!0;break}catch(a){if(a.name===$t.unminifiable_name)continue;throw a}if(!i)return}else throw new Error(`Invalid channels type, expected list or dict, got ${e.channels}`);return n&&e.mapper!==void 0&&(r=e.mapper(r)),r}function ZJ(e,t){if(typeof e.args!="object"||e.args===null)return e;let n={};for(let[r,i]of Object.entries(e.args)){let s=t[r];(!s||s.lc_graph_name!=="UntrackedValue")&&(n[r]=i)}return new Xo(e.node,n)}function Cf({pendingWrites:e,taskId:t,currentTaskInput:n,resumeMap:r,namespaceHash:i}){let s=e.find(([o,c])=>o==="00000000-0000-0000-0000-000000000000"&&c==="__resume__")?.[2],a={callCounter:0,interruptCounter:-1,resume:(()=>{let o=e.filter(([c,u])=>c===t&&u==="__resume__").flatMap(([c,u,l])=>l);if(r!=null&&i in r){let c=r[i];o.push(c)}return o})(),nullResume:s,subgraphCounter:0,currentTaskInput:n,consumeNullResume:()=>{if(a.nullResume)return delete a.nullResume,e.splice(e.findIndex(([o,c])=>o==="00000000-0000-0000-0000-000000000000"&&c==="__resume__"),1),s}};return a}var Tc={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},Ec=(e,t)=>`${e.start}${t}${e.end}`;function*Vx(e){for(let{id:t,name:n,input:r,config:i,triggers:s,writes:a}of e)i?.tags?.includes("langsmith:hidden")||(yield{id:t,name:n,input:r,triggers:s,interrupts:a.filter(([o,c])=>o===t&&c==="__interrupt__").map(([,o])=>o)})}function BJ(e){return typeof e!="object"||e===null?!1:"$writes"in e&&Array.isArray(e.$writes)}function RP(e){let t={};for(let[n,r]of e){let i=String(n);if(i in t){let s=BJ(t[i])?t[i].$writes:[t[i]];s.push(r),t[i]={$writes:s}}else t[i]=r}return t}function*qJ(e,t){for(let[{id:n,name:r,config:i},s]of e)i?.tags?.includes("langsmith:hidden")||(yield{id:n,name:r,result:RP(s.filter(([a])=>Array.isArray(t)?t.includes(a):a===t)),interrupts:s.filter(a=>a[0]===yt).map(a=>a[1])})}function*JJ(e,t,n,r,i,s,a,o){function c(d){let p={};return d.callbacks!=null&&(p.callbacks=d.callbacks),d.configurable!=null&&(p.configurable=d.configurable),d.maxConcurrency!=null&&(p.max_concurrency=d.maxConcurrency),d.metadata!=null&&(p.metadata=d.metadata),d.recursionLimit!=null&&(p.recursion_limit=d.recursionLimit),d.runId!=null&&(p.run_id=d.runId),d.runName!=null&&(p.run_name=d.runName),d.tags!=null&&(p.tags=d.tags),p}let u=e.configurable?.checkpoint_ns,l={};for(let d of i){if(!(d.subgraphs?.length?d.subgraphs:[d.proc]).find(PP))continue;let p=`${d.name}:${d.id}`;u&&(p=`${u}|${p}`),l[d.id]={configurable:{thread_id:e.configurable?.thread_id,checkpoint_ns:p}}}yield{config:c(e),values:$s(t,n),metadata:r,next:i.map(d=>d.name),tasks:MP(i,s,l,o),parentConfig:a?c(a):void 0}}function MP(e,t,n,r){return e.map(i=>{let s=t.find(([u,l])=>u===i.id&&l==="__error__")?.[2],a=t.filter(([u,l])=>u===i.id&&l==="__interrupt__").map(([,,u])=>u),o=(()=>{if(s||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 r=="string")return t.find(([l,d])=>l===i.id&&d===r)?.[2];if(Array.isArray(r)){let l=t.filter(([d,p])=>d===i.id&&r.includes(p)).map(([,d,p])=>[d,p]);return l.length?RP(l):void 0}})();if(s)return{id:i.id,name:i.name,path:i.path,error:s,interrupts:a,result:o};let c=n?.[i.id];return{id:i.id,name:i.name,path:i.path,interrupts:a,...c!==void 0?{state:c}:{},result:o}})}function HJ(e,t,n){console.log([`${Ec(Tc.blue,`[${e}:checkpoint]`)}`,`\x1B[1m State at the end of step ${e}:\x1B[0m
|
|
323
|
+
`,JSON.stringify($s(t,n),null,2)].join(""))}function UP(e,t){let n=t.length;console.log([`${Ec(Tc.blue,`[${e}:tasks]`)}`,`\x1B[1m Starting step ${e} with ${n} task${n===1?"":"s"}:\x1B[0m
|
|
324
|
+
`,t.map(r=>`- ${Ec(Tc.green,String(r.name))} -> ${JSON.stringify(r.input,null,2)}`).join(`
|
|
325
|
+
`)].join(""))}function VJ(e,t,n){let r={};for(let[i,s]of t)n.includes(i)&&(r[i]||(r[i]=[]),r[i].push(s));console.log([`${Ec(Tc.blue,`[${e}:writes]`)}`,`\x1B[1m Finished step ${e} with writes to ${Object.keys(r).length} channel${Object.keys(r).length!==1?"s":""}:\x1B[0m
|
|
326
|
+
`,Object.entries(r).map(([i,s])=>`- ${Ec(Tc.yellow,i)} -> ${s.map(a=>JSON.stringify(a)).join(", ")}`).join(`
|
|
327
|
+
`)].join(""))}var Nf=class extends un{_abortController;_innerReader;constructor(e,t){let n=e.getReader(),r=t??new AbortController;super({start(i){return s();function s(){return n.read().then(({done:a,value:o})=>{if(a){i.close();return}return i.enqueue(o),s()})}}}),this._abortController=r,this._innerReader=n}async cancel(e){this._abortController.abort(e),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},LP=class extends un{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(e){let t,n=new Promise(r=>{t=r});super({start:r=>{t(r)}}),n.then(r=>{this.controller=r}),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)}},KJ=class extends Li{name="StreamToolsHandler";streamFn;runs={};constructor(e){super(),this.streamFn=e}handleToolStart(e,t,n,r,i,s,a,o){if(!s||i&&i.includes("langsmith:hidden"))return;let c=s.langgraph_checkpoint_ns?.split("|")??[],u={ns:c,toolCallId:o,toolName:a??"unknown",input:t};this.runs[n]=u,this.streamFn([c,"tools",{event:"on_tool_start",toolCallId:u.toolCallId,name:u.toolName,input:t}])}handleToolEvent(e,t){let n=this.runs[t];n&&this.streamFn([n.ns,"tools",{event:"on_tool_event",toolCallId:n.toolCallId,name:n.toolName,data:e}])}handleToolEnd(e,t){let n=this.runs[t];delete this.runs[t],n&&this.streamFn([n.ns,"tools",{event:"on_tool_end",toolCallId:n.toolCallId,name:n.toolName,output:e}])}handleToolError(e,t){let n=this.runs[t];delete this.runs[t],n&&this.streamFn([n.ns,"tools",{event:"on_tool_error",toolCallId:n.toolCallId,name:n.toolName,error:e}])}};function WJ(e){return JSON.stringify(e,function(t,n){let r=this[t];if(r!=null&&typeof r=="object"&&"toDict"in r&&typeof r.toDict=="function"){let{type:i,data:s}=r.toDict();return{...s,type:i}}return n})}function GJ(e){return e instanceof Error?{error:e.name,message:e.message}:{error:"Error",message:JSON.stringify(e)}}function S0(e){return typeof e!="object"||e==null?!1:"configurable"in e&&typeof e.configurable=="object"&&e.configurable!=null}function Pf(e){return!S0(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 Kx(e){if(S0(e)){let t=Object.fromEntries(Object.entries(e.configurable).filter(([r])=>!r.startsWith("__"))),n={...e,configurable:t};return delete n.callbacks,n}return e}function Wx(e){let t={...e,checkpoint:Pf(e.config),parent_checkpoint:Pf(e.parentConfig),config:Kx(e.config),parent_config:Kx(e.parentConfig),tasks:e.tasks.map(n=>{if(S0(n.state)){let r=Pf(n.state);if(r!=null){let i={...n,checkpoint:r};return delete i.state,i}}return n})};return delete t.parentConfig,t}function XJ(e){let t=new TextEncoder;return new ReadableStream({async start(n){let r=i=>{n.enqueue(t.encode(`event: ${i.event}
|
|
328
|
+
data: ${WJ(i.data)}
|
|
329
|
+
|
|
330
|
+
`))};try{for await(let i of e){let[s,a,o]=i,c=o;if(a==="debug"){let u=o;u.type==="checkpoint"&&(c={...u,payload:Wx(u.payload)})}a==="checkpoints"&&(c=Wx(o)),r({event:s?.length?`${a}|${s.join("|")}`:a,data:c})}}catch(i){r({event:"error",data:GJ(i)})}n.close()}})}var wl=Symbol.for("INPUT_DONE"),jf=Symbol.for("INPUT_RESUMING"),YJ=25;function QJ(...e){return new LP({passthroughFn:t=>{for(let n of e)n.modes.has(t[1])&&n.push(t)},modes:new Set(e.flatMap(t=>Array.from(t.modes)))})}var eH=class extends Cq{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 n=this.queue.then(()=>this.cache[e](...t));return this.queue=n.then(()=>{},()=>{}),n}},tH=class zP{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";tasks={};stream;checkpointerPromises=new Set;isNested;_checkpointerChainedPromise=Promise.resolve();_trackCheckpointerPromise(t){let n=t.then(r=>(this.checkpointerPromises.delete(n),r),r=>{throw r});this.checkpointerPromises.add(n)}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 o in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,o)){t=!0;break}let n=this.config.configurable?.__pregel_resuming!==void 0&&this.config.configurable?.__pregel_resuming,r=this.input===null||this.input===void 0,i=Dt(this.input)&&this.input.resume!=null,s=this.input===jf,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&&(n||r||i||s||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=MJ,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 eH(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:n,stream:r}=t;r!==void 0&&n.configurable?.__pregel_stream!==void 0&&(r=QJ(r,n.configurable[m_]));let i=n.configurable?!("checkpoint_id"in n.configurable):!0,s=n.configurable?.[mi];n.configurable&&s&&(s.subgraphCounter>0&&(n=Gn(n,{[Zr]:[n.configurable[Zr],s.subgraphCounter.toString()].join("|")})),s.subgraphCounter+=1);let a=as in(n.configurable??{});!a&&n.configurable?.checkpoint_ns!==void 0&&n.configurable?.checkpoint_ns!==""&&(n=Gn(n,{checkpoint_ns:"",checkpoint_id:void 0}));let o=n;n.configurable?.checkpoint_map!==void 0&&n.configurable?.checkpoint_map?.[n.configurable?.checkpoint_ns]&&(o=Gn(n,{checkpoint_id:n.configurable[Mr][n.configurable?.checkpoint_ns]}));let c=n.configurable?.checkpoint_ns?.split("|")??[],u=await t.checkpointer?.getTuple(o)??{config:n,checkpoint:dP(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};o={...n,...u.config,configurable:{checkpoint_ns:"",...n.configurable,...u.config.configurable}};let l=u.parentConfig,d=Bd(u.checkpoint),p={...u.metadata},h=u.pendingWrites??[],m=qd(t.channelSpecs,d),f=(p.step??0)+1,v=f+(n.recursionLimit??YJ)+1,g={...d.channel_versions},y=t.store?new Eq(t.store):void 0;return y&&await y.start(),new zP({input:t.input,config:n,checkpointer:t.checkpointer,checkpoint:d,checkpointMetadata:p,checkpointConfig:o,prevCheckpointConfig:l,checkpointNamespace:c,channels:m,isNested:a,manager:t.manager,skipDoneTasks:i,step:f,stop:v,checkpointPreviousVersions:g,checkpointPendingWrites:h,outputKeys:t.outputKeys??[],streamKeys:t.streamKeys??[],nodes:t.nodes,stream:r,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._trackCheckpointerPromise(this._checkpointerChainedPromise)}putWrites(t,n){let r=n;if(r.length===0)return;r.every(([c])=>c in Sq)&&(r=Array.from(new Map(r.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 s=r;i&&(s=r.filter(([c])=>{let u=this.channels[c];return!u||u.lc_graph_name!=="UntrackedValue"}).map(([c,u])=>c==="__pregel_tasks"&&cn(u)?[c,ZJ(u,this.channels)]:[c,u])),this.checkpointPendingWrites=this.checkpointPendingWrites.filter(c=>c[0]!==t);for(let[c,u]of s)this.checkpointPendingWrites.push([t,c,u]);let a=Gn(this.checkpointConfig,{[Zr]:this.config.configurable?.checkpoint_ns??"",[Wf]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null&&this._trackCheckpointerPromise(this.checkpointer.putWrites(a,s,t)),this.tasks&&this._outputWrites(t,r),!n.length||!this.cache||!this.tasks)return;let o=this.tasks[t];o==null||o.cache_key==null||n[0][0]==="__error__"||n[0][0]==="__interrupt__"||this.cache.set([{key:[o.cache_key.ns,o.cache_key.key],value:o.writes,ttl:o.cache_key.ttl}])}_outputWrites(t,n,r=!1){let i=this.tasks[t];if(i!==void 0){if(i.config!==void 0&&(i.config.tags??[]).includes("langsmith:hidden"))return;if(n.length>0)if(n[0][0]==="__interrupt__"){if(i.path?.[0]==="__pregel_push"&&i.path?.[i.path.length-1]===!0)return;let s=n.filter(a=>a[0]===yt).flatMap(a=>a[1]);this._emit([["updates",{[yt]:s}],["values",{[yt]:s}]])}else n[0][0]!=="__error__"&&this._emit(Po(ri(EJ(this.outputKeys,[[i,n]],r),"updates")));r||this._emit(Po(ri(qJ([[i,n]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let t=[],n=([a,o])=>`ns:${a.join(",")}|key:${o}`,r=[],i={};for(let a of Object.values(this.tasks))a.cache_key!=null&&!a.writes.length&&(r.push([a.cache_key.ns,a.cache_key.key]),i[n([a.cache_key.ns,a.cache_key.key])]=a);if(r.length===0)return[];let s=await this.cache.get(r);for(let{key:a,value:o}of s){let c=i[n(a)];c!=null&&(c.writes.push(...o),t.push({task:c,result:o}))}return t}async tick(t){this.store&&!this.store.isRunning&&await this.store?.start();let{inputKeys:n=[]}=t;if(this.status!=="pending")throw new Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![wl,jf].includes(this.input))await this._first(n);else{if(this.toInterrupt.length>0)throw this.status="interrupt_before",new pa;if(Object.values(this.tasks).every(i=>i.writes.length>0)){let i=Object.values(this.tasks).flatMap(a=>a.writes);this.updatedChannels=yn(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let s=await ui(ri(Tf(this.outputKeys,i,this.channels),"values"));if(this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),this._emitValuesWithCheckpointMeta(s),bl(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new pa;this.config.configurable?.__pregel_resuming!==void 0&&delete this.config.configurable?.[ld]}else return!1}if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=la(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 ui(ri(JJ(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,s,a]of this.checkpointPendingWrites){if(s==="__error__"||s==="__interrupt__"||s==="__resume__")continue;let o=Object.values(this.tasks).find(c=>c.id===i);o&&o.writes.push([s,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:n});if(bl(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new pa;let r=await ui(ri(Vx(Object.values(this.tasks)),"tasks"));return this._emit(r),!0}async finishAndHandleError(t){this.durability==="exit"&&(!this.isNested||typeof t<"u"||this.checkpointNamespace.every(r=>!r.includes(":")))&&(this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites());let n=this._suppressInterrupt(t);return(n||t===void 0)&&(this.output=$s(this.channels,this.outputKeys)),n&&(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some(r=>r.writes.length>0)&&(this.updatedChannels=yn(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emitValuesWithCheckpointMeta(Po(ri(Tf(this.outputKeys,Object.values(this.tasks).flatMap(r=>r.writes),this.channels),"values")))),na(t)&&!t.interrupts.length&&this._emit([["updates",{[yt]:[]}],["values",{[yt]:[]}]])),n}async acceptPush(t,n,r){if(this.interruptAfter?.length>0&&bl(this.checkpoint,this.interruptAfter,[t])){this.toInterrupt.push(t);return}let i=My([Br,t.path??[],n,t.id,r],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&&bl(this.checkpoint,this.interruptBefore,[i])){this.toInterrupt.push(i);return}this._emit(Po(ri(Vx([i]),"tasks"))),this.debug&&UP(this.step,[i]),this.tasks[i.id]=i,this.skipDoneTasks&&this._matchWrites({[i.id]:i});let s=await this._matchCachedWrites();for(let{task:a}of s)this._outputWrites(a.id,a.writes,!0);return i}_suppressInterrupt(t){return na(t)&&!this.isNested}async _first(t){let{configurable:n}=this.config,r=n?.[mi];if(r&&r.nullResume!==void 0&&this.putWrites(mr,[[ki,r.nullResume]]),Dt(this.input)){let a=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume=="object"&&Object.keys(this.input.resume).every(CP)&&(this.config.configurable??={},this.config.configurable[Rl]=this.input.resume),a&&this.checkpointer==null)throw new Error("Cannot use Command(resume=...) without checkpointer");let o={};for(let[c,u,l]of TJ(this.input,this.checkpointPendingWrites))o[c]??=[],o[c].push([u,l]);if(Object.keys(o).length===0)throw new kw("Received empty Command input");for(let[c,u]of Object.entries(o))this.putWrites(c,u)}let i=(this.checkpointPendingWrites??[]).filter(a=>a[0]===mr).map(a=>a.slice(1));i.length>0&&yn(this.checkpoint,this.channels,[{name:ci,writes:i,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let s=Dt(this.input)&&i.length>0;if(this.isResuming||s){for(let o in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,o)&&this.checkpoint.channel_versions[o]!==void 0){let c=this.checkpoint.channel_versions[o];this.checkpoint.versions_seen[yt]={...this.checkpoint.versions_seen[yt],[o]:c}}let a=await ui(ri(Tf(this.outputKeys,!0,this.channels),"values"));this.isResuming?this.input=jf:s&&(await this._putCheckpoint({source:"input"}),this.input=wl),this._emitValuesWithCheckpointMeta(a)}else{let a=await ui(jP(t,this.input));if(a.length>0){let o=la(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=yn(this.checkpoint,this.channels,Object.values(o).concat([{name:ci,writes:a,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=wl}else if("__pregel_resuming"in(this.config.configurable??{}))this.input=wl;else throw new kw(`Received no input writes for ${JSON.stringify(t,null,2)}`)}this.isNested||(this.config=Gn(this.config,{[ld]:this.isResuming}))}_emit(t){for(let n of t){let[r,i,s]=n;if(this.stream.modes.has(r)&&this.stream.push([this.checkpointNamespace,r,i,s]),(r==="checkpoints"||r==="tasks")&&this.stream.modes.has("debug")){let a=r==="checkpoints"?this.step-1:this.step,o=new Date().toISOString(),c=r==="checkpoints"?"checkpoint":typeof i=="object"&&i!=null&&"result"in i?"task_result":"task";this.stream.push([this.checkpointNamespace,"debug",{step:a,type:c,timestamp:o,payload:i}])}}}_currentCheckpointMeta(){if(!this.checkpointMetadata||!this.checkpoint?.id)return;let t=this.prevCheckpointConfig?.configurable?.checkpoint_id;return{checkpoint:{id:this.checkpoint.id,...t?{parent_id:t}:{},step:this.checkpointMetadata.step,source:this.checkpointMetadata.source}}}_emitValuesWithCheckpointMeta(t){let n=this._currentCheckpointMeta();if(!n){this._emit(t);return}this._emit(t.map(([r,i])=>r==="values"?[r,i,n]:[r,i]))}_putCheckpoint(t){let n=this.checkpointMetadata===t,r=this.checkpointer!=null&&(this.durability!=="exit"||n),i=s=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=Gn(this.checkpointConfig,{[Zr]:this.config.configurable?.checkpoint_ns??""});let a={...this.checkpoint.channel_versions},o=Ql(this.checkpointPreviousVersions,a);this.checkpointPreviousVersions=a,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:Bd(s),metadata:{...this.checkpointMetadata},newVersions:o}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}};n||(this.checkpointMetadata={...t,step:this.step,parents:this.config.configurable?.checkpoint_map??{}}),this.checkpoint=Yi(this.checkpoint,r?this.channels:void 0,this.step,n?{id:this.checkpoint.id}:void 0),r&&i(this.checkpoint),n||(this.step+=1)}_flushPendingWrites(){if(this.checkpointer==null||this.checkpointPendingWrites.length===0)return;let t=Gn(this.checkpointConfig,{[Zr]:this.config.configurable?.checkpoint_ns??"",[Wf]:this.checkpoint.id}),n={};for(let[r,i,s]of this.checkpointPendingWrites)n[r]??=[],n[r].push([i,s]);for(let[r,i]of Object.entries(n))this._trackCheckpointerPromise(this.checkpointer.putWrites(t,i,r))}_matchWrites(t){for(let[n,r,i]of this.checkpointPendingWrites){if(r==="__error__"||r==="__interrupt__"||r==="__resume__")continue;let s=Object.values(t).find(a=>a.id===n);s&&s.writes.push([r,i])}for(let n of Object.values(t))n.writes.length>0&&this._outputWrites(n.id,n.writes,!0)}};function nH(e){return it(e?.message)}function Gx(e,t,n){if(!e)return;let r=e.langgraph_checkpoint_ns,i=e.checkpoint_ns,s=r??i;if(s)return[s.split("|"),{tags:t,name:n,...e}]}var rH=class extends Li{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(e){super(),this.streamFn=e}_emit(e,t,n,r=!1){if(r&&t.id!==void 0&&this.seen[t.id]!==void 0)return;let i=t.id;n!=null&&(ec(t)?i??=`run-${n}-tool-${t.tool_call_id}`:((i==null||i===`run-${n}`)&&(i=this.stableMessageIdMap[n]??i??`run-${n}`),this.stableMessageIdMap[n]??=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,n,r,i,s,a,o){a&&(!s||!s.includes("langsmith:nostream")&&!s.includes("nostream"))&&(this.metadatas[n]=Gx(a,s,o))}handleLLMNewToken(e,t,n,r,i,s){let a=s?.chunk;this.emittedChatModelRunIds[n]=!0,this.metadatas[n]!==void 0&&(nH(a)?this._emit(this.metadatas[n],a.message,n):this._emit(this.metadatas[n],new Pt({content:e}),n))}handleLLMEnd(e,t){if(this.metadatas[t]!==void 0){if(!this.emittedChatModelRunIds[t]){let n=e.generations?.[0]?.[0];it(n?.message)&&this._emit(this.metadatas[t],n?.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,n,r,i,s,a,o){if(s!==void 0&&o===s.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[n]=Gx(s,i,o),typeof t=="object")){for(let c of Object.values(t))if((it(c)||ms(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(it(u)||ms(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let n=this.metadatas[t];if(delete this.metadatas[t],n!==void 0){if(it(e))this._emit(n,e,t,!0);else if(Array.isArray(e))for(let r of e)it(r)&&this._emit(n,r,t,!0);else if(e!=null&&typeof e=="object"){for(let r of Object.values(e))if(it(r))this._emit(n,r,t,!0);else if(Array.isArray(r))for(let i of r)it(i)&&this._emit(n,i,t,!0)}}}handleChainError(e,t){delete this.metadatas[t]}};function Xx(e){if("response_metadata"in e&&typeof e.response_metadata=="object"&&e.response_metadata!=null)return e.response_metadata}function Yx(e){if("usage_metadata"in e&&typeof e.usage_metadata=="object"&&e.usage_metadata!=null)return e.usage_metadata}function iH(e){switch(e.type){case"text":return{type:"text",text:""};case"reasoning":return{type:"reasoning",reasoning:""};case"tool_call":case"tool_call_chunk":return{type:"tool_call_chunk",...e.id!=null?{id:e.id}:{},...e.name!=null?{name:e.name}:{},args:""};default:return e}}function sH(e){switch(e.type){case"text":{let t=typeof e.text=="string"?e.text:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"text-delta",text:t}}:void 0}case"reasoning":{let t=typeof e.reasoning=="string"?e.reasoning:"";return t.length>0?{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"reasoning-delta",reasoning:t}}:void 0}case"tool_call_chunk":return{event:"content-block-delta",index:typeof e.index=="number"?e.index:0,delta:{type:"block-delta",fields:{...e,type:"tool_call_chunk"}}};default:return}}var aH=class extends Li{name="StreamProtocolMessagesHandler";streamFn;metadatas={};seen={};streamedRunIds=new Set;stableMessageIdMap={};lc_prefer_chat_model_stream_events=!0;constructor(e){super(),this.streamFn=e}normalizeMessageId(e,t){let n=e.id;return t!=null&&(ec(e)?n??=`run-${t}-tool-${e.tool_call_id}`:((n==null||n===`run-${t}`)&&(n=this.stableMessageIdMap[t]??n??`run-${t}`),this.stableMessageIdMap[t]??=n)),n!==e.id&&(e.id=n,e.lc_kwargs.id=n),e.id!=null&&(this.seen[e.id]=e),e.id}emit(e,t,n){let r=n!=null?{...e[1],run_id:n}:e[1];this.streamFn([e[0],"messages",[t,r]])}emitFinalMessage(e,t,n,r=!1){let i=t.id??(n!=null?this.stableMessageIdMap[n]:void 0);if(r&&i!=null&&this.seen[i]!==void 0)return;let s=this.normalizeMessageId(t,n),a=t.type==="human"?"human":t.type==="system"?"system":t.type==="tool"?"tool":"ai",o=a==="tool"&&ec(t)?t.tool_call_id:void 0;this.emit(e,{event:"message-start",...s!=null?{id:s}:{},...a!=="ai"?{role:a}:{},...typeof o=="string"?{tool_call_id:o}:{}},n),(Array.isArray(t.content)?t.content:typeof t.content=="string"&&t.content.length>0?[{type:"text",text:t.content}]:[]).forEach((c,u)=>{let l=typeof c.index=="number"?c.index:u;this.emit(e,{event:"content-block-start",index:l,content:iH(c)},n);let d=sH({...c,index:l});d!=null&&this.emit(e,d,n),this.emit(e,{event:"content-block-finish",index:l,content:c},n)}),this.emit(e,{event:"message-finish",...Yx(t)!=null?{usage:Yx(t)}:{},...Xx(t)!=null?{responseMetadata:Xx(t)}:{}},n)}handleChatModelStart(e,t,n,r,i,s,a,o){a&&(!s||!s.includes("langsmith:nostream")&&!s.includes("nostream"))&&(this.metadatas[n]=[a.langgraph_checkpoint_ns.split("|"),{tags:s,name:o,...a}])}handleLLMNewToken(){}handleChatModelStreamEvent(e,t){let n=this.metadatas[t];if(n===void 0)return;let r=e;if(e.event==="message-start"){this.streamedRunIds.add(t);let i=e.id??`run-${t}`;this.seen[i]=!0,this.stableMessageIdMap[t]??=i,e.id==null&&(r={...e,id:i})}this.emit(n,r,t)}handleLLMEnd(e,t){let n=this.metadatas[t];if(n===void 0)return;let r=e.generations?.[0]?.[0],i=it(r?.message)?r.message:void 0;if(i!=null)if(this.streamedRunIds.has(t)){let s=this.normalizeMessageId(i,t);s!=null&&(this.seen[s]=i)}else this.emitFinalMessage(n,i,t,!0);this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleLLMError(e,t){this.streamedRunIds.delete(t),delete this.metadatas[t],delete this.stableMessageIdMap[t]}handleChainStart(e,t,n,r,i,s,a,o){if(s!==void 0&&o===s.langgraph_node&&(i===void 0||!i.includes("langsmith:hidden"))&&(this.metadatas[n]=[s.langgraph_checkpoint_ns.split("|"),{tags:i,name:o,...s}],typeof t=="object")){for(let c of Object.values(t))if((it(c)||ms(c))&&c.id!==void 0)this.seen[c.id]=c;else if(Array.isArray(c))for(let u of c)(it(u)||ms(u))&&u.id!==void 0&&(this.seen[u.id]=u)}}handleChainEnd(e,t){let n=this.metadatas[t];if(delete this.metadatas[t],n===void 0)return;let r=i=>{it(i)&&this.emitFinalMessage(n,i,t,!0)};if(it(e))r(e);else if(Array.isArray(e))for(let i of e)r(i);else if(e!=null&&typeof e=="object")for(let i of Object.values(e))if(Array.isArray(i))for(let s of i)r(s);else r(i);delete this.stableMessageIdMap[t]}handleChainError(e,t){delete this.metadatas[t],delete this.stableMessageIdMap[t]}},oH=[400,401,402,403,404,405,406,407,409],cH=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&&oH.includes(+t)||e?.error?.code==="insufficient_quota")};async function DP(e,t,n,r){let i=e.retry_policy??t,s=i!==void 0?i.initialInterval??500:0,a=0,o,c,u=e.config??{};n&&(u=Gn(u,n)),u={...u,signal:r};let l=Date.now();for(u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeFirstAttemptTime:l});!r?.aborted;){e.writes.splice(0,e.writes.length),o=void 0;try{c=await e.proc.invoke(e.input,u);break}catch(d){if(o=d,o.pregelTaskId=e.id,c2(o)){let m=u?.configurable?.checkpoint_ns,f=o.command;if(f.graph===m){for(let v of e.writers)await v.invoke(f,u);o=void 0;break}else if(f.graph===fr.PARENT){let v=Dq(m);o.command=new fr({...o.command,graph:v})}}if(Ll(o)||i===void 0||(a+=1,a>=(i.maxAttempts??3))||!(i.retryOn??cH)(o))break;s=Math.min(i.maxInterval??128e3,s*(i.backoffFactor??2));let p=i.jitter?Math.floor(s+Math.random()*1e3):s;await new Promise(m=>setTimeout(m,p));let h=o.name??o.constructor.unminifiable_name??o.constructor.name;(i?.logWarning??!0)&&console.log(`Retrying task "${String(e.name)}" after ${s.toFixed(2)}ms (attempt ${a}) after ${h}: ${o}`),u=Gn(u,{[ld]:!0}),u.executionInfo!=null&&(u.executionInfo={...u.executionInfo,nodeAttempt:a+1,nodeFirstAttemptTime:l})}}return{task:e,result:c,error:o,signalAborted:r?.aborted}}var Uy=Symbol.for("promiseAdded");function uH(){let e={next:()=>{},wait:Promise.resolve(Uy)};function t(n){e.next=()=>{e.wait=new Promise(t),n(Uy)}}return e.wait=new Promise(t),e}var lH=class{nodeFinished;loop;constructor({loop:e,nodeFinished:t}){this.loop=e,this.nodeFinished=t}async tick(e={}){let{timeout:t,retryPolicy:n,onStepWrite:r,maxConcurrency:i}=e,s=new Set,a,o=new AbortController,c=o.signal,u=t?AbortSignal.timeout(t):void 0,l=Object.values(this.loop.tasks).filter(m=>m.writes.length===0),{signals:d,disposeCombinedSignal:p}=this._initializeAbortSignals({exceptionSignal:c,stepTimeoutSignal:u,signal:e.signal}),h=this._executeTasksWithRetry(l,{signals:d,retryPolicy:n,maxConcurrency:i});for await(let{task:m,error:f,signalAborted:v}of h)this._commit(m,f),na(f)||Ll(f)&&!na(a)?a=f:f&&(s.size===0||!v)&&(o.abort(),s.add(f));if(p?.(),r?.(this.loop.step,Object.values(this.loop.tasks).map(m=>m.writes).flat()),s.size===1)throw Array.from(s)[0];if(s.size>1)throw new AggregateError(Array.from(s),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(na(a)||Ll(a)&&this.loop.isNested)throw a}_initializeAbortSignals({exceptionSignal:e,stepTimeoutSignal:t,signal:n}){let r=this.loop.config.configurable?.__pregel_abort_signals??{},i=r.externalAbortSignal??n,s=t??r.timeoutAbortSignal,{signal:a,dispose:o}=Wd(i,s,e),c={externalAbortSignal:i,timeoutAbortSignal:s,composedAbortSignal:a};return this.loop.config=Gn(this.loop.config,{[n2]:c}),{signals:c,disposeCombinedSignal:o}}async*_executeTasksWithRetry(e,t){let{retryPolicy:n,maxConcurrency:r,signals:i}=t??{},s=uH(),a={},o={executingTasksMap:a,barrier:s,retryPolicy:n,scheduleTask:async(p,h,m)=>this.loop.acceptPush(p,h,m)};if(i?.composedAbortSignal?.aborted)throw new Error("Abort");let c=0,u,l=Wd(i?.externalAbortSignal,i?.timeoutAbortSignal),d=l.signal?new Promise((p,h)=>{u=()=>h(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<(r??e.length)&&c<e.length;c+=1){let h=e[c];a[h.id]=DP(h,n,{[h_]:FP?.bind(o,this,h)},i?.composedAbortSignal).catch(m=>({task:h,error:m,signalAborted:i?.composedAbortSignal?.aborted}))}let p=await Promise.race([...Object.values(a),...d?[d]:[],s.wait]);p!==Uy&&(yield p,u!=null&&(l.signal?.removeEventListener("abort",u),l.dispose?.()),delete a[p.task.id])}}_commit(e,t){if(t!==void 0)if(na(t)){if(t.interrupts.length){let n=t.interrupts.map(i=>[yt,i]),r=e.writes.filter(i=>i[0]===ki);r.length&&n.push(...r),this.loop.putWrites(e.id,n)}}else Ll(t)&&e.writes.length?this.loop.putWrites(e.id,e.writes):this.loop.putWrites(e.id,[[dh,{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([f_,null]),this.loop.putWrites(e.id,e.writes)}};async function FP(e,t,n,r,i,s={}){let a=t.config?.configurable?.[mi];if(!a)throw new Error(`BUG: No scratchpad found on task ${t.name}__${t.id}`);let o=a.callCounter;a.callCounter+=1;let c=new PJ({func:n,name:r,input:i,cache:s.cache,retry:s.retry,callbacks:s.callbacks}),u=await this.scheduleTask(t,o,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(([h])=>h===ph),p=u.writes.filter(([h])=>h===dh);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(p.length>0){if(p.length===1){let h=p[0][1],m=h instanceof Error?h:new Error(String(h));return Promise.reject(m)}throw new Error(`BUG: multiple errors found for task ${u.name}__${u.id}`)}return}else{let d=DP(u,s.retry,{[h_]:FP.bind(this,e,u)});return this.executingTasksMap[u.id]=d,this.barrier.next(),d.then(({result:p,error:h})=>h?Promise.reject(h):p)}}var Nr=class extends Error{constructor(e){super(e),this.name="GraphValidationError"}};function dH({nodes:e,channels:t,inputChannels:n,outputChannels:r,streamChannels:i,interruptAfterNodes:s,interruptBeforeNodes:a}){if(!t)throw new Nr("Channels not provided");let o=new Set,c=new Set;for(let[u,l]of Object.entries(e)){if(u==="__interrupt__")throw new Nr(`"Node name ${yt} is reserved"`);if(l.constructor===Ac)l.triggers.forEach(d=>o.add(d));else throw new Nr(`Invalid node type ${typeof l}, expected PregelNode`)}for(let u of o)if(!(u in t))throw new Nr(`Subscribed channel '${String(u)}' not in channels`);if(Array.isArray(n)){if(n.every(u=>!o.has(u)))throw new Nr(`None of the input channels ${n} are subscribed to by any node`)}else if(!o.has(n))throw new Nr(`Input channel ${String(n)} is not subscribed to by any node`);Array.isArray(r)?r.forEach(u=>c.add(u)):c.add(r),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 Nr(`Output channel '${String(u)}' not in channels`);if(s&&s!=="*"){for(let u of s)if(!(u in e))throw new Nr(`Node ${String(u)} not in nodes`)}if(a&&a!=="*"){for(let u of a)if(!(u in e))throw new Nr(`Node ${String(u)} not in nodes`)}}function Qx(e,t){if(Array.isArray(e)){for(let n of e)if(!(n in t))throw new Error(`Key ${String(n)} not found in channels`)}else if(!(e in t))throw new Error(`Key ${String(e)} not found in channels`)}var pH=class ZP extends Di{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 n=new ZP({unique:this.unique,accumulate:this.accumulate});return typeof t<"u"&&(n.seen=new Set(t[0]),n.values=t[1]),n}update(t){let n=!1;this.accumulate||(n=this.values.length>0,this.values=[]);let r=t.flat();if(r.length>0)if(this.unique)for(let i of r)this.seen.has(i)||(n=!0,this.seen.add(i),this.values.push(i));else n=!0,this.values.push(...r);return n}get(){if(this.values.length===0)throw new $t;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};function hH(e){let t=new TextEncoder;return new ReadableStream({async start(n){try{for await(let r of e){let i=r.params.namespace,s=i.length?`${r.method}|${i.join("|")}`:r.method;n.enqueue(t.encode(`event: ${s}
|
|
331
|
+
data: ${JSON.stringify(r.params.data??{})}
|
|
332
|
+
|
|
333
|
+
`))}}catch(r){n.enqueue(t.encode(`event: error
|
|
334
|
+
data: ${JSON.stringify({message:String(r)})}
|
|
335
|
+
|
|
336
|
+
`))}finally{n.close()}}})}var mH=class{static subscribeTo(e,t){let{key:n,tags:r}={key:void 0,tags:void 0,...t??{}};if(Array.isArray(e)&&n!==void 0)throw new Error("Can't specify a key when subscribing to multiple channels");let i;return typeof e=="string"?n?i={[n]:e}:i=[e]:i=Object.fromEntries(e.map(s=>[s,s])),new Ac({channels:i,triggers:Array.isArray(e)?e:[e],tags:r})}static writeTo(e,t){let n=[];for(let r of e)n.push({channel:r,value:ps,skipNone:!1});for(let[r,i]of Object.entries(t??{}))Ae.isRunnable(i)||typeof i=="function"?n.push({channel:r,value:ps,skipNone:!0,mapper:Nt(i)}):n.push({channel:r,value:i,skipNone:!1});return new Kt(n)}},fH=class extends Ae{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)}},gH=class extends fH{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;streamTransformers;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 '${_a}' is reserved and cannot be used in the graph.`);this.channels[_a]=new pH({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.streamTransformers=e.streamTransformers??[],this.autoValidate&&this.validate()}withConfig(e){let{streamTransformers:t,...n}=e,r=Nn(this.config,n),i=[...this.streamTransformers,...t??[]];return new this.constructor({...this,config:r,streamTransformers:i})}validate(){dH({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 n of t.triggers)this.triggerToNodes[n]??=[],this.triggerToNodes[n].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[n,r]of Object.entries(this.nodes)){if(e!==void 0&&!e.startsWith(n))continue;let i=r.subgraphs?.length?r.subgraphs:[r.bound];for(let s of i){let a=PP(s);if(a!==void 0){if(n===e){yield[n,a];return}if(e===void 0&&(yield[n,a]),t){let o=e;e!==void 0&&(o=e.slice(n.length+1));for(let[c,u]of a.getSubgraphs(o,t))yield[`${n}|${c}`,u]}}}}}async*getSubgraphsAsync(e,t){yield*this.getSubgraphs(e,t)}async _prepareStateSnapshot({config:e,saved:t,subgraphCheckpointer:n,applyPendingWrites:r=!1}){if(t===void 0)return{values:{},next:[],config:e,tasks:[]};let i=qd(this.channels,t.checkpoint);if(t.pendingWrites?.length){let d=t.pendingWrites.filter(([p,h])=>p===mr).map(([p,h,m])=>[String(h),m]);d.length>0&&yn(t.checkpoint,i,[{name:ci,writes:d,triggers:[]}],void 0,this.triggerToNodes)}let s=Object.values(la(t.checkpoint,t.pendingWrites,this.nodes,i,t.config,!0,{step:(t.metadata?.step??-1)+1,store:this.store})),a=await ui(this.getSubgraphsAsync()),o=t.config.configurable?.checkpoint_ns??"",c={};for(let d of s){let p=a.find(([m])=>m===d.name);if(!p)continue;let h=`${String(d.name)}:${d.id}`;if(o&&(h=`${o}|${h}`),n===void 0){let m={configurable:{thread_id:t.config.configurable?.thread_id,checkpoint_ns:h}};c[d.id]=m}else{let m={configurable:{[Fr]:n,thread_id:t.config.configurable?.thread_id,checkpoint_ns:h}},f=p[1];c[d.id]=await f.getState(m,{subgraphs:!0})}}if(r&&t.pendingWrites?.length){let d=Object.fromEntries(s.map(h=>[h.id,h]));for(let[h,m,f]of t.pendingWrites)["__error__","__interrupt__",zl].includes(m)||h in d&&d[h].writes.push([String(m),f]);let p=s.filter(h=>h.writes.length>0);p.length>0&&yn(t.checkpoint,i,p,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=s.filter(d=>d.writes.length===0).map(d=>d.name);return{values:$s(i,this.streamChannelsAsIs),next:l,tasks:MP(s,t?.pendingWrites??[],c,this.streamChannelsAsIs),metadata:u,config:Hi(t.config,t.metadata),createdAt:t.checkpoint.ts,parentConfig:t.parentConfig}}async getState(e,t){let n=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!n)throw new Ul("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let r=e.configurable?.checkpoint_ns??"";if(r!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=If(r);for await(let[o,c]of this.getSubgraphsAsync(a,!0))if(o===a)return await c.getState(Bs(e,{[Fr]:n}),{subgraphs:t?.subgraphs})}let i=Nn(this.config,e),s=await n.getTuple(e);return await this._prepareStateSnapshot({config:i,saved:s,subgraphCheckpointer:t?.subgraphs?n:void 0,applyPendingWrites:!e.configurable?.checkpoint_id})}async*getStateHistory(e,t){let n=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!n)throw new Ul("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let r=e.configurable?.checkpoint_ns??"";if(r!==""&&e.configurable?.__pregel_checkpointer===void 0){let s=If(r);for await(let[a,o]of this.getSubgraphsAsync(s,!0))if(a===s){yield*o.getStateHistory(Bs(e,{[Fr]:n}),t);return}}let i=Nn(this.config,e,{configurable:{checkpoint_ns:r}});for await(let s of n.list(i,t))yield this._prepareStateSnapshot({config:s.config,saved:s})}async bulkUpdateState(e,t){let n=e.configurable?.__pregel_checkpointer??this.checkpointer;if(!n)throw new Ul("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 r=e.configurable?.checkpoint_ns??"";if(r!==""&&e.configurable?.__pregel_checkpointer===void 0){let a=If(r);for await(let[,o]of this.getSubgraphsAsync(a,!0))return await o.bulkUpdateState(Bs(e,{[Fr]:n}),t);throw new Error(`Subgraph "${a}" not found`)}let i=async(a,o)=>{let c=this.config?Nn(this.config,a):a,u=await n.getTuple(c),l=u!==void 0?Bd(u.checkpoint):dP(),d={...u?.checkpoint.channel_versions},p=u?.metadata?.step??-1,h=Bs(c,{checkpoint_ns:c.configurable?.checkpoint_ns??""}),m=c.metadata??{};u?.config.configurable&&(h=Bs(c,u.config.configurable),m={...u.metadata,...m});let{values:f,asNode:v}=o[0];if(f==null&&v===void 0){if(o.length>1)throw new qe("Cannot create empty checkpoint with multiple updates");return Hi(await n.put(h,Yi(l,void 0,p),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},{}),u?u.metadata:void 0)}let g=qd(this.channels,l);if(f===null&&v==="__end__"){if(o.length>1)throw new qe("Cannot apply multiple updates when clearing state");if(u){let T=la(l,u.pendingWrites||[],this.nodes,g,u.config,!0,{step:(u.metadata?.step??-1)+1,checkpointer:n,store:this.store}),k=(u.pendingWrites||[]).filter(B=>B[0]===mr).map(B=>B.slice(1));k.length>0&&yn(l,g,[{name:ci,writes:k,triggers:[]}],n.getNextVersion.bind(n),this.triggerToNodes);for(let[B,C,E]of u.pendingWrites||[])["__error__","__interrupt__",zl].includes(C)||B in T&&T[B].writes.push([C,E]);yn(l,g,Object.values(T),n.getNextVersion.bind(n),this.triggerToNodes)}return Hi(await n.put(h,Yi(l,g,p),{...m,source:"update",step:p+1,parents:u?.metadata?.parents??{}},Ql(d,l.channel_versions)),u?u.metadata:void 0)}if(v==="__copy__"){if(o.length>1)throw new qe("Cannot copy checkpoint with multiple updates");if(u==null)throw new qe("Cannot copy a non-existent checkpoint");let T=C=>!Array.isArray(C)||C.length===0?!1:C.every(E=>Array.isArray(E)&&E.length===2),k=Yi(l,void 0,p),B=await n.put(u.parentConfig??Bs(u.config,{checkpoint_id:void 0}),k,{source:"fork",step:p+1,parents:u.metadata?.parents??{}},{});if(T(f)){let C=la(k,u.pendingWrites,this.nodes,g,B,!1,{step:p+2}),E=Object.values(C).reduce((X,{name:ae,id:Ne})=>(X[ae]??=[],X[ae].push({id:Ne}),X),{}),Z=f.reduce((X,ae)=>{let[Ne,ve]=ae;X[ve]??=[];let sr=X[ve].length,On=E[ve]?.[sr]?.id;return X[ve].push({values:Ne,asNode:ve,taskId:On}),X},{});return i(Hi(B,u.metadata),Object.values(Z).flat())}return Hi(B,u.metadata)}if(v==="__input__"){if(o.length>1)throw new qe("Cannot apply multiple updates when updating as input");let T=await ui(jP(this.inputChannels,f));if(T.length===0)throw new qe(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);yn(l,g,[{name:ci,writes:T,triggers:[]}],n.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let k=u?.metadata?.step!=null?u.metadata.step+1:-1,B=await n.put(h,Yi(l,g,k),{source:"input",step:k,parents:u?.metadata?.parents??{}},Ql(d,l.channel_versions));return await n.putWrites(B,T,ra(ci,l.id)),Hi(B,u?u.metadata:void 0)}if(c.configurable?.checkpoint_id===void 0&&u?.pendingWrites!==void 0&&u.pendingWrites.length>0){let T=la(l,u.pendingWrites,this.nodes,g,u.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(u.metadata?.step??-1)+1}),k=(u.pendingWrites??[]).filter(C=>C[0]===mr).map(C=>C.slice(1));k.length>0&&yn(u.checkpoint,g,[{name:ci,writes:k,triggers:[]}],void 0,this.triggerToNodes);for(let[C,E,Z]of u.pendingWrites)["__error__","__interrupt__",zl].includes(E)||T[C]===void 0||T[C].writes.push([E,Z]);let B=Object.values(T).filter(C=>C.writes.length>0);B.length>0&&yn(l,g,B,void 0,this.triggerToNodes)}let y=Object.values(l.versions_seen).map(T=>Object.values(T)).flat().find(T=>!!T),w=[];if(o.length===1){let{values:T,asNode:k,taskId:B}=o[0];if(k===void 0&&Object.keys(this.nodes).length===1)[k]=Object.keys(this.nodes);else if(k===void 0&&y===void 0)typeof this.inputChannels=="string"&&this.nodes[this.inputChannels]!==void 0&&(k=this.inputChannels);else if(k===void 0){let C=Object.entries(l.versions_seen).map(([E,Z])=>Object.values(Z).map(X=>[X,E])).flat().filter(([E,Z])=>Z!==yt).sort(([E],[Z])=>pP(E,Z));C&&(C.length===1?k=C[0][1]:C[C.length-1][0]!==C[C.length-2][0]&&(k=C[C.length-1][1]))}if(k===void 0)throw new qe('Ambiguous update, specify "asNode"');w.push({values:T,asNode:k,taskId:B})}else for(let{asNode:T,values:k,taskId:B}of o){if(T==null)throw new qe('"asNode" is required when applying multiple updates');w.push({values:k,asNode:T,taskId:B})}let x=[];for(let{asNode:T,values:k,taskId:B}of w){if(this.nodes[T]===void 0)throw new qe(`Node "${T.toString()}" does not exist`);let C=this.nodes[T].getWriters();if(!C.length)throw new qe(`No writers found for node "${T.toString()}"`);x.push({name:T,input:k,proc:C.length>1?Ni.from(C,{omitSequenceTags:!0}):C[0],writes:[],triggers:[yt],id:B??ra("__interrupt__",l.id),writers:[]})}for(let T of x)await T.proc.invoke(T.input,Re({...c,store:c?.store??this.store},{runName:c.runName??`${this.getName()}UpdateState`,configurable:{[hi]:k=>T.writes.push(...k),[as]:(k,B=!1)=>ed(l,g,T,k,B)}}));for(let T of x){let k=T.writes.filter(B=>B[0]!==Br);u!==void 0&&k.length>0&&await n.putWrites(h,k,T.id)}yn(l,g,x,n.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let O=Ql(d,l.channel_versions),z=await n.put(h,Yi(l,g,p+1),{source:"update",step:p+1,parents:u?.metadata?.parents??{}},O);for(let T of x){let k=T.writes.filter(B=>B[0]===Br);k.length>0&&await n.putWrites(z,k,T.id)}return Hi(z,u?u.metadata:void 0)},s=e;for(let{updates:a}of t)s=await i(s,a);return s}async updateState(e,t,n){return this.bulkUpdateState(e,[{updates:[{values:t,asNode:n}]}])}_defaults(e){let{debug:t,streamMode:n,inputKeys:r,outputKeys:i,interruptAfter:s,interruptBefore:a,...o}=e,c=!0,u=t!==void 0?t:this.debug,l=i;l===void 0?l=this.streamChannelsAsIs:Qx(l,this.channels);let d=r;d===void 0?d=this.inputChannels:Qx(d,this.channels);let p=a??this.interruptBefore??[],h=s??this.interruptAfter??[],m;n!==void 0?(m=Array.isArray(n)?n:[n],c=typeof n=="string"):(e.configurable?.__pregel_task_id!==void 0?m=["values"]:m=this.streamMode,c=!0);let f;if(this.checkpointer===!1)f=void 0;else if(e!==void 0&&e.configurable?.__pregel_checkpointer!==void 0)f=e.configurable[Fr];else{if(this.checkpointer===!0)throw new Error("checkpointer: true cannot be used for root graphs.");f=this.checkpointer}let v=e.store??this.store,g=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"})(),w=e.durability??y??e?.configurable?.__pregel_durability??"async";return[u,m,d,l,o,p,h,f,v,c,g,w]}async stream(e,t){let n=new AbortController,r={recursionLimit:this.config?.recursionLimit,...t,signal:Wd(t?.signal,n.signal).signal},i=await super.stream(e,r);return new Nf(t?.encoding==="text/event-stream"?XJ(i):i,n)}async#e(e,t){let{version:n,encoding:r,transformers:i,...s}=t,a={recursionLimit:this.config?.recursionLimit,...s,configurable:{...this.config?.configurable,...s?.configurable},version:n,streamMode:Zq,subgraphs:!0,encoding:void 0},o=this.stream(e,a),c=sJ({[Symbol.asyncIterator]:async function*(){let u=await o;for await(let l of u)yield l}},[...this.streamTransformers??[],...i??[]]);if(r==="text/event-stream"){let u=new AbortController;return u.signal.addEventListener("abort",()=>c.abort(u.signal.reason),{once:!0}),new Nf(hH(c),u)}return c}streamEvents(e,t,n){if(t.version==="v3")return this.#e(e,t);let r=new AbortController,i={recursionLimit:this.config?.recursionLimit,...t,callbacks:NJ(this.config?.callbacks,t?.callbacks),signal:Wd(t?.signal,r.signal).signal};return new Nf(super.streamEvents(e,i,n),r)}async _validateInput(e){return e}async _validateContext(e){return e}async*_streamIterator(e,t){let n="version"in(t??{})?void 0:t?.encoding??void 0,r=t?.subgraphs,i=_P(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 s=await this._validateInput(e),{runId:a,...o}=i,[c,u,,l,d,p,h,m,f,v,g,y]=this._defaults(o);d.metadata={ls_integration:"langgraph",...d.metadata},typeof d.context<"u"?d.context=await this._validateContext(d.context):d.configurable=await this._validateContext(d.configurable);let w=new LP({modes:new Set(u)});if(this.checkpointer===!0){d.configurable??={};let C=d.configurable.checkpoint_ns??"";d.configurable[Zr]=C.split("|").map(E=>E.split(":")[0]).join("|")}if(u.includes("messages")){let C=t?.version==="v3"?new aH(Z=>w.push(Z)):new rH(Z=>w.push(Z)),{callbacks:E}=d;if(E===void 0)d.callbacks=[C];else if(Array.isArray(E))d.callbacks=E.concat(C);else{let Z=E.copy();Z.addHandler(C,!0),d.callbacks=Z}}if(u.includes("tools")){let C=new KJ(Z=>w.push(Z)),{callbacks:E}=d;if(E===void 0)d.callbacks=[C];else if(Array.isArray(E))d.callbacks=E.concat(C);else{let Z=E.copy();Z.addHandler(C,!0),d.callbacks=Z}}d.writer??=C=>{if(!u.includes("custom"))return;let E=zq()?.configurable?.[Zr]?.split("|").slice(0,-1);w.push([E??[],"custom",C])},d.interrupt??=this.userInterrupt??IJ,d.serverInfo==null&&(d.serverInfo=yH(d));let x={tracerInheritableMetadata:bH(d)},O=await(await Ft._configureSync(d?.callbacks,void 0,d?.tags,void 0,d?.metadata,void 0,x))?.handleChainStart(this.toJSON(),CJ(e,"input"),a,void 0,void 0,void 0,d?.runName??this.getName()),z=w0(this.channels),T,k,B=(async()=>{try{T=await tH.initialize({input:s,config:d,checkpointer:m,nodes:this.nodes,channelSpecs:z,outputKeys:l,streamKeys:this.streamChannelsAsIs,store:f,cache:g,stream:w,interruptAfter:h,interruptBefore:p,manager:O,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:y});let C=new lH({loop:T,nodeFinished:d.configurable?.[t2]});t?.subgraphs&&(T.config.configurable={...T.config.configurable,[m_]:T.stream}),await this._runLoop({loop:T,runner:C,debug:c,config:d}),y==="sync"&&await Promise.all(T?.checkpointerPromises??[])}catch(C){k=C}finally{try{T&&(await T.store?.stop(),await T.cache?.stop()),await Promise.all(T?.checkpointerPromises??[])}catch(C){k=k??C}k?w.error(k):w.close()}})();try{for await(let C of w){if(C===void 0)throw new Error("Data structure error.");let[E,Z,X,ae]=C;if(u.includes(Z)){if(n==="text/event-stream"){r?yield[E,Z,X]:yield[null,Z,X];continue}r&&!v?yield ae!==void 0?[E,Z,X,ae]:[E,Z,X]:v?r?yield[E,X]:yield X:yield[Z,X]}}}catch(C){throw await O?.handleChainError(k),C}finally{await B}await O?.handleChainEnd(T?.output??{},a,void 0,void 0,void 0)}async invoke(e,t){let n=t?.streamMode??"values",r={...t,outputKeys:t?.outputKeys??this.outputChannels,streamMode:n,encoding:void 0},i=[],s=await this.stream(e,r),a=[],o;for await(let c of s)n==="values"?g_(c)?a.push(c[yt]):o=c:i.push(c);if(n==="values"){if(a.length>0){let c=a.flat(1);if(o==null)return{[yt]:c};if(typeof o=="object")return{...o,[yt]:c}}return o}return i}async _runLoop(e){let{loop:t,runner:n,debug:r,config:i}=e,s;try{for(;await t.tick({inputKeys:this.inputChannels});){for(let{task:a}of await t._matchCachedWrites())t._outputWrites(a.id,a.writes,!0);r&&HJ(t.checkpointMetadata.step,t.channels,this.streamChannelsList),r&&UP(t.step,Object.values(t.tasks)),await n.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(a,o)=>{r&&VJ(a,o,this.streamChannelsList)},maxConcurrency:i.maxConcurrency,signal:i.signal})}if(t.status==="out_of_steps")throw new o2([`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(s=a,!await t.finishAndHandleError(s))throw a}finally{s===void 0&&await t.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};function yH(e){let t=e.metadata??{},n=e.configurable??{},r=t.assistant_id,i=t.graph_id,s=n.langgraph_auth_user,a;if(s!=null&&typeof s=="object"&&"identity"in s&&(a=s),r!=null||i!=null||a!=null)return{assistantId:r!=null?String(r):"",graphId:i!=null?String(i):"",user:a}}var _H=new Set(["key","token","secret","password","auth"]);function vH(e,t){let n=e.toLowerCase(),r=!1;for(let i of _H)if(n.includes(i)){r=!0;break}return e.startsWith("__")||!(typeof t=="string"||typeof t=="number"||typeof t=="boolean")||r}function bH(e){let t=e.configurable;if(!t)return;let n={};for(let[r,i]of Object.entries(t))vH(r,i)||(n[r]=i);return Object.keys(n).length>0?n:void 0}var Ba=class BP extends Di{lc_graph_name="EphemeralValue";guard;value=[];constructor(t=!0){super(),this.guard=t}fromCheckpoint(t){let n=new BP(this.guard);return typeof t<"u"&&(n.value=[t]),n}update(t){if(t.length===0){let n=this.value.length>0;return this.value=[],n}if(t.length!==1&&this.guard)throw new qe("EphemeralValue can only receive one value per step.");return this.value=[t[t.length-1]],!0}get(){if(this.value.length===0)throw new $t;return this.value[0]}checkpoint(){if(this.value.length===0)throw new $t;return this.value[0]}isAvailable(){return this.value.length!==0}},qP=class{path;ends;constructor(e){Ae.isRunnable(e.path)?this.path=e.path:this.path=Nt(e.path),this.ends=Array.isArray(e.pathMap)?e.pathMap.reduce((t,n)=>(t[n]=n,t),{}):e.pathMap}run(e,t){return Kt.registerWriter(new Rs({name:"<branch_run>",trace:!1,func:async(n,r)=>{try{return await this._route(n,r,e,t)}catch(i){throw i.name===hh.unminifiable_name&&console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
|
|
337
|
+
NodeInterrupt should only be thrown inside a node, not in edge conditions.`),i}}}))}async _route(e,t,n,r){let i=await this.path.invoke(r?r(t):e,t);Array.isArray(i)||(i=[i]);let s;if(this.ends?s=i.map(a=>cn(a)?a:this.ends[a]):s=i,s.some(a=>!a))throw new Error("Branch condition returned unknown or null destination");if(s.filter(cn).some(a=>a.node==="__end__"))throw new qe("Cannot send a packet to the END node");return await n(s,t)??e}},wH=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(r){return r.length>=1&&typeof r[0]!="string"}let n=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]):[[e[0],e[1],e[2]]];if(n.length===0)throw new Error("No nodes provided in `addNode`");for(let[r,i,s]of n){for(let o of["|",":"])if(r.includes(o))throw new Error(`"${o}" 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."),r in this.nodes)throw new Error(`Node \`${r}\` already present.`);if(r==="__end__")throw new Error(`Node \`${r}\` is reserved.`);let a=Nt(i);this.nodes[r]={runnable:a,metadata:s?.metadata,subgraphs:$0(a)?[a]:s?.subgraphs,ends:s?.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(([n])=>n===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,n){let r=typeof e=="object"?e:{source:e,path:t,pathMap:n};this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),Ae.isRunnable(r.path)||(r.path=Nt(r.path));let i=r.path.getName()==="RunnableLambda"?"condition":r.path.getName();if(this.branches[r.source]&&this.branches[r.source][i])throw new Error(`Condition \`${i}\` already present for node \`${e}\``);return this.branches[r.source]??={},this.branches[r.source][i]=new qP(r),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(_t,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,dt)}compile({checkpointer:e,interruptBefore:t,interruptAfter:n,name:r,transformers:i}={}){this.validate([...Array.isArray(t)?t:[],...Array.isArray(n)?n:[]]);let s=new JP({builder:this,checkpointer:e,interruptAfter:n,interruptBefore:t,autoValidate:!1,nodes:{},channels:{[_t]:new Ba,[dt]:new Ba},inputChannels:_t,outputChannels:dt,streamChannels:[],streamMode:"values",name:r,streamTransformers:i});for(let[a,o]of Object.entries(this.nodes))s.attachNode(a,o);for(let[a,o]of this.edges)s.attachEdge(a,o);for(let[a,o]of Object.entries(this.branches))for(let[c,u]of Object.entries(o))s.attachBranch(a,c,u);return s.validate()}validate(e){let t=new Set([...this.allEdges].map(([r,i])=>r));for(let[r]of Object.entries(this.branches))t.add(r);for(let r of t)if(r!=="__start__"&&!(r in this.nodes))throw new Error(`Found edge starting at unknown node \`${r}\``);let n=new Set([...this.allEdges].map(([r,i])=>i));for(let[r,i]of Object.entries(this.branches))for(let s of Object.values(i))if(s.ends!=null)for(let a of Object.values(s.ends))n.add(a);else{n.add(dt);for(let a of Object.keys(this.nodes))a!==r&&n.add(a)}for(let r of Object.values(this.nodes))for(let i of r.ends??[])n.add(i);for(let r of Object.keys(this.nodes))if(!n.has(r))throw new u2([`Node \`${r}\` 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(`
|
|
338
|
+
`),{lc_error_code:"UNREACHABLE_NODE"});for(let r of n)if(r!=="__end__"&&!(r in this.nodes))throw new Error(`Found edge ending at unknown node \`${r}\``);if(e){for(let r of e)if(!(r in this.nodes))throw new Error(`Interrupt node \`${r}\` is not present`)}this.compiled=!0}},JP=class extends gH{builder;constructor({builder:e,...t}){super(t),this.builder=e}withConfig(e){return super.withConfig(e)}attachNode(e,t){this.channels[e]=new Ba,this.nodes[e]=new Ac({channels:[],triggers:[],metadata:t.metadata,subgraphs:t.subgraphs,ends:t.ends}).pipe(t.runnable).pipe(new Kt([{channel:e,value:ps}],[rn])),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 Kt([{channel:dt,value:ps}],[rn]))}else this.nodes[t].triggers.push(e),this.nodes[t].channels.push(e)}attachBranch(e,t,n){e==="__start__"&&!this.nodes.__start__&&(this.nodes[_t]=mH.subscribeTo(_t,{tags:[rn]})),this.nodes[e].pipe(n.run(i=>new Kt(i.map(s=>cn(s)?s:{channel:s==="__end__"?dt:`branch:${e}:${t}:${s}`,value:ps}),[rn])));let r=n.ends?Object.values(n.ends):Object.keys(this.nodes);for(let i of r)if(i!=="__end__"){let s=`branch:${e}:${t}:${i}`;this.channels[s]=new Ba,this.nodes[i].triggers.push(s),this.nodes[i].channels.push(s)}}async getGraphAsync(e){let t=e?.xray,n=new _c,r={[_t]:n.addNode({schema:ua()},_t)},i={},s={};t&&(s=Object.fromEntries((await ui(this.getSubgraphsAsync())).filter(c=>e$(c[1]))));function a(c,u,l,d=!1){if(u==="__end__"&&i.__end__===void 0&&(i[dt]=n.addNode({schema:ua()},dt)),r[c]!==void 0){if(i[u]===void 0)throw new Error(`End node ${u} not found!`);return n.addEdge(r[c],i[u],l!==u?l:void 0,d)}}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Lt(c),d=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?p.__interrupt="before,after":this.interruptBefore?.includes(c)?p.__interrupt="before":this.interruptAfter?.includes(c)&&(p.__interrupt="after"),t){let h=typeof t=="number"?t-1:t,m=s[c]!==void 0?await s[c].getGraphAsync({...e,xray:h}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let f=function(w){return w?w.lc_runnable:!1},v=function(w,x){if(w!==void 0&&!Qf(w))return w;if(f(x))try{let O=x.getName();return O=O.startsWith("Runnable")?O.slice(8):O,O}catch{return x.getName()}else return x.name??"UnknownSchema"},[g,y]=n.extend(m,l);if(g===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);y!==void 0&&(r[l]={name:v(y.id,y.data),...y}),i[l]={name:v(g.id,g.data),...g}}else{let f=n.addNode(d,l,p);r[l]=f,i[l]=f}}else{let h=n.addNode(d,l,p);r[l]=h,i[l]=h}}let o=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of o)a(Lt(c),Lt(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=>[Lt(d),Lt(d)])),[dt]:dt};for(let d of Object.values(u)){let p;d.ends!==void 0?p=d.ends:p=l;for(let[h,m]of Object.entries(p))a(Lt(c),Lt(m),h,!0)}}for(let[c,u]of Object.entries(this.builder.nodes))if(u.ends!==void 0)for(let l of u.ends)a(Lt(c),Lt(l),void 0,!0);return n}getGraph(e){let t=e?.xray,n=new _c,r={[_t]:n.addNode({schema:ua()},_t)},i={},s={};t&&(s=Object.fromEntries(Po(this.getSubgraphs()).filter(c=>e$(c[1]))));function a(c,u,l,d=!1){return u==="__end__"&&i.__end__===void 0&&(i[dt]=n.addNode({schema:ua()},dt)),n.addEdge(r[c],i[u],l!==u?l:void 0,d)}for(let[c,u]of Object.entries(this.builder.nodes)){let l=Lt(c),d=u.runnable,p=u.metadata??{};if(this.interruptBefore?.includes(c)&&this.interruptAfter?.includes(c)?p.__interrupt="before,after":this.interruptBefore?.includes(c)?p.__interrupt="before":this.interruptAfter?.includes(c)&&(p.__interrupt="after"),t){let h=typeof t=="number"?t-1:t,m=s[c]!==void 0?s[c].getGraph({...e,xray:h}):d.getGraph(e);if(m.trimFirstNode(),m.trimLastNode(),Object.keys(m.nodes).length>1){let f=function(w){return w?w.lc_runnable:!1},v=function(w,x){if(w!==void 0&&!Qf(w))return w;if(f(x))try{let O=x.getName();return O=O.startsWith("Runnable")?O.slice(8):O,O}catch{return x.getName()}else return x.name??"UnknownSchema"},[g,y]=n.extend(m,l);if(g===void 0)throw new Error(`Could not extend subgraph "${c}" due to missing entrypoint.`);y!==void 0&&(r[l]={name:v(y.id,y.data),...y}),i[l]={name:v(g.id,g.data),...g}}else{let f=n.addNode(d,l,p);r[l]=f,i[l]=f}}else{let h=n.addNode(d,l,p);r[l]=h,i[l]=h}}let o=[...this.builder.allEdges].sort(([c],[u])=>c<u?-1:u>c?1:0);for(let[c,u]of o)a(Lt(c),Lt(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=>[Lt(d),Lt(d)])),[dt]:dt};for(let d of Object.values(u)){let p;d.ends!==void 0?p=d.ends:p=l;for(let[h,m]of Object.entries(p))a(Lt(c),Lt(m),h,!0)}}return n}};function e$(e){return typeof e.attachNode=="function"&&typeof e.attachEdge=="function"}function Lt(e){return e==="subgraph"?`"${e}"`:e}function Ro(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"validate"in e["~standard"]}function kH(e){return typeof e=="object"&&e!==null&&"~standard"in e&&typeof e["~standard"]=="object"&&e["~standard"]!==null&&"jsonSchema"in e["~standard"]}function Js(e){if(kH(e))try{return e["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function Hs(e){if(e!=null&&Ro(e))try{let t=e["~standard"].validate(void 0);if(t&&typeof t=="object"&&!("then"in t&&typeof t.then=="function")){let n=t;if(!n.issues){let r=n.value;return()=>r}}}catch{}}var Rf=Symbol.for("langgraph.channel.missing"),xH=class HP extends Di{lc_graph_name="UntrackedValue";guard;_value=Rf;initialValueFactory;constructor(t){super(),this.guard=t?.guard??!0,this.initialValueFactory=t?.initialValueFactory,this.initialValueFactory&&(this._value=this.initialValueFactory())}fromCheckpoint(t){return new HP({guard:this.guard,initialValueFactory:this.initialValueFactory})}update(t){if(t.length===0)return!1;if(t.length!==1&&this.guard)throw new qe("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===Rf)throw new $t;return this._value}checkpoint(){}isAvailable(){return this._value!==Rf}},ts=(e,t)=>e.size===t.size&&[...e].every(n=>t.has(n)),$H=class VP extends Di{lc_graph_name="NamedBarrierValue";names;seen;constructor(t){super(),this.names=t,this.seen=new Set}fromCheckpoint(t){let n=new VP(this.names);return typeof t<"u"&&(n.seen=new Set(t)),n}update(t){let n=!1;for(let r of t)if(this.names.has(r))this.seen.has(r)||(this.seen.add(r),n=!0);else throw new qe(`Value ${JSON.stringify(r)} not in names ${JSON.stringify(this.names)}`);return n}get(){if(!ts(this.names,this.seen))throw new $t}checkpoint(){return[...this.seen]}consume(){return this.seen&&this.names&&ts(this.seen,this.names)?(this.seen=new Set,!0):!1}isAvailable(){return!!this.names&&ts(this.names,this.seen)}},IH=class KP extends Di{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor(t){super(),this.names=t,this.seen=new Set,this.finished=!1}fromCheckpoint(t){let n=new KP(this.names);if(typeof t<"u"){let[r,i]=t;n.seen=new Set(r),n.finished=i}return n}update(t){let n=!1;for(let r of t)if(this.names.has(r)&&!this.seen.has(r))this.seen.add(r),n=!0;else if(!this.names.has(r))throw new qe(`Value ${JSON.stringify(r)} not in names ${JSON.stringify(this.names)}`);return n}get(){if(!this.finished||!ts(this.names,this.seen))throw new $t}checkpoint(){return[[...this.seen],this.finished]}consume(){return this.finished&&this.seen&&this.names&&ts(this.seen,this.names)?(this.seen=new Set,this.finished=!1,!0):!1}finish(){return!this.finished&&this.names&&ts(this.names,this.seen)?(this.finished=!0,!0):!1}isAvailable(){return this.finished&&!!this.names&&ts(this.names,this.seen)}},Mf=Symbol.for("langgraph.state.reduced_value"),Xs=class{[Mf]=!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&&Mf in e&&e[Mf]===!0}},t$=Symbol.for("langgraph.state.untracked_value"),xo=class{[t$]=!0;schema;guard;constructor(e,t){this.schema=e,this.guard=t?.guard??!0}static isInstance(e){return typeof e=="object"&&e!==null&&t$ in e}},Uf=Symbol.for("langgraph.state.state_schema"),ns=class{[Uf]=!0;constructor(e){this.fields=e}getChannels(){let e={};for(let[t,n]of Object.entries(this.fields))if(Xs.isInstance(n)){let r=Hs(n.valueSchema);e[t]=new Jd(n.reducer,r)}else if(xo.isInstance(n)){let r=n.schema?Hs(n.schema):void 0;e[t]=new xH({guard:n.guard,initialValueFactory:r})}else if(Ro(n))e[t]=new $m(Hs(n));else throw new Error(`Invalid state field "${t}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return e}getJsonSchema(){let e={},t=[];for(let[n,r]of Object.entries(this.fields)){let i;if(Xs.isInstance(r)?(i=Js(r.valueSchema),r.jsonSchemaExtra&&(i={...i??{},...r.jsonSchemaExtra})):xo.isInstance(r)?i=r.schema?Js(r.schema):void 0:Ro(r)&&(i=Js(r)),i){e[n]=i;let s=!1;Xs.isInstance(r)?s=Hs(r.valueSchema)!==void 0:xo.isInstance(r)?s=r.schema?Hs(r.schema)!==void 0:!1:s=Hs(r)!==void 0,s||t.push(n)}}return{type:"object",properties:e,required:t.length>0?t:void 0}}getInputJsonSchema(){let e={};for(let[t,n]of Object.entries(this.fields)){let r;Xs.isInstance(n)?(r=Js(n.inputSchema),n.jsonSchemaExtra&&(r={...r??{},...n.jsonSchemaExtra})):xo.isInstance(n)?r=n.schema?Js(n.schema):void 0:Ro(n)&&(r=Js(n)),r&&(e[t]=r)}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[n,r]of Object.entries(e)){let i=this.fields[n];if(i===void 0){t[n]=r;continue}let s;if(Xs.isInstance(i)?s=i.inputSchema:xo.isInstance(i)?s=i.schema:Ro(i)&&(s=i),s){let a=await s["~standard"].validate(r);if(a.issues)throw new Error(`Validation failed for field "${n}": ${JSON.stringify(a.issues)}`);t[n]=a.value}else t[n]=r}return t}static isInstance(e){return typeof e=="object"&&e!==null&&Uf in e&&e[Uf]===!0}};function O0(e,t){let n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=n.map(br),s=r.map(br);for(let l of i)(l.id===null||l.id===void 0)&&(l.id=$w(),l.lc_kwargs.id=l.id);let a;for(let l=0;l<s.length;l+=1){let d=s[l];(d.id===null||d.id===void 0)&&(d.id=$w(),d.lc_kwargs.id=d.id),os.isInstance(d)&&d.id==="__remove_all__"&&(a=l)}if(a!=null)return s.slice(a+1);let o=[...i],c=new Map(o.map((l,d)=>[l.id,d])),u=new Set;for(let l of s){let d=c.get(l.id);if(d!==void 0)os.isInstance(l)?u.add(l.id):(u.delete(l.id),o[d]=l);else{if(os.isInstance(l))throw new Error(`Attempting to delete a message with an ID that doesn't exist ('${l.id}')`);c.set(l.id,o.length),o.push(l)}}return o.filter(l=>!u.has(l.id))}new Xs(Zd().default(()=>[]),{inputSchema:Zd(),reducer:O0,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var SH=class{_map=new Map;_extensionCache=new Map;get(e){return this._map.get(e)}extend(e,t){let n=this.get(e);this._map.set(e,t(n))}remove(e){return this._map.delete(e),this}has(e){return this._map.has(e)}getChannelsForSchema(e){let t={},n=hc(e);for(let[r,i]of Object.entries(n)){let s=this.get(i);s?.reducer?t[r]=new Jd(s.reducer.fn,s.default):t[r]=new $m(s?.default)}return t}getExtendedChannelSchemas(e,t){if(Object.keys(t).length===0)return e;let n=Object.entries(t).filter(([,s])=>s===!0).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}:${a}`).join("|"),r=this._extensionCache.get(n)??new Map;if(r.has(e))return r.get(e);let i=e;if(t.withReducerSchema||t.withJsonSchemaExtrasAsDescription){let s=Object.entries(hc(e)).map(([a,o])=>{let c=this.get(o),u=t.withReducerSchema?c?.reducer?.schema??o:o;if(t.withJsonSchemaExtrasAsDescription&&c?.jsonSchemaExtra){let l=ja(u)??ja(o),d=JSON.stringify({...c.jsonSchemaExtra,description:l});u=u.describe(`lg:${d}`)}return[a,u]});i=ET(e,Object.fromEntries(s)),pt(i)&&(i._def.unknownKeys="strip")}return t.asPartial&&(i=Gv(i)),r.set(e,i),this._extensionCache.set(n,r),i}},Cc=new SH;function Ly(e,t){if(t.reducer&&!t.default){let n=Fh(e);n!=null&&(t.default=n)}if(t.reducer){let n=Object.assign(e,{lg_reducer_schema:t.reducer?.schema??e});return Cc.extend(n,()=>t),n}else return Cc.extend(e,()=>t),e}function Ys(e){return e==null?!1:!!(ns.isInstance(e)||En(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"||hP(t)))}function OH(e){if(typeof e!="object"||e==null)return!1;let t=e,n="state"in t&&Ys(t.state),r="stateSchema"in t&&Ys(t.stateSchema),i="input"in t&&Ys(t.input);return!(!n&&!r&&!i||"input"in t&&t.input!=null&&!Ys(t.input)||"output"in t&&t.output!=null&&!Ys(t.output))}var pi="__root__",Gd=Symbol.for("langgraph.state.partial"),A0=class extends wH{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=Cc;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(e,t){super();let n=this._normalizeToStateGraphInit(e,t),r=n.state??n.stateSchema??n.input;if(!r)throw new Bm;let i=this._getChannelsFromSchema(r);this._schemaDefinition=i,ns.isInstance(r)?this._schemaRuntimeDefinition=r:En(r)&&(this._schemaRuntimeDefinition=r),n.input?ns.isInstance(n.input)?this._inputRuntimeDefinition=n.input:En(n.input)?this._inputRuntimeDefinition=n.input:this._inputRuntimeDefinition=Gd:this._inputRuntimeDefinition=Gd,n.output?ns.isInstance(n.output)?this._outputRuntimeDefinition=n.output:En(n.output)?this._outputRuntimeDefinition=n.output:this._outputRuntimeDefinition=this._schemaRuntimeDefinition:this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let s=n.input?this._getChannelsFromSchema(n.input):i,a=n.output?this._getChannelsFromSchema(n.output):i;this._inputDefinition=s,this._outputDefinition=a,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),n.context&&En(n.context)&&(this._configRuntimeSchema=n.context),this._interrupt=n.interrupt,this._writer=n.writer}_normalizeToStateGraphInit(e,t){if(OH(e)){if(En(t)||Oy.isInstance(t))return{...e,context:t};let n=t;return{...e,input:e.input??n?.input,output:e.output??n?.output,context:e.context??n?.context,interrupt:e.interrupt??n?.interrupt,writer:e.writer??n?.writer,nodes:e.nodes??n?.nodes}}if(Ys(e)){if(En(t)||Oy.isInstance(t))return{state:e,context:t};let n=t;return{state:e,input:n?.input,output:n?.output,context:n?.context,interrupt:n?.interrupt,writer:n?.writer,nodes:n?.nodes}}if(EH(e))return{state:AH(e.channels)};throw new Bm}_getChannelsFromSchema(e){if(ns.isInstance(e))return e.getChannels();if(En(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 Bm("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(n=>[n,t]))])}_addSchema(e){if(!this._schemaDefinitions.has(e)){this._schemaDefinitions.set(e,e);for(let[t,n]of Object.entries(e)){let r;if(typeof n=="function"?r=n():r=n,this.channels[t]!==void 0){if(!this.channels[t].equals(r)&&r.lc_graph_name!=="LastValue")throw new Error(`Channel "${t}" already exists with a different type.`)}else this.channels[t]=r}}}addNode(...e){function t(r){return r.length>=1&&typeof r[0]!="string"}let n=t(e)?Array.isArray(e[0])?e[0]:Object.entries(e[0]).map(([r,i])=>[r,i]):[[e[0],e[1],e[2]]];if(n.length===0)throw new Error("No nodes provided in `addNode`");for(let[r,i,s]of n){if(r in this.channels)throw new Error(`${r} 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(r.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."),r in this.nodes)throw new Error(`Node \`${r}\` already present.`);if(r==="__end__"||r==="__start__")throw new Error(`Node \`${r}\` is reserved.`);let a=this._schemaDefinition;s?.input!==void 0&&(a=this._getChannelsFromSchema(s.input)),this._addSchema(a);let o;Ae.isRunnable(i)?o=i:typeof i=="function"?o=new Rs({func:i,name:r,trace:!1}):o=Nt(i);let c=s?.cachePolicy;typeof c=="boolean"&&(c=c?{}:void 0);let u={runnable:o,retryPolicy:s?.retryPolicy,cachePolicy:c,metadata:s?.metadata,input:a??this._schemaDefinition,subgraphs:$0(o)?[o]:s?.subgraphs,ends:s?.ends,defer:s?.defer};this.nodes[r]=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 n of e){if(n==="__end__")throw new Error("END cannot be a start node");if(!Object.keys(this.nodes).some(r=>r===n))throw new Error(`Need to add a node named "${n}" first`)}if(t==="__end__")throw new Error("END cannot be an end node");if(!Object.keys(this.nodes).some(n=>n===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 n;for(let[r,i,s]of t){if(r in this.nodes)throw new Error(`Node names must be unique: node with the name "${r}" already exists.`);let a=r;this.addNode(a,i,s),n!=null&&this.addEdge(n,a),n=a}return this}compile({checkpointer:e,store:t,cache:n,interruptBefore:r,interruptAfter:i,name:s,description:a,transformers:o}={}){this.validate([...Array.isArray(r)?r:[],...Array.isArray(i)?i:[]]);let c=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),u=c.length===1&&c[0]===pi?pi:c,l=Object.keys(this.channels),d=l.length===1&&l[0]===pi?pi:l,p=this._interrupt,h=new TH({builder:this,checkpointer:e,interruptAfter:i,interruptBefore:r,autoValidate:!1,nodes:{},channels:{...this.channels,[_t]:new Ba},inputChannels:_t,outputChannels:u,streamChannels:d,streamMode:"updates",store:t,cache:n,name:s,description:a,userInterrupt:p,streamTransformers:o});h.attachNode(_t);for(let[m,f]of Object.entries(this.nodes))h.attachNode(m,f);h.attachBranch(_t,bw,n$(),{withReader:!1});for(let[m]of Object.entries(this.nodes))h.attachBranch(m,bw,n$(),{withReader:!1});for(let[m,f]of this.edges)h.attachEdge(m,f);for(let[m,f]of this.waitingEdges)h.attachEdge(m,f);for(let[m,f]of Object.entries(this.branches))for(let[v,g]of Object.entries(f))h.attachBranch(m,v,g);return h.validate()}};function AH(e){let t={};for(let[n,r]of Object.entries(e))t[n]=yP(r);return t}var TH=class extends JP{description;_metaRegistry=Cc;constructor({description:e,...t}){super(t),this.description=e}attachNode(e,t){let n;e==="__start__"?n=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([o])=>o):n=Object.keys(this.builder.channels);function r(o){if(Dt(o))return o.graph===fr.PARENT?null:o._updateAsTuples();if(Array.isArray(o)&&o.length>0&&o.some(c=>Dt(c))){let c=[];for(let u of o)if(Dt(u)){if(u.graph===fr.PARENT)continue;c.push(...u._updateAsTuples())}else c.push([pi,u]);return c}else if(o!=null)return[[pi,o]];return null}let i=e;function s(o){if(o){if(Dt(o))return o.graph===fr.PARENT?null:o._updateAsTuples().filter(([c])=>n.includes(c));if(Array.isArray(o)&&o.length>0&&o.some(Dt)){let c=[];for(let u of o)if(Dt(u)){if(u.graph===fr.PARENT)continue;c.push(...u._updateAsTuples().filter(([l])=>n.includes(l)))}else{let l=s(u);l&&c.push(...l??[])}return c}else{if(typeof o=="object"&&!Array.isArray(o))return Object.entries(o).filter(([c])=>n.includes(c));{let c=Array.isArray(o)?"array":typeof o;throw new qe(`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:ps,mapper:new Rs({func:n.length&&n[0]===pi?r:s,trace:!1,recurse:!1})}];if(e==="__start__")this.nodes[e]=new Ac({tags:[rn],triggers:[_t],channels:[_t],writers:[new Kt(a,[rn])]});else{let o=t?.input??this.builder._schemaDefinition,c=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(o)).map(d=>[d,d])),u=Object.keys(c).length===1&&pi in c,l=`branch:to:${e}`;this.channels[l]=t?.defer?new Pq:new Ba(!1),this.nodes[e]=new Ac({triggers:[l],channels:u?Object.keys(c):c,writers:[new Kt(a,[rn])],mapper:u?void 0:d=>Object.fromEntries(Object.entries(d).filter(([p])=>p 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 Kt([{channel:`branch:to:${t}`,value:null}],[rn]));else if(Array.isArray(e)){let n=`join:${e.join("+")}:${t}`;this.channels[n]=this.builder.nodes[t].defer?new IH(new Set(e)):new $H(new Set(e)),this.nodes[t].triggers.push(n);for(let r of e)this.nodes[r].writers.push(new Kt([{channel:n,value:r}],[rn]))}}}attachBranch(e,t,n,r={withReader:!0}){let i=async(s,a)=>{let o=s.filter(u=>u!==dt);if(!o.length)return;let c=o.map(u=>cn(u)?u:{channel:u==="__end__"?u:`branch:to:${u}`,value:e});await Kt.doWrite({...a,tags:(a.tags??[]).concat([rn])},c)};this.nodes[e].writers.push(n.run(i,r.withReader?s=>OJ.doRead(s,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(e){if(e==null)return e;let t=this.builder._inputRuntimeDefinition,n=this.builder._schemaRuntimeDefinition;if(ns.isInstance(t)){if(Dt(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===Gd&&ns.isInstance(n)){if(Dt(e)){let i=e;return e.update&&(i.update=await n.validateInput(Array.isArray(e.update)?Object.fromEntries(e.update):e.update)),i}return await n.validateInput(e)}let r=(()=>{let i=s=>{if(s!=null)return this._metaRegistry.getExtendedChannelSchemas(s,{withReducerSchema:!0})};if(En(t))return i(t);if(t===Gd)return En(n)?Gv(i(n)):void 0})();if(Dt(e)){let i=e;return e.update&&r!=null&&(i.update=Bl(r,e.update)),i}return r!=null?Bl(r,e):e}isInterrupted(e){return g_(e)}async _validateContext(e){let t=this.builder._configRuntimeSchema;return En(t)&&Bl(t,e),e}};function EH(e){return typeof e=="object"&&e!==null&&e.channels!==void 0}function CH(e){if(cn(e))return[e];let t=[];Dt(e)?t.push(e):Array.isArray(e)&&t.push(...e.filter(Dt));let n=[];for(let r of t){if(r.graph===fr.PARENT)throw new J$(r);cn(r.goto)||typeof r.goto=="string"?n.push(r.goto):Array.isArray(r.goto)&&n.push(...r.goto)}return n}function n$(){return new qP({path:new Rs({func:CH,tags:[rn],trace:!1,recurse:!1,name:"<control_branch>"})})}Ye.Root({messages:Ye({reducer:O0,default:()=>[]})});var NH={reducer:{fn:O0},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]};tt({messages:Ly(xr(),NH)});async function PH(e,t,n){if(n===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).",`
|
|
339
|
+
|
|
340
|
+
If you continue to see this error, please import from "@langchain/core/callbacks/dispatch/web"`,"and explicitly pass in a config parameter.",`
|
|
341
|
+
|
|
342
|
+
Or, if you are calling this from a custom tool, ensure you're using the "tool" helper constructor as documented here:`,`
|
|
343
|
+
|`,`
|
|
344
|
+
\u2514-> https://js.langchain.com/docs/how_to/custom_tools#tool-function`,`
|
|
345
|
+
`].join(" "));let r=await on(n),i=r?.getParentRunId();r!==void 0&&i!==void 0&&await r.handleCustomEvent?.(e,t,i)}var zy=Symbol.for("langgraph-zod");zy in globalThis||(globalThis[zy]=new WeakSet);function r$(e){let t=globalThis[zy];t.has(e)||(Object.defineProperty(e,"langgraph",{get(){let n=this;return{metadata(r){return Ly(n,{jsonSchemaExtra:r})},reducer(r,i){return Ly(n,{default:Fh(n),reducer:{schema:i,fn:r}})}}}}),t.add(e))}try{r$(Se.prototype),r$(ye.prototype)}catch(e){throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.",{cause:e})}var jH=class extends lc{constructor(e){super(),this.parent=e,this._map=this.parent._map}add(e,...t){let n=t[0];if(n&&!n?.default){let r=Fh(e);r!=null&&(n.default=r)}return super.add(e,...t)}};new jH(Cc);var RH=yu().args(xr(),xr(),xr()).returns(Yr([lt(),FT(lt())])),MH=["approve","edit","reject"],UH=La(MH),LH=tt({allowedDecisions:Cs(UH),description:Yr([lt(),RH]).optional(),argsSchema:yc(ay()).optional()});tt({interruptOn:yc(Yr([ls(),LH])).optional(),descriptionPrefix:lt().default("Tool execution requires approval")});var zH=`<role>
|
|
346
|
+
Context Extraction Assistant
|
|
347
|
+
</role>
|
|
348
|
+
|
|
349
|
+
<primary_objective>
|
|
350
|
+
Your sole objective in this task is to extract the highest quality/most relevant context from the conversation history below.
|
|
351
|
+
</primary_objective>
|
|
352
|
+
|
|
353
|
+
<objective_information>
|
|
354
|
+
You're nearing the total number of input tokens you can accept, so you must extract the highest quality/most relevant pieces of information from your conversation history.
|
|
355
|
+
This context will then overwrite the conversation history presented below. Because of this, ensure the context you extract is only the most important information to your overall goal.
|
|
356
|
+
</objective_information>
|
|
357
|
+
|
|
358
|
+
<instructions>
|
|
359
|
+
The conversation history below will be replaced with the context you extract in this step. Because of this, you must do your very best to extract and record all of the most important context from the conversation history.
|
|
360
|
+
You want to ensure that you don't repeat any actions you've already completed, so the context you extract from the conversation history should be focused on the most important information to your overall goal.
|
|
361
|
+
</instructions>
|
|
362
|
+
|
|
363
|
+
The user will message you with the full message history you'll be extracting context from, to then replace. Carefully read over it all, and think deeply about what information is most important to your overall goal that should be saved:
|
|
364
|
+
|
|
365
|
+
With all of this in mind, please carefully read over the entire conversation history, and extract the most important and relevant context to replace it so that you can free up space in the conversation history.
|
|
366
|
+
Respond ONLY with the extracted context. Do not include any additional information, or text before or after the extracted context.
|
|
367
|
+
|
|
368
|
+
<messages>
|
|
369
|
+
Messages to summarize:
|
|
370
|
+
{messages}
|
|
371
|
+
</messages>`,DH=yu().args(Cs(xr())).returns(Yr([Ke(),FT(Ke())])),i$=tt({fraction:Ke().gt(0,"Fraction must be greater than 0").max(1,"Fraction must be less than or equal to 1").optional(),tokens:Ke().positive("Tokens must be greater than 0").optional(),messages:Ke().int("Messages must be an integer").positive("Messages must be greater than 0").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length>=1,{message:"At least one of fraction, tokens, or messages must be provided"}),FH=tt({fraction:Ke().min(0,"Messages must be non-negative").max(1,"Fraction must be less than or equal to 1").optional(),tokens:Ke().min(0,"Tokens must be greater than or equal to 0").optional(),messages:Ke().int("Messages must be an integer").min(0,"Messages must be non-negative").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length===1,{message:"Exactly one of fraction, tokens, or messages must be provided"});tt({model:xr(),trigger:Yr([i$,Cs(i$)]).optional(),keep:FH.optional(),tokenCounter:DH.optional(),summaryPrompt:lt().default(zH),trimTokensToSummarize:Ke().optional(),summaryPrefix:lt().optional(),maxTokensBeforeSummary:Ke().optional(),messagesToKeep:Ke().optional()});tt({model:lt().or(gu(Jh)).optional(),systemPrompt:lt().optional(),maxTools:Ke().optional(),alwaysInclude:Cs(lt()).optional()});tt({applyToInput:ls().optional(),applyToOutput:ls().optional(),applyToToolResults:ls().optional()});tt({rules:yc(lt(),gu(RegExp).describe("Regular expression pattern to match PII")).optional()});var ZH=["continue","error","end"],BH="continue",qH=La(ZH).default(BH);tt({toolName:lt().optional(),threadLimit:Ke().optional(),runLimit:Ke().optional(),exitBehavior:qH});tt({threadToolCallCount:yc(lt(),Ke()).default({}),runToolCallCount:yc(lt(),Ke()).default({})});var JH=La(["pending","in_progress","completed"]).describe("Status of the todo"),HH=tt({content:lt().describe("Content of the todo item"),status:JH});tt({todos:Cs(HH).default([])});tt({threadLimit:Ke().optional(),runLimit:Ke().optional(),exitBehavior:La(["error","end"]).optional()});tt({threadModelCallCount:Ke().default(0),runModelCallCount:Ke().default(0)});var WP=tt({maxRetries:Ke().min(0).default(2),retryOn:Yr([yu().args(gu(Error)).returns(ls()),Cs(xr())]).default(()=>()=>!0),backoffFactor:Ke().min(0).default(2),initialDelayMs:Ke().min(0).default(1e3),maxDelayMs:Ke().min(0).default(6e4),jitter:ls().default(!0)});tt({onFailure:Yr([ca("error"),ca("continue"),yu().args(gu(Error)).returns(lt())]).default("continue")}).merge(WP);tt({tools:Cs(Yr([xr(),xr(),lt()])).optional(),onFailure:Yr([ca("error"),ca("continue"),ca("raise"),ca("return_message"),yu().args(gu(Error)).returns(lt())]).default("continue")}).merge(WP);tt({enableCaching:ls().optional(),ttl:La(["5m","1h"]).optional(),minMessagesToCache:Ke().optional(),unsupportedModelBehavior:La(["ignore","warn","raise"]).optional()});function kl(e,t){return e.lc_error_code=t,e.message=`${e.message}
|
|
372
|
+
|
|
373
|
+
Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/
|
|
374
|
+
`,e}function de(e,t,n,r,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}function A(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}var GP=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return GP=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function Dy(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}var Fy=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)},se=class extends Error{},It=class e extends se{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get("x-request-id"),this.error=n;let s=n;this.code=s?.code,this.param=s?.param,this.type=s?.type}static makeMessage(t,n,r){let i=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return t&&i?`${t} ${i}`:t?`${t} status code (no body)`:i||"(no status code or body)"}static generate(t,n,r,i){if(!t||!i)return new qa({message:r,cause:Fy(n)});let s=n?.error;return t===400?new Xd(t,s,r,i):t===401?new Yd(t,s,r,i):t===403?new Qd(t,s,r,i):t===404?new ep(t,s,r,i):t===409?new tp(t,s,r,i):t===422?new np(t,s,r,i):t===429?new rp(t,s,r,i):t>=500?new ip(t,s,r,i):new e(t,s,r,i)}},Wt=class extends It{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}},qa=class extends It{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}},Ja=class extends qa{constructor({message:t}={}){super({message:t??"Request timed out."})}},Xd=class extends It{},Yd=class extends It{},Qd=class extends It{},ep=class extends It{},tp=class extends It{},np=class extends It{},rp=class extends It{},ip=class extends It{},sp=class extends se{constructor(){super("Could not parse response content as the length limit was reached")}},ap=class extends se{constructor(){super("Could not parse response content as the request was rejected by the content filter")}},rs=class extends Error{constructor(t){super(t)}},op=class extends It{constructor(t,n,r){let i="OAuth2 authentication error",s;if(n&&typeof n=="object"){let a=n;s=a.error;let o=a.error_description;o&&typeof o=="string"?i=o:s&&(i=s)}super(t,n,i,r),this.error_code=s}},Zy=class extends se{constructor(t,n,r){super(t),this.provider=n,this.cause=r}},VH=/^[a-z][a-z0-9+.-]*:/i,KH=e=>VH.test(e),nn=e=>(nn=Array.isArray,nn(e)),s$=nn;function T0(e){return typeof e!="object"?{}:e??{}}function a$(e){if(!e)return!0;for(let t in e)return!1;return!0}function WH(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Lf(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}var GH=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new se(`${e} must be an integer`);if(t<0)throw new se(`${e} must be a positive integer`);return t},XH=e=>{try{return JSON.parse(e)}catch{return}},Mu=e=>new Promise(t=>setTimeout(t,e)),Qs="6.36.0",YH=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function QH(){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 eV=()=>{let e=QH();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qs,"X-Stainless-OS":c$(Deno.build.os),"X-Stainless-Arch":o$(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":Qs,"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":Qs,"X-Stainless-OS":c$(globalThis.process.platform??"unknown"),"X-Stainless-Arch":o$(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=tV();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qs,"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":Qs,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function tV(){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:n}of e){let r=n.exec(navigator.userAgent);if(r){let i=r[1]||0,s=r[2]||0,a=r[3]||0;return{browser:t,version:`${i}.${s}.${a}`}}}return null}var o$=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",c$=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"),u$,nV=()=>u$??(u$=eV());function XP(){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 YP(...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 QP(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return YP({start(){},async pull(n){let{done:r,value:i}=await t.next();r?n.close():n.enqueue(i)},async cancel(){await t.return?.()}})}function ej(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let n=await t.read();return n?.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){let n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function l$(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var rV=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),tj="RFC3986",nj=e=>String(e),d$={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:nj},iV="RFC1738",By=(e,t)=>(By=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),By(e,t)),ur=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),zf=1024,sV=(e,t,n,r,i)=>{if(e.length===0)return e;let s=e;if(typeof e=="symbol"?s=Symbol.prototype.toString.call(e):typeof e!="string"&&(s=String(e)),n==="iso-8859-1")return escape(s).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});let a="";for(let o=0;o<s.length;o+=zf){let c=s.length>=zf?s.slice(o,o+zf):s,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===iV&&(d===40||d===41)){u[u.length]=c.charAt(l);continue}if(d<128){u[u.length]=ur[d];continue}if(d<2048){u[u.length]=ur[192|d>>6]+ur[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=ur[224|d>>12]+ur[128|d>>6&63]+ur[128|d&63];continue}l+=1,d=65536+((d&1023)<<10|c.charCodeAt(l)&1023),u[u.length]=ur[240|d>>18]+ur[128|d>>12&63]+ur[128|d>>6&63]+ur[128|d&63]}a+=u.join("")}return a};function aV(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function p$(e,t){if(nn(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var rj={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},ij=function(e,t){Array.prototype.push.apply(e,nn(t)?t:[t])},h$,ft={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:sV,encodeValuesOnly:!1,format:tj,formatter:nj,indices:!1,serializeDate(e){return(h$??(h$=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function oV(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var Df={};function sj(e,t,n,r,i,s,a,o,c,u,l,d,p,h,m,f,v,g){let y=e,w=g,x=0,O=!1;for(;(w=w.get(Df))!==void 0&&!O;){let C=w.get(e);if(x+=1,typeof C<"u"){if(C===x)throw new RangeError("Cyclic object value");O=!0}typeof w.get(Df)>"u"&&(x=0)}if(typeof u=="function"?y=u(t,y):y instanceof Date?y=p?.(y):n==="comma"&&nn(y)&&(y=p$(y,function(C){return C instanceof Date?p?.(C):C})),y===null){if(s)return c&&!f?c(t,ft.encoder,v,"key",h):t;y=""}if(oV(y)||aV(y)){if(c){let C=f?t:c(t,ft.encoder,v,"key",h);return[m?.(C)+"="+m?.(c(y,ft.encoder,v,"value",h))]}return[m?.(t)+"="+m?.(String(y))]}let z=[];if(typeof y>"u")return z;let T;if(n==="comma"&&nn(y))f&&c&&(y=p$(y,c)),T=[{value:y.length>0?y.join(",")||null:void 0}];else if(nn(u))T=u;else{let C=Object.keys(y);T=l?C.sort(l):C}let k=o?String(t).replace(/\./g,"%2E"):String(t),B=r&&nn(y)&&y.length===1?k+"[]":k;if(i&&nn(y)&&y.length===0)return B+"[]";for(let C=0;C<T.length;++C){let E=T[C],Z=typeof E=="object"&&typeof E.value<"u"?E.value:y[E];if(a&&Z===null)continue;let X=d&&o?E.replace(/\./g,"%2E"):E,ae=nn(y)?typeof n=="function"?n(B,X):B:B+(d?"."+X:"["+X+"]");g.set(e,x);let Ne=new WeakMap;Ne.set(Df,g),ij(z,sj(Z,ae,n,r,i,s,a,o,n==="comma"&&f&&nn(y)?null:c,u,l,d,p,h,m,f,v,Ne))}return z}function cV(e=ft){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||ft.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 n=tj;if(typeof e.format<"u"){if(!By(d$,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=d$[n],i=ft.filter;(typeof e.filter=="function"||nn(e.filter))&&(i=e.filter);let s;if(e.arrayFormat&&e.arrayFormat in rj?s=e.arrayFormat:"indices"in e?s=e.indices?"indices":"repeat":s=ft.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:ft.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:ft.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:ft.allowEmptyArrays,arrayFormat:s,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:ft.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?ft.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:ft.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:ft.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:ft.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:ft.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:ft.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:ft.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:ft.strictNullHandling}}function uV(e,t={}){let n=e,r=cV(t),i,s;typeof r.filter=="function"?(s=r.filter,n=s("",n)):nn(r.filter)&&(s=r.filter,i=s);let a=[];if(typeof n!="object"||n===null)return"";let o=rj[r.arrayFormat],c=o==="comma"&&r.commaRoundTrip;i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);let u=new WeakMap;for(let p=0;p<i.length;++p){let h=i[p];r.skipNulls&&n[h]===null||ij(a,sj(n[h],h,o,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u))}let l=a.join(r.delimiter),d=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),l.length>0?d+l:""}function lV(e){return uV(e,{arrayFormat:"brackets"})}function dV(e){let t=0;for(let i of e)t+=i.length;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.length;return n}var m$;function E0(e){let t;return(m$??(t=new globalThis.TextEncoder,m$=t.encode.bind(t)))(e)}var f$;function g$(e){let t;return(f$??(t=new globalThis.TextDecoder,f$=t.decode.bind(t)))(e)}var mn,fn,Ha=class{constructor(){mn.set(this,void 0),fn.set(this,void 0),de(this,mn,new Uint8Array),de(this,fn,null)}decode(t){if(t==null)return[];let n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?E0(t):t;de(this,mn,dV([A(this,mn,"f"),n]));let r=[],i;for(;(i=pV(A(this,mn,"f"),A(this,fn,"f")))!=null;){if(i.carriage&&A(this,fn,"f")==null){de(this,fn,i.index);continue}if(A(this,fn,"f")!=null&&(i.index!==A(this,fn,"f")+1||i.carriage)){r.push(g$(A(this,mn,"f").subarray(0,A(this,fn,"f")-1))),de(this,mn,A(this,mn,"f").subarray(A(this,fn,"f"))),de(this,fn,null);continue}let s=A(this,fn,"f")!==null?i.preceding-1:i.preceding,a=g$(A(this,mn,"f").subarray(0,s));r.push(a),de(this,mn,A(this,mn,"f").subarray(i.index)),de(this,fn,null)}return r}flush(){return A(this,mn,"f").length?this.decode(`
|
|
375
|
+
`):[]}};mn=new WeakMap,fn=new WeakMap;Ha.NEWLINE_CHARS=new Set([`
|
|
376
|
+
`,"\r"]);Ha.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function pV(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function hV(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var cp={off:0,error:200,warn:300,info:400,debug:500},y$=(e,t,n)=>{if(e){if(WH(cp,e))return e;Et(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(cp))}`)}};function Mo(){}function xl(e,t,n){return!t||cp[e]>cp[n]?Mo:t[e].bind(t)}var mV={error:Mo,warn:Mo,info:Mo,debug:Mo},_$=new WeakMap;function Et(e){let t=e.logger,n=e.logLevel??"off";if(!t)return mV;let r=_$.get(t);if(r&&r[0]===n)return r[1];let i={error:xl("error",t,n),warn:xl("warn",t,n),info:xl("info",t,n),debug:xl("debug",t,n)};return _$.set(t,[n,i]),i}var Gi=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,n])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),$o,Is=class e{constructor(t,n,r){this.iterator=t,$o.set(this,void 0),this.controller=n,de(this,$o,r)}static fromSSEResponse(t,n,r,i){let s=!1,a=r?Et(r):console;async function*o(){if(s)throw new se("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let c=!1;try{for await(let u of fV(t,n))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 It(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 It(void 0,l.error,l.message,void 0);yield{event:u.event,data:l}}}c=!0}catch(u){if(Dy(u))return;throw u}finally{c||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*s(){let o=new Ha,c=ej(t);for await(let u of c)for(let l of o.decode(u))yield l;for(let u of o.flush())yield u}async function*a(){if(i)throw new se("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let o=!1;try{for await(let c of s())o||c&&(yield JSON.parse(c));o=!0}catch(c){if(Dy(c))return;throw c}finally{o||n.abort()}}return new e(a,n,r)}[($o=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=s=>({next:()=>{if(s.length===0){let a=r.next();t.push(a),n.push(a)}return s.shift()}});return[new e(()=>i(t),this.controller,A(this,$o,"f")),new e(()=>i(n),this.controller,A(this,$o,"f"))]}toReadableStream(){let t=this,n;return YP({async start(){n=t[Symbol.asyncIterator]()},async pull(r){try{let{value:i,done:s}=await n.next();if(s)return r.close();let a=E0(JSON.stringify(i)+`
|
|
377
|
+
`);r.enqueue(a)}catch(i){r.error(i)}},async cancel(){await n.return?.()}})}};async function*fV(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new se("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 se("Attempted to iterate over a response with no body");let n=new qy,r=new Ha,i=ej(e.body);for await(let s of gV(i))for(let a of r.decode(s)){let o=n.decode(a);o&&(yield o)}for(let s of r.flush()){let a=n.decode(s);a&&(yield a)}}async function*gV(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let r=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?E0(n):n,i=new Uint8Array(t.length+r.length);i.set(t),i.set(r,t.length),t=i;let s;for(;(s=hV(t))!==-1;)yield t.slice(0,s),t=t.slice(s)}t.length>0&&(yield t)}var qy=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 s={event:this.event,data:this.data.join(`
|
|
378
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,r,i]=yV(t,":");return i.startsWith(" ")&&(i=i.substring(1)),n==="event"?this.event=i:n==="data"&&this.data.push(i),null}};function yV(e,t){let n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}async function aj(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:s}=t,a=await(async()=>{if(t.options.stream)return Et(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):Is.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let o=n.headers.get("content-type")?.split(";")[0]?.trim();if(o?.includes("application/json")||o?.endsWith("+json")){if(n.headers.get("content-length")==="0")return;let c=await n.json();return oj(c,n)}return await n.text()})();return Et(e).debug(`[${r}] response parsed`,Gi({retryOfRequestLogID:i,url:n.url,status:n.status,body:a,durationMs:Date.now()-s})),a}function oj(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 Uo,up=class e extends Promise{constructor(t,n,r=aj){super(i=>{i(null)}),this.responsePromise=n,this.parseResponse=r,Uo.set(this,void 0),de(this,Uo,t)}_thenUnwrap(t){return new e(A(this,Uo,"f"),this.responsePromise,async(n,r)=>oj(t(await this.parseResponse(n,r),r),r.response))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n,request_id:n.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(A(this,Uo,"f"),t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};Uo=new WeakMap;var $l,Va=class{constructor(t,n,r,i){$l.set(this,void 0),de(this,$l,t),this.options=i,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let t=this.nextPageRequestOptions();if(!t)throw new se("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await A(this,$l,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[($l=new WeakMap,Symbol.asyncIterator)](){for await(let t of this.iterPages())for(let n of t.getPaginatedItems())yield n}},Jy=class extends up{constructor(t,n,r){super(t,n,async(i,s)=>new r(i,s.response,await aj(i,s),s.options))}async*[Symbol.asyncIterator](){let t=await this;for await(let n of t)yield n}},Or=class extends Va{constructor(t,n,r,i){super(t,n,r,i),this.data=r.data||[],this.object=r.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},Ge=class extends Va{constructor(t,n,r,i){super(t,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.getPaginatedItems(),n=t[t.length-1]?.id;return n?{...this.options,query:{...T0(this.options.query),after:n}}:null}},Mt=class extends Va{constructor(t,n,r,i){super(t,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1,this.last_id=r.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:{...T0(this.options.query),after:t}}:null}},nr=class extends Va{constructor(t,n,r,i){super(t,n,r,i),this.data=r.data||[],this.has_more=r.has_more||!1,this.next=r.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.next;return t?{...this.options,query:{...T0(this.options.query),after:t}}:null}},_V={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},vV="urn:ietf:params:oauth:grant-type:token-exchange",Hy=class{constructor(t,n){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl="https://auth.openai.com/oauth/token",this.config=t,this.fetch=n??XP()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let t=await this.config.provider.getToken(),n=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:vV,client_id:this.config.clientId,subject_token:t,subject_token_type:_V[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId})});if(!n.ok){let a=await n.text(),o;try{o=JSON.parse(a)}catch{}throw n.status===400||n.status===401||n.status===403?new op(n.status,o,n.headers):It.generate(n.status,o,`Token exchange failed with status ${n.status}`,n.headers)}let r=await n.json(),i=r.expires_in||3600,s=Date.now()+i*1e3;return this.cachedToken={token:r.access_token,expiresAt:s},r.access_token}isTokenExpired(t){return Date.now()>=t.expiresAt}needsRefresh(t){let n=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=t.expiresAt-n}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}},cj=()=>{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 Ko(e,t,n){return cj(),new File(e,t??"unknown_file",n)}function td(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 C0=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function",Im=async(e,t)=>Vy(e.body)?{...e,body:await uj(e.body,t)}:e,vr=async(e,t)=>({...e,body:await uj(e.body,t)}),v$=new WeakMap;function bV(e){let t=typeof e=="function"?e:e.fetch,n=v$.get(t);if(n)return n;let r=(async()=>{try{let i="Response"in t?t.Response:(await t("data:,")).constructor,s=new FormData;return s.toString()!==await new i(s).text()}catch{return!0}})();return v$.set(t,r),r}var uj=async(e,t)=>{if(!await bV(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([r,i])=>Ky(n,r,i))),n},lj=e=>e instanceof Blob&&"name"in e,wV=e=>typeof e=="object"&&e!==null&&(e instanceof Response||C0(e)||lj(e)),Vy=e=>{if(wV(e))return!0;if(Array.isArray(e))return e.some(Vy);if(e&&typeof e=="object"){for(let t in e)if(Vy(e[t]))return!0}return!1},Ky=async(e,t,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")e.append(t,String(n));else if(n instanceof Response)e.append(t,Ko([await n.blob()],td(n)));else if(C0(n))e.append(t,Ko([await new Response(QP(n)).blob()],td(n)));else if(lj(n))e.append(t,n,td(n));else if(Array.isArray(n))await Promise.all(n.map(r=>Ky(e,t+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,i])=>Ky(e,`${t}[${r}]`,i)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},dj=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",kV=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&dj(e),xV=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function $V(e,t,n){if(cj(),e=await e,kV(e))return e instanceof File?e:Ko([await e.arrayBuffer()],e.name);if(xV(e)){let i=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Ko(await Wy(i),t,n)}let r=await Wy(e);if(t||(t=td(e)),!n?.type){let i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(n={...n,type:i})}return Ko(r,t,n)}async function Wy(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(dj(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(C0(e))for await(let n of e)t.push(...await Wy(n));else{let n=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${n?`; constructor: ${n}`:""}${IV(e)}`)}return t}function IV(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(t=>`"${t}"`).join(", ")}]`}var F=class{constructor(t){this._client=t}};function pj(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var b$=Object.freeze(Object.create(null)),SV=(e=pj)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],s=t.reduce((u,l,d)=>{/[?#]/.test(l)&&(r=!0);let p=n[d],h=(r?encodeURIComponent:e)(""+p);return d!==n.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??b$)??b$)?.toString)&&(h=p+"",i.push({start:u.length+l.length,length:h.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),u+l+(d===n.length?"":h)},""),a=s.split(/[?#]/,1)[0],o=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=o.exec(a))!==null;)i.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can't be safely passed as a path parameter`});if(i.sort((u,l)=>u.start-l.start),i.length>0){let u=0,l=i.reduce((d,p)=>{let h=" ".repeat(p.start-u),m="^".repeat(p.length);return u=p.start+p.length,d+h+m},"");throw new se(`Path parameters result in path with invalid segments:
|
|
379
|
+
${i.map(d=>d.error).join(`
|
|
380
|
+
`)}
|
|
381
|
+
${s}
|
|
382
|
+
${l}`)}return s},S=SV(pj),hj=class extends F{list(e,t={},n){return this._client.getAPIList(S`/chat/completions/${e}/messages`,Ge,{query:t,...n,__security:{bearerAuth:!0}})}};function lp(e){return e!==void 0&&"function"in e&&e.function!==void 0}function OV(e,t){let n={...e};return Object.defineProperties(n,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),n}function N0(e){return e?.$brand==="auto-parseable-response-format"}function Uu(e){return e?.$brand==="auto-parseable-tool"}function AV(e,t){return!t||!mj(t)?{...e,choices:e.choices.map(n=>(fj(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:P0(e,t)}function P0(e,t){let n=e.choices.map(r=>{if(r.finish_reason==="length")throw new sp;if(r.finish_reason==="content_filter")throw new ap;return fj(r.message.tool_calls),{...r,message:{...r.message,...r.message.tool_calls?{tool_calls:r.message.tool_calls?.map(i=>EV(t,i))??void 0}:void 0,parsed:r.message.content&&!r.message.refusal?TV(t,r.message.content):null}}});return{...e,choices:n}}function TV(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 EV(e,t){let n=e.tools?.find(r=>lp(r)&&r.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:Uu(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}function CV(e,t){if(!e||!("tools"in e)||!e.tools)return!1;let n=e.tools?.find(r=>lp(r)&&r.function?.name===t.function.name);return lp(n)&&(Uu(n)||n?.function.strict||!1)}function mj(e){return N0(e.response_format)?!0:e.tools?.some(t=>Uu(t)||t.type==="function"&&t.function.strict===!0)??!1}function fj(e){for(let t of e||[])if(t.type!=="function")throw new se(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}function NV(e){for(let t of e??[]){if(t.type!=="function")throw new se(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new se(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var dp=e=>e?.role==="assistant",gj=e=>e?.role==="tool",Gy,nd,rd,Lo,zo,id,Do,jr,Fo,pp,hp,ea,yj,Nc=class{constructor(){Gy.add(this),this.controller=new AbortController,nd.set(this,void 0),rd.set(this,()=>{}),Lo.set(this,()=>{}),zo.set(this,void 0),id.set(this,()=>{}),Do.set(this,()=>{}),jr.set(this,{}),Fo.set(this,!1),pp.set(this,!1),hp.set(this,!1),ea.set(this,!1),de(this,nd,new Promise((t,n)=>{de(this,rd,t,"f"),de(this,Lo,n,"f")})),de(this,zo,new Promise((t,n)=>{de(this,id,t,"f"),de(this,Do,n,"f")})),A(this,nd,"f").catch(()=>{}),A(this,zo,"f").catch(()=>{})}_run(t){setTimeout(()=>{t().then(()=>{this._emitFinal(),this._emit("end")},A(this,Gy,"m",yj).bind(this))},0)}_connected(){this.ended||(A(this,rd,"f").call(this),this._emit("connect"))}get ended(){return A(this,Fo,"f")}get errored(){return A(this,pp,"f")}get aborted(){return A(this,hp,"f")}abort(){this.controller.abort()}on(t,n){return(A(this,jr,"f")[t]||(A(this,jr,"f")[t]=[])).push({listener:n}),this}off(t,n){let r=A(this,jr,"f")[t];if(!r)return this;let i=r.findIndex(s=>s.listener===n);return i>=0&&r.splice(i,1),this}once(t,n){return(A(this,jr,"f")[t]||(A(this,jr,"f")[t]=[])).push({listener:n,once:!0}),this}emitted(t){return new Promise((n,r)=>{de(this,ea,!0),t!=="error"&&this.once("error",r),this.once(t,n)})}async done(){de(this,ea,!0),await A(this,zo,"f")}_emit(t,...n){if(A(this,Fo,"f"))return;t==="end"&&(de(this,Fo,!0),A(this,id,"f").call(this));let r=A(this,jr,"f")[t];if(r&&(A(this,jr,"f")[t]=r.filter(i=>!i.once),r.forEach(({listener:i})=>i(...n))),t==="abort"){let i=n[0];!A(this,ea,"f")&&!r?.length&&Promise.reject(i),A(this,Lo,"f").call(this,i),A(this,Do,"f").call(this,i),this._emit("end");return}if(t==="error"){let i=n[0];!A(this,ea,"f")&&!r?.length&&Promise.reject(i),A(this,Lo,"f").call(this,i),A(this,Do,"f").call(this,i),this._emit("end")}}_emitFinal(){}};nd=new WeakMap,rd=new WeakMap,Lo=new WeakMap,zo=new WeakMap,id=new WeakMap,Do=new WeakMap,jr=new WeakMap,Fo=new WeakMap,pp=new WeakMap,hp=new WeakMap,ea=new WeakMap,Gy=new WeakSet,yj=function(e){if(de(this,pp,!0),e instanceof Error&&e.name==="AbortError"&&(e=new Wt),e instanceof Wt)return de(this,hp,!0),this._emit("abort",e);if(e instanceof se)return this._emit("error",e);if(e instanceof Error){let t=new se(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new se(String(e)))};function PV(e){return typeof e.parse=="function"}var Vt,Xy,mp,Yy,Qy,e_,_j,vj,jV=10,fp=class extends Nc{constructor(){super(...arguments),Vt.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(t){this._chatCompletions.push(t),this._emit("chatCompletion",t);let n=t.choices[0]?.message;return n&&this._addMessage(n),t}_addMessage(t,n=!0){if("content"in t||(t.content=null),this.messages.push(t),n){if(this._emit("message",t),gj(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(dp(t)&&t.tool_calls)for(let r of t.tool_calls)r.type==="function"&&this._emit("functionToolCall",r.function)}}async finalChatCompletion(){await this.done();let t=this._chatCompletions[this._chatCompletions.length-1];if(!t)throw new se("stream ended without producing a ChatCompletion");return t}async finalContent(){return await this.done(),A(this,Vt,"m",Xy).call(this)}async finalMessage(){return await this.done(),A(this,Vt,"m",mp).call(this)}async finalFunctionToolCall(){return await this.done(),A(this,Vt,"m",Yy).call(this)}async finalFunctionToolCallResult(){return await this.done(),A(this,Vt,"m",Qy).call(this)}async totalUsage(){return await this.done(),A(this,Vt,"m",e_).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let t=this._chatCompletions[this._chatCompletions.length-1];t&&this._emit("finalChatCompletion",t);let n=A(this,Vt,"m",mp).call(this);n&&this._emit("finalMessage",n);let r=A(this,Vt,"m",Xy).call(this);r&&this._emit("finalContent",r);let i=A(this,Vt,"m",Yy).call(this);i&&this._emit("finalFunctionToolCall",i);let s=A(this,Vt,"m",Qy).call(this);s!=null&&this._emit("finalFunctionToolCallResult",s),this._chatCompletions.some(a=>a.usage)&&this._emit("totalUsage",A(this,Vt,"m",e_).call(this))}async _createChatCompletion(t,n,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),A(this,Vt,"m",_j).call(this,n);let s=await t.chat.completions.create({...n,stream:!1},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(P0(s,n))}async _runChatCompletion(t,n,r){for(let i of n.messages)this._addMessage(i,!1);return await this._createChatCompletion(t,n,r)}async _runTools(t,n,r){let i="tool",{tool_choice:s="auto",stream:a,...o}=n,c=typeof s!="string"&&s.type==="function"&&s?.function?.name,{maxChatCompletions:u=jV}=r||{},l=n.tools.map(h=>{if(Uu(h)){if(!h.$callback)throw new se("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:h.$callback,name:h.function.name,description:h.function.description||"",parameters:h.function.parameters,parse:h.$parseRaw,strict:!0}}}return h}),d={};for(let h of l)h.type==="function"&&(d[h.function.name||h.function.function.name]=h.function);let p="tools"in n?l.map(h=>h.type==="function"?{type:"function",function:{name:h.function.name||h.function.function.name,parameters:h.function.parameters,description:h.function.description,strict:h.function.strict}}:h):void 0;for(let h of n.messages)this._addMessage(h,!1);for(let h=0;h<u;++h){let m=(await this._createChatCompletion(t,{...o,tool_choice:s,tools:p,messages:[...this.messages]},r)).choices[0]?.message;if(!m)throw new se("missing message in ChatCompletion response");if(!m.tool_calls?.length)return;for(let f of m.tool_calls){if(f.type!=="function")continue;let v=f.id,{name:g,arguments:y}=f.function,w=d[g];if(w){if(c&&c!==g){let T=`Invalid tool_call: ${JSON.stringify(g)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:v,content:T});continue}}else{let T=`Invalid tool_call: ${JSON.stringify(g)}. Available options are: ${Object.keys(d).map(k=>JSON.stringify(k)).join(", ")}. Please try again`;this._addMessage({role:i,tool_call_id:v,content:T});continue}let x;try{x=PV(w)?await w.parse(y):y}catch(T){let k=T instanceof Error?T.message:String(T);this._addMessage({role:i,tool_call_id:v,content:k});continue}let O=await w.function(x,this),z=A(this,Vt,"m",vj).call(this,O);if(this._addMessage({role:i,tool_call_id:v,content:z}),c)return}}}};Vt=new WeakSet,Xy=function(){return A(this,Vt,"m",mp).call(this).content??null},mp=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(dp(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new se("stream ended without producing a ChatCompletionMessage with role=assistant")},Yy=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(dp(t)&&t?.tool_calls?.length)return t.tool_calls.filter(n=>n.type==="function").at(-1)?.function}},Qy=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(gj(t)&&t.content!=null&&typeof t.content=="string"&&this.messages.some(n=>n.role==="assistant"&&n.tool_calls?.some(r=>r.type==="function"&&r.id===t.tool_call_id)))return t.content}},e_=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},_j=function(e){if(e.n!=null&&e.n>1)throw new se("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},vj=function(e){return typeof e=="string"?e:e===void 0?"undefined":JSON.stringify(e)};var t_=class e extends fp{static runTools(t,n,r){let i=new e,s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(t,n,s)),i}_addMessage(t,n=!0){super._addMessage(t,n),dp(t)&&t.content&&this._emit("content",t.content)}},bj=1,wj=2,kj=4,xj=8,$j=16,Ij=32,Sj=64,Oj=128,Aj=256,Tj=Oj|Aj,Ej=$j|Ij|Tj|Sj,Cj=bj|wj|Ej,Nj=kj|xj,RV=Cj|Nj,kt={STR:bj,NUM:wj,ARR:kj,OBJ:xj,NULL:$j,BOOL:Ij,NAN:Sj,INFINITY:Oj,MINUS_INFINITY:Aj,INF:Tj,SPECIAL:Ej,ATOM:Cj,COLLECTION:Nj,ALL:RV},n_=class extends Error{},r_=class extends Error{};function MV(e,t=kt.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return UV(e.trim(),t)}var UV=(e,t)=>{let n=e.length,r=0,i=p=>{throw new n_(`${p} at position ${r}`)},s=p=>{throw new r_(`${p} at position ${r}`)},a=()=>(d(),r>=n&&i("Unexpected end of input"),e[r]==='"'?o():e[r]==="{"?c():e[r]==="["?u():e.substring(r,r+4)==="null"||kt.NULL&t&&n-r<4&&"null".startsWith(e.substring(r))?(r+=4,null):e.substring(r,r+4)==="true"||kt.BOOL&t&&n-r<4&&"true".startsWith(e.substring(r))?(r+=4,!0):e.substring(r,r+5)==="false"||kt.BOOL&t&&n-r<5&&"false".startsWith(e.substring(r))?(r+=5,!1):e.substring(r,r+8)==="Infinity"||kt.INFINITY&t&&n-r<8&&"Infinity".startsWith(e.substring(r))?(r+=8,1/0):e.substring(r,r+9)==="-Infinity"||kt.MINUS_INFINITY&t&&1<n-r&&n-r<9&&"-Infinity".startsWith(e.substring(r))?(r+=9,-1/0):e.substring(r,r+3)==="NaN"||kt.NAN&t&&n-r<3&&"NaN".startsWith(e.substring(r))?(r+=3,NaN):l()),o=()=>{let p=r,h=!1;for(r++;r<n&&(e[r]!=='"'||h&&e[r-1]==="\\");)h=e[r]==="\\"?!h:!1,r++;if(e.charAt(r)=='"')try{return JSON.parse(e.substring(p,++r-Number(h)))}catch(m){s(String(m))}else if(kt.STR&t)try{return JSON.parse(e.substring(p,r-Number(h))+'"')}catch{return JSON.parse(e.substring(p,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},c=()=>{r++,d();let p={};try{for(;e[r]!=="}";){if(d(),r>=n&&kt.OBJ&t)return p;let h=o();d(),r++;try{let m=a();Object.defineProperty(p,h,{value:m,writable:!0,enumerable:!0,configurable:!0})}catch(m){if(kt.OBJ&t)return p;throw m}d(),e[r]===","&&r++}}catch{if(kt.OBJ&t)return p;i("Expected '}' at end of object")}return r++,p},u=()=>{r++;let p=[];try{for(;e[r]!=="]";)p.push(a()),d(),e[r]===","&&r++}catch{if(kt.ARR&t)return p;i("Expected ']' at end of array")}return r++,p},l=()=>{if(r===0){e==="-"&&kt.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e)}catch(h){if(kt.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}s(String(h))}}let p=r;for(e[r]==="-"&&r++;e[r]&&!",]}".includes(e[r]);)r++;r==n&&!(kt.NUM&t)&&i("Unterminated number literal");try{return JSON.parse(e.substring(p,r))}catch{e.substring(p,r)==="-"&&kt.NUM&t&&i("Not sure what '-' is");try{return JSON.parse(e.substring(p,e.lastIndexOf("e")))}catch(h){s(String(h))}}},d=()=>{for(;r<n&&`
|
|
383
|
+
\r `.includes(e[r]);)r++};return a()},w$=e=>MV(e,kt.ALL^kt.NUM),mt,Pr,Vs,ii,Ff,Il,Zf,Bf,qf,Sl,Jf,k$,gp=class e extends fp{constructor(t){super(),mt.add(this),Pr.set(this,void 0),Vs.set(this,void 0),ii.set(this,void 0),de(this,Pr,t),de(this,Vs,[])}get currentChatCompletionSnapshot(){return A(this,ii,"f")}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,r){let i=new e(n);return i._run(()=>i._runChatCompletion(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createChatCompletion(t,n,r){super._createChatCompletion;let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),A(this,mt,"m",Ff).call(this);let s=await t.chat.completions.create({...n,stream:!0},{...r,signal:this.controller.signal});this._connected();for await(let a of s)A(this,mt,"m",Zf).call(this,a);if(s.controller.signal?.aborted)throw new Wt;return this._addChatCompletion(A(this,mt,"m",Sl).call(this))}async _fromReadableStream(t,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),A(this,mt,"m",Ff).call(this),this._connected();let i=Is.fromReadableStream(t,this.controller),s;for await(let a of i)s&&s!==a.id&&this._addChatCompletion(A(this,mt,"m",Sl).call(this)),A(this,mt,"m",Zf).call(this,a),s=a.id;if(i.controller.signal?.aborted)throw new Wt;return this._addChatCompletion(A(this,mt,"m",Sl).call(this))}[(Pr=new WeakMap,Vs=new WeakMap,ii=new WeakMap,mt=new WeakSet,Ff=function(){this.ended||de(this,ii,void 0)},Il=function(t){let n=A(this,Vs,"f")[t.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},A(this,Vs,"f")[t.index]=n,n)},Zf=function(t){if(this.ended)return;let n=A(this,mt,"m",k$).call(this,t);this._emit("chunk",t,n);for(let r of t.choices){let i=n.choices[r.index];r.delta.content!=null&&i.message?.role==="assistant"&&i.message?.content&&(this._emit("content",r.delta.content,i.message.content),this._emit("content.delta",{delta:r.delta.content,snapshot:i.message.content,parsed:i.message.parsed})),r.delta.refusal!=null&&i.message?.role==="assistant"&&i.message?.refusal&&this._emit("refusal.delta",{delta:r.delta.refusal,snapshot:i.message.refusal}),r.logprobs?.content!=null&&i.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:r.logprobs?.content,snapshot:i.logprobs?.content??[]}),r.logprobs?.refusal!=null&&i.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:r.logprobs?.refusal,snapshot:i.logprobs?.refusal??[]});let s=A(this,mt,"m",Il).call(this,i);i.finish_reason&&(A(this,mt,"m",qf).call(this,i),s.current_tool_call_index!=null&&A(this,mt,"m",Bf).call(this,i,s.current_tool_call_index));for(let a of r.delta.tool_calls??[])s.current_tool_call_index!==a.index&&(A(this,mt,"m",qf).call(this,i),s.current_tool_call_index!=null&&A(this,mt,"m",Bf).call(this,i,s.current_tool_call_index)),s.current_tool_call_index=a.index;for(let a of r.delta.tool_calls??[]){let o=i.message.tool_calls?.[a.index];o?.type&&(o?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:o.function?.name,index:a.index,arguments:o.function.arguments,parsed_arguments:o.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):o?.type)}}},Bf=function(t,n){if(A(this,mt,"m",Il).call(this,t).done_tool_calls.has(n))return;let r=t.message.tool_calls?.[n];if(!r)throw new Error("no tool call snapshot");if(!r.type)throw new Error("tool call snapshot missing `type`");if(r.type==="function"){let i=A(this,Pr,"f")?.tools?.find(s=>lp(s)&&s.function.name===r.function.name);this._emit("tool_calls.function.arguments.done",{name:r.function.name,index:n,arguments:r.function.arguments,parsed_arguments:Uu(i)?i.$parseRaw(r.function.arguments):i?.function.strict?JSON.parse(r.function.arguments):null})}else r.type},qf=function(t){let n=A(this,mt,"m",Il).call(this,t);if(t.message.content&&!n.content_done){n.content_done=!0;let r=A(this,mt,"m",Jf).call(this);this._emit("content.done",{content:t.message.content,parsed:r?r.$parseRaw(t.message.content):null})}t.message.refusal&&!n.refusal_done&&(n.refusal_done=!0,this._emit("refusal.done",{refusal:t.message.refusal})),t.logprobs?.content&&!n.logprobs_content_done&&(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:t.logprobs.content})),t.logprobs?.refusal&&!n.logprobs_refusal_done&&(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:t.logprobs.refusal}))},Sl=function(){if(this.ended)throw new se("stream has ended, this shouldn't happen");let t=A(this,ii,"f");if(!t)throw new se("request ended without sending any chunks");return de(this,ii,void 0),de(this,Vs,[]),LV(t,A(this,Pr,"f"))},Jf=function(){let t=A(this,Pr,"f")?.response_format;return N0(t)?t:null},k$=function(t){var n,r,i,s;let a=A(this,ii,"f"),{choices:o,...c}=t;a?Object.assign(a,c):a=de(this,ii,{...c,choices:[]});for(let{delta:u,finish_reason:l,index:d,logprobs:p=null,...h}of t.choices){let m=a.choices[d];if(m||(m=a.choices[d]={finish_reason:l,index:d,message:{},logprobs:p,...h}),p)if(!m.logprobs)m.logprobs=Object.assign({},p);else{let{content:O,refusal:z,...T}=p;Object.assign(m.logprobs,T),O&&((n=m.logprobs).content??(n.content=[]),m.logprobs.content.push(...O)),z&&((r=m.logprobs).refusal??(r.refusal=[]),m.logprobs.refusal.push(...z))}if(l&&(m.finish_reason=l,A(this,Pr,"f")&&mj(A(this,Pr,"f")))){if(l==="length")throw new sp;if(l==="content_filter")throw new ap}if(Object.assign(m,h),!u)continue;let{content:f,refusal:v,function_call:g,role:y,tool_calls:w,...x}=u;if(Object.assign(m.message,x),v&&(m.message.refusal=(m.message.refusal||"")+v),y&&(m.message.role=y),g&&(m.message.function_call?(g.name&&(m.message.function_call.name=g.name),g.arguments&&((i=m.message.function_call).arguments??(i.arguments=""),m.message.function_call.arguments+=g.arguments)):m.message.function_call=g),f&&(m.message.content=(m.message.content||"")+f,!m.message.refusal&&A(this,mt,"m",Jf).call(this)&&(m.message.parsed=w$(m.message.content))),w){m.message.tool_calls||(m.message.tool_calls=[]);for(let{index:O,id:z,type:T,function:k,...B}of w){let C=(s=m.message.tool_calls)[O]??(s[O]={});Object.assign(C,B),z&&(C.id=z),T&&(C.type=T),k&&(C.function??(C.function={name:k.name??"",arguments:""})),k?.name&&(C.function.name=k.name),k?.arguments&&(C.function.arguments+=k.arguments,CV(A(this,Pr,"f"),C)&&(C.function.parsed_arguments=w$(C.function.arguments)))}}}return a},Symbol.asyncIterator)](){let t=[],n=[],r=!1;return this.on("chunk",i=>{let s=n.shift();s?s.resolve(i):t.push(i)}),this.on("end",()=>{r=!0;for(let i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((i,s)=>n.push({resolve:i,reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Is(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function LV(e,t){let{id:n,choices:r,created:i,model:s,system_fingerprint:a,...o}=e,c={...o,id:n,choices:r.map(({message:u,finish_reason:l,index:d,logprobs:p,...h})=>{if(!l)throw new se(`missing finish_reason for choice ${d}`);let{content:m=null,function_call:f,tool_calls:v,...g}=u,y=u.role;if(!y)throw new se(`missing role for choice ${d}`);if(f){let{arguments:w,name:x}=f;if(w==null)throw new se(`missing function_call.arguments for choice ${d}`);if(!x)throw new se(`missing function_call.name for choice ${d}`);return{...h,message:{content:m,function_call:{arguments:w,name:x},role:y,refusal:u.refusal??null},finish_reason:l,index:d,logprobs:p}}return v?{...h,index:d,finish_reason:l,logprobs:p,message:{...g,role:y,content:m,refusal:u.refusal??null,tool_calls:v.map((w,x)=>{let{function:O,type:z,id:T,...k}=w,{arguments:B,name:C,...E}=O||{};if(T==null)throw new se(`missing choices[${d}].tool_calls[${x}].id
|
|
384
|
+
${Ol(e)}`);if(z==null)throw new se(`missing choices[${d}].tool_calls[${x}].type
|
|
385
|
+
${Ol(e)}`);if(C==null)throw new se(`missing choices[${d}].tool_calls[${x}].function.name
|
|
386
|
+
${Ol(e)}`);if(B==null)throw new se(`missing choices[${d}].tool_calls[${x}].function.arguments
|
|
387
|
+
${Ol(e)}`);return{...k,id:T,type:z,function:{...E,name:C,arguments:B}}})}}:{...h,message:{...g,content:m,role:y,refusal:u.refusal??null},finish_reason:l,index:d,logprobs:p}}),created:i,model:s,object:"chat.completion",...a?{system_fingerprint:a}:{}};return AV(c,t)}function Ol(e){return JSON.stringify(e)}var i_=class e extends gp{static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,r){let i=new e(n),s={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return i._run(()=>i._runTools(t,n,s)),i}},j0=class extends F{constructor(){super(...arguments),this.messages=new hj(this._client)}create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(S`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(S`/chat/completions/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList("/chat/completions",Ge,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(S`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}parse(e,t){return NV(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(n=>P0(n,e))}runTools(e,t){return e.stream?i_.runTools(this._client,e,t):t_.runTools(this._client,e,t)}stream(e,t){return gp.createChatCompletion(this._client,e,t)}};j0.Messages=hj;var Pc=class extends F{constructor(){super(...arguments),this.completions=new j0(this._client)}};Pc.Completions=j0;var yp=class extends F{create(t,n){return this._client.post("/organization/admin_api_keys",{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,n){return this._client.get(S`/organization/admin_api_keys/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t={},n){return this._client.getAPIList("/organization/admin_api_keys",Ge,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,n){return this._client.delete(S`/organization/admin_api_keys/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}},_p=class extends F{list(t={},n){return this._client.getAPIList("/organization/audit_logs",Mt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}},Pj=class extends F{create(e,t){return this._client.post("/organization/certificates",{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(S`/organization/certificates/${e}`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(S`/organization/certificates/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList("/organization/certificates",Mt,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(S`/organization/certificates/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}activate(e,t){return this._client.getAPIList("/organization/certificates/activate",Or,{body:e,method:"post",...t,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t){return this._client.getAPIList("/organization/certificates/deactivate",Or,{body:e,method:"post",...t,__security:{adminAPIKeyAuth:!0}})}},vp=class extends F{create(t,n){return this._client.post("/organization/invites",{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,n){return this._client.get(S`/organization/invites/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(t={},n){return this._client.getAPIList("/organization/invites",Mt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,n){return this._client.delete(S`/organization/invites/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}},jj=class extends F{create(e,t){return this._client.post("/organization/roles",{body:e,...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(S`/organization/roles/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList("/organization/roles",nr,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(S`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},bp=class extends F{audioSpeeches(t,n){return this._client.get("/organization/usage/audio_speeches",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions(t,n){return this._client.get("/organization/usage/audio_transcriptions",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions(t,n){return this._client.get("/organization/usage/code_interpreter_sessions",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}completions(t,n){return this._client.get("/organization/usage/completions",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}costs(t,n){return this._client.get("/organization/costs",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}embeddings(t,n){return this._client.get("/organization/usage/embeddings",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}images(t,n){return this._client.get("/organization/usage/images",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}moderations(t,n){return this._client.get("/organization/usage/moderations",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}vectorStores(t,n){return this._client.get("/organization/usage/vector_stores",{query:t,...n,__security:{adminAPIKeyAuth:!0}})}},Rj=class extends F{create(e,t,n){return this._client.post(S`/organization/groups/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/organization/groups/${e}/roles`,nr,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(S`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Mj=class extends F{create(e,t,n){return this._client.post(S`/organization/groups/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/organization/groups/${e}/users`,nr,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(S`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Sm=class extends F{constructor(){super(...arguments),this.users=new Mj(this._client),this.roles=new Rj(this._client)}create(e,t){return this._client.post("/organization/groups",{body:e,...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(S`/organization/groups/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList("/organization/groups",nr,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(S`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}};Sm.Users=Mj;Sm.Roles=Rj;var wp=class extends F{retrieve(t,n,r){let{project_id:i}=n;return this._client.get(S`/organization/projects/${i}/api_keys/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/organization/projects/${t}/api_keys`,Mt,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,n,r){let{project_id:i}=n;return this._client.delete(S`/organization/projects/${i}/api_keys/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}},kp=class extends F{list(t,n={},r){return this._client.getAPIList(S`/organization/projects/${t}/certificates`,Mt,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}activate(t,n,r){return this._client.getAPIList(S`/organization/projects/${t}/certificates/activate`,Or,{body:n,method:"post",...r,__security:{adminAPIKeyAuth:!0}})}deactivate(t,n,r){return this._client.getAPIList(S`/organization/projects/${t}/certificates/deactivate`,Or,{body:n,method:"post",...r,__security:{adminAPIKeyAuth:!0}})}},xp=class extends F{listRateLimits(t,n={},r){return this._client.getAPIList(S`/organization/projects/${t}/rate_limits`,Mt,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}updateRateLimit(t,n,r){let{project_id:i,...s}=n;return this._client.post(S`/organization/projects/${i}/rate_limits/${t}`,{body:s,...r,__security:{adminAPIKeyAuth:!0}})}},Uj=class extends F{create(e,t,n){return this._client.post(S`/projects/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(S`/projects/${r}/roles/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/projects/${e}/roles`,nr,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(S`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},$p=class extends F{create(t,n,r){return this._client.post(S`/organization/projects/${t}/service_accounts`,{body:n,...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,n,r){let{project_id:i}=n;return this._client.get(S`/organization/projects/${i}/service_accounts/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/organization/projects/${t}/service_accounts`,Mt,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,n,r){let{project_id:i}=n;return this._client.delete(S`/organization/projects/${i}/service_accounts/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}},Lj=class extends F{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(S`/projects/${r}/groups/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(S`/projects/${r}/groups/${e}/roles`,nr,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,group_id:i}=t;return this._client.delete(S`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},jc=class extends F{constructor(){super(...arguments),this.roles=new Lj(this._client)}create(t,n,r){return this._client.post(S`/organization/projects/${t}/groups`,{body:n,...r,__security:{adminAPIKeyAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/organization/projects/${t}/groups`,nr,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,n,r){let{project_id:i}=n;return this._client.delete(S`/organization/projects/${i}/groups/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}};jc.Roles=Lj;var zj=class extends F{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(S`/projects/${r}/users/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(S`/projects/${r}/users/${e}/roles`,nr,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,user_id:i}=t;return this._client.delete(S`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},R0=class extends F{constructor(){super(...arguments),this.roles=new zj(this._client)}create(e,t,n){return this._client.post(S`/organization/projects/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(S`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(S`/organization/projects/${r}/users/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/organization/projects/${e}/users`,Mt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(S`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}};R0.Roles=zj;var rr=class extends F{constructor(){super(...arguments),this.users=new R0(this._client),this.serviceAccounts=new $p(this._client),this.apiKeys=new wp(this._client),this.rateLimits=new xp(this._client),this.groups=new jc(this._client),this.roles=new Uj(this._client),this.certificates=new kp(this._client)}create(t,n){return this._client.post("/organization/projects",{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(t,n){return this._client.get(S`/organization/projects/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,n,r){return this._client.post(S`/organization/projects/${t}`,{body:n,...r,__security:{adminAPIKeyAuth:!0}})}list(t={},n){return this._client.getAPIList("/organization/projects",Mt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}archive(t,n){return this._client.post(S`/organization/projects/${t}/archive`,{...n,__security:{adminAPIKeyAuth:!0}})}};rr.Users=R0;rr.ServiceAccounts=$p;rr.APIKeys=wp;rr.RateLimits=xp;rr.Groups=jc;rr.Roles=Uj;rr.Certificates=kp;var Ip=class extends F{create(t,n,r){return this._client.post(S`/organization/users/${t}/roles`,{body:n,...r,__security:{adminAPIKeyAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/organization/users/${t}/roles`,nr,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,n,r){let{user_id:i}=n;return this._client.delete(S`/organization/users/${i}/roles/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}},Rc=class extends F{constructor(){super(...arguments),this.roles=new Ip(this._client)}retrieve(t,n){return this._client.get(S`/organization/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(t,n,r){return this._client.post(S`/organization/users/${t}`,{body:n,...r,__security:{adminAPIKeyAuth:!0}})}list(t={},n){return this._client.getAPIList("/organization/users",Mt,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(t,n){return this._client.delete(S`/organization/users/${t}`,{...n,__security:{adminAPIKeyAuth:!0}})}};Rc.Roles=Ip;var xn=class extends F{constructor(){super(...arguments),this.auditLogs=new _p(this._client),this.adminAPIKeys=new yp(this._client),this.usage=new bp(this._client),this.invites=new vp(this._client),this.users=new Rc(this._client),this.groups=new Sm(this._client),this.roles=new jj(this._client),this.certificates=new Pj(this._client),this.projects=new rr(this._client)}};xn.AuditLogs=_p;xn.AdminAPIKeys=yp;xn.Usage=bp;xn.Invites=vp;xn.Users=Rc;xn.Groups=Sm;xn.Roles=jj;xn.Certificates=Pj;xn.Projects=rr;var Mc=class extends F{constructor(){super(...arguments),this.organization=new xn(this._client)}};Mc.Organization=xn;var Dj=Symbol("brand.privateNullableHeaders");function*zV(e){if(!e)return;if(Dj in e){let{values:r,nulls:i}=e;yield*r.entries();for(let s of i)yield[s,null];return}let t=!1,n;e instanceof Headers?n=e.entries():s$(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let r of n){let i=r[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");let s=s$(r[1])?r[1]:[r[1]],a=!1;for(let o of s)o!==void 0&&(t&&!a&&(a=!0,yield[i,null]),yield[i,o])}}var V=e=>{let t=new Headers,n=new Set;for(let r of e){let i=new Set;for(let[s,a]of zV(r)){let o=s.toLowerCase();i.has(o)||(t.delete(s),i.add(o)),a===null?(t.delete(s),n.add(o)):(t.append(s,a),n.delete(o))}}return{[Dj]:!0,values:t,nulls:n}},Sp=class extends F{create(t,n){return this._client.post("/audio/speech",{body:t,...n,headers:V([{Accept:"application/octet-stream"},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},Op=class extends F{create(t,n){return this._client.post("/audio/transcriptions",vr({body:t,...n,stream:t.stream??!1,__metadata:{model:t.model},__security:{bearerAuth:!0}},this._client))}},Ap=class extends F{create(t,n){return this._client.post("/audio/translations",vr({body:t,...n,__metadata:{model:t.model},__security:{bearerAuth:!0}},this._client))}},Ss=class extends F{constructor(){super(...arguments),this.transcriptions=new Op(this._client),this.translations=new Ap(this._client),this.speech=new Sp(this._client)}};Ss.Transcriptions=Op;Ss.Translations=Ap;Ss.Speech=Sp;var Tp=class extends F{create(t,n){return this._client.post("/batches",{body:t,...n,__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/batches/${t}`,{...n,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/batches",Ge,{query:t,...n,__security:{bearerAuth:!0}})}cancel(t,n){return this._client.post(S`/batches/${t}/cancel`,{...n,__security:{bearerAuth:!0}})}},Ep=class extends F{create(t,n){return this._client.post("/assistants",{body:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/assistants/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/assistants/${t}`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/assistants",Ge,{query:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/assistants/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}},Fj=class extends F{create(e,t){return this._client.post("/realtime/sessions",{body:e,...t,headers:V([{"OpenAI-Beta":"assistants=v2"},t?.headers]),__security:{bearerAuth:!0}})}},Cp=class extends F{create(t,n){return this._client.post("/realtime/transcription_sessions",{body:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}},Om=class extends F{constructor(){super(...arguments),this.sessions=new Fj(this._client),this.transcriptionSessions=new Cp(this._client)}};Om.Sessions=Fj;Om.TranscriptionSessions=Cp;var Np=class extends F{create(t,n){return this._client.post("/chatkit/sessions",{body:t,...n,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers]),__security:{bearerAuth:!0}})}cancel(t,n){return this._client.post(S`/chatkit/sessions/${t}/cancel`,{...n,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers]),__security:{bearerAuth:!0}})}},Zj=class extends F{retrieve(e,t){return this._client.get(S`/chatkit/threads/${e}`,{...t,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList("/chatkit/threads",Mt,{query:e,...t,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(S`/chatkit/threads/${e}`,{...t,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},t?.headers]),__security:{bearerAuth:!0}})}listItems(e,t={},n){return this._client.getAPIList(S`/chatkit/threads/${e}/items`,Mt,{query:t,...n,headers:V([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers]),__security:{bearerAuth:!0}})}},Ka=class extends F{constructor(){super(...arguments),this.sessions=new Np(this._client),this.threads=new Zj(this._client)}};Ka.Sessions=Np;Ka.Threads=Zj;var Pp=class extends F{create(t,n,r){return this._client.post(S`/threads/${t}/messages`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n,r){let{thread_id:i}=n;return this._client.get(S`/threads/${i}/messages/${t}`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}update(t,n,r){let{thread_id:i,...s}=n;return this._client.post(S`/threads/${i}/messages/${t}`,{body:s,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/threads/${t}/messages`,Ge,{query:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,n,r){let{thread_id:i}=n;return this._client.delete(S`/threads/${i}/messages/${t}`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}},jp=class extends F{retrieve(t,n,r){let{thread_id:i,run_id:s,...a}=n;return this._client.get(S`/threads/${i}/runs/${s}/steps/${t}`,{query:a,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}list(t,n,r){let{thread_id:i,...s}=n;return this._client.getAPIList(S`/threads/${i}/runs/${t}/steps`,Ge,{query:s,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}},DV=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),n=t.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=t.charCodeAt(i);return Array.from(new Float32Array(r.buffer))}},si=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()||void 0},Ct,is,s_,hr,sd,Wn,ss,da,Qi,Rp,gn,ad,od,Wo,Zo,Bo,x$,$$,I$,S$,O$,A$,T$,hs=class extends Nc{constructor(){super(...arguments),Ct.add(this),s_.set(this,[]),hr.set(this,{}),sd.set(this,{}),Wn.set(this,void 0),ss.set(this,void 0),da.set(this,void 0),Qi.set(this,void 0),Rp.set(this,void 0),gn.set(this,void 0),ad.set(this,void 0),od.set(this,void 0),Wo.set(this,void 0)}[(s_=new WeakMap,hr=new WeakMap,sd=new WeakMap,Wn=new WeakMap,ss=new WeakMap,da=new WeakMap,Qi=new WeakMap,Rp=new WeakMap,gn=new WeakMap,ad=new WeakMap,od=new WeakMap,Wo=new WeakMap,Ct=new WeakSet,Symbol.asyncIterator)](){let t=[],n=[],r=!1;return this.on("event",i=>{let s=n.shift();s?s.resolve(i):t.push(i)}),this.on("end",()=>{r=!0;for(let i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((i,s)=>n.push({resolve:i,reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(t){let n=new is;return n._run(()=>n._fromReadableStream(t)),n}async _fromReadableStream(t,n){let r=n?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),this._connected();let i=Is.fromReadableStream(t,this.controller);for await(let s of i)A(this,Ct,"m",Zo).call(this,s);if(i.controller.signal?.aborted)throw new Wt;return this._addRun(A(this,Ct,"m",Bo).call(this))}toReadableStream(){return new Is(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(t,n,r,i){let s=new is;return s._run(()=>s._runToolAssistantStream(t,n,r,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),s}async _createToolAssistantStream(t,n,r,i){let s=i?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort()));let a={...r,stream:!0},o=await t.submitToolOutputs(n,a,{...i,signal:this.controller.signal});this._connected();for await(let c of o)A(this,Ct,"m",Zo).call(this,c);if(o.controller.signal?.aborted)throw new Wt;return this._addRun(A(this,Ct,"m",Bo).call(this))}static createThreadAssistantStream(t,n,r){let i=new is;return i._run(()=>i._threadAssistantStream(t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}static createAssistantStream(t,n,r,i){let s=new is;return s._run(()=>s._runAssistantStream(t,n,r,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),s}currentEvent(){return A(this,ad,"f")}currentRun(){return A(this,od,"f")}currentMessageSnapshot(){return A(this,Wn,"f")}currentRunStepSnapshot(){return A(this,Wo,"f")}async finalRunSteps(){return await this.done(),Object.values(A(this,hr,"f"))}async finalMessages(){return await this.done(),Object.values(A(this,sd,"f"))}async finalRun(){if(await this.done(),!A(this,ss,"f"))throw Error("Final run was not received.");return A(this,ss,"f")}async _createThreadAssistantStream(t,n,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let s={...n,stream:!0},a=await t.createAndRun(s,{...r,signal:this.controller.signal});this._connected();for await(let o of a)A(this,Ct,"m",Zo).call(this,o);if(a.controller.signal?.aborted)throw new Wt;return this._addRun(A(this,Ct,"m",Bo).call(this))}async _createAssistantStream(t,n,r,i){let s=i?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort()));let a={...r,stream:!0},o=await t.create(n,a,{...i,signal:this.controller.signal});this._connected();for await(let c of o)A(this,Ct,"m",Zo).call(this,c);if(o.controller.signal?.aborted)throw new Wt;return this._addRun(A(this,Ct,"m",Bo).call(this))}static accumulateDelta(t,n){for(let[r,i]of Object.entries(n)){if(!t.hasOwnProperty(r)){t[r]=i;continue}let s=t[r];if(s==null){t[r]=i;continue}if(r==="index"||r==="type"){t[r]=i;continue}if(typeof s=="string"&&typeof i=="string")s+=i;else if(typeof s=="number"&&typeof i=="number")s+=i;else if(Lf(s)&&Lf(i))s=this.accumulateDelta(s,i);else if(Array.isArray(s)&&Array.isArray(i)){if(s.every(a=>typeof a=="string"||typeof a=="number")){s.push(...i);continue}for(let a of i){if(!Lf(a))throw new Error(`Expected array delta entry to be an object but got: ${a}`);let o=a.index;if(o==null)throw console.error(a),new Error("Expected array delta entry to have an `index` property");if(typeof o!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${o}`);let c=s[o];c==null?s.push(a):s[o]=this.accumulateDelta(c,a)}continue}else throw Error(`Unhandled record type: ${r}, deltaValue: ${i}, accValue: ${s}`);t[r]=s}return t}_addRun(t){return t}async _threadAssistantStream(t,n,r){return await this._createThreadAssistantStream(n,t,r)}async _runAssistantStream(t,n,r,i){return await this._createAssistantStream(n,t,r,i)}async _runToolAssistantStream(t,n,r,i){return await this._createToolAssistantStream(n,t,r,i)}};is=hs,Zo=function(e){if(!this.ended)switch(de(this,ad,e),A(this,Ct,"m",I$).call(this,e),e.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":A(this,Ct,"m",T$).call(this,e);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":A(this,Ct,"m",$$).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":A(this,Ct,"m",x$).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},Bo=function(){if(this.ended)throw new se("stream has ended, this shouldn't happen");if(!A(this,ss,"f"))throw Error("Final run has not been received");return A(this,ss,"f")},x$=function(e){let[t,n]=A(this,Ct,"m",O$).call(this,e,A(this,Wn,"f"));de(this,Wn,t),A(this,sd,"f")[t.id]=t;for(let r of n){let i=t.content[r.index];i?.type=="text"&&this._emit("textCreated",i.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let r of e.data.delta.content){if(r.type=="text"&&r.text){let i=r.text,s=t.content[r.index];if(s&&s.type=="text")this._emit("textDelta",i,s.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(r.index!=A(this,da,"f")){if(A(this,Qi,"f"))switch(A(this,Qi,"f").type){case"text":this._emit("textDone",A(this,Qi,"f").text,A(this,Wn,"f"));break;case"image_file":this._emit("imageFileDone",A(this,Qi,"f").image_file,A(this,Wn,"f"));break}de(this,da,r.index)}de(this,Qi,t.content[r.index])}break;case"thread.message.completed":case"thread.message.incomplete":if(A(this,da,"f")!==void 0){let r=e.data.content[A(this,da,"f")];if(r)switch(r.type){case"image_file":this._emit("imageFileDone",r.image_file,A(this,Wn,"f"));break;case"text":this._emit("textDone",r.text,A(this,Wn,"f"));break}}A(this,Wn,"f")&&this._emit("messageDone",e.data),de(this,Wn,void 0)}},$$=function(e){let t=A(this,Ct,"m",S$).call(this,e);switch(de(this,Wo,t),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let n=e.data.delta;if(n.step_details&&n.step_details.type=="tool_calls"&&n.step_details.tool_calls&&t.step_details.type=="tool_calls")for(let r of n.step_details.tool_calls)r.index==A(this,Rp,"f")?this._emit("toolCallDelta",r,t.step_details.tool_calls[r.index]):(A(this,gn,"f")&&this._emit("toolCallDone",A(this,gn,"f")),de(this,Rp,r.index),de(this,gn,t.step_details.tool_calls[r.index]),A(this,gn,"f")&&this._emit("toolCallCreated",A(this,gn,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":de(this,Wo,void 0),e.data.step_details.type=="tool_calls"&&A(this,gn,"f")&&(this._emit("toolCallDone",A(this,gn,"f")),de(this,gn,void 0)),this._emit("runStepDone",e.data,t);break}},I$=function(e){A(this,s_,"f").push(e),this._emit("event",e)},S$=function(e){switch(e.event){case"thread.run.step.created":return A(this,hr,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=A(this,hr,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let n=e.data;if(n.delta){let r=is.accumulateDelta(t,n.delta);A(this,hr,"f")[e.data.id]=r}return A(this,hr,"f")[e.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":A(this,hr,"f")[e.data.id]=e.data;break}if(A(this,hr,"f")[e.data.id])return A(this,hr,"f")[e.data.id];throw new Error("No snapshot available")},O$=function(e,t){let n=[];switch(e.event){case"thread.message.created":return[e.data,n];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let r=e.data;if(r.delta.content)for(let i of r.delta.content)if(i.index in t.content){let s=t.content[i.index];t.content[i.index]=A(this,Ct,"m",A$).call(this,i,s)}else t.content[i.index]=i,n.push(i);return[t,n];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,n];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},A$=function(e,t){return is.accumulateDelta(t,e)},T$=function(e){switch(de(this,od,e.data),e.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":de(this,ss,e.data),A(this,gn,"f")&&(this._emit("toolCallDone",A(this,gn,"f")),de(this,gn,void 0));break}};var M0=class extends F{constructor(){super(...arguments),this.steps=new jp(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(S`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(S`/threads/${r}/runs/${e}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(S`/threads/${r}/runs/${e}`,{body:i,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/threads/${e}/runs`,Ge,{query:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(S`/threads/${r}/runs/${e}/cancel`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(r.id,{thread_id:e},n)}createAndStream(e,t,n){return hs.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=V([n?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:s}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...r}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(n?.pollIntervalMs)a=n.pollIntervalMs;else{let o=s.headers.get("openai-poll-after-ms");if(o){let c=parseInt(o);isNaN(c)||(a=c)}}await Mu(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,n){return hs.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(S`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async submitToolOutputsAndPoll(e,t,n){let r=await this.submitToolOutputs(e,t,n);return await this.poll(r.id,t,n)}submitToolOutputsStream(e,t,n){return hs.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}};M0.Steps=jp;var Wa=class extends F{constructor(){super(...arguments),this.runs=new M0(this._client),this.messages=new Pp(this._client)}create(t={},n){return this._client.post("/threads",{body:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/threads/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/threads/${t}`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/threads/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}createAndRun(t,n){return this._client.post("/threads/runs",{body:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async createAndRunPoll(t,n){let r=await this.createAndRun(t,n);return await this.runs.poll(r.id,{thread_id:r.thread_id},n)}createAndRunStream(t,n){return hs.createThreadAssistantStream(t,this._client.beta.threads,n)}};Wa.Runs=M0;Wa.Messages=Pp;var ji=class extends F{constructor(){super(...arguments),this.realtime=new Om(this._client),this.chatkit=new Ka(this._client),this.assistants=new Ep(this._client),this.threads=new Wa(this._client)}};ji.Realtime=Om;ji.ChatKit=Ka;ji.Assistants=Ep;ji.Threads=Wa;var Mp=class extends F{create(t,n){return this._client.post("/completions",{body:t,...n,stream:t.stream??!1,__security:{bearerAuth:!0}})}},Bj=class extends F{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(S`/containers/${r}/files/${e}/content`,{...n,headers:V([{Accept:"application/binary"},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},U0=class extends F{constructor(){super(...arguments),this.content=new Bj(this._client)}create(e,t,n){return this._client.post(S`/containers/${e}/files`,Im({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(S`/containers/${r}/files/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(S`/containers/${e}/files`,Ge,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(S`/containers/${r}/files/${e}`,{...n,headers:V([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}};U0.Content=Bj;var Uc=class extends F{constructor(){super(...arguments),this.files=new U0(this._client)}create(t,n){return this._client.post("/containers",{body:t,...n,__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/containers/${t}`,{...n,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/containers",Ge,{query:t,...n,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/containers/${t}`,{...n,headers:V([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}};Uc.Files=U0;var Up=class extends F{create(t,n,r){let{include:i,...s}=n;return this._client.post(S`/conversations/${t}/items`,{query:{include:i},body:s,...r,__security:{bearerAuth:!0}})}retrieve(t,n,r){let{conversation_id:i,...s}=n;return this._client.get(S`/conversations/${i}/items/${t}`,{query:s,...r,__security:{bearerAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/conversations/${t}/items`,Mt,{query:n,...r,__security:{bearerAuth:!0}})}delete(t,n,r){let{conversation_id:i}=n;return this._client.delete(S`/conversations/${i}/items/${t}`,{...r,__security:{bearerAuth:!0}})}},Lc=class extends F{constructor(){super(...arguments),this.items=new Up(this._client)}create(t={},n){return this._client.post("/conversations",{body:t,...n,__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/conversations/${t}`,{...n,__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/conversations/${t}`,{body:n,...r,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/conversations/${t}`,{...n,__security:{bearerAuth:!0}})}};Lc.Items=Up;var Lp=class extends F{create(t,n){let r=!!t.encoding_format,i=r?t.encoding_format:"base64";r&&Et(this._client).debug("embeddings/user defined encoding_format:",t.encoding_format);let s=this._client.post("/embeddings",{body:{...t,encoding_format:i},...n,__security:{bearerAuth:!0}});return r?s:(Et(this._client).debug("embeddings/decoding base64 embeddings from base64"),s._thenUnwrap(a=>(a&&a.data&&a.data.forEach(o=>{let c=o.embedding;o.embedding=DV(c)}),a)))}},zp=class extends F{retrieve(t,n,r){let{eval_id:i,run_id:s}=n;return this._client.get(S`/evals/${i}/runs/${s}/output_items/${t}`,{...r,__security:{bearerAuth:!0}})}list(t,n,r){let{eval_id:i,...s}=n;return this._client.getAPIList(S`/evals/${i}/runs/${t}/output_items`,Ge,{query:s,...r,__security:{bearerAuth:!0}})}},zc=class extends F{constructor(){super(...arguments),this.outputItems=new zp(this._client)}create(t,n,r){return this._client.post(S`/evals/${t}/runs`,{body:n,...r,__security:{bearerAuth:!0}})}retrieve(t,n,r){let{eval_id:i}=n;return this._client.get(S`/evals/${i}/runs/${t}`,{...r,__security:{bearerAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/evals/${t}/runs`,Ge,{query:n,...r,__security:{bearerAuth:!0}})}delete(t,n,r){let{eval_id:i}=n;return this._client.delete(S`/evals/${i}/runs/${t}`,{...r,__security:{bearerAuth:!0}})}cancel(t,n,r){let{eval_id:i}=n;return this._client.post(S`/evals/${i}/runs/${t}`,{...r,__security:{bearerAuth:!0}})}};zc.OutputItems=zp;var Dc=class extends F{constructor(){super(...arguments),this.runs=new zc(this._client)}create(t,n){return this._client.post("/evals",{body:t,...n,__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/evals/${t}`,{...n,__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/evals/${t}`,{body:n,...r,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/evals",Ge,{query:t,...n,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/evals/${t}`,{...n,__security:{bearerAuth:!0}})}};Dc.Runs=zc;var qj=class extends F{create(e,t){return this._client.post("/files",vr({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(S`/files/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList("/files",Ge,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(S`/files/${e}`,{...t,__security:{bearerAuth:!0}})}content(e,t){return this._client.get(S`/files/${e}/content`,{...t,headers:V([{Accept:"application/binary"},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=1800*1e3}={}){let r=new Set(["processed","error","deleted"]),i=Date.now(),s=await this.retrieve(e);for(;!s.status||!r.has(s.status);)if(await Mu(t),s=await this.retrieve(e),Date.now()-i>n)throw new Ja({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return s}},Dp=class extends F{},Jj=class extends F{run(e,t){return this._client.post("/fine_tuning/alpha/graders/run",{body:e,...t,__security:{bearerAuth:!0}})}validate(e,t){return this._client.post("/fine_tuning/alpha/graders/validate",{body:e,...t,__security:{bearerAuth:!0}})}},Fc=class extends F{constructor(){super(...arguments),this.graders=new Jj(this._client)}};Fc.Graders=Jj;var Fp=class extends F{create(t,n,r){return this._client.getAPIList(S`/fine_tuning/checkpoints/${t}/permissions`,Or,{body:n,method:"post",...r,__security:{adminAPIKeyAuth:!0}})}retrieve(t,n={},r){return this._client.get(S`/fine_tuning/checkpoints/${t}/permissions`,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/fine_tuning/checkpoints/${t}/permissions`,Mt,{query:n,...r,__security:{adminAPIKeyAuth:!0}})}delete(t,n,r){let{fine_tuned_model_checkpoint:i}=n;return this._client.delete(S`/fine_tuning/checkpoints/${i}/permissions/${t}`,{...r,__security:{adminAPIKeyAuth:!0}})}},L0=class extends F{constructor(){super(...arguments),this.permissions=new Fp(this._client)}};L0.Permissions=Fp;var Zp=class extends F{list(t,n={},r){return this._client.getAPIList(S`/fine_tuning/jobs/${t}/checkpoints`,Ge,{query:n,...r,__security:{bearerAuth:!0}})}},Zc=class extends F{constructor(){super(...arguments),this.checkpoints=new Zp(this._client)}create(t,n){return this._client.post("/fine_tuning/jobs",{body:t,...n,__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/fine_tuning/jobs/${t}`,{...n,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/fine_tuning/jobs",Ge,{query:t,...n,__security:{bearerAuth:!0}})}cancel(t,n){return this._client.post(S`/fine_tuning/jobs/${t}/cancel`,{...n,__security:{bearerAuth:!0}})}listEvents(t,n={},r){return this._client.getAPIList(S`/fine_tuning/jobs/${t}/events`,Ge,{query:n,...r,__security:{bearerAuth:!0}})}pause(t,n){return this._client.post(S`/fine_tuning/jobs/${t}/pause`,{...n,__security:{bearerAuth:!0}})}resume(t,n){return this._client.post(S`/fine_tuning/jobs/${t}/resume`,{...n,__security:{bearerAuth:!0}})}};Zc.Checkpoints=Zp;var Ri=class extends F{constructor(){super(...arguments),this.methods=new Dp(this._client),this.jobs=new Zc(this._client),this.checkpoints=new L0(this._client),this.alpha=new Fc(this._client)}};Ri.Methods=Dp;Ri.Jobs=Zc;Ri.Checkpoints=L0;Ri.Alpha=Fc;var Bp=class extends F{},Bc=class extends F{constructor(){super(...arguments),this.graderModels=new Bp(this._client)}};Bc.GraderModels=Bp;var qp=class extends F{createVariation(t,n){return this._client.post("/images/variations",vr({body:t,...n,__security:{bearerAuth:!0}},this._client))}edit(t,n){return this._client.post("/images/edits",vr({body:t,...n,stream:t.stream??!1,__security:{bearerAuth:!0}},this._client))}generate(t,n){return this._client.post("/images/generations",{body:t,...n,stream:t.stream??!1,__security:{bearerAuth:!0}})}},Jp=class extends F{retrieve(t,n){return this._client.get(S`/models/${t}`,{...n,__security:{bearerAuth:!0}})}list(t){return this._client.getAPIList("/models",Or,{...t,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/models/${t}`,{...n,__security:{bearerAuth:!0}})}},Hp=class extends F{create(t,n){return this._client.post("/moderations",{body:t,...n,__security:{bearerAuth:!0}})}},Vp=class extends F{accept(t,n,r){return this._client.post(S`/realtime/calls/${t}/accept`,{body:n,...r,headers:V([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}hangup(t,n){return this._client.post(S`/realtime/calls/${t}/hangup`,{...n,headers:V([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}refer(t,n,r){return this._client.post(S`/realtime/calls/${t}/refer`,{body:n,...r,headers:V([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}reject(t,n={},r){return this._client.post(S`/realtime/calls/${t}/reject`,{body:n,...r,headers:V([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}},Kp=class extends F{create(t,n){return this._client.post("/realtime/client_secrets",{body:t,...n,__security:{bearerAuth:!0}})}},Ga=class extends F{constructor(){super(...arguments),this.clientSecrets=new Kp(this._client),this.calls=new Vp(this._client)}};Ga.ClientSecrets=Kp;Ga.Calls=Vp;function FV(e,t){return!t||!BV(t)?{...e,output_parsed:null,output:e.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:n.type==="message"?{...n,content:n.content.map(r=>({...r,parsed:null}))}:n)}:Hj(e,t)}function Hj(e,t){let n=e.output.map(i=>{if(i.type==="function_call")return{...i,parsed_arguments:HV(t,i)};if(i.type==="message"){let s=i.content.map(a=>a.type==="output_text"?{...a,parsed:ZV(t,a.text)}:a);return{...i,content:s}}return i}),r=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||a_(r),Object.defineProperty(r,"output_parsed",{enumerable:!0,get(){for(let i of r.output)if(i.type==="message"){for(let s of i.content)if(s.type==="output_text"&&s.parsed!==null)return s.parsed}return null}}),r}function ZV(e,t){return e.text?.format?.type!=="json_schema"?null:"$parseRaw"in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t)}function BV(e){return!!N0(e.text?.format)}function qV(e){return e?.$brand==="auto-parseable-tool"}function JV(e,t){return e.find(n=>n.type==="function"&&n.name===t)}function HV(e,t){let n=JV(e.tools??[],t.name);return{...t,...t,parsed_arguments:qV(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function a_(e){let t=[];for(let n of e.output)if(n.type==="message")for(let r of n.content)r.type==="output_text"&&t.push(r.text);e.output_text=t.join("")}var Ks,Al,ai,Tl,E$,C$,N$,P$,o_=class e extends Nc{constructor(t){super(),Ks.add(this),Al.set(this,void 0),ai.set(this,void 0),Tl.set(this,void 0),de(this,Al,t)}static createResponse(t,n,r){let i=new e(n);return i._run(()=>i._createOrRetrieveResponse(t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createOrRetrieveResponse(t,n,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort())),A(this,Ks,"m",E$).call(this);let s,a=null;"response_id"in n?(s=await t.responses.retrieve(n.response_id,{stream:!0},{...r,signal:this.controller.signal,stream:!0}),a=n.starting_after??null):s=await t.responses.create({...n,stream:!0},{...r,signal:this.controller.signal}),this._connected();for await(let o of s)A(this,Ks,"m",C$).call(this,o,a);if(s.controller.signal?.aborted)throw new Wt;return A(this,Ks,"m",N$).call(this)}[(Al=new WeakMap,ai=new WeakMap,Tl=new WeakMap,Ks=new WeakSet,E$=function(){this.ended||de(this,ai,void 0)},C$=function(t,n){if(this.ended)return;let r=(s,a)=>{(n==null||a.sequence_number>n)&&this._emit(s,a)},i=A(this,Ks,"m",P$).call(this,t);switch(r("event",t),t.type){case"response.output_text.delta":{let s=i.output[t.output_index];if(!s)throw new se(`missing output at index ${t.output_index}`);if(s.type==="message"){let a=s.content[t.content_index];if(!a)throw new se(`missing content at index ${t.content_index}`);if(a.type!=="output_text")throw new se(`expected content to be 'output_text', got ${a.type}`);r("response.output_text.delta",{...t,snapshot:a.text})}break}case"response.function_call_arguments.delta":{let s=i.output[t.output_index];if(!s)throw new se(`missing output at index ${t.output_index}`);s.type==="function_call"&&r("response.function_call_arguments.delta",{...t,snapshot:s.arguments});break}default:r(t.type,t);break}},N$=function(){if(this.ended)throw new se("stream has ended, this shouldn't happen");let t=A(this,ai,"f");if(!t)throw new se("request ended without sending any events");de(this,ai,void 0);let n=VV(t,A(this,Al,"f"));return de(this,Tl,n),n},P$=function(t){let n=A(this,ai,"f");if(!n){if(t.type!=="response.created")throw new se(`When snapshot hasn't been set yet, expected 'response.created' event, got ${t.type}`);return n=de(this,ai,t.response),n}switch(t.type){case"response.output_item.added":{n.output.push(t.item);break}case"response.content_part.added":{let r=n.output[t.output_index];if(!r)throw new se(`missing output at index ${t.output_index}`);let i=r.type,s=t.part;i==="message"&&s.type!=="reasoning_text"?r.content.push(s):i==="reasoning"&&s.type==="reasoning_text"&&(r.content||(r.content=[]),r.content.push(s));break}case"response.output_text.delta":{let r=n.output[t.output_index];if(!r)throw new se(`missing output at index ${t.output_index}`);if(r.type==="message"){let i=r.content[t.content_index];if(!i)throw new se(`missing content at index ${t.content_index}`);if(i.type!=="output_text")throw new se(`expected content to be 'output_text', got ${i.type}`);i.text+=t.delta}break}case"response.function_call_arguments.delta":{let r=n.output[t.output_index];if(!r)throw new se(`missing output at index ${t.output_index}`);r.type==="function_call"&&(r.arguments+=t.delta);break}case"response.reasoning_text.delta":{let r=n.output[t.output_index];if(!r)throw new se(`missing output at index ${t.output_index}`);if(r.type==="reasoning"){let i=r.content?.[t.content_index];if(!i)throw new se(`missing content at index ${t.content_index}`);if(i.type!=="reasoning_text")throw new se(`expected content to be 'reasoning_text', got ${i.type}`);i.text+=t.delta}break}case"response.completed":{de(this,ai,t.response);break}}return n},Symbol.asyncIterator)](){let t=[],n=[],r=!1;return this.on("event",i=>{let s=n.shift();s?s.resolve(i):t.push(i)}),this.on("end",()=>{r=!0;for(let i of n)i.resolve(void 0);n.length=0}),this.on("abort",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),this.on("error",i=>{r=!0;for(let s of n)s.reject(i);n.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((i,s)=>n.push({resolve:i,reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let t=A(this,Tl,"f");if(!t)throw new se("stream ended without producing a ChatCompletion");return t}};function VV(e,t){return FV(e,t)}var Wp=class extends F{list(t,n={},r){return this._client.getAPIList(S`/responses/${t}/input_items`,Ge,{query:n,...r,__security:{bearerAuth:!0}})}},Gp=class extends F{count(t={},n){return this._client.post("/responses/input_tokens",{body:t,...n,__security:{bearerAuth:!0}})}},Xa=class extends F{constructor(){super(...arguments),this.inputItems=new Wp(this._client),this.inputTokens=new Gp(this._client)}create(t,n){return this._client.post("/responses",{body:t,...n,stream:t.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(r=>("object"in r&&r.object==="response"&&a_(r),r))}retrieve(t,n={},r){return this._client.get(S`/responses/${t}`,{query:n,...r,stream:n?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(i=>("object"in i&&i.object==="response"&&a_(i),i))}delete(t,n){return this._client.delete(S`/responses/${t}`,{...n,headers:V([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}parse(t,n){return this._client.responses.create(t,n)._thenUnwrap(r=>Hj(r,t))}stream(t,n){return o_.createResponse(this._client,t,n)}cancel(t,n){return this._client.post(S`/responses/${t}/cancel`,{...n,__security:{bearerAuth:!0}})}compact(t,n){return this._client.post("/responses/compact",{body:t,...n,__security:{bearerAuth:!0}})}};Xa.InputItems=Wp;Xa.InputTokens=Gp;var Vj=class extends F{retrieve(e,t){return this._client.get(S`/skills/${e}/content`,{...t,headers:V([{Accept:"application/binary"},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},Xp=class extends F{retrieve(t,n,r){let{skill_id:i}=n;return this._client.get(S`/skills/${i}/versions/${t}/content`,{...r,headers:V([{Accept:"application/binary"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}},qc=class extends F{constructor(){super(...arguments),this.content=new Xp(this._client)}create(t,n={},r){return this._client.post(S`/skills/${t}/versions`,Im({body:n,...r,__security:{bearerAuth:!0}},this._client))}retrieve(t,n,r){let{skill_id:i}=n;return this._client.get(S`/skills/${i}/versions/${t}`,{...r,__security:{bearerAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/skills/${t}/versions`,Ge,{query:n,...r,__security:{bearerAuth:!0}})}delete(t,n,r){let{skill_id:i}=n;return this._client.delete(S`/skills/${i}/versions/${t}`,{...r,__security:{bearerAuth:!0}})}};qc.Content=Xp;var Ya=class extends F{constructor(){super(...arguments),this.content=new Vj(this._client),this.versions=new qc(this._client)}create(t={},n){return this._client.post("/skills",Im({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(t,n){return this._client.get(S`/skills/${t}`,{...n,__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/skills/${t}`,{body:n,...r,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/skills",Ge,{query:t,...n,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/skills/${t}`,{...n,__security:{bearerAuth:!0}})}};Ya.Content=Vj;Ya.Versions=qc;var Yp=class extends F{create(t,n,r){return this._client.post(S`/uploads/${t}/parts`,vr({body:n,...r,__security:{bearerAuth:!0}},this._client))}},Jc=class extends F{constructor(){super(...arguments),this.parts=new Yp(this._client)}create(t,n){return this._client.post("/uploads",{body:t,...n,__security:{bearerAuth:!0}})}cancel(t,n){return this._client.post(S`/uploads/${t}/cancel`,{...n,__security:{bearerAuth:!0}})}complete(t,n,r){return this._client.post(S`/uploads/${t}/complete`,{body:n,...r,__security:{bearerAuth:!0}})}};Jc.Parts=Yp;var KV=async e=>{let t=await Promise.allSettled(e),n=t.filter(i=>i.status==="rejected");if(n.length){for(let i of n)console.error(i.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}let r=[];for(let i of t)i.status==="fulfilled"&&r.push(i.value);return r},Qp=class extends F{create(t,n,r){return this._client.post(S`/vector_stores/${t}/file_batches`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n,r){let{vector_store_id:i}=n;return this._client.get(S`/vector_stores/${i}/file_batches/${t}`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}cancel(t,n,r){let{vector_store_id:i}=n;return this._client.post(S`/vector_stores/${i}/file_batches/${t}/cancel`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(t,n,r){let i=await this.create(t,n);return await this.poll(t,i.id,r)}listFiles(t,n,r){let{vector_store_id:i,...s}=n;return this._client.getAPIList(S`/vector_stores/${i}/file_batches/${t}/files`,Ge,{query:s,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}async poll(t,n,r){let i=V([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:s,response:a}=await this.retrieve(n,{vector_store_id:t},{...r,headers:i}).withResponse();switch(s.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let c=a.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(o=u)}}await Mu(o);break;case"failed":case"cancelled":case"completed":return s}}}async uploadAndPoll(t,{files:n,fileIds:r=[]},i){if(n==null||n.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let s=i?.maxConcurrency??5,a=Math.min(s,n.length),o=this._client,c=n.values(),u=[...r];async function l(p){for(let h of p){let m=await o.files.create({file:h,purpose:"assistants"},i);u.push(m.id)}}let d=Array(a).fill(c).map(l);return await KV(d),await this.createAndPoll(t,{file_ids:u})}},eh=class extends F{create(t,n,r){return this._client.post(S`/vector_stores/${t}/files`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n,r){let{vector_store_id:i}=n;return this._client.get(S`/vector_stores/${i}/files/${t}`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}update(t,n,r){let{vector_store_id:i,...s}=n;return this._client.post(S`/vector_stores/${i}/files/${t}`,{body:s,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}list(t,n={},r){return this._client.getAPIList(S`/vector_stores/${t}/files`,Ge,{query:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}delete(t,n,r){let{vector_store_id:i}=n;return this._client.delete(S`/vector_stores/${i}/files/${t}`,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}async createAndPoll(t,n,r){let i=await this.create(t,n,r);return await this.poll(t,i.id,r)}async poll(t,n,r){let i=V([r?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":r?.pollIntervalMs?.toString()??void 0}]);for(;;){let s=await this.retrieve(n,{vector_store_id:t},{...r,headers:i}).withResponse(),a=s.data;switch(a.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let c=s.response.headers.get("openai-poll-after-ms");if(c){let u=parseInt(c);isNaN(u)||(o=u)}}await Mu(o);break;case"failed":case"completed":return a}}}async upload(t,n,r){let i=await this._client.files.create({file:n,purpose:"assistants"},r);return this.create(t,{file_id:i.id},r)}async uploadAndPoll(t,n,r){let i=await this.upload(t,n,r);return await this.poll(t,i.id,r)}content(t,n,r){let{vector_store_id:i}=n;return this._client.getAPIList(S`/vector_stores/${i}/files/${t}/content`,Or,{...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}},Qa=class extends F{constructor(){super(...arguments),this.files=new eh(this._client),this.fileBatches=new Qp(this._client)}create(t,n){return this._client.post("/vector_stores",{body:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}retrieve(t,n){return this._client.get(S`/vector_stores/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}update(t,n,r){return this._client.post(S`/vector_stores/${t}`,{body:n,...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/vector_stores",Ge,{query:t,...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/vector_stores/${t}`,{...n,headers:V([{"OpenAI-Beta":"assistants=v2"},n?.headers]),__security:{bearerAuth:!0}})}search(t,n,r){return this._client.getAPIList(S`/vector_stores/${t}/search`,Or,{body:n,method:"post",...r,headers:V([{"OpenAI-Beta":"assistants=v2"},r?.headers]),__security:{bearerAuth:!0}})}};Qa.Files=eh;Qa.FileBatches=Qp;var th=class extends F{create(t,n){return this._client.post("/videos",vr({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(t,n){return this._client.get(S`/videos/${t}`,{...n,__security:{bearerAuth:!0}})}list(t={},n){return this._client.getAPIList("/videos",Mt,{query:t,...n,__security:{bearerAuth:!0}})}delete(t,n){return this._client.delete(S`/videos/${t}`,{...n,__security:{bearerAuth:!0}})}createCharacter(t,n){return this._client.post("/videos/characters",vr({body:t,...n,__security:{bearerAuth:!0}},this._client))}downloadContent(t,n={},r){return this._client.get(S`/videos/${t}/content`,{query:n,...r,headers:V([{Accept:"application/binary"},r?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit(t,n){return this._client.post("/videos/edits",vr({body:t,...n,__security:{bearerAuth:!0}},this._client))}extend(t,n){return this._client.post("/videos/extensions",vr({body:t,...n,__security:{bearerAuth:!0}},this._client))}getCharacter(t,n){return this._client.get(S`/videos/characters/${t}`,{...n,__security:{bearerAuth:!0}})}remix(t,n,r){return this._client.post(S`/videos/${t}/remix`,Im({body:n,...r,__security:{bearerAuth:!0}},this._client))}},ta,Kj,cd,nh=class extends F{constructor(){super(...arguments),ta.add(this)}async unwrap(t,n,r=this._client.webhookSecret,i=300){return await this.verifySignature(t,n,r,i),JSON.parse(t)}async verifySignature(t,n,r=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");A(this,ta,"m",Kj).call(this,r);let s=V([n]).values,a=A(this,ta,"m",cd).call(this,s,"webhook-signature"),o=A(this,ta,"m",cd).call(this,s,"webhook-timestamp"),c=A(this,ta,"m",cd).call(this,s,"webhook-id"),u=parseInt(o,10);if(isNaN(u))throw new rs("Invalid webhook timestamp format");let l=Math.floor(Date.now()/1e3);if(l-u>i)throw new rs("Webhook timestamp is too old");if(u>l+i)throw new rs("Webhook timestamp is too new");let d=a.split(" ").map(f=>f.startsWith("v1,")?f.substring(3):f),p=r.startsWith("whsec_")?Buffer.from(r.replace("whsec_",""),"base64"):Buffer.from(r,"utf-8"),h=c?`${c}.${o}.${t}`:`${o}.${t}`,m=await crypto.subtle.importKey("raw",p,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let f of d)try{let v=Buffer.from(f,"base64");if(await crypto.subtle.verify("HMAC",m,v,new TextEncoder().encode(h)))return}catch{continue}throw new rs("The given webhook signature does not match the expected signature")}};ta=new WeakSet,Kj=function(e){if(typeof e!="string"||e.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")},cd=function(e,t){if(!e)throw new Error("Headers are required");let n=e.get(t);if(n==null)throw new Error(`Missing required header: ${t}`);return n};var c_,z0,ud,Wj,WV="workload-identity-auth",fe=class{constructor({baseURL:t=si("OPENAI_BASE_URL"),apiKey:n=si("OPENAI_API_KEY")??null,adminAPIKey:r=si("OPENAI_ADMIN_KEY")??null,organization:i=si("OPENAI_ORG_ID")??null,project:s=si("OPENAI_PROJECT_ID")??null,webhookSecret:a=si("OPENAI_WEBHOOK_SECRET")??null,workloadIdentity:o,...c}={}){c_.add(this),ud.set(this,void 0),this.completions=new Mp(this),this.chat=new Pc(this),this.embeddings=new Lp(this),this.files=new qj(this),this.images=new qp(this),this.audio=new Ss(this),this.moderations=new Hp(this),this.models=new Jp(this),this.fineTuning=new Ri(this),this.graders=new Bc(this),this.vectorStores=new Qa(this),this.webhooks=new nh(this),this.beta=new ji(this),this.batches=new Tp(this),this.uploads=new Jc(this),this.admin=new Mc(this),this.responses=new Xa(this),this.realtime=new Ga(this),this.conversations=new Lc(this),this.evals=new Dc(this),this.containers=new Uc(this),this.skills=new Ya(this),this.videos=new th(this);let u={apiKey:n,adminAPIKey:r,organization:i,project:s,webhookSecret:a,workloadIdentity:o,...c,baseURL:t||"https://api.openai.com/v1"};if(n&&o)throw new se("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!n&&!r&&!o)throw new se("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!u.dangerouslyAllowBrowser&&YH())throw new se(`It looks like you're running in a browser-like environment.
|
|
388
|
+
|
|
389
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
390
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
391
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
392
|
+
|
|
393
|
+
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
394
|
+
|
|
395
|
+
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
396
|
+
`);this.baseURL=u.baseURL,this.timeout=u.timeout??z0.DEFAULT_TIMEOUT,this.logger=u.logger??console;let l="warn";this.logLevel=l,this.logLevel=y$(u.logLevel,"ClientOptions.logLevel",this)??y$(si("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=u.fetchOptions,this.maxRetries=u.maxRetries??2,this.fetch=u.fetch??XP(),de(this,ud,rV);let d=si("OPENAI_CUSTOM_HEADERS");if(d){let p={};for(let h of d.split(`
|
|
397
|
+
`)){let m=h.indexOf(":");m>=0&&(p[h.substring(0,m).trim()]=h.substring(m+1).trim())}u.defaultHeaders=V([p,u.defaultHeaders])}this._options=u,o&&(this._workloadIdentityAuth=new Hy(o,this.fetch)),this.apiKey=typeof n=="string"?n:null,this.adminAPIKey=r,this.organization=i,this.project=s,this.webhookSecret=a}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._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:n},r={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(t.get("authorization")||t.get("api-key"))&&!(n.has("authorization")||n.has("api-key"))&&!(this._workloadIdentityAuth&&r.bearerAuth))throw new Error('Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted')}async authHeaders(t,n={bearerAuth:!0,adminAPIKeyAuth:!0}){return V([n.bearerAuth?await this.bearerAuth(t):null,n.adminAPIKeyAuth?await this.adminAPIKeyAuth(t):null])}async bearerAuth(t){if(this._workloadIdentityAuth)return V([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return V([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(t){if(this.adminAPIKey!=null)return V([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(t){return lV(t)}getUserAgent(){return`${this.constructor.name}/JS ${Qs}`}defaultIdempotencyKey(){return`stainless-node-retry-${GP()}`}makeStatusError(t,n,r,i){return It.generate(t,n,r,i)}async _callApiKey(){let t=this._options.apiKey;if(typeof t!="function")return!1;let n;try{n=await t()}catch(r){throw r instanceof se?r:new se(`Failed to get token from 'apiKey' function: ${r.message}`,{cause:r})}if(typeof n!="string"||!n)throw new se(`Expected 'apiKey' function argument to return a string but it returned ${n}`);return this.apiKey=n,!0}buildURL(t,n,r){let i=!A(this,c_,"m",Wj).call(this)&&r||this.baseURL,s=KH(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),a=this.defaultQuery(),o=Object.fromEntries(s.searchParams);return(!a$(a)||!a$(o))&&(n={...o,...a,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(s.search=this.stringifyQuery(n)),s.toString()}async prepareOptions(t){(t.__security??{bearerAuth:!0}).bearerAuth&&await this._callApiKey()}async prepareRequest(t,{url:n,options:r}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,r){return this.request(Promise.resolve(r).then(i=>({method:t,path:n,...i})))}request(t,n=null){return new up(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,r){let i=await t,s=i.maxRetries??this.maxRetries;n==null&&(n=s),await this.prepareOptions(i);let{req:a,url:o,timeout:c}=await this.buildRequest(i,{retryCount:s-n});await this.prepareRequest(a,{url:o,options:i});let u="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),l=r===void 0?"":`, retryOf: ${r}`,d=Date.now();if(Et(this).debug(`[${u}] sending request`,Gi({retryOfRequestLogID:r,method:i.method,url:o,options:i,headers:a.headers})),i.signal?.aborted)throw new Wt;let p=i.__security??{bearerAuth:!0},h=new AbortController,m=await this.fetchWithAuth(o,a,c,h,p).catch(Fy),f=Date.now();if(m instanceof globalThis.Error){let y=`retrying, ${n} attempts remaining`;if(i.signal?.aborted)throw new Wt;let w=Dy(m)||/timed? ?out/i.test(String(m)+("cause"in m?String(m.cause):""));if(n)return Et(this).info(`[${u}] connection ${w?"timed out":"failed"} - ${y}`),Et(this).debug(`[${u}] connection ${w?"timed out":"failed"} (${y})`,Gi({retryOfRequestLogID:r,url:o,durationMs:f-d,message:m.message})),this.retryRequest(i,n,r??u);throw Et(this).info(`[${u}] connection ${w?"timed out":"failed"} - error; no more retries left`),Et(this).debug(`[${u}] connection ${w?"timed out":"failed"} (error; no more retries left)`,Gi({retryOfRequestLogID:r,url:o,durationMs:f-d,message:m.message})),m instanceof op||m instanceof Zy?m:w?new Ja:new qa({cause:m})}let v=[...m.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,w])=>", "+y+": "+JSON.stringify(w)).join(""),g=`[${u}${l}${v}] ${a.method} ${o} ${m.ok?"succeeded":"failed"} with status ${m.status} in ${f-d}ms`;if(!m.ok){if(m.status===401&&this._workloadIdentityAuth&&p.bearerAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await l$(m.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},n,r??u);let y=await this.shouldRetry(m);if(n&&y){let T=`retrying, ${n} attempts remaining`;return await l$(m.body),Et(this).info(`${g} - ${T}`),Et(this).debug(`[${u}] response error (${T})`,Gi({retryOfRequestLogID:r,url:m.url,status:m.status,headers:m.headers,durationMs:f-d})),this.retryRequest(i,n,r??u,m.headers)}let w=y?"error; no more retries left":"error; not retryable";Et(this).info(`${g} - ${w}`);let x=await m.text().catch(T=>Fy(T).message),O=XH(x),z=O?void 0:x;throw Et(this).debug(`[${u}] response error (${w})`,Gi({retryOfRequestLogID:r,url:m.url,status:m.status,headers:m.headers,message:z,durationMs:Date.now()-d})),this.makeStatusError(m.status,O,z,m.headers)}return Et(this).info(g),Et(this).debug(`[${u}] response start`,Gi({retryOfRequestLogID:r,url:m.url,status:m.status,headers:m.headers,durationMs:f-d})),{response:m,options:i,controller:h,requestLogID:u,retryOfRequestLogID:r,startTime:d}}getAPIList(t,n,r){return this.requestAPIList(n,r&&"then"in r?r.then(i=>({method:"get",path:t,...i})):{method:"get",path:t,...r})}requestAPIList(t,n){let r=this.makeRequest(n,null,void 0);return new Jy(this,r,t)}async fetchWithAuth(t,n,r,i,s={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&s.bearerAuth){let a=n.headers,o=a.get("Authorization");if(!o||o===`Bearer ${WV}`){let c=await this._workloadIdentityAuth.getToken();a.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(t,n,r,i)}async fetchWithTimeout(t,n,r,i){let{signal:s,method:a,...o}=n||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let u=setTimeout(c,r),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body=="object"&&o.body!==null&&Symbol.asyncIterator in o.body,d={signal:i.signal,...l?{duplex:"half"}:{},method:"GET",...o};a&&(d.method=a.toUpperCase());try{return await this.fetch.call(void 0,t,d)}finally{clearTimeout(u)}}async shouldRetry(t){let n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,r,i){let s,a=i?.get("retry-after-ms");if(a){let c=parseFloat(a);Number.isNaN(c)||(s=c)}let o=i?.get("retry-after");if(o&&!s){let c=parseFloat(o);Number.isNaN(c)?s=Date.parse(o)-Date.now():s=c*1e3}if(s===void 0){let c=t.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(n,c)}return await Mu(s),this.makeRequest(t,n-1,r)}calculateDefaultRetryTimeoutMillis(t,n){let r=n-t,i=Math.min(.5*Math.pow(2,r),8),s=1-Math.random()*.25;return i*s*1e3}async buildRequest(t,{retryCount:n=0}={}){let r={...t},{method:i,path:s,query:a,defaultBaseURL:o}=r,c=this.buildURL(s,a,o);"timeout"in r&&GH("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:u,body:l,isStreamingBody:d}=this.buildBody({options:r});d&&(t.__metadata={...t.__metadata,hasStreamingBody:!0});let p=await this.buildHeaders({options:t,method:i,bodyHeaders:u,retryCount:n});return{req:{method:i,headers:p,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:"half"},...l&&{body:l},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:r,retryCount:i}){let s={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=t.idempotencyKey);let a=V([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...nV(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(t,t.__security??{bearerAuth:!0}),this._options.defaultHeaders,r,t.headers]);return this.validateHeaders(a,t.__security??{bearerAuth:!0}),a.values}_makeAbort(t){return()=>t.abort()}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let r=V([n]),i=typeof globalThis.ReadableStream<"u"&&t instanceof globalThis.ReadableStream,s=!i&&(typeof t=="string"||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof globalThis.Blob<"u"&&t instanceof globalThis.Blob||t instanceof URLSearchParams||t instanceof FormData);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&r.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||i?{bodyHeaders:void 0,body:t,isStreamingBody:!s}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:QP(t),isStreamingBody:!0}:typeof t=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(t),isStreamingBody:!1}:{...A(this,ud,"f").call(this,{body:t,headers:r}),isStreamingBody:!1}}};z0=fe,ud=new WeakMap,c_=new WeakSet,Wj=function(){return this.baseURL!=="https://api.openai.com/v1"};fe.OpenAI=z0;fe.DEFAULT_TIMEOUT=6e5;fe.OpenAIError=se;fe.APIError=It;fe.APIConnectionError=qa;fe.APIConnectionTimeoutError=Ja;fe.APIUserAbortError=Wt;fe.NotFoundError=ep;fe.ConflictError=tp;fe.RateLimitError=rp;fe.BadRequestError=Xd;fe.AuthenticationError=Yd;fe.InternalServerError=ip;fe.PermissionDeniedError=Qd;fe.UnprocessableEntityError=np;fe.InvalidWebhookSignatureError=rs;fe.toFile=$V;fe.Completions=Mp;fe.Chat=Pc;fe.Embeddings=Lp;fe.Files=qj;fe.Images=qp;fe.Audio=Ss;fe.Moderations=Hp;fe.Models=Jp;fe.FineTuning=Ri;fe.Graders=Bc;fe.VectorStores=Qa;fe.Webhooks=nh;fe.Beta=ji;fe.Batches=Tp;fe.Uploads=Jc;fe.Admin=Mc;fe.Responses=Xa;fe.Realtime=Ga;fe.Conversations=Lc;fe.Evals=Dc;fe.Containers=Uc;fe.Skills=Ya;fe.Videos=th;function GV(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")||e.message.includes("maximum context length")))}function Am(e){if(!e||typeof e!="object")return e;let t;return e.constructor.name===Ja.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="TimeoutError"):e.constructor.name===Wt.name&&"message"in e&&typeof e.message=="string"?(t=new Error(e.message),t.name="AbortError"):GV(e)?t=s1.fromError(e):"status"in e&&e.status===400&&"message"in e&&typeof e.message=="string"&&e.message.includes("tool_calls")?t=kl(e,"INVALID_TOOL_RESULTS"):"status"in e&&e.status===401?t=kl(e,"MODEL_AUTHENTICATION"):"status"in e&&e.status===429?t=kl(e,"MODEL_RATE_LIMIT"):"status"in e&&e.status===404?t=kl(e,"MODEL_NOT_FOUND"):t=e,t}var qr=e=>e();function Lu(e){return e?!!(/^o\d/.test(e??"")||e.startsWith("gpt-5")&&!e.startsWith("gpt-5-chat")):!1}function XV(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 j$(e){return e.metadata?.filename??e.metadata?.name??e.metadata?.title}var YV="LC_AUTOGENERATED";function rh(e){return(e.metadata?.filename??e.metadata?.name??e.metadata?.title)||(console.warn("OpenAI may require a filename for file uploads. Specify a filename in the content block metadata, e.g.: { type: 'file', mimeType: '...', data: '...', metadata: { filename: 'my-file.pdf' } }. Using placeholder filename 'LC_AUTOGENERATED'."),YV)}function zu(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(!Qr.isInstance(e))throw new Error("Invalid generic chat message");return XV(e);default:throw new Error(`Unknown message type: ${t}`)}}function QV(e){return!!(e.includes("gpt-5.2-pro")||e.includes("gpt-5.4-pro")||e.includes("gpt-5.5-pro")||e.includes("codex"))}function Gj(e){let{azureOpenAIApiDeploymentName:t,azureOpenAIApiInstanceName:n,azureOpenAIApiKey:r,azureOpenAIBasePath:i,baseURL:s,azureADTokenProvider:a,azureOpenAIEndpoint:o}=e;if((r||a)&&i&&t)return`${i}/${t}`;if((r||a)&&o&&t)return`${o}/openai/deployments/${t}`;if(r||a){if(!n)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!t)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${n}.openai.azure.com/openai/deployments/${t}`}return s}function R$(e){return typeof Headers<"u"&&e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Headers]"}function eK(e){let t=qr(()=>{if(R$(e))return e;if(Array.isArray(e))return new Headers(e);if(typeof e=="object"&&e!==null&&"values"in e&&R$(e.values))return e.values;if(typeof e=="object"&&e!==null){let n=Object.entries(e).filter(([,r])=>typeof r=="string").map(([r,i])=>[r,i]);return new Headers(n)}return new Headers});return Object.fromEntries(t.entries())}function tK(){let e=y_();return(e==="node"||e==="deno")&&(e=`(${e}/${process.version}; ${process.platform}; ${process.arch})`),e}function Xj(e,t=!1,n="1.0.0"){let r=eK(e),i=tK(),s=`langchainjs${t?"-azure":""}-openai`;return{...r,"User-Agent":r["User-Agent"]?`${s}/${n} (${i})${r["User-Agent"]}`:`${s}/${n} (${i})`}}function nK(e,t){let n;return $u(e)?n=YN(e):n=e,t?.strict!==void 0&&(n.function.strict=t.strict),n}function rK(e){return e.anyOf!==void 0&&Array.isArray(e.anyOf)}function iK(e){let t=["namespace functions {",""];for(let n of e)n.description&&t.push(`// ${n.description}`),Object.keys(n.parameters.properties??{}).length>0?(t.push(`type ${n.name} = (_: {`),t.push(Yj(n.parameters,0)),t.push("}) => any;")):t.push(`type ${n.name} = () => any;`),t.push("");return t.push("} // namespace functions"),t.join(`
|
|
398
|
+
`)}function Yj(e,t){let n=[];for(let[r,i]of Object.entries(e.properties??{}))i.description&&t<2&&n.push(`// ${i.description}`),e.required?.includes(r)?n.push(`${r}: ${ih(i,t)},`):n.push(`${r}?: ${ih(i,t)},`);return n.map(r=>" ".repeat(t)+r).join(`
|
|
399
|
+
`)}function ih(e,t){if(rK(e))return e.anyOf.map(n=>ih(n,t)).join(" | ");switch(e.type){case"string":return e.enum?e.enum.map(n=>`"${n}"`).join(" | "):"string";case"number":return e.enum?e.enum.map(n=>`${n}`).join(" | "):"number";case"integer":return e.enum?e.enum.map(n=>`${n}`).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",Yj(e,t+2),"}"].join(`
|
|
400
|
+
`);case"array":return e.items?`${ih(e.items,t)}[]`:"any[]";default:return""}}function Qj(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 D0(e){return"type"in e&&e.type!=="function"}function sK(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 aK(e){return e!=null&&typeof e=="object"&&"type"in e&&e.type!=="function"}function sh(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 e4(e){return"type"in e&&e.type==="custom"&&"custom"in e&&typeof e.custom=="object"&&e.custom!==null}function oK(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 cK(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 uK(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_call"&&"isComputerTool"in e&&e.isComputerTool===!0}function lK(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_call"&&"isCustomTool"in e&&e.isCustomTool===!0}function dK(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 pK(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 hK=Symbol("Let zodToJsonSchema decide on which parser to use"),M$={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"},mK=e=>typeof e=="string"?{...M$,basePath:["#"],definitions:{},name:e}:{...M$,basePath:["#"],definitions:{},...e},u_=e=>"_def"in e?e._def:e;function fK(e){if(!e)return!0;for(let t in e)return!1;return!0}var gK=e=>{let t=mK(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map(([r,i])=>[u_(i),{def:u_(i),path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}};function t4(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Ue(e,t,n,r,i){e[t]=n,t4(e,t,r,i)}function yK(){return{}}function _K(e,t){let n={type:"array"};return e.type?._def?.typeName!==N.ZodAny&&(n.items=Ce(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ue(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ue(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ue(n,"minItems",e.exactLength.value,e.exactLength.message,t),Ue(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}function vK(e,t){let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"min":t.target==="jsonSchema7"?r.inclusive?Ue(n,"minimum",r.value,r.message,t):Ue(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Ue(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?Ue(n,"maximum",r.value,r.message,t):Ue(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Ue(n,"maximum",r.value,r.message,t));break;case"multipleOf":Ue(n,"multipleOf",r.value,r.message,t);break}return n}function bK(){return{type:"boolean"}}function wK(e,t){return Ce(e.type._def,t)}var kK=(e,t)=>Ce(e.innerType._def,t);function n4(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>n4(e,t,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return xK(e,t)}}var xK=(e,t)=>{let n={type:"integer",format:"unix-time"};if(t.target==="openApi3")return n;for(let r of e.checks)switch(r.kind){case"min":Ue(n,"minimum",r.value,r.message,t);break;case"max":Ue(n,"maximum",r.value,r.message,t);break}return n};function $K(e,t){return{...Ce(e.innerType._def,t),default:e.defaultValue()}}function IK(e,t,n){return t.effectStrategy==="input"?Ce(e.schema._def,t,n):{}}function SK(e){return{type:"string",enum:[...e.values]}}var OK=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function AK(e,t){let n=[Ce(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Ce(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),r=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(OK(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:o,...c}=s;a=c}else r=void 0;i.push(a)}}),i.length?{allOf:i,...r}:void 0}function TK(e,t){let n=typeof e.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[e.value]}:{type:n==="bigint"?"integer":n,const:e.value}}var Hf,Vi={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:()=>(Hf===void 0&&(Hf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Hf),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function r4(e,t){let n={type:"string"};function r(i){return t.patternStrategy==="escape"?EK(i):i}if(e.checks)for(let i of e.checks)switch(i.kind){case"min":Ue(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,t);break;case"max":Ue(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":qn(n,"email",i.message,t);break;case"format:idn-email":qn(n,"idn-email",i.message,t);break;case"pattern:zod":Jn(n,Vi.email,i.message,t);break}break;case"url":qn(n,"uri",i.message,t);break;case"uuid":qn(n,"uuid",i.message,t);break;case"regex":Jn(n,i.regex,i.message,t);break;case"cuid":Jn(n,Vi.cuid,i.message,t);break;case"cuid2":Jn(n,Vi.cuid2,i.message,t);break;case"startsWith":Jn(n,RegExp(`^${r(i.value)}`),i.message,t);break;case"endsWith":Jn(n,RegExp(`${r(i.value)}$`),i.message,t);break;case"datetime":qn(n,"date-time",i.message,t);break;case"date":qn(n,"date",i.message,t);break;case"time":qn(n,"time",i.message,t);break;case"duration":qn(n,"duration",i.message,t);break;case"length":Ue(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,t),Ue(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,t);break;case"includes":{Jn(n,RegExp(r(i.value)),i.message,t);break}case"ip":{i.version!=="v6"&&qn(n,"ipv4",i.message,t),i.version!=="v4"&&qn(n,"ipv6",i.message,t);break}case"emoji":Jn(n,Vi.emoji,i.message,t);break;case"ulid":{Jn(n,Vi.ulid,i.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{qn(n,"binary",i.message,t);break}case"contentEncoding:base64":{Ue(n,"contentEncoding","base64",i.message,t);break}case"pattern:zod":{Jn(n,Vi.base64,i.message,t);break}}break}case"nanoid":Jn(n,Vi.nanoid,i.message,t)}return n}var EK=e=>Array.from(e).map(t=>/[a-zA-Z0-9]/.test(t)?t:`\\${t}`).join(""),qn=(e,t,n,r)=>{e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.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,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Ue(e,"format",t,n,r)},Jn=(e,t,n,r)=>{e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.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:U$(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Ue(e,"pattern",U$(t,r),n,r)},U$=(e,t)=>{let n=typeof e=="function"?e():e;if(!t.applyRegexFlags||!n.flags)return n.source;let r={i:n.flags.includes("i"),m:n.flags.includes("m"),s:n.flags.includes("s")},i=r.i?n.source.toLowerCase():n.source,s="",a=!1,o=!1,c=!1;for(let u=0;u<i.length;u++){if(a){s+=i[u],a=!1;continue}if(r.i){if(o){if(i[u].match(/[a-z]/)){c?(s+=i[u],s+=`${i[u-2]}-${i[u]}`.toUpperCase(),c=!1):i[u+1]==="-"&&i[u+2]?.match(/[a-z]/)?(s+=i[u],c=!0):s+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){s+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){s+=`(^|(?<=[\r
|
|
401
|
+
]))`;continue}else if(i[u]==="$"){s+=`($|(?=[\r
|
|
402
|
+
]))`;continue}}if(r.s&&i[u]==="."){s+=o?`${i[u]}\r
|
|
403
|
+
`:`[${i[u]}\r
|
|
404
|
+
]`;continue}s+=i[u],i[u]==="\\"?a=!0:o&&i[u]==="]"?o=!1:!o&&i[u]==="["&&(o=!0)}try{let u=new RegExp(s)}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`),n.source}return s};function i4(e,t){if(t.target==="openApi3"&&e.keyType?._def.typeName===N.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:Ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??{}}),{}),additionalProperties:!1};let n={type:"object",additionalProperties:Ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if(t.target==="openApi3")return n;if(e.keyType?._def.typeName===N.ZodString&&e.keyType._def.checks?.length){let r=Object.entries(r4(e.keyType._def,t)).reduce((i,[s,a])=>s==="type"?i:{...i,[s]:a},{});return{...n,propertyNames:r}}else if(e.keyType?._def.typeName===N.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};return n}function CK(e,t){if(t.mapStrategy==="record")return i4(e,t);let n=Ce(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},r=Ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function NK(e){let t=e.values,n=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(n.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:n}}function PK(){return{not:{}}}function jK(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var ah={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function RK(e,t){if(t.target==="openApi3")return L$(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in ah&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=ah[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return L$(e,t)}var L$=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Ce(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function MK(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:ah[e.innerType._def.typeName],nullable:!0}:{type:[ah[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let r=Ce(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let n=Ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function UK(e,t){let n={type:"number"};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case"int":n.type="integer",t4(n,"type",r.message,t);break;case"min":t.target==="jsonSchema7"?r.inclusive?Ue(n,"minimum",r.value,r.message,t):Ue(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Ue(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?Ue(n,"maximum",r.value,r.message,t):Ue(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Ue(n,"maximum",r.value,r.message,t));break;case"multipleOf":Ue(n,"multipleOf",r.value,r.message,t);break}return n}function LK(e,t){return t.removeAdditionalStrategy==="strict"?e.catchall._def.typeName==="ZodNever"?e.unknownKeys!=="strict":Ce(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:e.catchall._def.typeName==="ZodNever"?e.unknownKeys==="passthrough":Ce(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function zK(e,t){let n={type:"object",...Object.entries(e.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=[...t.currentPath,"properties",i],o=Ce(s._def,{...t,currentPath:a,propertyPath:a});if(o===void 0)return r;if(t.openaiStrictMode&&s.isOptional()&&!s.isNullable()&&typeof s._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:{...r.properties,[i]:o},required:s.isOptional()&&!t.openaiStrictMode?r.required:[...r.required,i]}},{properties:{},required:[]}),additionalProperties:LK(e,t)};return n.required.length||delete n.required,n}var DK=(e,t)=>{if(t.propertyPath&&t.currentPath.slice(0,t.propertyPath.length).toString()===t.propertyPath.toString())return Ce(e.innerType._def,{...t,currentPath:t.currentPath});let n=Ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:{}},n]}:{}},FK=(e,t)=>{if(t.pipeStrategy==="input")return Ce(e.in._def,t);if(t.pipeStrategy==="output")return Ce(e.out._def,t);let n=Ce(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Ce(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function ZK(e,t){return Ce(e.type._def,t)}function BK(e,t){let n={type:"array",uniqueItems:!0,items:Ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ue(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ue(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function qK(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Ce(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ce(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Ce(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function JK(){return{not:{}}}function HK(){return{}}var VK=(e,t)=>Ce(e.innerType._def,t);function Ce(e,t,n=!1){let r=t.seen.get(e);if(t.override){let a=t.override?.(e,t,r,n);if(a!==hK)return a}if(r&&!n){let a=KK(r,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 s=GK(e,e.typeName,t,n);return s&&XK(e,t,s),i.jsonSchema=s,s}var KK=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":let n=e.path.slice(t.basePath.length+1).join("_");return n!==t.name&&t.nameStrategy==="duplicate-ref"&&(t.definitions[n]=e.def),{$ref:[...t.basePath,t.definitionPath,n].join("/")};case"relative":return{$ref:WK(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,i)=>t.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):t.$refStrategy==="seen"?{}:void 0}},WK=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},GK=(e,t,n,r)=>{switch(t){case N.ZodString:return r4(e,n);case N.ZodNumber:return UK(e,n);case N.ZodObject:return zK(e,n);case N.ZodBigInt:return vK(e,n);case N.ZodBoolean:return bK();case N.ZodDate:return n4(e,n);case N.ZodUndefined:return JK();case N.ZodNull:return jK(n);case N.ZodArray:return _K(e,n);case N.ZodUnion:case N.ZodDiscriminatedUnion:return RK(e,n);case N.ZodIntersection:return AK(e,n);case N.ZodTuple:return qK(e,n);case N.ZodRecord:return i4(e,n);case N.ZodLiteral:return TK(e,n);case N.ZodEnum:return SK(e);case N.ZodNativeEnum:return NK(e);case N.ZodNullable:return MK(e,n);case N.ZodOptional:return DK(e,n);case N.ZodMap:return CK(e,n);case N.ZodSet:return BK(e,n);case N.ZodLazy:return Ce(e.getter()._def,n);case N.ZodPromise:return ZK(e,n);case N.ZodNaN:case N.ZodNever:return PK();case N.ZodEffects:return IK(e,n,r);case N.ZodAny:return yK();case N.ZodUnknown:return HK();case N.ZodDefault:return $K(e,n);case N.ZodBranded:return wK(e,n);case N.ZodReadonly:return VK(e,n);case N.ZodCatch:return kK(e,n);case N.ZodPipeline:return FK(e,n);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return(i=>{})()}},XK=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),YK=(e,t)=>{let n=gK(t),r=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=Ce(e._def,r===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,r]},!1)??{},s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(i.title=s);let a=(()=>{if(fK(n.definitions))return;let c={},u=new Set;for(let l=0;l<500;l++){let d=Object.entries(n.definitions).filter(([p])=>!u.has(p));if(d.length===0)break;for(let[p,h]of d)c[p]=Ce(u_(h),{...n,currentPath:[...n.basePath,n.definitionPath,p]},!0)??{},u.add(p)}return c})(),o=r===void 0?a?{...i,[n.definitionPath]:a}:i:n.nameStrategy==="duplicate-ref"?{...i,...a||n.seenRefs.size?{[n.definitionPath]:{...a,...n.seenRefs.size?{[r]:i}:void 0}}:void 0}:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,r].join("/"),[n.definitionPath]:{...a,[r]:i}};return n.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};function QK(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 Rr(t,[],t)}function l_(e){if(typeof e=="boolean")return!1;if(e.type==="null")return!0;for(let t of e.oneOf??[])if(l_(t))return!0;for(let t of e.anyOf??[])if(l_(t))return!0;return!1}function Rr(e,t,n){if(typeof e=="boolean")throw new TypeError(`Expected object schema but got boolean; path=${t.join("/")}`);if(!Xi(e))throw new TypeError(`Expected ${JSON.stringify(e)} to be an object; path=${t.join("/")}`);let r=e.$defs;if(Xi(r))for(let[d,p]of Object.entries(r))Rr(p,[...t,"$defs",d],n);let i=e.definitions;if(Xi(i))for(let[d,p]of Object.entries(i))Rr(p,[...t,"definitions",d],n);e.type==="object"&&!("additionalProperties"in e)&&(e.additionalProperties=!1);let s=e.required??[],a=e.properties;if(Xi(a)){for(let[d,p]of Object.entries(a))if(!l_(p)&&!s.includes(d))throw new Error(`Zod field at \`${[...t,"properties",d].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(a),e.properties=Object.fromEntries(Object.entries(a).map(([d,p])=>[d,Rr(p,[...t,"properties",d],n)]))}let o=e.items;Xi(o)&&(e.items=Rr(o,[...t,"items"],n));let c=e.anyOf;Array.isArray(c)&&(e.anyOf=c.map((d,p)=>Rr(d,[...t,"anyOf",String(p)],n)));let u=e.allOf;if(Array.isArray(u))if(u.length===1){let d=Rr(u[0],[...t,"allOf","0"],n);Object.assign(e,d),delete e.allOf}else e.allOf=u.map((d,p)=>Rr(d,[...t,"allOf",String(p)],n));e.default===null&&delete e.default;let l=e.$ref;if(l&&tW(e,1)){if(typeof l!="string")throw new TypeError(`Received non-string $ref - ${l}; path=${t.join("/")}`);let d=eW(n,l);if(typeof d=="boolean")throw new Error(`Expected \`$ref: ${l}\` to resolve to an object schema but got boolean`);if(!Xi(d))throw new Error(`Expected \`$ref: ${l}\` to resolve to an object but got ${JSON.stringify(d)}`);return Object.assign(e,{...d,...e}),delete e.$ref,Rr(e,t,n)}return e}function eW(e,t){if(!t.startsWith("#/"))throw new Error(`Unexpected $ref format ${JSON.stringify(t)}; Does not start with #/`);let n=t.slice(2).split("/"),r=e;for(let i of n){if(!Xi(r))throw new Error(`encountered non-object entry while resolving ${t} - ${JSON.stringify(r)}`);let s=r[i];if(s===void 0)throw new Error(`Key ${i} not found while resolving ${t}`);r=s}return r}function Xi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function tW(e,t){let n=0;for(let r in e)if(n++,n>t)return!0;return!1}function nW(e,t){return YK(e,{openaiStrictMode:!0,name:t.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}function rW(e){return QK(pc(e,{target:"draft-7"}))}function iW(e){return"_zod"in e}function sW(e,t,n){return OV({type:"json_schema",json_schema:{...n,name:t,strict:!0,schema:iW(e)?rW(e):nW(e,{name:t})}},r=>e.parse(JSON.parse(r)))}var z$=["jsonSchema","functionCalling","jsonMode"];function aW(e,t){if(typeof t<"u"&&!z$.includes(t))throw new Error(`Invalid method: ${t}. Supported methods are: ${z$.join(", ")}`);let n=!e.startsWith("gpt-3")&&!e.startsWith("gpt-4-")&&e!=="gpt-4";if(n&&!t)return"jsonSchema";if(!n&&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 oW(e,t){let n={...e};return Object.defineProperties(n,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),n}function cW(e,t,n){if(pt(e))return sW(e,t,n);if(We(e))return oW({type:"json_schema",json_schema:{...n,name:t,strict:!0,schema:xt(e,{cycles:"ref",reused:"ref",override(r){r.jsonSchema.title=t}})}},r=>_s(e,JSON.parse(r)));throw new Error("Unsupported schema response format")}function uW(e,t){if(t&&typeof t=="object"&&"images"in t&&Array.isArray(t.images)){let n=t.images.filter(r=>typeof r?.image_url?.url=="string").map(r=>({type:"image",url:r.image_url.url}));return[{type:"text",text:e},...n]}return e}var lW={"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},"gpt-5.5":{maxInputTokens:105e4,imageInputs:!0,audioInputs:!1,pdfInputs:!0,videoInputs:!1,maxOutputTokens:13e4,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0,imageUrlInputs:!0,pdfToolMessage:!0,imageToolMessage:!0,toolChoice:!0},"gpt-5.5-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 F0(e,t){return typeof e=="string"?{model:e,...t??{}}:e??t}var Z0=class extends Ns{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??bn("OPENAI_API_KEY"),this.organization=e?.configuration?.organization??bn("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.4.5")}_getReasoningParams(e){if(!Lu(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&&_n(e.json_schema.schema)?cW(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=Gj({baseURL:this.clientConfig.baseURL}),n={...this.clientConfig,baseURL:t,timeout:this.timeout,maxRetries:0};n.baseURL||delete n.baseURL,n.defaultHeaders=Xj(n.defaultHeaders),this.client=new fe(n)}return{...this.clientConfig,...e}}_convertChatOpenAIToolToCompletionsTool(e,t){return sh(e)?pK(e.metadata.customTool):ob(e)?t?.strict!==void 0?{...e,function:{...e.function,strict:t.strict}}:e:nK(e,t)}bindTools(e,t){let n;return t?.strict!==void 0?n=t.strict:this.supportsStrictToolCalling!==void 0&&(n=this.supportsStrictToolCalling),this.withConfig({tools:e.map(r=>{if(D0(r)||sh(r))return r;if(sK(r))return r.extras.providerToolDefinition;let i=this._convertChatOpenAIToolToCompletionsTool(r,{strict:n});return $u(r)&&r.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,n)=>(n&&n.tokenUsage&&(t.tokenUsage.completionTokens+=n.tokenUsage.completionTokens??0,t.tokenUsage.promptTokens+=n.tokenUsage.promptTokens??0,t.tokenUsage.totalTokens+=n.tokenUsage.totalTokens??0),t),{tokenUsage:{completionTokens:0,promptTokens:0,totalTokens:0}})}async getNumTokensFromMessages(e){let t=0,n=0,r=0;this.model==="gpt-3.5-turbo-0301"?(n=4,r=-1):(n=3,r=1);let i=await Promise.all(e.map(async s=>{let[a,o]=await Promise.all([this.getNumTokens(s.content),this.getNumTokens(zu(s))]),c=s.name!==void 0?r+await this.getNumTokens(s.name):0,u=a+n+o+c,l=s;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,n)=>t+n,0)}async _getEstimatedTokenCountFromPrompt(e,t,n){let r=(await this.getNumTokensFromMessages(e)).totalCount;if(t&&n!=="auto"){let i=iK(t);r+=await this.getNumTokens(i),r+=9}return t&&e.find(i=>i._getType()==="system")&&(r-=4),n==="none"?r+=1:typeof n=="object"&&(r+=await this.getNumTokens(n.name)+4),r}async moderateContent(e,t){let n=this._getClientOptions(t?.options),r={input:e,model:t?.model??"omni-moderation-latest"};return this.caller.call(async()=>{try{return await this.client.moderations.create(r,n)}catch(i){throw Am(i)}})}get profile(){return lW[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 n,r,{schema:i,name:s,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 o=aW(this.model,t?.method);if(o==="jsonMode"){r=fy(i);let c=xt(i);n=this.withConfig({outputVersion:"v0",response_format:{type:"json_object"},ls_structured_output_format:{kwargs:{method:"json_mode"},schema:{title:s??"extract",...c}}})}else if(o==="jsonSchema"){let c=xt(i),u={name:s??"extract",description:ja(c),schema:_n(i)?i:c,strict:t?.strict};if(n=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}}}),_n(i)||gs(i)){let l=fy(i);r=ir.from(async d=>"parsed"in d.additional_kwargs?d.additional_kwargs.parsed:l.invoke(d.content))}else r=new ub}else{let c=s??"extract",u=xt(i),l;_n(i)||gs(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}),n=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}:{}}),r=OE(i,c)}return db(n,r,a)}},s4={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=Qo({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 n=t.mime_type||e.mime_type||"",r;try{r=ig(n)}catch{throw new Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(r.type!=="audio"||r.subtype!=="wav"&&r.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:r.subtype,data:t.data}}}if(e.source_type==="base64"){let t;try{t=ig(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=Qo({dataUrl:e.url}),n=rh(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,filename:n}}}if(e.source_type==="base64"){let t=rh(e);return{type:"file",file:{file_data:`data:${e.mime_type??""};base64,${e.data}`,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`)}},dW=({message:e,rawResponse:t,includeRawResponse:n})=>{let r=e.tool_calls,i=e.reasoning_content;switch(e.role){case"assistant":{let s=[],a=[];for(let u of r??[])try{s.push(Vh(u,{returnId:!0}))}catch(l){a.push(Vo(u,l.message))}let o={function_call:e.function_call,tool_calls:r};n!==void 0&&(o.__raw_response=t),i!==void 0&&(o.reasoning_content=i);let c={model_provider:"openai",model_name:t.model,...t.system_fingerprint?{usage:{...t.usage},system_fingerprint:t.system_fingerprint}:{}};return e.audio&&(o.audio=e.audio),new Le({content:uW(e.content||"",t.choices?.[0]?.message),tool_calls:s,invalid_tool_calls:a,additional_kwargs:o,response_metadata:c,id:t.id})}default:return new Qr(e.content||"",e.role??"unknown")}},pW=({delta:e,rawResponse:t,includeRawResponse:n,defaultRole:r})=>{let i=e.role??r,s=e.content??"",a;e.function_call?a={function_call:e.function_call}:e.tool_calls?a={tool_calls:e.tool_calls}:a={},n&&(a.__raw_response=t),e.reasoning_content!==void 0&&(a.reasoning_content=e.reasoning_content),e.audio&&(a.audio={...e.audio,index:t.choices[0].index});let o={model_provider:"openai",usage:{...t.usage}};if(i==="user")return new Xc({content:s,response_metadata:o});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 Pt({content:s,tool_call_chunks:c,additional_kwargs:a,id:t.id,response_metadata:o})}else return i==="system"?new xi({content:s,response_metadata:o}):i==="developer"?new xi({content:s,response_metadata:o,additional_kwargs:{__openai_role__:"developer"}}):i==="function"?new Gc({content:s,additional_kwargs:a,name:e.name,response_metadata:o}):i==="tool"?new Kc({content:s,additional_kwargs:a,tool_call_id:e.tool_call_id,response_metadata:o}):new Wc({content:s,role:i,response_metadata:o})},hW=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=k1(()=>{let[,n]=e.mimeType.split("/");return n==="wav"||n==="mp3"?n:"wav"});return{type:"input_audio",input_audio:{data:e.data.toString(),format:t}}}if(e.type==="file"){if(e.data){let t=rh(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}}}},mW=({message:e,model:t})=>{let n=zu(e);if(n==="system"&&Lu(t)&&(n="developer"),n==="developer")return{role:"developer",content:e.contentBlocks.filter(i=>i.type==="text")};if(n==="system")return{role:"system",content:e.contentBlocks.filter(i=>i.type==="text")};if(n==="assistant")return{role:"assistant",content:e.contentBlocks.filter(i=>i.type==="text")};if(n==="tool"&&Mn.isInstance(e))return{role:"tool",tool_call_id:e.tool_call_id,content:e.contentBlocks.filter(i=>i.type==="text")};if(n==="function")return{role:"function",name:e.name??"",content:e.contentBlocks.filter(i=>i.type==="text").join("")};function*r(i){for(let s of i){s.type==="text"&&(yield{type:"text",text:s.text});let a=hW(s);a&&(yield a)}}return{role:"user",content:Array.from(r(e.contentBlocks))}},D$=({messages:e,model:t})=>e.flatMap(n=>{if("output_version"in n.response_metadata&&n.response_metadata?.output_version==="v1")return mW({message:n});let r=zu(n);r==="system"&&Lu(t)&&(r="developer");let i=typeof n.content=="string"?n.content:n.content.flatMap(a=>$r(a)?k_(a,s4):typeof a=="object"&&a!==null&&"type"in a&&a.type==="tool_use"?[]:a),s={role:r,content:i};return n.name!=null&&(s.name=n.name),n.additional_kwargs.function_call!=null&&(s.function_call=n.additional_kwargs.function_call),Le.isInstance(n)&&n.tool_calls?.length?s.tool_calls=n.tool_calls.map($E):(n.additional_kwargs.tool_calls!=null&&(s.tool_calls=n.additional_kwargs.tool_calls),Mn.isInstance(n)&&n.tool_call_id!=null&&(s.tool_call_id=n.tool_call_id)),n.additional_kwargs.audio&&typeof n.additional_kwargs.audio=="object"&&"id"in n.additional_kwargs.audio?[s,{role:"assistant",audio:{id:n.additional_kwargs.audio.id}}]:s}),fW=class extends Z0{constructor(e,t){super(F0(e,t))}invocationParams(e,t){let n;e?.strict!==void 0?n=e.strict:this.supportsStrictToolCalling!==void 0&&(n=this.supportsStrictToolCalling);let r={};e?.stream_options!==void 0?r={stream_options:e.stream_options}:this.streamUsage&&(this.streaming||t?.streaming)&&(r={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:n})):void 0,tool_choice:Qj(e?.tool_choice),response_format:this._getResponseFormat(e?.response_format),seed:e?.seed,...r,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 s=this._getReasoningParams(e);return s!==void 0&&s.effort!==void 0&&(i.reasoning_effort=s.effort),Lu(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,n){t.signal?.throwIfAborted();let r={},i=this.invocationParams(t),s=D$({messages:e,model:this.model});if(i.stream){let a=this._streamResponseChunks(e,t,n),o={};for await(let h of a){h.message.response_metadata={...h.generationInfo,...h.message.response_metadata};let m=h.generationInfo?.completion??0;o[m]===void 0?o[m]=h:o[m]=o[m].concat(h)}let c=Object.entries(o).sort(([h],[m])=>parseInt(h,10)-parseInt(m,10)).map(([h,m])=>m),{functions:u,function_call:l}=this.invocationParams(t),d=await this._getEstimatedTokenCountFromPrompt(e,u,l),p=await this._getNumTokensFromGenerations(c);return r.input_tokens=d,r.output_tokens=p,r.total_tokens=d+p,{generations:c,llmOutput:{estimatedTokenUsage:{promptTokens:r.input_tokens,completionTokens:r.output_tokens,totalTokens:r.total_tokens}}}}else{let a=await this.completionWithRetry({...i,stream:!1,messages:s},{signal:t?.signal,...t?.options}),{completion_tokens:o,prompt_tokens:c,total_tokens:u,prompt_tokens_details:l,completion_tokens_details:d}=a?.usage??{};o&&(r.output_tokens=(r.output_tokens??0)+o),c&&(r.input_tokens=(r.input_tokens??0)+c),u&&(r.total_tokens=(r.total_tokens??0)+u),(l?.audio_tokens!==null||l?.cached_tokens!==null)&&(r.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)&&(r.output_token_details={...d?.audio_tokens!==null&&{audio:d?.audio_tokens},...d?.reasoning_tokens!==null&&{reasoning:d?.reasoning_tokens}});let p=[];for(let h of a?.choices??[]){let m={text:h.message?.content??"",message:this._convertCompletionsMessageToBaseMessage(h.message??{role:"assistant"},a)};m.generationInfo={...h.finish_reason?{finish_reason:h.finish_reason}:{},...h.logprobs?{logprobs:h.logprobs}:{}},yh(m.message)&&(m.message.usage_metadata=r),m.message=new Le(Object.fromEntries(Object.entries(m.message).filter(([f])=>!f.startsWith("lc_")))),p.push(m)}return{generations:p,llmOutput:{tokenUsage:{promptTokens:r.input_tokens,completionTokens:r.output_tokens,totalTokens:r.total_tokens}}}}}async*_streamResponseChunks(e,t,n){let r=D$({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:r,stream:!0},s,a=await this.completionWithRetry(i,t),o;for await(let c of a){if(t.signal?.aborted)return;let u=c?.choices?.[0];if(c.usage&&(o=c.usage),!u)continue;let{delta:l}=u;if(!l)continue;let d=this._convertCompletionsDeltaToBaseMessageChunk(l,c,s);s=l.role??s;let p={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 h={...p};u.finish_reason!=null&&(h.finish_reason=u.finish_reason,h.system_fingerprint=c.system_fingerprint,h.model_name=c.model,h.service_tier=c.service_tier),this.logprobs&&(h.logprobs=u.logprobs);let m=new Wr({message:d,text:d.content,generationInfo:h});yield m,await n?.handleLLMNewToken(m.text??"",p,void 0,void 0,void 0,{chunk:m})}if(o){let c={...o.prompt_tokens_details?.audio_tokens!==null&&{audio:o.prompt_tokens_details?.audio_tokens},...o.prompt_tokens_details?.cached_tokens!==null&&{cache_read:o.prompt_tokens_details?.cached_tokens}},u={...o.completion_tokens_details?.audio_tokens!==null&&{audio:o.completion_tokens_details?.audio_tokens},...o.completion_tokens_details?.reasoning_tokens!==null&&{reasoning:o.completion_tokens_details?.reasoning_tokens}},l=new Wr({message:new Pt({content:"",response_metadata:{usage:{...o}},usage_metadata:{input_tokens:o.prompt_tokens,output_tokens:o.completion_tokens,total_tokens:o.total_tokens,...Object.keys(c).length>0&&{input_token_details:c},...Object.keys(u).length>0&&{output_token_details:u}}}),text:""});yield l,await n?.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 n=this._getClientOptions(t),r=e.response_format&&e.response_format.type==="json_schema";return this.caller.call(async()=>{try{return r&&!e.stream?await this.client.chat.completions.parse(e,n):await this.client.chat.completions.create(e,n)}catch(i){throw Am(i)}})}_convertCompletionsDeltaToBaseMessageChunk(e,t,n){return pW({delta:e,rawResponse:t,includeRawResponse:this.__includeRawResponse,defaultRole:n})}_convertCompletionsMessageToBaseMessage(e,t){return dW({message:e,rawResponse:t,includeRawResponse:this.__includeRawResponse})}},oh="__openai_function_call_ids__";function a4(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 gW(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 o4=e=>{let t={...e?.input_tokens_details?.cached_tokens!=null&&{cache_read:e?.input_tokens_details?.cached_tokens}},n={...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:n}},c4=e=>{if(e.error){let c=new Error(e.error.message);throw c.name=e.error.code,c}let t,n=[],r=[],i=[],s=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:s,status:e.status,user:e.user,service_tier:e.service_tier,model_name:e.model},o={};for(let c of e.output)if(c.type==="message")t=c.id,n.push(...c.content.flatMap(u=>u.type==="output_text"?("parsed"in u&&u.parsed!=null&&(o.parsed=u.parsed),{type:"text",text:u.text,annotations:u.annotations.map(a4),...c.phase!==null?{phase:c.phase}:{}}):u.type==="refusal"?(o.refusal=u.refusal,[]):u));else if(c.type==="function_call"){let u={function:{name:c.name,arguments:c.arguments},id:c.call_id};try{r.push(Vh(u,{returnId:!0}))}catch(l){let d;typeof l=="object"&&l!=null&&"message"in l&&typeof l.message=="string"&&(d=l.message),i.push(Vo(u,d))}o[oh]??={},c.id&&(o[oh][c.call_id]=c.id)}else if(c.type==="reasoning"){o.reasoning=c;let u=c.summary?.map(l=>l.text).filter(Boolean).join("");u&&n.push({type:"reasoning",reasoning:u})}else if(c.type==="custom_tool_call"){let u=oK(c);u?r.push(u):i.push(Vo(c,"Malformed custom tool call"))}else if(c.type==="computer_call"){let u=cK(c);u?r.push(u):i.push(Vo(c,"Malformed computer call"))}else c.type==="image_generation_call"?(c.result&&n.push({type:"image",mimeType:"image/png",data:c.result,id:c.id,metadata:{status:c.status}}),o.tool_outputs??=[],o.tool_outputs.push(c)):(o.tool_outputs??=[],o.tool_outputs.push(c));return new Le({id:t,content:n,tool_calls:r,invalid_tool_calls:i,usage_metadata:o4(e.usage),additional_kwargs:o,response_metadata:a})},yW=e=>{let t=(e.summary.length>1?e.summary.reduce((n,r)=>{let i=n[n.length-1];return i.index===r.index?i.text+=r.text:n.push(r),n},[{...e.summary[0]}]):e.summary).map(n=>Object.fromEntries(Object.entries(n).filter(([r])=>r!=="index")));return{...e,summary:t}},_W=e=>{let t=[],n={},r,i=[],s={model_provider:"openai"},a={},o;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:[a4(e.annotation)],index:e.content_index});else if(e.type==="response.output_item.added"&&e.item.type==="message"){o=e.item.id;let c="phase"in e.item?e.item.phase:void 0;c&&t.push({type:"text",text:"",phase:c,index:0})}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[oh]={[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")s.id=e.response.id,s.model_name=e.response.model,s.model=e.response.model;else if(e.type==="response.completed"){let c=c4(e.response);r=o4(e.response.usage),e.response.text?.format?.type==="json_schema"&&c.text&&(a.parsed??=JSON.parse(c.text));for(let[u,l]of Object.entries(e.response))u!=="id"&&(u==="output"?s[u]=c.response_metadata.output:s[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")n={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,index:e.summary_index});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,index:e.summary_index});else return e.type,null;return new Wr({text:t.map(c=>c.text).join(""),message:new Pt({id:o,content:t,tool_call_chunks:i,usage_metadata:r,additional_kwargs:a,response_metadata:s}),generationInfo:n})},vW=e=>{let t=Le.isInstance(e)&&e.response_metadata?.model_provider==="openai";function*n(){let r=qr(()=>{try{let g=zu(e);return g==="system"||g==="developer"||g==="assistant"||g==="user"?g:"assistant"}catch{return"assistant"}}),i,s=new Set,a=new Set,o=new Map,c=new Map;function*u(){if(!i)return;let g=i.content;(typeof g=="string"&&g.length>0||Array.isArray(g)&&g.length>0)&&(yield i),i=void 0}let l=(g,y)=>{i||(i={type:"message",role:r,content:[],...y?{phase:y}:{}}),typeof i.content=="string"?i.content=i.content.length>0?[{type:"input_text",text:i.content},...g]:[...g]:i.content.push(...g)},d=g=>{if(typeof g=="string")return g;try{return JSON.stringify(g??{})}catch{return"{}"}},p=g=>{let y=qr(()=>{let w=g.metadata?.detail;return w==="low"||w==="high"||w==="auto"?w:"auto"});if(g.fileId)return{type:"input_image",detail:y,file_id:g.fileId};if(g.url)return{type:"input_image",detail:y,image_url:g.url};if(g.data){let w=typeof g.data=="string"?g.data:Buffer.from(g.data).toString("base64");return{type:"input_image",detail:y,image_url:`data:${g.mimeType??"image/png"};base64,${w}`}}},h=g=>{if(g.fileId){let y=j$(g);return{type:"input_file",file_id:g.fileId,...y?{filename:y}:{}}}if(g.url){let y=j$(g);return{...y?{filename:y}:{},type:"input_file",file_url:g.url}}if(g.data){let y=rh(g),w=typeof g.data=="string"?g.data:Buffer.from(g.data).toString("base64");return{type:"input_file",file_data:`data:${g.mimeType??"application/octet-stream"};base64,${w}`,filename:y}}},m=g=>{let y=qr(()=>{if(Array.isArray(g.summary)){let O=g.summary?.map(z=>z?.text).filter(z=>typeof z=="string")??[];if(O.length>0)return O}return g.reasoning?[g.reasoning]:[]}),w=y.length>0?y.map(O=>({type:"summary_text",text:O})):[{type:"summary_text",text:""}],x={type:"reasoning",id:g.id??"",summary:w};return g.reasoning&&(x.content=[{type:"reasoning_text",text:g.reasoning}]),x},f=g=>({type:"function_call",name:g.name??"",call_id:g.id??"",arguments:d(g.args)}),v=g=>{let y=d(g.output),w=g.status==="success"?"completed":g.status==="error"?"incomplete":void 0;return{type:"function_call_output",call_id:g.toolCallId??"",output:y,...w?{status:w}:{}}};for(let g of e.contentBlocks)if(g.type==="text"){let y=qr(()=>{if("extras"in g&&typeof g.extras=="object"&&g.extras!==null&&"phase"in g.extras)return g.extras.phase});l([{type:"input_text",text:g.text}],y)}else if(g.type!=="invalid_tool_call"){if(g.type==="reasoning")yield*u(),yield m(g);else if(g.type==="tool_call"){yield*u();let y=g.id??"";y&&(s.add(y),o.delete(y)),yield f(g)}else if(g.type==="tool_call_chunk"){if(g.id){let y=o.get(g.id)??{name:g.name,args:[]};g.name&&(y.name=g.name),g.args&&y.args.push(g.args),o.set(g.id,y)}}else if(g.type==="server_tool_call"){yield*u();let y=g.id??"";y&&(a.add(y),c.delete(y)),yield f(g)}else if(g.type==="server_tool_call_chunk"){if(g.id){let y=c.get(g.id)??{name:g.name,args:[]};g.name&&(y.name=g.name),g.args&&y.args.push(g.args),c.set(g.id,y)}}else if(g.type==="server_tool_call_result")yield*u(),yield v(g);else if(g.type!=="audio")if(g.type==="file"){let y=h(g);y&&l([y])}else if(g.type==="image"){let y=p(g);y&&l([y])}else if(g.type==="video"){let y=h(g);y&&l([y])}else g.type==="text-plain"?g.text&&l([{type:"input_text",text:g.text}]):g.type==="non_standard"&&t&&(yield*u(),yield g.value)}yield*u();for(let[g,y]of o){if(!g||s.has(g))continue;let w=y.args.join("");!y.name&&!w||(yield{type:"function_call",call_id:g,name:y.name??"",arguments:w})}for(let[g,y]of c){if(!g||a.has(g))continue;let w=y.args.join("");!y.name&&!w||(yield{type:"function_call",call_id:g,name:y.name??"",arguments:w})}}return Array.from(n())},F$=({messages:e,zdrEnabled:t,model:n})=>e.flatMap(r=>{let i=r.response_metadata;if(i?.output_version==="v1")return vW(r);let s=r.additional_kwargs,a=zu(r);if(a==="system"&&Lu(n)&&(a="developer"),a==="function")throw new Error("Function messages are not supported in Responses API");if(a==="tool"){let o=r;if(s?.type==="computer_call_output")return{type:"computer_call_output",output:(()=>{if(typeof o.content=="string")return{type:"input_image",image_url:o.content};if(Array.isArray(o.content)){let u=o.content.find(p=>p.type==="input_image");if(u)return u;let l=o.content.find(p=>p.type==="computer_screenshot");if(l)return l;let d=o.content.find(p=>p.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:o.tool_call_id};if(o.additional_kwargs?.customTool)return{type:"custom_tool_call_output",call_id:o.tool_call_id,output:o.content};let c=Array.isArray(o.content)&&o.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:o.tool_call_id,id:o.id?.startsWith("fc_")?o.id:void 0,output:c?o.content:typeof o.content!="string"?JSON.stringify(o.content):o.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 o=[],c=s?.reasoning,u=!!c?.encrypted_content;if(c&&(!t||u)){let m=yW(c);o.push(m)}let{content:l}=r;if(s?.refusal&&(typeof l=="string"&&(l=[{type:"output_text",text:l,annotations:[]}]),l=[...l,{type:"refusal",refusal:s.refusal}]),typeof l=="string"||l.length>0){let m={type:"message",role:"assistant",...r.id&&!t&&r.id.startsWith("msg_")?{id:r.id}:{},content:qr(()=>typeof l=="string"?l:l.flatMap(f=>{if(f.type==="text"){let v=f;return{type:"output_text",text:v.text,annotations:(v.annotations??[]).map(gW)}}return f.type==="output_text"||f.type==="refusal"?f:[]})),phase:qr(()=>{if(Array.isArray(l))return l.find(f=>"phase"in f&&typeof f.phase=="string")?.phase})};o.push(m)}let d=s?.[oh];Le.isInstance(r)&&r.tool_calls?.length?o.push(...r.tool_calls.map(m=>lK(m)?{type:"custom_tool_call",id:m.call_id,call_id:m.id??"",input:m.args.input,name:m.name}:uK(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]}})):s?.tool_calls&&o.push(...s.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 p=i?.output?.length?i?.output:s.tool_outputs,h=["computer_call","mcp_call","code_interpreter_call","image_generation_call","shell_call","local_shell_call"];if(p!=null){let m=p?.filter(f=>h.includes(f.type));m.length>0&&o.push(...m)}return o}if(a==="user"||a==="system"||a==="developer"){if(typeof r.content=="string")return{type:"message",role:a,content:r.content};let o=[],c=r.content.flatMap(u=>(u.type==="mcp_approval_response"&&o.push({type:"mcp_approval_response",approval_request_id:u.approval_request_id,approve:u.approve}),$r(u)?k_(u,s4):u.type==="text"?{type:"input_text",text:u.text}:u.type==="image_url"?{type:"input_image",image_url:qr(()=>{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:qr(()=>{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&&o.push({type:"message",role:a,content:c}),o}return console.warn(`Unsupported role found when converting to OpenAI Responses API: ${a}`),[]}),bW=class extends Z0{constructor(e,t){super(F0(e,t))}invocationParams(e){let t;e?.strict!==void 0&&(t=e.strict),t===void 0&&this.supportsStrictToolCalling!==void 0&&(t=this.supportsStrictToolCalling);let n={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:aK(e?.tool_choice)?e?.tool_choice:(()=>{let i=Qj(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},r=this._getReasoningParams(e);return r!==void 0&&(n.reasoning=r),n}async _generate(e,t,n){t.signal?.throwIfAborted();let r=this.invocationParams(t);if(r.stream){let i=this._streamResponseChunks(e,t,n),s;for await(let a of i)a.message.response_metadata={...a.generationInfo,...a.message.response_metadata},s=s?.concat(a)??a;return{generations:s?[s]:[],llmOutput:{estimatedTokenUsage:s?.message?.usage_metadata}}}else{let i=await this.completionWithRetry({input:F$({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),...r,stream:!1},{signal:t?.signal,...t?.options});return{generations:[{text:i.output_text,message:c4(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,n){let r=await this.completionWithRetry({...this.invocationParams(t),input:F$({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t);for await(let i of r){if(t.signal?.aborted)return;let s=_W(i);s!=null&&(yield s,await n?.handleLLMNewToken(s.text||"",{prompt:t.promptIndex??0,completion:0},void 0,void 0,void 0,{chunk:s}))}}async completionWithRetry(e,t){return this.caller.call(async()=>{let n=this._getClientOptions(t);try{return e.text?.format?.type==="json_schema"&&!e.stream?await this.client.responses.parse(e,n):await this.client.responses.create(e,n)}catch(r){throw Am(r)}})}_reduceChatOpenAITools(e,t){let n=[];for(let r of e)if(D0(r))r.type==="image_generation"&&t?.stream&&(r.partial_images=1),n.push(r);else if(sh(r)){let i=r.metadata.customTool;n.push({type:"custom",name:i.name,description:i.description,format:i.format})}else if(ob(r)){let i={};for(let[s,a]of Object.entries(r))s!=="type"&&s!=="function"&&(i[s]=a);n.push({type:"function",name:r.function.name,parameters:r.function.parameters,description:r.function.description,strict:t?.strict??null,...i})}else e4(r)&&n.push(dK(r));return n}},wW=class u4 extends Z0{useResponsesApi=!1;responses;completions;get lc_serializable_keys(){return[...super.lc_serializable_keys,"useResponsesApi"]}get callKeys(){return[...super.callKeys,"useResponsesApi"]}fields;constructor(t,n){let r=F0(t,n);super(r),this.fields=r,this.useResponsesApi=r?.useResponsesApi??!1,this.responses=r?.responses??new bW(r),this.completions=r?.completions??new fW(r)}_useResponsesApi(t){let n=t?.tools?.some(D0),r=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(e4)||t?.tools?.some(sh);return this.useResponsesApi||n||r||i||QV(this.model)}getLsParams(t){let n=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.getLsParams(n):this.completions.getLsParams(n)}invocationParams(t){let n=this._combineCallOptions(t);return this._useResponsesApi(t)?this.responses.invocationParams(n):this.completions.invocationParams(n)}async _generate(t,n,r){return this._useResponsesApi(n)?this.responses._generate(t,n,r):this.completions._generate(t,n,r)}async*_streamResponseChunks(t,n,r){if(this._useResponsesApi(n)){yield*this.responses._streamResponseChunks(t,this._combineCallOptions(n),r);return}yield*this.completions._streamResponseChunks(t,this._combineCallOptions(n),r)}withConfig(t){let n=new u4(this.fields);return n.defaultOptions={...this.defaultOptions,...t},n}},kW=class extends Zh{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 n=t?.apiKey??t?.openAIApiKey??bn("OPENAI_API_KEY");this.organization=t?.configuration?.organization??bn("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:n,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration}}async embedDocuments(e){let t=VN(this.stripNewLines?e.map(s=>s.replace(/\n/g," ")):e,this.batchSize),n=t.map(s=>{let a={model:this.model,input:s};return this.dimensions&&(a.dimensions=this.dimensions),this.encodingFormat&&(a.encoding_format=this.encodingFormat),this.embeddingWithRetry(a)}),r=await Promise.all(n),i=[];for(let s=0;s<r.length;s+=1){let a=t[s],{data:o}=r[s];for(let c=0;c<a.length;c+=1)i.push(o[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:n}=await this.embeddingWithRetry(t);return n[0].embedding}async embeddingWithRetry(e){if(!this.client){let n=Gj({baseURL:this.clientConfig.baseURL}),r={...this.clientConfig,baseURL:n,timeout:this.timeout,maxRetries:0};r.baseURL||delete r.baseURL,r.defaultHeaders=Xj(r.defaultHeaders),this.client=new fe(r)}let t={};return this.caller.call(async()=>{try{return await this.client.embeddings.create(e,t)}catch(n){throw Am(n)}})}},xW=Qe({type:bt("screenshot")}),$W=Qe({type:bt("click"),x:at(),y:at(),button:so(["left","right","wheel","back","forward"]).default("left")}),IW=Qe({type:bt("double_click"),x:at(),y:at(),button:so(["left","right","wheel","back","forward"]).default("left")}),SW=Qe({type:bt("drag"),path:vn(Qe({x:at(),y:at()}))}),OW=Qe({type:bt("keypress"),keys:vn(je())}),AW=Qe({type:bt("move"),x:at(),y:at()}),TW=Qe({type:bt("scroll"),x:at(),y:at(),scroll_x:at(),scroll_y:at()}),EW=Qe({type:bt("type"),text:je()}),CW=Qe({type:bt("wait"),duration:at().optional()}),NW=js([xW,$W,IW,SW,OW,AW,TW,EW,CW]);Qe({action:NW});var PW=Qe({type:bt("exec"),command:vn(je()),env:ym(je(),je()).optional(),working_directory:je().optional(),timeout_ms:at().optional(),user:je().optional()});js([PW]);Qe({commands:vn(je()).describe("Array of shell commands to execute"),timeout_ms:at().optional().describe("Optional timeout in milliseconds for the commands"),max_output_length:at().optional().describe("Optional maximum number of characters to return from each command")});var jW=Qe({type:bt("create_file"),path:je(),diff:je()}),RW=Qe({type:bt("update_file"),path:je(),diff:je()}),MW=Qe({type:bt("delete_file"),path:je()});js([jW,RW,MW]);var l4={advanced:"gpt-5.2",default:"gpt-5-mini",fast:"gpt-5.4-nano"},B0={default:"text-embedding-ada-002"},Vf=new Map,El=null,UW=()=>{let e=lh.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},d4=async e=>{let t=UW();Vf.size===0&&(El||(El=(async()=>{try{let r=await fetch(`${t}/models`);if(!r.ok)throw new Error("Failed to fetch AI service discovery data.");(await r.json()).models.forEach(i=>Vf.set(i.name,i))}catch(r){throw El=null,r}})()),await El);let n=Vf.get(e);if(!n)throw new Error(`Model '${e}' is not available in the discovery service.`);return n.endpoint},LW=async(e="default")=>await d4(l4[e]),zW=async(e="default")=>await d4(B0[e]),ch=(e,t)=>t,p4=(e,t)=>({...e,...t}),h4=(e="",t)=>{let n=typeof t=="string"?t.trim():"";if(!n)return e;let r=e.trim();if(!r)return n;if(r===n)return e;let i=r.split(`
|
|
405
|
+
|
|
406
|
+
`);return i[i.length-1]?.trim()===n?e:`${e}
|
|
407
|
+
|
|
408
|
+
${n}`},m4=()=>({userRequest:"",assignedTask:"",messages:[],priorSteps:[],sharedState:{}}),q0=()=>({agentExecutionContext:Ye({reducer:p4,default:m4}),outputMessage:Ye({reducer:h4,default:()=>""}),summary:Ye({reducer:ch,default:()=>""}),status:Ye({reducer:ch})});Ye.Root({agentExecutionContext:Ye({default:m4,reducer:p4}),currentIntent:Ye({default:()=>"none",reducer:ch}),requiresFollowUp:Ye({default:()=>!0,reducer:ch}),stepCount:Ye({default:()=>0,reducer:(e,t)=>t??e+1}),finalOutputMessage:Ye({default:()=>"",reducer:h4})});var Os=async(e,t)=>{await PH("trace_message",e,t)},f4=e=>async(t,n)=>{let r=new Headers(n?.headers);return r.delete("Authorization"),r.delete("api-key"),e&&e.length>0&&(r.set("X-Esri-Authorization",`Bearer ${e}`),r.set("X-Esri-Request-Source","MapsSDK")),await fetch(t,{...n,headers:r})},g4=async(e="default",t=0)=>{let n=lh.getDefault(),r=await B$.getCredential(`${n.url}/sharing`),i=l4[e],s=await LW(e);return new wW({modelName:i,apiKey:"dummy-key",...e!=="default"&&{temperature:t},configuration:{baseURL:s,fetch:f4(r.token)}})},DW=async(e="default")=>{let t=lh.getDefault(),n=await B$.getCredential(`${t.url}/sharing`),r=B0[e],i=await zW(e);return new kW({modelName:r,apiKey:"dummy-key",configuration:{baseURL:i,fetch:f4(n.token)},batchSize:2048,maxConcurrency:10})};Qe({id:je().min(1),name:je().min(1),description:je().min(1)});var FW=async e=>{try{return await(await DW()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},ZW="0.1",Io=1536,BW="openai",qW=B0.default,JW=`Name: {name}
|
|
409
|
+
Title: {title}
|
|
410
|
+
Description: {description}`,HW=`Name: {name}
|
|
411
|
+
Alias: {alias}
|
|
412
|
+
Description: {description}`;Qe({schemaVersion:bt(ZW),modified:at().int().nonnegative(),embeddings:Qe({modelProvider:bt(BW),model:bt(qW),dimensions:bt(Io),templates:Qe({layer:je().default(JW),field:je().default(HW)})}),layers:vn(Qe({id:je().min(1),name:je().min(1),title:je().catch(""),description:je().catch(""),vector:vn(at()).length(Io,{message:`Layer vector must be exactly ${Io} dimensions`}),fields:vn(Qe({name:je().min(1),alias:je().catch(""),description:je().catch(""),vector:vn(at()).length(Io,{message:`Field vector must be exactly ${Io} dimensions`})}))})).default([])});var y4=(e,t)=>{let n=yb.fromTemplate(e);return Wh.fromMessages([n,...t])},VW=async e=>{let{promptText:t,modelTier:n,temperature:r,messages:i}=e,s=y4(t,i??[]),a=await g4(n,r);return s.pipe(a)},KW=async e=>{let{promptText:t,modelTier:n="default",temperature:r=0,messages:i,inputVariables:s}=e,a=await(await VW({promptText:t,modelTier:n,temperature:r,messages:i})).invoke(s??{});if(typeof a=="string")return a;let o=a.content;return typeof o=="string"?o:JSON.stringify(o)},Tm=async e=>{let{promptText:t,modelTier:n="default",temperature:r=0,messages:i,inputVariables:s,schema:a}=e,o=y4(t,i??[]),c=(await g4(n,r)).withStructuredOutput(a);return await o.pipe(c).invoke(s??{})},WW=W.object({name:W.string(),description:W.string(),valueType:W.string(),alias:W.string()});W.object({fields:W.array(WW)});W.object({title:W.string(),description:W.string(),name:W.string().nullable()});var GW=(e,t)=>{if(e.length!==t.length)throw new Error("Vectors must be the same length");let n=0,r=0,i=0;for(let o=0;o<e.length;++o){let c=e[o],u=t[o];n+=c*u,r+=c*c,i+=u*u}let s=Math.sqrt(r*i);if(s===0)return 0;let a=n/s;return Math.max(-1,Math.min(1,a))};async function Fi(e,t){let n=Object.entries(e).find(([r])=>r.endsWith(`/${t}.md`));if(!n)throw new Error(`Prompt not found: ${t}
|
|
413
|
+
Available prompts:
|
|
414
|
+
${Object.keys(e).join(`
|
|
415
|
+
`)}`);return await n[1]()}function J0(e){return e?.configurable?.context?.translations}function _4(e){if(typeof window>"u"||e.length<=1)return;let t=e.map(r=>r.solution.id),n=e.map(r=>r.solution.title);window.dispatchEvent(new CustomEvent("searchTermSet",{detail:{scope:"all-solutions",searchTerm:""}})),window.dispatchEvent(new CustomEvent("solutionMatchesFromAssistant",{detail:{solutionIds:t,solutionTitles:n},bubbles:!0,composed:!0})),window.dispatchEvent(new CustomEvent("navTabSelected",{detail:{tabType:"all-solutions"}}))}function v4(e){if(typeof window>"u"||!e)return;let t=new CustomEvent("solutionIDFromAssistant",{detail:e,bubbles:!0,composed:!0});window.dispatchEvent(t)}var b4=e=>{if(e&&Array.isArray(e.id)&&e.id.length>0)return e.id[e.id.length-1].replace("Message","").toLowerCase();if(e&&typeof e._getType=="function")try{return e._getType()}catch{return"human"}return"human"},XW=e=>{let t=b4(e);if(e&&e.kwargs)return{role:t,...e.kwargs};if(e&&typeof e=="object"){let n={role:t,content:typeof e.content=="string"?e.content:String(e.content||"")};return e.id&&(n.id=e.id),e.name&&(n.name=e.name),e.additional_kwargs&&(n.additional_kwargs=e.additional_kwargs),e.response_metadata&&(n.response_metadata=e.response_metadata),n}return{role:"human",content:String(e)}},YW=e=>b4(e)==="human",QW=(e,t=3)=>{let n=e.map((i,s)=>YW(i)?s:-1).filter(i=>i!==-1);if(n.length===0)return[];let r=n.length>t?n[n.length-t]:n[0];return e.slice(r).map(XW)},w4=Object.assign({"./prompts/solutions_assistant_description.md":()=>import("./JQLLXM7G.js").then(e=>e.default),"./prompts/solutions_assistant_prompts.md":()=>import("./JMO7ZFWL.js").then(e=>e.default)}),k4=Ye.Root({...q0()}),e7=async(e,t)=>{let n=J0(t);await Os({text:n?.executingSolutionsAssistantAgent||"Preparing a response..."},t);let r=await Fi(w4,"solutions_assistant_prompts"),i=e.agentExecutionContext.messages.slice(-10),s=await KW({promptText:r,modelTier:"default",temperature:.7,messages:QW(i)}),a=t?.configurable?.context?.clearSuggestedPrompts;return a&&a(),{outputMessage:s,summary:s,status:"success"}},t7=()=>new A0(k4).addNode("assistantLLM",e7).addEdge(_t,"assistantLLM").addEdge("assistantLLM",dt),n7=await Fi(w4,"solutions_assistant_description"),r7={id:"solutionsAssistant",name:"Solutions Assistant Agent",description:n7,createGraph:t7,workspace:k4};function i7(e,t,n){let r=["params","httpMethod","rawResponse","authentication","hideToken","portal","credentials","maxUrlLength","headers","signal","suppressWarnings","request"],i=Object.assign(Object.assign({params:{}},n),e);return i.params=t.reduce((s,a)=>((e[a]||typeof e[a]=="boolean"||typeof e[a]=="number"&&e[a]===0)&&(s[a]=e[a]),s),i.params),r.reduce((s,a)=>(i[a]&&(s[a]=i[a]),s),{})}var Go=class e{constructor(t=""){this.termStack=[],this.rangeStack=[],this.openGroups=0,this.q=t}match(...t){return this.termStack=this.termStack.concat(t),this}in(t){let n=`\`in(${t?`"${t}"`:""})\``;return!this.hasRange&&!this.hasTerms?(Er(`${n} was called with no call to \`match(...)\` or \`from(...)\`/\`to(...)\`. Your query was not modified.`),this):(t&&t!=="*"&&(this.q+=`${t}:`),this.commit())}startGroup(){return this.commit(),this.openGroups>0&&(this.q+=" "),this.openGroups++,this.q+="(",this}endGroup(){return this.openGroups<=0?(Er("`endGroup(...)` was called without calling `startGroup(...)` first. Your query was not modified."),this):(this.commit(),this.openGroups--,this.q+=")",this)}and(){return this.addModifier("and")}or(){return this.addModifier("or")}not(){return this.addModifier("not")}from(t){return this.hasTerms?(Er('`from(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'),this):(this.rangeStack[0]=t,this)}to(t){return this.hasTerms?(Er('`to(...)` is not allowed after `match(...)` try using `.from(...).to(...).in(...)`. Optionally, you may see this because dates are incorrectly formatted. Dates should be a primative Date value, aka a number in milliseconds or Date object, ie new Date("2020-01-01"). Your query was not modified.'),this):(this.rangeStack[1]=t,this)}boost(t){return this.commit(),this.q+=`^${t}`,this}toParam(){return this.commit(),this.cleanup(),this.q}clone(){return this.commit(),this.cleanup(),new e(this.q+"")}addModifier(t){return this.currentModifer?(Er(`You have called \`${this.currentModifer}()\` after \`${t}()\`. Your current query was not modified.`),this):(this.commit(),this.q===""&&t!=="not"?(Er(`You have called \`${t}()\` without calling another method to modify your query first. Try calling \`match()\` first.`),this):(this.currentModifer=t,this.q+=this.q===""?"":" ",this.q+=`${t.toUpperCase()} `,this))}hasWhiteSpace(t){return/\s/g.test(t)}formatTerm(t){return t instanceof Date?t.getTime():typeof t=="string"&&this.hasWhiteSpace(t)?`"${t}"`:t}commit(){return this.currentModifer=void 0,this.hasRange&&(this.q+=`[${this.formatTerm(this.rangeStack[0])} TO ${this.formatTerm(this.rangeStack[1])}]`,this.rangeStack=[void 0,void 0]),this.hasTerms&&(this.q+=this.termStack.map(t=>this.formatTerm(t)).join(" "),this.termStack=[]),this}get hasTerms(){return this.termStack.length>0}get hasRange(){return this.rangeStack.length&&this.rangeStack[0]&&this.rangeStack[1]}cleanup(){if(this.openGroups>0)for(Er(`Automatically closing ${this.openGroups} group(s). You can use \`endGroup(...)\` to remove this warning.`);this.openGroups>0;)this.q+=")",this.openGroups--;let t=this.q;this.q=t.replace(/( AND ?| NOT ?| OR ?)*$/,""),t!==this.q&&Er("`startGroup(...)` was called without calling `endGroup(...)` first. Your query was not modified."),this.q=this.q.replace(/(\(\))*/,"")}};function x4(e,t){let n;typeof e=="string"||e instanceof Go?n={httpMethod:"GET",params:{q:e}}:n=i7(e,["q","num","start","sortField","sortOrder","searchUserAccess","searchUserName","filter","countFields","countSize","categories","categoryFilters"],{httpMethod:"GET"});let r;switch(t){case"item":r="/search";break;case"group":r="/community/groups";break;case"groupContent":if(typeof e!="string"&&!(e instanceof Go)&&e.groupId)r=`/content/groups/${e.groupId}/search`;else return Promise.reject(new Error("you must pass a `groupId` option to `searchGroupContent`"));break;case"communityUser":r="/community/users";break;default:r="/portals/self/users/search";break}let i=hw(n)+r;return pw(i,n).then(s=>(s.nextStart&&s.nextStart!==-1&&(s.nextPage=function(){let a;return typeof e=="string"||e instanceof Go?a={q:e,start:s.nextStart}:(a=e,a.start=s.nextStart),x4(a,t)}),s))}function $4(e){return x4(e,"item")}var s7={understandingRequest:"Understanding your request...",selectTemplatePrompt:"This use case could be supported in a few different ways. Choose the option that best matches what you want to accomplish.",searchingExistingSolutions:"Searching for existing solutions...",existingSolutionMatch:"I found an existing solution that closely matches your use case and may already meet your needs: {{solutionMatch}}. Do you want to continue building your solution?",creatingDesign:"Generating solution design...",updatingDesign:"Updating solution design...",applyChangeFailed:"I wasn't able to apply that change. The design was not modified. Please try rephrasing your request.",createDesignFailed:"I wasn't able to create a solution design from that request. Please try rephrasing and try again."},a7={builderMessages:s7},o7=new Set(["add","all","alter","and","any","as","asc","backup","between","by","case","check","column","constraint","create","database","date","default","delete","desc","distinct","drop","exec","exists","foreign","from","full","group","having","in","index","inner","insert","into","is","join","key","left","like","limit","not","null","on","or","order","outer","primary","procedure","right","rownum","select","set","table","top","truncate","union","unique","update","values","view","where"]),uh=class{constructor(t,n){this.isValid=!0,this.issues=[],this.response=t,this.template=n,this.validate()}validate(){this.compareModels(),this.validateResponse()}compareModels(){this.compareStrings(),this.compareItems(),this.compareFeatureLayers()}compareStrings(){let t=new Set(this.template.solution.strings.map(r=>r.key)),n=new Set(this.response.solution.strings.map(r=>r.key));(t.size!==n.size||[...t].some(r=>!n.has(r)))&&this.logIssue("String keys in llm response do not match the template.");for(let r of this.response.solution.strings)r.value||this.logIssue(`String key '${r.key}' has no value.`)}compareItems(){let t=new Set(this.template.items.map(r=>r.id)),n=new Set(this.response.items.map(r=>r.id));(t.size!==n.size||[...t].some(r=>!n.has(r)))&&this.logIssue("Item ids in llm response do not match the template.")}compareFeatureLayers(){let t=this.template.featureLayer,n=this.response.featureLayer;if(t.itemId!==n.itemId){this.logIssue(`Feature Layer itemId '${n.itemId}' does not match template '${t.itemId}'.`);return}if(!t.addLayers){let r=new Set(t.layers.map(s=>s.id)),i=new Set(n.layers.map(s=>s.id));(r.size!==i.size||[...r].some(s=>!i.has(s)))&&this.logIssue(`Feature Layer '${t.itemId}' had its layer ids altered.`)}}validateResponse(){let t=this.template.featureLayer.layers,n=this.response.featureLayer.layers.map(r=>r.name.toLowerCase());n.length!==new Set(n).size&&this.logIssue("Layer names must be unique (case-insensitive).");for(let r of this.response.featureLayer.layers){this.validateLayer(r);let i=t.find(s=>s.id===r.id);i&&this.validateRequiredFields(r,i)}}validateRequiredFields(t,n){let r=new Set(t.requiredFields.map(i=>i.name));for(let i of n.requiredFields)r.has(i.name)||this.logIssue(`Layer '${t.name}' is missing required field '${i.name}'.`)}validateLayer(t){let n=new Set(["objectid","globalid","created_date","created_user","last_edited_date","last_edited_user"]),r=t.systemFields??[];if(r.length){let s=new Set(r.map(a=>a.name));(s.size!==n.size||[...n].some(a=>!s.has(a)))&&this.logIssue(`Layer '${t.name}' has invalid system fields: ${JSON.stringify([...s])}.`)}let i=[...t.customFields,...t.requiredFields,...r].map(s=>s.name);i.length!==new Set(i).size&&this.logIssue(`Layer '${t.name}' has duplicate fields: ${JSON.stringify(i)}.`);for(let s of[...t.customFields,...t.requiredFields,...r])this.validateField(s)}validateField(t){if(t.alias||this.logIssue(`Field '${t.name}' has no display name (alias).`),/^[A-Za-z]/u.test(t.name)||this.logIssue(`Field '${t.name}' does not start with a letter.`),/^[A-Za-z][A-Za-z0-9_]*$/u.test(t.name)||this.logIssue(`Field '${t.name}' contains invalid characters (only letters, numbers, and underscores allowed).`),t.name.length>31&&this.logIssue(`Field '${t.name}' exceeds 31 characters.`),o7.has(t.name.toLowerCase())&&this.logIssue(`Field '${t.name}' is a SQL reserved keyword.`),t.choiceList&&(t.choiceList.some(n=>!n)&&this.logIssue(`Field '${t.name}' has empty domain values.`),t.choiceList.length!==new Set(t.choiceList).size&&this.logIssue(`Field '${t.name}' has duplicate domain values.`),t.length!=null)){let n=Math.max(...t.choiceList.map(r=>r.length));n>t.length&&(console.debug(`Field '${t.name}' length ${t.length} is insufficient for choiceList value of length ${n}. Auto-fixing to ${n}.`),t.length=n)}}logIssue(t){console.debug(t),this.issues.push(t),this.isValid=!1}},c7=W.object({key:W.string().describe("Stable key identifier for the string."),value:W.string().describe("Display value for the string."),description:W.string().describe("Explanation of where/how the string is used.")}),u7=W.object({id:W.string().describe("ArcGIS item id (32 hex characters)."),title:W.string().describe("Item title."),description:W.string().describe("Item description."),type:W.enum(["Feature Layer (hosted)","Feature Layer (hosted, view)","Web Map","Instant App","Dashboard","Web Experience","Form","Table (hosted)","Table (hosted, view)","Hub Site Application","Hub Page","CSV","Data Pipeline","Desktop Application Template","Group","Notebook","QuickCapture Project"]).describe("ArcGIS item type.")}),Z$=W.object({name:W.string().describe("Field name."),type:W.enum(["string","integer","double","date","oid","guid","globalid"]).describe("Field data type."),alias:W.string().describe("Field alias for display."),description:W.string().describe("Field description."),choiceList:W.array(W.string()).nullable().describe("List of allowed values for string fields with a controlled vocabulary. Null if unrestricted or not applicable."),length:W.number().int().nullable().describe("Maximum string length for string fields. Null for non-string fields.")}),l7=W.object({id:W.number().int().describe("Layer/table id within the feature service."),type:W.enum(["Point","Polyline","Polygon","Table"]).describe("Layer type."),name:W.string().describe("Layer/table name."),description:W.string().describe("Layer/table description."),customFields:W.array(Z$).describe("User/business fields specific to the solution."),requiredFields:W.array(Z$).describe("Fields required for solution functionality (e.g., relationship keys).")}),d7=W.object({itemId:W.string().describe("ArcGIS item id for the feature layer."),addLayers:W.boolean().describe("Indicates whether new layers can be added during solution design."),layers:W.array(l7)}),H0=W.object({response:W.string().describe("Conversational response to the user's query."),solution:W.object({itemId:W.string().nullable().describe("ArcGIS item id of the source Solution template used for deployment. Preserve the existing value exactly when known; otherwise use null."),title:W.string().describe("Title of the solution."),description:W.string().describe("Description of the solution."),tags:W.array(W.string()).describe("Keywords/tags associated with the solution."),strings:W.array(c7).describe("Localized strings/labels used by apps (dashboards, forms, etc.).")}),items:W.array(u7).describe("ArcGIS items that belong to the solution (apps, maps, layers, etc.)."),featureLayer:d7.describe("Primary feature layer item and its schema/layers/tables details.")}),p7=W.object({op:W.enum(["add","remove","replace","move","copy"]).describe("RFC 6902 operation type."),path:W.string().describe("RFC 6901 JSON Pointer to the target location."),value:W.string().nullable().describe(`JSON-encoded value to apply (required for add and replace). Must be null \u2014 not an empty string \u2014 for remove, move, and copy operations. Serialize as a JSON string, e.g. '\\"text\\"' for a string, '[\\"a\\",\\"b\\"]' for an array, or '{\\"name\\":\\"x\\"}' for an object.`),from:W.string().nullable().describe("RFC 6901 JSON Pointer to the source location (required for move and copy). Must be null \u2014 not an empty string \u2014 for all other operations.")}),h7=W.object({response:W.string().describe("Conversational response describing the accepted design changes."),patches:W.array(p7).describe("Minimal RFC 6902 patch operations needed to update the current design.")}),m7=W.object({matchedTitles:W.array(W.string()).describe("Titles of solutions that match the user's request. Empty array if no strong match.")}),f7=W.object({templateId:W.string().min(1).describe("Template id from the available template list."),confidence:W.number().min(0).max(1).describe("Confidence score from 0 to 1 for this template match."),templateDescription:W.string().min(1).describe("Short description this template in the user's use case/workflow.")}),g7=W.object({assistantResponse:W.string().describe("Natural-language response for the user."),isValidUseCase:W.boolean().describe("True only when the request is concrete, appropriate, and has at least one matching template."),matchedTemplates:W.array(f7).describe("Ordered list of matching templates, best match first. Empty when no valid match exists.")}),V0=e=>e in Ls,y7=5,_7=.8,v7=.15,b7="Web Mapping Application",w7="Embeddings",Cl=null,Kf=null,Nl=null,Pl=null,k7="Build",Du=Object.assign({"./prompts/description.md":()=>import("./GYL4W6ZG.js").then(e=>e.default),"./prompts/designSolution.md":()=>import("./ZUDEZGGC.js").then(e=>e.default),"./prompts/findExistingSolution.md":()=>import("./PRXFYNIG.js").then(e=>e.default),"./prompts/initialAssessment.md":()=>import("./SXVCHOTK.js").then(e=>e.default),"./prompts/updateDesign.md":()=>import("./NSKVOAA7.js").then(e=>e.default)}),x7=a7.builderMessages,Cn=(e,t,n)=>{let r=J0(t)?.builderMessages?.[e]??x7[e];if(!n)return r;for(let[i,s]of Object.entries(n))r=r.replaceAll(`{{${i}}}`,s);return r},I4=e=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("arcgis-solution-design-update",{detail:e}))},$7=async(e,t,n)=>{if(!e)return null;let r=`type:"${b7}" AND typekeywords:${w7} AND group:${e}`;return(await $4({q:r,params:t?{token:t}:void 0,portal:n,num:1}))?.results?.[0]??null};async function I7(e,t,n){try{let r=await $7(e,t,n);if(!r)return null;let i=new X4({id:r.id});return await i.load(),await i.fetchData("json")}catch{return null}}var S7=async(e,t,n)=>{if(!e)return[];let r=`type:Solution AND typekeywords:${k7} AND group:${e}`;return(await $4({q:r,params:t?{token:t}:void 0,portal:n,num:100}))?.results??[]},O7=async(e,t,n)=>{try{return(await mw(e,{params:t?{token:t}:void 0,portal:n}))?.buildSolution??null}catch{return null}},As=(e,t={})=>{let n=e;return"itemId"in t&&(n={...n,solution:{...n.solution,itemId:t.itemId??null}}),t.sourceBuildSolution!=null&&(n={...n,sourceBuildSolution:t.sourceBuildSolution}),"templateId"in t&&(n={...n,templateId:t.templateId??null}),n},S4=(e,t)=>{if(e==null||t==null)return{ok:!1,error:"design or sourceBuildSolution is null/undefined"};try{let n=structuredClone(t);return new Pm({buildSolution:n}).applyLlmTemplate(e),{ok:!0}}catch(n){return{ok:!1,error:n instanceof Error?n.stack??n.message:String(n)}}},K0=async e=>{if(Kf){Object.entries(Kf).forEach(([a,o])=>{Ls[a]&&(Ls[a].initialTemplate=o)});return}let t=e?.configurable?.context?.token,n=A4(e),r=T4(e);if(!n){console.warn("Solution Builder: missing primarySolutionsGroupId in appConfig; skipping live template hydration.");return}let i=await S7(n,t,r),s={};await Promise.all(i.map(async a=>{let o=a.properties?.templateInfo;if(!o||typeof o!="object")return;let c=o.id;if(typeof c!="string"||s[c])return;let u=await O7(a.id,t,r);if(!u)return;let l={...o,buildSolution:u};s[c]=As(new Pm(l).dumpToLlmTemplate(),{itemId:a.id,sourceBuildSolution:structuredClone(u)}),Ls[c]={...o,initialTemplate:s[c]}})),Kf=s},O4=e=>{let t=e?.configurable?.context?.token;return typeof t!="string"||!t.trim()?null:t},A4=e=>{let t=e?.configurable?.context?.configContext?.primarySolutionsGroupId;return typeof t!="string"||!t.trim()?null:t},T4=e=>{let t=e?.configurable?.context?.configContext?.portalURL;if(!(typeof t!="string"||!t.trim()))return`${t.replace(/\/+$/,"")}/sharing/rest`},A7=async e=>{await Promise.all([C4(e),K0(e)])},E4=async e=>{let t=O4(e);(!Nl||t&&t!==Pl)&&(Pl=t??Pl,Nl=A7(e).catch(n=>{throw Nl=null,Pl=null,n})),await Nl};async function C4(e){if(Cl)return Cl;let t=A4(e);if(!t)return console.warn("Solution Builder: missing primarySolutionsGroupId in appConfig; skipping embeddings load."),null;let n=T4(e),r=e?.configurable?.context?.configContext?.portalURL;await new lh(r?{url:r}:void 0).load();let i=O4(e)??void 0,s=await I7(t,i,n);return s?(Cl=s.items,Cl):null}var T7=()=>Object.entries(Ls).map(([e,t])=>`ID: ${e}
|
|
416
|
+
Label: ${t.label}
|
|
417
|
+
Description: ${t.description}`).join(`
|
|
418
|
+
|
|
419
|
+
`),E7=e=>{let t=e?.configurable?.context?.solutionDesignJson;if(typeof t!="string"||!t.trim())return null;try{let n=JSON.parse(t),r=As({response:"",...n},{itemId:n?.solution?.itemId??null}),i=H0.safeParse(r);if(!i.success)return null;let{response:s,...a}=i.data,o=n.templateId,c=typeof o=="string"&&V0(o)?o:null;return As(a,{sourceBuildSolution:n.sourceBuildSolution,templateId:c})}catch{return null}},N4=Ye.Root({...q0(),templateDescription:Ye({reducer:(e,t)=>typeof t=="string"||t===null?t:e??null,default:()=>null}),currentDesign:Ye({reducer:(e=null,t)=>t===void 0?e:t??null,default:()=>null}),assessment:Ye({reducer:(e=null,t)=>t===void 0?e:t??null,default:()=>null}),selectedTemplate:Ye({reducer:(e=null,t)=>t===void 0?e:t??null,default:()=>null}),existingMatches:Ye({reducer:(e=[],t)=>t===void 0?e:t??[],default:()=>[]})}),C7=(e,t)=>{let n=E7(t),r=n?.templateId??null,i={};return JSON.stringify(e.currentDesign)!==JSON.stringify(n)&&(i.currentDesign=n),r&&e.selectedTemplate!==r&&(i.selectedTemplate=r),i},N7=async(e,t)=>{await E4(t);let n=e.agentExecutionContext.userRequest;await Os({text:Cn("understandingRequest",t)},t);let r=T7(),i=await Tm({promptText:await Fi(Du,"initialAssessment"),modelTier:"advanced",temperature:0,schema:g7,inputVariables:{query:n,availableTemplates:r}}),s=i.matchedTemplates.filter(l=>V0(l.templateId)),a={...i,matchedTemplates:s},[o,c]=s,u=o&&o.confidence>=_7&&(c===void 0||o.confidence-c.confidence>=v7)?o.templateId:null;return{assessment:a,selectedTemplate:u,existingMatches:[]}},P7=e=>{let t=e.assessment?.assistantResponse??"";return{outputMessage:t,summary:t,status:"success"}},j7=(e,t)=>{let{hitlResponse:n}=t.configurable,r="selectTemplate",i=e.assessment?.matchedTemplates.filter(c=>V0(c.templateId))??[],s=i.map(c=>`${c.templateDescription}`);if(n?.agentId!=="solutionBuilder"||n.id!==r){let c={agentId:"solutionBuilder",id:r,kind:"singleSelection",message:Cn("selectTemplatePrompt",t),metadata:[...s]};throw new hh(c)}let a=String(n.payload??""),o=s.findIndex(c=>c===a);return{selectedTemplate:(o>=0?i[o]:void 0)?.templateId??i[0]?.templateId??null}},R7=async(e,t)=>{await Os({text:Cn("searchingExistingSolutions",t)},t);let n=e.agentExecutionContext.userRequest,r=await C4(t);if(!r)return console.warn("Solutions Search: failed to load solution embeddings cache; skipping search."),{existingMatches:[]};if(!r.length)return{existingMatches:[]};let[i]=await FW([n]),s=r.map(c=>({solution:c,score:GW(i,c.embedding)}));s.sort((c,u)=>u.score-c.score);let a=s.slice(0,y7);if(!a.length)return{existingMatches:[]};let o=a.map(({solution:c})=>`${c.title}
|
|
420
|
+
Snippet: ${c.snippet}
|
|
421
|
+
Description: ${c.description}`).join(`
|
|
422
|
+
|
|
423
|
+
`);return{existingMatches:(await Tm({promptText:await Fi(Du,"findExistingSolution"),modelTier:"advanced",temperature:0,schema:m7,inputVariables:{query:n,candidates:o}})).matchedTitles.map(c=>a.find(({solution:u})=>u.title===c)).filter(c=>c!==void 0)}},M7=(e,t)=>{let{existingMatches:n}=e,{hitlResponse:r}=t.configurable,i=`confirmExistingSolution:${n[0].solution.id}`;if(r?.agentId!=="solutionBuilder"||r.id!==i){n.length===1?v4(n[0].solution.id):_4(n);let s=n.map(c=>`${c.solution.title}`).join(", "),a=Cn("existingSolutionMatch",t,{solutionMatch:s}),o={agentId:"solutionBuilder",id:i,kind:"booleanChoice",message:a,metadata:[]};throw new hh(o)}return{}},P4=async(e,t)=>{await E4(t);let{currentDesign:n}=e,r=e.agentExecutionContext.userRequest;await Os({text:Cn("creatingDesign",t)},t);let i=lo(e.selectedTemplate);if(i?.initialTemplate||(await K0(t),i=lo(e.selectedTemplate)),!i?.initialTemplate)throw new Error("No hydrated templates are available for solution design.");let s=As(n??i.initialTemplate,{itemId:(n??i.initialTemplate)?.solution?.itemId??null,sourceBuildSolution:n?.sourceBuildSolution??i.initialTemplate.sourceBuildSolution}),a=await Tm({promptText:await Fi(Du,"designSolution"),modelTier:"advanced",temperature:0,schema:H0,inputVariables:{currentDesign:JSON.stringify(jm(s)),templateInstructions:i.instructions,query:r}}),{response:o,featureLayer:c,...u}=a,l=Rm(c,s.featureLayer),d=As({...u,featureLayer:l},{itemId:s?.solution?.itemId,sourceBuildSolution:s.sourceBuildSolution,templateId:e.selectedTemplate??null}),p=new uh(d,i.initialTemplate);if(!p.isValid)return console.warn("[SolutionBuilder] designSolution validation failed:",{issues:p.issues,llmResponse:a}),{outputMessage:Cn("createDesignFailed",t)};let h=d.sourceBuildSolution,m=S4(d,h);if(!m.ok){console.warn("[SolutionBuilder] designSolution Esri JSON conversion failed:",{error:m.error,llmResponse:a,design:d});let f=Cn("createDesignFailed",t);return{outputMessage:f,summary:f,status:"success"}}return I4(d),{outputMessage:o,summary:o,status:"success",currentDesign:d}},U7=async(e,t)=>{let{currentDesign:n}=e;if(!n)return P4(e,t);let r=e.agentExecutionContext.userRequest;await Os({text:Cn("updatingDesign",t)},t);let i=await Tm({promptText:await Fi(Du,"updateDesign"),modelTier:"advanced",temperature:0,schema:h7,inputVariables:{currentDesign:JSON.stringify(fw(n)),query:r}}),{response:s,patches:a}=i,o=[...a.map(x=>({op:x.op,path:x.path.replace(/\/+$/,""),...x.value!=null&&x.value!==""?{value:JSON.parse(x.value)}:{},...x.from!=null&&x.from!==""?{from:x.from}:{}}))].sort((x,O)=>x.op!=="remove"||O.op!=="remove"?0:O.path.localeCompare(x.path,void 0,{numeric:!0})),c=structuredClone(jm(n));try{Ds(c,o,!0)}catch(x){console.warn("[SolutionBuilder] updateDesign JSON patch failed:",{error:x,llmResponse:i,patches:o,patchTarget:c});let O=Cn("applyChangeFailed",t);return{outputMessage:O,summary:O,status:"success"}}let u=As({response:"",...c},{itemId:n.solution?.itemId??null}),l=H0.safeParse(u);if(!l.success){console.warn("[SolutionBuilder] updateDesign schema validation failed:",{errors:l.error.issues,llmResponse:i,patchedDesign:u});let x=Cn("applyChangeFailed",t);return{outputMessage:x,summary:x,status:"success"}}let{response:d,featureLayer:p,...h}=l.data,m=Rm(p,n.featureLayer),f=As({...h,featureLayer:m},{itemId:n.solution?.itemId,sourceBuildSolution:n.sourceBuildSolution,templateId:n.templateId??e.selectedTemplate??null}),v=lo(e.selectedTemplate);if(v?.initialTemplate||(await K0(t),v=lo(e.selectedTemplate)),!v?.initialTemplate)throw new Error("No hydrated templates are available for solution design.");let g=new uh(f,v.initialTemplate);if(!g.isValid)return console.warn("[SolutionBuilder] updateDesign validation failed:",{issues:g.issues,llmResponse:i,patchedDesign:f}),{outputMessage:Cn("applyChangeFailed",t)};let y=f.sourceBuildSolution,w=S4(f,y);if(!w.ok){console.warn("[SolutionBuilder] updateDesign Esri JSON conversion failed:",{error:w.error,llmResponse:i,design:f});let x=Cn("applyChangeFailed",t);return{outputMessage:x,summary:x,status:"success"}}return I4(f),{outputMessage:s,summary:s,status:"success",currentDesign:f}},L7=e=>e.currentDesign!==null?"updateDesign":"assessInitialRequest",z7=e=>!e.assessment||!e.assessment.isValidUseCase?"invalidUseCaseExit":!e.selectedTemplate&&e.assessment.matchedTemplates.length>1?"selectTemplateHIL":"findExistingSolutions",D7=e=>e.existingMatches.length>0?"confirmContinueBuildingHIL":"designSolution",F7=()=>new A0(N4).addNode("syncCurrentDesignFromContext",C7).addNode("assessInitialRequest",N7).addNode("invalidUseCaseExit",P7).addNode("selectTemplateHIL",j7).addNode("findExistingSolutions",R7).addNode("confirmContinueBuildingHIL",M7).addNode("designSolution",P4).addNode("updateDesign",U7).addEdge(_t,"syncCurrentDesignFromContext").addConditionalEdges("syncCurrentDesignFromContext",L7,{updateDesign:"updateDesign",assessInitialRequest:"assessInitialRequest"}).addConditionalEdges("assessInitialRequest",z7,{invalidUseCaseExit:"invalidUseCaseExit",selectTemplateHIL:"selectTemplateHIL",findExistingSolutions:"findExistingSolutions"}).addEdge("invalidUseCaseExit",dt).addEdge("selectTemplateHIL","findExistingSolutions").addConditionalEdges("findExistingSolutions",D7,{confirmContinueBuildingHIL:"confirmContinueBuildingHIL",designSolution:"designSolution"}).addEdge("confirmContinueBuildingHIL","designSolution").addEdge("designSolution",dt).addEdge("updateDesign",dt),Z7=await Fi(Du,"description"),B7={id:"solutionsBuilder",name:"Solutions Builder Agent",description:Z7,createGraph:F7,workspace:N4},q7=Object.assign({"./prompts/solutions_explorer_description.md":()=>import("./MZXUUA7G.js").then(e=>e.default)});function J7(e){return e.replace(/<sup>\[\[(\d+)\]\]\(([^)]+)\)<\/sup>/g,'<sup><a href="$2">[$1]</a></sup>')}function H7(e,t){let n=[];return(t?.configurable?.context?.configContext.allCards??[]).forEach(r=>{let i=r.title;if(e.toLowerCase().includes(i.toLowerCase())){let s=`<a href="" target="solutionId:${r.deployCommonId}">${i}</a>`,a=new RegExp(i,"gi");e=e.replace(a,s),n.push({solution:{title:r.title,id:r.deployCommonId,snippet:r.snippet,description:r.description},score:100})}}),{source:e,allMatches:n}}function V7(e){return e&&e.helperServices.aiAssistantServices?`${e.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/chat`:null}function j4(e){return e&&e.helperServices.aiAssistantServices?`${e.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/api/pre-chat`:null}async function d_(e,t,n){let r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",token:n},body:JSON.stringify(e)});if(!r.ok)throw new Error(`HTTP ${r.status} calling ${t}`);return r.json()}var K7=e=>new Promise(t=>setTimeout(t,e)),R4=Ye.Root({...q0(),solutionResponse:Ye({reducer:(e,t)=>t??null,default:()=>null}),documentSkillUrl:Ye({reducer:(e,t)=>t??null,default:()=>null}),conversationId:Ye({reducer:(e,t)=>t??e,default:()=>null})}),W7=()=>new A0(R4).addNode("initializeAgent",X7).addNode("askSolutionsQuestions",G7).addEdge(_t,"initializeAgent").addEdge("initializeAgent","askSolutionsQuestions").addEdge("askSolutionsQuestions",dt),M4=async(e,t,n)=>{if(!e)return;let r=j4(e);if(!r)return;let i={context:{kind:"DocAIAssistantRequest",filters:{products:"ArcGIS Solutions",persona:{persona:"solutions"}}}};n&&(i.conversationId=n),d_(i,r,t??"")},G7=async(e,t)=>{let n=J0(t),r=e.documentSkillUrl,i=[];await Os({text:n.agentProgress.explorerAgentSearching},t);let s=await d_({message:e.agentExecutionContext.userRequest,conversationId:t?.configurable?.context?.convoId??void 0,context:{kind:"DocAIAssistantRequest",filters:{products:"ArcGIS Solutions",persona:{persona:"solutions"}}}},r,t?.configurable?.context?.token??"");s.conversationId&&t?.configurable?.context?.setConversationId&&t.configurable.context.setConversationId(s.conversationId);let a={message:s.message,conversationId:s.conversationId,hasMore:s.hasMore,ackSequenceNumber:s.sequenceNumber,inquiryId:s.inquiryId},o="",c=null,u=async l=>{let d=l.context?.results?.[0]?.reply??"";if(d!==""){let h=J7(d),m=H7(h,t);o=m.source,i=[...i,...m.allMatches.filter(f=>!i.some(v=>v.solution.id===f.solution.id))]}d!==""&&l.context?.results?.[0]?.followupQuestions&&(c=l.context.results[0].followupQuestions);let p=l.context?.results?.[0]?.status?.currentStatusStep;if(p){let h="";p===1?h=n.agentProgress.explorerAgentReading:p===2?h=n.agentProgress.explorerAgentReviewing:p===3&&(h=n.agentProgress.explorerAgentPreparing),await Os({text:h},t)}};for(await u(s);a.hasMore;)await K7(500),s=await d_({conversationId:a.conversationId,ackSequenceNumber:a.ackSequenceNumber,inquiryId:a.inquiryId},r,t?.configurable?.context?.token??""),a={message:s.message,conversationId:s.conversationId,hasMore:s.hasMore,ackSequenceNumber:s.sequenceNumber,inquiryId:s.inquiryId},await u(s);if(c&&t?.configurable?.context?.updateSuggestedPrompts){let l=t.configurable.context.updateSuggestedPrompts,d=c;setTimeout(()=>l(d),0)}return j4(t?.configurable?.context.portal)&&M4(t?.configurable?.context.portal,t?.configurable?.context.token??"",a.conversationId),i.length&&(i.length===1?v4(i[0].solution.id):_4(i)),{outputMessage:o,summary:o,status:"success",solutionResponse:a,conversationId:a.conversationId}},X7=async(e,t)=>{let n=null;return e.documentSkillUrl===null&&t?.configurable?.context?.portal&&(n=V7(t.configurable.context.portal)),{documentSkillUrl:n}},Y7=await Fi(q7,"solutions_explorer_description"),Q7={id:"solutionsExplorer",name:"Solutions Explorer Agent",description:Y7,createGraph:W7,workspace:R4},eG="https://links.esri.com/solutions/agol-organizational-account",tG="https://links.esri.com/solutions/configure-assistants",p_=class extends sw{constructor(){super(),this.open=!1,this.userFirstName="",this.builderVisible=!1,this.hasActiveBuilderDesign=!1,this._conversationId=void 0,this._orgSettings={aiAssistantsEnabled:!1,blockBetaApps:!0,colocateCompute:!1},this._suggestedPrompts=[],this._hasInteracted=!1,this._isMobile=window.innerWidth<=800,this._translations=ow({name:"arcgis-solutions-assistant",blocking:!0}),this._builderWidth=48,this._solutionDesignJson='{ "solution": null }',this._isAssistantBusy=!1,this._isBuilderBusy=!1,this._preChatCheck=!1,this._assistantRef=rw(),this._configContextConsumer=Nm({context:cw,subscribe:!0,callback:t=>{t?.portalURL&&(vw.portalUrl=t.portalURL),t?.userSession&&!this.userFirstName&&this._loadUserFirstName(),t?.authentication?.PortalSubset?.orgSettings&&(this._orgSettings=t?.authentication?.PortalSubset?.orgSettings)}}),this._builderDesignContextConsumer=Nm({context:uw,subscribe:!0,callback:t=>{t?.design&&(this._solutionDesignJson=JSON.stringify(t.design,null,2))}}),this._handleResize=()=>{this._isMobile=window.innerWidth<=800},this.closeAssistant=Q0(),this._handleAssistantLinkClick=t=>{let n=t.composedPath().find(r=>r instanceof HTMLAnchorElement);if(n?.href)if(t.preventDefault(),n.target.indexOf("solutionId:")>-1){let r=n.target.split("solutionId:")[1];this._emitItemIdFromAI(r)}else window.open(n.href,"_blank","noopener,noreferrer")},this._onSolutionDesignUpdate=t=>{let n=t.detail;this._solutionDesignJson=n?JSON.stringify(n,null,2):'{ "solution": null }'},this._handleSignIn=()=>{this._configContextConsumer.value?.authentication?.signIn("aiOpen")},this._checkURLOpenParameter=()=>{this.open=this._configContextConsumer.value?.authentication?.SignInParam==="aiOpen"||this.open},this.listenOn(window,"arcgisFeedback",t=>{let n=t.detail,{agentPicked:r,taskAssigned:i,userMessage:s}=this._parseAgentPickedAndTask(n);this._sendFeedback(n.content,s??i??"",n.feedback?.positive?"Good":n.feedback?.positive=="Bad"?"Bad":"N/A",r??"")})}static{this.properties={open:5,userFirstName:1,builderVisible:5,hasActiveBuilderDesign:5,_conversationId:16,_orgSettings:16,_suggestedPrompts:16,_hasInteracted:16,_isMobile:16,_translations:16,_builderWidth:16,_solutionDesignJson:16,_isAssistantBusy:16,_isBuilderBusy:16,_preChatCheck:16}}static{this.styles=Y4}get _telemetry(){return this._configContextConsumer.value?.telemetrySession}connectedCallback(){super.connectedCallback(),window.addEventListener("arcgis-solution-design-update",this._onSolutionDesignUpdate),this.el.addEventListener("click",this._handleAssistantLinkClick),window.addEventListener("resize",this._handleResize),this._builderDesignContextConsumer}disconnectedCallback(){window.removeEventListener("arcgis-solution-design-update",this._onSolutionDesignUpdate),this.el.removeEventListener("click",this._handleAssistantLinkClick),window.removeEventListener("resize",this._handleResize),super.disconnectedCallback()}loaded(){this._checkURLOpenParameter()}load(){this._configContextConsumer.value?.portalURL&&(vw.portalUrl=this._configContextConsumer.value.portalURL)}firstUpdated(t){this._loadUserFirstName()}willUpdate(t){t.has("open")&&this.open&&window.dispatchEvent(new CustomEvent("openAssistant")),this._configContextConsumer.value?.authentication&&this._configContextConsumer.value?.userSession?.token&&(this._preChatCheck||(M4(this._configContextConsumer.value?.authentication.Portal,this._configContextConsumer.value?.userSession?.token),this._preChatCheck=!0)),this._configContextConsumer.value?.userSession?.token&&this._configContextConsumer.value?.authentication?.CanUseAI}_renderNoSign(){return qi`<calcite-notice class="margin-lg" open scale=m icon=effects kind=info><div slot=message>${this._translations.signInMessage}</div><calcite-link @click=${this._handleSignIn} slot=link title=${this._translations.signInMessage??Cm} class="padding-top-10">${this._translations.signIn}</calcite-link></calcite-notice>`}_renderNoPermission(){return qi`<calcite-notice open scale=m icon=effects kind=info><div slot=title>${this._translations.noPermissionTitle}</div><div slot=message class="padding-top-10">${gw(this._translations.noPermissionMessage.replace("{{orgUrl}}",eG).replace("{{configAI}}",tG))}</div></calcite-notice>`}render(){let t=this._suggestedPrompts.length>0?this._suggestedPrompts:this._hasInteracted?[]:Object.values(this._translations.defaultFollowUpQuestions);return this._suggestedPrompts.length>0?t=this._suggestedPrompts:this._hasInteracted||(t=[...Object.values(this._translations.defaultFollowUpQuestions)]),qi`<calcite-panel class="chat-panel"><div class="header-content" slot=header-content><span class="header-title">${this._translations.solutionAssistantTitle}</span></div>${this._configContextConsumer.value?.userSession?.token?this._configContextConsumer.value?.authentication?.CanUseAI?qi`${!this._isMobile&&qi`<calcite-action id=solutionBuilderAction icon=pencil-square .text=${this._translations.tooltips.solutionBuilder} .indicator=${this.hasActiveBuilderDesign} .disabled=${!this.hasActiveBuilderDesign} .active=${this.builderVisible} selection-appearance=highlight @click=${()=>{window.dispatchEvent(new CustomEvent("toggleSolutionBuilder"))}} scale=m slot=header-actions-end></calcite-action>`||""}<calcite-action id=newChatButton icon=speech-bubble-plus .text=${this._translations.tooltips.newConversation} @click=${()=>{this._conversationId=void 0,this._suggestedPrompts=[],this._hasInteracted=!1,this._assistantRef.value?.clearChatHistory()}} scale=m slot=header-actions-end></calcite-action><calcite-tooltip placement=bottom reference-element=newChatButton><span>${this._translations.tooltips.newConversation}</span></calcite-tooltip>${!this._isMobile&&qi`<calcite-tooltip placement=bottom reference-element=solutionBuilderAction><span>${this._translations.tooltips.toggleSolutionBuilder}</span></calcite-tooltip>`||""}<arcgis-assistant reference-element copy-enabled feedback-enabled heading description entry-message=${this._translations.defaultStartUpMessage??Cm} .suggestedPrompts=${t} @arcgisSubmit=${n=>{console.log("arcgis submit: ",n.detail),this._suggestedPrompts=[],t=[],this._hasInteracted=!0;let r=Date.now(),i=lw(r),s=n.detail||"Unknown";this._telemetry?.logEvent({category:dw.ASSISTANT,action:"Chat",dimensions:[s],metrics:[i]})}} @arcgisFeedback=${n=>{n.detail}} ${iw(this._assistantRef)}><arcgis-assistant-agent .agent=${Q7} .context=${{token:this._configContextConsumer.value?.userSession?.token,configContext:this._configContextConsumer.value,convoId:this._conversationId,portal:this._configContextConsumer.value?.authentication.Portal,assistantRef:this._assistantRef,translations:this._translations,updateSuggestedPrompts:n=>{this._suggestedPrompts=n},setConversationId:n=>{this._conversationId=n}}}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${r7} .context=${{translations:this._translations,clearSuggestedPrompts:()=>{this._suggestedPrompts=[]}}}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${B7} .context=${{solutionDesignJson:this._solutionDesignJson,translations:this._translations,token:this._configContextConsumer.value?.userSession?.token,configContext:this._configContextConsumer.value}}></arcgis-assistant-agent></arcgis-assistant><div slot=footer class="disclaimer-div width-100"><calcite-chip class="beta-chip" appearance=outline kind=neutral .label=${this._translations.betaTag} scale=s>${this._translations.betaTag}</calcite-chip><span>${this._translations.disclaimerMessage} <a href=https://links.esri.com/solutions/security-concern rel="noopener noreferrer" target=_blank>${this._translations.reportConcern}</a></span></div>`:this._renderNoPermission():this._renderNoSign()}<calcite-action icon=x id=closeAssistantButton .label=${this._translations.tooltips.close} @click=${()=>{this.closeAssistant.emit(!0)}} slot=header-actions-end .text=${this._translations.tooltips.close}></calcite-action><calcite-tooltip placement=bottom reference-element=closeAssistantButton><span>${this._translations.tooltips.close}</span></calcite-tooltip></calcite-panel>`}_sendFeedback(t,n,r,i){let s=`https://survey123.arcgis.com/share/6e349a50b4504ca6b6107216d568db5f?field:_source=${encodeURIComponent("Solutions Assistant")}&field:user_evaluation=${encodeURIComponent(r)}&field:question=${encodeURIComponent(n)}&field:answer=${encodeURIComponent(t)}&field:context=${encodeURIComponent(JSON.stringify({agent:i}))}&field:version=${encodeURIComponent("v2")}`;window.open(s,"_blank")}async _loadUserFirstName(){try{let t=await this._configContextConsumer.value?.userSession?.getUser();if(t?.fullName){let n=t.fullName.split(" ")[0];this.userFirstName=n}}catch{}}_parseAgentPickedAndTask(t){let n=Array.from(this._assistantRef.value?.messages||[]),r=t.log||[],i=[...n].sort((l,d)=>d.id-l.id).find(l=>l.role==="user"&&l.id<=t.id)?.content||null,s=r.find(l=>typeof l=="string"&&l.includes("Agent picked:"))??null;if(!s)return{agentPicked:null,taskAssigned:null,userMessage:i};let a=/Agent picked:\s*(.*?)\s*(?:\\n|\r?\n)\s*Task Assigned:\s*([\s\S]*)$/i,o=s.match(a);if(!o)return{agentPicked:null,taskAssigned:null,userMessage:i};let c=o[1].trim(),u=o[2].trim();return{agentPicked:c,taskAssigned:u,userMessage:i}}_emitItemIdFromAI(t){let n=new CustomEvent("solutionIDFromAssistant",{detail:t,bubbles:!0,composed:!0});window.dispatchEvent(n)}};aw("arcgis-solutions-assistant",p_);return p_},"config","identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request","portal/PortalItem",a,b,c)
|