@datalayer/agent-runtimes 1.5.70 → 1.5.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed/chunks/{DeckComponent-DAnUabRV.js → DeckComponent-Cd1sbs9L.js} +1 -1
- package/dist-embed/chunks/{DocumentView-BKFitqiB.js → DocumentView-ssQ835Wa.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-BRzYMd8Z.js → EphemeralDocument-DNziilOG.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-VnKcai35.js → ExcalidrawComponent-CQ4BeoQt.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-DrntFjbe.js → ExcalidrawModal-8W-b1OmA.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-BBivQZvX.js → JupyterLexicalExtension-BLYM-DTn.js} +4 -4
- package/dist-embed/chunks/{YouTubePlugin-C209681s.js → YouTubePlugin-BgZG6fCA.js} +1 -1
- package/dist-embed/chunks/abnfDiagram-VCTEODGH-BdOOK2nG.js +1 -0
- package/dist-embed/chunks/abnfDiagram-VCTEODGH-CHerLzZ0.js +1 -0
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-Dypu3IcK.js → ar-SA-G6X2FPQ2-Bcy9b6jn.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-C22xzf-o.js → architectureDiagram-5GKGNRK7-C8jjE2mY.js} +2 -2
- package/dist-embed/chunks/architectureDiagram-5GKGNRK7-GukKr_g1.js +36 -0
- package/dist-embed/chunks/{az-AZ-76LH7QW2-D8CzfKb1.js → az-AZ-76LH7QW2-Bzy5rt95.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-_NVFEM1_.js → bg-BG-XCXSNQG7-C3mQkAoD.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-CHicgYkf.js → blockDiagram-I7D4REHJ-DH6ta7S_.js} +2 -2
- package/dist-embed/chunks/blockDiagram-I7D4REHJ-edfypROz.js +129 -0
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-DMgdNi-k.js → bn-BD-2XOGV67Q-DHwDUFeg.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-auJZQjpw.js → c4Diagram-7LVT6UL2-B6NHHf7w.js} +2 -2
- package/dist-embed/chunks/c4Diagram-7LVT6UL2-BD3Ld97M.js +38 -0
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-DpOQhzr4.js → ca-ES-6MX7JW3Y-CWMZCfjI.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-DpFWUcsT.js → chunk-2Q5K7J3B-9xCosPaH.js} +1 -1
- package/dist-embed/chunks/chunk-2Q5K7J3B-ZWnuQ6M2.js +1 -0
- package/dist-embed/chunks/{chunk-5VM5RSS4-CaowF8Al.js → chunk-5VM5RSS4-7q2jPq-I.js} +1 -1
- package/dist-embed/chunks/chunk-5VM5RSS4-C2EZUNrH.js +15 -0
- package/dist-embed/chunks/{chunk-F27PBJKO-D7PuEggc.js → chunk-F27PBJKO-hasZYXJc.js} +1 -1
- package/dist-embed/chunks/chunk-F27PBJKO-iAw_9Xtd.js +1 -0
- package/dist-embed/chunks/{chunk-IMKFNOWR-jZNuNkCa.js → chunk-IMKFNOWR-CR2LIHPi.js} +1 -1
- package/dist-embed/chunks/chunk-IMKFNOWR-CU661Hle.js +231 -0
- package/dist-embed/chunks/{chunk-JWPE2WC7-BIShIUcJ.js → chunk-JWPE2WC7-B40RAhYQ.js} +1 -1
- package/dist-embed/chunks/chunk-JWPE2WC7-D4pNFsZF.js +1 -0
- package/dist-embed/chunks/{chunk-POPQ4Y6H-DG5Q2OKT.js → chunk-POPQ4Y6H-CNc-_UkX.js} +1 -1
- package/dist-embed/chunks/chunk-POPQ4Y6H-PC7NS4ab.js +1 -0
- package/dist-embed/chunks/{chunk-SVP7TREG-ERRaAh-x.js → chunk-SVP7TREG-B-LR0OEY.js} +1 -1
- package/dist-embed/chunks/chunk-SVP7TREG-BgVpHjUA.js +88 -0
- package/dist-embed/chunks/{chunk-TICWLB2K-B91fA6Jd.js → chunk-TICWLB2K-BKUWUi4x.js} +1 -1
- package/dist-embed/chunks/chunk-TICWLB2K-D0mlrZUj.js +206 -0
- package/dist-embed/chunks/{chunk-XXDRQBXY-BAy0lBJk.js → chunk-XXDRQBXY-CFD4Agg8.js} +1 -1
- package/dist-embed/chunks/chunk-XXDRQBXY-DF8wFPCi.js +1 -0
- package/dist-embed/chunks/classDiagram-ZZMXUADV-B2RPE1Bl.js +1 -0
- package/dist-embed/chunks/classDiagram-ZZMXUADV-BSdRgwsr.js +1 -0
- package/dist-embed/chunks/classDiagram-v2-VYDZK3BY-B2RPE1Bl.js +1 -0
- package/dist-embed/chunks/classDiagram-v2-VYDZK3BY-BSdRgwsr.js +1 -0
- package/dist-embed/chunks/cose-bilkent-JH36ORCC-CGF9N16A.js +1 -0
- package/dist-embed/chunks/cose-bilkent-JH36ORCC-D976z1sp.js +1 -0
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-Fr-SpqHD.js → cs-CZ-2BRQDIVT-B_pe2qj9.js} +1 -1
- package/dist-embed/chunks/cynefin-OW5HDTMX-BBLugbYz.js +166 -0
- package/dist-embed/chunks/cynefinDiagram-5FMLGOSQ-Cil4cm66.js +62 -0
- package/dist-embed/chunks/cynefinDiagram-5FMLGOSQ-D7ioXav_.js +62 -0
- package/dist-embed/chunks/{da-DK-5WZEPLOC-DO_sAXvt.js → da-DK-5WZEPLOC-CGWCNcJj.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-BgrGEY09.js → dagre-GXQ25YYZ-Cp78_L9l.js} +2 -2
- package/dist-embed/chunks/dagre-GXQ25YYZ-DauBFK-x.js +4 -0
- package/dist-embed/chunks/{de-DE-XR44H4JA-4JnXB_iM.js → de-DE-XR44H4JA-DTdq2h_G.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-hQvZziAN.js → diagram-S7CK7UJ4-LsSU5PzE.js} +2 -2
- package/dist-embed/chunks/diagram-S7CK7UJ4-cLOCifii.js +30 -0
- package/dist-embed/chunks/diagram-UQ7AKVKN-BK4qe_eB.js +41 -0
- package/dist-embed/chunks/diagram-UQ7AKVKN-CoIPlGw-.js +41 -0
- package/dist-embed/chunks/diagram-VSXAHHWV-CIhWkrRX.js +3 -0
- package/dist-embed/chunks/{diagram-VSXAHHWV-WVuzjdxU.js → diagram-VSXAHHWV-DWWQ-Ga9.js} +2 -2
- package/dist-embed/chunks/diagram-VX7I27RA-43SwkivD.js +24 -0
- package/dist-embed/chunks/diagram-VX7I27RA-CQM8aGRO.js +24 -0
- package/dist-embed/chunks/diagram-Z3DM3KII-Da75Rc5Q.js +24 -0
- package/dist-embed/chunks/diagram-Z3DM3KII-DrILxydN.js +24 -0
- package/dist-embed/chunks/ebnfDiagram-PWID7BFC-CwBVaHP2.js +1 -0
- package/dist-embed/chunks/ebnfDiagram-PWID7BFC-Klx1dPe6.js +1 -0
- package/dist-embed/chunks/{el-GR-BZB4AONW-MydAlwHl.js → el-GR-BZB4AONW-qdInZt55.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-zwXEFcAp.js → erDiagram-RLTQ6QDP-6YXMuidI.js} +2 -2
- package/dist-embed/chunks/erDiagram-RLTQ6QDP-DmlOR1VA.js +99 -0
- package/dist-embed/chunks/{es-ES-U4NZUMDT-rQmnr_uu.js → es-ES-U4NZUMDT-CbVgghD5.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-j5Hf8ngk.js → eu-ES-A7QVB2H4-Cfyi4-QV.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-DMJRRSBp.js → fa-IR-HGAKTJCU-Bpz9Yk2c.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-BFLC0BFd.js → fi-FI-Z5N7JZ37-CnNP_ASI.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-BrbR1EkW.js → flowDiagram-HODETNUW-DpJLPDJS.js} +1 -1
- package/dist-embed/chunks/flowDiagram-HODETNUW-_PPo6xx4.js +168 -0
- package/dist-embed/chunks/{fr-FR-RHASNOE6-CxjhSJC1.js → fr-FR-RHASNOE6-CXIU81zC.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-DfJDZVnm.js → ganttDiagram-EL5Y4UJY-B3ddBLm-.js} +2 -2
- package/dist-embed/chunks/ganttDiagram-EL5Y4UJY-DnJUq63S.js +292 -0
- package/dist-embed/chunks/gitGraphDiagram-WWUBYQGX-CKVR9Ajq.js +106 -0
- package/dist-embed/chunks/gitGraphDiagram-WWUBYQGX-u7eHxrMk.js +106 -0
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-BuuMpTaX.js → gl-ES-HMX3MZ6V-Do1RdVfG.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-Cv3Nrcgu.js → he-IL-6SHJWFNN-NcTscmv6.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-Sddst60F.js → hi-IN-IWLTKZ5I-CyNpoQ12.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-ehrXVpD0.js → hu-HU-A5ZG7DT2-Bzge2Fdz.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-Gfb1UYxZ.js → id-ID-SAP4L64H-DaNcoDhl.js} +1 -1
- package/dist-embed/chunks/{index-BaBNw6X5.js → index-BQdtKMKk.js} +56 -61
- package/dist-embed/chunks/index-CJys1M3A.js +6 -0
- package/dist-embed/chunks/{index-hxIHgkzg.js → index-CLdL3h_Z.js} +1 -1
- package/dist-embed/chunks/{index-DmpLE1d4.js → index-Cx_cIRez.js} +1 -1
- package/dist-embed/chunks/index-lOJZWhTu.js +337 -0
- package/dist-embed/chunks/infoDiagram-27XIBGKW-C3YByzAX.js +2 -0
- package/dist-embed/chunks/infoDiagram-27XIBGKW-CrHEoNfn.js +2 -0
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-DrEzfSK9.js → ishikawaDiagram-5VMMS53U-B87JmQRn.js} +6 -6
- package/dist-embed/chunks/ishikawaDiagram-5VMMS53U-DkW3YLz9.js +70 -0
- package/dist-embed/chunks/{it-IT-JPQ66NNP-BehLHkar.js → it-IT-JPQ66NNP-6fWP-4Pk.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-BZvqIigI.js → ja-JP-DBVTYXUO-TOPcUfq8.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-DpWKIFIN.js → journeyDiagram-3NMN7TZE-BcfZXfHF.js} +2 -2
- package/dist-embed/chunks/journeyDiagram-3NMN7TZE-BjO5pIr-.js +139 -0
- package/dist-embed/chunks/{kaa-6HZHGXH3-DgAIF6rN.js → kaa-6HZHGXH3-WPmptgZr.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-DW4thPSJ.js → kab-KAB-ZGHBKWFO-CMOAXrZA.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-DxbTprYr.js → kanban-definition-UXKFOSKX-D9d45rsU.js} +2 -2
- package/dist-embed/chunks/kanban-definition-UXKFOSKX-DKCJ8_n0.js +89 -0
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-CCy_nSJ7.js → kk-KZ-P5N5QNE5-B6ezOPzr.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-kpXyoxjS.js → km-KH-HSX4SM5Z-C84QUPbc.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-CFm6WtQG.js → ko-KR-MTYHY66A-cuBEuTL_.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-CKF85mOv.js → ku-TR-6OUDTVRD-B9KdlCAR.js} +1 -1
- package/dist-embed/chunks/{layout-DYytgC9r.js → layout-C6Twj1mW.js} +1 -1
- package/dist-embed/chunks/layout-Do3wJC1j.js +1 -0
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-CO9Bo5qJ.js → lt-LT-XHIRWOB4-B39JwBGi.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-CvZszc5p.js → lv-LV-5QDEKY6T-8WReOaa7.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-_1SBIPav.js → mindmap-definition-YA3MSWOX-5wZuXgB8.js} +2 -2
- package/dist-embed/chunks/mindmap-definition-YA3MSWOX-BURkGTKI.js +96 -0
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-Cio_dB9M.js → mr-IN-CRQNXWMA-DUaS8VWx.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-Z0RQ5Vbz.js → my-MM-5M5IBNSE-BdJYwQXg.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-BEQ0YP9J.js → nb-NO-T6EIAALU-C_p5yu1z.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-YtkJnS_J.js → nl-NL-IS3SIHDZ-DM5qgcCp.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-C1j2s3qO.js → nn-NO-6E72VCQL-BuX1DqI5.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-CinnjccW.js → oc-FR-POXYY2M6-BAWljcaf.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-c_6OtC6L.js → pa-IN-N4M65BXN-2iyq8qxX.js} +1 -1
- package/dist-embed/chunks/pegDiagram-XKGWAZYB-BjrOX_Ki.js +1 -0
- package/dist-embed/chunks/pegDiagram-XKGWAZYB-CyuSADYr.js +1 -0
- package/dist-embed/chunks/{percentages-BXMCSKIN-VqMxh8LK.js → percentages-BXMCSKIN-C9b5dzpq.js} +5 -5
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-EvMxJb2S.js → pieDiagram-E7YTZNPT-GvxNnk0x.js} +2 -2
- package/dist-embed/chunks/pieDiagram-E7YTZNPT-ni9UMEzV.js +39 -0
- package/dist-embed/chunks/{pl-PL-T2D74RX3-Cn_9xZgM.js → pl-PL-T2D74RX3-C6nLJHhB.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-Da6r-Pp1.js → pt-BR-5N22H2LF-B1adz-DU.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-D6lhcuX9.js → pt-PT-UZXXM6DQ-BCZpI4LV.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-rFaTvNlk.js → quadrantDiagram-AXDQQJYC-CufBEqrC.js} +4 -4
- package/dist-embed/chunks/quadrantDiagram-AXDQQJYC-Yg2WGHWh.js +7 -0
- package/dist-embed/chunks/railroadDiagram-O6MQD6OU-6tStysfX.js +1 -0
- package/dist-embed/chunks/railroadDiagram-O6MQD6OU-Df7m1mT4.js +1 -0
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-DHLQ_9Lw.js → requirementDiagram-BXWQKSXE-0AqPqv7a.js} +2 -2
- package/dist-embed/chunks/requirementDiagram-BXWQKSXE-CmXBYo40.js +84 -0
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-BFss9e8X.js → ro-RO-JPDTUUEW-BPM7y_F2.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-DIruW2gS.js → ru-RU-B4JR7IUQ-UViKo8dy.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-Nk71fRsK.js → sankeyDiagram-P5KCCOFB-CqcWOAyy.js} +2 -2
- package/dist-embed/chunks/sankeyDiagram-P5KCCOFB-rQsp_j9w.js +40 -0
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-Dm3QM01Z.js → sequenceDiagram-WJ2MYXX4-Br4F1sd7.js} +2 -2
- package/dist-embed/chunks/sequenceDiagram-WJ2MYXX4-GMFparx1.js +162 -0
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-Dom-aTTE.js → si-LK-N5RQ5JYF-D7TIYEDr.js} +1 -1
- package/dist-embed/chunks/sizeCapture-INFHLROL-8qFOiWrK.js +1 -0
- package/dist-embed/chunks/sizeCapture-INFHLROL-C_M5Nl06.js +1 -0
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-CLRU9TNq.js → sk-SK-C5VTKIMK-CQedcNlJ.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-BKLCNVXA.js → sl-SI-NN7IZMDC-BX1W51zJ.js} +1 -1
- package/dist-embed/chunks/stateDiagram-D77RDMKH-CWrs6KzY.js +1 -0
- package/dist-embed/chunks/stateDiagram-D77RDMKH-XK76naDS.js +1 -0
- package/dist-embed/chunks/stateDiagram-v2-MP3YSRHH-D3ZN_IoS.js +1 -0
- package/dist-embed/chunks/stateDiagram-v2-MP3YSRHH-lpluVNfO.js +1 -0
- package/dist-embed/chunks/{subset-shared.chunk-zIH7OLsP.js → subset-shared.chunk-PVguOYyR.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-b9j7PKPe.js → subset-worker.chunk-iWGyr_E5.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-D0UV0HV7.js → sv-SE-XGPEYMSR-DI7YcqUR.js} +1 -1
- package/dist-embed/chunks/swimlanes-42K2YHIH-B9qJ99nD.js +1 -0
- package/dist-embed/chunks/swimlanes-42K2YHIH-Ca0PhRmf.js +1 -0
- package/dist-embed/chunks/swimlanesDiagram-VR7AAH4N-BEQKTD21.js +8 -0
- package/dist-embed/chunks/swimlanesDiagram-VR7AAH4N-D-2e4UFJ.js +8 -0
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-C-EJ3jDE.js → ta-IN-2NMHFXQM-OZH5xroe.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-CfQh62Qa.js → th-TH-HPSO5L25-gAuWhBpT.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-CKtubk73.js → timeline-definition-24CTP7MA-B8lxEouP.js} +2 -2
- package/dist-embed/chunks/timeline-definition-24CTP7MA-CtZZro9U.js +120 -0
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-Lz7Ka2Zr.js → tr-TR-DEFEU3FU-DQ0SDuS6.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-DU0hsGUJ.js → uk-UA-QMV73CPH-7J4e2jng.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-Bq0xMhnH.js → vennDiagram-4TSXK5OY-Ca7szyFH.js} +2 -2
- package/dist-embed/chunks/vennDiagram-4TSXK5OY-zaNGkt8b.js +28 -0
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-CDvS0SiL.js → vi-VN-M7AON7JQ-dNpZ5DZ5.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-DL5LgQWr.js → wardleyDiagram-VM6X3IG4-D_Q6gtp2.js} +2 -2
- package/dist-embed/chunks/wardleyDiagram-VM6X3IG4-Dh0UOrRp.js +78 -0
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-BXkM4beH.js → xychartDiagram-S5SC5T6Z-4OhI4XQl.js} +2 -2
- package/dist-embed/chunks/xychartDiagram-S5SC5T6Z-D_TaZM0k.js +7 -0
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-CWE-bF0d.js → zh-CN-LNUGB5OW-CZSp2g8b.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-pEfL2bds.js → zh-HK-E62DVLB3-DUqVOyB_.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-Cp6UFUuD.js → zh-TW-RAJ6MFWO-U-TalxxN.js} +1 -1
- package/dist-embed/datalayer-app-main.js +3 -3
- package/lib/portable/attention.d.ts +204 -0
- package/lib/portable/attention.js +352 -0
- package/lib/portable/localApprovals.d.ts +72 -0
- package/lib/portable/localApprovals.js +125 -0
- package/lib/portable/localRuntime.d.ts +365 -0
- package/lib/portable/localRuntime.js +555 -0
- package/lib/portable/sessionList.d.ts +426 -0
- package/lib/portable/sessionList.js +618 -0
- package/package.json +1 -1
- package/dist-embed/chunks/abnfDiagram-VCTEODGH-m7LJLYga.js +0 -1
- package/dist-embed/chunks/classDiagram-ZZMXUADV-CGdcKCOI.js +0 -1
- package/dist-embed/chunks/classDiagram-v2-VYDZK3BY-CGdcKCOI.js +0 -1
- package/dist-embed/chunks/cose-bilkent-JH36ORCC-BsK2pWDL.js +0 -1
- package/dist-embed/chunks/cynefinDiagram-5FMLGOSQ-vmheD_S2.js +0 -62
- package/dist-embed/chunks/diagram-UQ7AKVKN-BFkOO3Wu.js +0 -41
- package/dist-embed/chunks/diagram-VX7I27RA-_LUOsaBb.js +0 -24
- package/dist-embed/chunks/diagram-Z3DM3KII-CY856Sry.js +0 -24
- package/dist-embed/chunks/ebnfDiagram-PWID7BFC-kqD9RLAA.js +0 -1
- package/dist-embed/chunks/gitGraphDiagram-WWUBYQGX-BujqTwbf.js +0 -106
- package/dist-embed/chunks/infoDiagram-27XIBGKW-C18Zz25F.js +0 -2
- package/dist-embed/chunks/pegDiagram-XKGWAZYB-BBVcHZ8T.js +0 -1
- package/dist-embed/chunks/railroadDiagram-O6MQD6OU-bR7xXZGS.js +0 -1
- package/dist-embed/chunks/sizeCapture-INFHLROL-BW7unDBA.js +0 -1
- package/dist-embed/chunks/stateDiagram-D77RDMKH-mLSMGpPQ.js +0 -1
- package/dist-embed/chunks/stateDiagram-v2-MP3YSRHH-C6TftAzE.js +0 -1
- package/dist-embed/chunks/swimlanes-42K2YHIH-BQTDK2Ta.js +0 -1
- package/dist-embed/chunks/swimlanesDiagram-VR7AAH4N-BV8Vb5g2.js +0 -8
|
@@ -3688,7 +3688,7 @@ ${Pu}\`\`\``}),lo}function ChatMarkdown({text:Au,density:lo="comfortable"}){retu
|
|
|
3688
3688
|
}`;function squeezed(Au){return Au.replace(/\s+/g," ").trim()}function saidMessageId(Au,lo){const $u=squeezed(lo??"");if($u)for(let Ru=Au.length-1;Ru>=0;Ru-=1){const Iu=answerText(Au[Ru]);if(Iu!==void 0&&squeezed(plainWords(Iu)).includes($u)){const Pu=Au[Ru].id;return typeof Pu=="string"?Pu:void 0}}}function sentenceRange(Au,lo){const $u=squeezed(lo);if(!$u||!Au.ownerDocument)return;const Ru=Au.ownerDocument,Iu=Ru.createTreeWalker(Au,4);let Pu="";const Ou=[];let Mu=!0;for(let Fu=Iu.nextNode();Fu;Fu=Iu.nextNode()){const zu=Fu.nodeValue??"";for(let Uu=0;Uu<zu.length;Uu+=1){const Hu=zu[Uu];if(/\s/.test(Hu)){if(Mu)continue;Mu=!0,Pu+=" "}else Mu=!1,Pu+=Hu;Ou.push({node:Fu,offset:Uu})}}const Du=Pu.indexOf($u);if(Du<0)return;const Lu=Ou[Du],Bu=Ou[Du+$u.length-1],ju=Ru.createRange();return ju.setStart(Lu.node,Lu.offset),ju.setEnd(Bu.node,Bu.offset+1),ju}function registry(){return globalThis.CSS?.highlights}function highlightOf(Au){const lo=globalThis.Highlight;return lo?new lo(Au):void 0}let styled=!1;function ensureStyle(Au){if(styled||Au.getElementById("datalayer-voice-said")){styled=!0;return}const lo=Au.createElement("style");lo.id="datalayer-voice-said",lo.textContent=SAID_STYLE,Au.head.appendChild(lo),styled=!0}function useSaidSentence(Au,lo,$u){reactExports.useEffect(()=>{const Ru=registry(),Iu=Au.current?.querySelector("[data-voice-saying]");if(!Ru||!Iu||!lo)return;const Pu=()=>{const Mu=sentenceRange(Iu,lo),Du=Mu?highlightOf(Mu):void 0;return Du?(ensureStyle(Iu.ownerDocument),Ru.set(SAID_HIGHLIGHT,Du),!0):!1};let Ou;return!Pu()&&typeof MutationObserver<"u"&&(Ou=new MutationObserver(()=>{Pu()&&Ou?.disconnect()}),Ou.observe(Iu,{childList:!0,subtree:!0,characterData:!0})),()=>{Ou?.disconnect(),Ru.delete(SAID_HIGHLIGHT)}},[Au,lo,$u])}function ToolApprovalBanner({pendingApprovals:Au,onReview:lo,onApproveAll:$u,onDismiss:Ru,collapsible:Iu=!0}){const Pu=useChatWords(),[Ou,Mu]=reactExports.useState(!1);return Au.length===0?null:Ou?jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,bg:"attention.subtle",borderBottom:"1px solid",borderColor:"attention.muted",cursor:"pointer",onClick:()=>Mu(!1),children:[jsxRuntimeExports.jsx(ShieldCheckIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,fontWeight:"semibold"},children:Pu.toolApprovalsPending}),jsxRuntimeExports.jsx(CounterLabel,{children:Au.length})]}):jsxRuntimeExports.jsxs(Box,{borderBottom:"1px solid",borderColor:"attention.muted",bg:"attention.subtle",children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,fontWeight:"semibold"},children:Pu.approvalsPending(Au.length)})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:1,children:[$u&&Au.length>=1&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"primary",leadingVisual:CheckIcon,onClick:$u,children:Pu.approveAll}),Iu&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",onClick:()=>Mu(!0),children:Pu.collapse}),Ru&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",leadingVisual:XIcon,onClick:Ru,"aria-label":Pu.dismiss})]})]}),jsxRuntimeExports.jsx(Box,{px:3,pb:2,children:Au.map(Du=>jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",py:1,px:2,mb:1,bg:"canvas.default",borderRadius:2,border:"1px solid",borderColor:"border.default",children:[jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",fontSize:1},children:Du.toolName}),Du.toolDescription&&jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontSize:0,ml:2},children:Du.toolDescription})]}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"default",onClick:()=>lo(Du),children:Pu.review})]},Du.id))})]})}function ToolApprovalDialog({isOpen:Au,toolName:lo,toolDescription:$u,args:Ru,onApprove:Iu,onDeny:Pu,onClose:Ou,showRememberChoice:Mu=!0}){const Du=useChatWords(),[Lu,Bu]=reactExports.useState(!1),ju=reactExports.useCallback(()=>{Iu(Lu)},[Iu,Lu]),Fu=reactExports.useCallback(()=>{Pu(Lu)},[Pu,Lu]);return Au?jsxRuntimeExports.jsxs(Dialog$1,{onClose:Ou,"aria-labelledby":"tool-approval-title",children:[jsxRuntimeExports.jsx(Dialog$1.Header,{children:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),Du.approvalTitle]})}),jsxRuntimeExports.jsxs(Box,{p:3,children:[jsxRuntimeExports.jsxs(Box,{mb:3,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,mb:2,children:[jsxRuntimeExports.jsx(ToolsIcon,{size:20}),jsxRuntimeExports.jsx(Heading$2,{as:"h4",sx:{fontSize:2},children:lo})]}),$u&&jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontSize:1},children:$u})]}),jsxRuntimeExports.jsxs(Box,{mb:3,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",fontSize:1,mb:2,display:"block"},children:Du.arguments}),jsxRuntimeExports.jsx(Box,{as:"pre",p:3,bg:"canvas.subtle",borderRadius:2,border:"1px solid",borderColor:"border.default",overflow:"auto",maxHeight:200,fontSize:0,children:JSON.stringify(Ru,null,2)})]}),jsxRuntimeExports.jsx(Box,{p:3,bg:"attention.subtle",borderRadius:2,border:"1px solid",borderColor:"attention.muted",mb:3,children:jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1},children:Du.approvalWarning})}),Mu&&jsxRuntimeExports.jsxs(FormControl$1,{sx:{mb:3},children:[jsxRuntimeExports.jsx(Checkbox,{checked:Lu,onChange:zu=>Bu(zu.target.checked)}),jsxRuntimeExports.jsx(FormControl$1.Label,{children:Du.rememberChoice})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"flex-end",gap:2,children:[jsxRuntimeExports.jsx(ButtonComponent,{variant:"danger",onClick:Fu,leadingVisual:XIcon,children:Du.deny}),jsxRuntimeExports.jsx(ButtonComponent,{variant:"primary",onClick:ju,leadingVisual:CheckIcon,children:Du.approve})]})]})]}):null}const isUsable=Au=>Au.isAvailable!==!1;function usableModels(Au){const lo=Au.filter(isUsable);return lo.length>0?lo:Au}function offeredModels(Au,lo){return usableModels(Au??lo())}const isOffered=(Au,lo)=>!!lo&&Au.some($u=>$u.id===lo&&isUsable($u));function initialModelId(Au,lo){return Au.some(Ru=>Ru.id===lo&&isUsable(Ru))?lo:(Au.find(isUsable)??Au[0])?.id}function readServerCatalogue(Au){return(Au?.models??[]).map(readServerModel)}function readServerDecisions(Au){return{models:Au.decision_models.map(readServerModel),note:Au.decisions_note}}function readServerModel(Au){const lo=Au.missing_env_vars??[],$u=Au.reason??(lo.length>0?`Set ${lo.join(", ")}`:void 0)??Au.warning??void 0;return{id:Au.id,name:Au.name??Au.id,isAvailable:Au.available!==!1,...$u&&Au.available===!1?{unavailableReason:$u}:{}}}const executionCache=new Map,CACHE_TTL_MS=2e3;function getOperationSignature(Au,lo){return`${Au}:${JSON.stringify(lo)}`}function isRecentDuplicate(Au,lo){const $u=getOperationSignature(Au,lo),Ru=executionCache.get($u);if(Ru&&Date.now()-Ru<CACHE_TTL_MS)return!0;for(const[Iu,Pu]of executionCache.entries())Date.now()-Pu>CACHE_TTL_MS*2&&executionCache.delete(Iu);return executionCache.set($u,Date.now()),!1}function processParameters(Au){if(!Au||typeof Au!="object"||Array.isArray(Au))return Au;const lo={};for(const[$u,Ru]of Object.entries(Au))if(typeof Ru=="string"&&(Ru.startsWith("{")||Ru.startsWith("[")))try{lo[$u]=JSON.parse(Ru)}catch{lo[$u]=Ru}else lo[$u]=Ru;return lo}function createAgentRuntimesTool(Au,lo,$u){const Ru=new OperationRunner;return{name:Au.toolReferenceName||Au.name,description:Au.description,parameters:Au.parameters,handler:async Iu=>{if(isRecentDuplicate(Au.name,Iu))return{success:!1,message:"Operation already executed recently (duplicate detected)"};try{const Pu=processParameters(Iu);return await Ru.execute(lo,Pu,{...$u,format:"toon"})}catch(Pu){return console.error("[agent-runtimes] ❌ ERROR in handler:",Pu),{success:!1,error:Pu instanceof Error?Pu.message:String(Pu)}}}}}function createAllAgentRuntimesTools(Au,lo,$u){const Ru=[];for(const Iu of Au){const Pu=lo[Iu.operation];if(!Pu){console.warn(`[agent-runtimes Tools] No operation found for ${Iu.name} (operation: ${Iu.operation})`);continue}const Ou=createAgentRuntimesTool(Iu,Pu,$u);Ru.push(Ou)}return Ru}const useNotebookStore=()=>notebookStore.getState();function createNotebookTools(Au,lo){const $u=new DefaultExecutor(Au,notebookStore.getState());return createAllAgentRuntimesTools(notebookToolDefinitions,notebookToolOperations,{documentId:Au,executor:$u,format:"toon",...lo})}function useNotebookTools(Au,lo){const $u=useNotebookStore(),Ru=reactExports.useMemo(()=>new DefaultExecutor(Au,$u),[Au]),Iu=reactExports.useMemo(()=>({documentId:Au,executor:Ru,format:"toon",...lo}),[Au,Ru,lo]);return reactExports.useMemo(()=>createAllAgentRuntimesTools(notebookToolDefinitions,notebookToolOperations,Iu),[Iu])}const notebookHooks=Object.freeze(Object.defineProperty({__proto__:null,createNotebookTools,useNotebookTools},Symbol.toStringTag,{value:"Module"})),AGENT_SPAN_ATTRIBUTES={operation:"gen_ai.operation.name",agentName:"gen_ai.agent.name",conversationId:"gen_ai.conversation.id",requestModel:"gen_ai.request.model",inputMessages:"gen_ai.input.messages",outputMessages:"gen_ai.output.messages",inputTokens:"gen_ai.usage.input_tokens",outputTokens:"gen_ai.usage.output_tokens",toolName:"gen_ai.tool.name",toolCallId:"gen_ai.tool.call.id",toolArguments:"gen_ai.tool.call.arguments",toolResult:"gen_ai.tool.call.result",toolType:"gen_ai.tool.type",toolKind:"datalayer.tool.kind",markIcon:"datalayer.mark.icon",markEmoji:"datalayer.mark.emoji",origin:"datalayer.span.origin",errorType:"error.type"},A=AGENT_SPAN_ATTRIBUTES;function jsonAttribute(Au){if(Au!==void 0)try{return JSON.stringify(Au)}catch{return String(Au)}}function shortLine(Au,lo=160){const $u=Au.replace(/\s+/g," ").trim();return $u.length>lo?`${$u.slice(0,lo-1)}…`:$u}function argumentsLine(Au,lo=100){if(!Au||typeof Au!="object")return Au===void 0?"":shortLine(String(Au),lo);const $u=Object.entries(Au).map(([Ru,Iu])=>`${Ru}=${typeof Iu=="string"?Iu:JSON.stringify(Iu)}`);return shortLine($u.join(", "),lo)}function messages(Au,lo){return JSON.stringify([{role:Au,parts:[{type:"text",content:lo}]}])}function startAgentTurn(Au,lo){return Au.startSpan(`invoke_agent ${lo.agent}`,{serviceName:lo.agent,parent:null,attributes:{[A.operation]:"invoke_agent",[A.agentName]:lo.agent,[A.requestModel]:lo.model||void 0,[A.conversationId]:lo.conversationId,[A.inputMessages]:messages("user",lo.prompt)}})}function endAgentTurn(Au,lo){const $u=lo.usage;Au.setAttributes({[A.outputMessages]:lo.text?messages("assistant",lo.text):void 0,[A.inputTokens]:$u?.inputTokens??$u?.promptTokens,[A.outputTokens]:$u?.outputTokens??$u?.completionTokens}),lo.error?(Au.setAttribute(A.errorType,"error"),Au.recordException(new Error(lo.error))):Au.setStatus("OK"),Au.end()}function toolType(Au){return Au==="mcp"?"extension":"function"}function startToolCall(Au,lo){return Au.startSpan(`execute_tool ${lo.name}`,{serviceName:lo.agent,...lo.parent?{parent:lo.parent}:{},attributes:{[A.operation]:"execute_tool",[A.agentName]:lo.agent,[A.toolName]:lo.name,[A.toolCallId]:lo.id,[A.toolArguments]:jsonAttribute(lo.args??{}),[A.toolType]:toolType(lo.tool.kind),[A.toolKind]:lo.tool.kind,[A.markIcon]:lo.tool.icon,[A.markEmoji]:lo.tool.emoji,[A.origin]:lo.origin}})}function endToolCall(Au,lo){Au.setAttribute(A.toolResult,jsonAttribute(lo.result)),lo.error?(Au.setAttribute(A.errorType,"tool_error"),Au.recordException(new Error(lo.error))):Au.setStatus("OK"),Au.end()}function sourceOfSpan(Au){const lo=Au.attributes??{};if(lo[A.toolKind])return String(lo[A.toolKind]);if(lo["rpc.service"]==="a2a"||Au.span_name.startsWith("a2a "))return"a2a";if(lo[A.operation]==="invoke_agent")return"model"}const SPAN_SOURCE_LABELS={a2a:"A2A",mcp:"MCP",frontend:"Frontend tool",skill:"Skill",codemode:"Codemode",runtime:"Runtime tool",model:"Model"};function messageText$1(Au){if(typeof Au!="string")return"";try{return(JSON.parse(Au)[0]?.parts??[]).map($u=>typeof $u.content=="string"?$u.content:"").join("")}catch{return""}}function describeAgentSpan(Au){const lo=Au.attributes??{},$u=lo[A.operation];if($u==="execute_tool"){let Mu;try{Mu=JSON.parse(String(lo[A.toolArguments]??"{}"))}catch{Mu=lo[A.toolArguments]}return argumentsLine(Mu)||void 0}if($u==="invoke_agent"){const Mu=messageText$1(lo[A.inputMessages]),Du=messageText$1(lo[A.outputMessages]),Lu=Number(lo[A.inputTokens]??0),Bu=Number(lo[A.outputTokens]??0),ju=Lu+Bu?` · ${Lu+Bu} tokens`:"";return shortLine(Du?`${shortLine(Mu,60)} → ${Du}`:Mu)+ju}const Ru=lo["a2a.message.text"],Iu=lo["a2a.task.state"],Pu=[typeof Iu=="string"?stateWord(Iu):"",typeof Ru=="string"?shortLine(Ru):""].filter(Boolean);if(Pu.length)return Pu.join(" · ");const Ou=lo["a2a.agent.skills"];return Array.isArray(Ou)?Ou.join(", "):void 0}function stateWord(Au){return typeof Au=="string"?Au.replace(/^TASK_STATE_/,"").toLowerCase().replace(/_/g," "):""}const AgentInspectorContext=reactExports.createContext(null);function useAgentInspectorTracer(){return reactExports.useContext(AgentInspectorContext)}const CODEMODE_TOOLS=new Set(["list_servers","list_tool_names","search_tools","get_tool_details","execute_code"]);function classifyToolCall(Au,lo,$u={}){const Ru=marksOfToolCall(Au,lo,$u.mcpServers);return{kind:$u.frontendTools?.includes(Au)?"frontend":Ru?.kind?Ru.kind:CODEMODE_TOOLS.has(Au)?"codemode":$u.fallback??"runtime",...Ru?.icon?{icon:Ru.icon}:{},...Ru?.emoji?{emoji:Ru.emoji}:{}}}function chatSpanRecorder(Au,lo,$u={}){let Ru;const Iu=new Map;return{turnStarted(Pu,Ou){Ru=startAgentTurn(Au,{agent:lo(),prompt:Pu,model:Ou})},turnEnded(Pu){Ru&&(endAgentTurn(Ru,Pu),Ru=void 0)},toolStarted({id:Pu,name:Ou,args:Mu}){const Du=Iu.get(Pu);if(Du){Du.setAttribute("gen_ai.tool.call.arguments",JSON.stringify(Mu??{}));return}Iu.set(Pu,startToolCall(Au,{agent:lo(),name:Ou,id:Pu,args:Mu,tool:classifyToolCall(Ou,Mu,{frontendTools:$u.frontendTools?.(),mcpServers:$u.mcpServers?.()}),...Ru?{parent:Ru.context}:{}}))},toolEnded(Pu,Ou){const Mu=Iu.get(Pu);Mu&&(Iu.delete(Pu),endToolCall(Mu,Ou))}}}const STEP_DISPLAY_TYPE="application/vnd.datalayer.loop.step+json",isStepDisplay=Au=>Au.type===STEP_DISPLAY_TYPE;function stepOfDisplay(Au){const lo=Au.data??{};if(!isStepDisplay(Au)||typeof lo.name!="string")throw new Error(`Display ${Au.id} is not a step`);return{id:Au.id,name:lo.name,kind:typeof lo.kind=="string"?lo.kind:"run",parentId:typeof lo.parent_id=="string"&&lo.parent_id?lo.parent_id:null,input:lo.input??null,output:lo.output??null,error:typeof lo.error=="string"?lo.error:"",ended:typeof lo.ended_at=="string"&&lo.ended_at!==""}}const stepCallId=Au=>`step-${Au}`;function stepItem(Au,lo){const $u=stepCallId(Au.id),Ru=`${Au.kind} step`;return{id:$u,type:"tool-call",toolCallId:$u,toolName:Au.name,args:{kind:Au.kind,...Au.input!==null?{input:Au.input}:{}},...!Au.error&&Au.output!==null?{result:Au.output}:{},status:Au.ended?Au.error?"error":"complete":"executing",...Au.error?{error:Au.error}:{},summary:lo?`${Ru}, inside ${lo}`:Ru}}function withLoopStep(Au,lo){const $u=lo.parentId?Au.find(Ou=>"toolCallId"in Ou&&Ou.toolCallId===stepCallId(lo.parentId)):void 0,Ru=stepItem(lo,$u&&"toolName"in $u?$u.toolName:void 0);let Iu=!1;const Pu=Au.map(Ou=>"toolCallId"in Ou&&Ou.toolCallId===Ru.toolCallId?(Iu=!0,Ru):Ou);return Iu?Pu:[...Au,Ru]}function elementOfDisplay(Au){const lo=Au.data?.where;if(lo!=="panel"&&lo!=="page")return null;const $u=Au.data?.title;return{id:Au.id,where:lo,title:typeof $u=="string"?$u:"",shows:Au}}function withLoopElement(Au,lo){if("closed"in lo)return Au.filter(Ru=>Ru.id!==lo.id);const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}let opened=[];const listeners$4=new Set,openLoopElements=()=>opened;function applyLoopElement(Au){opened=withLoopElement(opened,Au);for(const lo of[...listeners$4])lo(opened)}const closeLoopElement=Au=>applyLoopElement({id:Au,closed:!0});function clearLoopElements(){opened=[];for(const Au of[...listeners$4])Au(opened)}function onLoopElements(Au){return listeners$4.add(Au),()=>{listeners$4.delete(Au)}}const WINDOW_MESSAGE="message";function windowMessageOf(Au){if(Au.body.name!==WINDOW_MESSAGE)throw new Error(`A window op named ${Au.body.name} is not one this page acts on`);const lo=Au.body.args;if(!lo||!("data"in lo))throw new Error("A window message says no data");return lo.data}const listeners$3=new Set;function tellLoopWindow(Au){for(const lo of[...listeners$3])lo(Au)}function onLoopWindowMessage(Au){return listeners$3.add(Au),()=>{listeners$3.delete(Au)}}function windowTurnErrorOf(Au){let lo=null;for(const $u of Au.split(`
|
|
3689
3689
|
|
|
3690
3690
|
`)){const Ru=$u.split(`
|
|
3691
|
-
`).filter(Pu=>Pu.startsWith("data:")).map(Pu=>Pu.slice(5).trim()).join("");if(!Ru)continue;let Iu;try{Iu=JSON.parse(Ru)}catch{continue}if(Iu.type==="RUN_ERROR")lo=String(Iu.message??"The turn failed.");else if(Iu.type==="CUSTOM"&&Iu.name===AGUI_NAME)throw new Error("A reactor.ui op came on the run stream: it comes over the ui socket.")}return lo}function messageOfDisplay(Au){const lo=Au.data?.message_id;if(typeof lo!="string"||!lo)throw new Error(`Display ${Au.id} says no message it is under`);return lo}function speakerOf(Au){return{id:`author:${Au}`,name:Au}}function changed(Au,lo,$u){const Ru=Au.findIndex(Iu=>(Iu.displays??[]).some(Pu=>Pu.id===lo));if(Ru<0)throw new Error(`Display ${lo} is shown under no message here`);return Au.map((Iu,Pu)=>{if(Pu!==Ru)return Iu;const Ou=[];for(const Mu of Iu.displays??[]){if(Mu.id!==lo){Ou.push(Mu);continue}const Du=$u(Mu);Du&&Ou.push({...Du,id:lo})}return{...Iu,displays:Ou}})}function replaced(Au,lo){const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}function withUiOp(Au,lo){switch(lo.op){case"show":case"ask":{const $u=lo.body,Ru=messageOfDisplay($u);if(!Au.some(Iu=>Iu.id===Ru))throw new Error(`Display ${$u.id} is under message ${Ru}, which is not here`);return Au.map(Iu=>Iu.id===Ru?{...Iu,displays:replaced(Iu.displays??[],$u)}:Iu)}case"remove":{if(Au.some(Ru=>(Ru.displays??[]).some(Iu=>Iu.id===lo.id)))return changed(Au,lo.id,()=>{});if(!Au.some(Ru=>Ru.id===lo.id))throw new Error(`Nothing here is ${lo.id}: it cannot be removed`);return Au.filter(Ru=>Ru.id!==lo.id)}case"patch":{const $u=lo.body;return changed(Au,lo.id,Ru=>applyPatch$1(Ru,$u))}case"append":{const{path:$u,value:Ru}=lo.body;return changed(Au,lo.id,Iu=>applyPatch$1(Iu,[{op:"add",path:`${$u}/-`,value:Ru}]))}case"meta":{const $u=lo.body.author,Ru=Object.keys(lo.body);if(!lo.id||Ru.length!==1||typeof $u!="string"||!$u.trim())throw new Error(`A meta op says ${JSON.stringify(lo.body)}: only a message's author is read`);if(!Au.some(Iu=>Iu.id===lo.id))throw new Error(`Message ${lo.id} is not here: it has no author to say`);return Au.map(Iu=>Iu.id===lo.id?{...Iu,speaker:speakerOf($u.trim())}:Iu)}case"window":throw new Error("A window op is for the page, not the messages");default:return Au}}function routeUiOp(Au,lo,$u){switch(Au.op){case"window":return{routed:{to:"window",data:windowMessageOf(Au)},steps:lo};case"show":case"ask":{if(isStepDisplay(Au.body)){const Iu=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Au.body)},steps:Iu}}const Ru=elementOfDisplay(Au.body);return Ru?{routed:{to:"element",change:Ru},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}case"patch":case"append":{if(Au.id in lo.displays){const Ru=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Ru.displays[Au.id])},steps:Ru}}return{routed:{to:"messages",op:Au},steps:lo}}case"remove":{if(Au.id in lo.displays)throw new Error(`Step ${Au.id} is never removed: it ends`);return $u.has(Au.id)?{routed:{to:"element",change:{id:Au.id,closed:!0}},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}default:return{routed:{to:"messages",op:Au},steps:lo}}}function placeable(Au,lo){const $u=Iu=>!!Iu&&Au.some(Pu=>Pu.id===Iu),Ru=Iu=>!!Iu&&Au.some(Pu=>(Pu.displays??[]).some(Ou=>Ou.id===Iu));switch(lo.op){case"show":case"ask":{const Iu=lo.body.data?.message_id;return typeof Iu=="string"&&$u(Iu)}case"meta":return $u(lo.id);case"patch":case"append":return Ru(lo.id);case"remove":return Ru(lo.id)||$u(lo.id);default:return!0}}function displayPressOf(Au){const $u=Au?.loop?.action;if(!$u||typeof $u.display_id!="string")return null;if(typeof $u.name!="string"||typeof $u.token!="string")throw new Error("A press of a display says its action and its token");return{action:$u.name,display_id:$u.display_id,token:$u.token,payload:$u.payload??{}}}function withPress(Au,lo){const $u=lo?.press;if(typeof $u!="string"||!$u)throw new Error("The runtime checked the press but named none");const Ru={...Au.loop};return delete Ru.action,{...Au,loop:{...Ru,press:$u}}}function blobOfDataUrl(Au,lo,$u){const[Ru,Iu]=[Au.slice(0,Au.indexOf(",")),Au.slice(Au.indexOf(",")+1)];if(!Ru.startsWith("data:")||Au.indexOf(",")<0)throw new Error(`${lo} could not be read: it is not a data URL.`);const Pu=$u||Ru.slice(5).split(";")[0];let Ou;if(Ru.endsWith(";base64")){const Mu=atob(Iu);Ou=new Uint8Array(Mu.length);for(let Du=0;Du<Mu.length;Du+=1)Ou[Du]=Mu.charCodeAt(Du)}else Ou=new TextEncoder().encode(decodeURIComponent(Iu));return Object.assign(new Blob([Ou],{type:Pu}),{name:lo})}function namesFiles(Au){const lo=Au?.loop?.files;return Array.isArray(lo)&&lo.length>0}async function withUploadedFiles(Au,lo){const $u=Au.loop,Ru=$u.files,Iu=[];for(const Pu of Ru){if(isFileRef(Pu)){Iu.push(Pu);continue}const Ou=Pu;if(typeof Ou.name!="string"||typeof Ou.data_url!="string")throw new Error("A file given is neither the page’s nor a ref.");Iu.push(await lo(blobOfDataUrl(Ou.data_url,Ou.name,typeof Ou.type=="string"?Ou.type:void 0)))}return{...Au,loop:{...$u,files:Iu}}}const EphemeralDocument=vM.lazy(()=>__vitePreload(()=>import("./chunks/EphemeralDocument-BRzYMd8Z.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralDocument}))),loadAgentDetails=()=>__vitePreload(()=>import("./chunks/AgentDetails-BriiIXid.js"),[],import.meta.url).then(Au=>({default:Au.AgentDetails})),loadEphemeralNotebook=()=>__vitePreload(()=>import("./chunks/EphemeralNotebook-COnqhW7Q.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralNotebook})),lazyViewRefused=Au=>lo=>jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{p:3,color:"danger.fg"},children:`The ${Au} could not be loaded: ${lo.message}`}),agentDetailsRefused=lazyViewRefused("agent details"),ephemeralNotebookRefused=lazyViewRefused("notebook"),sentPendingPromptKeys=new Set;function frontendToolExpectsArgs(Au){const lo=Au?.parameters;if(!lo)return!1;if(Array.isArray(lo))return lo.length>0;const $u=lo.properties;return $u&&typeof $u=="object"?Object.keys($u).length>0:Object.keys(lo).length>0}function CompanionSurfaceSkeleton({mode:Au}){return jsxRuntimeExports.jsx(Box,{"aria-label":Au==="notebook"?"Preparing notebook…":"Preparing document…",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",gap:3,p:4,children:Au==="notebook"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:[0,1,2].map(lo=>jsxRuntimeExports.jsxs(Box,{p:3,border:"1px solid",borderColor:"border.muted",borderRadius:2,bg:"canvas.subtle",display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:lo===0?2:3})]},lo))}):jsxRuntimeExports.jsxs(Box,{maxWidth:860,width:"100%",mx:"auto",display:"flex",flexDirection:"column",gap:3,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:4}),jsxRuntimeExports.jsx(SkeletonText,{lines:3}),jsxRuntimeExports.jsx(SkeletonText,{lines:5})]})})}const ThemedJupyterReactTheme=JupyterReactTheme$1;function ThemedChatBoundary({children:Au,themeVariant:lo,colorMode:$u,themeOverrides:Ru}){const Iu=useThemeStore(zu=>zu.colorMode),Pu=useThemeStore(zu=>zu.theme),Ou=$u??Iu,Mu=lo??Pu,Du=useSystemColorMode(),Lu=getThemeConfig(Mu),Bu=Ou==="auto"?Du:Ou,ju={...Bu==="dark"?Lu.themeStyles.dark:Lu.themeStyles.light,...Ru?.[Bu]},Fu=ju.backgroundColor??"";return jsxRuntimeExports.jsx(ThemedJupyterReactTheme,{colormode:Bu,theme:Lu.primerTheme,backgroundColor:Fu,loadJupyterLabCss:!1,style:{...ju,color:"var(--fgColor-default)",fontSize:"var(--text-body-size-medium)",display:"contents"},children:Au})}const AI_AGENTS_API_PREFIX="/api/ai-agents/v1",isDevTraceEnabled=()=>{try{return!1}catch{return!1}},logApprovalTrace=(Au,lo)=>{isDevTraceEnabled()&&console.debug(`[approval-trace] ${Au}`,lo)},normalizeAgentId=Au=>(Au??"").trim().toLowerCase(),normalizeToolName=Au=>Au.replace(/[-_]/g,"").toLowerCase(),normalizeSkillApprovalId=Au=>{const lo=Au.indexOf(":");return lo<=0?Au:Au.slice(0,lo)},stableStringify=Au=>Au===null||typeof Au!="object"?JSON.stringify(Au):Array.isArray(Au)?`[${Au.map($u=>stableStringify($u)).join(",")}]`:`{${Object.entries(Au).sort(([$u],[Ru])=>$u.localeCompare(Ru)).map(([$u,Ru])=>`${JSON.stringify($u)}:${stableStringify(Ru)}`).join(",")}}`,approvalSignature=(Au,lo)=>`${normalizeToolName(Au)}::${stableStringify(lo??{})}`,normalizeAiAgentsBaseUrl=Au=>{const lo=Au.replace(/\/$/,"");return lo.endsWith(AI_AGENTS_API_PREFIX)?lo.slice(0,-AI_AGENTS_API_PREFIX.length):lo},toWsUrl=(Au,lo,$u)=>{try{const Ru=new URL(Au);return Ru.protocol=Ru.protocol==="https:"?"wss:":"ws:",Ru.pathname=lo,$u?Ru.searchParams.set("token",$u):Ru.search="",Ru.toString()}catch{return null}},normalizeApprovalPayload=Au=>{const lo=typeof Au.id=="string"&&Au.id||typeof Au.approval_id=="string"&&Au.approval_id||typeof Au.approvalId=="string"&&Au.approvalId||"",$u=typeof Au.tool_name=="string"&&Au.tool_name||typeof Au.toolName=="string"&&Au.toolName||"";if(!lo||!$u)return null;const Ru=(Au.tool_args&&typeof Au.tool_args=="object"?Au.tool_args:Au.toolArgs&&typeof Au.toolArgs=="object"?Au.toolArgs:void 0)??{};return{id:lo,tool_name:$u,tool_args:Ru,tool_call_id:typeof Au.tool_call_id=="string"&&Au.tool_call_id||typeof Au.toolCallId=="string"&&Au.toolCallId||void 0,note:typeof Au.note=="string"&&Au.note||typeof Au.message=="string"&&Au.message||void 0,status:typeof Au.status=="string"&&Au.status||"pending",agent_id:typeof Au.agent_id=="string"&&Au.agent_id||typeof Au.agentId=="string"&&Au.agentId||void 0,created_at:typeof Au.created_at=="string"&&Au.created_at||typeof Au.createdAt=="string"&&Au.createdAt||void 0,updated_at:typeof Au.updated_at=="string"&&Au.updated_at||typeof Au.updatedAt=="string"&&Au.updatedAt||void 0}},statusFromApprovalEvent=Au=>{if(Au==="tool_approval_created")return"pending";if(Au==="tool_approval_approved")return"approved";if(Au==="tool_approval_rejected")return"rejected";if(Au==="tool_approval_deleted")return"deleted"},RESOLVED_TOOL_CALL_SUPPRESSION_MS=15e3,isApprovalForAgent=(Au,lo)=>{if(!lo)return!0;if(!Au.agent_id)return!1;if(Au.agent_id===lo)return!0;const $u=normalizeAgentId(Au.agent_id),Ru=normalizeAgentId(lo);return $u.includes(Ru)||Ru.includes($u)};function isToolCallOnlyPrompt(Au){const lo=Au.toLowerCase();return/tool\s*call\s*only/.test(lo)||/use\s+(?:a\s+)?tool\s+call\s+only/.test(lo)}function formatToolResultFallback(Au){if(typeof Au=="string")return Au;if(typeof Au=="number"||typeof Au=="boolean"||Au===null)return String(Au);try{const lo=JSON.stringify(Au,null,2);return lo.length>2e3?`${lo.slice(0,2e3)}
|
|
3691
|
+
`).filter(Pu=>Pu.startsWith("data:")).map(Pu=>Pu.slice(5).trim()).join("");if(!Ru)continue;let Iu;try{Iu=JSON.parse(Ru)}catch{continue}if(Iu.type==="RUN_ERROR")lo=String(Iu.message??"The turn failed.");else if(Iu.type==="CUSTOM"&&Iu.name===AGUI_NAME)throw new Error("A reactor.ui op came on the run stream: it comes over the ui socket.")}return lo}function messageOfDisplay(Au){const lo=Au.data?.message_id;if(typeof lo!="string"||!lo)throw new Error(`Display ${Au.id} says no message it is under`);return lo}function speakerOf(Au){return{id:`author:${Au}`,name:Au}}function changed(Au,lo,$u){const Ru=Au.findIndex(Iu=>(Iu.displays??[]).some(Pu=>Pu.id===lo));if(Ru<0)throw new Error(`Display ${lo} is shown under no message here`);return Au.map((Iu,Pu)=>{if(Pu!==Ru)return Iu;const Ou=[];for(const Mu of Iu.displays??[]){if(Mu.id!==lo){Ou.push(Mu);continue}const Du=$u(Mu);Du&&Ou.push({...Du,id:lo})}return{...Iu,displays:Ou}})}function replaced(Au,lo){const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}function withUiOp(Au,lo){switch(lo.op){case"show":case"ask":{const $u=lo.body,Ru=messageOfDisplay($u);if(!Au.some(Iu=>Iu.id===Ru))throw new Error(`Display ${$u.id} is under message ${Ru}, which is not here`);return Au.map(Iu=>Iu.id===Ru?{...Iu,displays:replaced(Iu.displays??[],$u)}:Iu)}case"remove":{if(Au.some(Ru=>(Ru.displays??[]).some(Iu=>Iu.id===lo.id)))return changed(Au,lo.id,()=>{});if(!Au.some(Ru=>Ru.id===lo.id))throw new Error(`Nothing here is ${lo.id}: it cannot be removed`);return Au.filter(Ru=>Ru.id!==lo.id)}case"patch":{const $u=lo.body;return changed(Au,lo.id,Ru=>applyPatch$1(Ru,$u))}case"append":{const{path:$u,value:Ru}=lo.body;return changed(Au,lo.id,Iu=>applyPatch$1(Iu,[{op:"add",path:`${$u}/-`,value:Ru}]))}case"meta":{const $u=lo.body.author,Ru=Object.keys(lo.body);if(!lo.id||Ru.length!==1||typeof $u!="string"||!$u.trim())throw new Error(`A meta op says ${JSON.stringify(lo.body)}: only a message's author is read`);if(!Au.some(Iu=>Iu.id===lo.id))throw new Error(`Message ${lo.id} is not here: it has no author to say`);return Au.map(Iu=>Iu.id===lo.id?{...Iu,speaker:speakerOf($u.trim())}:Iu)}case"window":throw new Error("A window op is for the page, not the messages");default:return Au}}function routeUiOp(Au,lo,$u){switch(Au.op){case"window":return{routed:{to:"window",data:windowMessageOf(Au)},steps:lo};case"show":case"ask":{if(isStepDisplay(Au.body)){const Iu=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Au.body)},steps:Iu}}const Ru=elementOfDisplay(Au.body);return Ru?{routed:{to:"element",change:Ru},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}case"patch":case"append":{if(Au.id in lo.displays){const Ru=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Ru.displays[Au.id])},steps:Ru}}return{routed:{to:"messages",op:Au},steps:lo}}case"remove":{if(Au.id in lo.displays)throw new Error(`Step ${Au.id} is never removed: it ends`);return $u.has(Au.id)?{routed:{to:"element",change:{id:Au.id,closed:!0}},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}default:return{routed:{to:"messages",op:Au},steps:lo}}}function placeable(Au,lo){const $u=Iu=>!!Iu&&Au.some(Pu=>Pu.id===Iu),Ru=Iu=>!!Iu&&Au.some(Pu=>(Pu.displays??[]).some(Ou=>Ou.id===Iu));switch(lo.op){case"show":case"ask":{const Iu=lo.body.data?.message_id;return typeof Iu=="string"&&$u(Iu)}case"meta":return $u(lo.id);case"patch":case"append":return Ru(lo.id);case"remove":return Ru(lo.id)||$u(lo.id);default:return!0}}function displayPressOf(Au){const $u=Au?.loop?.action;if(!$u||typeof $u.display_id!="string")return null;if(typeof $u.name!="string"||typeof $u.token!="string")throw new Error("A press of a display says its action and its token");return{action:$u.name,display_id:$u.display_id,token:$u.token,payload:$u.payload??{}}}function withPress(Au,lo){const $u=lo?.press;if(typeof $u!="string"||!$u)throw new Error("The runtime checked the press but named none");const Ru={...Au.loop};return delete Ru.action,{...Au,loop:{...Ru,press:$u}}}function blobOfDataUrl(Au,lo,$u){const[Ru,Iu]=[Au.slice(0,Au.indexOf(",")),Au.slice(Au.indexOf(",")+1)];if(!Ru.startsWith("data:")||Au.indexOf(",")<0)throw new Error(`${lo} could not be read: it is not a data URL.`);const Pu=$u||Ru.slice(5).split(";")[0];let Ou;if(Ru.endsWith(";base64")){const Mu=atob(Iu);Ou=new Uint8Array(Mu.length);for(let Du=0;Du<Mu.length;Du+=1)Ou[Du]=Mu.charCodeAt(Du)}else Ou=new TextEncoder().encode(decodeURIComponent(Iu));return Object.assign(new Blob([Ou],{type:Pu}),{name:lo})}function namesFiles(Au){const lo=Au?.loop?.files;return Array.isArray(lo)&&lo.length>0}async function withUploadedFiles(Au,lo){const $u=Au.loop,Ru=$u.files,Iu=[];for(const Pu of Ru){if(isFileRef(Pu)){Iu.push(Pu);continue}const Ou=Pu;if(typeof Ou.name!="string"||typeof Ou.data_url!="string")throw new Error("A file given is neither the page’s nor a ref.");Iu.push(await lo(blobOfDataUrl(Ou.data_url,Ou.name,typeof Ou.type=="string"?Ou.type:void 0)))}return{...Au,loop:{...$u,files:Iu}}}const EphemeralDocument=vM.lazy(()=>__vitePreload(()=>import("./chunks/EphemeralDocument-DNziilOG.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralDocument}))),loadAgentDetails=()=>__vitePreload(()=>import("./chunks/AgentDetails-BriiIXid.js"),[],import.meta.url).then(Au=>({default:Au.AgentDetails})),loadEphemeralNotebook=()=>__vitePreload(()=>import("./chunks/EphemeralNotebook-COnqhW7Q.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralNotebook})),lazyViewRefused=Au=>lo=>jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{p:3,color:"danger.fg"},children:`The ${Au} could not be loaded: ${lo.message}`}),agentDetailsRefused=lazyViewRefused("agent details"),ephemeralNotebookRefused=lazyViewRefused("notebook"),sentPendingPromptKeys=new Set;function frontendToolExpectsArgs(Au){const lo=Au?.parameters;if(!lo)return!1;if(Array.isArray(lo))return lo.length>0;const $u=lo.properties;return $u&&typeof $u=="object"?Object.keys($u).length>0:Object.keys(lo).length>0}function CompanionSurfaceSkeleton({mode:Au}){return jsxRuntimeExports.jsx(Box,{"aria-label":Au==="notebook"?"Preparing notebook…":"Preparing document…",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",gap:3,p:4,children:Au==="notebook"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:[0,1,2].map(lo=>jsxRuntimeExports.jsxs(Box,{p:3,border:"1px solid",borderColor:"border.muted",borderRadius:2,bg:"canvas.subtle",display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:lo===0?2:3})]},lo))}):jsxRuntimeExports.jsxs(Box,{maxWidth:860,width:"100%",mx:"auto",display:"flex",flexDirection:"column",gap:3,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:4}),jsxRuntimeExports.jsx(SkeletonText,{lines:3}),jsxRuntimeExports.jsx(SkeletonText,{lines:5})]})})}const ThemedJupyterReactTheme=JupyterReactTheme$1;function ThemedChatBoundary({children:Au,themeVariant:lo,colorMode:$u,themeOverrides:Ru}){const Iu=useThemeStore(zu=>zu.colorMode),Pu=useThemeStore(zu=>zu.theme),Ou=$u??Iu,Mu=lo??Pu,Du=useSystemColorMode(),Lu=getThemeConfig(Mu),Bu=Ou==="auto"?Du:Ou,ju={...Bu==="dark"?Lu.themeStyles.dark:Lu.themeStyles.light,...Ru?.[Bu]},Fu=ju.backgroundColor??"";return jsxRuntimeExports.jsx(ThemedJupyterReactTheme,{colormode:Bu,theme:Lu.primerTheme,backgroundColor:Fu,loadJupyterLabCss:!1,style:{...ju,color:"var(--fgColor-default)",fontSize:"var(--text-body-size-medium)",display:"contents"},children:Au})}const AI_AGENTS_API_PREFIX="/api/ai-agents/v1",isDevTraceEnabled=()=>{try{return!1}catch{return!1}},logApprovalTrace=(Au,lo)=>{isDevTraceEnabled()&&console.debug(`[approval-trace] ${Au}`,lo)},normalizeAgentId=Au=>(Au??"").trim().toLowerCase(),normalizeToolName=Au=>Au.replace(/[-_]/g,"").toLowerCase(),normalizeSkillApprovalId=Au=>{const lo=Au.indexOf(":");return lo<=0?Au:Au.slice(0,lo)},stableStringify=Au=>Au===null||typeof Au!="object"?JSON.stringify(Au):Array.isArray(Au)?`[${Au.map($u=>stableStringify($u)).join(",")}]`:`{${Object.entries(Au).sort(([$u],[Ru])=>$u.localeCompare(Ru)).map(([$u,Ru])=>`${JSON.stringify($u)}:${stableStringify(Ru)}`).join(",")}}`,approvalSignature=(Au,lo)=>`${normalizeToolName(Au)}::${stableStringify(lo??{})}`,normalizeAiAgentsBaseUrl=Au=>{const lo=Au.replace(/\/$/,"");return lo.endsWith(AI_AGENTS_API_PREFIX)?lo.slice(0,-AI_AGENTS_API_PREFIX.length):lo},toWsUrl=(Au,lo,$u)=>{try{const Ru=new URL(Au);return Ru.protocol=Ru.protocol==="https:"?"wss:":"ws:",Ru.pathname=lo,$u?Ru.searchParams.set("token",$u):Ru.search="",Ru.toString()}catch{return null}},normalizeApprovalPayload=Au=>{const lo=typeof Au.id=="string"&&Au.id||typeof Au.approval_id=="string"&&Au.approval_id||typeof Au.approvalId=="string"&&Au.approvalId||"",$u=typeof Au.tool_name=="string"&&Au.tool_name||typeof Au.toolName=="string"&&Au.toolName||"";if(!lo||!$u)return null;const Ru=(Au.tool_args&&typeof Au.tool_args=="object"?Au.tool_args:Au.toolArgs&&typeof Au.toolArgs=="object"?Au.toolArgs:void 0)??{};return{id:lo,tool_name:$u,tool_args:Ru,tool_call_id:typeof Au.tool_call_id=="string"&&Au.tool_call_id||typeof Au.toolCallId=="string"&&Au.toolCallId||void 0,note:typeof Au.note=="string"&&Au.note||typeof Au.message=="string"&&Au.message||void 0,status:typeof Au.status=="string"&&Au.status||"pending",agent_id:typeof Au.agent_id=="string"&&Au.agent_id||typeof Au.agentId=="string"&&Au.agentId||void 0,created_at:typeof Au.created_at=="string"&&Au.created_at||typeof Au.createdAt=="string"&&Au.createdAt||void 0,updated_at:typeof Au.updated_at=="string"&&Au.updated_at||typeof Au.updatedAt=="string"&&Au.updatedAt||void 0}},statusFromApprovalEvent=Au=>{if(Au==="tool_approval_created")return"pending";if(Au==="tool_approval_approved")return"approved";if(Au==="tool_approval_rejected")return"rejected";if(Au==="tool_approval_deleted")return"deleted"},RESOLVED_TOOL_CALL_SUPPRESSION_MS=15e3,isApprovalForAgent=(Au,lo)=>{if(!lo)return!0;if(!Au.agent_id)return!1;if(Au.agent_id===lo)return!0;const $u=normalizeAgentId(Au.agent_id),Ru=normalizeAgentId(lo);return $u.includes(Ru)||Ru.includes($u)};function isToolCallOnlyPrompt(Au){const lo=Au.toLowerCase();return/tool\s*call\s*only/.test(lo)||/use\s+(?:a\s+)?tool\s+call\s+only/.test(lo)}function formatToolResultFallback(Au){if(typeof Au=="string")return Au;if(typeof Au=="number"||typeof Au=="boolean"||Au===null)return String(Au);try{const lo=JSON.stringify(Au,null,2);return lo.length>2e3?`${lo.slice(0,2e3)}
|
|
3692
3692
|
...`:lo}catch{return"Tool completed successfully."}}function parseEnabledMcpToolsByServer(Au){if(!Au||typeof Au!="object")return null;const lo=Au.enabled_tools_by_server;if(lo==null)return new Map;if(typeof lo!="object")return new Map;const $u=new Map;for(const[Ru,Iu]of Object.entries(lo)){if(!Array.isArray(Iu))continue;const Ou=Iu.filter(Mu=>typeof Mu=="string"&&Mu.length>0).map(Mu=>{const Du=Mu.indexOf("__");return Du>=0?Mu.slice(Du+2):Mu});$u.set(Ru,new Set(Ou))}return $u}function parseApprovedMcpToolsByServer(Au){if(!Au||typeof Au!="object")return null;const lo=Au.approved_tools_by_server;if(lo==null)return new Map;if(typeof lo!="object")return new Map;const $u=new Map;for(const[Ru,Iu]of Object.entries(lo)){if(!Array.isArray(Iu))continue;const Ou=Iu.filter(Mu=>typeof Mu=="string"&&Mu.length>0).map(Mu=>{const Du=Mu.indexOf("__");return Du>=0?Mu.slice(Du+2):Mu});$u.set(Ru,new Set(Ou))}return $u}const WELCOME_AT=new Date(0);function ChatBase(Au){const{agentRuntimeConfig:lo,protocol:$u,useStore:Ru=!0,disableInternalJupyterTheme:Iu=!1,themeVariant:Pu,colorMode:Ou,themeOverrides:Mu}=Au,Bu=lo?{type:(typeof $u=="string"?$u:void 0)||lo.protocol||"vercel-ai",endpoint:lo.url,authToken:lo.authToken,agentId:lo.agentId,enableConfigQuery:!0,configEndpoint:`${lo.url}/api/v1/config`}:typeof $u=="object"?$u:void 0,ju=lo?!1:Ru,Fu=reactExports.useContext(QueryClientContext),zu={...Au,protocol:Bu,useStore:ju},Uu=jsxRuntimeExports.jsx(ChatBaseInner,{...zu}),Hu=Iu?Uu:jsxRuntimeExports.jsx(ThemedChatBoundary,{themeVariant:Pu,colorMode:Ou,themeOverrides:Mu,children:Uu});return Fu?Hu:jsxRuntimeExports.jsx(QueryClientProvider,{client:internalQueryClient,children:Hu})}function ChatBaseInner({title:Au,subtitle:lo,showHeader:$u=!1,showTokenUsage:Ru=!0,showContextRing:Iu=!1,showLoadingIndicator:Pu=!0,showErrors:Ou=!0,showInput:Mu=!0,showModelSelector:Du=!0,showToolsMenu:Lu=!0,showSkillsMenu:Bu=!0,disableInputPrompt:ju=!1,promptVariant:Fu,mentionableAgents:zu,promptCommands:Uu,showAgentsMenu:Hu=!0,agents:Vu,selectedAgentId:Gu,onSelectAgent:Wu,disabled:Ku,disableReason:Ju,overlay:Yu,launching:Xu=!1,launchingMessage:ed,autoConnect:td=!0,codemodeEnabled:nd=!1,onToggleCodemode:od,initialModel:sd,availableModels:ad,mcpServers:pd,initialSkills:gd,className:Sd,loadingState:_d,headerActions:yd,kernelIndicatorState:wd,kernelIndicatorPlacement:Ad="left",kernel:md,kernelEnvironmentName:dd,kernelCpu:bd,kernelMemory:ld,kernelGpu:ud,themeVariant:hd,colorMode:vd,chatViewMode:Ed,onChatViewModeChange:Cd,disabledViewModes:Rd,useStore:jd=!0,protocol:Td,onSendMessage:$d,onSendReady:Id,onLoadingChange:qd,onSpeakingChange:Md,onContextSnapshot:Wd,enableStreaming:rh=!1,brandIcon:Yd,avatarConfig:mh,headerButtons:oh,showPoweredBy:yh=!1,poweredByProps:gh,emptyState:Xd,renderHeader:eh,showTurnFooter:ah=!0,renderMessageFooter:Oh,notebookToolSurfacesId:Gd,footerContent:zd,welcome:Pd,trailingContent:Od,voice:Vd,voiceSpeaking:Ld=!1,voiceSentence:Kd,onStopSpeaking:Qd,voiceLevel:fh,onReadAloud:_h,showInformation:Ch=!1,onInformationClick:Zh,headerContent:Nd,children:xd,borderRadius:Hd,backgroundColor:Zd,border:hh,boxShadow:wh,compact:Eh=!1,placeholder:Ah,description:$h="Start a conversation with the AI agent.",onStateUpdate:Sh,onNewChat:Mh,onClear:Kh,onMessagesChange:Ph,onItemsChange:rp,onDisplayItemsChange:ip,autoFocus:up=!1,suggestions:bp,submitOnSuggestionClick:Qh=!0,hideMessagesAfterToolUI:_p=!1,focusTrigger:np,frontendTools:ap,enableEphemeralNotebook:qh=!1,initialEphemeralNotebookOpen:Uh=!0,onEphemeralNotebookOpenChange:Jh,enableEphemeralDocument:wf=!1,initialEphemeralSurfaceMode:Op,onEphemeralSurfaceModeChange:Rh,collapsed:jh=!1,onExpandFromCollapsed:Qp,ephemeralNotebookToolbar:Fp,ephemeralNotebookToolbarExtraItems:ef,ephemeralDocumentToolbarExtraItems:tf,ephemeralNotebookCollaborationProvider:tp,ephemeralNotebookCollaborationDocumentId:Gp,ephemeralDocumentCollaboration:Tf,ephemeralRuntimeOverride:nm,onToolCallStart:Af,onToolCallComplete:jf,onToolCallUpdate:Gf,inspector:vp,onAuthorizationRequired:zp,connectedIdentities:xp,runtimeId:Cp,thread:pf,historyEndpoint:Zp,historyAuthToken:uf,pendingPrompt:fp,contextSnapshot:Em,mcpStatusData:ff,sandboxStatusData:Cm,showToolApprovalBanner:Pf=!0,pendingApprovals:gm,onApproveApproval:mf,onRejectApproval:Tm}){const om=useChatWords();reactExports.useEffect(()=>{setupPrimerPortals()},[]);const Of=useChatAvailability(),Dh=Ku??Of.disabled,Ud=Ju??Of.disableReason,{theme:lh}=useThemeStore(),Lh=getColorPalette(lh,"dark").textLight,Nh=useAgentRuntimeStore(Dd=>Dd.approvals),hp=useAgentRuntimeStore(Dd=>Dd.historyVersion),lp=useAgentRuntimeStore(Dd=>Dd.mcpStatus),Sp=ff??lp,Np=typeof Td=="object"?Td:void 0,yf=useCoreStore(Dd=>Dd.configuration?.aiAgentsUrl),Fh=Np?.agentId||Cp,cp=Cp||Fh,Up=Np?.authToken,dm=reactExports.useRef(`ephemeral-notebook-${Math.random().toString(36).slice(2,10)}`),kf=Cp||Np?.agentId||Fh,Yp=Gp||(kf?`ephemeral-notebook-${kf}`:dm.current),Pm=useAgentRuntimeStore(Dd=>Dd.getEphemeralNotebookModel(Yp)),Om=useAgentRuntimeStore(Dd=>Dd.setEphemeralNotebookModel),og=reactExports.useCallback(Dd=>{Om(Yp,Dd)},[Yp,Om]),Wf=Tf?.roomId||(kf?`ephemeral-document-${kf}`:`ephemeral-document-${dm.current}`),Ff=useAgentRuntimeStore(Dd=>Dd.getEphemeralDocumentModel(Wf)),Kf=useAgentRuntimeStore(Dd=>Dd.setEphemeralDocumentModel),zf=reactExports.useCallback(Dd=>{Kf(Wf,Dd)},[Wf,Kf]),Ef=Op??(qh&&Uh?"notebook":"none"),[Uf,Ep]=reactExports.useState(Ef),Hf=reactExports.useCallback(Dd=>{Ep(Dd),Rh?.(Dd),Jh?.(Dd==="notebook")},[Rh,Jh]),gf=qh&&Uf==="notebook",Vh=wf&&Uf==="document",$p=gf||Vh,Hp=$p&&jh,vf=Hp?{key:"ephemeral-surface",type:"custom",order:900,render:()=>jsxRuntimeExports.jsx(EphemeralSurfaceControl,{mode:Uf,onChange:Hf,enableNotebook:qh,enableDocument:wf,enableChatOnly:!1})}:null,Mf=vf?[...ef??[],vf]:ef,vm=vf?[...tf??[],vf]:tf,[Zf,Ap]=reactExports.useState(null);reactExports.useEffect(()=>{if(!gf){Ap(null);return}const Dd=()=>notebookStore.getState().selectNotebook(Yp)?.adapter?.kernel??null,Fd=()=>{const nh=Dd();Ap(bh=>bh?.id===nh?.id?bh:nh)};Fd();const sh=window.setInterval(Fd,750),vh=notebookStore.subscribe(Fd);return()=>{window.clearInterval(sh),vh()}},[gf,Yp]);const[Yf,Am]=reactExports.useState(null),df=reactExports.useCallback(Dd=>{Am(Fd=>Fd?.id===Dd?.id?Fd:Dd)},[]);reactExports.useEffect(()=>{Vh||Am(null)},[Vh]);const Yh=$p&&isFloatingChatViewMode(Ed),Lp=Ed==="floating-small"||Ed==="floating-draggable",hm=useNotebookTools(Yp),[rf,$f]=reactExports.useState([]),u0=reactExports.useCallback(Dd=>{$f(Dd)},[]),Mm=reactExports.useMemo(()=>gf?[...ap||[],...hm]:Vh?[...ap||[],...rf]:ap,[gf,Vh,ap,hm,rf]),Hg=reactExports.useMemo(()=>normalizeAiAgentsBaseUrl(yf||DEFAULT_SERVICE_URLS.AI_AGENTS),[yf]),Jf=reactExports.useRef(null),d0=reactExports.useRef(new Map),Tg=reactExports.useCallback((Dd,Fd,sh)=>{const vh=Jf.current;if(!vh||vh.readyState!==WebSocket.OPEN)return logApprovalTrace("send_decision_skipped_ws_not_ready",{approvalId:Dd,approved:Fd,wsReadyState:vh?.readyState}),!1;try{return logApprovalTrace("send_decision",{approvalId:Dd,approved:Fd,hasNote:!!sh}),vh.send(JSON.stringify({type:"tool_approval_decision",approvalId:Dd,approved:Fd,...sh?{note:sh}:{}})),!0}catch{return logApprovalTrace("send_decision_failed",{approvalId:Dd,approved:Fd}),!1}},[]),qg=reactExports.useCallback(()=>{const Dd=Jf.current;if(!Dd||Dd.readyState!==WebSocket.OPEN)return!1;try{return Dd.send(JSON.stringify({type:"tool-approvals-history"})),logApprovalTrace("request_history",{}),!0}catch{return!1}},[]),D0=reactExports.useCallback(Dd=>{Dd&&(d0.current.set(Dd,Date.now()+RESOLVED_TOOL_CALL_SUPPRESSION_MS),logApprovalTrace("suppress_pending_for_tool_call",{toolCallId:Dd,windowMs:RESOLVED_TOOL_CALL_SUPPRESSION_MS}))},[]),g1=reactExports.useCallback(Dd=>{if(!Dd)return!1;const Fd=d0.current.get(Dd);return Fd?Fd<Date.now()?(d0.current.delete(Dd),!1):!0:!1},[]),N0=reactExports.useCallback((Dd,Fd,sh)=>{window.setTimeout(()=>{if(!agentRuntimeStore.getState().approvals.some(bh=>bh.id===Dd&&bh.status==="pending"))return;const nh=Tg(Dd,Fd,sh);logApprovalTrace("retry_send_decision",{approvalId:Dd,approved:Fd,sent:nh}),nh&&qg()},500)},[qg,Tg]),L0=reactExports.useMemo(()=>gm||Nh.filter(Dd=>Dd.status==="pending"&&isApprovalForAgent(Dd,Fh)).map(Dd=>({id:Dd.id,toolName:Dd.tool_name,toolDescription:Dd.note??void 0,args:Dd.tool_args??{},agentId:Dd.agent_id??"",requestedAt:Dd.created_at??new Date().toISOString()})),[gm,Nh,Fh]),G1=reactExports.useCallback((Dd,Fd)=>{const sh=agentRuntimeStore.getState().approvals.find(Wh=>Wh.id===Dd),vh=sh?.tool_name;if(!vh)return;const bh=(()=>{if(vh.startsWith("skill:")){const pp=vh.slice(6);return pp?normalizeSkillApprovalId(pp):null}if(!new Set(["run_skill_script","load_skill","read_skill_resource"]).has(vh))return null;const gp=sh?.tool_args??{},Gh=gp.skill_name??gp.skill??gp.name;return typeof Gh!="string"||!Gh?null:normalizeSkillApprovalId(Gh)})();if(bh){f0(gp=>{const Gh=new Map(gp);return Gh.set(bh,Fd),Gh}),agentRuntimeStore.getState().sendRawMessage({type:Fd?"skill_approve":"skill_unapprove",skillId:bh},Fh)||console.warn("[ChatBase] skill_approve persistence dropped: websocket not ready");return}const zh=vh.indexOf("__");if(zh!==-1){const Wh=vh.slice(0,zh),gp=vh.slice(zh+2);agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tool_approve",serverId:Wh,toolName:gp,approved:Fd},Fh)||console.warn("[ChatBase] mcp_server_tool_approve persistence dropped: websocket not ready")}},[Fh]),h0=reactExports.useCallback(async(Dd,Fd,sh)=>{const nh=agentRuntimeStore.getState().approvals.find(Wh=>Wh.id===Dd)?.tool_call_id??sh;D0(nh);const bh=Tg(Dd,!0,Fd);bh||console.warn("[ChatBase] ai-agents tool_approval_decision not sent: websocket not ready");const zh=agentRuntimeStore.getState().sendDecision(Dd,!0,Fd,nh,Fh);zh?G1(Dd,!0):console.warn("[ChatBase] tool_approval_decision dropped: websocket not ready"),(bh||zh)&&agentRuntimeStore.getState().removeApproval(Dd),qg(),N0(Dd,!0,Fd),await mf?.(Dd,Fd)},[Fh,D0,mf,G1,N0,qg,Tg]),Vg=reactExports.useCallback(async(Dd,Fd,sh)=>{const nh=agentRuntimeStore.getState().approvals.find(Wh=>Wh.id===Dd)?.tool_call_id??sh;D0(nh);const bh=Tg(Dd,!1,Fd);bh||console.warn("[ChatBase] ai-agents tool_approval_decision not sent: websocket not ready");const zh=agentRuntimeStore.getState().sendDecision(Dd,!1,Fd,nh,Fh);zh||console.warn("[ChatBase] tool_approval_decision dropped: websocket not ready"),(bh||zh)&&agentRuntimeStore.getState().removeApproval(Dd),qg(),N0(Dd,!1,Fd),await Tm?.(Dd,Fd)},[Fh,D0,Tm,N0,qg,Tg]),B0=reactExports.useRef(null),km=reactExports.useCallback(Dd=>{const Fd=agentRuntimeStore.getState(),sh=new Set([Dd.id]),nh=!!Dd.tool_name?approvalSignature(Dd.tool_name,Dd.tool_args??{}):null;for(const bh of Fd.approvals){if(bh.status!=="pending"||!isApprovalForAgent(bh,Fh))continue;if(bh.id===Dd.id){sh.add(bh.id);continue}if(Dd.tool_call_id&&bh.tool_call_id&&bh.tool_call_id===Dd.tool_call_id){sh.add(bh.id);continue}if(!nh||!bh.tool_name)continue;approvalSignature(bh.tool_name,bh.tool_args??{})===nh&&sh.add(bh.id)}for(const bh of sh)Fd.removeApproval(bh)},[Fh]);reactExports.useEffect(()=>{if(!Pf||gm||!Up)return;const Dd=toWsUrl(Hg,`${AI_AGENTS_API_PREFIX}/ws`,Up);if(!Dd)return;let Fd=!1;const sh=new WebSocket(Dd);return Jf.current=sh,sh.onopen=()=>{logApprovalTrace("ws_open_request_history",{activeAgentId:Fh}),sh.send(JSON.stringify({type:"tool-approvals-history"}))},sh.onmessage=vh=>{try{const nh=JSON.parse(String(vh.data)),bh=[],zh=typeof nh.type=="string"?nh.type:void 0,Wh=typeof nh.event=="string"?nh.event:void 0;if(zh==="tool-approvals-history"){const pp=(nh.data&&typeof nh.data=="object"?nh.data:{}).approvals;if(Array.isArray(pp))for(const Hh of pp)Hh&&typeof Hh=="object"&&bh.push(Hh)}else if(Wh?.startsWith("tool_approval_")){const Gh=nh.data&&typeof nh.data=="object"?nh.data:nh.payload&&typeof nh.payload=="object"?nh.payload:null;if(Gh){const pp=statusFromApprovalEvent(Wh);logApprovalTrace("recv_tool_approval_event",{event:Wh,approvalId:typeof Gh.id=="string"?Gh.id:typeof Gh.approval_id=="string"?Gh.approval_id:void 0,status:typeof Gh.status=="string"?Gh.status:pp}),bh.push(pp&&typeof Gh.status!="string"?{...Gh,status:pp}:Gh)}}if(bh.length===0)return;const gp=agentRuntimeStore.getState();for(const Gh of bh){let pp=normalizeApprovalPayload(Gh);if(!pp){const Rp=typeof Gh.id=="string"&&Gh.id||typeof Gh.approval_id=="string"&&Gh.approval_id||typeof Gh.approvalId=="string"&&Gh.approvalId||"",Bp=typeof Gh.status=="string"&&Gh.status||"";if(Rp&&Bp&&Bp!=="pending"){const xf=gp.approvals.find(Lf=>Lf.id===Rp);xf&&(pp={...xf,status:Bp})}}if(!pp)continue;const Hh=pp.agent_id||!Fh?pp:{...pp,agent_id:Fh};if(isApprovalForAgent(Hh,Fh)){if(Hh.status==="pending"&&g1(Hh.tool_call_id)){logApprovalTrace("drop_transient_pending",{approvalId:Hh.id,toolCallId:Hh.tool_call_id,status:Hh.status});continue}logApprovalTrace("apply_tool_approval_update",{approvalId:Hh.id,status:Hh.status,agentId:Hh.agent_id,activeAgentId:Fh}),Hh.status==="pending"?gp.upsertApproval(Hh):(km(Hh),B0.current?.(Hh,Hh.status==="approved",Hh.note??void 0))}}}catch{}},sh.onclose=()=>{Fd||(Jf.current=null)},sh.onerror=()=>{Jf.current=null},()=>{Fd=!0,Jf.current=null,sh.close()}},[Pf,gm,Hg,Up,Fh,g1,km]);const Xh=typeof Td=="object"?Td:void 0,Pv=Xh?JSON.stringify(Xh):"",b1="agent-runtimes",j0=useChatStore(Dd=>Dd.clearMessages),pm=Xh?.type==="a2a",[F0,z0]=reactExports.useState(()=>emptyConversation(BROWSER_LIMITS)),Xf=reactExports.useRef(F0),Gg=reactExports.useRef(!1),Rf=reactExports.useCallback(Dd=>{const Fd=Dd(Xf.current);Fd!==Xf.current&&(Xf.current=Fd,Gg.current=!0,z0(Fd))},[]),[p0,W1]=reactExports.useState(emptyChatLayer),Ag=reactExports.useRef(p0),im=reactExports.useCallback(Dd=>{const Fd=Dd(Ag.current);Fd!==Ag.current&&(Ag.current=Fd,W1(Fd))},[]),ig=reactExports.useCallback(()=>{Rf(()=>emptyConversation(BROWSER_LIMITS)),im(()=>emptyChatLayer())},[Rf,im]),Qf=reactExports.useCallback(Dd=>{let Fd;try{Fd=reduceConversation(emptyConversation(BROWSER_LIMITS),snapshotOfMessages(Dd))}catch(vh){console.error("[ChatBase] Conversation not read again:",vh),Df(vh instanceof Error?vh:new Error(String(vh)));return}const sh=new Map;for(const vh of Dd){const{id:nh,role:bh,content:zh,toolCalls:Wh,...gp}=vh;sh.set(nh,gp)}im(()=>({...emptyChatLayer(),extras:sh})),Rf(()=>Fd)},[Rf,im]),bm=reactExports.useCallback(Dd=>Rf(Fd=>reduceConversation(Fd,Dd)),[Rf]),hg=reactExports.useCallback(Dd=>{const Fd=Xf.current.items.find(sh=>sh.kind==="tool"&&sh.id===Dd);return Fd&&Fd.kind==="tool"?toolCallOf(Fd):void 0},[]),qf=reactExports.useCallback(()=>Xf.current.items.flatMap(Dd=>Dd.kind==="tool"?[toolCallOf(Dd)]:[]),[]),Dm=reactExports.useRef(om);Dm.current=om;const pg=reactExports.useMemo(()=>conversationDrawer(Dd=>Dm.current.error(Dd)),[]),Wp=reactExports.useMemo(()=>pg(F0,p0),[pg,F0,p0]),kg=reactExports.useRef(Wp);kg.current=Wp;const[fg,Wg]=reactExports.useState(null),[y1,Bh]=reactExports.useState(!1),[yp,bf]=reactExports.useState(!1),[$m,Jp]=reactExports.useState(),[mg,ym]=reactExports.useState(!1),[_m,Df]=reactExports.useState(null),[Kg,gg]=reactExports.useState("");reactExports.useEffect(()=>{if(!md){Jp(void 0);return}Jp(md.status);const Dd=(Fd,sh)=>{Jp(sh)};return md.statusChanged.connect(Dd),()=>{md.statusChanged.disconnect(Dd)}},[md]);const[sm,xm]=reactExports.useState(!cp),[K1,Z1]=reactExports.useState(0),$g=reactExports.useRef(new Map),Y1=reactExports.useRef(emptyUiModel()),_1=reactExports.useRef(new Set),[J1,U0]=reactExports.useState(!1),x1=reactExports.useRef(null),Nm=fp&&[Cp||Zp||Xh?.endpoint||Xh?.agentId,fp].filter(Boolean).join("::"),[sg,Ov]=reactExports.useState(""),[Rg,vg]=reactExports.useState(new Map),[Mv,X1]=reactExports.useState(new Map),[H0,fb]=reactExports.useState([]),Zg=useAgentRuntimeWsState(),S1=!!Xh?.enableConfigQuery&&td,jp=useConfig(S1,Xh?.configEndpoint,Xh?.authToken,Xh?.agentId),Ig=useSkills(S1&&Bu,Xh?.configEndpoint,Xh?.authToken),{enableSkill:q0,disableSkill:w1,approveSkill:Dv,unapproveSkill:Q1}=useSkillActions(Fh),[Hm,f0]=reactExports.useState(new Map);reactExports.useEffect(()=>{f0(new Map)},[Fh]);const fm=reactExports.useMemo(()=>{const Dd=new Set;for(const Fd of Ig.data?.skills??[])(Fd.status==="enabled"||Fd.status==="loaded")&&Dd.add(Fd.id);return Dd},[Ig.data]);reactExports.useEffect(()=>{if(!Fh||T1.current.has(Fh))return;const Dd=Ig.data?.skills??[];if(Dd.length===0)return;if(Dd.some(nh=>nh.status==="enabled"||nh.status==="loaded")){T1.current.add(Fh);return}const sh=Dd.filter(nh=>nh.status==="available").map(nh=>nh.id).filter(Boolean);if(sh.length===0){T1.current.add(Fh);return}sh.every(nh=>q0(nh))&&T1.current.add(Fh)},[Fh,Ig.data,q0]);const Yg=reactExports.useMemo(()=>{const Dd=new Set;for(const Fd of Ig.data?.skills??[])Fd.approved===!0&&Dd.add(Fd.id);return Hm.forEach((Fd,sh)=>{Fd?Dd.add(sh):Dd.delete(sh)}),Dd},[Hm,Ig.data]),ev=reactExports.useMemo(()=>{const Dd=jp.data?.builtinTools??[],Fd=Xh?.options?.frontendTools??[],sh=new Set(Dd.map(nh=>nh.name)),vh=[...Mm??[],...Fd].filter(nh=>sh.has(nh.name)?!1:(sh.add(nh.name),!0)).map(nh=>({id:nh.name,name:nh.name}));return{runtime:Dd,frontend:vh}},[jp.data?.builtinTools,Mm,Xh?.options]),Jg=reactExports.useMemo(()=>Vu??(Fh?[{id:Fh,name:Au||Fh,description:lo||$h}]:[]),[Vu,Fh,Au,lo,$h]),m0=typeof Xh?.options?.model=="string"?(Xh?.options).model:void 0,Pg=reactExports.useMemo(()=>{const Dd=ad||jp.data?.models||(jp.isError?[]:void 0);return offeredModels(Dd,()=>{const Fd=Object.values(AI_MODEL_CATALOGUE).filter(sh=>sh.available&&isChatModel(sh)).map(sh=>({id:sh.id,name:sh.name,provider:sh.provider}));return Fd.length>0?Fd:m0?[{id:m0,name:m0,provider:"inference"}]:[]})},[ad,jp.data?.models,jp.isError,m0]),g0=reactExports.useMemo(()=>zu??Jg.map(Dd=>({name:Dd.name,description:Dd.description,icon:Dd.icon,disabled:Dd.id===(Gu??Jg[0]?.id),disabledReason:`You are already talking to ${Dd.name}`})),[zu,Jg,Gu]),mb=useContextSnapshot(S1&&Ru,Xh?.configEndpoint,Xh?.agentId,Xh?.authToken),tv=reactExports.useMemo(()=>Xh?.enableConfigQuery?void 0:{totalTokens:fg?.totalTokens??0,contextWindow:2e5,sumResponseInputTokens:fg?.sessionInput??0,sumResponseOutputTokens:fg?.sessionOutput??0,systemPromptTokens:0,userMessageTokens:0,assistantMessageTokens:0,toolTokens:0,toolCallTokens:0,toolReturnTokens:0,historyToolCallTokens:0,historyToolReturnTokens:0,currentToolCallTokens:0,currentToolReturnTokens:0,turnUsage:{inputTokens:fg?.turnInput??0,outputTokens:fg?.turnOutput??0,requests:0,toolCalls:0,toolNames:[],durationSeconds:0},sessionUsage:{inputTokens:fg?.sessionInput??0,outputTokens:fg?.sessionOutput??0,requests:0,toolCalls:0,turns:0,durationSeconds:0}},[fg,Xh?.enableConfigQuery]),v0=reactExports.useRef(Fh),gb=reactExports.useRef(null),am=mb.data,rv=reactExports.useRef(am);rv.current=am,reactExports.useEffect(()=>{v0.current!==Fh&&(v0.current=Fh,Wg(null),gb.current=rv.current??null)},[Fh]);const Og=am&&am!==gb.current?am:void 0,E1=Em??Og??tv;reactExports.useEffect(()=>{Wd?.(E1)},[E1,Wd]);const C1=useSandbox(S1&&$u&&!Xh?.ownRoutesOnly,Xh?.configEndpoint,Xh?.authToken,Xh?.agentId),Vf=reactExports.useRef(null),nv=reactExports.useRef(null),Lm=reactExports.useRef(0),ov=reactExports.useRef(new Set),T1=reactExports.useRef(new Set),Bm=reactExports.useRef(new Set),qm=reactExports.useRef(!1),Xg=reactExports.useRef(_p);Xg.current=_p;const bg=reactExports.useRef(pf?.id||generateMessageId()),V0=reactExports.useRef(pf),jm=reactExports.useRef(pf?.messages.length?pf.id:null),Fm=reactExports.useCallback(()=>{const Dd=bg.current;jm.current!==Dd&&(jm.current=Dd,V0.current?.onStarted?.(Dd))},[]),Vm=reactExports.useRef(null),Rm=reactExports.useRef([]),Gm=reactExports.useRef(new Set),ag=Xh?.uiSocket,iv=reactExports.useRef(Xh?.authToken);iv.current=Xh?.authToken;const A1=Xh?.uiFiles,k1=reactExports.useCallback(Dd=>A1?uploadFile(Dd,{url:A1,scope:bg.current,token:iv.current}):Promise.reject(new Error("This conversation takes no file.")),[A1]),b0=reactExports.useCallback(()=>{const Dd=Ag.current;return Xf.current.items.flatMap(Fd=>Fd.kind==="message"||Fd.kind==="error"?[{id:Fd.id,displays:Dd.displays.get(Fd.id),speaker:Dd.speakers.get(Fd.id)}]:[])},[]),If=reactExports.useCallback(Dd=>{const Fd=b0();let sh;try{sh=withUiOp(Fd,Dd)}catch(bh){console.error("[ChatBase] reactor.ui op not applied:",bh);return}const vh=new Set(sh.map(bh=>bh.id)),nh=Fd.filter(bh=>!vh.has(bh.id)).map(bh=>bh.id);im(bh=>{const zh=new Map(bh.displays),Wh=new Map(bh.speakers);for(const gp of sh)gp.displays&&zh.set(gp.id,gp.displays),gp.speaker&&Wh.set(gp.id,gp.speaker);for(const gp of nh)zh.delete(gp),Wh.delete(gp);return{...bh,displays:zh,speakers:Wh}}),nh.length>0&&Rf(bh=>withoutItems(bh,nh))},[b0,im,Rf]),sf=reactExports.useCallback((Dd,Fd)=>{if(Fd){if(Dd.op==="window")return;if((Dd.op==="show"||Dd.op==="ask")&&isStepDisplay(Dd.body)){Gm.current.add(Dd.body.id);return}if((Dd.op==="patch"||Dd.op==="append")&&Gm.current.has(Dd.id))return}let sh;try{sh=routeUiOp(Dd,Y1.current,_1.current)}catch(nh){console.error("[ChatBase] reactor.ui op not applied:",nh);return}Y1.current=sh.steps;const vh=sh.routed;if(vh.to==="window")tellLoopWindow(vh.data);else if(vh.to==="step"){const nh=vh.step;im(bh=>{const zh=new Map(bh.steps.map(Gh=>[Gh.item.id,Gh.after])),Wh=Xf.current.items.at(-1)?.id??null,gp=withLoopStep(bh.steps.map(Gh=>Gh.item),nh);return{...bh,steps:gp.map(Gh=>({item:Gh,after:zh.has(Gh.id)?zh.get(Gh.id)??null:Wh}))}})}else if(vh.to==="element")_1.current.add(vh.change.id),applyLoopElement(vh.change);else if(placeable(b0(),vh.op))If(vh.op);else{const nh=vh.op.op==="show"||vh.op.op==="ask"?vh.op.body.data?.message_id:void 0;Fd&&typeof nh=="string"?(bm({type:"MESSAGE_SAID",messageId:nh,role:"assistant",text:"",streaming:!1}),If(vh.op)):Rm.current.push(vh.op)}},[If,b0,im,bm]),kp=reactExports.useRef(sf);kp.current=sf,reactExports.useEffect(()=>{if(Rm.current.length===0)return;const Dd=Rm.current.splice(0);for(const Fd of Dd){if(!placeable(b0(),Fd)){Rm.current.push(Fd);continue}If(Fd)}},[F0,If,b0]);const Mg=reactExports.useCallback(()=>{if(!ag)return null;const Dd=bg.current,Fd=Vm.current;if(Fd&&Fd.scope===Dd)return Fd.socket;Fd?.socket.close(),Y1.current=emptyUiModel(),_1.current=new Set,Rm.current=[],Gm.current=new Set;const sh=new UiSocket({url:ag,scope:Dd,token:()=>iv.current??"",onOp:(vh,nh,bh)=>kp.current(vh,bh),onStatus:(vh,nh)=>{(vh==="refused"||vh==="gone")&&console.error(`[ChatBase] ui socket ${vh}: ${nh??""}`)}});return Vm.current={socket:sh,scope:Dd},sh.connect(),sh},[ag]),Im=reactExports.useRef(Mg);Im.current=Mg,reactExports.useEffect(()=>(pf?.messages.length&&Im.current(),()=>{Vm.current?.socket.close(),Vm.current=null}),[]);const $1=reactExports.useRef(null),Dg=reactExports.useRef(null),Ng=reactExports.useRef(null),R1=reactExports.useRef(null),lg=reactExports.useRef(!1),Qg=reactExports.useRef(xp);Qg.current=xp;const I1=reactExports.useRef(Mm);I1.current=Mm;const G0=reactExports.useRef(Af);G0.current=Af;const sv=reactExports.useRef(jf);sv.current=jf;const Lg=reactExports.useRef(Gf);Lg.current=Gf;const Bg=useAgentInspectorTracer(),Wm=vp??Bg,yg=reactExports.useRef("Agent");yg.current=typeof Au=="string"&&Au||Fh||"Agent";const Km=reactExports.useRef(null);Wm&&Km.current?.tracer!==Wm?Km.current={tracer:Wm,recorder:chatSpanRecorder(Wm,()=>yg.current,{frontendTools:()=>(I1.current??[]).map(Dd=>Dd.name)})}:Wm||(Km.current=null);const W0=reactExports.useRef(""),y0=reactExports.useRef(void 0),K0=reactExports.useRef(null);reactExports.useEffect(()=>{let Dd=agentRuntimeStore.getState().toolDecisionRequest?.seq??0;return agentRuntimeStore.subscribe(Fd=>Fd.toolDecisionRequest,Fd=>{if(!Fd||Fd.seq===Dd)return;Dd=Fd.seq;const sh=K0.current;if(!sh)return;const vh=zh=>(zh??"").toLowerCase().replace(/[-_]/g,""),nh=qf(),bh=nh.find(zh=>zh.result?.approvalId===Fd.approvalId)??nh.find(zh=>vh(zh.toolName)===vh(Fd.toolName)&&(zh.status==="executing"||zh.status==="inProgress"));bh&&sh(bh.toolCallId,{type:"tool-approval-decision",approved:Fd.approved,approvalId:Fd.approvalId,toolName:bh.toolName})})},[]);const jg=reactExports.useCallback((Dd,Fd,sh)=>{if(!Dd?.id||ov.current.has(Dd.id))return!1;let vh=Dd.tool_call_id;if(!vh)for(const bh of qf()){if(bh.status!=="inProgress"&&bh.status!=="executing")continue;const zh=approvalSignature(bh.toolName,bh.args??{}),Wh=approvalSignature(Dd.tool_name,Dd.tool_args??{});if(zh===Wh){vh=bh.toolCallId;break}}if(!vh)return!1;const nh=hg(vh);return!nh||nh.status!=="inProgress"&&nh.status!=="executing"?!1:(ov.current.add(Dd.id),K0.current?.(vh,{type:"tool-approval-decision",approved:Fd,approvalId:Dd.id,toolName:Dd.tool_name||nh.toolName,_fromServerEcho:!0,_alreadyDispatched:!0,...sh?{message:sh}:{}}),!0)},[Fh]);B0.current=jg;const lm=!!(Xh?.endpoint&&/\/api\/runtimes\/v1\/agent-nodes\/[^/]+\/ag-ui\/?$/.test(Xh.endpoint)),P1=Xh?.configEndpoint?Xh.configEndpoint.replace(/\/api\/v1\/(config|configure)\/?$/,""):Xh?.endpoint?.replace(/\/api\/v1\/.*$/,"")??"";useAgentRuntimeWebSocket({enabled:!!Xh&&!!P1&&!lm&&!Xh.ownRoutesOnly,baseUrl:P1,authToken:Xh?.authToken,agentId:Xh?.agentId,onMessage:Dd=>{if(Dd.type!=="tool_approval_created"&&Dd.type!=="tool_approval_approved"&&Dd.type!=="tool_approval_rejected")return;const Fd=Dd.payload;if(Fd){if(Dd.type==="tool_approval_created"){isApprovalForAgent(Fd,Fh)&&agentRuntimeStore.getState().upsertApproval(Fd);return}km(Fd),jg(Fd,Dd.type==="tool_approval_approved",Fd.note??void 0)}}});const _0=reactExports.useCallback(Dd=>{if(!pd)return!0;const Fd=Dd.isConfig===!1?"catalog":"config";return pd.some(sh=>sh.id===Dd.id&&sh.origin===Fd)},[pd]);reactExports.useEffect(()=>{if(up&&Ng.current){const Dd=setTimeout(()=>Ng.current?.focus(),100);return()=>clearTimeout(Dd)}},[up]),reactExports.useEffect(()=>{if(np!==void 0&&np>0&&Ng.current){const Dd=setTimeout(()=>Ng.current?.focus(),150);return()=>clearTimeout(Dd)}},[np]);const vb=reactExports.useRef(!1);reactExports.useEffect(()=>{if(vb.current&&!yp&&Ng.current){const Dd=setTimeout(()=>Ng.current?.focus(),50);return()=>clearTimeout(Dd)}vb.current=yp},[yp]);const av=reactExports.useCallback(()=>{const Dd=Ng.current;if(Dd){Dd.style.height="auto";const Fd=120,vh=Math.min(Math.max(Dd.scrollHeight,40),Fd);Dd.style.height=`${vh}px`,Dd.style.overflowY=Dd.scrollHeight>Fd?"auto":"hidden"}},[]);reactExports.useEffect(()=>{av()},[Kg,av]),reactExports.useEffect(()=>{const Dd=setTimeout(av,0);return()=>clearTimeout(Dd)},[av]),reactExports.useEffect(()=>{if(Pg.length===0||isOffered(Pg,sg))return;const Dd=initialModelId(Pg,sd||jp.data?.defaultModel||DEFAULT_MODEL);Dd&&Dd!==sg&&Ov(Dd)},[Pg,sg,sd,jp.data?.defaultModel]);const bb=reactExports.useRef(!1);reactExports.useEffect(()=>{if(Pg.length>0&&!bb.current){bb.current=!0;const Dd=jp.data?.builtinTools?.map(Fd=>Fd.id)||[];if(fb(Dd),jp.data?.mcpServers){const Fd=new Map;for(const sh of jp.data.mcpServers)if(sh.isAvailable&&sh.enabled&&_0(sh)){const nh=new Set(sh.tools.map(bh=>bh.name).filter(bh=>!!bh));Fd.set(sh.id,nh)}vg(Fd)}}},[jp.data,Pg,sg,sd,ad,pd,_0]),reactExports.useEffect(()=>{!jp.data?.mcpServers||!pd||vg(Dd=>{const Fd=new Map;for(const sh of jp.data?.mcpServers??[])if(_0(sh)&&Dd.has(sh.id)){const vh=Dd.get(sh.id);vh&&Fd.set(sh.id,vh)}else if(_0(sh)&&sh.isAvailable&&sh.enabled){const vh=new Set(sh.tools.map(nh=>nh.name).filter(nh=>!!nh));Fd.set(sh.id,vh)}return Fd})},[pd,jp.data?.mcpServers,_0]);const af=reactExports.useRef(pd);af.current=pd,reactExports.useEffect(()=>{const Dd=parseEnabledMcpToolsByServer(Sp);if(!Dd)return;const Fd=Fh||"__global__",sh=!Bm.current.has(Fd)&&Zg==="connected";vg(vh=>{const nh=new Map(vh);if(Dd.forEach((bh,zh)=>{(!af.current||af.current.some(gp=>gp.id===zh))&&bh.size!==0&&nh.set(zh,new Set(bh))}),sh){const bh=[];for(const Wh of jp.data?.mcpServers??[]){if(!(!af.current||af.current.some(Hh=>Hh.id===Wh.id))||!Wh.isAvailable||!Wh.enabled)continue;const Gh=Wh.tools.map(Hh=>Hh.name).filter(Hh=>!!Hh);if(Gh.length===0)continue;const pp=nh.get(Wh.id);(!pp||pp.size===0)&&(nh.set(Wh.id,new Set(Gh)),bh.push({serverId:Wh.id,enabledToolNames:Gh}))}let zh=!0;for(const Wh of bh)agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Wh.serverId,enabledToolNames:Wh.enabledToolNames},Fh)||(zh=!1,console.warn("[ChatBase] initial mcp_server_tools_set dropped: websocket not ready"));zh&&Bm.current.add(Fd)}return nh})},[Sp,Fh,jp.data?.mcpServers,Zg]),reactExports.useEffect(()=>{const Dd=parseApprovedMcpToolsByServer(Sp);Dd&&X1(()=>{const Fd=new Map;return Dd.forEach((sh,vh)=>{(!af.current||af.current.some(bh=>bh.id===vh))&&Fd.set(vh,new Set(sh))}),Fd})},[Sp]);const lv=reactExports.useRef("");reactExports.useEffect(()=>{const Dd=Sp?.servers;if(!Dd||Dd.length===0)return;const Fd=Dd.filter(bh=>bh.status==="started").map(bh=>bh.id).sort();if(Fd.length===0)return;const sh=jp.data?.mcpServers||[],vh=Fd.some(bh=>{const zh=sh.find(Wh=>Wh.id===bh);return!zh||zh.tools.length===0}),nh=Fd.join(",");vh&&nh!==lv.current&&jp.refetch&&(lv.current=nh,jp.refetch())},[Sp,jp]);const O1=reactExports.useCallback((Dd,Fd)=>{vg(sh=>{const vh=new Map(sh),nh=new Set(sh.get(Dd)||[]);return nh.has(Fd)?nh.delete(Fd):nh.add(Fd),vh.set(Dd,nh),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Dd,enabledToolNames:Array.from(nh)},Fh)||console.warn("[ChatBase] mcp_server_tools_set dropped: websocket not ready"),vh})},[Fh]),M1=reactExports.useCallback((Dd,Fd,sh)=>{vg(vh=>{const nh=new Map(vh),bh=sh?new Set(Fd):new Set;return nh.set(Dd,bh),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Dd,enabledToolNames:Array.from(bh)},Fh)||console.warn("[ChatBase] mcp_server_tools_set dropped: websocket not ready"),nh})},[Fh]),Nv=reactExports.useCallback(Dd=>{fm.has(Dd)?w1(Dd):q0(Dd)},[fm,q0,w1]),Z0=reactExports.useCallback((Dd,Fd)=>{for(const sh of Dd)Fd?q0(sh):w1(sh)},[q0,w1]),Y0=reactExports.useCallback((Dd,Fd)=>{X1(sh=>{const vh=new Map(sh),nh=new Set(sh.get(Dd)??[]),bh=nh.has(Fd);return bh?nh.delete(Fd):nh.add(Fd),vh.set(Dd,nh),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tool_approve",serverId:Dd,toolName:Fd,approved:!bh},Fh)||console.warn("[ChatBase] mcp_server_tool_approve dropped: websocket not ready"),vh})},[Fh]),hy=reactExports.useCallback(Dd=>{Yg.has(Dd)?(f0(Fd=>{const sh=new Map(Fd);return sh.set(Dd,!1),sh}),Q1(Dd)):(f0(Fd=>{const sh=new Map(Fd);return sh.set(Dd,!0),sh}),Dv(Dd))},[Yg,Dv,Q1]),cv=reactExports.useCallback(()=>{const Dd=[];return Rg.forEach((Fd,sh)=>{(!pd||pd.some(vh=>vh.id===sh))&&Fd.forEach(vh=>Dd.push(vh))}),Dd},[Rg,pd]),yb=reactExports.useCallback(()=>Array.from(fm),[fm]);reactExports.useEffect(()=>{if(jd&&!Cp){const Dd=useChatStore.getState().messages;Dd.length>0&&Qf(Dd)}},[jd,Cp,Qf]);const Lv=reactExports.useRef(void 0),e0=reactExports.useRef(0),D1=reactExports.useRef(!1),N1=reactExports.useRef(null);reactExports.useEffect(()=>{if(cp!==Lv.current&&(cp&&$g.current.set(cp,0),Lv.current=cp,ig(),!cp)||!cp)return;const Dd=V0.current;if(Dd){N1.current!==Dd.id&&(N1.current=Dd.id,useConversationStore.getState().setMessages(cp,Dd.messages),Qf(Dd.messages),useConversationStore.getState().markFetched(cp),xm(!0));return}hp!==e0.current&&(e0.current=hp,hp>0&&(useConversationStore.getState().clearMessages(cp),ig(),$g.current.set(cp,0),D1.current=!0));const Fd=useConversationStore.getState(),sh=Fd.isFetching(cp),vh=Fd.getMessages(cp);if(vh.length>0&&(Xf.current.items.length===0&&Qf(vh),xm(!0)),sh)return;if(Zg!=="connected"){vh.length===0&&xm(!1);return}Fd.setFetching(cp,!0);const nh=()=>extractChatMessagesFromFullContext(agentRuntimeStore.getState().fullContext),bh=Bp=>{Fd.setMessages(cp,Bp),Qf(Bp),$g.current.set(cp,0),Fd.markFetched(cp),xm(!0)},zh=D1.current?[]:nh();if(D1.current=!1,zh.length>0){bh(zh);return}const Wh=()=>{const Bp=[Fh,Np?.agentId,Cp,cp,"default",void 0],xf=new Set;for(const Lf of Bp){const a0=typeof Lf=="string"?Lf.trim():void 0,vv=a0||"__global__";if(xf.has(vv))continue;if(xf.add(vv),agentRuntimeStore.getState().requestRefresh(a0))return!0}return!1};if(!Wh()){Fd.setFetching(cp,!1),vh.length===0&&xm(!1);return}let Gh=!1;const pp=window.setTimeout(()=>{Gh||Wh()},500),Hh=agentRuntimeStore.subscribe(Bp=>Bp.fullContext,Bp=>{if(Gh||!Bp)return;const xf=extractChatMessagesFromFullContext(Bp);Gh=!0,Hh(),bh(xf)}),Rp=window.setTimeout(()=>{if(Gh)return;Gh=!0,Hh(),Fd.setFetching(cp,!1),xm(vh.length>0);const Bp=$g.current.get(cp)??0;Zg==="connected"&&Bp<3?($g.current.set(cp,Bp+1),Wh(),Z1(Lf=>Lf+1)):xm(!0)},2e3);return()=>{window.clearTimeout(pp),window.clearTimeout(Rp),Hh()}},[cp,Zp,Xh?.agentId,Zg,Fh,K1,hp,ig,Qf]),reactExports.useEffect(()=>{if(cp&&Wp.length>0){const Dd=Wp.filter(Fd=>!isToolCallMessage(Fd));Dd.length>0&&useConversationStore.getState().setMessages(cp,Dd)}},[cp,Wp]),reactExports.useEffect(()=>{!jd||!Gg.current||useChatStore.getState().setMessages(Wp.filter(Dd=>!isToolCallMessage(Dd)))},[jd,Wp]);const L1=Wp.filter(Dd=>!isToolCallMessage(Dd)),x0=reactExports.useRef(0);reactExports.useEffect(()=>{const Dd=L1.length;Dd!==x0.current&&(x0.current=Dd,Ph?.(L1))},[Wp,L1,Ph]),reactExports.useEffect(()=>{rp?.(Wp.filter(Dd=>!isToolCallMessage(Dd)))},[Wp,rp]),reactExports.useEffect(()=>{ip?.(Wp)},[Wp,ip]);const J0=Eh?2:3,uv=reactExports.useMemo(()=>{if(Xh?.configEndpoint)return{apiBaseUrl:getApiBaseFromConfig(Xh.configEndpoint),authToken:Xh.authToken}},[Xh?.configEndpoint,Xh?.authToken]),dv={userAvatar:jsxRuntimeExports.jsx(PersonIcon,{size:16}),assistantAvatar:jsxRuntimeExports.jsx(ForwardRef$2,{size:16,color:Lh}),showAvatars:!0,avatarSize:32,userAvatarBg:"neutral.muted",assistantAvatarBg:"accent.emphasis",...mh};reactExports.useEffect(()=>{if(!Xh||!td||Dh)return;const Dd=createProtocolAdapter(Xh);if(Dd)return Vf.current=Dd,U0(!0),nv.current=Dd.subscribe(Fd=>{if(Im.current(),lg.current&&Fd.type!=="state-update"&&Fd.type!=="error"&&Fd.type!=="done")return;const sh=()=>{try{const nh=conversationEventsOf(Fd,Xf.current);Rf(bh=>nh.reduce((zh,Wh)=>reduceConversation(zh,Wh),bh))}catch(nh){console.error("[ChatBase] Protocol event not read:",nh),Df(nh instanceof Error?nh:new Error(String(nh)))}},vh=()=>{const nh=Xf.current.items;if(nh.some(Wh=>Wh.kind==="message"&&Wh.role==="assistant"&&Wh.text.trim().length>0))return;const zh=[...nh].reverse().find(Wh=>Wh.kind==="tool"&&Wh.status==="complete"&&Wh.value!==void 0);!zh||zh.kind!=="tool"||bm({type:"MESSAGE_SAID",messageId:generateMessageId(),role:"assistant",text:formatToolResultFallback(zh.value),streaming:!1})};switch(Fd.type){case"message":if(Fd.usage){const nh=Fd.timestamp instanceof Date?Fd.timestamp.getTime():Date.now(),bh=Math.max(0,Fd.usage.promptTokens??0),zh=Math.max(0,Fd.usage.completionTokens??0),Wh=Math.max(bh+zh,Fd.usage.totalTokens??0),gp=agentRuntimeStore.getState();gp.appendLocalTokenTurn({serviceName:b1,agentId:Xh?.agentId,timestampMs:nh,promptTokens:bh,completionTokens:zh,totalTokens:Wh});const Gh=gp.costUsage?.cumulativeCostUsd;typeof Gh=="number"&&Number.isFinite(Gh)&&gp.upsertLocalCostPoint({serviceName:b1,agentId:Xh?.agentId,timestampMs:nh,cumulativeUsd:Math.max(0,Gh)})}if(qm.current)break;if(Fd.message){const nh=Fd.message.content;typeof nh=="string"&&nh&&(W0.current=sanitizeAssistantContent(nh)),sh()}break;case"tool-call":if(Fd.toolCall&&!lg.current){const nh=Fd.toolCall.toolCallId,bh=Fd.toolCall.toolName,zh=Fd.toolCall.args||{},Wh=Fd.toolCall.argsComplete,gp=hg(nh);sh();const Gh=hg(nh);if(!Gh)break;const pp=I1.current?.find(Rp=>Rp.name===bh),Hh=pp?.handler;gp?Hh&&gp.status==="executing"&&(Wh??Object.keys(zh).length>0)&&(Lm.current++,Bv(Hh,Gh,nh)):(G0.current?.({toolName:bh,toolCallId:nh,args:zh}),Km.current?.recorder.toolStarted({id:nh,name:bh,args:zh}),Hh&&(Wh??(Object.keys(zh).length>0||!frontendToolExpectsArgs(pp)))&&(Lm.current++,Bv(Hh,Gh,nh)))}break;case"tool-result":if(Fd.toolResult){const nh=Fd.toolResult.toolCallId??"",bh=hg(nh);sh();const zh=hg(nh);bh&&zh&&(Km.current?.recorder.toolEnded(nh,{result:Fd.toolResult.result,error:Fd.toolResult.error??(zh.status==="error"?zh.executionError??"failed":void 0)}),sv.current?.({toolName:bh.toolName,toolCallId:nh,args:bh.args,result:Fd.toolResult.result,status:zh.status,error:Fd.toolResult.error}))}break;case"state-update":Sh?.(Fd.data),sh();break;case"activity":if(Fd.activity&&y0.current?.(Fd.activity),sh(),Fd.activity?.type===HARNESS_TOOL_CALL&&Lg.current){const nh=Fd.activity.data,bh=nh&&typeof nh=="object"&&"id"in nh?String(nh.id??""):"",zh=Xf.current.items.find(Wh=>Wh.kind==="tool"&&Wh.id===bh);zh&&zh.kind==="tool"&&zh.display&&Lg.current({toolName:zh.name,toolCallId:bh,args:zh.input??{},display:zh.display})}break;case"done":{Km.current?.recorder.turnEnded({text:W0.current||void 0,usage:Fd.usage}),W0.current="";const nh=Fd.usage?.promptTokens??0,bh=Fd.usage?.completionTokens??0,zh=Fd.usage?.totalTokens??nh+bh;zh>0&&Wg(Wh=>({turnInput:nh,turnOutput:bh,sessionInput:(Wh?.sessionInput??0)+nh,sessionOutput:(Wh?.sessionOutput??0)+bh,totalTokens:zh}))}qm.current&&Xg.current&&vh(),lg.current||sh(),qm.current=!1,Lm.current=0,bf(!1),ym(!1),agentRuntimeStore.getState().requestRefresh(Fh);break;case"error":console.error("[ChatBase] Protocol error:",Fd.error),Km.current?.recorder.turnEnded({error:Fd.error?.message??"error"}),Fd.error?.message&&/exceeded maximum retries/i.test(Fd.error.message)&&Xg.current&&vh(),sh(),qm.current=!1,Df(Fd.error||new Error("Unknown error")),Lm.current=0,bf(!1),ym(!1),agentRuntimeStore.getState().requestRefresh(Fh);break;default:sh();break}}),Dd.connect().catch(console.error),()=>{nv.current?.(),Vf.current?.disconnect()}},[Pv,Sh,jd,td]);function Bv(Dd,Fd,sh){(async()=>{if(lg.current){Lm.current--,Lm.current<0&&(Lm.current=0);return}try{const vh=await Dd(Fd.args);Vf.current&&await Vf.current.sendToolResult(sh,{toolCallId:sh,success:!0,result:vh}),Km.current?.recorder.toolEnded(sh,{result:vh}),bm({type:"TOOL_CALL_DONE",toolCallId:sh,success:!0,result:vh})}catch(vh){console.error("[ChatBase] Frontend tool execution error:",vh),Km.current?.recorder.toolEnded(sh,{error:vh.message}),bm({type:"TOOL_CALL_DONE",toolCallId:sh,success:!1,error:vh.message})}finally{Lm.current--,Lm.current<0&&(Lm.current=0)}})()}reactExports.useEffect(()=>{const Dd=$1.current;if(Dd){Dd.scrollTo({top:Dd.scrollHeight,behavior:"smooth"});return}Dg.current?.scrollIntoView({behavior:"smooth"})},[Wp]);const hv=reactExports.useRef(void 0),[t0]=useVoiceSettings(),Zm=reactExports.useMemo(()=>Vd?settledVoice(Vd,t0):void 0,[Vd,t0]),[xb,Sb]=reactExports.useState(!1),_g=!!(_h||Qd),cm=useVoiceSpeaker(Zm,!_g);useSpokenAnswers(Wp,yp,!_g&&Zm?.output==="always",cm.speaker);const X0=Ld||cm.state.speaking,Q0=_g?Kd:cm.state.sentence,B1=reactExports.useRef(null);useSaidSentence(B1,Q0,Wp);const[jv,r0]=reactExports.useState("");y0.current=Dd=>{if(isVoiceInterrupted(Dd)){Qd?Qd():cm.speaker&&cm.stop();return}const Fd=lineToSay(Dd);Fd&&(r0(Fd),Zm?.output==="always"&&(_h?_h(Fd):cm.speaker?.say(Fd)))},reactExports.useEffect(()=>{yp||r0("")},[yp]);const[Fv,n0]=reactExports.useState(()=>new Set),pv=reactExports.useRef([]),j1=reactExports.useCallback(()=>{const Dd=answerSpokenOver(pv.current.filter(Fd=>!isToolCallMessage(Fd)));Dd&&n0(Fd=>new Set([...Fd,Dd]))},[]),xg=Qd??(cm.speaker?cm.stop:void 0),Sg=_g?fh:cm.level,o0=_h??(cm.speaker?cm.read:void 0),Ym=reactExports.useCallback(async(Dd,Fd,sh)=>{const vh=(Dd??Kg).trim();if(!vh||yp||!Vf.current&&!$d)return;if(Fd&&namesFiles(Fd))try{Fd=await withUploadedFiles(Fd,k1)}catch(Hh){Df(Hh instanceof Error?Hh:new Error(String(Hh)));return}const nh=displayPressOf(Fd);if(nh&&Fd){const Hh=Vm.current?.socket;if(!Hh){Df(new Error("This conversation’s ui channel is not open."));return}try{const Rp=await Hh.act(nh);if(!Rp.ok){Df(new Error(Rp.detail||`The press was refused (${Rp.status}).`));return}Fd=withPress(Fd,Rp.value)}catch(Rp){Df(Rp instanceof Error?Rp:new Error(String(Rp)));return}}lg.current=!1,W0.current="",Km.current?.recorder.turnStarted(vh,sg||void 0),qm.current=isToolCallOnlyPrompt(vh);const bh=sh??spokenOf(Fd?.voice)??(Dd===void 0?hv.current:void 0);hv.current=void 0;const zh=bh?{...Fd??{},voice:bh}:Fd;let Wh;if(bh){const{sound:Hh,...Rp}=bh;Wh=Rp}const gp=createUserMessage(vh,Wh?{...Wh}:void 0),pp=[...Wp.filter(Hh=>!isToolCallMessage(Hh)),gp];{const{id:Hh,role:Rp,content:Bp,...xf}=gp;im(Lf=>({...Lf,extras:new Map(Lf.extras).set(Hh,xf)}))}Rf(Hh=>reduceConversation(withPrompt(Hh,gp.id,vh),{type:"RUN_STARTED"})),gg(""),bf(!0),ym(!0),Df(null);try{if($d)if(rh){const Hh=generateMessageId(),Rp=(Bp,xf)=>bm({type:"MESSAGE_SAID",messageId:Hh,role:"assistant",text:Bp,streaming:xf});Rp("",!0),jd&&useChatStore.getState().startStreaming(Hh),R1.current=new AbortController,await $d(vh,pp,{onChunk:Bp=>{bm({type:"TEXT_MESSAGE_CONTENT",messageId:Hh,delta:Bp})},onComplete:Bp=>{Rp(Bp,!1),jd&&useChatStore.getState().stopStreaming()},onError:Bp=>{Rp(om.error(Bp.message),!1),jd&&useChatStore.getState().stopStreaming(),Df(Bp)},signal:R1.current.signal})}else{const Hh=await $d(vh,pp);Hh&&bm({type:"MESSAGE_SAID",messageId:generateMessageId(),role:"assistant",text:Hh,streaming:!1})}else if(Vf.current){const Hh=(Mm||[]).map(xf=>({name:xf.name,description:xf.description,parameters:xf.parameters||{type:"object",properties:{}}}));console.warn("[ChatBase] frontendTools count:",Mm?.length??0,"toolsForRequest:",Hh.map(xf=>xf.name));const Rp=cv(),Bp=yb();Fm(),await Vf.current.sendMessage(gp,{threadId:bg.current,messages:pp,...sg&&{model:sg},tools:Hh,builtinTools:Rp,skills:Bp,identities:Qg.current,...zh?{forwardedProps:zh}:{}})}}catch(Hh){Hh.name!=="AbortError"&&(console.error("[ChatBase] Send error:",Hh),Rf(Rp=>withError(Rp,Hh.message)),Df(Hh))}finally{Vf.current||(Xf.current.running&&bm({type:"RUN_FINISHED"}),bf(!1),ym(!1),agentRuntimeStore.getState().requestRefresh(Fh)),qm.current=!1,R1.current=null}},[Kg,yp,Wp,sg,Mm,jd,$d,Fh,rh,cv,yb,Fm,om,k1,Rf,im,bm]);reactExports.useEffect(()=>{if(!fp||Nm&&x1.current===Nm)return;if(Nm&&sentPendingPromptKeys.has(Nm)){x1.current=Nm;return}!sm&&!(!cp||Zg!=="connected")||!J1&&!$d||(x1.current=Nm??null,Nm&&sentPendingPromptKeys.add(Nm),queueMicrotask(()=>Ym(fp)))},[fp,Nm,sm,cp,Zg,J1,Ym,$d,jg]);const e1=reactExports.useCallback(Dd=>{lg.current=!0,R1.current?.abort();const Fd=Vf.current;Fd&&(typeof Fd.stopGeneration=="function"&&Fd.stopGeneration(),Dd&&typeof Fd.interruptSession=="function"?Fd.interruptSession().catch(()=>{}):typeof Fd.terminateSession=="function"?Fd.terminateSession().catch(()=>{}):typeof Fd.terminateAgent=="function"?Fd.terminateAgent().catch(()=>{}):typeof Fd.terminateTask=="function"?Fd.terminateTask().catch(()=>{}):typeof Fd.terminateRequest=="function"&&Fd.terminateRequest().catch(()=>{})),Rf(sh=>withTurnEnded(sh,"stopped")),jd&&useChatStore.getState().stopStreaming(),Lm.current=0,bf(!1),ym(!1),agentRuntimeStore.getState().requestRefresh(Fh),agentRuntimeStore.getState().stopSubagentActivity(),qm.current=!1,C1.interrupt(),md&&md.interrupt().catch(()=>{})},[md,jd,Fh,Xh?.configEndpoint,Xh?.authToken,Xh?.agentId]),S0=reactExports.useCallback(()=>e1(!1),[e1]),w0=reactExports.useCallback(()=>e1(!0),[e1]),wb=reactExports.useCallback(Dd=>async Fd=>{const sh=Dd.actions?.find(bh=>bh.name===Fd.action);if(!sh)throw new Error(`“${Fd.action}” was not offered here.`);const vh=Fd.payload?.value,nh=Fd.action===ANSWER_ACTION?typeof vh=="string"?vh:isFileRef(vh)?vh.name:"Answered.":Fd.action;await Ym(nh,{loop:{action:{name:Fd.action,display_id:Dd.id,token:sh.token,payload:Fd.payload??{}}}})},[Ym]),fv=reactExports.useCallback(()=>{ig(),Lm.current=0,gg(""),bg.current=generateMessageId(),jd&&j0(),cp&&useConversationStore.getState().clearMessages(cp),Mh?.(),oh?.onNewChat?.()},[j0,Mh,oh,jd,Cp,ig]);reactExports.useEffect(()=>{if(Id){if(!J1&&!$d){Id(null);return}return Id({send:(Dd,Fd)=>{Ym(Dd,Fd)},stop:S0,newChat:fv,thread:()=>bg.current,stopSpeaking:xg,voiceLevel:Sg,markInterrupted:j1,interrupt:w0}),()=>{Id(null)}}},[Id,J1,$d,Ym,S0,w0,fv,xg,Sg,j1]),reactExports.useEffect(()=>{qd?.(yp)},[qd,yp]),reactExports.useEffect(()=>{Md?.(X0)},[Md,X0]);const t1=reactExports.useCallback(()=>{window.confirm("Clear all messages?")&&(ig(),jd&&j0(),cp&&useConversationStore.getState().clearMessages(cp),Kh?.(),oh?.onClear?.())},[j0,Kh,oh,jd,Cp,ig]),mv=reactExports.useCallback(Dd=>{const Fd=new Set(Dd),sh=kg.current.filter(vh=>Fd.has(vh.id)).map(rowIdOf);Rf(vh=>withoutItems(vh,sh)),im(vh=>vh.steps.some(nh=>Fd.has(nh.item.id))?{...vh,steps:vh.steps.filter(nh=>!Fd.has(nh.item.id))}:vh)},[Rf,im]),zv=reactExports.useCallback(async(Dd,Fd)=>{const sh=hg(Dd);if(sh&&(sh.status==="executing"||sh.status==="inProgress")){if(!!Fd&&typeof Fd=="object"&&Fd.type==="tool-approval-decision"&&typeof Fd.approved=="boolean"&&Vf.current){const nh=Fd,bh=!!nh.approved,zh=nh._fromServerEcho===!0,Wh=nh._alreadyDispatched===!0,gp=sh.status==="inProgress",Gh=typeof nh.toolName=="string"?nh.toolName:sh.toolName,pp=Gh.includes("__");if(bh){const Hh=Gh.indexOf("__");if(Hh!==-1){const Rp=Gh.slice(0,Hh),Bp=Gh.slice(Hh+2);X1(xf=>{const Lf=new Map(xf),a0=new Set(xf.get(Rp)??[]);return a0.add(Bp),Lf.set(Rp,a0),Lf})}}try{const Hh=typeof Fd=="object"&&Fd!==null&&typeof Fd.approvalId=="string"?Fd.approvalId:void 0;if(!zh&&!gp){Hh&&(bh?await h0?.(Hh,void 0,Dd):await Vg?.(Hh,void 0,Dd));return}if(Hh&&!Wh&&(bh?await h0?.(Hh,void 0,Dd):await Vg?.(Hh,void 0,Dd)),pp&&!gp)return;Rf(Rp=>reduceConversation(reduceConversation(Rp,{type:"TOOL_CALL_DONE",toolCallId:Dd,success:bh,result:Fd,answered:!0,...bh?{}:{error:"Tool approval rejected by user"}}),{type:"RUN_STARTED"})),bf(!0),ym(!0),await Vf.current.sendToolResult(Dd,{toolCallId:Dd,success:bh,result:bh?{approved:!0,message:"Tool call approved by user.",...Hh?{approvalId:Hh}:{}}:{approved:!1,message:"Tool call rejected by user.",...Hh?{approvalId:Hh}:{}},...bh?{}:{error:"Tool approval rejected by user"}})}catch(Hh){console.error("[ChatBase] Approval continuation error:",Hh),Df(Hh)}return}if(bm({type:"TOOL_CALL_DONE",toolCallId:Dd,success:!0,result:Fd,answered:!0}),Vf.current){let nh;if(typeof Fd=="string")nh=Fd;else if(Fd&&typeof Fd=="object"&&"accepted"in Fd){const zh=Fd;if(zh.accepted){const Wh=zh.steps?.map(gp=>gp.description).join(", ")||"";nh=Wh?`I confirm and approve the following steps: ${Wh}`:"I confirm and approve the plan."}else nh="I reject this plan. Please suggest something else."}else nh=JSON.stringify(Fd,null,2);const bh={id:generateMessageId(),role:"user",content:nh,createdAt:new Date};bf(!0),ym(!0),bm({type:"RUN_STARTED"});try{const zh=Wp.filter(Wh=>!isToolCallMessage(Wh));await Vf.current.sendMessage(bh,{threadId:bg.current,messages:[...zh,bh]})}catch(zh){console.error("[ChatBase] HITL respond error:",zh)}}}},[Wp,h0,Vg,hg,Rf,bm]);K0.current=zv;const Uv=reactExports.useCallback(Dd=>{Ym(Dd.message)},[Ym]),Hv=reactExports.useCallback(Dd=>{gg(Dd),setTimeout(()=>Ng.current?.focus(),0)},[]),zm=reactExports.useCallback(async(Dd,Fd)=>{await h0?.(Dd,Fd)},[h0]),Jm=reactExports.useCallback(async(Dd,Fd)=>{await Vg?.(Dd,Fd)},[Vg]),wg=(jp.data?.mcpServers||[]).filter(Dd=>!pd||_0(Dd)),gv=reactExports.useMemo(()=>{const Dd=wg.map(sh=>{const vh=Sp?.servers?.find(nh=>nh.id===sh.id);if(vh&&vh.status==="started"){const nh={};if(sh.isAvailable||(nh.isAvailable=!0),vh.tools&&vh.tools.length>0&&(nh.tools=vh.tools.map(bh=>({name:bh.name,description:bh.description||"",enabled:bh.enabled??!0}))),Object.keys(nh).length>0)return{...sh,...nh}}return sh}),Fd=new Set(wg.map(sh=>sh.id));for(const sh of Sp?.servers??[])sh.status==="started"&&!Fd.has(sh.id)&&sh.tools&&sh.tools.length>0&&(!pd||pd.some(nh=>nh.id===sh.id))&&Dd.push({id:sh.id,name:sh.id,description:"",url:"",enabled:!0,tools:sh.tools.map(nh=>({name:nh.name,description:nh.description||"",enabled:nh.enabled??!0})),args:[],requiredEnvVars:[],isAvailable:!0,transport:"stdio",isConfig:!1,isRunning:!0});return Dd},[wg,Sp,pd]),Eb=Xh?.configEndpoint?Xh.configEndpoint.replace(/\/api\/v1\/(config|configure)\/?$/,""):void 0,i0=!Xh||!Xh.enableConfigQuery||!!jp.data||!!Ig.data,Um=$h||jp.data?.welcomeMessage||"",_f=jp.data?.suggestions,F1=bp&&bp.length>0?bp:Array.isArray(_f)&&_f.length>0?_f.map(Dd=>{if(typeof Dd=="string"){const vh=Dd.trim();return{title:vh,message:vh}}const Fd=(Dd?.text??"").trim();return{title:(Dd?.summary??"").trim()||Fd,message:Fd}}).filter(Dd=>Dd.message):void 0,Xm=Pd?[{id:"__welcome__",role:"assistant",content:Pd,createdAt:WELCOME_AT},...Wp]:Wp;pv.current=Xm;const wp=saidMessageId(Xm,Q0),Xp=yp||mg?[...Xm].reverse().find(Dd=>!isToolCallMessage(Dd)&&Dd.role==="assistant")?.id:void 0,Nf=o0||Fv.size||Oh?(Dd,Fd)=>{const sh=getMessageText(Dd),vh=Oh?.(Dd,Fd)??null,nh=Fv.has(Dd.id),bh=!!(o0&&readsAloud(Dd,sh,Xp));return!vh&&!nh&&!bh?null:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[nh?jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,color:"fg.muted",fontStyle:"italic"},"data-interrupted":"",children:"interrupted"}):null,bh&&o0?jsxRuntimeExports.jsx(ReadAloud,{onRead:()=>o0(sh)}):null,vh]})}:void 0,z1=xd||jsxRuntimeExports.jsxs(Box,{ref:B1,display:"flex",flexDirection:"column",minHeight:0,width:"100%",maxWidth:920,mx:"auto",bg:"canvas.default",children:[jsxRuntimeExports.jsx(ChatMessageList,{displayItems:Xm,actOn:Xh?.uiSocket?wb:void 0,upload:Xh?.uiFiles?k1:void 0,isLoading:yp,isStreaming:mg,showLoadingIndicator:Pu,hideMessagesAfterToolUI:_p,avatarConfig:dv,padding:J0,notebookToolSurfacesId:Gd,approvalConfig:uv,messagesEndRef:Dg,onRespond:zv,showTurnFooters:ah,renderMessageFooter:Nf,saidMessageId:wp,agentUsage:E1,onRemoveItems:mv,mcpServers:gv,emptyContent:Xu?null:jsxRuntimeExports.jsx(ChatEmptyState,{emptyState:Xd,brandIcon:Yd,description:Um,suggestions:F1,submitOnSuggestionClick:Qh,onSuggestionSubmit:Uv,onSuggestionFill:Hv})}),Od]}),E0=Zm&&Zm.input!=="off"?jsxRuntimeExports.jsx(ComposerVoice,{voice:Zm,input:Kg,setInput:gg,disabled:Dh||Xu,speaking:X0,onStopSpeaking:xg,playbackLevel:Sg,running:yp,onStopRun:w0,onInterrupted:j1,onInterimChange:Sb,answers:!!(Vd?.output&&Vd.output!=="off"&&Vd.speechUrl),onSpoken:Dd=>{hv.current=Dd},send:(Dd,Fd)=>{Ym(Dd,void 0,Fd)}}):void 0,s0=!_g&&cm.state.refused?jsxRuntimeExports.jsx(Text$3,{role:"alert",sx:{fontSize:0,color:"danger.fg",maxWidth:260},"data-voice-refused":"",children:cm.state.refused}):null,U1=jv?jsxRuntimeExports.jsxs(Text$3,{"aria-live":"polite",sx:{fontSize:0,fontStyle:"italic",color:"fg.muted",maxWidth:260,display:"inline-flex",alignItems:"center",gap:1},"data-voice-say":"",children:[jsxRuntimeExports.jsx(UnmuteIcon,{size:12,"aria-label":"Said aloud"}),jv]}):null,r1=Mu?jsxRuntimeExports.jsx(InputPrompt,{footerExtras:s0||U1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[U1,s0,E0]}):E0,interim:xb,input:Kg,setInput:gg,isLoading:yp,kernelStatus:$m,connectionConfirmed:i0,placeholder:Ah,typingSuggestions:F1?.map(Dd=>Dd.message||Dd.title),autoFocus:up,focusTrigger:np,padding:J0,onSend:()=>Ym(),onStop:S0,disableInputPrompt:ju||Dh||!!Yu||Xu,promptVariant:Fu,mentionableAgents:g0,promptCommands:Uu,promptHistory:jp.data?.promptHistory?.map(askedOf),showTokenUsage:Ru,showContextRing:Iu,agentUsage:E1,showModelSelector:Du,showToolsMenu:Lu,showSkillsMenu:Bu,codemodeEnabled:nd,onToggleCodemode:od,isA2AProtocol:pm,showAgentsMenu:Hu,agents:Jg,selectedAgentId:Gu??Jg[0]?.id,onSelectAgent:Wu,hasConfigData:!!jp.data,hasSkillsData:!!Ig.data,configLoading:jp.isLoading,models:Pg,decisions:jp.data?{models:jp.data.decisionModels,note:jp.data.decisionsNote}:void 0,selectedModel:sg,onModelSelect:Ov,availableTools:ev.runtime,availableFrontendTools:ev.frontend,mcpServers:gv,enabledMcpTools:Rg,enabledMcpToolCount:cv().length,onToggleMcpTool:O1,onToggleAllMcpServerTools:M1,approvedMcpTools:Mv,onToggleMcpToolApproval:Y0,skills:Ig.data?.skills||[],skillsLoading:!1,enabledSkills:fm,onToggleSkill:Nv,onToggleAllSkills:Z0,approvedSkills:Yg,onToggleSkillApproval:hy,apiBase:Eb,authToken:Xh?.authToken,mcpStatusData:Sp}):null,C0={title:Au,subtitle:lo,disableReason:Dh?Ud:void 0,brandIcon:Yd,headerContent:Nd,headerActions:yd,showInformation:Ch,onInformationClick:Zh??(()=>Bh(!0)),padding:J0,kernelIndicatorState:wd,kernelIndicatorPlacement:Ad,runtimeStatus:Cm??C1.data,kernel:gf?Zf??md:Vh?Yf??md:md,kernelEnvironmentName:dd,kernelCpu:bd,kernelMemory:ld,kernelGpu:ud,headerButtons:oh,messageCount:L1.length,onNewChat:fv,onClear:t1,chatViewMode:Ed,onChatViewModeChange:Cd,disabledViewModes:Rd,showEphemeralSurfaceControl:qh||wf,enableEphemeralNotebookOption:qh,enableEphemeralDocumentOption:wf,ephemeralSurfaceMode:Uf,onEphemeralSurfaceModeChange:Hf},Cb=$u?eh?eh(C0):jsxRuntimeExports.jsx(ChatBaseHeader,{...C0}):null;return jsxRuntimeExports.jsxs(Box,{className:Sd,position:"relative",display:"flex",flexDirection:"column",height:"100%",maxHeight:"100%",minHeight:0,flex:"1 1 auto",width:"100%",minWidth:0,bg:Zd||"canvas.default",borderRadius:Hd,border:hh,boxShadow:wh,overflow:"hidden",children:[!$p&&Cb,y1&&jsxRuntimeExports.jsx(Box,{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",children:jsxRuntimeExports.jsx(ReactorLazy,{load:loadAgentDetails,errorFallback:agentDetailsRefused,props:{name:Au||"AI Agent",icon:Yd,protocol:Xh?.type??"unknown",url:Xh?.endpoint||"",messageCount:Wp.length,agentId:Fh,apiBase:Xh?.configEndpoint,onBack:()=>Bh(!1)}})}),Pf&&L0&&L0.length>0&&jsxRuntimeExports.jsx(ToolApprovalBannerSection,{pendingApprovals:L0,onApprove:zm,onReject:Jm}),Ou&&_m&&jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,p:J0,bg:"danger.subtle",borderBottom:"1px solid",borderColor:"danger.muted",children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"danger.fg",fontSize:1},children:_m.message})]}),$p?jsxRuntimeExports.jsxs(Box,{flex:1,minHeight:0,display:"flex",overflow:"hidden",position:"relative",children:[jsxRuntimeExports.jsx(Box,{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",sx:Yh||Hp?null:{borderRight:"1px solid",borderColor:"border.default"},children:Xu||Yu?jsxRuntimeExports.jsx(CompanionSurfaceSkeleton,{mode:gf?"notebook":"document"}):gf?jsxRuntimeExports.jsx(ReactorLazy,{load:loadEphemeralNotebook,errorFallback:ephemeralNotebookRefused,fallback:jsxRuntimeExports.jsx(CompanionSurfaceSkeleton,{mode:"notebook"}),props:{notebookId:Yp,runtimeName:Cp||Fh,runtimeOverride:nm,themeVariant:hd,colorMode:vd,nbformat:Pm??void 0,onNbformatChange:og,toolbarComponent:Fp,toolbarExtraItems:Mf,collaborationProvider:tp}}):jsxRuntimeExports.jsx(vM.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(EphemeralDocument,{documentId:Wf,runtimeName:Cp||Fh,runtimeOverride:nm,themeVariant:hd,colorMode:vd,content:Ff??void 0,onContentChange:zf,onToolsReady:u0,onKernelChange:df,collaboration:Tf,toolbarExtraItems:vm})})}),!Hp&&jsxRuntimeExports.jsxs(Box,{sx:Yh?{position:"absolute",right:16,width:Lp?360:440,maxWidth:"calc(100% - 32px)",...Lp?{bottom:16,height:"62%"}:{top:16,bottom:16},display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",bg:"canvas.default",border:"1px solid",borderColor:"border.default",borderRadius:2,boxShadow:"shadow.large",zIndex:5}:{flexShrink:0,width:440,minWidth:320,maxWidth:"48%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",bg:"canvas.default"},children:[Cb,jsxRuntimeExports.jsx(Box,{ref:$1,flex:1,minHeight:0,overflow:"auto",bg:"canvas.default",children:z1}),zd,r1]}),Hp&&Qp&&(Ed==="sidebar"?jsxRuntimeExports.jsx(Box,{position:"absolute",top:8,right:8,zIndex:6,children:jsxRuntimeExports.jsx(IconButton,{icon:SidebarExpandIcon,"aria-label":"Open chat",onClick:Qp,variant:"default",size:"small"})}):jsxRuntimeExports.jsx(FloatingBrandButton,{isOpen:!1,onToggle:Qp,position:"bottom-right",tooltip:"Open chat"}))]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Box,{ref:$1,"data-chat-history":"",flex:1,flexGrow:1,minHeight:0,overflow:"auto",bg:"canvas.default",children:z1}),zd,r1]}),yh&&jsxRuntimeExports.jsx(PoweredByTag,{...gh}),Yu&&jsxRuntimeExports.jsxs(Box,{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",p:3,overflow:"auto",children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,position:"absolute",inset:0,bg:"canvas.default",opacity:.4,backdropFilter:"blur(1px)"}),jsxRuntimeExports.jsx(Box,{position:"relative",zIndex:1,maxWidth:"100%",children:Yu})]}),Xu&&!Yu&&jsxRuntimeExports.jsxs(Box,{position:"absolute",inset:0,zIndex:15,display:"flex",alignItems:"center",justifyContent:"center",p:3,children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,position:"absolute",inset:0,bg:"canvas.default",opacity:.35,backdropFilter:"blur(1px)"}),jsxRuntimeExports.jsxs(Box,{position:"relative",zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:3,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"large"}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:ed||"Launching your agent…"})]})]})]})}function ToolApprovalBannerSection({pendingApprovals:Au,onApprove:lo,onReject:$u}){const[Ru,Iu]=reactExports.useState(null);return reactExports.useEffect(()=>{Ru&&(Au.some(Pu=>Pu.id===Ru.id)||Iu(null))},[Au,Ru]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolApprovalBanner,{pendingApprovals:Au,onReview:Pu=>Iu(Pu),onApproveAll:async()=>{if(lo)for(const Pu of Au)await lo(Pu.id)}}),jsxRuntimeExports.jsx(ToolApprovalDialog,{isOpen:!!Ru,toolName:Ru?.toolName??"",toolDescription:Ru?.toolDescription,args:Ru?.args??{},onApprove:async()=>{if(!Ru||!lo){Iu(null);return}await lo(Ru.id)!==!1&&Iu(null)},onDeny:async()=>{if(!Ru||!$u){Iu(null);return}await $u(Ru.id,"Rejected from tool approval dialog")!==!1&&Iu(null)},onClose:()=>Iu(null)})]})}const halo=Au=>({position:"absolute",inset:0,borderRadius:"50%",bg:Au||"accent.emphasis",zIndex:-1,pointerEvents:"none",willChange:"transform, opacity"});function ButtonGlow({color:Au}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,"data-button-glow":"breath",sx:{...halo(Au),filter:"blur(10px)",animation:"agentRuntimesGlowBreath 3.4s ease-in-out infinite","@keyframes agentRuntimesGlowBreath":{"0%, 100%":{transform:"scale(0.9)",opacity:.35},"50%":{transform:"scale(1.25)",opacity:.7}},"@media (prefers-reduced-motion: reduce)":{animation:"none",transform:"scale(1.1)",opacity:.4}}}),jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,"data-button-glow":"aura",sx:{...halo(Au),filter:"blur(18px)",animation:"agentRuntimesGlowAura 5.3s ease-in-out infinite","@keyframes agentRuntimesGlowAura":{"0%, 100%":{transform:"scale(1)",opacity:.15},"40%":{transform:"scale(1.55)",opacity:.4},"70%":{transform:"scale(1.3)",opacity:.25}},"@media (prefers-reduced-motion: reduce)":{animation:"none",transform:"scale(1.3)",opacity:.2}}})]})}const MARGIN=24;function useViewportDrag(Au,{whole:lo=!1}={}){const[$u,Ru]=reactExports.useState(null),Iu=reactExports.useRef(null),Pu=reactExports.useCallback(Mu=>{const Du=Au.current;if(!Du)return;const Lu=Du.getBoundingClientRect();Iu.current={dx:Mu.clientX-Lu.left,dy:Mu.clientY-Lu.top};const Bu=Mu.currentTarget;Bu.setPointerCapture?.(Mu.pointerId);const ju=zu=>{if(!Iu.current)return;const Uu=Math.min(Math.max(zu.clientX-Iu.current.dx,lo?0:MARGIN-Lu.width),window.innerWidth-(lo?Lu.width:MARGIN)),Hu=Math.min(Math.max(zu.clientY-Iu.current.dy,0),window.innerHeight-(lo?Lu.height:MARGIN));Ru({left:Uu,top:Hu})},Fu=()=>{Iu.current=null,Bu.removeEventListener("pointermove",ju),Bu.removeEventListener("pointerup",Fu),Bu.removeEventListener("pointercancel",Fu)};Bu.addEventListener("pointermove",ju),Bu.addEventListener("pointerup",Fu),Bu.addEventListener("pointercancel",Fu),Mu.preventDefault()},[Au,lo]),Ou=reactExports.useCallback(()=>Ru(null),[]);return{position:$u,onHandlePointerDown:Pu,reset:Ou}}const INK=loopColors.ink,INK_DARK=loopColors.inkDark;function Eyes({cx:Au,cy:lo,gap:$u,r:Ru,colours:Iu}){const Pu=Au-$u/2,Ou=Au+$u/2;return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("circle",{cx:Pu,cy:lo,r:Ru,fill:Iu.white,stroke:Iu.ring,strokeWidth:1.5}),jsxRuntimeExports.jsx("circle",{cx:Ou,cy:lo,r:Ru,fill:Iu.white,stroke:Iu.ring,strokeWidth:1.5}),jsxRuntimeExports.jsxs("g",{className:"assistant-pupils",children:[jsxRuntimeExports.jsx("circle",{cx:Pu+Ru*.15,cy:lo+Ru*.1,r:Ru*.45,fill:Iu.pupil}),jsxRuntimeExports.jsx("circle",{cx:Ou+Ru*.15,cy:lo+Ru*.1,r:Ru*.45,fill:Iu.pupil}),jsxRuntimeExports.jsx("circle",{cx:Pu+Ru*.3,cy:lo-Ru*.1,r:Ru*.14,fill:Iu.white}),jsxRuntimeExports.jsx("circle",{cx:Ou+Ru*.3,cy:lo-Ru*.1,r:Ru*.14,fill:Iu.white})]}),jsxRuntimeExports.jsxs("g",{className:"assistant-lids",children:[jsxRuntimeExports.jsx("ellipse",{cx:Pu,cy:lo,rx:Ru+.5,ry:Ru+.5,fill:Iu.lid}),jsxRuntimeExports.jsx("ellipse",{cx:Ou,cy:lo,rx:Ru+.5,ry:Ru+.5,fill:Iu.lid})]})]})}const PAPER_CLIP={light:{wire:"#7A808A",shine:"#E3E6EB",line:INK,eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#B8BDC6"}},dark:{wire:"#C9CED6",shine:"#8D93A0",line:INK_DARK,eye:{white:INK_DARK,ring:loopColors.grayDark,pupil:INK,lid:"#8D93A0"}}},WIZARD={light:{hat:"#6E5CD6",brim:"#4A3C9E",robe:"#5B4BB7",face:"#F2D3B3",beard:"#F4F4F6",beardEdge:"#7A808A",star:"#F8D469",eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#F2D3B3"}},dark:{hat:"#9C88F0",brim:"#7B67DB",robe:"#8F7CE8",face:"#E8C4A0",beard:"#E4E4EA",beardEdge:loopColors.grayDark,star:"#F8D469",eye:{white:INK_DARK,ring:INK,pupil:INK,lid:"#E8C4A0"}}},CAT={light:{fur:"#F4A261",edge:"#B4571A",tail:"#E08A45",ear:"#F6A5C1",nose:"#B83A6B",whiskers:INK,eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#F4A261"}},dark:{fur:"#F4A261",edge:"#F4A261",tail:"#E08A45",ear:"#F6A5C1",nose:"#B83A6B",whiskers:INK_DARK,eye:{white:INK_DARK,ring:INK,pupil:INK,lid:"#F4A261"}}},LOOP_EYES={light:{eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#E3E6EB"}},dark:{eye:{white:INK_DARK,ring:INK_DARK,pupil:loopColors.black,lid:loopColors.grayDark}}};function PaperClip({size:Au,mode:lo="light"}){const $u=PAPER_CLIP[lo],Ru="M40 86 L40 30 Q40 14 52 14 Q64 14 64 30 L64 74 Q64 82 56 82 Q48 82 48 74 L48 36";return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Paper clip","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:Ru,fill:"none",stroke:$u.wire,strokeWidth:6,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:Ru,fill:"none",stroke:$u.shine,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M36 22 Q42 18 47 21",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M57 21 Q62 18 68 22",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx(Eyes,{cx:52,cy:30,gap:16,r:6.5,colours:$u.eye}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M48 44 Q52 47 56 44",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"})]})})}function Wizard({size:Au,mode:lo="light"}){const $u=WIZARD[lo];return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Wizard","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:"M34 58 Q48 52 62 58 Q70 74 76 92 Q48 98 20 92 Q26 74 34 58 Z",fill:$u.robe}),jsxRuntimeExports.jsx("path",{d:"M21 90 Q48 96 75 90 L76 92 Q48 98 20 92 Z",fill:$u.brim}),jsxRuntimeExports.jsx("circle",{cx:30,cy:82,r:1.6,fill:$u.star}),jsxRuntimeExports.jsx("circle",{cx:67,cy:78,r:1.3,fill:$u.star}),jsxRuntimeExports.jsx("ellipse",{cx:48,cy:46,rx:13,ry:12,fill:$u.face}),jsxRuntimeExports.jsx("path",{d:"M33 38 Q31 66 40 77 Q48 89 56 77 Q65 66 63 38 Q61 50 56 53 Q48 58 40 53 Q35 50 33 38 Z",fill:$u.beard,stroke:$u.beardEdge,strokeWidth:1,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M44 59 Q48 62 52 59",stroke:INK,strokeWidth:1.8,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M39 55 Q44 51 48 54 Q52 51 57 55 Q52 57 48 56 Q44 57 39 55 Z",fill:$u.beard,stroke:$u.beardEdge,strokeWidth:.8}),jsxRuntimeExports.jsx("path",{d:"M25 36 Q35 26 39 14 Q43 2 58 3 Q50 8 53 18 Q58 30 71 36 Q48 30 25 36 Z",fill:$u.hat}),jsxRuntimeExports.jsx("path",{d:"M18 37 Q48 27 78 37 Q48 45 18 37 Z",fill:$u.brim}),jsxRuntimeExports.jsx("path",{d:"M47 17 l1.8 3.6 4 .6 -2.9 2.8 .7 4 -3.6 -1.9 -3.6 1.9 .7 -4 -2.9 -2.8 4 -.6 Z",fill:$u.star}),jsxRuntimeExports.jsx("circle",{cx:56,cy:28,r:1.4,fill:$u.star}),jsxRuntimeExports.jsx(Eyes,{cx:48,cy:46,gap:11,r:4,colours:$u.eye})]})})}function Cat({size:Au,mode:lo="light"}){const $u=CAT[lo],Ru="M70 84 Q90 78 84 58";return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Cat","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:Ru,stroke:$u.edge,strokeWidth:8,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:Ru,stroke:$u.tail,strokeWidth:5,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("ellipse",{cx:48,cy:78,rx:24,ry:14,fill:$u.fur,stroke:$u.edge,strokeWidth:1.5}),jsxRuntimeExports.jsx("path",{d:"M24 30 L28 8 L42 22 Z",fill:$u.fur,stroke:$u.edge,strokeWidth:1.5,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M72 30 L68 8 L54 22 Z",fill:$u.fur,stroke:$u.edge,strokeWidth:1.5,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M28 26 L30 14 L38 22 Z",fill:$u.ear}),jsxRuntimeExports.jsx("path",{d:"M68 26 L66 14 L58 22 Z",fill:$u.ear}),jsxRuntimeExports.jsx("circle",{cx:48,cy:42,r:24,fill:$u.fur,stroke:$u.edge,strokeWidth:1.5}),jsxRuntimeExports.jsx(Eyes,{cx:48,cy:38,gap:18,r:6.5,colours:$u.eye}),jsxRuntimeExports.jsx("path",{d:"M45 48 L51 48 L48 52 Z",fill:$u.nose}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M43 55 Q48 58 53 55",stroke:INK,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M30 48 L18 46 M30 52 L18 54 M66 48 L78 46 M66 52 L78 54",stroke:$u.whiskers,strokeWidth:1.2,strokeLinecap:"round"})]})})}function LoopEyes({size:Au,mode:lo="light"}){const $u=LOOP_EYES[lo];return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"L👀P eyes","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx(Eyes,{cx:48,cy:50,gap:40,r:18,colours:$u.eye}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M42 80 Q48 84 54 80",stroke:lo==="dark"?INK_DARK:INK,strokeWidth:2.5,fill:"none",strokeLinecap:"round",opacity:0})]})})}const eyeOf=(Au,lo)=>({white:Au.white,ring:Au.ring,pupil:Au.pupil,on:lo}),ASSISTANT_CHARACTERS=[{id:"paperclip",name:"Paper clip",Drawing:PaperClip,keyColours:{light:{edges:[PAPER_CLIP.light.wire,PAPER_CLIP.light.line],eye:eyeOf(PAPER_CLIP.light.eye,"page")},dark:{edges:[PAPER_CLIP.dark.wire,PAPER_CLIP.dark.line],eye:eyeOf(PAPER_CLIP.dark.eye,"page")}}},{id:"wizard",name:"Wizard",Drawing:Wizard,keyColours:{light:{edges:[WIZARD.light.hat,WIZARD.light.brim,WIZARD.light.robe,WIZARD.light.beardEdge],eye:eyeOf(WIZARD.light.eye,WIZARD.light.face)},dark:{edges:[WIZARD.dark.hat,WIZARD.dark.brim,WIZARD.dark.robe,WIZARD.dark.beardEdge],eye:eyeOf(WIZARD.dark.eye,WIZARD.dark.face)}}},{id:"cat",name:"Cat",Drawing:Cat,keyColours:{light:{edges:[CAT.light.edge,CAT.light.whiskers],eye:eyeOf(CAT.light.eye,CAT.light.fur)},dark:{edges:[CAT.dark.edge,CAT.dark.whiskers],eye:eyeOf(CAT.dark.eye,CAT.dark.fur)}}},{id:"eyes",name:"L👀P eyes",Drawing:LoopEyes,keyColours:{light:{edges:[LOOP_EYES.light.eye.ring],eye:eyeOf(LOOP_EYES.light.eye,"page")},dark:{edges:[LOOP_EYES.dark.eye.white],eye:eyeOf(LOOP_EYES.dark.eye,"page")}}}],DEFAULT_ASSISTANT_CHARACTER="paperclip";function assistantCharacter(Au){const lo=ASSISTANT_CHARACTERS.find($u=>$u.id===Au);if(!lo)throw new Error(`There is no assistant character "${Au}"; the characters are ${ASSISTANT_CHARACTERS.map($u=>$u.id).join(", ")}.`);return lo}const DEFAULT_DECISION_NAME="Answer",DEFAULT_SCORE_RANGE={from:1,to:5},MAX_SCORE_STEPS=11;function scoreSteps(Au){const lo=[];for(let $u=Au.from;$u<=Au.to;$u+=1)lo.push(String($u));return lo}function decisionAskProblem(Au){if(!Au.situation.trim())return"Say the situation the question is about.";if(!Au.question.trim())return"Ask a question.";if(Au.type==="choice"){const lo=(Au.options??[]).filter($u=>$u.trim());if(lo.length<2)return"A choice needs at least two options.";if(new Set(lo.map($u=>$u.trim())).size!==lo.length)return"Two options are the same."}if(Au.type==="score"){const lo=Au.range??DEFAULT_SCORE_RANGE;if(!Number.isInteger(lo.from)||!Number.isInteger(lo.to))return"A score goes from a whole number to another.";if(lo.to<=lo.from)return"A score goes from a lower number to a higher one.";if(lo.to-lo.from+1>MAX_SCORE_STEPS)return`A score has at most ${MAX_SCORE_STEPS} steps.`}}function decisionRequest(Au){const lo=Au.type==="choice"?(Au.options??[]).map($u=>$u.trim()).filter(Boolean):Au.type==="score"?scoreSteps(Au.range??DEFAULT_SCORE_RANGE):[];return{state:Au.situation.trim(),questions:[{name:Au.name?.trim()||DEFAULT_DECISION_NAME,type:Au.type,instructions:Au.question.trim(),options:lo}]}}function confidenceWords(Au){return String(Number(Au.toFixed(2)))}function decisionAnswerWords(Au,lo,$u=[]){if(typeof lo.probability=="number"&&lo.choice===void 0){const Iu=lo.probability>=.5;return`${Au}: ${Iu?"yes":"no"} (${confidenceWords(Iu?lo.probability:1-lo.probability)})`}const Ru=typeof lo.confidence=="number"?` (${confidenceWords(lo.confidence)})`:"";if(typeof lo.score=="number"){const Iu=$u.length?$u:Object.keys(lo.legend??{}).sort((Du,Lu)=>Number(Du)-Number(Lu)).map(Du=>lo.legend?.[Du]??Du),Pu=lo.legend?.[String(lo.score)]??Iu[lo.score],Ou=Iu[Iu.length-1],Mu=Iu.length>0&&Iu.every(Du=>/^-?\d+$/.test(Du.trim()));return`${Au}: ${Pu??lo.score+1}${Mu&&Ou!==void 0?` of ${Ou}`:""}${Ru}`}return typeof lo.choice=="string"?`${Au}: ${lo.choice}${Ru}`:`${Au}: no answer`}function decisionResponseWords(Au,lo){if(lo.refusal)return lo.refusal;const[$u]=Au.questions,Ru=lo.answers?.[$u.name];return Ru?decisionAnswerWords($u.name,Ru,$u.options):"Nothing was decided: the answer did not come back."}function decisionsAskerAt(Au,lo){const $u=Au.replace(/\/+$/,"");return async Ru=>{let Iu;try{Iu=await fetch(`${$u}/api/v1/configure/inference/decisions`,{method:"POST",headers:{"Content-Type":"application/json",...lo?{Authorization:`Bearer ${lo}`}:{}},body:JSON.stringify(Ru)})}catch{return{refusal:"Nothing was decided: the runtime could not be reached."}}if(!Iu.ok){let Pu="";try{const Ou=await Iu.json();Pu=typeof Ou.detail=="string"?Ou.detail:""}catch{}return{refusal:`Nothing was decided: the runtime refused it (${Iu.status})${Pu?`: ${Pu}`:"."}`}}return await Iu.json()}}const DECISION_WORDS={ask:"Ask a decision",asking:"Asking…",submit:"Ask",cancel:"Cancel",again:"Ask another",types:{noul:"Yes or no",choice:"A choice",score:"A score"}},LINK_SX={mt:1,p:0,border:0,bg:"transparent",color:"accent.fg",textDecoration:"underline",cursor:"pointer",fontSize:1};function DecisionAsk({ask:Au,onActiveChange:lo}){const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(""),[Du,Lu]=reactExports.useState(""),[Bu,ju]=reactExports.useState("noul"),[Fu,zu]=reactExports.useState(""),[Uu,Hu]=reactExports.useState(String(DEFAULT_SCORE_RANGE.from)),[Vu,Gu]=reactExports.useState(String(DEFAULT_SCORE_RANGE.to)),[Wu,Ku]=reactExports.useState(),[Ju,Yu]=reactExports.useState(!1),[Xu,ed]=reactExports.useState(),td=reactExports.useRef(lo);td.current=lo,reactExports.useEffect(()=>()=>td.current?.(!1),[]);const nd=ad=>{Ru(ad),lo?.(ad)},od=()=>{ed(void 0),Ku(void 0),nd(!1)};if(!$u)return jsxRuntimeExports.jsx(Box,{as:"button",type:"button","data-balloon-ask-decision":"",onClick:()=>nd(!0),...LINK_SX,display:"block",children:DECISION_WORDS.ask});if(Xu!==void 0)return jsxRuntimeExports.jsxs(Box,{"data-balloon-decision":"answered",mt:2,children:[jsxRuntimeExports.jsx(Text$3,{as:"p","data-decision-answer":"",sx:{m:0,fontWeight:"semibold"},children:Xu}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,mt:2,children:[jsxRuntimeExports.jsx(ButtonComponent,{size:"small",onClick:()=>ed(void 0),children:DECISION_WORDS.again}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",onClick:od,children:DECISION_WORDS.cancel})]})]});const sd=async()=>{const ad={situation:Iu,question:Ou,type:Bu,name:Du,options:Fu.split(`
|
|
3693
3693
|
`),range:{from:Number(Uu),to:Number(Vu)}},pd=decisionAskProblem(ad);if(Ku(pd),pd)return;const gd=decisionRequest(ad);Yu(!0);try{ed(decisionResponseWords(gd,await Au(gd)))}catch(Sd){ed(`Nothing was decided: ${Sd instanceof Error?Sd.message:String(Sd)}`)}finally{Yu(!1)}};return jsxRuntimeExports.jsxs(Box,{as:"form","data-balloon-decision":"asking","aria-label":DECISION_WORDS.ask,onSubmit:ad=>{ad.preventDefault(),sd()},onKeyDown:ad=>{ad.key==="Escape"&&od()},mt:2,display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Situation"}),jsxRuntimeExports.jsx(Textarea,{block:!0,rows:3,resize:"vertical",name:"situation",placeholder:"Help! My payouts have been failing for 3 days.",value:Iu,onChange:ad=>Pu(ad.target.value)})]}),jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Question"}),jsxRuntimeExports.jsx(TextInput$1,{block:!0,size:"small",name:"question",placeholder:"Is it urgent?",value:Ou,onChange:ad=>Mu(ad.target.value)})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,children:[jsxRuntimeExports.jsxs(FormControl$1,{sx:{flex:1},children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Type"}),jsxRuntimeExports.jsx(Select$1,{block:!0,size:"small",name:"type",value:Bu,onChange:ad=>ju(ad.target.value),children:Object.keys(DECISION_WORDS.types).map(ad=>jsxRuntimeExports.jsx(Select$1.Option,{value:ad,children:DECISION_WORDS.types[ad]},ad))})]}),jsxRuntimeExports.jsxs(FormControl$1,{sx:{flex:1},children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Name"}),jsxRuntimeExports.jsx(TextInput$1,{block:!0,size:"small",name:"name",placeholder:"Answer",value:Du,onChange:ad=>Lu(ad.target.value)})]})]}),Bu==="choice"&&jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Options, one per line"}),jsxRuntimeExports.jsx(Textarea,{block:!0,rows:3,resize:"vertical",name:"options",placeholder:`Billing
|
|
3694
3694
|
Tech
|
|
@@ -3858,7 +3858,7 @@ ${Mu}`:ju,inputs:Mu,clear:Ou?[]:[DRAFT.path],loop:Lu()}:{refused:"Nothing to sen
|
|
|
3858
3858
|
0%, 100% { opacity: 0.25; }
|
|
3859
3859
|
50% { opacity: 1; }
|
|
3860
3860
|
}`;function SubagentPulse(){const Au=useAgentRuntimeActiveSubagentToolCallId(),lo=useAgentRuntimeSubagentActivity(Au??void 0),$u=useOptionalReactorPlatform(),Ru=lo[0]?.subagentName??Au??"",Iu=$u?.getOutput(AGENTS_PLUGIN_NAME)?.team?.members.find(Du=>Du.name===Ru),Pu=agentIcon(Iu?.icon);if(!Au)return null;const Mu=lo.some(Du=>Du.transport==="a2a")?`${Ru} is working over A2A…`:`${Ru} is working…`;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{children:KEYFRAMES}),jsxRuntimeExports.jsx(Tooltip,{text:Mu,direction:"n",children:jsxRuntimeExports.jsx(Box,{as:"button",type:"button","aria-label":Mu,"data-subagent-pulse":Ru,display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,p:0,border:0,bg:"transparent",color:"accent.fg",cursor:"default",animation:`${PULSE_ANIMATION} 1.4s ease-in-out infinite`,children:jsxRuntimeExports.jsx(Pu,{size:16})})})]})}const SUBAGENT_ACTIVITY_PLUGIN_NAME="@datalayer/loop-plugin-subagent-activity",SubagentActivityPlugin={name:SUBAGENT_ACTIVITY_PLUGIN_NAME,displayName:"Subagent activity",description:"A delegated agent's icon, pulsing in the prompt's header while it works.",octicon:"people",emoji:"👥",dependencies:[InputPromptPlugin],build:()=>({components:[{id:"subagent-pulse",slot:LoopSlots.inpromptMenu,order:0,Component:SubagentPulse}]})},A2UI_PLUGIN_NAME="@datalayer/loop-plugin-a2ui",A2uiPlugin={name:A2UI_PLUGIN_NAME,displayName:"A2UI surfaces",description:"The last execution, rendered as a surface rather than dumped.",octicon:"browser",emoji:"🖼",dependencies:[AgentsPlugin],contributes:[contribution(LoopViewType,{viewType:"a2ui",title:"Surface",icon:BrowserIcon,order:30,canOpen:Au=>Au.sandbox.state==="running"&&Au.sandbox.variant!=="pyodide",unavailableReason:Au=>Au.sandbox.variant==="pyodide"?"Surfaces are rendered by the server; this sandbox runs in the browser":"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/A2uiView-CsiMsnAN.js"),[],import.meta.url)},{id:"a2ui",order:30}),contribution(LoopCommand,{name:"a2ui",aliases:["surface"],description:"Show the last execution as a rendered surface",group:"Open",keybinding:"Mod+Alt+U",run:async({workspace:Au})=>{Au.setActiveViewType("a2ui")}},{id:"a2ui"})]},NONE_VIEW="none";let state={viewId:NONE_VIEW,options:[],allowNone:!0},announcer=()=>!0;const listeners=new Set;function notify(){for(const Au of[...listeners])Au()}function getViewChoice(){return state}function subscribeViewChoice(Au){return listeners.add(Au),()=>{listeners.delete(Au)}}function setViewAnnouncer(Au){const lo=announcer;return announcer=Au,()=>{announcer=lo}}function setViewOptions(Au,lo=!0){if(lo===state.allowNone&&Au.length===state.options.length&&Au.every((Ru,Iu)=>Ru===state.options[Iu]))return;state={viewId:!lo&&!Au.includes(state.viewId)?Au[0]??NONE_VIEW:state.viewId,options:Au,allowNone:lo},notify()}function chooseView(Au){return state={...state,viewId:Au},notify(),announcer(Au)}function seedViewChoice(Au){state.viewId!==Au&&(state={...state,viewId:Au},notify())}function nextView(){const Au=state.allowNone?[NONE_VIEW,...state.options]:[...state.options];if(Au.length===0)return NONE_VIEW;const lo=Au.indexOf(state.viewId);return Au[(lo+1)%Au.length]}function ViewSelector({point:Au,describe:lo,context:$u,noneLabel:Ru,ariaLabel:Iu,allowNone:Pu=!0}){const Ou=useContributions(Au),Mu=reactExports.useSyncExternalStore(subscribeViewChoice,getViewChoice),[Du,Lu]=reactExports.useState(null),Bu=reactExports.useRef(null),ju=()=>{Bu.current!==null&&(window.clearTimeout(Bu.current),Bu.current=null)},Fu=Vu=>{ju(),Lu(Vu)},zu=()=>{ju(),Bu.current=window.setTimeout(()=>{Lu(null),Bu.current=null},250)};reactExports.useEffect(()=>ju,[]);const Uu=reactExports.useMemo(()=>Ou.map(Vu=>lo(Vu.value,$u)).sort((Vu,Gu)=>(Vu.order??100)-(Gu.order??100)),[Ou,lo,$u]);if(reactExports.useEffect(()=>{setViewOptions(Uu.map(Vu=>Vu.id),Pu)},[Uu,Pu]),Uu.length<(Pu?1:2))return null;const Hu=Uu.find(Vu=>Vu.id===Du&&Vu.details);return jsxRuntimeExports.jsxs(Box$1,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",position:"relative"},children:[jsxRuntimeExports.jsxs(SegmentedControl,{"aria-label":Iu,size:"small",children:[Pu?jsxRuntimeExports.jsx(SegmentedControl.Button,{selected:Mu.viewId===NONE_VIEW,onClick:()=>chooseView(NONE_VIEW),children:Ru}):null,Uu.map(Vu=>jsxRuntimeExports.jsx(SegmentedControl.Button,{selected:Mu.viewId===Vu.id,"aria-disabled":Vu.disabled||void 0,title:Vu.disabled?Vu.disabledReason:Vu.title,leadingIcon:Vu.icon,onMouseEnter:Vu.details?()=>Fu(Vu.id):void 0,onMouseLeave:Vu.details?zu:void 0,onClick:()=>{Vu.disabled||chooseView(Vu.id)},children:Vu.badge?`${Vu.title} (${Vu.badge})`:Vu.title},Vu.id))]}),Hu?jsxRuntimeExports.jsx(Box$1,{onMouseEnter:ju,onMouseLeave:zu,sx:{position:"absolute",top:"calc(100% + 6px)",right:0,minWidth:260,maxWidth:380,maxHeight:320,overflowY:"auto",p:2,bg:"canvas.overlay",border:"1px solid",borderColor:"border.default",borderRadius:2,boxShadow:"shadow.large",zIndex:40,fontSize:0,color:"fg.default",textAlign:"left"},children:Hu.details}):null]})}const SHELL_PLUGIN_NAME$1="@datalayer/reactor-shell",ShellView=defineContributionPoint("reactor.shell.view"),describeAsIs=Au=>Au,ShellPlugin$1={name:SHELL_PLUGIN_NAME$1,displayName:"Shell",description:"A view point, its selector, and the choice as a command.",octicon:"columns",emoji:"📑",config:{point:ShellView,describe:describeAsIs,slot:"header",defaultView:NONE_VIEW,showSelector:!0,allowNone:!0,noneLabel:"None",ariaLabel:"View",announce:()=>!0,commandId:"shell.cycleView",commandName:"Switch the view",commandDescription:"Cycle through the contributed views, and none",keybinding:"Mod+Alt+E"},contributionPoints:[ShellView],register:({config:Au,registerCommand:lo})=>{const $u=setViewAnnouncer(Au.announce),Ru=lo({id:Au.commandId,name:Au.commandName,description:Au.commandDescription,emoji:"📑",category:"Workspace",keybinding:Au.keybinding||void 0,execute:()=>{chooseView(nextView())}});return()=>{$u(),Ru()}},build:({config:Au})=>(seedViewChoice(Au.defaultView||NONE_VIEW),{components:Au.showSelector?[{id:"view-selector",slot:Au.slot,Component:lo=>jsxRuntimeExports.jsx(ViewSelector,{point:Au.point,describe:Au.describe,context:lo,noneLabel:Au.noneLabel,allowNone:Au.allowNone,ariaLabel:Au.ariaLabel})}]:[]})};setViewAnnouncer(requestSurface);const NONE_EDITOR=NONE_VIEW;let mappedFor=null,mapped=null;function getEditorChoice(){const Au=getViewChoice();return(Au!==mappedFor||!mapped)&&(mappedFor=Au,mapped={editorId:Au.viewId,options:Au.options}),mapped}const subscribeEditorChoice=subscribeViewChoice,setEditorOptions=setViewOptions,chooseEditor=chooseView,seedEditorChoice=seedViewChoice,nextEditor=nextView;let jupyterReact=null;function loadJupyterReact(){return jupyterReact?Promise.resolve(jupyterReact):__vitePreload(()=>import("./chunks/index-BOGJMsUN.js").then(Au=>Au.r),[],import.meta.url).then(Au=>(jupyterReact=Au,Au))}const PREVIEW_LENGTH=56;function stripped(Au){const $u=(Au.split(`
|
|
3861
|
-
`).find(Ru=>Ru.trim())??"").trim();return $u.length>PREVIEW_LENGTH?`${$u.slice(0,PREVIEW_LENGTH-1)}…`:$u||"(empty)"}function PreviewList({title:Au,rows:lo}){return jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",display:"block",mb:1},children:Au}),lo.length===0?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:"Empty so far."}):lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,py:"2px",alignItems:"baseline",children:[jsxRuntimeExports.jsxs(Text$3,{sx:{color:"fg.muted",flexShrink:0,fontFamily:"mono"},children:[Ru," · ",$u.kind]}),jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$u.text})]},Ru))]})}function useOfferedEditors(){return reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().options)}function useNotebookRows(Au,lo){const[$u,Ru]=reactExports.useState(0);return reactExports.useEffect(()=>{if(!lo)return;let Iu=!1;const Pu=()=>Ru(Du=>Du+1),Ou=[],Mu=jupyterReact!==null;return loadJupyterReact().then(({notebookStore:Du})=>{if(!Iu)try{const Lu=Du.subscribe?.(Pu);Lu&&Ou.push(Lu);const Bu=Du.getState()?.notebooks?.get(Au)?.model;if(Bu){const ju=[Bu.contentChanged,Bu.cells?.changed];for(const Fu of ju)Fu?.connect&&(Fu.connect(Pu),Ou.push(()=>Fu.disconnect(Pu)))}Mu||Pu()}catch{}}),()=>{Iu=!0;for(const Du of Ou)try{Du()}catch{}}},[lo,Au,$u]),reactExports.useMemo(()=>{if(!lo)return null;const Iu=safeModel(Au);if(!Iu)return null;const Pu=[],Ou=Iu.cells;for(let Mu=0;Mu<Ou.length;Mu+=1){const Du=Ou.get(Mu);Pu.push({kind:Du.type,text:stripped(Du.sharedModel.getSource())})}return Pu},[lo,Au,$u])}function safeModel(Au){try{return jupyterReact?.notebookStore.getState()?.notebooks?.get(Au)?.model??null}catch{return null}}function useDocumentRows(Au,lo){const[$u,Ru]=reactExports.useState(null);return reactExports.useEffect(()=>{if(!lo){Ru(null);return}let Iu=!1,Pu,Ou=!1;return __vitePreload(()=>import("./chunks/PrismCss-sPywsCAF.js").then(Mu=>Mu.a),[],import.meta.url).then(()=>__vitePreload(()=>import("./chunks/index-hxIHgkzg.js"),[],import.meta.url)).then(({lexicalStore:Mu})=>{if(Iu)return;const Du=()=>{Ou||(Ou=!0,Mu.getState().readAllBlocks(Au,"brief").then(Lu=>{Ou=!1,!(Iu||!Array.isArray(Lu))&&Ru(Lu.map(Bu=>({kind:Bu.block_type??"block",text:stripped(Bu.preview??"")})))}).catch(()=>{Ou=!1,Iu||Ru(null)}))};Du(),Pu=Mu.subscribe(Du)}).catch(()=>{Iu||Ru(null)}),()=>{Iu=!0,Pu?.()}},[lo,Au]),$u}function useEditorPreviews(Au){const lo=useOfferedEditors(),$u=useNotebookRows(Au,lo.includes("notebook")),Ru=useDocumentRows(Au,lo.includes("document"));return reactExports.useMemo(()=>{const Iu={};return $u&&(Iu.notebook={badge:String($u.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Cells",rows:$u})}),Ru&&(Iu.document={badge:String(Ru.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Blocks",rows:Ru})}),Iu},[$u,Ru])}const SHELL_PLUGIN_NAME="@datalayer/loop-plugin-shell";function describeEditor(Au,lo){const $u=Au,Ru=lo?.workspace,Iu=Ru?canOpenView($u,Ru):!0;return{id:$u.surfaceId,title:$u.title,icon:$u.icon,order:$u.order,disabled:!Iu,disabledReason:Iu?void 0:Ru&&$u.unavailableReason?.(Ru)||"Not available right now"}}function EditorSelectorComponent(Au){const lo=Au.workspace,$u=useEditorPreviews(lo?.surfaceId??""),Ru=(Iu,Pu)=>{const Ou=describeEditor(Iu,Pu),Mu=$u[Ou.id];return Mu?{...Ou,badge:Mu.badge,details:Mu.details}:Ou};return jsxRuntimeExports.jsx(ViewSelector,{point:LoopEditorView,describe:Ru,context:Au,noneLabel:"Chat",ariaLabel:"Editor"})}const ShellPlugin={name:SHELL_PLUGIN_NAME,displayName:"Loop shell",description:"The Loop workspace’s extension points, and the editor choice.",octicon:"columns",emoji:"📑",config:{defaultEditor:NONE_EDITOR,showSelector:!0},dependencies:[configurePlugin(ShellPlugin$1,{point:LoopEditorView,describe:describeEditor,showSelector:!1,announce:Au=>requestSurface(Au),commandId:"loop.shell.cycleEditor",commandName:"Switch the editor",commandDescription:"Cycle through the editors beside the conversation, and none",keybinding:""})],contributionPoints:[LoopViewType,LoopEditorView],contributes:[contribution(LoopCommand,{name:"editor",aliases:["editors"],description:"Switch the editor beside the conversation",group:"Open",keybinding:"Mod+Alt+E",args:[{name:"editor",description:"Which editor: none, or a surface id. Omit to cycle.",required:!1,choices:()=>[NONE_EDITOR,...getEditorChoice().options]}],run:async({argv:Au})=>{const lo=Au.trim(),$u=lo===""?nextEditor():lo,Ru=[NONE_EDITOR,...getEditorChoice().options];if(!Ru.includes($u))throw new Error(`No editor called '${$u}'. There is: ${Ru.join(", ")}.`);if(!chooseEditor($u))throw new Error("No chat is on screen to host the editor.")}},{id:"editor"})],build:({config:Au})=>(seedEditorChoice(Au.defaultEditor||NONE_EDITOR),{components:Au.showSelector?[{id:"editor-selector",slot:LoopSlots.header,Component:EditorSelectorComponent}]:[]})};function NewChatAction({workspace:Au}){return Au?jsxRuntimeExports.jsx(IconButton,{icon:PlusIcon,"aria-label":"New conversation",title:"New conversation",variant:"invisible",size:"small",onClick:()=>{Au.submit("/new")}}):null}const PROMPT_PLUGIN_NAME="@datalayer/loop-plugin-prompt",PromptPlugin={name:PROMPT_PLUGIN_NAME,displayName:"Prompt",description:"Prompt commands: focus the composer, start over, and the +.",octicon:"paper-airplane",emoji:"🪶",contributes:[contribution(LoopCommand,{name:"prompt",description:"Focus the prompt",group:"Session",keybinding:"Mod+Alt+P",run:async()=>{if(!focusPrompt())throw new Error("No prompt is on screen to focus.")}},{id:"prompt"}),contribution(LoopCommand,{name:"new",aliases:["reset"],description:"Start the conversation over",group:"Session",keybinding:"Mod+Alt+R",run:async({workspace:Au})=>{const lo=Au.viewControls.newChat;if(!lo)throw new Error("No conversation is on screen to start over.");lo()}},{id:"new"})],build:()=>({components:[{id:"new-chat",slot:LoopSlots.promptAction,Component:NewChatAction}]})};function AgentspecPicker({workspace:Au}){const[lo,$u]=reactExports.useState([]),[Ru,Iu]=reactExports.useState(!1),[Pu,Ou]=reactExports.useState(Au.agentId),Mu=Au.sandbox.target,Du=Au.sandbox.state;reactExports.useEffect(()=>{let Fu=!1;return fetch(`${Au.serverUrl}/api/v1/agents`).then(zu=>zu.ok?zu.json():{agents:[]}).then(zu=>{Fu||$u(zu.agents??[])}).catch(()=>{}),()=>{Fu=!0}},[Au.serverUrl,Mu,Du]),reactExports.useEffect(()=>{Ou(Au.agentId)},[Au.agentId]);const Lu=reactExports.useCallback(async Fu=>{Iu(!0);try{(await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:Fu})})).ok&&(Ou(Fu),Au.setAgentId(Fu))}finally{Iu(!1)}},[Au.agentId,Au.conversationId,Au.serverUrl,Au.setAgentId]),Bu=lo.find(Fu=>Fu.id===Pu),ju=Bu?.name||getAgentspecs(Pu)?.name||Pu||"Agent";return lo.length===0?null:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:1,children:[Ru?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):null,jsxRuntimeExports.jsxs(ActionMenu,{children:[jsxRuntimeExports.jsxs(ActionMenu.Button,{variant:"invisible",size:"small",children:[Bu?.emoji?`${Bu.emoji} `:"",ju]}),jsxRuntimeExports.jsx(ActionMenu.Overlay,{width:"medium",children:jsxRuntimeExports.jsx(ActionList,{selectionVariant:"single",children:lo.map(Fu=>jsxRuntimeExports.jsxs(ActionList.Item,{selected:Fu.id===Pu,onSelect:()=>{Lu(Fu.id)},children:[Fu.emoji?`${Fu.emoji} `:"",Fu.name||Fu.id,Fu.description?jsxRuntimeExports.jsx(ActionList.Description,{variant:"block",children:Fu.description}):null]},Fu.id))})})]})]})}const AGENTSPECS_PLUGIN_NAME="@datalayer/loop-plugin-agentspecs",AgentspecsPlugin={name:AGENTSPECS_PLUGIN_NAME,displayName:"Agentspecs",description:"Pick the agentspec this session runs.",octicon:"people",emoji:"🤖",build(){return{components:[{slot:LoopSlots.header,id:"agent-picker",Component:AgentspecPicker}]}},contributes:[contribution(LoopCommand,{name:"agents",aliases:["agent"],description:"Switch the agent this session is using",group:"Agents",keybinding:"Mod+Alt+A",args:[{name:"agent-id",description:"Agent to switch to"}],run:async({workspace:Au,argv:lo})=>{const $u=lo.trim();if(!$u)return{content:"Pick an agent from the header, or /agents <id>."};const Ru=await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:$u})});if(!Ru.ok)return{content:`Unknown agent: ${$u}`};const Iu=await Ru.json();return{content:`Now using ${Iu.name??Iu.agent_id}.`}}},{id:"agents"})]},CHAT_HEADER_PLUGIN_NAME="@datalayer/loop-plugin-chat-header",LazyHeaderView=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/HeaderView-D8h-aEea.js"),[],import.meta.url));function HeaderView(Au){return jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(LazyHeaderView,{...Au})})}const ChatHeaderPlugin={name:CHAT_HEADER_PLUGIN_NAME,displayName:"Chat Header",description:"The conversation’s title bar: agent, kernel, actions.",octicon:"rows",emoji:"🏷️",contributes:[contribution(LoopChatHeader,{id:"chat-header",Component:HeaderView},{id:"chat-header"})]};function readA2uiToolResult(Au,lo){if(!Au)return null;let $u=Au;if(typeof Au=="string")try{$u=JSON.parse(Au)}catch{return null}if(typeof $u!="object"||$u===null||!Array.isArray($u.messages))return null;const Ru=$u,Iu=(Ru.messages??[]).map(Pu=>{const Ou=Pu;return Ou.createSurface&&Ou.createSurface.catalogId!==lo?{...Ou,createSurface:{...Ou.createSurface,catalogId:lo}}:Pu});return{...Ru,messages:Iu}}function isEmptyA2uiValue(Au){return Au==null?!0:typeof Au=="string"?Au.trim()==="":Array.isArray(Au)?Au.length===0:typeof Au=="boolean"?Au===!1:!1}const EMAIL_PATTERN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function validateA2uiField(Au,lo){if(isEmptyA2uiValue(lo))return Au.required?`${Au.label} is required.`:null;if(Au.format==="email"&&typeof lo=="string"&&!EMAIL_PATTERN.test(lo.trim()))return`${Au.label} must be a valid email address.`;if(Au.pattern&&typeof lo=="string"){let $u;try{$u=new RegExp(Au.pattern).test(lo.trim())}catch{$u=!0}if(!$u)return`${Au.label} is not in the expected format.`}if(Au.minLength!==void 0&&typeof lo=="string"&&lo.trim().length<Au.minLength)return`${Au.label} must be at least ${Au.minLength} characters.`;if(Au.type==="slider"&&typeof lo=="number"){if(Au.min!==void 0&&lo<Au.min)return`${Au.label} must be at least ${Au.min}.`;if(Au.max!==void 0&&lo>Au.max)return`${Au.label} must be at most ${Au.max}.`}return null}function validateA2uiSubmission(Au,lo){return Au.map($u=>validateA2uiField($u,lo[$u.id])).filter($u=>$u!==null)}const ANSWER_DISPLAY_TYPE="application/vnd.datalayer.loop.answer+json";function answerSurface(Au,lo){return Au.type!==ANSWER_DISPLAY_TYPE?null:readA2uiToolResult(Au.data?.surface,lo)}function answerPress(Au,lo){const $u=lo.name.trim(),Ru=(Au.actions??[]).find(Iu=>Iu.name===$u);return Ru?{message:$u,forwardedProps:{loop:{action:{name:$u,display_id:Au.id,token:Ru.token,payload:{...lo.context}}}}}:{refused:`“${$u||"This button"}” was not offered here.`}}function AnswerShowsView({display:Au,send:lo}){const $u=reactExports.useMemo(()=>answerSurface(Au,SURFACE_CATALOG_ID),[Au]),Ru=useOwnCatalog(),[Iu,Pu]=reactExports.useState(null);if(!$u?.messages||$u.messages.length===0)return jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:Au.text});const Ou=Mu=>{const Du=answerPress(Au,Mu);if("refused"in Du){Pu(Du.refused);return}Pu(lo(Du.message,Du.forwardedProps)?null:"The chat is not ready to take it yet.")};return jsxRuntimeExports.jsx(InlineSurface,{messages:$u.messages,onAction:Ou,validationError:Iu,catalog:Ru},JSON.stringify(Au))}function SurfaceToolResult({context:Au,send:lo,onRendered:$u,onSubmitted:Ru}){const Iu=reactExports.useMemo(()=>Au.status==="complete"?readA2uiToolResult(Au.result,SURFACE_CATALOG_ID):null,[Au.status,Au.result]),Pu=Iu?.title??"the form",[Ou,Mu]=reactExports.useState(null),Du=useOwnCatalog();reactExports.useEffect(()=>{Iu?.messages&&Iu.messages.length>0&&$u?.({toolCallId:Au.toolCallId,surfaceId:Iu.surfaceId,title:Pu,messages:Iu.messages,result:Iu})},[Iu,Au.toolCallId]);const Lu=reactExports.useCallback(Bu=>{if(Bu.name!=="submit_a2ui_form")return;const ju=Bu.context??{},Fu=validateA2uiSubmission(Iu?.fieldRules??[],ju);if(Fu.length>0){Mu(Fu.join(" "));return}Mu(null),Ru?.({surfaceId:Bu.surfaceId,title:Pu,values:ju}),lo(encodeFormSubmission({title:Pu,surfaceId:Bu.surfaceId,values:ju}))||Mu("The chat is not ready to take the submission yet.")},[Iu,Pu,lo,Ru]);return!Iu?.messages||Iu.messages.length===0?jsxRuntimeExports.jsxs(Box,{border:"1px solid",borderColor:"border.default",borderRadius:2,px:3,py:2,bg:"canvas.default",display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,color:"fg.muted"},children:"Rendering A2UI surface..."})]}):jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"bold"},children:Pu}),jsxRuntimeExports.jsx(InlineSurface,{messages:Iu.messages,onAction:Lu,validationError:Ou,catalog:Du})]})}const A2UI_SURFACE_PLUGIN_NAME="@datalayer/loop-plugin-a2ui-surface",A2UI_SURFACE_RENDERER="a2ui-surface",A2UI_SURFACE_TYPE="application/vnd.datalayer.a2ui.surface+json";function surfaceToolNames(){const Au=new Set;for(const lo of Object.values(AGENTSPECS))for(const $u of lo.frontendRenderTools??[])$u.renderer===A2UI_SURFACE_RENDERER&&Au.add($u.tool);return Au}let counter=0;function createA2uiSurfacePlugin(Au={}){const lo=`a2ui-surface-${counter+=1}`;let $u;const Ru=(Du,Lu)=>$u?!$u(Du,Lu):!1;function Iu({workspace:Du}){const Lu=Du?.viewControls.send;return reactExports.useEffect(()=>($u=Lu,()=>{$u===Lu&&($u=void 0)}),[Lu]),null}function Pu({context:Du}){return Du?Du.status==="error"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Du.defaultUI}):jsxRuntimeExports.jsx(SurfaceToolResult,{context:Du,send:Ru,onRendered:Au.onRendered,onSubmitted:Au.onSubmitted},Du.toolCallId):null}function Ou({display:Du}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Du,send:Ru})}return{name:counter===1?A2UI_SURFACE_PLUGIN_NAME:`${A2UI_SURFACE_PLUGIN_NAME}-${lo}`,displayName:"A2UI surfaces",description:"Generated surfaces drawn in the transcript, and submitted back to the agent.",octicon:"browser",emoji:"🪟",contributes:[contribution(Renderers,defineRenderer({type:A2UI_SURFACE_TYPE,component:Pu,rank:Au.onRendered||Au.onSubmitted?1:0}),{id:lo}),contribution(Renderers,defineRenderer({type:ANSWER_DISPLAY_TYPE,component:Ou}),{id:`${lo}:answer`}),...[...surfaceToolNames()].map(Du=>contribution(ToolBindings,{tool:Du,type:A2UI_SURFACE_TYPE},{id:`${lo}:${Du}`}))],build(){return{components:[{slot:LoopSlots.chatHeader,id:lo,Component:Iu}]}}}}const A2uiSurfacePlugin=createA2uiSurfacePlugin(),qrcode=function(Au,lo){let Iu=Au;const Pu=QRErrorCorrectionLevel[lo];let Ou=null,Mu=0,Du=null;const Lu=[],Bu={},ju=function(ed,td){Mu=Iu*4+17,Ou=(function(nd){const od=new Array(nd);for(let sd=0;sd<nd;sd+=1){od[sd]=new Array(nd);for(let ad=0;ad<nd;ad+=1)od[sd][ad]=null}return od})(Mu),Fu(0,0),Fu(Mu-7,0),Fu(0,Mu-7),Hu(),Uu(),Gu(ed,td),Iu>=7&&Vu(ed),Du==null&&(Du=Ju(Iu,Pu,Lu)),Wu(Du,td)},Fu=function(ed,td){for(let nd=-1;nd<=7;nd+=1)if(!(ed+nd<=-1||Mu<=ed+nd))for(let od=-1;od<=7;od+=1)td+od<=-1||Mu<=td+od||(0<=nd&&nd<=6&&(od==0||od==6)||0<=od&&od<=6&&(nd==0||nd==6)||2<=nd&&nd<=4&&2<=od&&od<=4?Ou[ed+nd][td+od]=!0:Ou[ed+nd][td+od]=!1)},zu=function(){let ed=0,td=0;for(let nd=0;nd<8;nd+=1){ju(!0,nd);const od=QRUtil.getLostPoint(Bu);(nd==0||ed>od)&&(ed=od,td=nd)}return td},Uu=function(){for(let ed=8;ed<Mu-8;ed+=1)Ou[ed][6]==null&&(Ou[ed][6]=ed%2==0);for(let ed=8;ed<Mu-8;ed+=1)Ou[6][ed]==null&&(Ou[6][ed]=ed%2==0)},Hu=function(){const ed=QRUtil.getPatternPosition(Iu);for(let td=0;td<ed.length;td+=1)for(let nd=0;nd<ed.length;nd+=1){const od=ed[td],sd=ed[nd];if(Ou[od][sd]==null)for(let ad=-2;ad<=2;ad+=1)for(let pd=-2;pd<=2;pd+=1)ad==-2||ad==2||pd==-2||pd==2||ad==0&&pd==0?Ou[od+ad][sd+pd]=!0:Ou[od+ad][sd+pd]=!1}},Vu=function(ed){const td=QRUtil.getBCHTypeNumber(Iu);for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[Math.floor(nd/3)][nd%3+Mu-8-3]=od}for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[nd%3+Mu-8-3][Math.floor(nd/3)]=od}},Gu=function(ed,td){const nd=Pu<<3|td,od=QRUtil.getBCHTypeInfo(nd);for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<6?Ou[sd][8]=ad:sd<8?Ou[sd+1][8]=ad:Ou[Mu-15+sd][8]=ad}for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<8?Ou[8][Mu-sd-1]=ad:sd<9?Ou[8][15-sd-1+1]=ad:Ou[8][15-sd-1]=ad}Ou[Mu-8][8]=!ed},Wu=function(ed,td){let nd=-1,od=Mu-1,sd=7,ad=0;const pd=QRUtil.getMaskFunction(td);for(let gd=Mu-1;gd>0;gd-=2)for(gd==6&&(gd-=1);;){for(let Sd=0;Sd<2;Sd+=1)if(Ou[od][gd-Sd]==null){let _d=!1;ad<ed.length&&(_d=(ed[ad]>>>sd&1)==1),pd(od,gd-Sd)&&(_d=!_d),Ou[od][gd-Sd]=_d,sd-=1,sd==-1&&(ad+=1,sd=7)}if(od+=nd,od<0||Mu<=od){od-=nd,nd=-nd;break}}},Ku=function(ed,td){let nd=0,od=0,sd=0;const ad=new Array(td.length),pd=new Array(td.length);for(let yd=0;yd<td.length;yd+=1){const wd=td[yd].dataCount,Ad=td[yd].totalCount-wd;od=Math.max(od,wd),sd=Math.max(sd,Ad),ad[yd]=new Array(wd);for(let ld=0;ld<ad[yd].length;ld+=1)ad[yd][ld]=255&ed.getBuffer()[ld+nd];nd+=wd;const md=QRUtil.getErrorCorrectPolynomial(Ad),bd=qrPolynomial(ad[yd],md.getLength()-1).mod(md);pd[yd]=new Array(md.getLength()-1);for(let ld=0;ld<pd[yd].length;ld+=1){const ud=ld+bd.getLength()-pd[yd].length;pd[yd][ld]=ud>=0?bd.getAt(ud):0}}let gd=0;for(let yd=0;yd<td.length;yd+=1)gd+=td[yd].totalCount;const Sd=new Array(gd);let _d=0;for(let yd=0;yd<od;yd+=1)for(let wd=0;wd<td.length;wd+=1)yd<ad[wd].length&&(Sd[_d]=ad[wd][yd],_d+=1);for(let yd=0;yd<sd;yd+=1)for(let wd=0;wd<td.length;wd+=1)yd<pd[wd].length&&(Sd[_d]=pd[wd][yd],_d+=1);return Sd},Ju=function(ed,td,nd){const od=QRRSBlock.getRSBlocks(ed,td),sd=qrBitBuffer();for(let pd=0;pd<nd.length;pd+=1){const gd=nd[pd];sd.put(gd.getMode(),4),sd.put(gd.getLength(),QRUtil.getLengthInBits(gd.getMode(),ed)),gd.write(sd)}let ad=0;for(let pd=0;pd<od.length;pd+=1)ad+=od[pd].dataCount;if(sd.getLengthInBits()>ad*8)throw"code length overflow. ("+sd.getLengthInBits()+">"+ad*8+")";for(sd.getLengthInBits()+4<=ad*8&&sd.put(0,4);sd.getLengthInBits()%8!=0;)sd.putBit(!1);for(;!(sd.getLengthInBits()>=ad*8||(sd.put(236,8),sd.getLengthInBits()>=ad*8));)sd.put(17,8);return Ku(sd,od)};Bu.addData=function(ed,td){td=td||"Byte";let nd=null;switch(td){case"Numeric":nd=qrNumber(ed);break;case"Alphanumeric":nd=qrAlphaNum(ed);break;case"Byte":nd=qr8BitByte(ed);break;case"Kanji":nd=qrKanji(ed);break;default:throw"mode:"+td}Lu.push(nd),Du=null},Bu.isDark=function(ed,td){if(ed<0||Mu<=ed||td<0||Mu<=td)throw ed+","+td;return Ou[ed][td]},Bu.getModuleCount=function(){return Mu},Bu.make=function(){if(Iu<1){let ed=1;for(;ed<40;ed++){const td=QRRSBlock.getRSBlocks(ed,Pu),nd=qrBitBuffer();for(let sd=0;sd<Lu.length;sd++){const ad=Lu[sd];nd.put(ad.getMode(),4),nd.put(ad.getLength(),QRUtil.getLengthInBits(ad.getMode(),ed)),ad.write(nd)}let od=0;for(let sd=0;sd<td.length;sd++)od+=td[sd].dataCount;if(nd.getLengthInBits()<=od*8)break}Iu=ed}ju(!1,zu())},Bu.createTableTag=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;let nd="";nd+='<table style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: "+td+"px;",nd+='">',nd+="<tbody>";for(let od=0;od<Bu.getModuleCount();od+=1){nd+="<tr>";for(let sd=0;sd<Bu.getModuleCount();sd+=1)nd+='<td style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: 0px;",nd+=" width: "+ed+"px;",nd+=" height: "+ed+"px;",nd+=" background-color: ",nd+=Bu.isDark(od,sd)?"#000000":"#ffffff",nd+=";",nd+='"/>';nd+="</tr>"}return nd+="</tbody>",nd+="</table>",nd},Bu.createSvgTag=function(ed,td,nd,od){let sd={};typeof arguments[0]=="object"&&(sd=arguments[0],ed=sd.cellSize,td=sd.margin,nd=sd.alt,od=sd.title),ed=ed||2,td=typeof td>"u"?ed*4:td,nd=typeof nd=="string"?{text:nd}:nd||{},nd.text=nd.text||null,nd.id=nd.text?nd.id||"qrcode-description":null,od=typeof od=="string"?{text:od}:od||{},od.text=od.text||null,od.id=od.text?od.id||"qrcode-title":null;const ad=Bu.getModuleCount()*ed+td*2;let pd,gd,Sd,_d,yd="",wd;for(wd="l"+ed+",0 0,"+ed+" -"+ed+",0 0,-"+ed+"z ",yd+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',yd+=sd.scalable?"":' width="'+ad+'px" height="'+ad+'px"',yd+=' viewBox="0 0 '+ad+" "+ad+'" ',yd+=' preserveAspectRatio="xMinYMin meet"',yd+=od.text||nd.text?' role="img" aria-labelledby="'+Yu([od.id,nd.id].join(" ").trim())+'"':"",yd+=">",yd+=od.text?'<title id="'+Yu(od.id)+'">'+Yu(od.text)+"</title>":"",yd+=nd.text?'<description id="'+Yu(nd.id)+'">'+Yu(nd.text)+"</description>":"",yd+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',yd+='<path d="',Sd=0;Sd<Bu.getModuleCount();Sd+=1)for(_d=Sd*ed+td,pd=0;pd<Bu.getModuleCount();pd+=1)Bu.isDark(Sd,pd)&&(gd=pd*ed+td,yd+="M"+gd+","+_d+wd);return yd+='" stroke="transparent" fill="black"/>',yd+="</svg>",yd},Bu.createDataURL=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;return createDataURL(nd,nd,function(ad,pd){if(od<=ad&&ad<sd&&od<=pd&&pd<sd){const gd=Math.floor((ad-od)/ed),Sd=Math.floor((pd-od)/ed);return Bu.isDark(Sd,gd)?0:1}else return 1})},Bu.createImgTag=function(ed,td,nd){ed=ed||2,td=typeof td>"u"?ed*4:td;const od=Bu.getModuleCount()*ed+td*2;let sd="";return sd+="<img",sd+=' src="',sd+=Bu.createDataURL(ed,td),sd+='"',sd+=' width="',sd+=od,sd+='"',sd+=' height="',sd+=od,sd+='"',nd&&(sd+=' alt="',sd+=Yu(nd),sd+='"'),sd+="/>",sd};const Yu=function(ed){let td="";for(let nd=0;nd<ed.length;nd+=1){const od=ed.charAt(nd);switch(od){case"<":td+="<";break;case">":td+=">";break;case"&":td+="&";break;case'"':td+=""";break;default:td+=od;break}}return td},Xu=function(ed){ed=typeof ed>"u"?2:ed;const nd=Bu.getModuleCount()*1+ed*2,od=ed,sd=nd-ed;let ad,pd,gd,Sd,_d;const yd={"██":"█","█ ":"▀"," █":"▄"," ":" "},wd={"██":"▀","█ ":"▀"," █":" "," ":" "};let Ad="";for(ad=0;ad<nd;ad+=2){for(gd=Math.floor((ad-od)/1),Sd=Math.floor((ad+1-od)/1),pd=0;pd<nd;pd+=1)_d="█",od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/1))&&(_d=" "),od<=pd&&pd<sd&&od<=ad+1&&ad+1<sd&&Bu.isDark(Sd,Math.floor((pd-od)/1))?_d+=" ":_d+="█",Ad+=ed<1&&ad+1>=sd?wd[_d]:yd[_d];Ad+=`
|
|
3861
|
+
`).find(Ru=>Ru.trim())??"").trim();return $u.length>PREVIEW_LENGTH?`${$u.slice(0,PREVIEW_LENGTH-1)}…`:$u||"(empty)"}function PreviewList({title:Au,rows:lo}){return jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",display:"block",mb:1},children:Au}),lo.length===0?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:"Empty so far."}):lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,py:"2px",alignItems:"baseline",children:[jsxRuntimeExports.jsxs(Text$3,{sx:{color:"fg.muted",flexShrink:0,fontFamily:"mono"},children:[Ru," · ",$u.kind]}),jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$u.text})]},Ru))]})}function useOfferedEditors(){return reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().options)}function useNotebookRows(Au,lo){const[$u,Ru]=reactExports.useState(0);return reactExports.useEffect(()=>{if(!lo)return;let Iu=!1;const Pu=()=>Ru(Du=>Du+1),Ou=[],Mu=jupyterReact!==null;return loadJupyterReact().then(({notebookStore:Du})=>{if(!Iu)try{const Lu=Du.subscribe?.(Pu);Lu&&Ou.push(Lu);const Bu=Du.getState()?.notebooks?.get(Au)?.model;if(Bu){const ju=[Bu.contentChanged,Bu.cells?.changed];for(const Fu of ju)Fu?.connect&&(Fu.connect(Pu),Ou.push(()=>Fu.disconnect(Pu)))}Mu||Pu()}catch{}}),()=>{Iu=!0;for(const Du of Ou)try{Du()}catch{}}},[lo,Au,$u]),reactExports.useMemo(()=>{if(!lo)return null;const Iu=safeModel(Au);if(!Iu)return null;const Pu=[],Ou=Iu.cells;for(let Mu=0;Mu<Ou.length;Mu+=1){const Du=Ou.get(Mu);Pu.push({kind:Du.type,text:stripped(Du.sharedModel.getSource())})}return Pu},[lo,Au,$u])}function safeModel(Au){try{return jupyterReact?.notebookStore.getState()?.notebooks?.get(Au)?.model??null}catch{return null}}function useDocumentRows(Au,lo){const[$u,Ru]=reactExports.useState(null);return reactExports.useEffect(()=>{if(!lo){Ru(null);return}let Iu=!1,Pu,Ou=!1;return __vitePreload(()=>import("./chunks/PrismCss-sPywsCAF.js").then(Mu=>Mu.a),[],import.meta.url).then(()=>__vitePreload(()=>import("./chunks/index-CLdL3h_Z.js"),[],import.meta.url)).then(({lexicalStore:Mu})=>{if(Iu)return;const Du=()=>{Ou||(Ou=!0,Mu.getState().readAllBlocks(Au,"brief").then(Lu=>{Ou=!1,!(Iu||!Array.isArray(Lu))&&Ru(Lu.map(Bu=>({kind:Bu.block_type??"block",text:stripped(Bu.preview??"")})))}).catch(()=>{Ou=!1,Iu||Ru(null)}))};Du(),Pu=Mu.subscribe(Du)}).catch(()=>{Iu||Ru(null)}),()=>{Iu=!0,Pu?.()}},[lo,Au]),$u}function useEditorPreviews(Au){const lo=useOfferedEditors(),$u=useNotebookRows(Au,lo.includes("notebook")),Ru=useDocumentRows(Au,lo.includes("document"));return reactExports.useMemo(()=>{const Iu={};return $u&&(Iu.notebook={badge:String($u.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Cells",rows:$u})}),Ru&&(Iu.document={badge:String(Ru.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Blocks",rows:Ru})}),Iu},[$u,Ru])}const SHELL_PLUGIN_NAME="@datalayer/loop-plugin-shell";function describeEditor(Au,lo){const $u=Au,Ru=lo?.workspace,Iu=Ru?canOpenView($u,Ru):!0;return{id:$u.surfaceId,title:$u.title,icon:$u.icon,order:$u.order,disabled:!Iu,disabledReason:Iu?void 0:Ru&&$u.unavailableReason?.(Ru)||"Not available right now"}}function EditorSelectorComponent(Au){const lo=Au.workspace,$u=useEditorPreviews(lo?.surfaceId??""),Ru=(Iu,Pu)=>{const Ou=describeEditor(Iu,Pu),Mu=$u[Ou.id];return Mu?{...Ou,badge:Mu.badge,details:Mu.details}:Ou};return jsxRuntimeExports.jsx(ViewSelector,{point:LoopEditorView,describe:Ru,context:Au,noneLabel:"Chat",ariaLabel:"Editor"})}const ShellPlugin={name:SHELL_PLUGIN_NAME,displayName:"Loop shell",description:"The Loop workspace’s extension points, and the editor choice.",octicon:"columns",emoji:"📑",config:{defaultEditor:NONE_EDITOR,showSelector:!0},dependencies:[configurePlugin(ShellPlugin$1,{point:LoopEditorView,describe:describeEditor,showSelector:!1,announce:Au=>requestSurface(Au),commandId:"loop.shell.cycleEditor",commandName:"Switch the editor",commandDescription:"Cycle through the editors beside the conversation, and none",keybinding:""})],contributionPoints:[LoopViewType,LoopEditorView],contributes:[contribution(LoopCommand,{name:"editor",aliases:["editors"],description:"Switch the editor beside the conversation",group:"Open",keybinding:"Mod+Alt+E",args:[{name:"editor",description:"Which editor: none, or a surface id. Omit to cycle.",required:!1,choices:()=>[NONE_EDITOR,...getEditorChoice().options]}],run:async({argv:Au})=>{const lo=Au.trim(),$u=lo===""?nextEditor():lo,Ru=[NONE_EDITOR,...getEditorChoice().options];if(!Ru.includes($u))throw new Error(`No editor called '${$u}'. There is: ${Ru.join(", ")}.`);if(!chooseEditor($u))throw new Error("No chat is on screen to host the editor.")}},{id:"editor"})],build:({config:Au})=>(seedEditorChoice(Au.defaultEditor||NONE_EDITOR),{components:Au.showSelector?[{id:"editor-selector",slot:LoopSlots.header,Component:EditorSelectorComponent}]:[]})};function NewChatAction({workspace:Au}){return Au?jsxRuntimeExports.jsx(IconButton,{icon:PlusIcon,"aria-label":"New conversation",title:"New conversation",variant:"invisible",size:"small",onClick:()=>{Au.submit("/new")}}):null}const PROMPT_PLUGIN_NAME="@datalayer/loop-plugin-prompt",PromptPlugin={name:PROMPT_PLUGIN_NAME,displayName:"Prompt",description:"Prompt commands: focus the composer, start over, and the +.",octicon:"paper-airplane",emoji:"🪶",contributes:[contribution(LoopCommand,{name:"prompt",description:"Focus the prompt",group:"Session",keybinding:"Mod+Alt+P",run:async()=>{if(!focusPrompt())throw new Error("No prompt is on screen to focus.")}},{id:"prompt"}),contribution(LoopCommand,{name:"new",aliases:["reset"],description:"Start the conversation over",group:"Session",keybinding:"Mod+Alt+R",run:async({workspace:Au})=>{const lo=Au.viewControls.newChat;if(!lo)throw new Error("No conversation is on screen to start over.");lo()}},{id:"new"})],build:()=>({components:[{id:"new-chat",slot:LoopSlots.promptAction,Component:NewChatAction}]})};function AgentspecPicker({workspace:Au}){const[lo,$u]=reactExports.useState([]),[Ru,Iu]=reactExports.useState(!1),[Pu,Ou]=reactExports.useState(Au.agentId),Mu=Au.sandbox.target,Du=Au.sandbox.state;reactExports.useEffect(()=>{let Fu=!1;return fetch(`${Au.serverUrl}/api/v1/agents`).then(zu=>zu.ok?zu.json():{agents:[]}).then(zu=>{Fu||$u(zu.agents??[])}).catch(()=>{}),()=>{Fu=!0}},[Au.serverUrl,Mu,Du]),reactExports.useEffect(()=>{Ou(Au.agentId)},[Au.agentId]);const Lu=reactExports.useCallback(async Fu=>{Iu(!0);try{(await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:Fu})})).ok&&(Ou(Fu),Au.setAgentId(Fu))}finally{Iu(!1)}},[Au.agentId,Au.conversationId,Au.serverUrl,Au.setAgentId]),Bu=lo.find(Fu=>Fu.id===Pu),ju=Bu?.name||getAgentspecs(Pu)?.name||Pu||"Agent";return lo.length===0?null:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:1,children:[Ru?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):null,jsxRuntimeExports.jsxs(ActionMenu,{children:[jsxRuntimeExports.jsxs(ActionMenu.Button,{variant:"invisible",size:"small",children:[Bu?.emoji?`${Bu.emoji} `:"",ju]}),jsxRuntimeExports.jsx(ActionMenu.Overlay,{width:"medium",children:jsxRuntimeExports.jsx(ActionList,{selectionVariant:"single",children:lo.map(Fu=>jsxRuntimeExports.jsxs(ActionList.Item,{selected:Fu.id===Pu,onSelect:()=>{Lu(Fu.id)},children:[Fu.emoji?`${Fu.emoji} `:"",Fu.name||Fu.id,Fu.description?jsxRuntimeExports.jsx(ActionList.Description,{variant:"block",children:Fu.description}):null]},Fu.id))})})]})]})}const AGENTSPECS_PLUGIN_NAME="@datalayer/loop-plugin-agentspecs",AgentspecsPlugin={name:AGENTSPECS_PLUGIN_NAME,displayName:"Agentspecs",description:"Pick the agentspec this session runs.",octicon:"people",emoji:"🤖",build(){return{components:[{slot:LoopSlots.header,id:"agent-picker",Component:AgentspecPicker}]}},contributes:[contribution(LoopCommand,{name:"agents",aliases:["agent"],description:"Switch the agent this session is using",group:"Agents",keybinding:"Mod+Alt+A",args:[{name:"agent-id",description:"Agent to switch to"}],run:async({workspace:Au,argv:lo})=>{const $u=lo.trim();if(!$u)return{content:"Pick an agent from the header, or /agents <id>."};const Ru=await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:$u})});if(!Ru.ok)return{content:`Unknown agent: ${$u}`};const Iu=await Ru.json();return{content:`Now using ${Iu.name??Iu.agent_id}.`}}},{id:"agents"})]},CHAT_HEADER_PLUGIN_NAME="@datalayer/loop-plugin-chat-header",LazyHeaderView=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/HeaderView-D8h-aEea.js"),[],import.meta.url));function HeaderView(Au){return jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(LazyHeaderView,{...Au})})}const ChatHeaderPlugin={name:CHAT_HEADER_PLUGIN_NAME,displayName:"Chat Header",description:"The conversation’s title bar: agent, kernel, actions.",octicon:"rows",emoji:"🏷️",contributes:[contribution(LoopChatHeader,{id:"chat-header",Component:HeaderView},{id:"chat-header"})]};function readA2uiToolResult(Au,lo){if(!Au)return null;let $u=Au;if(typeof Au=="string")try{$u=JSON.parse(Au)}catch{return null}if(typeof $u!="object"||$u===null||!Array.isArray($u.messages))return null;const Ru=$u,Iu=(Ru.messages??[]).map(Pu=>{const Ou=Pu;return Ou.createSurface&&Ou.createSurface.catalogId!==lo?{...Ou,createSurface:{...Ou.createSurface,catalogId:lo}}:Pu});return{...Ru,messages:Iu}}function isEmptyA2uiValue(Au){return Au==null?!0:typeof Au=="string"?Au.trim()==="":Array.isArray(Au)?Au.length===0:typeof Au=="boolean"?Au===!1:!1}const EMAIL_PATTERN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function validateA2uiField(Au,lo){if(isEmptyA2uiValue(lo))return Au.required?`${Au.label} is required.`:null;if(Au.format==="email"&&typeof lo=="string"&&!EMAIL_PATTERN.test(lo.trim()))return`${Au.label} must be a valid email address.`;if(Au.pattern&&typeof lo=="string"){let $u;try{$u=new RegExp(Au.pattern).test(lo.trim())}catch{$u=!0}if(!$u)return`${Au.label} is not in the expected format.`}if(Au.minLength!==void 0&&typeof lo=="string"&&lo.trim().length<Au.minLength)return`${Au.label} must be at least ${Au.minLength} characters.`;if(Au.type==="slider"&&typeof lo=="number"){if(Au.min!==void 0&&lo<Au.min)return`${Au.label} must be at least ${Au.min}.`;if(Au.max!==void 0&&lo>Au.max)return`${Au.label} must be at most ${Au.max}.`}return null}function validateA2uiSubmission(Au,lo){return Au.map($u=>validateA2uiField($u,lo[$u.id])).filter($u=>$u!==null)}const ANSWER_DISPLAY_TYPE="application/vnd.datalayer.loop.answer+json";function answerSurface(Au,lo){return Au.type!==ANSWER_DISPLAY_TYPE?null:readA2uiToolResult(Au.data?.surface,lo)}function answerPress(Au,lo){const $u=lo.name.trim(),Ru=(Au.actions??[]).find(Iu=>Iu.name===$u);return Ru?{message:$u,forwardedProps:{loop:{action:{name:$u,display_id:Au.id,token:Ru.token,payload:{...lo.context}}}}}:{refused:`“${$u||"This button"}” was not offered here.`}}function AnswerShowsView({display:Au,send:lo}){const $u=reactExports.useMemo(()=>answerSurface(Au,SURFACE_CATALOG_ID),[Au]),Ru=useOwnCatalog(),[Iu,Pu]=reactExports.useState(null);if(!$u?.messages||$u.messages.length===0)return jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:Au.text});const Ou=Mu=>{const Du=answerPress(Au,Mu);if("refused"in Du){Pu(Du.refused);return}Pu(lo(Du.message,Du.forwardedProps)?null:"The chat is not ready to take it yet.")};return jsxRuntimeExports.jsx(InlineSurface,{messages:$u.messages,onAction:Ou,validationError:Iu,catalog:Ru},JSON.stringify(Au))}function SurfaceToolResult({context:Au,send:lo,onRendered:$u,onSubmitted:Ru}){const Iu=reactExports.useMemo(()=>Au.status==="complete"?readA2uiToolResult(Au.result,SURFACE_CATALOG_ID):null,[Au.status,Au.result]),Pu=Iu?.title??"the form",[Ou,Mu]=reactExports.useState(null),Du=useOwnCatalog();reactExports.useEffect(()=>{Iu?.messages&&Iu.messages.length>0&&$u?.({toolCallId:Au.toolCallId,surfaceId:Iu.surfaceId,title:Pu,messages:Iu.messages,result:Iu})},[Iu,Au.toolCallId]);const Lu=reactExports.useCallback(Bu=>{if(Bu.name!=="submit_a2ui_form")return;const ju=Bu.context??{},Fu=validateA2uiSubmission(Iu?.fieldRules??[],ju);if(Fu.length>0){Mu(Fu.join(" "));return}Mu(null),Ru?.({surfaceId:Bu.surfaceId,title:Pu,values:ju}),lo(encodeFormSubmission({title:Pu,surfaceId:Bu.surfaceId,values:ju}))||Mu("The chat is not ready to take the submission yet.")},[Iu,Pu,lo,Ru]);return!Iu?.messages||Iu.messages.length===0?jsxRuntimeExports.jsxs(Box,{border:"1px solid",borderColor:"border.default",borderRadius:2,px:3,py:2,bg:"canvas.default",display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,color:"fg.muted"},children:"Rendering A2UI surface..."})]}):jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"bold"},children:Pu}),jsxRuntimeExports.jsx(InlineSurface,{messages:Iu.messages,onAction:Lu,validationError:Ou,catalog:Du})]})}const A2UI_SURFACE_PLUGIN_NAME="@datalayer/loop-plugin-a2ui-surface",A2UI_SURFACE_RENDERER="a2ui-surface",A2UI_SURFACE_TYPE="application/vnd.datalayer.a2ui.surface+json";function surfaceToolNames(){const Au=new Set;for(const lo of Object.values(AGENTSPECS))for(const $u of lo.frontendRenderTools??[])$u.renderer===A2UI_SURFACE_RENDERER&&Au.add($u.tool);return Au}let counter=0;function createA2uiSurfacePlugin(Au={}){const lo=`a2ui-surface-${counter+=1}`;let $u;const Ru=(Du,Lu)=>$u?!$u(Du,Lu):!1;function Iu({workspace:Du}){const Lu=Du?.viewControls.send;return reactExports.useEffect(()=>($u=Lu,()=>{$u===Lu&&($u=void 0)}),[Lu]),null}function Pu({context:Du}){return Du?Du.status==="error"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Du.defaultUI}):jsxRuntimeExports.jsx(SurfaceToolResult,{context:Du,send:Ru,onRendered:Au.onRendered,onSubmitted:Au.onSubmitted},Du.toolCallId):null}function Ou({display:Du}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Du,send:Ru})}return{name:counter===1?A2UI_SURFACE_PLUGIN_NAME:`${A2UI_SURFACE_PLUGIN_NAME}-${lo}`,displayName:"A2UI surfaces",description:"Generated surfaces drawn in the transcript, and submitted back to the agent.",octicon:"browser",emoji:"🪟",contributes:[contribution(Renderers,defineRenderer({type:A2UI_SURFACE_TYPE,component:Pu,rank:Au.onRendered||Au.onSubmitted?1:0}),{id:lo}),contribution(Renderers,defineRenderer({type:ANSWER_DISPLAY_TYPE,component:Ou}),{id:`${lo}:answer`}),...[...surfaceToolNames()].map(Du=>contribution(ToolBindings,{tool:Du,type:A2UI_SURFACE_TYPE},{id:`${lo}:${Du}`}))],build(){return{components:[{slot:LoopSlots.chatHeader,id:lo,Component:Iu}]}}}}const A2uiSurfacePlugin=createA2uiSurfacePlugin(),qrcode=function(Au,lo){let Iu=Au;const Pu=QRErrorCorrectionLevel[lo];let Ou=null,Mu=0,Du=null;const Lu=[],Bu={},ju=function(ed,td){Mu=Iu*4+17,Ou=(function(nd){const od=new Array(nd);for(let sd=0;sd<nd;sd+=1){od[sd]=new Array(nd);for(let ad=0;ad<nd;ad+=1)od[sd][ad]=null}return od})(Mu),Fu(0,0),Fu(Mu-7,0),Fu(0,Mu-7),Hu(),Uu(),Gu(ed,td),Iu>=7&&Vu(ed),Du==null&&(Du=Ju(Iu,Pu,Lu)),Wu(Du,td)},Fu=function(ed,td){for(let nd=-1;nd<=7;nd+=1)if(!(ed+nd<=-1||Mu<=ed+nd))for(let od=-1;od<=7;od+=1)td+od<=-1||Mu<=td+od||(0<=nd&&nd<=6&&(od==0||od==6)||0<=od&&od<=6&&(nd==0||nd==6)||2<=nd&&nd<=4&&2<=od&&od<=4?Ou[ed+nd][td+od]=!0:Ou[ed+nd][td+od]=!1)},zu=function(){let ed=0,td=0;for(let nd=0;nd<8;nd+=1){ju(!0,nd);const od=QRUtil.getLostPoint(Bu);(nd==0||ed>od)&&(ed=od,td=nd)}return td},Uu=function(){for(let ed=8;ed<Mu-8;ed+=1)Ou[ed][6]==null&&(Ou[ed][6]=ed%2==0);for(let ed=8;ed<Mu-8;ed+=1)Ou[6][ed]==null&&(Ou[6][ed]=ed%2==0)},Hu=function(){const ed=QRUtil.getPatternPosition(Iu);for(let td=0;td<ed.length;td+=1)for(let nd=0;nd<ed.length;nd+=1){const od=ed[td],sd=ed[nd];if(Ou[od][sd]==null)for(let ad=-2;ad<=2;ad+=1)for(let pd=-2;pd<=2;pd+=1)ad==-2||ad==2||pd==-2||pd==2||ad==0&&pd==0?Ou[od+ad][sd+pd]=!0:Ou[od+ad][sd+pd]=!1}},Vu=function(ed){const td=QRUtil.getBCHTypeNumber(Iu);for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[Math.floor(nd/3)][nd%3+Mu-8-3]=od}for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[nd%3+Mu-8-3][Math.floor(nd/3)]=od}},Gu=function(ed,td){const nd=Pu<<3|td,od=QRUtil.getBCHTypeInfo(nd);for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<6?Ou[sd][8]=ad:sd<8?Ou[sd+1][8]=ad:Ou[Mu-15+sd][8]=ad}for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<8?Ou[8][Mu-sd-1]=ad:sd<9?Ou[8][15-sd-1+1]=ad:Ou[8][15-sd-1]=ad}Ou[Mu-8][8]=!ed},Wu=function(ed,td){let nd=-1,od=Mu-1,sd=7,ad=0;const pd=QRUtil.getMaskFunction(td);for(let gd=Mu-1;gd>0;gd-=2)for(gd==6&&(gd-=1);;){for(let Sd=0;Sd<2;Sd+=1)if(Ou[od][gd-Sd]==null){let _d=!1;ad<ed.length&&(_d=(ed[ad]>>>sd&1)==1),pd(od,gd-Sd)&&(_d=!_d),Ou[od][gd-Sd]=_d,sd-=1,sd==-1&&(ad+=1,sd=7)}if(od+=nd,od<0||Mu<=od){od-=nd,nd=-nd;break}}},Ku=function(ed,td){let nd=0,od=0,sd=0;const ad=new Array(td.length),pd=new Array(td.length);for(let yd=0;yd<td.length;yd+=1){const wd=td[yd].dataCount,Ad=td[yd].totalCount-wd;od=Math.max(od,wd),sd=Math.max(sd,Ad),ad[yd]=new Array(wd);for(let ld=0;ld<ad[yd].length;ld+=1)ad[yd][ld]=255&ed.getBuffer()[ld+nd];nd+=wd;const md=QRUtil.getErrorCorrectPolynomial(Ad),bd=qrPolynomial(ad[yd],md.getLength()-1).mod(md);pd[yd]=new Array(md.getLength()-1);for(let ld=0;ld<pd[yd].length;ld+=1){const ud=ld+bd.getLength()-pd[yd].length;pd[yd][ld]=ud>=0?bd.getAt(ud):0}}let gd=0;for(let yd=0;yd<td.length;yd+=1)gd+=td[yd].totalCount;const Sd=new Array(gd);let _d=0;for(let yd=0;yd<od;yd+=1)for(let wd=0;wd<td.length;wd+=1)yd<ad[wd].length&&(Sd[_d]=ad[wd][yd],_d+=1);for(let yd=0;yd<sd;yd+=1)for(let wd=0;wd<td.length;wd+=1)yd<pd[wd].length&&(Sd[_d]=pd[wd][yd],_d+=1);return Sd},Ju=function(ed,td,nd){const od=QRRSBlock.getRSBlocks(ed,td),sd=qrBitBuffer();for(let pd=0;pd<nd.length;pd+=1){const gd=nd[pd];sd.put(gd.getMode(),4),sd.put(gd.getLength(),QRUtil.getLengthInBits(gd.getMode(),ed)),gd.write(sd)}let ad=0;for(let pd=0;pd<od.length;pd+=1)ad+=od[pd].dataCount;if(sd.getLengthInBits()>ad*8)throw"code length overflow. ("+sd.getLengthInBits()+">"+ad*8+")";for(sd.getLengthInBits()+4<=ad*8&&sd.put(0,4);sd.getLengthInBits()%8!=0;)sd.putBit(!1);for(;!(sd.getLengthInBits()>=ad*8||(sd.put(236,8),sd.getLengthInBits()>=ad*8));)sd.put(17,8);return Ku(sd,od)};Bu.addData=function(ed,td){td=td||"Byte";let nd=null;switch(td){case"Numeric":nd=qrNumber(ed);break;case"Alphanumeric":nd=qrAlphaNum(ed);break;case"Byte":nd=qr8BitByte(ed);break;case"Kanji":nd=qrKanji(ed);break;default:throw"mode:"+td}Lu.push(nd),Du=null},Bu.isDark=function(ed,td){if(ed<0||Mu<=ed||td<0||Mu<=td)throw ed+","+td;return Ou[ed][td]},Bu.getModuleCount=function(){return Mu},Bu.make=function(){if(Iu<1){let ed=1;for(;ed<40;ed++){const td=QRRSBlock.getRSBlocks(ed,Pu),nd=qrBitBuffer();for(let sd=0;sd<Lu.length;sd++){const ad=Lu[sd];nd.put(ad.getMode(),4),nd.put(ad.getLength(),QRUtil.getLengthInBits(ad.getMode(),ed)),ad.write(nd)}let od=0;for(let sd=0;sd<td.length;sd++)od+=td[sd].dataCount;if(nd.getLengthInBits()<=od*8)break}Iu=ed}ju(!1,zu())},Bu.createTableTag=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;let nd="";nd+='<table style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: "+td+"px;",nd+='">',nd+="<tbody>";for(let od=0;od<Bu.getModuleCount();od+=1){nd+="<tr>";for(let sd=0;sd<Bu.getModuleCount();sd+=1)nd+='<td style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: 0px;",nd+=" width: "+ed+"px;",nd+=" height: "+ed+"px;",nd+=" background-color: ",nd+=Bu.isDark(od,sd)?"#000000":"#ffffff",nd+=";",nd+='"/>';nd+="</tr>"}return nd+="</tbody>",nd+="</table>",nd},Bu.createSvgTag=function(ed,td,nd,od){let sd={};typeof arguments[0]=="object"&&(sd=arguments[0],ed=sd.cellSize,td=sd.margin,nd=sd.alt,od=sd.title),ed=ed||2,td=typeof td>"u"?ed*4:td,nd=typeof nd=="string"?{text:nd}:nd||{},nd.text=nd.text||null,nd.id=nd.text?nd.id||"qrcode-description":null,od=typeof od=="string"?{text:od}:od||{},od.text=od.text||null,od.id=od.text?od.id||"qrcode-title":null;const ad=Bu.getModuleCount()*ed+td*2;let pd,gd,Sd,_d,yd="",wd;for(wd="l"+ed+",0 0,"+ed+" -"+ed+",0 0,-"+ed+"z ",yd+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',yd+=sd.scalable?"":' width="'+ad+'px" height="'+ad+'px"',yd+=' viewBox="0 0 '+ad+" "+ad+'" ',yd+=' preserveAspectRatio="xMinYMin meet"',yd+=od.text||nd.text?' role="img" aria-labelledby="'+Yu([od.id,nd.id].join(" ").trim())+'"':"",yd+=">",yd+=od.text?'<title id="'+Yu(od.id)+'">'+Yu(od.text)+"</title>":"",yd+=nd.text?'<description id="'+Yu(nd.id)+'">'+Yu(nd.text)+"</description>":"",yd+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',yd+='<path d="',Sd=0;Sd<Bu.getModuleCount();Sd+=1)for(_d=Sd*ed+td,pd=0;pd<Bu.getModuleCount();pd+=1)Bu.isDark(Sd,pd)&&(gd=pd*ed+td,yd+="M"+gd+","+_d+wd);return yd+='" stroke="transparent" fill="black"/>',yd+="</svg>",yd},Bu.createDataURL=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;return createDataURL(nd,nd,function(ad,pd){if(od<=ad&&ad<sd&&od<=pd&&pd<sd){const gd=Math.floor((ad-od)/ed),Sd=Math.floor((pd-od)/ed);return Bu.isDark(Sd,gd)?0:1}else return 1})},Bu.createImgTag=function(ed,td,nd){ed=ed||2,td=typeof td>"u"?ed*4:td;const od=Bu.getModuleCount()*ed+td*2;let sd="";return sd+="<img",sd+=' src="',sd+=Bu.createDataURL(ed,td),sd+='"',sd+=' width="',sd+=od,sd+='"',sd+=' height="',sd+=od,sd+='"',nd&&(sd+=' alt="',sd+=Yu(nd),sd+='"'),sd+="/>",sd};const Yu=function(ed){let td="";for(let nd=0;nd<ed.length;nd+=1){const od=ed.charAt(nd);switch(od){case"<":td+="<";break;case">":td+=">";break;case"&":td+="&";break;case'"':td+=""";break;default:td+=od;break}}return td},Xu=function(ed){ed=typeof ed>"u"?2:ed;const nd=Bu.getModuleCount()*1+ed*2,od=ed,sd=nd-ed;let ad,pd,gd,Sd,_d;const yd={"██":"█","█ ":"▀"," █":"▄"," ":" "},wd={"██":"▀","█ ":"▀"," █":" "," ":" "};let Ad="";for(ad=0;ad<nd;ad+=2){for(gd=Math.floor((ad-od)/1),Sd=Math.floor((ad+1-od)/1),pd=0;pd<nd;pd+=1)_d="█",od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/1))&&(_d=" "),od<=pd&&pd<sd&&od<=ad+1&&ad+1<sd&&Bu.isDark(Sd,Math.floor((pd-od)/1))?_d+=" ":_d+="█",Ad+=ed<1&&ad+1>=sd?wd[_d]:yd[_d];Ad+=`
|
|
3862
3862
|
`}return nd%2&&ed>0?Ad.substring(0,Ad.length-nd-1)+Array(nd+1).join("▀"):Ad.substring(0,Ad.length-1)};return Bu.createASCII=function(ed,td){if(ed=ed||1,ed<2)return Xu(td);ed-=1,td=typeof td>"u"?ed*2:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;let ad,pd,gd,Sd;const _d=Array(ed+1).join("██"),yd=Array(ed+1).join(" ");let wd="",Ad="";for(ad=0;ad<nd;ad+=1){for(gd=Math.floor((ad-od)/ed),Ad="",pd=0;pd<nd;pd+=1)Sd=1,od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/ed))&&(Sd=0),Ad+=Sd?_d:yd;for(gd=0;gd<ed;gd+=1)wd+=Ad+`
|
|
3863
3863
|
`}return wd.substring(0,wd.length-1)},Bu.renderTo2dContext=function(ed,td){td=td||2;const nd=Bu.getModuleCount();for(let od=0;od<nd;od++)for(let sd=0;sd<nd;sd++)ed.fillStyle=Bu.isDark(od,sd)?"black":"white",ed.fillRect(sd*td,od*td,td,td)},Bu};qrcode.stringToBytes=function(Au){const lo=[];for(let $u=0;$u<Au.length;$u+=1){const Ru=Au.charCodeAt($u);lo.push(Ru&255)}return lo};qrcode.createStringToBytes=function(Au,lo){const $u=(function(){const Iu=base64DecodeInputStream(Au),Pu=function(){const Du=Iu.read();if(Du==-1)throw"eof";return Du};let Ou=0;const Mu={};for(;;){const Du=Iu.read();if(Du==-1)break;const Lu=Pu(),Bu=Pu(),ju=Pu(),Fu=String.fromCharCode(Du<<8|Lu),zu=Bu<<8|ju;Mu[Fu]=zu,Ou+=1}if(Ou!=lo)throw Ou+" != "+lo;return Mu})(),Ru=63;return function(Iu){const Pu=[];for(let Ou=0;Ou<Iu.length;Ou+=1){const Mu=Iu.charCodeAt(Ou);if(Mu<128)Pu.push(Mu);else{const Du=$u[Iu.charAt(Ou)];typeof Du=="number"?(Du&255)==Du?Pu.push(Du):(Pu.push(Du>>>8),Pu.push(Du&255)):Pu.push(Ru)}}return Pu}};const QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectionLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil=(function(){const Au=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],lo=1335,$u=7973,Ru=21522,Iu={},Pu=function(Ou){let Mu=0;for(;Ou!=0;)Mu+=1,Ou>>>=1;return Mu};return Iu.getBCHTypeInfo=function(Ou){let Mu=Ou<<10;for(;Pu(Mu)-Pu(lo)>=0;)Mu^=lo<<Pu(Mu)-Pu(lo);return(Ou<<10|Mu)^Ru},Iu.getBCHTypeNumber=function(Ou){let Mu=Ou<<12;for(;Pu(Mu)-Pu($u)>=0;)Mu^=$u<<Pu(Mu)-Pu($u);return Ou<<12|Mu},Iu.getPatternPosition=function(Ou){return Au[Ou-1]},Iu.getMaskFunction=function(Ou){switch(Ou){case QRMaskPattern.PATTERN000:return function(Mu,Du){return(Mu+Du)%2==0};case QRMaskPattern.PATTERN001:return function(Mu,Du){return Mu%2==0};case QRMaskPattern.PATTERN010:return function(Mu,Du){return Du%3==0};case QRMaskPattern.PATTERN011:return function(Mu,Du){return(Mu+Du)%3==0};case QRMaskPattern.PATTERN100:return function(Mu,Du){return(Math.floor(Mu/2)+Math.floor(Du/3))%2==0};case QRMaskPattern.PATTERN101:return function(Mu,Du){return Mu*Du%2+Mu*Du%3==0};case QRMaskPattern.PATTERN110:return function(Mu,Du){return(Mu*Du%2+Mu*Du%3)%2==0};case QRMaskPattern.PATTERN111:return function(Mu,Du){return(Mu*Du%3+(Mu+Du)%2)%2==0};default:throw"bad maskPattern:"+Ou}},Iu.getErrorCorrectPolynomial=function(Ou){let Mu=qrPolynomial([1],0);for(let Du=0;Du<Ou;Du+=1)Mu=Mu.multiply(qrPolynomial([1,QRMath.gexp(Du)],0));return Mu},Iu.getLengthInBits=function(Ou,Mu){if(1<=Mu&&Mu<10)switch(Ou){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:return 8;case QRMode.MODE_KANJI:return 8;default:throw"mode:"+Ou}else if(Mu<27)switch(Ou){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw"mode:"+Ou}else if(Mu<41)switch(Ou){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw"mode:"+Ou}else throw"type:"+Mu},Iu.getLostPoint=function(Ou){const Mu=Ou.getModuleCount();let Du=0;for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu;Fu+=1){let zu=0;const Uu=Ou.isDark(ju,Fu);for(let Hu=-1;Hu<=1;Hu+=1)if(!(ju+Hu<0||Mu<=ju+Hu))for(let Vu=-1;Vu<=1;Vu+=1)Fu+Vu<0||Mu<=Fu+Vu||Hu==0&&Vu==0||Uu==Ou.isDark(ju+Hu,Fu+Vu)&&(zu+=1);zu>5&&(Du+=3+zu-5)}for(let ju=0;ju<Mu-1;ju+=1)for(let Fu=0;Fu<Mu-1;Fu+=1){let zu=0;Ou.isDark(ju,Fu)&&(zu+=1),Ou.isDark(ju+1,Fu)&&(zu+=1),Ou.isDark(ju,Fu+1)&&(zu+=1),Ou.isDark(ju+1,Fu+1)&&(zu+=1),(zu==0||zu==4)&&(Du+=3)}for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu-6;Fu+=1)Ou.isDark(ju,Fu)&&!Ou.isDark(ju,Fu+1)&&Ou.isDark(ju,Fu+2)&&Ou.isDark(ju,Fu+3)&&Ou.isDark(ju,Fu+4)&&!Ou.isDark(ju,Fu+5)&&Ou.isDark(ju,Fu+6)&&(Du+=40);for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu-6;Fu+=1)Ou.isDark(Fu,ju)&&!Ou.isDark(Fu+1,ju)&&Ou.isDark(Fu+2,ju)&&Ou.isDark(Fu+3,ju)&&Ou.isDark(Fu+4,ju)&&!Ou.isDark(Fu+5,ju)&&Ou.isDark(Fu+6,ju)&&(Du+=40);let Lu=0;for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu;Fu+=1)Ou.isDark(Fu,ju)&&(Lu+=1);const Bu=Math.abs(100*Lu/Mu/Mu-50)/5;return Du+=Bu*10,Du},Iu})(),QRMath=(function(){const Au=new Array(256),lo=new Array(256);for(let Ru=0;Ru<8;Ru+=1)Au[Ru]=1<<Ru;for(let Ru=8;Ru<256;Ru+=1)Au[Ru]=Au[Ru-4]^Au[Ru-5]^Au[Ru-6]^Au[Ru-8];for(let Ru=0;Ru<255;Ru+=1)lo[Au[Ru]]=Ru;const $u={};return $u.glog=function(Ru){if(Ru<1)throw"glog("+Ru+")";return lo[Ru]},$u.gexp=function(Ru){for(;Ru<0;)Ru+=255;for(;Ru>=256;)Ru-=255;return Au[Ru]},$u})(),qrPolynomial=function(Au,lo){if(typeof Au.length>"u")throw Au.length+"/"+lo;const $u=(function(){let Iu=0;for(;Iu<Au.length&&Au[Iu]==0;)Iu+=1;const Pu=new Array(Au.length-Iu+lo);for(let Ou=0;Ou<Au.length-Iu;Ou+=1)Pu[Ou]=Au[Ou+Iu];return Pu})(),Ru={};return Ru.getAt=function(Iu){return $u[Iu]},Ru.getLength=function(){return $u.length},Ru.multiply=function(Iu){const Pu=new Array(Ru.getLength()+Iu.getLength()-1);for(let Ou=0;Ou<Ru.getLength();Ou+=1)for(let Mu=0;Mu<Iu.getLength();Mu+=1)Pu[Ou+Mu]^=QRMath.gexp(QRMath.glog(Ru.getAt(Ou))+QRMath.glog(Iu.getAt(Mu)));return qrPolynomial(Pu,0)},Ru.mod=function(Iu){if(Ru.getLength()-Iu.getLength()<0)return Ru;const Pu=QRMath.glog(Ru.getAt(0))-QRMath.glog(Iu.getAt(0)),Ou=new Array(Ru.getLength());for(let Mu=0;Mu<Ru.getLength();Mu+=1)Ou[Mu]=Ru.getAt(Mu);for(let Mu=0;Mu<Iu.getLength();Mu+=1)Ou[Mu]^=QRMath.gexp(QRMath.glog(Iu.getAt(Mu))+Pu);return qrPolynomial(Ou,0).mod(Iu)},Ru},QRRSBlock=(function(){const Au=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],lo=function(Iu,Pu){const Ou={};return Ou.totalCount=Iu,Ou.dataCount=Pu,Ou},$u={},Ru=function(Iu,Pu){switch(Pu){case QRErrorCorrectionLevel.L:return Au[(Iu-1)*4+0];case QRErrorCorrectionLevel.M:return Au[(Iu-1)*4+1];case QRErrorCorrectionLevel.Q:return Au[(Iu-1)*4+2];case QRErrorCorrectionLevel.H:return Au[(Iu-1)*4+3];default:return}};return $u.getRSBlocks=function(Iu,Pu){const Ou=Ru(Iu,Pu);if(typeof Ou>"u")throw"bad rs block @ typeNumber:"+Iu+"/errorCorrectionLevel:"+Pu;const Mu=Ou.length/3,Du=[];for(let Lu=0;Lu<Mu;Lu+=1){const Bu=Ou[Lu*3+0],ju=Ou[Lu*3+1],Fu=Ou[Lu*3+2];for(let zu=0;zu<Bu;zu+=1)Du.push(lo(ju,Fu))}return Du},$u})(),qrBitBuffer=function(){const Au=[];let lo=0;const $u={};return $u.getBuffer=function(){return Au},$u.getAt=function(Ru){const Iu=Math.floor(Ru/8);return(Au[Iu]>>>7-Ru%8&1)==1},$u.put=function(Ru,Iu){for(let Pu=0;Pu<Iu;Pu+=1)$u.putBit((Ru>>>Iu-Pu-1&1)==1)},$u.getLengthInBits=function(){return lo},$u.putBit=function(Ru){const Iu=Math.floor(lo/8);Au.length<=Iu&&Au.push(0),Ru&&(Au[Iu]|=128>>>lo%8),lo+=1},$u},qrNumber=function(Au){const lo=QRMode.MODE_NUMBER,$u=Au,Ru={};Ru.getMode=function(){return lo},Ru.getLength=function(Ou){return $u.length},Ru.write=function(Ou){const Mu=$u;let Du=0;for(;Du+2<Mu.length;)Ou.put(Iu(Mu.substring(Du,Du+3)),10),Du+=3;Du<Mu.length&&(Mu.length-Du==1?Ou.put(Iu(Mu.substring(Du,Du+1)),4):Mu.length-Du==2&&Ou.put(Iu(Mu.substring(Du,Du+2)),7))};const Iu=function(Ou){let Mu=0;for(let Du=0;Du<Ou.length;Du+=1)Mu=Mu*10+Pu(Ou.charAt(Du));return Mu},Pu=function(Ou){if("0"<=Ou&&Ou<="9")return Ou.charCodeAt(0)-48;throw"illegal char :"+Ou};return Ru},qrAlphaNum=function(Au){const lo=QRMode.MODE_ALPHA_NUM,$u=Au,Ru={};Ru.getMode=function(){return lo},Ru.getLength=function(Pu){return $u.length},Ru.write=function(Pu){const Ou=$u;let Mu=0;for(;Mu+1<Ou.length;)Pu.put(Iu(Ou.charAt(Mu))*45+Iu(Ou.charAt(Mu+1)),11),Mu+=2;Mu<Ou.length&&Pu.put(Iu(Ou.charAt(Mu)),6)};const Iu=function(Pu){if("0"<=Pu&&Pu<="9")return Pu.charCodeAt(0)-48;if("A"<=Pu&&Pu<="Z")return Pu.charCodeAt(0)-65+10;switch(Pu){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+Pu}};return Ru},qr8BitByte=function(Au){const lo=QRMode.MODE_8BIT_BYTE,$u=qrcode.stringToBytes(Au),Ru={};return Ru.getMode=function(){return lo},Ru.getLength=function(Iu){return $u.length},Ru.write=function(Iu){for(let Pu=0;Pu<$u.length;Pu+=1)Iu.put($u[Pu],8)},Ru},qrKanji=function(Au){const lo=QRMode.MODE_KANJI,$u=qrcode.stringToBytes;(function(Pu,Ou){const Mu=$u(Pu);if(Mu.length!=2||(Mu[0]<<8|Mu[1])!=Ou)throw"sjis not supported."})("友",38726);const Ru=$u(Au),Iu={};return Iu.getMode=function(){return lo},Iu.getLength=function(Pu){return~~(Ru.length/2)},Iu.write=function(Pu){const Ou=Ru;let Mu=0;for(;Mu+1<Ou.length;){let Du=(255&Ou[Mu])<<8|255&Ou[Mu+1];if(33088<=Du&&Du<=40956)Du-=33088;else if(57408<=Du&&Du<=60351)Du-=49472;else throw"illegal char at "+(Mu+1)+"/"+Du;Du=(Du>>>8&255)*192+(Du&255),Pu.put(Du,13),Mu+=2}if(Mu<Ou.length)throw"illegal char at "+(Mu+1)},Iu},byteArrayOutputStream=function(){const Au=[],lo={};return lo.writeByte=function($u){Au.push($u&255)},lo.writeShort=function($u){lo.writeByte($u),lo.writeByte($u>>>8)},lo.writeBytes=function($u,Ru,Iu){Ru=Ru||0,Iu=Iu||$u.length;for(let Pu=0;Pu<Iu;Pu+=1)lo.writeByte($u[Pu+Ru])},lo.writeString=function($u){for(let Ru=0;Ru<$u.length;Ru+=1)lo.writeByte($u.charCodeAt(Ru))},lo.toByteArray=function(){return Au},lo.toString=function(){let $u="";$u+="[";for(let Ru=0;Ru<Au.length;Ru+=1)Ru>0&&($u+=","),$u+=Au[Ru];return $u+="]",$u},lo},base64EncodeOutputStream=function(){let Au=0,lo=0,$u=0,Ru="";const Iu={},Pu=function(Mu){Ru+=String.fromCharCode(Ou(Mu&63))},Ou=function(Mu){if(Mu<0)throw"n:"+Mu;if(Mu<26)return 65+Mu;if(Mu<52)return 97+(Mu-26);if(Mu<62)return 48+(Mu-52);if(Mu==62)return 43;if(Mu==63)return 47;throw"n:"+Mu};return Iu.writeByte=function(Mu){for(Au=Au<<8|Mu&255,lo+=8,$u+=1;lo>=6;)Pu(Au>>>lo-6),lo-=6},Iu.flush=function(){if(lo>0&&(Pu(Au<<6-lo),Au=0,lo=0),$u%3!=0){const Mu=3-$u%3;for(let Du=0;Du<Mu;Du+=1)Ru+="="}},Iu.toString=function(){return Ru},Iu},base64DecodeInputStream=function(Au){const lo=Au;let $u=0,Ru=0,Iu=0;const Pu={};Pu.read=function(){for(;Iu<8;){if($u>=lo.length){if(Iu==0)return-1;throw"unexpected end of file./"+Iu}const Du=lo.charAt($u);if($u+=1,Du=="=")return Iu=0,-1;if(Du.match(/^\s$/))continue;Ru=Ru<<6|Ou(Du.charCodeAt(0)),Iu+=6}const Mu=Ru>>>Iu-8&255;return Iu-=8,Mu};const Ou=function(Mu){if(65<=Mu&&Mu<=90)return Mu-65;if(97<=Mu&&Mu<=122)return Mu-97+26;if(48<=Mu&&Mu<=57)return Mu-48+52;if(Mu==43)return 62;if(Mu==47)return 63;throw"c:"+Mu};return Pu},gifImage=function(Au,lo){const $u=Au,Ru=lo,Iu=new Array(Au*lo),Pu={};Pu.setPixel=function(Lu,Bu,ju){Iu[Bu*$u+Lu]=ju},Pu.write=function(Lu){Lu.writeString("GIF87a"),Lu.writeShort($u),Lu.writeShort(Ru),Lu.writeByte(128),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(255),Lu.writeByte(255),Lu.writeByte(255),Lu.writeString(","),Lu.writeShort(0),Lu.writeShort(0),Lu.writeShort($u),Lu.writeShort(Ru),Lu.writeByte(0);const Bu=2,ju=Mu(Bu);Lu.writeByte(Bu);let Fu=0;for(;ju.length-Fu>255;)Lu.writeByte(255),Lu.writeBytes(ju,Fu,255),Fu+=255;Lu.writeByte(ju.length-Fu),Lu.writeBytes(ju,Fu,ju.length-Fu),Lu.writeByte(0),Lu.writeString(";")};const Ou=function(Lu){const Bu=Lu;let ju=0,Fu=0;const zu={};return zu.write=function(Uu,Hu){if(Uu>>>Hu)throw"length over";for(;ju+Hu>=8;)Bu.writeByte(255&(Uu<<ju|Fu)),Hu-=8-ju,Uu>>>=8-ju,Fu=0,ju=0;Fu=Uu<<ju|Fu,ju=ju+Hu},zu.flush=function(){ju>0&&Bu.writeByte(Fu)},zu},Mu=function(Lu){const Bu=1<<Lu,ju=(1<<Lu)+1;let Fu=Lu+1;const zu=Du();for(let Wu=0;Wu<Bu;Wu+=1)zu.add(String.fromCharCode(Wu));zu.add(String.fromCharCode(Bu)),zu.add(String.fromCharCode(ju));const Uu=byteArrayOutputStream(),Hu=Ou(Uu);Hu.write(Bu,Fu);let Vu=0,Gu=String.fromCharCode(Iu[Vu]);for(Vu+=1;Vu<Iu.length;){const Wu=String.fromCharCode(Iu[Vu]);Vu+=1,zu.contains(Gu+Wu)?Gu=Gu+Wu:(Hu.write(zu.indexOf(Gu),Fu),zu.size()<4095&&(zu.size()==1<<Fu&&(Fu+=1),zu.add(Gu+Wu)),Gu=Wu)}return Hu.write(zu.indexOf(Gu),Fu),Hu.write(ju,Fu),Hu.flush(),Uu.toByteArray()},Du=function(){const Lu={};let Bu=0;const ju={};return ju.add=function(Fu){if(ju.contains(Fu))throw"dup key:"+Fu;Lu[Fu]=Bu,Bu+=1},ju.size=function(){return Bu},ju.indexOf=function(Fu){return Lu[Fu]},ju.contains=function(Fu){return typeof Lu[Fu]<"u"},ju};return Pu},createDataURL=function(Au,lo,$u){const Ru=gifImage(Au,lo);for(let Mu=0;Mu<lo;Mu+=1)for(let Du=0;Du<Au;Du+=1)Ru.setPixel(Du,Mu,$u(Du,Mu));const Iu=byteArrayOutputStream();Ru.write(Iu);const Pu=base64EncodeOutputStream(),Ou=Iu.toByteArray();for(let Mu=0;Mu<Ou.length;Mu+=1)Pu.writeByte(Ou[Mu]);return Pu.flush(),"data:image/gif;base64,"+Pu};qrcode.stringToBytes;function _extends(){return _extends=Object.assign?Object.assign.bind():function(Au){for(var lo=1;lo<arguments.length;lo++){var $u=arguments[lo];for(var Ru in $u)({}).hasOwnProperty.call($u,Ru)&&(Au[Ru]=$u[Ru])}return Au},_extends.apply(null,arguments)}function _objectWithoutProperties(Au,lo){if(Au==null)return{};var $u,Ru,Iu=_objectWithoutPropertiesLoose(Au,lo);if(Object.getOwnPropertySymbols){var Pu=Object.getOwnPropertySymbols(Au);for(Ru=0;Ru<Pu.length;Ru++)$u=Pu[Ru],lo.indexOf($u)===-1&&{}.propertyIsEnumerable.call(Au,$u)&&(Iu[$u]=Au[$u])}return Iu}function _objectWithoutPropertiesLoose(Au,lo){if(Au==null)return{};var $u={};for(var Ru in Au)if({}.hasOwnProperty.call(Au,Ru)){if(lo.indexOf(Ru)!==-1)continue;$u[Ru]=Au[Ru]}return $u}var _excluded$1=["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"],propTypes$1={bgColor:s$5.oneOfType([s$5.object,s$5.string]).isRequired,bgD:s$5.string.isRequired,fgColor:s$5.oneOfType([s$5.object,s$5.string]).isRequired,fgD:s$5.string.isRequired,size:s$5.number.isRequired,title:s$5.string,viewBoxSize:s$5.number.isRequired,xmlns:s$5.string},QRCodeSvg=reactExports.forwardRef(function(Au,lo){var $u=Au.bgColor,Ru=Au.bgD,Iu=Au.fgD,Pu=Au.fgColor,Ou=Au.size,Mu=Au.title,Du=Au.viewBoxSize,Lu=Au.xmlns,Bu=Lu===void 0?"http://www.w3.org/2000/svg":Lu,ju=_objectWithoutProperties(Au,_excluded$1);return vM.createElement("svg",_extends({},ju,{height:Ou,ref:lo,viewBox:"0 0 ".concat(Du," ").concat(Du),width:Ou,xmlns:Bu}),Mu?vM.createElement("title",null,Mu):null,vM.createElement("path",{d:Ru,fill:$u}),vM.createElement("path",{d:Iu,fill:Pu}))});QRCodeSvg.displayName="QRCodeSvg";QRCodeSvg.propTypes=propTypes$1;var _excluded=["bgColor","fgColor","level","size","value"];qrcode.stringToBytes=function(Au){return Array.from(new TextEncoder().encode(Au))};var propTypes={bgColor:s$5.oneOfType([s$5.object,s$5.string]),fgColor:s$5.oneOfType([s$5.object,s$5.string]),level:s$5.string,size:s$5.number,value:s$5.string.isRequired},QRCode=reactExports.forwardRef(function(Au,lo){var $u=Au.bgColor,Ru=$u===void 0?"#FFFFFF":$u,Iu=Au.fgColor,Pu=Iu===void 0?"#000000":Iu,Ou=Au.level,Mu=Ou===void 0?"L":Ou,Du=Au.size,Lu=Du===void 0?256:Du,Bu=Au.value,ju=_objectWithoutProperties(Au,_excluded),Fu=qrcode(0,Mu);Fu.addData(Bu),Fu.make();var zu=Fu.getModuleCount(),Uu=Array.from({length:zu},function(Hu,Vu){return Array.from({length:zu},function(Gu,Wu){return Fu.isDark(Vu,Wu)})});return vM.createElement(QRCodeSvg,_extends({},ju,{bgColor:Ru,bgD:Uu.map(function(Hu,Vu){return Hu.map(function(Gu,Wu){return Gu?"":"M ".concat(Wu," ").concat(Vu," l 1 0 0 1 -1 0 Z")}).join(" ")}).join(" "),fgColor:Pu,fgD:Uu.map(function(Hu,Vu){return Hu.map(function(Gu,Wu){return Gu?"M ".concat(Wu," ").concat(Vu," l 1 0 0 1 -1 0 Z"):""}).join(" ")}).join(" "),ref:lo,size:Lu,viewBoxSize:zu}))});QRCode.displayName="QRCode";QRCode.propTypes=propTypes;function PapSignInCard({context:Au,send:lo}){const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(!1),[Ou,Mu]=reactExports.useState(null),Du=Au.status==="complete"?readPapSignIn(Au.result):null,Lu=Du&&!("refused"in Du)&&Du.mode==="direct"?Du.company??"":"";if(reactExports.useEffect(()=>{if(!Lu||typeof BroadcastChannel>"u")return;const Uu=new BroadcastChannel(PAP_SIGN_IN_CHANNEL);return Uu.onmessage=Hu=>{const Vu=signInReturnOf(Hu.data,Lu);Vu&&(Mu(Vu),Uu.close())},()=>Uu.close()},[Lu]),reactExports.useEffect(()=>{Ou==="signed_in"&&lo&&!Iu&&Pu(lo(PAP_SIGN_IN_WORDS.checkMessage(Lu)))},[Ou,lo,Iu,Lu]),!Du)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Au.defaultUI});if("refused"in Du)return jsxRuntimeExports.jsx(Flash,{variant:"danger",role:"alert",sx:{my:2},children:Du.refused});const Bu=async()=>{try{await navigator.clipboard.writeText(Du.code??""),Ru(!0)}catch{Ru(!1)}},ju=Du.company??Du.host,Fu=Du.organization,zu=Du.mode==="mediated"?Fu?PAP_SIGN_IN_WORDS.mediatedTitleFor(Fu.name,Fu.domain,Du.host):PAP_SIGN_IN_WORDS.mediatedTitle(Du.host):Fu&&Du.mode==="device"?PAP_SIGN_IN_WORDS.titleFor(Fu.name,Fu.domain,Du.host):PAP_SIGN_IN_WORDS.title(ju);return jsxRuntimeExports.jsxs(Box,{as:"section","aria-label":zu,my:2,p:3,border:"1px solid",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle",maxWidth:480,children:[jsxRuntimeExports.jsx(Heading$2,{as:"h4",sx:{fontSize:2,mb:1},children:zu}),jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,color:"fg.muted",fontSize:1},children:Du.mode==="device"?PAP_SIGN_IN_WORDS.device:Du.mode==="mediated"?PAP_SIGN_IN_WORDS.mediated:PAP_SIGN_IN_WORDS.direct}),Du.needs?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,fontSize:1},children:PAP_SIGN_IN_WORDS.needs(Du.needs)}):null,Du.sentTo?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,fontSize:1},children:PAP_SIGN_IN_WORDS.sentTo(Du.sentTo)}):null,Du.code?jsxRuntimeExports.jsxs(Box,{display:"flex",gap:3,alignItems:"center",flexWrap:"wrap",mb:2,children:[jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{as:"div",sx:{fontSize:0,color:"fg.muted"},children:PAP_SIGN_IN_WORDS.code}),jsxRuntimeExports.jsx(Text$3,{as:"div","aria-live":"polite",sx:{fontFamily:"mono",fontSize:5,fontWeight:"bold",letterSpacing:"0.15em"},children:Du.code}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",leadingVisual:CopyIcon,onClick:()=>{Bu()},children:$u?PAP_SIGN_IN_WORDS.copied:PAP_SIGN_IN_WORDS.copy})]}),jsxRuntimeExports.jsx(Box,{bg:"#ffffff",p:2,borderRadius:2,lineHeight:0,children:jsxRuntimeExports.jsx(QRCode,{value:Du.open,size:112,title:PAP_SIGN_IN_WORDS.qr(Du.host)})})]}):null,jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",children:[jsxRuntimeExports.jsx(ButtonComponent,{as:"a",href:Du.open,target:"_blank",rel:"noopener noreferrer",variant:"primary",trailingVisual:LinkExternalIcon,children:PAP_SIGN_IN_WORDS.open(ju)}),lo?jsxRuntimeExports.jsx(ButtonComponent,{disabled:Iu,onClick:()=>Pu(lo(PAP_SIGN_IN_WORDS.checkMessage(ju))),children:PAP_SIGN_IN_WORDS.checkAgain}):null]}),Ou?jsxRuntimeExports.jsx(Text$3,{as:"p",role:"status",sx:{mt:2,mb:0,fontSize:1},children:PAP_SIGN_IN_WORDS.returned[Ou](ju)}):null,Du.expiresAt?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:2,mb:0,fontSize:0,color:"fg.muted"},children:PAP_SIGN_IN_WORDS.until(Du.expiresAt)}):null,lo?null:jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:1,mb:0,fontSize:1},children:PAP_SIGN_IN_WORDS.tellMe})]})}const PAP_SIGN_IN_PLUGIN_NAME="@datalayer/loop-plugin-pap-sign-in",PAP_SIGN_IN_TYPE="application/vnd.datalayer.pap.sign-in+json";function resultOf(Au,lo){const $u=Au.data??{};return"toolName"in $u?lo?.result:{status:"waiting_for_the_person",...$u}}function createPapSignInPlugin(){let Au;const lo=Pu=>Au?!Au(Pu):!1;function $u({workspace:Pu}){const Ou=Pu?.viewControls.send;return reactExports.useEffect(()=>(Au=Ou,()=>{Au===Ou&&(Au=void 0)}),[Ou]),null}function Ru({display:Pu,context:Ou}){const Mu=resultOf(Pu,Ou);return reactExports.createElement(PapSignInCard,{key:Pu.id,context:Ou?{...Ou,result:Mu}:{toolCallId:Pu.id,toolName:"pap_sign_in",name:"pap_sign_in",args:{},status:"complete",result:Mu},send:Au?lo:void 0})}return{name:PAP_SIGN_IN_PLUGIN_NAME,displayName:"Sign in at a company",description:"The company’s page, the code and until when, where the agent asks the person to sign in.",octicon:"sign-in",emoji:"🔑",contributes:[contribution(Renderers,defineRenderer({type:PAP_SIGN_IN_TYPE,component:Ru}),{id:"pap-sign-in"}),contribution(ToolBindings,{tool:PAP_SIGN_IN_TOOL,type:PAP_SIGN_IN_TYPE},{id:"pap-sign-in"})],build(){return{components:[{slot:LoopSlots.chatHeader,id:"pap-sign-in",Component:$u}]}}}}const PapSignInPlugin=createPapSignInPlugin(),isRecord=Au=>!!Au&&typeof Au=="object"&&!Array.isArray(Au),records=Au=>Array.isArray(Au)?Au.filter(isRecord):[],said=Au=>typeof Au=="string"?Au:Au==null?"":String(Au),SESSION_STATES=["open","paused","ended"],SESSION_TURNS=["idle","running","waiting"],runsOnOf=Au=>{if(!isRecord(Au))return null;if(Au.kind==="runtime")return{kind:"runtime",uid:said(Au.uid)};if(Au.kind==="team_run")return{kind:"team_run",executionId:said(Au.execution_id),seat:said(Au.seat)};throw new Error(`A session runs on a runtime or a team run, not on ${JSON.stringify(Au.kind)}.`)},lineageOf=Au=>{const lo=isRecord(Au)?Au:{},$u=isRecord(lo.forked_from)?lo.forked_from:null,Ru=isRecord(lo.imported_from)?lo.imported_from:null;return{forkedFrom:$u?{uid:said($u.uid),atTurn:Number($u.at_turn)||0}:null,importedFrom:Ru?{digest:said(Ru.digest),exportedAt:said(Ru.exported_at),exportedBy:said(Ru.exported_by)}:null}};function sessionRowOf(Au){const lo=said(Au.uid);if(!lo)throw new Error("A session row names its uid; this one does not.");const $u=said(Au.state);if(!SESSION_STATES.includes($u))throw new Error(`There is no session state ${JSON.stringify($u)} (session ${lo}): one of ${SESSION_STATES.join(", ")}.`);const Ru=said(Au.turn);if(Ru&&!SESSION_TURNS.includes(Ru))throw new Error(`There is no turn phase ${JSON.stringify(Ru)} (session ${lo}): one of ${SESSION_TURNS.join(", ")}.`);return{uid:lo,appUid:said(Au.app_uid),deploymentUid:said(Au.deployment_uid),version:Number(Au.version)||0,purpose:said(Au.purpose),launchUid:said(Au.launch_uid),ownerUid:said(Au.owner_uid),openedBy:said(Au.opened_by),wokenBy:said(Au.woken_by),state:$u,turn:Ru,held:typeof Au.held=="boolean"?Au.held:null,agent:said(Au.agent),harness:said(Au.harness),title:said(Au.title),archived:Au.archived===!0,runsOn:runsOnOf(Au.runs_on),lineage:lineageOf(Au.lineage),turns:Number(Au.turns)||0,startedAt:said(Au.started_at),keptUntil:said(Au.kept_until)}}function sessionPageOf(Au){return{sessions:records(Au.sessions).map(sessionRowOf),hasMore:Au.has_more===!0}}const SESSION_STATE_WORDS={open:"Open",paused:"Paused",ended:"Ended"},SESSION_TURN_WORDS={idle:"",running:"answering",waiting:"waiting for you"};function sessionStateSaid(Au){const lo=Au.state==="open"&&Au.turn?SESSION_TURN_WORDS[Au.turn]:"";return lo?`${SESSION_STATE_WORDS[Au.state]} · ${lo}`:SESSION_STATE_WORDS[Au.state]}const SESSION_LINEAGE_WORDS={cloned:(Au,lo)=>`Cloned from ${Au} at turn ${lo}`,imported:Au=>Au?`Imported from a file exported ${Au}`:"Imported from a file"};function sessionLineageSaid(Au){const{forkedFrom:lo,importedFrom:$u}=Au.lineage;return lo?SESSION_LINEAGE_WORDS.cloned(lo.uid,lo.atTurn):$u?SESSION_LINEAGE_WORDS.imported($u.exportedAt):""}function sessionAgentSaid(Au){return Au.agent?Au.harness&&Au.harness!==Au.agent?`${Au.agent} (${Au.harness})`:Au.agent:""}const COLOURS={context:{bg:"transparent",fg:"fg.muted",sign:" "},add:{bg:"success.subtle",fg:"success.fg",sign:"+"},remove:{bg:"danger.subtle",fg:"danger.fg",sign:"-"}};function DiffCard({display:Au}){const lo=unifiedDiffLines(Au.oldText,Au.newText);return jsxRuntimeExports.jsxs(Box,{"data-shield-display":"diff","data-language":Au.language,sx:{width:"100%",border:"1px solid",borderColor:"border.default",borderRadius:2,overflow:"hidden",fontSize:0},children:[jsxRuntimeExports.jsxs(Box,{sx:{px:2,py:1,bg:"canvas.subtle",borderBottom:"1px solid",borderColor:"border.default",display:"flex",justifyContent:"space-between"},children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",fontWeight:"bold"},children:Au.path}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:displayLine(Au)})]}),jsxRuntimeExports.jsx(Box,{as:"pre",className:`language-${Au.language}`,sx:{m:0,overflowX:"auto",fontFamily:"mono"},children:lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{as:"span","data-diff-line":$u.kind,sx:{display:"block",px:2,bg:COLOURS[$u.kind].bg,color:COLOURS[$u.kind].fg,whiteSpace:"pre"},children:[COLOURS[$u.kind].sign,$u.text]},Ru))})]})}function TerminalCard({display:Au}){const lo=Au.exitCode!==null&&Au.exitCode!==0;return jsxRuntimeExports.jsxs(Box,{"data-shield-display":"terminal","data-exit-code":Au.exitCode===null?"running":Au.exitCode,sx:{width:"100%",border:"1px solid",borderColor:lo?"danger.muted":"border.default",borderRadius:2,overflow:"hidden",fontSize:0},children:[jsxRuntimeExports.jsxs(Box,{sx:{px:2,py:1,bg:"canvas.subtle",borderBottom:"1px solid",borderColor:"border.default",display:"flex",justifyContent:"space-between"},children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",fontWeight:"bold"},children:Au.command?`$ ${Au.command}`:Au.terminalId}),jsxRuntimeExports.jsx(Text$3,{sx:{color:lo?"danger.fg":"fg.muted"},children:displayLine(Au)})]}),jsxRuntimeExports.jsx(Box,{as:"pre",sx:{m:0,px:2,py:1,overflowX:"auto",fontFamily:"mono",whiteSpace:"pre-wrap",bg:"canvas.default"},children:Au.output||(Au.exitCode===null?"…":"(no output)")})]})}const SHIELD_DISPLAYS_PLUGIN_NAME="@datalayer/loop-plugin-shield-displays";function Diff({display:Au,context:lo}){const $u=protocolDisplayOf(Au);return!$u||$u.kind!=="diff"?reactExports.createElement("span",null,lo?.defaultUI??Au.text):reactExports.createElement(DiffCard,{key:Au.id,display:$u})}function Terminal$1({display:Au,context:lo}){const $u=protocolDisplayOf(Au);return!$u||$u.kind!=="terminal"?reactExports.createElement("span",null,lo?.defaultUI??Au.text):reactExports.createElement(TerminalCard,{key:Au.id,display:$u})}function createShieldDisplaysPlugin(){return{name:SHIELD_DISPLAYS_PLUGIN_NAME,displayName:"Diffs and terminals",description:"What a coding agent changed, as a unified diff, and what it ran, with its output.",octicon:"diff",emoji:"🛡",contributes:[contribution(Renderers,defineRenderer({type:SHIELD_DIFF_TYPE,component:Diff}),{id:"shield-diff"}),contribution(Renderers,defineRenderer({type:SHIELD_TERMINAL_TYPE,component:Terminal$1}),{id:"shield-terminal"})]}}const ShieldDisplaysPlugin=createShieldDisplaysPlugin();function makeViewSwitchAction({viewId:Au,icon:lo,tooltip:$u}){return function(){const Iu=reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().editorId),Pu=useContributions(LoopEditorView);if(Au!==NONE_EDITOR&&!Pu.some(Mu=>Mu.value.surfaceId===Au))return null;const Ou=(Iu||NONE_EDITOR)===Au;return jsxRuntimeExports.jsx(IconButton,{icon:lo,"aria-label":$u,size:"small",variant:"invisible",onClick:()=>{chooseEditor(Au)||console.warn(`[loop] No chat is on screen to switch to '${Au}'.`)},sx:Ou?{color:"accent.fg"}:void 0})}}function defineViewPlugin(Au){const{key:lo,viewId:$u,displayName:Ru,description:Iu,icon:Pu,tooltip:Ou,order:Mu}=Au,Du=makeViewSwitchAction({viewId:$u,icon:Pu,tooltip:Ou});return{name:`@datalayer/loop-plugin-${lo}-view`,displayName:Ru,description:Iu,octicon:Au.octicon??"eye",emoji:Au.emoji,dependencies:[InputPromptPlugin],build:()=>({components:[{id:`${lo}-view-action`,slot:LoopSlots.promptAction,order:Mu,Component:Du}]})}}const ChatViewPlugin=defineViewPlugin({key:"chat",viewId:NONE_EDITOR,displayName:"Chat view",description:"The conversation on its own, from the composer footer.",icon:CommentDiscussionIcon,tooltip:"Show the chat",octicon:"comment-discussion",emoji:"💬",order:10}),DocumentViewPlugin=defineViewPlugin({key:"document",viewId:"document",displayName:"Document view",description:"The document beside the chat, from the composer footer.",icon:FileIcon,tooltip:"Show the document",octicon:"file",emoji:"📄",order:12}),NotebookViewPlugin=defineViewPlugin({key:"notebook",viewId:"notebook",displayName:"Notebook view",description:"The notebook beside the chat, from the composer footer.",icon:RowsIcon,tooltip:"Show the notebook",octicon:"rows",emoji:"📓",order:11}),STYLE_ELEMENT_ID="datalayer-reactor-commands-style",PALETTE_CSS=`
|
|
3864
3864
|
/*
|
|
@@ -4017,7 +4017,7 @@ ${Mu}`:ju,inputs:Mu,clear:Ou?[]:[DRAFT.path],loop:Lu()}:{refused:"Nothing to sen
|
|
|
4017
4017
|
opacity: 0.6;
|
|
4018
4018
|
border-top: 1px solid var(--cmdk-border);
|
|
4019
4019
|
}
|
|
4020
|
-
`;function usePaletteStyles(){reactExports.useEffect(()=>{if(typeof document>"u"||document.getElementById(STYLE_ELEMENT_ID))return;const Au=document.createElement("style");Au.id=STYLE_ELEMENT_ID,Au.textContent=PALETTE_CSS,document.head.appendChild(Au)},[])}function rank(Au,lo){if(!lo)return{command:Au,score:0};const $u=lo.toLowerCase(),Ru=[[Au.name.toLowerCase(),0],[Au.id.toLowerCase(),100],[(Au.category??"").toLowerCase(),200],[(Au.description??"").toLowerCase(),300]];for(const[Iu,Pu]of Ru){const Ou=Iu.indexOf($u);if(Ou>=0)return{command:Au,score:Pu+Ou}}return null}const PRIMER_PORTAL_ROOT_ID="__primerPortalRoot__";function paletteRoot(){return document.getElementById(PRIMER_PORTAL_ROOT_ID)??document.body}const LIST_ID="dla-cmdk-list",optionId=Au=>`dla-cmdk-option-${Au}`,PALETTE_KEYBINDING="Mod+K",PALETTE_CHORD=parseKeybinding(PALETTE_KEYBINDING);function CommandPalette(){const Au=useReactorPlatform(),lo=useCommands();usePaletteStyles();const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(0),[Du,Lu]=reactExports.useState(null),[Bu,ju]=reactExports.useState(null),Fu=reactExports.useRef(null),zu=reactExports.useMemo(()=>lo.map(Wu=>rank(Wu,Iu)).filter(Wu=>Wu!==null).sort((Wu,Ku)=>Wu.score-Ku.score).map(Wu=>Wu.command),[lo,Iu]),Uu=reactExports.useCallback(()=>{Ru(!1),Pu(""),Mu(0),ju(null)},[]),Hu=reactExports.useCallback(async Wu=>{Lu(Wu.id),ju(null);try{await Au.executeCommand(Wu.id),Uu()}catch(Ku){ju(Ku instanceof Error?Ku.message:String(Ku))}finally{Lu(null)}},[Uu,Au]);if(reactExports.useEffect(()=>{const Wu=lo.map(Yu=>{const Xu=Yu.keybinding?parseKeybinding(Yu.keybinding):null;return Xu?{chord:Xu,id:Yu.id}:null}).filter(Yu=>Yu!==null),Ku=isApplePlatform();function Ju(Yu){if(PALETTE_CHORD&&matchesKeybinding(Yu,PALETTE_CHORD,Ku)){Yu.preventDefault(),Yu.stopPropagation(),Ru(Xu=>!Xu);return}if(Yu.key==="Escape"){Ru(Xu=>Xu&&!1);return}if(!$u){for(const Xu of Wu)if(matchesKeybinding(Yu,Xu.chord,Ku)){Yu.preventDefault(),Yu.stopPropagation();const ed=Au.getCommand(Xu.id);ed&&ed.isEnabled?.()!==!1&&Au.executeCommand(Xu.id).catch(td=>{console.error(`Command ${Xu.id} failed`,td)});return}}}return document.addEventListener("keydown",Ju,{capture:!0}),()=>document.removeEventListener("keydown",Ju,{capture:!0})},[lo,$u,Au]),reactExports.useEffect(()=>{if(!$u)return;Pu(""),Mu(0),ju(null);const Wu=window.requestAnimationFrame(()=>Fu.current?.focus());return()=>window.cancelAnimationFrame(Wu)},[$u]),reactExports.useEffect(()=>{Mu(Wu=>Wu>=zu.length?0:Wu)},[zu.length]),!$u||typeof document>"u")return null;const Vu=Wu=>{if(Wu.key==="ArrowDown")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku+1)%zu.length);else if(Wu.key==="ArrowUp")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku-1+zu.length)%zu.length);else if(Wu.key==="Enter"){Wu.preventDefault();const Ku=zu[Ou];Ku&&Ku.isEnabled?.()!==!1&&Hu(Ku)}},Gu=jsxRuntimeExports.jsx("div",{className:"dla-cmdk-backdrop",onClick:Uu,children:jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:Wu=>Wu.stopPropagation(),children:[jsxRuntimeExports.jsx("div",{className:"dla-cmdk-search",children:jsxRuntimeExports.jsx("input",{ref:Fu,className:"dla-cmdk-input",type:"text",placeholder:"Run a command…","aria-label":"Search commands",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,role:"combobox","aria-expanded":!0,"aria-controls":LIST_ID,"aria-autocomplete":"list","aria-activedescendant":zu.length>0?optionId(Ou):void 0,value:Iu,onChange:Wu=>Pu(Wu.target.value),onKeyDown:Vu})}),Bu!==null&&jsxRuntimeExports.jsx("div",{className:"dla-cmdk-error",children:Bu}),jsxRuntimeExports.jsx("ul",{className:"dla-cmdk-list",id:LIST_ID,role:"listbox",children:zu.length===0?jsxRuntimeExports.jsx("li",{className:"dla-cmdk-empty",children:lo.length===0?"No plugin has registered a command yet.":`Nothing matches “${Iu}”.`}):zu.map((Wu,Ku)=>{const Ju=Wu.isEnabled?.()!==!1;return jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsxs("button",{type:"button",className:"dla-cmdk-item",id:optionId(Ku),role:"option","aria-selected":Ku===Ou,"aria-disabled":!Ju,disabled:!Ju,onMouseEnter:()=>Mu(Ku),onClick:()=>{Hu(Wu)},children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-mark","aria-hidden":"true",children:Wu.emoji??"·"}),jsxRuntimeExports.jsxs("span",{className:"dla-cmdk-text",children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-name",children:Wu.name}),Wu.description&&jsxRuntimeExports.jsx("p",{className:"dla-cmdk-description",children:Wu.description})]}),Du===Wu.id&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:"running…"}),Wu.keybinding&&jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(Wu.keybinding)}),Wu.category&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:Wu.category})]})},Wu.id)})}),jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-footer",children:[jsxRuntimeExports.jsxs("span",{children:["↑↓ to move · ↵ to run · esc to close ·"," ",jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(PALETTE_KEYBINDING)})," ","to reopen"]}),jsxRuntimeExports.jsxs("span",{children:[zu.length," of ",lo.length]})]})]})});return reactDomExports.createPortal(Gu,paletteRoot())}const CommandsPlugin={name:"@datalayer/reactor-commands",version:"1.0.0",displayName:"Commands",description:"A command palette: Ctrl-K opens a floating search over every command plugins have registered.",octicon:"command-palette",emoji:"⌘",build(){return{components:[{slot:"root",id:"command-palette",Component:CommandPalette}]}},commands:[{id:"commands.showPalette",name:"Show the command palette",description:"The same thing Ctrl-K does — listed so it is discoverable",emoji:"⌘",category:"Commands",keybinding:PALETTE_KEYBINDING,execute:()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",ctrlKey:!0,bubbles:!0}))}}]},COMMANDS_PLUGIN_NAME="@datalayer/loop-plugin-commands",DEFAULT_CATEGORY="Workspace",GROUP_EMOJI={Agents:"🤖",Open:"📂",Session:"🧭",Workspace:"🪟"};function LoopCommandBridge({workspace:Au,sync:lo}){const $u=useContributions(LoopCommand);return reactExports.useEffect(()=>{lo($u,Au)},[$u,Au,lo]),null}const LoopCommandsPlugin={name:COMMANDS_PLUGIN_NAME,displayName:"Command palette",description:"Puts the workspace commands in a Ctrl-K palette, beside every plugin that registers one.",octicon:"command-palette",emoji:"⌘",dependencies:[CommandsPlugin,ThemePlugin],build:Au=>{const lo=new Map;let $u="",Ru;const Iu=(Pu,Ou)=>{const Mu=Ou?Pu.map(Du=>`${Du.plugin}:${Du.value.name}`).join("|"):"";if(!(Mu===$u&&Ou===Ru)){$u=Mu,Ru=Ou;for(const Du of lo.values())Du();if(lo.clear(),!!Ou)for(const Du of Pu){const Lu=Du.value,Bu=Lu.group??DEFAULT_CATEGORY;lo.set(Lu.name,Au.registerCommand({id:`loop.${Lu.name}`,name:Lu.description,description:`/${Lu.name}`,emoji:GROUP_EMOJI[Bu]??"💠",category:Bu,keybinding:Lu.keybinding,execute:async()=>{await Lu.run({workspace:Ou,argv:""})}}))}}};return{components:[{id:"loop-command-bridge",slot:LoopSlots.status,Component:({workspace:Pu})=>jsxRuntimeExports.jsx(LoopCommandBridge,{workspace:Pu,sync:Iu})}]}}},MODELS_PLUGIN_NAME="@datalayer/loop-plugin-models",ModelsPlugin={name:MODELS_PLUGIN_NAME,displayName:"Models",description:"Which model answers, from the agentspecs catalog.",octicon:"cpu",emoji:"🧠",contributes:[contribution(LoopCommand,{name:"models",aliases:["model"],description:"Show the models available to this session",group:"Agents",keybinding:"Mod+Alt+M",run:async({workspace:Au})=>{const lo=await fetch(`${Au.serverUrl}/api/v1/configure/models`);if(!lo.ok)return{content:"The model catalogue is unavailable."};const $u=await lo.json();return{content:`${($u.models??[]).filter(Iu=>Iu.available!==!1).length} of ${($u.models??[]).length} models are ready. Pick one under the prompt.`}}},{id:"models"})]},WINDOW_CONTROLS_SLOT="loop.window.controls",WINDOW_ACTIONS_SLOT="loop.window.actions";function WindowFrame({children:Au,title:lo,height:$u,slotProps:Ru={}}){const Iu=useOptionalSlotComponents(WINDOW_ACTIONS_SLOT);return jsxRuntimeExports.jsxs(Box,{position:"relative",borderRadius:"14px",overflow:"hidden",border:"1px solid",borderColor:"border.default",bg:"canvas.default",boxShadow:"0 24px 60px -28px rgba(0, 0, 0, 0.55)",height:$u===void 0?"100%":void 0,display:$u===void 0?"flex":void 0,flexDirection:$u===void 0?"column":void 0,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",bg:"canvas.subtle",flexWrap:"wrap",rowGap:2,flex:"0 0 auto",children:[jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:"6px",mr:1,flexShrink:0,children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_CONTROLS_SLOT,props:Ru})}),jsxRuntimeExports.jsx(Box,{minWidth:0,flex:"1 1 auto",children:lo}),Iu.length>0?jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:2,flexShrink:0,ml:"auto",children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_ACTIONS_SLOT,props:Ru})}):null]}),jsxRuntimeExports.jsx(Box,{sx:$u===void 0?{flex:"1 1 auto",minHeight:0}:{height:$u,minHeight:0},children:Au})]})}const WINDOW_FRAME_PLUGIN_NAME="@datalayer/loop-plugin-window-frame";function WindowControls(){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:["danger.emphasis","attention.emphasis","success.emphasis"].map(Au=>jsxRuntimeExports.jsx(Box,{width:10,height:10,borderRadius:"50%",bg:Au},Au))})}const WindowFramePlugin={name:WINDOW_FRAME_PLUGIN_NAME,displayName:"Window frame",description:"Draws Loop as a window, and opens its title bar to controls and actions.",octicon:"browser",emoji:"🪟",build:()=>({components:[{id:"window-controls",slot:WINDOW_CONTROLS_SLOT,Component:WindowControls},{id:"full-screen",slot:LoopSlots.header,Component:WorkspaceFullScreenAction}]})},DOCUMENT_PLUGIN_NAME="@datalayer/loop-plugin-document",DocumentPlugin={name:DOCUMENT_PLUGIN_NAME,displayName:"Document editor",description:"A rich-text document beside the chat, driven by the agent.",octicon:"file",emoji:"📄",dependencies:[AgentsPlugin],contributionPoints:[LoopDocumentToolbar,LoopOpeningDocument],contributes:[contribution(LoopEditorView,{surfaceId:"document",title:"Document",icon:FileIcon,order:20,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/DocumentView-BKFitqiB.js"),[],import.meta.url)},{id:"document",order:20}),contribution(LoopCommand,{name:"document",description:"Open the document beside the chat",group:"Open",keybinding:"Mod+Alt+O",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("document"))throw new Error("No chat is on screen to open the document beside.")}},{id:"document"})],build:Au=>(__vitePreload(async()=>{const{createLexicalTools:lo}=await import("./chunks/lexicalHooks-DbTGOMyq.js");return{createLexicalTools:lo}},[],import.meta.url).then(({createLexicalTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"document-tools",tools:$u=>lo($u.surfaceId)},{id:"document-tools"})},lo=>{console.warn("The document tools could not be loaded",lo)}),{})},DOCUMENT_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-document-toolbar",DocumentToolbarPlugin=defineLazyPlugin({name:DOCUMENT_TOOLBAR_PLUGIN_NAME,displayName:"Document toolbar",description:"Shows what the document’s code blocks run on.",octicon:"circle",emoji:"🔵",activationEvents:[onContributionPoint(LoopDocumentToolbar)],contributionPoints:[LoopDocumentToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-CB5BxGYz.js"),[],import.meta.url)}),NOTEBOOK_PLUGIN_NAME="@datalayer/loop-plugin-notebook",NotebookPlugin={name:NOTEBOOK_PLUGIN_NAME,displayName:"Notebook editor",description:"A notebook beside the chat, on the session’s kernel.",octicon:"rows",emoji:"📓",dependencies:[AgentsPlugin],contributionPoints:[LoopNotebookToolbar,LoopOpeningNotebook],contributes:[contribution(LoopEditorView,{surfaceId:"notebook",title:"Notebook",icon:RowsIcon,order:10,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/NotebookView-BDChKuA9.js"),[],import.meta.url)},{id:"notebook",order:10}),contribution(LoopCommand,{name:"notebook",description:"Open the notebook beside the chat",group:"Open",keybinding:"Mod+Alt+N",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("notebook"))throw new Error("No chat is on screen to open the notebook beside.")}},{id:"notebook"})],build:Au=>(__vitePreload(async()=>{const{createNotebookTools:lo}=await Promise.resolve().then(()=>notebookHooks);return{createNotebookTools:lo}},void 0,import.meta.url).then(({createNotebookTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"notebook-tools",tools:$u=>lo($u.surfaceId)},{id:"notebook-tools"})},lo=>{console.warn("The notebook tools could not be loaded",lo)}),{})},NOTEBOOK_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-notebook-toolbar",NotebookToolbarPlugin=defineLazyPlugin({name:NOTEBOOK_TOOLBAR_PLUGIN_NAME,displayName:"Notebook toolbar",description:"Shows what the notebook is running on, on its toolbar.",octicon:"circle",emoji:"🟢",activationEvents:[onContributionPoint(LoopNotebookToolbar)],contributionPoints:[LoopNotebookToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-ThwcTbLM.js"),[],import.meta.url)}),NotebookExtension=defineExtension({name:"@datalayer/loop-extension-notebook",displayName:"Notebooks",description:"A notebook beside the chat, and the toolbar that reports on it.",octicon:"rows",emoji:"📓",plugins:[NotebookPlugin,NotebookToolbarPlugin]}),DocumentExtension=defineExtension({name:"@datalayer/loop-extension-document",displayName:"Documents",description:"A rich-text document beside the chat, and the toolbar that reports on it.",octicon:"file",emoji:"📄",plugins:[DocumentPlugin,DocumentToolbarPlugin]}),NO_TURN$5=signal$2({id:0,status:"idle"}),MAX_HEIGHT=168;function Thinking(){return jsxRuntimeExports.jsxs(Box,{as:"span","aria-label":"The agent is thinking",display:"inline-flex",gap:"4px",alignItems:"center",sx:{height:"1.5em","& > i":{width:5,height:5,borderRadius:"50%",bg:"fg.muted",animation:"loop-turn-dot 1.2s ease-in-out infinite"},"& > i:nth-of-type(2)":{animationDelay:"0.15s"},"& > i:nth-of-type(3)":{animationDelay:"0.3s"},"@keyframes loop-turn-dot":{"0%, 80%, 100%":{opacity:.25},"40%":{opacity:1}}},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{})]})}function TurnPanel({footer:Au="full"}){const lo=useContributions(LoopChatTurn),$u=useSignalValue$1(lo[0]?.value.turn??NO_TURN$5),Ru=useSignalValue$1(pageLayoutSheet),Iu=reactExports.useRef(null),[Pu,Ou]=reactExports.useState(null),[Mu,Du]=reactExports.useState(!1);reactExports.useEffect(()=>{const ju=Iu.current;ju&&(ju.scrollTop=ju.scrollHeight)},[$u.assistant]),reactExports.useEffect(()=>{if(!Mu)return;const ju=window.setTimeout(()=>Du(!1),1400);return()=>window.clearTimeout(ju)},[Mu]);const Lu=reactExports.useCallback(async()=>{const ju=[$u.user,$u.assistant].filter(Boolean).join(`
|
|
4020
|
+
`;function usePaletteStyles(){reactExports.useEffect(()=>{if(typeof document>"u"||document.getElementById(STYLE_ELEMENT_ID))return;const Au=document.createElement("style");Au.id=STYLE_ELEMENT_ID,Au.textContent=PALETTE_CSS,document.head.appendChild(Au)},[])}function rank(Au,lo){if(!lo)return{command:Au,score:0};const $u=lo.toLowerCase(),Ru=[[Au.name.toLowerCase(),0],[Au.id.toLowerCase(),100],[(Au.category??"").toLowerCase(),200],[(Au.description??"").toLowerCase(),300]];for(const[Iu,Pu]of Ru){const Ou=Iu.indexOf($u);if(Ou>=0)return{command:Au,score:Pu+Ou}}return null}const PRIMER_PORTAL_ROOT_ID="__primerPortalRoot__";function paletteRoot(){return document.getElementById(PRIMER_PORTAL_ROOT_ID)??document.body}const LIST_ID="dla-cmdk-list",optionId=Au=>`dla-cmdk-option-${Au}`,PALETTE_KEYBINDING="Mod+K",PALETTE_CHORD=parseKeybinding(PALETTE_KEYBINDING);function CommandPalette(){const Au=useReactorPlatform(),lo=useCommands();usePaletteStyles();const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(0),[Du,Lu]=reactExports.useState(null),[Bu,ju]=reactExports.useState(null),Fu=reactExports.useRef(null),zu=reactExports.useMemo(()=>lo.map(Wu=>rank(Wu,Iu)).filter(Wu=>Wu!==null).sort((Wu,Ku)=>Wu.score-Ku.score).map(Wu=>Wu.command),[lo,Iu]),Uu=reactExports.useCallback(()=>{Ru(!1),Pu(""),Mu(0),ju(null)},[]),Hu=reactExports.useCallback(async Wu=>{Lu(Wu.id),ju(null);try{await Au.executeCommand(Wu.id),Uu()}catch(Ku){ju(Ku instanceof Error?Ku.message:String(Ku))}finally{Lu(null)}},[Uu,Au]);if(reactExports.useEffect(()=>{const Wu=lo.map(Yu=>{const Xu=Yu.keybinding?parseKeybinding(Yu.keybinding):null;return Xu?{chord:Xu,id:Yu.id}:null}).filter(Yu=>Yu!==null),Ku=isApplePlatform();function Ju(Yu){if(PALETTE_CHORD&&matchesKeybinding(Yu,PALETTE_CHORD,Ku)){Yu.preventDefault(),Yu.stopPropagation(),Ru(Xu=>!Xu);return}if(Yu.key==="Escape"){Ru(Xu=>Xu&&!1);return}if(!$u){for(const Xu of Wu)if(matchesKeybinding(Yu,Xu.chord,Ku)){Yu.preventDefault(),Yu.stopPropagation();const ed=Au.getCommand(Xu.id);ed&&ed.isEnabled?.()!==!1&&Au.executeCommand(Xu.id).catch(td=>{console.error(`Command ${Xu.id} failed`,td)});return}}}return document.addEventListener("keydown",Ju,{capture:!0}),()=>document.removeEventListener("keydown",Ju,{capture:!0})},[lo,$u,Au]),reactExports.useEffect(()=>{if(!$u)return;Pu(""),Mu(0),ju(null);const Wu=window.requestAnimationFrame(()=>Fu.current?.focus());return()=>window.cancelAnimationFrame(Wu)},[$u]),reactExports.useEffect(()=>{Mu(Wu=>Wu>=zu.length?0:Wu)},[zu.length]),!$u||typeof document>"u")return null;const Vu=Wu=>{if(Wu.key==="ArrowDown")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku+1)%zu.length);else if(Wu.key==="ArrowUp")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku-1+zu.length)%zu.length);else if(Wu.key==="Enter"){Wu.preventDefault();const Ku=zu[Ou];Ku&&Ku.isEnabled?.()!==!1&&Hu(Ku)}},Gu=jsxRuntimeExports.jsx("div",{className:"dla-cmdk-backdrop",onClick:Uu,children:jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:Wu=>Wu.stopPropagation(),children:[jsxRuntimeExports.jsx("div",{className:"dla-cmdk-search",children:jsxRuntimeExports.jsx("input",{ref:Fu,className:"dla-cmdk-input",type:"text",placeholder:"Run a command…","aria-label":"Search commands",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,role:"combobox","aria-expanded":!0,"aria-controls":LIST_ID,"aria-autocomplete":"list","aria-activedescendant":zu.length>0?optionId(Ou):void 0,value:Iu,onChange:Wu=>Pu(Wu.target.value),onKeyDown:Vu})}),Bu!==null&&jsxRuntimeExports.jsx("div",{className:"dla-cmdk-error",children:Bu}),jsxRuntimeExports.jsx("ul",{className:"dla-cmdk-list",id:LIST_ID,role:"listbox",children:zu.length===0?jsxRuntimeExports.jsx("li",{className:"dla-cmdk-empty",children:lo.length===0?"No plugin has registered a command yet.":`Nothing matches “${Iu}”.`}):zu.map((Wu,Ku)=>{const Ju=Wu.isEnabled?.()!==!1;return jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsxs("button",{type:"button",className:"dla-cmdk-item",id:optionId(Ku),role:"option","aria-selected":Ku===Ou,"aria-disabled":!Ju,disabled:!Ju,onMouseEnter:()=>Mu(Ku),onClick:()=>{Hu(Wu)},children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-mark","aria-hidden":"true",children:Wu.emoji??"·"}),jsxRuntimeExports.jsxs("span",{className:"dla-cmdk-text",children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-name",children:Wu.name}),Wu.description&&jsxRuntimeExports.jsx("p",{className:"dla-cmdk-description",children:Wu.description})]}),Du===Wu.id&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:"running…"}),Wu.keybinding&&jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(Wu.keybinding)}),Wu.category&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:Wu.category})]})},Wu.id)})}),jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-footer",children:[jsxRuntimeExports.jsxs("span",{children:["↑↓ to move · ↵ to run · esc to close ·"," ",jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(PALETTE_KEYBINDING)})," ","to reopen"]}),jsxRuntimeExports.jsxs("span",{children:[zu.length," of ",lo.length]})]})]})});return reactDomExports.createPortal(Gu,paletteRoot())}const CommandsPlugin={name:"@datalayer/reactor-commands",version:"1.0.0",displayName:"Commands",description:"A command palette: Ctrl-K opens a floating search over every command plugins have registered.",octicon:"command-palette",emoji:"⌘",build(){return{components:[{slot:"root",id:"command-palette",Component:CommandPalette}]}},commands:[{id:"commands.showPalette",name:"Show the command palette",description:"The same thing Ctrl-K does — listed so it is discoverable",emoji:"⌘",category:"Commands",keybinding:PALETTE_KEYBINDING,execute:()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",ctrlKey:!0,bubbles:!0}))}}]},COMMANDS_PLUGIN_NAME="@datalayer/loop-plugin-commands",DEFAULT_CATEGORY="Workspace",GROUP_EMOJI={Agents:"🤖",Open:"📂",Session:"🧭",Workspace:"🪟"};function LoopCommandBridge({workspace:Au,sync:lo}){const $u=useContributions(LoopCommand);return reactExports.useEffect(()=>{lo($u,Au)},[$u,Au,lo]),null}const LoopCommandsPlugin={name:COMMANDS_PLUGIN_NAME,displayName:"Command palette",description:"Puts the workspace commands in a Ctrl-K palette, beside every plugin that registers one.",octicon:"command-palette",emoji:"⌘",dependencies:[CommandsPlugin,ThemePlugin],build:Au=>{const lo=new Map;let $u="",Ru;const Iu=(Pu,Ou)=>{const Mu=Ou?Pu.map(Du=>`${Du.plugin}:${Du.value.name}`).join("|"):"";if(!(Mu===$u&&Ou===Ru)){$u=Mu,Ru=Ou;for(const Du of lo.values())Du();if(lo.clear(),!!Ou)for(const Du of Pu){const Lu=Du.value,Bu=Lu.group??DEFAULT_CATEGORY;lo.set(Lu.name,Au.registerCommand({id:`loop.${Lu.name}`,name:Lu.description,description:`/${Lu.name}`,emoji:GROUP_EMOJI[Bu]??"💠",category:Bu,keybinding:Lu.keybinding,execute:async()=>{await Lu.run({workspace:Ou,argv:""})}}))}}};return{components:[{id:"loop-command-bridge",slot:LoopSlots.status,Component:({workspace:Pu})=>jsxRuntimeExports.jsx(LoopCommandBridge,{workspace:Pu,sync:Iu})}]}}},MODELS_PLUGIN_NAME="@datalayer/loop-plugin-models",ModelsPlugin={name:MODELS_PLUGIN_NAME,displayName:"Models",description:"Which model answers, from the agentspecs catalog.",octicon:"cpu",emoji:"🧠",contributes:[contribution(LoopCommand,{name:"models",aliases:["model"],description:"Show the models available to this session",group:"Agents",keybinding:"Mod+Alt+M",run:async({workspace:Au})=>{const lo=await fetch(`${Au.serverUrl}/api/v1/configure/models`);if(!lo.ok)return{content:"The model catalogue is unavailable."};const $u=await lo.json();return{content:`${($u.models??[]).filter(Iu=>Iu.available!==!1).length} of ${($u.models??[]).length} models are ready. Pick one under the prompt.`}}},{id:"models"})]},WINDOW_CONTROLS_SLOT="loop.window.controls",WINDOW_ACTIONS_SLOT="loop.window.actions";function WindowFrame({children:Au,title:lo,height:$u,slotProps:Ru={}}){const Iu=useOptionalSlotComponents(WINDOW_ACTIONS_SLOT);return jsxRuntimeExports.jsxs(Box,{position:"relative",borderRadius:"14px",overflow:"hidden",border:"1px solid",borderColor:"border.default",bg:"canvas.default",boxShadow:"0 24px 60px -28px rgba(0, 0, 0, 0.55)",height:$u===void 0?"100%":void 0,display:$u===void 0?"flex":void 0,flexDirection:$u===void 0?"column":void 0,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",bg:"canvas.subtle",flexWrap:"wrap",rowGap:2,flex:"0 0 auto",children:[jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:"6px",mr:1,flexShrink:0,children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_CONTROLS_SLOT,props:Ru})}),jsxRuntimeExports.jsx(Box,{minWidth:0,flex:"1 1 auto",children:lo}),Iu.length>0?jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:2,flexShrink:0,ml:"auto",children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_ACTIONS_SLOT,props:Ru})}):null]}),jsxRuntimeExports.jsx(Box,{sx:$u===void 0?{flex:"1 1 auto",minHeight:0}:{height:$u,minHeight:0},children:Au})]})}const WINDOW_FRAME_PLUGIN_NAME="@datalayer/loop-plugin-window-frame";function WindowControls(){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:["danger.emphasis","attention.emphasis","success.emphasis"].map(Au=>jsxRuntimeExports.jsx(Box,{width:10,height:10,borderRadius:"50%",bg:Au},Au))})}const WindowFramePlugin={name:WINDOW_FRAME_PLUGIN_NAME,displayName:"Window frame",description:"Draws Loop as a window, and opens its title bar to controls and actions.",octicon:"browser",emoji:"🪟",build:()=>({components:[{id:"window-controls",slot:WINDOW_CONTROLS_SLOT,Component:WindowControls},{id:"full-screen",slot:LoopSlots.header,Component:WorkspaceFullScreenAction}]})},DOCUMENT_PLUGIN_NAME="@datalayer/loop-plugin-document",DocumentPlugin={name:DOCUMENT_PLUGIN_NAME,displayName:"Document editor",description:"A rich-text document beside the chat, driven by the agent.",octicon:"file",emoji:"📄",dependencies:[AgentsPlugin],contributionPoints:[LoopDocumentToolbar,LoopOpeningDocument],contributes:[contribution(LoopEditorView,{surfaceId:"document",title:"Document",icon:FileIcon,order:20,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/DocumentView-ssQ835Wa.js"),[],import.meta.url)},{id:"document",order:20}),contribution(LoopCommand,{name:"document",description:"Open the document beside the chat",group:"Open",keybinding:"Mod+Alt+O",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("document"))throw new Error("No chat is on screen to open the document beside.")}},{id:"document"})],build:Au=>(__vitePreload(async()=>{const{createLexicalTools:lo}=await import("./chunks/lexicalHooks-DbTGOMyq.js");return{createLexicalTools:lo}},[],import.meta.url).then(({createLexicalTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"document-tools",tools:$u=>lo($u.surfaceId)},{id:"document-tools"})},lo=>{console.warn("The document tools could not be loaded",lo)}),{})},DOCUMENT_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-document-toolbar",DocumentToolbarPlugin=defineLazyPlugin({name:DOCUMENT_TOOLBAR_PLUGIN_NAME,displayName:"Document toolbar",description:"Shows what the document’s code blocks run on.",octicon:"circle",emoji:"🔵",activationEvents:[onContributionPoint(LoopDocumentToolbar)],contributionPoints:[LoopDocumentToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-CB5BxGYz.js"),[],import.meta.url)}),NOTEBOOK_PLUGIN_NAME="@datalayer/loop-plugin-notebook",NotebookPlugin={name:NOTEBOOK_PLUGIN_NAME,displayName:"Notebook editor",description:"A notebook beside the chat, on the session’s kernel.",octicon:"rows",emoji:"📓",dependencies:[AgentsPlugin],contributionPoints:[LoopNotebookToolbar,LoopOpeningNotebook],contributes:[contribution(LoopEditorView,{surfaceId:"notebook",title:"Notebook",icon:RowsIcon,order:10,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/NotebookView-BDChKuA9.js"),[],import.meta.url)},{id:"notebook",order:10}),contribution(LoopCommand,{name:"notebook",description:"Open the notebook beside the chat",group:"Open",keybinding:"Mod+Alt+N",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("notebook"))throw new Error("No chat is on screen to open the notebook beside.")}},{id:"notebook"})],build:Au=>(__vitePreload(async()=>{const{createNotebookTools:lo}=await Promise.resolve().then(()=>notebookHooks);return{createNotebookTools:lo}},void 0,import.meta.url).then(({createNotebookTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"notebook-tools",tools:$u=>lo($u.surfaceId)},{id:"notebook-tools"})},lo=>{console.warn("The notebook tools could not be loaded",lo)}),{})},NOTEBOOK_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-notebook-toolbar",NotebookToolbarPlugin=defineLazyPlugin({name:NOTEBOOK_TOOLBAR_PLUGIN_NAME,displayName:"Notebook toolbar",description:"Shows what the notebook is running on, on its toolbar.",octicon:"circle",emoji:"🟢",activationEvents:[onContributionPoint(LoopNotebookToolbar)],contributionPoints:[LoopNotebookToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-ThwcTbLM.js"),[],import.meta.url)}),NotebookExtension=defineExtension({name:"@datalayer/loop-extension-notebook",displayName:"Notebooks",description:"A notebook beside the chat, and the toolbar that reports on it.",octicon:"rows",emoji:"📓",plugins:[NotebookPlugin,NotebookToolbarPlugin]}),DocumentExtension=defineExtension({name:"@datalayer/loop-extension-document",displayName:"Documents",description:"A rich-text document beside the chat, and the toolbar that reports on it.",octicon:"file",emoji:"📄",plugins:[DocumentPlugin,DocumentToolbarPlugin]}),NO_TURN$5=signal$2({id:0,status:"idle"}),MAX_HEIGHT=168;function Thinking(){return jsxRuntimeExports.jsxs(Box,{as:"span","aria-label":"The agent is thinking",display:"inline-flex",gap:"4px",alignItems:"center",sx:{height:"1.5em","& > i":{width:5,height:5,borderRadius:"50%",bg:"fg.muted",animation:"loop-turn-dot 1.2s ease-in-out infinite"},"& > i:nth-of-type(2)":{animationDelay:"0.15s"},"& > i:nth-of-type(3)":{animationDelay:"0.3s"},"@keyframes loop-turn-dot":{"0%, 80%, 100%":{opacity:.25},"40%":{opacity:1}}},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{})]})}function TurnPanel({footer:Au="full"}){const lo=useContributions(LoopChatTurn),$u=useSignalValue$1(lo[0]?.value.turn??NO_TURN$5),Ru=useSignalValue$1(pageLayoutSheet),Iu=reactExports.useRef(null),[Pu,Ou]=reactExports.useState(null),[Mu,Du]=reactExports.useState(!1);reactExports.useEffect(()=>{const ju=Iu.current;ju&&(ju.scrollTop=ju.scrollHeight)},[$u.assistant]),reactExports.useEffect(()=>{if(!Mu)return;const ju=window.setTimeout(()=>Du(!1),1400);return()=>window.clearTimeout(ju)},[Mu]);const Lu=reactExports.useCallback(async()=>{const ju=[$u.user,$u.assistant].filter(Boolean).join(`
|
|
4021
4021
|
|
|
4022
4022
|
`);await navigator.clipboard?.writeText(ju),Du(!0)},[$u.user,$u.assistant]);if(Ru==="panel"||$u.status==="idle"||!$u.user||Pu===$u.id)return null;const Bu=$u.status==="thinking"||$u.status==="streaming";return jsxRuntimeExports.jsxs(Box,{"data-turn-panel":"",borderTop:"1px solid",borderColor:"border.muted",px:3,pt:2,pb:Au==="none"?2:1,display:"flex",flexDirection:"column",gap:2,bg:"canvas.default",children:[jsxRuntimeExports.jsx(Box,{display:"flex",justifyContent:"flex-end",children:jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,lineHeight:1.45,px:2,py:1,borderRadius:"10px",bg:"accent.subtle",color:"fg.default",maxWidth:"85%",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:$u.user})}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,alignItems:"flex-start",children:[jsxRuntimeExports.jsx(Box,{ref:Iu,flex:"1 1 auto",minWidth:0,maxHeight:MAX_HEIGHT,overflowY:"auto",fontSize:0,lineHeight:1.5,color:$u.assistant?"fg.default":"fg.muted",whiteSpace:$u.assistant?"normal":"pre-wrap",overflowWrap:"anywhere",children:$u.assistant?jsxRuntimeExports.jsx(Box,{sx:{...streamdownMarkdownStyles,fontSize:0},children:jsxRuntimeExports.jsx(_o$1,{rehypePlugins:REHYPE_PLUGINS_WITHOUT_HTML,children:normalizeAssistantMarkdown($u.assistant)})}):$u.activity?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontStyle:"italic"},children:$u.activity}):Bu?jsxRuntimeExports.jsx(Thinking,{}):$u.status==="error"?"The agent could not answer.":"Done — the result is in the page."}),jsxRuntimeExports.jsx(IconButton,{icon:CommentDiscussionIcon,size:"small",variant:"invisible","aria-label":"Open the conversation",onClick:openPagePanel,sx:{color:"fg.muted",flexShrink:0}})]}),$u.assistant&&$u.activity?jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,color:"fg.muted",fontStyle:"italic"},children:$u.activity}):null,Au==="full"?jsxRuntimeExports.jsx(TurnFooter,{usage:$u.usage,live:Bu,latest:!0,padding:0,onCopy:Lu,onRemove:()=>Ou($u.id)}):Au==="actions"?jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"flex-end",gap:1,mt:-1,children:[jsxRuntimeExports.jsx(IconButton,{icon:Mu?CheckIcon:CopyIcon,size:"small",variant:"invisible","aria-label":Mu?"Copied":"Copy this turn",onClick:()=>{Lu()},sx:{color:"fg.muted"}}),jsxRuntimeExports.jsx(IconButton,{icon:XIcon,size:"small",variant:"invisible","aria-label":"Dismiss until the next turn",onClick:()=>Ou($u.id),sx:{color:"fg.muted"}})]}):null]})}const SPLIT_DEFAULT_SHARE=.4,SPLIT_MIN_SHARE=.2,SPLIT_MAX_SHARE=.8,SPLIT_KEY_STEP=.05;function clampSplitShare(Au){return Number.isFinite(Au)?Math.min(SPLIT_MAX_SHARE,Math.max(SPLIT_MIN_SHARE,Au)):SPLIT_DEFAULT_SHARE}function splitShareForKey(Au,lo){switch(lo){case"ArrowLeft":return clampSplitShare(Au-SPLIT_KEY_STEP);case"ArrowRight":return clampSplitShare(Au+SPLIT_KEY_STEP);case"Home":return SPLIT_MIN_SHARE;case"End":return SPLIT_MAX_SHARE;default:return null}}function SplitLayout({editors:Au,hasEditor:lo,transcript:$u,prompt:Ru,chips:Iu,picker:Pu,transient:Ou}){const[Mu,Du]=reactExports.useState(SPLIT_DEFAULT_SHARE),Lu=reactExports.useRef(null),Bu=reactExports.useRef(!1),ju=reactExports.useCallback(Gu=>{const Wu=Lu.current?.getBoundingClientRect();return!Wu||Wu.width<=0?null:clampSplitShare((Gu-Wu.left)/Wu.width)},[]),Fu=Gu=>{Bu.current=!0,Gu.currentTarget.setPointerCapture?.(Gu.pointerId),Gu.preventDefault()},zu=Gu=>{if(!Bu.current)return;const Wu=ju(Gu.clientX);Wu!==null&&Du(Wu)},Uu=Gu=>{Bu.current=!1,Gu.currentTarget.releasePointerCapture?.(Gu.pointerId)},Hu=Gu=>{const Wu=splitShareForKey(Mu,Gu.key);Wu!==null&&(Gu.preventDefault(),Du(Wu))},Vu=Math.round(Mu*100);return jsxRuntimeExports.jsxs(Box,{"data-testid":"loop-split-layout",flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",children:[Pu,jsxRuntimeExports.jsxs(Box,{ref:Lu,flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",overflow:"hidden",children:[jsxRuntimeExports.jsxs(Box,{"data-testid":"loop-split-conversation",flex:lo?`0 0 ${Vu}%`:"1 1 auto",minWidth:0,minHeight:0,display:"flex",flexDirection:"column",ml:lo?"-1px":0,children:[$u,Iu,Ru]}),lo?jsxRuntimeExports.jsx(Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize the conversation and the page","aria-valuemin":Math.round(SPLIT_MIN_SHARE*100),"aria-valuemax":Math.round(SPLIT_MAX_SHARE*100),"aria-valuenow":Vu,tabIndex:0,onPointerDown:Fu,onPointerMove:zu,onPointerUp:Uu,onPointerCancel:Uu,onKeyDown:Hu,flex:"0 0 7px",mx:"-3px",zIndex:1,cursor:"col-resize",display:"flex",justifyContent:"center",outline:"none",touchAction:"none",sx:{"&::before":{content:'""',width:"1px",height:"100%",bg:"border.default"},"&:hover::before, &:focus-visible::before":{width:"3px",bg:"accent.emphasis"}}}):null,jsxRuntimeExports.jsx(Box,{"data-testid":"loop-split-page",sx:lo?{flex:"1 1 0",minWidth:0,minHeight:0,display:"flex",...paneOpening("right")}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:Au})]}),Ou]})}const LOOP_PAGE_LAYOUT_PLUGIN_NAME="@datalayer/loop-plugin-page-layout",NO_TURN$4=signal$2({id:0,status:"idle"}),pageLayoutChatMode=signal$2("floating-draggable"),promptStance=signal$2("floating-top");let floatingStance="floating-top";const PAGE_LAYOUT_DISABLED_MODES=["assistant"];function pageLayoutForChatMode(Au){switch(Au){case"sidebar":return{bandMode:"panel",panelMode:"docked"};case"floating":return{bandMode:"panel",panelMode:"overlay"};case"floating-small":return{bandMode:"panel",panelMode:"popup"};default:return{bandMode:"floating",panelMode:"docked"}}}function setPageLayoutChatMode(Au){pageLayoutChatMode.value=Au;const{bandMode:lo}=pageLayoutForChatMode(Au);promptStance.value=lo==="floating"?floatingStance:"docked-top",lo==="panel"&&openPagePanel()}function ChatModeAction(){const Au=useSignalValue$1(pageLayoutChatMode);return jsxRuntimeExports.jsx(ChatViewModeToggle,{value:Au,onChange:setPageLayoutChatMode,disabledModes:PAGE_LAYOUT_DISABLED_MODES})}function LoopPageLayout({parts:Au,promptMode:lo,pageSize:$u}){const Ru=useContributions(LoopChatTurn),Iu=useSignalValue$1(Ru[0]?.value.turn??NO_TURN$4),Pu=useSignalValue$1(pageLayoutChatMode),Ou=lo==="floating"?pageLayoutForChatMode(Pu):{bandMode:"docked",panelMode:"docked"};return jsxRuntimeExports.jsx(PageLayout,{page:Au.editors,hasPage:Au.hasEditor,panel:Au.transcript,band:Au.prompt,chips:Au.chips,picker:Au.picker,transient:Au.transient,activity:Iu.activity,bandMode:Ou.bandMode,panelMode:Ou.panelMode,pageSize:$u})}function ConversationToggle(){return jsxRuntimeExports.jsx(PagePanelToggle,{panelName:"conversation",icon:CommentDiscussionIcon,sx:{order:2}})}const LoopPageLayoutPlugin={name:LOOP_PAGE_LAYOUT_PLUGIN_NAME,config:{arrangement:"page",turnPanel:"below",turnPanelFooter:"full",prompt:"docked",promptAnchor:"top",pageSize:void 0},displayName:"Page layout",description:"The editor — or, in the chat view, the conversation — on a centred sheet, the prompt docked above it at the same width or floating over it as a draggable card, the current turn under the prompt, the conversation in a side panel; or, split, the conversation and the work side by side with a hairline to drag.",octicon:"file",emoji:"📄",build:({config:Au,...lo})=>{if(Au.arrangement==="split")return lo.contribute(LoopChatLayout,{id:"split-layout",prompt:"docked",Component:SplitLayout},{id:"split-layout"}),{components:[]};const $u=Au.prompt,Ru=Au.pageSize;floatingStance=Au.promptAnchor==="bottom"?"floating-bottom":"floating-top",$u==="floating"&&(promptStance.value=floatingStance);const Iu=Pu=>jsxRuntimeExports.jsx(LoopPageLayout,{parts:Pu,promptMode:$u,pageSize:Ru});if(lo.contribute(LoopChatLayout,{id:"page-layout",prompt:$u==="floating"?floatingStance:"docked-top",promptStance:$u==="floating"?promptStance:void 0,Component:Iu},{id:"page-layout"}),Au.turnPanel!=="none"){const Pu=Au.turnPanelFooter,Ou=()=>jsxRuntimeExports.jsx(TurnPanel,{footer:Pu});lo.contribute(LoopPromptPanel,{id:"page-layout-turn",placement:Au.turnPanel,order:0,Component:Ou},{id:"page-layout-turn"})}return{components:[{id:"page-layout-conversation-toggle",slot:LoopSlots.header,Component:ConversationToggle},...$u==="floating"?[{id:"page-layout-chat-mode",slot:LoopSlots.promptAction,Component:ChatModeAction}]:[]]}}};function loopPlugins(Au={}){const{serverUrl:lo,target:$u="browser",defaultEditor:Ru,showViewSelector:Iu=!0,hideChatHeader:Pu=!1,chatHeaderButtons:Ou=!1,promptPlacement:Mu,autoFocusPrompt:Du=!0,suggestionLabels:Lu=!0,fullScreenTopOffset:Bu=0,showAgentVariants:ju=!1,agentSummary:Fu=!0,teamId:zu,teamPicker:Uu=!0,pageLayout:Hu=!1,pageLayoutArrangement:Vu="page",pageLayoutTurnPanel:Gu="below",pageLayoutPrompt:Wu="docked",pageLayoutPromptAnchor:Ku="top",pageLayoutSize:Ju,pageLayoutTurnPanelFooter:Yu="full",localAgent:Xu,localAgentSpec:ed,datalayerAgentSpecId:td,datalayerCreatePayload:nd,datalayerVisitors:od,datalayerKept:sd,embedToken:ad,targetFixed:pd,themeVariant:gd,themeOverrides:Sd,colorMode:_d,presence:yd,showTokenUsage:wd,voice:Ad,thread:md,floatingPrompt:dd=!1,editorSelector:bd=!1,editors:ld=!0,conversation:ud=!0,commandPalette:hd=!1,pluginsPanel:vd=!1,windowFrame:Ed=!1,firstPromptHook:Cd}=Au,Rd=Ru??(ld?"notebook":"none");return ud?[configurePlugin(ChatPlugin,{defaultSurface:Rd,showSurfaceSelector:ld&&Iu&&!bd,hideHeader:Pu,headerButtons:{newChat:Ou,clear:Ou},promptPlacement:dd?"floating":Mu,autoFocusPrompt:Du,suggestionLabels:Lu,fullScreenTopOffset:Bu,themeVariant:gd,themeOverrides:Sd,colorMode:_d,presence:yd,showTokenUsage:wd,...Ad?{voice:Ad}:{},...md?{thread:md}:{}}),configurePlugin(InputPromptPlugin,{firstPromptHook:Cd}),ChatHeaderPlugin,A2uiSurfacePlugin,PapSignInPlugin,ShieldDisplaysPlugin,ChatViewPlugin,...ld?[NotebookViewPlugin,DocumentViewPlugin]:[],configurePlugin(AgentsPlugin,{serverUrl:lo,target:$u,datalayerAgentSpecId:td,datalayerCreatePayload:nd,datalayerVisitors:od,datalayerKept:sd,embedToken:ad,targetFixed:pd,showAgentVariants:ju,showAgentSummary:Fu,teamId:zu,showTeamPicker:Uu,localAgent:Xu??(ed?{createPayload:{description:`Local agent from the ${ed} spec`,agent_library:"pydantic-ai",agent_spec_id:ed,enable_codemode:!1}}:void 0)}),...ld?[NotebookExtension,DocumentExtension]:[],A2uiPlugin,AgentspecsPlugin,ModelsPlugin,ThemePlugin,SubagentActivityPlugin,configurePlugin(ShellPlugin,{defaultEditor:Rd,showSelector:ld&&bd}),...dd?[PromptPlugin]:[],...Hu?[configurePlugin(LoopPageLayoutPlugin,{arrangement:Vu,turnPanel:Gu,turnPanelFooter:Yu,prompt:Wu,promptAnchor:Ku,pageSize:Ju})]:[],...hd?[LoopCommandsPlugin]:[],...vd?[PluginsPanelPlugin]:[],...Ed?[WindowFramePlugin]:[]]:[ThemePlugin,configurePlugin(ShellPlugin,{defaultEditor:"none",showSelector:!1}),...hd?[LoopCommandsPlugin]:[],...vd?[PluginsPanelPlugin]:[],...Ed?[WindowFramePlugin]:[]]}function LoopEmbed({agentId:Au="",showHeader:lo=!1,chatHeaderActions:$u,headerActions:Ru,headerContainer:Iu,frameTitle:Pu,frameHeight:Ou,sidebarRail:Mu=!1,plugins:Du=[],...Lu}){const Bu=reactExports.useRef(Lu.firstPromptHook);Bu.current=Lu.firstPromptHook;const ju=reactExports.useMemo(()=>buildLoopReactor([...loopPlugins({...Lu,windowFrame:Lu.windowFrame||Pu!==void 0,firstPromptHook:()=>Bu.current?.()}),...Du]),[Lu.serverUrl,Lu.target,Lu.datalayerAgentSpecId,Lu.targetFixed,Lu.themeVariant,JSON.stringify(Lu.themeOverrides??null),Lu.colorMode,Lu.presence?.name,Lu.presence?.face,Lu.presence?.welcome,Lu.presence?.paused,Lu.showTokenUsage,JSON.stringify({...Lu.voice??{},engines:void 0,token:void 0}),Lu.thread?.id,JSON.stringify(Lu.datalayerCreatePayload??null),JSON.stringify(Lu.datalayerVisitors??null),Lu.datalayerKept?.url,Lu.embedToken,Lu.defaultEditor,Lu.showViewSelector,Lu.hideChatHeader,Lu.chatHeaderButtons,Lu.promptPlacement,Lu.autoFocusPrompt,Lu.suggestionLabels,Lu.fullScreenTopOffset,Lu.showAgentVariants,Lu.agentSummary,Lu.teamId,Lu.teamPicker,Lu.pageLayout,Lu.pageLayoutTurnPanel,Lu.pageLayoutTurnPanelFooter,Lu.pageLayoutPrompt,Lu.pageLayoutPromptAnchor,Lu.pageLayoutSize?.format,Lu.pageLayoutSize?.width,Lu.pageLayoutSize?.height,Lu.localAgentSpec,Lu.floatingPrompt,Lu.editorSelector,Lu.editors,Lu.conversation,Lu.commandPalette,Lu.pluginsPanel,Lu.windowFrame,Pu!==void 0,Du]);useReactor(ju);const Fu=jsxRuntimeExports.jsx(LoopWorkspace,{serverUrl:Lu.serverUrl??"",agentId:Au,reactor:ju,manageReactor:!1,showViewSelector:Lu.showViewSelector,showHeader:lo,chatHeaderActions:$u,headerActions:Ru,headerContainer:Iu,sidebarRail:Mu});return jsxRuntimeExports.jsx(QueryClientProvider,{client:internalQueryClient,children:Pu!==void 0?jsxRuntimeExports.jsx(WindowFrame,{title:Pu,height:Ou,children:Fu}):jsxRuntimeExports.jsx(Box,{height:"100%",minHeight:0,width:"100%",flex:"1 1 auto",minWidth:0,children:Fu})})}const RECORD_KIND_WORDS={session:"Session",tool_call:"Tool call",decision:"Rule",check:"Check",approval:"Approval",output:"Answer",feedback:"Feedback",turn:"Turn",run:"Working",notification:"Notification"};function entryOf(Au){return{uid:String(Au.uid??""),sessionUid:String(Au.session_uid??""),deploymentUid:String(Au.deployment_uid??""),version:Number(Au.version)||0,kind:String(Au.kind??"output"),summary:String(Au.summary??""),payload:Au.payload&&typeof Au.payload=="object"?Au.payload:{},createdAt:String(Au.created_at??"")}}function runEndOf(Au){const lo=Au.kind==="output"?Au.payload.status:void 0;return typeof lo=="string"&&lo in RUN_END_WORDS?lo:""}function entrySaid(Au){return Au.summary||RUN_END_WORDS[runEndOf(Au)]||""}function sessionSentence(Au){const lo=Au.filter(Ou=>Ou.kind==="tool_call").length,$u=Au.filter(Ou=>Ou.kind==="check"),Ru=Au.map(runEndOf).filter(Boolean),Iu=Ru.filter(Ou=>Ou==="answered").length,Pu=[lo===0?"No tool called":`${lo} tool call${lo===1?"":"s"}`];return $u.length&&Pu.push(`${$u.length} step${$u.length===1?"":"s"} a check did not let pass`),Ru[Ru.length-1]==="stopped"?Pu.push("stopped"):Iu&&Pu.push(`${Iu} answer${Iu===1?"":"s"}`),`${Pu.join(", ")}.`}async function read(Au,lo,$u){if(!Au.aiAgentsUrl)throw new Error("The record service is not configured.");const Ru=await fetch(`${Au.aiAgentsUrl.replace(/\/+$/,"")}/api/ai-agents/v1/apps${lo}`,{headers:Au.token?{Authorization:`Bearer ${Au.token}`}:{}}),Iu=await Ru.json().catch(()=>({}));if(!Ru.ok||Iu.success===!1)throw new Error(`${$u}: ${String(Iu.detail??Ru.status)}`);return Iu}async function listSessions(Au,lo,$u=20,Ru=!1){const Iu=await read(Au,`/sessions?app_uid=${encodeURIComponent(lo)}&limit=${$u}${Ru===null?"":`&tests=${Ru}`}`,"The sessions could not be read");return sessionPageOf(Iu)}async function readSession(Au,lo){const $u=await read(Au,`/records?session_uid=${encodeURIComponent(lo)}&limit=500`,"The session could not be read");return Array.isArray($u.entries)?$u.entries.map(entryOf).filter(Ru=>Ru.kind!=="run"):[]}const APP_ACTIVITY_WORDS={title:"Activity",unsaved:"Recorded once it is saved on Datalayer: each session there — its address, or its Preview on Datalayer — is listed here.",signedOut:"Its activity is its owner’s: sign in to Datalayer to read it.",none:"Nothing yet: a session on Datalayer — its address, or the Preview on Datalayer — is recorded here."},NO_TURN$3=signal$2({id:0,status:"idle"});function useRead(Au,lo,$u=!0){const[Ru,Iu]=reactExports.useState({loading:$u});return reactExports.useEffect(()=>{if(!$u)return;let Pu=!1;return Iu(Ou=>({...Ou,loading:!0})),Au().then(Ou=>!Pu&&Iu({value:Ou,loading:!1}),Ou=>!Pu&&Iu({error:Ou instanceof Error?Ou.message:String(Ou),loading:!1})),()=>{Pu=!0}},[lo,$u]),Ru}function Session({context:Au,session:lo}){const[$u,Ru]=reactExports.useState(!1),Iu=useRead(()=>readSession(Au,lo.uid),`${lo.uid}:${Au.token}`,$u),Pu=[sessionStateSaid(lo),sessionAgentSaid(lo),sessionLineageSaid(lo)].filter(Boolean);return jsxRuntimeExports.jsxs(Box,{as:"details",onToggle:Ou=>Ru(Ou.currentTarget.open),borderTop:"1px solid",borderColor:"border.muted",py:2,children:[jsxRuntimeExports.jsxs(Box,{as:"summary",cursor:"pointer",fontSize:1,children:[lo.startedAt?jsxRuntimeExports.jsx(RelativeTime,{datetime:lo.startedAt}):"A session",lo.title?` · ${lo.title}`:"",lo.version?` · version ${lo.version}`:"",Pu.length?` · ${Pu.join(" · ")}`:"",Iu.value?` · ${sessionSentence(Iu.value)}`:""]}),$u?Iu.loading?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):Iu.error?jsxRuntimeExports.jsx(Text$3,{role:"alert",sx:{fontSize:1},children:Iu.error}):jsxRuntimeExports.jsx(Box,{as:"ol",pl:3,mt:2,mb:0,fontSize:1,children:(Iu.value??[]).map(Ou=>jsxRuntimeExports.jsxs(Box,{as:"li",mb:1,children:[jsxRuntimeExports.jsx(Label,{sx:{mr:2},children:RECORD_KIND_WORDS[Ou.kind]??Ou.kind}),entrySaid(Ou)]},Ou.uid))}):null]})}function AppActivity({appUid:Au}){const lo=useIAMStore(ju=>ju.token)??"",$u=useCoreStore(ju=>ju.configuration)?.aiAgentsUrl??"",Ru=useContributions(LoopChatTurn),Iu=useSignalValue$1(Ru[0]?.value.turn??NO_TURN$3),Pu=Iu.status!=="thinking"&&Iu.status!=="streaming",[Ou,Mu]=reactExports.useState(0);reactExports.useEffect(()=>{Pu&&Mu(Iu.id)},[Pu,Iu.id]);const Du={aiAgentsUrl:$u,token:lo},Lu=!!(Au&&lo),Bu=useRead(()=>listSessions(Du,Au??""),`${Au}:${lo}:${$u}:${Ou}`,Lu);return jsxRuntimeExports.jsxs(Box,{"data-testid":"app-activity",children:[jsxRuntimeExports.jsx(Heading$2,{as:"h3",sx:{fontSize:2,mb:2},children:APP_ACTIVITY_WORDS.title}),Au?lo?Bu.loading&&!Bu.value?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):Bu.error?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:Bu.error}):(Bu.value?.sessions??[]).length===0?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.none}):(Bu.value?.sessions??[]).map(ju=>jsxRuntimeExports.jsx(Session,{context:Du,session:ju},ju.uid)):jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.signedOut}):jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.unsaved})]})}const APP_ACTIVITY_PLUGIN_NAME="@datalayer/loop-plugin-app-activity";function defineAppActivityPlugin(Au,lo){function $u(){return jsxRuntimeExports.jsx(AppActivity,{appUid:lo})}return{name:`${APP_ACTIVITY_PLUGIN_NAME}-${Au.id}`,displayName:`${Au.name}: activity`,description:`What ${Au.name} did, session by session, from its record.`,octicon:"pulse",build:()=>({components:[{id:"app-activity",slot:LoopSlots.sidebar,order:20,Component:$u,rail:{label:"Activity",icon:PulseIcon}}]})}}const APP_PANEL_WIDTH=380;function elementsByPlace(Au){const lo=Au.filter($u=>$u.where==="page");return{panels:Au.filter($u=>$u.where==="panel"),page:lo.length>0?lo[lo.length-1]:null}}function ElementBody({element:Au,send:lo}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Au.shows,send:($u,Ru)=>lo!==void 0&&!lo($u,Ru)})}function ElementHeader({element:Au}){return jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:2,children:[jsxRuntimeExports.jsx(Text$3,{as:"h2",sx:{fontSize:2,fontWeight:"bold",m:0},children:Au.title}),jsxRuntimeExports.jsx(IconButton,{icon:XIcon,variant:"invisible",size:"small","aria-label":`Close ${Au.title}`,onClick:()=>closeLoopElement(Au.id)})]})}function AppElements({workspace:Au}){const lo=reactExports.useSyncExternalStore(onLoopElements,openLoopElements,openLoopElements),{panels:$u,page:Ru}=elementsByPlace(lo),Iu=Au?.viewControls.send;return $u.length===0&&Ru===null?null:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[$u.length>0?jsxRuntimeExports.jsx(Box,{as:"aside","aria-label":"Side panel",position:"absolute",top:0,right:0,bottom:0,width:`min(${APP_PANEL_WIDTH}px, 100%)`,zIndex:1,overflowY:"auto",borderLeft:"1px solid",borderColor:"border.default",bg:"canvas.subtle",boxShadow:"shadow.medium",p:3,display:"flex",flexDirection:"column",gap:3,children:$u.map(Pu=>jsxRuntimeExports.jsxs(Box,{as:"section","aria-label":Pu.title,children:[jsxRuntimeExports.jsx(ElementHeader,{element:Pu}),jsxRuntimeExports.jsx(ElementBody,{element:Pu,send:Iu})]},Pu.id))}):null,Ru!==null?jsxRuntimeExports.jsxs(Box,{role:"dialog","aria-label":Ru.title,position:"absolute",inset:0,zIndex:2,overflowY:"auto",bg:"canvas.default",p:[3,4],children:[jsxRuntimeExports.jsx(ElementHeader,{element:Ru}),jsxRuntimeExports.jsx(ElementBody,{element:Ru,send:Iu})]}):null]})}const QUESTION_DISPLAY_TYPE="application/vnd.datalayer.loop.question+json",SchemaForm=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/SchemaForm-C6wDxDrg.js"),[],import.meta.url));function questionOf(Au){const lo=Au.data??{},$u=lo.kind;if(Au.type!==QUESTION_DISPLAY_TYPE||$u!=="text"&&$u!=="choice"&&$u!=="file"&&$u!=="form"||typeof lo.prompt!="string")throw new Error(`Display ${Au.id} is not a question`);const Ru=Iu=>Array.isArray(Iu)?Iu.filter(Pu=>typeof Pu=="string"):[];return{kind:$u,prompt:lo.prompt,options:Ru(lo.options),accept:Ru(lo.accept),form:lo.form&&typeof lo.form=="object"?lo.form:{},answered:typeof lo.answered=="string"?lo.answered:null,answerable:(Au.actions??[]).some(Iu=>Iu.name===ANSWER_ACTION)}}function QuestionView({display:Au,act:lo,upload:$u}){const Ru=questionOf(Au),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(null),Du=Bu=>{if(!lo){Mu("The chat cannot take an answer here.");return}Mu(null),Promise.resolve(lo({action:ANSWER_ACTION,payload:{value:Bu}})).catch(ju=>Mu(ju instanceof Error?ju.message:String(ju)))};if(Ru.answered!==null)return jsxRuntimeExports.jsxs(Text$3,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:["Answered: ",Ru.answered]});const Lu=Ru.answerable&&!!lo;return jsxRuntimeExports.jsxs(Box$1,{display:"flex",flexDirection:"column",gap:2,"data-question-kind":Ru.kind,children:[Ru.kind==="choice"?jsxRuntimeExports.jsx(Box$1,{display:"flex",gap:2,flexWrap:"wrap",children:Ru.options.map(Bu=>jsxRuntimeExports.jsx(ButtonComponent,{size:"small",disabled:!Lu,onClick:()=>Du(Bu),children:Bu},Bu))}):null,Ru.kind==="text"?jsxRuntimeExports.jsxs(Box$1,{as:"form",display:"flex",gap:2,onSubmit:Bu=>{Bu.preventDefault(),Iu.trim()&&Du(Iu.trim())},children:[jsxRuntimeExports.jsx(TextInput$1,{"aria-label":Ru.prompt,value:Iu,disabled:!Lu,onChange:Bu=>Pu(Bu.target.value)}),jsxRuntimeExports.jsx(ButtonComponent,{type:"submit",size:"small",disabled:!Lu||!Iu.trim(),children:"Answer"})]}):null,Ru.kind==="form"?jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(SchemaForm,{schema:Ru.form,disabled:!Lu,onSubmit:({formData:Bu})=>Du(Bu??{})})}):null,Ru.kind==="file"?jsxRuntimeExports.jsx("input",{type:"file","aria-label":Ru.prompt,accept:Ru.accept.join(",")||void 0,disabled:!Lu||!$u,onChange:Bu=>{const ju=Bu.target.files?.[0];if(ju){if(!$u){Mu("The chat cannot take a file here.");return}Mu(null),$u(ju).then(Fu=>Du(Fu)).catch(Fu=>Mu(Fu instanceof Error?Fu.message:String(Fu)))}}}):null,Ou?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{color:"danger.fg",fontSize:1,m:0},children:Ou}):null]})}const APP_ELEMENTS_PLUGIN_NAME="@datalayer/loop-plugin-app-elements",AppElementsPlugin={name:APP_ELEMENTS_PLUGIN_NAME,displayName:"Side panel and pages",description:"What an application opens beside the conversation: a side panel, or a page of its own.",octicon:"sidebar-expand",contributes:[contribution(Renderers,defineRenderer({type:QUESTION_DISPLAY_TYPE,component:QuestionView}),{id:"app-elements:question"})],build:()=>({components:[{id:"app-elements",slot:LoopSlots.root,Component:AppElements}]}),register:()=>clearLoopElements},appComponentsPluginName=Au=>`@datalayer/loop-plugin-app-components-${Au}`,hasCustomComponents=Au=>(Au.interface.customComponents??[]).length>0;function defineAppComponentsPlugin(Au,lo){const $u=Au.interface.customComponents??[];if($u.length===0)throw new Error(`“${Au.name}” has no component of its own to contribute.`);return{name:appComponentsPluginName(Au.id),displayName:`${Au.name}'s components`,description:`The components ${Au.name}'s developer wrote: ${$u.map(Ru=>Ru.name).join(", ")}.`,octicon:"apps",contributes:$u.flatMap(Ru=>[contribution(LoopCanvasBlock,{id:Ru.name,ui:`app:${Au.id}`,component:customComponentEntry(Ru,Au.version)},{id:Ru.name}),contribution(LoopA2uiComponent,{id:Ru.name,app:Au.id,implementation:customImplementation(Ru,Au.version,lo,Au.id)},{id:Ru.name})])}}const COMPUTER_PARTS=["browse","files","shell"],COMPUTER_PART_TOOLS={browse:["open_page","read_page","page_screenshot","click_on_page","type_on_page"],files:["list_computer_files","read_computer_file","write_computer_file"],shell:["execute_code","run_skill_script"]},COMPUTER_WORDS={title:"Computer",part:{browse:"Browse",files:"Files",shell:"Shell"},on:"on",off:"off",none:"It has no computer: browse, files and shell are all off. Turn one on in its permissions to give it one.",offSaid:Au=>`Off, so its agent is given no tool for it: ${Au.join(", ")}.`,browser:"Browser",noBrowser:"No browser is installed on its computer.",noPage:"Its browser has opened no page yet.",pageAlt:Au=>`The page its browser shows: ${Au}`,clickToAct:"Click on the page to click there; with the page selected, what you type goes to it.",typeOnPage:"Text to type on the page",type:"Type",address:"An address to open",open:"Open",scrollUp:"Scroll up",scrollDown:"Scroll down",agentHas:"Its agent has the computer.",youHave:"You have the computer: its agent waits for it until you hand it back.",someoneHas:"Somebody else has taken this computer over.",takeOver:"Take over",handBack:"Hand back",run:"Run",yourCode:"Python to run on its computer",terminal:"What ran on it",nothingRan:"Nothing has run on it yet in this conversation.",files:"Files",notStarted:"Its computer starts when its agent first uses it: no file yet.",emptyDirectory:"Empty.",up:"Up",download:"Download",signedOut:"Its computer is shown once you are signed in to Datalayer."};function computerParts(Au){const lo=Au.permissions?.computer;return{browse:!!lo?.browse,files:!!lo?.files,shell:!!lo?.shell}}const hasComputer=Au=>COMPUTER_PARTS.some(lo=>Au[lo]),partsOff=Au=>COMPUTER_PARTS.filter(lo=>!Au[lo]).map(lo=>COMPUTER_WORDS.part[lo].toLowerCase());function partOf(Au){return COMPUTER_PARTS.find(lo=>COMPUTER_PART_TOOLS[lo].includes(Au))}const OUTPUT_LIMIT=4e3;function outputOf(Au){let lo=Au;if(typeof lo=="string")try{const Ru=JSON.parse(lo);Ru&&typeof Ru=="object"&&!Array.isArray(Ru)&&(lo=Ru)}catch{}let $u;if(lo&&typeof lo=="object"&&!Array.isArray(lo)){const Ru=lo,Iu=[typeof Ru.stdout=="string"?Ru.stdout:Ru.output,Ru.stderr,Ru.error??Ru.execution_error??Ru.code_error].filter(Pu=>typeof Pu=="string"&&Pu.trim()!=="");$u=Iu.length>0?Iu.join(`
|
|
4023
4023
|
`):"stdout"in Ru||"output"in Ru?"":JSON.stringify(lo,null,2)}else $u=typeof lo=="string"?lo:lo==null?"":JSON.stringify(lo,null,2);return $u.length>OUTPUT_LIMIT?`${$u.slice(0,OUTPUT_LIMIT)}
|