@arbidocs/blocks 0.5.47 → 0.5.48
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/{ConnectedCallDock-BXFBFIR4.js → ConnectedCallDock-5OLBZED2.js} +11 -11
- package/dist/{ConnectedCallDock-BXFBFIR4.js.map → ConnectedCallDock-5OLBZED2.js.map} +1 -1
- package/dist/{ConnectedCallDock-XRU6XUBE.cjs → ConnectedCallDock-GHJTVUSQ.cjs} +20 -20
- package/dist/{ConnectedCallDock-XRU6XUBE.cjs.map → ConnectedCallDock-GHJTVUSQ.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-2ZYYSPG6.cjs → ConnectedCallRoom-GVNZ3S6R.cjs} +12 -12
- package/dist/{ConnectedCallRoom-2ZYYSPG6.cjs.map → ConnectedCallRoom-GVNZ3S6R.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-DHVDXEYW.js → ConnectedCallRoom-SSSKBQA7.js} +11 -11
- package/dist/{ConnectedCallRoom-DHVDXEYW.js.map → ConnectedCallRoom-SSSKBQA7.js.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-OXP7S4HV.cjs → ConnectedNativeDocxComparison-7ADU6OGW.cjs} +20 -20
- package/dist/{ConnectedNativeDocxComparison-OXP7S4HV.cjs.map → ConnectedNativeDocxComparison-7ADU6OGW.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-LHM3BDUA.js → ConnectedNativeDocxComparison-GIATDKIH.js} +19 -19
- package/dist/{ConnectedNativeDocxComparison-PQ42LKHG.js.map → ConnectedNativeDocxComparison-GIATDKIH.js.map} +1 -1
- package/dist/{ConnectedNativeDocxEditor-FER3BDN6.cjs → ConnectedNativeDocxEditor-GCVZCWDG.cjs} +19 -19
- package/dist/{ConnectedNativeDocxEditor-FER3BDN6.cjs.map → ConnectedNativeDocxEditor-GCVZCWDG.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxEditor-X5SJEUYZ.js → ConnectedNativeDocxEditor-UQTPB42S.js} +17 -17
- package/dist/{ConnectedNativeDocxEditor-X5SJEUYZ.js.map → ConnectedNativeDocxEditor-UQTPB42S.js.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-OBTR3PPU.cjs → ConnectedStreamedWordArtifact-DUBHCHBP.cjs} +20 -20
- package/dist/ConnectedStreamedWordArtifact-DUBHCHBP.cjs.map +1 -0
- package/dist/{ConnectedNativeDocxComparison-PQ42LKHG.js → ConnectedStreamedWordArtifact-VN5XBWSI.js} +19 -19
- package/dist/ConnectedStreamedWordArtifact-VN5XBWSI.js.map +1 -0
- package/dist/{NativeDocxEditor-D6Z7BXTA.js → NativeDocxEditor-HJTKCPX2.js} +4 -4
- package/dist/{NativeDocxEditor-D6Z7BXTA.js.map → NativeDocxEditor-HJTKCPX2.js.map} +1 -1
- package/dist/{NativeDocxEditor-HE4PQV5F.cjs → NativeDocxEditor-TVZ6O6YS.cjs} +8 -8
- package/dist/{NativeDocxEditor-HE4PQV5F.cjs.map → NativeDocxEditor-TVZ6O6YS.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-B26WOMAL.cjs → WorkspaceTableView-GZ6Y6QCD.cjs} +5 -5
- package/dist/{WorkspaceTableView-B26WOMAL.cjs.map → WorkspaceTableView-GZ6Y6QCD.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-PZR5RYPG.js → WorkspaceTableView-ZI2HDG2R.js} +5 -5
- package/dist/{WorkspaceTableView-PZR5RYPG.js.map → WorkspaceTableView-ZI2HDG2R.js.map} +1 -1
- package/dist/agents/index.cjs +335 -335
- package/dist/agents/index.js +12 -12
- package/dist/calendar/index.cjs +116 -116
- package/dist/calendar/index.js +1 -1
- package/dist/calls/index.cjs +145 -145
- package/dist/calls/index.js +11 -11
- package/dist/chat/index.cjs +148 -148
- package/dist/chat/index.js +7 -7
- package/dist/{chunk-7W7TPWSZ.cjs → chunk-226ILMHW.cjs} +6 -6
- package/dist/{chunk-7W7TPWSZ.cjs.map → chunk-226ILMHW.cjs.map} +1 -1
- package/dist/{chunk-U4HWVCRN.js → chunk-3VCTVCAX.js} +68 -13
- package/dist/chunk-3VCTVCAX.js.map +1 -0
- package/dist/{chunk-5LPPY63C.cjs → chunk-4FIYA764.cjs} +83 -83
- package/dist/{chunk-5LPPY63C.cjs.map → chunk-4FIYA764.cjs.map} +1 -1
- package/dist/{chunk-RGWROTJ2.cjs → chunk-52CWM5AZ.cjs} +4 -4
- package/dist/{chunk-RGWROTJ2.cjs.map → chunk-52CWM5AZ.cjs.map} +1 -1
- package/dist/{chunk-6QHEW2GS.js → chunk-53YTK235.js} +6 -6
- package/dist/{chunk-6QHEW2GS.js.map → chunk-53YTK235.js.map} +1 -1
- package/dist/{chunk-SYP2A4GQ.js → chunk-5RYZUX5L.js} +3 -3
- package/dist/{chunk-SYP2A4GQ.js.map → chunk-5RYZUX5L.js.map} +1 -1
- package/dist/{chunk-EZJOJFY2.cjs → chunk-5WV7HI7Y.cjs} +6 -6
- package/dist/{chunk-EZJOJFY2.cjs.map → chunk-5WV7HI7Y.cjs.map} +1 -1
- package/dist/{chunk-OMYWRLV5.js → chunk-6D3XKIEB.js} +8 -8
- package/dist/{chunk-OMYWRLV5.js.map → chunk-6D3XKIEB.js.map} +1 -1
- package/dist/{chunk-S3YRRD54.js → chunk-6GI3S7TN.js} +3 -3
- package/dist/{chunk-S3YRRD54.js.map → chunk-6GI3S7TN.js.map} +1 -1
- package/dist/{chunk-HV7XHZLW.cjs → chunk-6R5Q65PB.cjs} +4 -4
- package/dist/{chunk-HV7XHZLW.cjs.map → chunk-6R5Q65PB.cjs.map} +1 -1
- package/dist/{chunk-WIW3XGHO.js → chunk-75Z5AUMM.js} +3 -3
- package/dist/{chunk-WIW3XGHO.js.map → chunk-75Z5AUMM.js.map} +1 -1
- package/dist/{chunk-C5ZP4CEQ.js → chunk-7G4N2HP7.js} +4 -4
- package/dist/{chunk-C5ZP4CEQ.js.map → chunk-7G4N2HP7.js.map} +1 -1
- package/dist/{chunk-WDMWWBPB.cjs → chunk-7KIM64LQ.cjs} +9 -9
- package/dist/{chunk-WDMWWBPB.cjs.map → chunk-7KIM64LQ.cjs.map} +1 -1
- package/dist/{chunk-H5XHCIWY.js → chunk-7P24MJQN.js} +3 -3
- package/dist/{chunk-H5XHCIWY.js.map → chunk-7P24MJQN.js.map} +1 -1
- package/dist/{chunk-CXY2ELL5.js → chunk-7QJNWQ7O.js} +4 -4
- package/dist/{chunk-CXY2ELL5.js.map → chunk-7QJNWQ7O.js.map} +1 -1
- package/dist/{chunk-GWQRGLA7.js → chunk-A54WLQQA.js} +5 -5
- package/dist/{chunk-GWQRGLA7.js.map → chunk-A54WLQQA.js.map} +1 -1
- package/dist/{chunk-7LN3ISPG.js → chunk-A7MWHMHP.js} +4 -3
- package/dist/chunk-A7MWHMHP.js.map +1 -0
- package/dist/{chunk-ORFP3QJQ.js → chunk-AEXFUPO7.js} +3 -3
- package/dist/{chunk-ORFP3QJQ.js.map → chunk-AEXFUPO7.js.map} +1 -1
- package/dist/{chunk-E5RN3LWS.js → chunk-AWVGKHJT.js} +2 -2
- package/dist/{chunk-E5RN3LWS.js.map → chunk-AWVGKHJT.js.map} +1 -1
- package/dist/{chunk-N3HSMPMY.cjs → chunk-BB4PMCU6.cjs} +14 -14
- package/dist/{chunk-N3HSMPMY.cjs.map → chunk-BB4PMCU6.cjs.map} +1 -1
- package/dist/{chunk-NIA4H7QN.js → chunk-BTTUZZN3.js} +3 -3
- package/dist/{chunk-NIA4H7QN.js.map → chunk-BTTUZZN3.js.map} +1 -1
- package/dist/{chunk-ASY4F546.js → chunk-CGHFFYOL.js} +3 -3
- package/dist/{chunk-ASY4F546.js.map → chunk-CGHFFYOL.js.map} +1 -1
- package/dist/{chunk-FV32BTXV.cjs → chunk-CKNUL4LM.cjs} +4 -4
- package/dist/{chunk-FV32BTXV.cjs.map → chunk-CKNUL4LM.cjs.map} +1 -1
- package/dist/{chunk-P6HVJP6Z.cjs → chunk-DLHAKRU2.cjs} +6 -5
- package/dist/chunk-DLHAKRU2.cjs.map +1 -0
- package/dist/{chunk-DCA4R3EU.js → chunk-E6EYRQC2.js} +3 -3
- package/dist/{chunk-DCA4R3EU.js.map → chunk-E6EYRQC2.js.map} +1 -1
- package/dist/{chunk-YWGDZR6A.cjs → chunk-E6FNC5PN.cjs} +7 -7
- package/dist/{chunk-YWGDZR6A.cjs.map → chunk-E6FNC5PN.cjs.map} +1 -1
- package/dist/{chunk-WZGSEQQX.js → chunk-EARQ2CUX.js} +4 -4
- package/dist/{chunk-WZGSEQQX.js.map → chunk-EARQ2CUX.js.map} +1 -1
- package/dist/{chunk-GNJ2NCS6.js → chunk-EXE3RBDZ.js} +4 -4
- package/dist/{chunk-GNJ2NCS6.js.map → chunk-EXE3RBDZ.js.map} +1 -1
- package/dist/{chunk-F2IAC4UE.cjs → chunk-FYL7IGK2.cjs} +31 -31
- package/dist/{chunk-F2IAC4UE.cjs.map → chunk-FYL7IGK2.cjs.map} +1 -1
- package/dist/{chunk-WDR6FO22.cjs → chunk-GKHIRR5A.cjs} +5 -5
- package/dist/{chunk-WDR6FO22.cjs.map → chunk-GKHIRR5A.cjs.map} +1 -1
- package/dist/{chunk-SI222Z3A.cjs → chunk-GMM3RBIB.cjs} +71 -11
- package/dist/chunk-GMM3RBIB.cjs.map +1 -0
- package/dist/{chunk-EHRT5M5F.js → chunk-GXJIN7G3.js} +4 -4
- package/dist/{chunk-EHRT5M5F.js.map → chunk-GXJIN7G3.js.map} +1 -1
- package/dist/{chunk-B3NYBMDR.cjs → chunk-I72IYIO2.cjs} +21 -55
- package/dist/chunk-I72IYIO2.cjs.map +1 -0
- package/dist/{chunk-TKTNXFAB.js → chunk-IDFAMK2G.js} +6 -6
- package/dist/{chunk-TKTNXFAB.js.map → chunk-IDFAMK2G.js.map} +1 -1
- package/dist/{chunk-XJA6TS6D.js → chunk-IKZWEPG4.js} +3 -3
- package/dist/{chunk-XJA6TS6D.js.map → chunk-IKZWEPG4.js.map} +1 -1
- package/dist/{chunk-7MSBEMOG.cjs → chunk-IOPGY3IP.cjs} +22 -22
- package/dist/{chunk-7MSBEMOG.cjs.map → chunk-IOPGY3IP.cjs.map} +1 -1
- package/dist/{chunk-WKHREKPY.js → chunk-JGFBC66V.js} +5 -5
- package/dist/{chunk-WKHREKPY.js.map → chunk-JGFBC66V.js.map} +1 -1
- package/dist/{chunk-QG7XCD5U.js → chunk-JGKPF3QV.js} +3 -3
- package/dist/{chunk-QG7XCD5U.js.map → chunk-JGKPF3QV.js.map} +1 -1
- package/dist/{chunk-NE7M6NJY.js → chunk-JOK2TJLY.js} +3 -3
- package/dist/{chunk-NE7M6NJY.js.map → chunk-JOK2TJLY.js.map} +1 -1
- package/dist/{chunk-YNFHWUFM.cjs → chunk-JYR55F3P.cjs} +27 -26
- package/dist/chunk-JYR55F3P.cjs.map +1 -0
- package/dist/{chunk-QZUZPC4J.js → chunk-KOOC6VD3.js} +18 -47
- package/dist/chunk-KOOC6VD3.js.map +1 -0
- package/dist/{chunk-FGVQIKOG.cjs → chunk-KZMEZYT6.cjs} +4 -4
- package/dist/{chunk-FGVQIKOG.cjs.map → chunk-KZMEZYT6.cjs.map} +1 -1
- package/dist/{chunk-5YNULK5L.cjs → chunk-MBGV6JHG.cjs} +9 -9
- package/dist/{chunk-5YNULK5L.cjs.map → chunk-MBGV6JHG.cjs.map} +1 -1
- package/dist/{chunk-EY3PBYRT.js → chunk-NIH2QCPE.js} +4 -4
- package/dist/{chunk-EY3PBYRT.js.map → chunk-NIH2QCPE.js.map} +1 -1
- package/dist/{chunk-UHYO2E25.js → chunk-NQA6P7XB.js} +4 -4
- package/dist/{chunk-UHYO2E25.js.map → chunk-NQA6P7XB.js.map} +1 -1
- package/dist/{chunk-73DANGPH.js → chunk-NXSGOC2M.js} +3 -3
- package/dist/{chunk-73DANGPH.js.map → chunk-NXSGOC2M.js.map} +1 -1
- package/dist/{chunk-ZBEWAE34.js → chunk-O4LORAFC.js} +10 -9
- package/dist/chunk-O4LORAFC.js.map +1 -0
- package/dist/{chunk-VHLMMXXE.js → chunk-OLMM6MPQ.js} +3 -3
- package/dist/{chunk-VHLMMXXE.js.map → chunk-OLMM6MPQ.js.map} +1 -1
- package/dist/{chunk-5R256EMF.cjs → chunk-PFJSYJ34.cjs} +39 -39
- package/dist/{chunk-5R256EMF.cjs.map → chunk-PFJSYJ34.cjs.map} +1 -1
- package/dist/{chunk-Z6DNYFVM.cjs → chunk-PICGTGEB.cjs} +3 -3
- package/dist/{chunk-Z6DNYFVM.cjs.map → chunk-PICGTGEB.cjs.map} +1 -1
- package/dist/{chunk-G7QBA27G.js → chunk-PP3LWBIH.js} +4 -4
- package/dist/{chunk-G7QBA27G.js.map → chunk-PP3LWBIH.js.map} +1 -1
- package/dist/{chunk-DWWRLKEZ.cjs → chunk-QK3SHV3F.cjs} +4 -4
- package/dist/{chunk-DWWRLKEZ.cjs.map → chunk-QK3SHV3F.cjs.map} +1 -1
- package/dist/{chunk-AE3QELMB.cjs → chunk-QKOFQMAY.cjs} +4 -4
- package/dist/{chunk-AE3QELMB.cjs.map → chunk-QKOFQMAY.cjs.map} +1 -1
- package/dist/{chunk-EGSSLWNZ.cjs → chunk-QPZDJVNY.cjs} +4 -4
- package/dist/{chunk-EGSSLWNZ.cjs.map → chunk-QPZDJVNY.cjs.map} +1 -1
- package/dist/chunk-QQMZ7XKU.cjs +18 -0
- package/dist/{chunk-36RSQCKH.cjs.map → chunk-QQMZ7XKU.cjs.map} +1 -1
- package/dist/{chunk-SEZEEHLU.js → chunk-QRQLQKRW.js} +3 -3
- package/dist/{chunk-SEZEEHLU.js.map → chunk-QRQLQKRW.js.map} +1 -1
- package/dist/{chunk-Y42LJ4TF.cjs → chunk-SWGQUHMF.cjs} +5 -5
- package/dist/{chunk-Y42LJ4TF.cjs.map → chunk-SWGQUHMF.cjs.map} +1 -1
- package/dist/{chunk-QTIAO2AH.cjs → chunk-TQYEHARI.cjs} +5 -5
- package/dist/{chunk-QTIAO2AH.cjs.map → chunk-TQYEHARI.cjs.map} +1 -1
- package/dist/{chunk-KFQ6E6LE.cjs → chunk-V2UQR7P6.cjs} +4 -4
- package/dist/{chunk-KFQ6E6LE.cjs.map → chunk-V2UQR7P6.cjs.map} +1 -1
- package/dist/{chunk-HDEOORSV.cjs → chunk-V5QAXGGT.cjs} +6 -6
- package/dist/{chunk-HDEOORSV.cjs.map → chunk-V5QAXGGT.cjs.map} +1 -1
- package/dist/{chunk-5TFI4YW2.js → chunk-VFSHI7IX.js} +3 -3
- package/dist/{chunk-5TFI4YW2.js.map → chunk-VFSHI7IX.js.map} +1 -1
- package/dist/{chunk-X6MGM3LH.cjs → chunk-VODFB3K2.cjs} +4 -4
- package/dist/{chunk-X6MGM3LH.cjs.map → chunk-VODFB3K2.cjs.map} +1 -1
- package/dist/{chunk-3XUF6FS3.cjs → chunk-VQHXVY26.cjs} +6 -6
- package/dist/{chunk-3XUF6FS3.cjs.map → chunk-VQHXVY26.cjs.map} +1 -1
- package/dist/{chunk-LM7DVT7C.cjs → chunk-W3PSIIMN.cjs} +2 -2
- package/dist/{chunk-LM7DVT7C.cjs.map → chunk-W3PSIIMN.cjs.map} +1 -1
- package/dist/{chunk-PPHUOWCJ.js → chunk-XBITXJZU.js} +3 -3
- package/dist/{chunk-PPHUOWCJ.js.map → chunk-XBITXJZU.js.map} +1 -1
- package/dist/chunk-XHHDVSYY.cjs +18 -0
- package/dist/{chunk-3QPQEX2X.cjs.map → chunk-XHHDVSYY.cjs.map} +1 -1
- package/dist/{chunk-X2AIPVIT.cjs → chunk-YD3RN2FY.cjs} +3 -3
- package/dist/{chunk-X2AIPVIT.cjs.map → chunk-YD3RN2FY.cjs.map} +1 -1
- package/dist/{chunk-VQAAU32B.js → chunk-YRORPDIY.js} +3 -3
- package/dist/{chunk-VQAAU32B.js.map → chunk-YRORPDIY.js.map} +1 -1
- package/dist/{chunk-BRYHW3OL.cjs → chunk-YTB6DLAD.cjs} +4 -4
- package/dist/{chunk-BRYHW3OL.cjs.map → chunk-YTB6DLAD.cjs.map} +1 -1
- package/dist/{chunk-UEORRV5P.cjs → chunk-ZXHGPTAZ.cjs} +11 -11
- package/dist/{chunk-UEORRV5P.cjs.map → chunk-ZXHGPTAZ.cjs.map} +1 -1
- package/dist/citations/index.cjs +11 -11
- package/dist/citations/index.js +3 -3
- package/dist/connect/docx.cjs +23 -23
- package/dist/connect/docx.js +19 -19
- package/dist/connect/index.cjs +1100 -1100
- package/dist/connect/index.js +44 -44
- package/dist/connect/viewer.cjs +94 -94
- package/dist/connect/viewer.js +19 -19
- package/dist/document-tools/index.cjs +17 -17
- package/dist/document-tools/index.js +2 -2
- package/dist/docx/index.cjs +51 -51
- package/dist/docx/index.js +4 -4
- package/dist/facts/index.cjs +60 -60
- package/dist/facts/index.js +7 -7
- package/dist/files/index.cjs +238 -238
- package/dist/files/index.js +6 -6
- package/dist/home/index.cjs +32 -32
- package/dist/home/index.js +7 -7
- package/dist/index.cjs +783 -783
- package/dist/index.js +26 -26
- package/dist/provider/dialog-registry.d.ts +2 -0
- package/dist/retrieval/index.cjs +5 -5
- package/dist/retrieval/index.js +3 -3
- package/dist/settings/index.cjs +5 -5
- package/dist/settings/index.js +3 -3
- package/dist/shell/index.cjs +38 -38
- package/dist/shell/index.js +4 -4
- package/dist/site/index.cjs +21 -21
- package/dist/site/index.js +1 -1
- package/dist/studio/index.cjs +18 -18
- package/dist/studio/index.js +10 -10
- package/dist/workflow-canvas/index.cjs +32 -32
- package/dist/workflow-canvas/index.js +14 -14
- package/dist/workspaces/index.cjs +30 -30
- package/dist/workspaces/index.js +5 -5
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ConnectedStreamedWordArtifact-LHM3BDUA.js.map +0 -1
- package/dist/ConnectedStreamedWordArtifact-OBTR3PPU.cjs.map +0 -1
- package/dist/chunk-36RSQCKH.cjs +0 -18
- package/dist/chunk-3QPQEX2X.cjs +0 -18
- package/dist/chunk-7LN3ISPG.js.map +0 -1
- package/dist/chunk-B3NYBMDR.cjs.map +0 -1
- package/dist/chunk-P6HVJP6Z.cjs.map +0 -1
- package/dist/chunk-QZUZPC4J.js.map +0 -1
- package/dist/chunk-SI222Z3A.cjs.map +0 -1
- package/dist/chunk-U4HWVCRN.js.map +0 -1
- package/dist/chunk-YNFHWUFM.cjs.map +0 -1
- package/dist/chunk-ZBEWAE34.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/ConnectionProvider.tsx"],"names":["login"],"mappings":";;;;;;AA4EA,IAAM,iBAAA,GAAoB,cAAsC,IAAI,CAAA;AAQpE,IAAM,wBAAA,GAA2B,wBAAA;AACjC,IAAM,mBAAmB,CAAC,KAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,WAAA,EAAY;AAG9D,IAAM,mBAAA,GAAsB,CAAC,MAAA,EAAgB,OAAA,KAClD,CAAA,EAAG,wBAAwB,CAAA,CAAA,EAAI,MAAA,IAAU,MAAM,CAAA,CAAA,EAAI,gBAAA,CAAiB,OAAO,CAAC,CAAA,CAAA;AAG9E,IAAM,4BAA4B,CAAC,MAAA,KACjC,GAAG,wBAAwB,CAAA,CAAA,EAAI,UAAU,MAAM,CAAA,CAAA;AAEjD,SAAS,sBAAA,CAAuB,QAAgB,OAAA,EAAuC;AACrF,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AACrB,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,YAAA,CAAa,OAAA,CAAQ,mBAAA,CAAoB,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,EACzE,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,gBAAA,CAAiB,MAAA,EAAgB,OAAA,EAAwB,EAAA,EAAyB;AACzF,EAAA,IAAI,CAAC,OAAA,EAAS;AACd,EAAA,IAAI;AACF,IAAA,IAAI,EAAA,SAAW,YAAA,CAAa,OAAA,CAAQ,oBAAoB,MAAA,EAA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UAAA,EAAY,kBAAA,EAAoB,IAAA,EAAM,SAAS,aAAa;AAAA,GAC/D;AACF","file":"chunk-7LN3ISPG.js","sourcesContent":["/**\n * The demo/live connection layer for a host app. Holds auth + workspace\n * selection state and exposes it via {@link useConnection}, so every surface\n * works identically whether it's talking to a live ARBI backend or the seeded\n * demo workspace. Host-specific values (backend URL, demo identity, default\n * workspace/assistant ids) arrive once through {@link ArbiConnectionConfig}.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport {\n arbiAccountClient,\n clearSealedDrafts,\n toProfileView,\n useArbi,\n useArbiSessionState,\n useArbiSessionStore,\n useSwitchWorkspace,\n type AccountClient,\n type LoginProfile,\n type ProfileView,\n} from '@arbidocs/react'\nimport type { ArbiMode, ArbiUser, ConnectionStatus, ArbiConnectionConfig } from './types'\nimport { useBlocksEnvironment } from '../provider/environment'\nimport { ArbiHost } from '../provider/host'\nimport { closeAllDialogs } from '../provider/dialog-registry'\n\ninterface ConnectionValue {\n mode: ArbiMode\n status: ConnectionStatus\n user: ArbiUser | null\n /** The selected workspace: the session state's (`useArbiSessionState`), set by `setWorkspace`. */\n workspaceId: string | null\n apiConfigured: boolean\n apiUrl: string\n /**\n * The deployment domain the user's keys are derived for (`arbi.getDeploymentDomain()`), for the\n * document tools' e-signing. `undefined` in demo mode.\n */\n deploymentDomain: string | undefined\n error: string | null\n /** Default assistant config ext_id (for the AI hooks). */\n assistantConfig?: string\n /**\n * The demo's workspace when none is selected. Never set signed in to a live backend: there the\n * selection is the only workspace (none while a switch is in flight), never a remembered one.\n */\n fallbackWorkspaceId?: string\n /** Authenticate. Live login when a backend is configured, otherwise the demo workspace. */\n login: (email: string, password: string) => Promise<void>\n /** One-click demo entry (no backend required). */\n enterDemo: () => void\n logout: () => void\n /**\n * Affirmatively select a workspace: opens it on the server (via the SDK),\n * updates the app-wide state, and persists the choice so it survives future\n * logins. This is the single entry point for \"the user is now in workspace X\".\n */\n setWorkspace: (id: string) => Promise<void>\n /**\n * Re-assert the selected workspace on the server session (idempotent `/open`).\n * Call before a workspace-scoped write when the session may have lost its open\n * workspace (token re-login, backend restart, session expiry) — the server\n * resolves the workspace from the session, so a dropped `/open` yields\n * \"No active workspace\" until it's re-opened.\n */\n ensureWorkspaceOpen: () => Promise<void>\n}\n\nconst ConnectionContext = createContext<ConnectionValue | null>(null)\n\n/**\n * Persist the affirmatively-selected workspace per backend AND per signed-in user, so a returning\n * user lands back in the workspace they last chose, while the next person on a shared browser\n * never starts from someone else's workspace id. Namespaced by apiUrl so distinct deployments\n * (and the demo workspace) don't clobber each other. Cleared on logout.\n */\nconst WORKSPACE_STORAGE_PREFIX = 'arbi:selectedWorkspace'\nconst normalizeUserKey = (email: string) => email.trim().toLowerCase()\n\n/** Exported for tests. */\nexport const workspaceStorageKey = (apiUrl: string, userKey: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}:${normalizeUserKey(userKey)}`\n\n/** The pre-isolation key (apiUrl only). Never read: removed so it cannot leak across users. */\nconst legacyWorkspaceStorageKey = (apiUrl: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}`\n\nfunction readPersistedWorkspace(apiUrl: string, userKey: string | null): string | null {\n if (!userKey) return null\n try {\n return window.localStorage.getItem(workspaceStorageKey(apiUrl, userKey))\n } catch {\n return null\n }\n}\n\nfunction persistWorkspace(apiUrl: string, userKey: string | null, id: string | null): void {\n if (!userKey) return\n try {\n if (id) window.localStorage.setItem(workspaceStorageKey(apiUrl, userKey), id)\n else window.localStorage.removeItem(workspaceStorageKey(apiUrl, userKey))\n window.localStorage.removeItem(legacyWorkspaceStorageKey(apiUrl))\n } catch {\n // Storage unavailable (private mode, SSR) — selection stays in-memory only.\n }\n}\n\n/** Shown on the sign-in screen after the session could not be recovered. */\nexport const SESSION_EXPIRED_MESSAGE = 'Your session expired. Sign in again.'\n\n/** The connection user for a profile: its full name, falling back to the email local part. */\nfunction userFromProfile(profile: LoginProfile, externalId?: string): ArbiUser {\n const fullName = [profile.givenName, profile.familyName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ')\n return {\n name: fullName || profile.email.split('@')[0],\n email: profile.email,\n externalId,\n picture: profile.picture,\n }\n}\n\n/**\n * The sign-in layer of a blocks-only site, mounted by its host (`defaultHost`): login, demo mode\n * and the selected workspace, over the host's session state (the selected workspace lives there,\n * so every block reads one value). Its account client is the host's `account` below it.\n */\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\n const session = useArbiSessionStore()\n const { switchWorkspace, openSelectedWorkspace, settled } = useSwitchWorkspace()\n const isLiveConfigured = config.apiUrl.length > 0\n const demoWorkspaceId = config.demoWorkspaceId ?? 'demo-workspace'\n\n const [status, setStatus] = useState<ConnectionStatus>(\n isLiveConfigured ? 'connecting' : 'disconnected'\n )\n const [user, setUser] = useState<ArbiUser | null>(null)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const selectWorkspaceId = session.setWorkspaceId\n const [mode, setMode] = useState<ArbiMode>('demo')\n const [error, setError] = useState<string | null>(null)\n // Dialogs belong to the signed-in session. A first signed-out mount may carry an invitation\n // intent, so clear only after an authenticated (or demo) session actually ends. A workspace\n // switch / sign-in can pass through `connecting` without ending that session.\n const hadDialogSession = useRef(false)\n useEffect(() => {\n if (status === 'authenticated' || status === 'demo') {\n hadDialogSession.current = true\n } else if (status !== 'connecting' && hadDialogSession.current) {\n hadDialogSession.current = false\n closeAllDialogs()\n }\n }, [status])\n // Who the persisted workspace belongs to; set at sign-in, cleared at logout.\n const storageUserRef = useRef<string | null>(null)\n // Moves at each logout: a sign-in still finishing from before it does not sign back in.\n const sessionRun = useRef(0)\n\n // The SDK could not recover the session (token refused, workspace not re-openable): drop to\n // 'disconnected' with a plain message, so the host's gate sends the user to sign in instead of\n // every call failing with a raw backend error. The remembered workspace is kept for next login.\n useEffect(\n () =>\n arbi.onSessionExpired?.(() => {\n storageUserRef.current = null\n setUser(null)\n selectWorkspaceId(null)\n setStatus('disconnected')\n setError(SESSION_EXPIRED_MESSAGE)\n }),\n [arbi, selectWorkspaceId]\n )\n\n // A saved name, picture or email reaches every surface reading `useConnection().user`.\n useEffect(\n () =>\n arbi.user.onProfileChange?.((profile) =>\n setUser((current) => (current ? userFromProfile(profile, current.externalId) : current))\n ),\n [arbi]\n )\n\n const enterDemo = useCallback(() => {\n setMode('demo')\n setStatus('demo')\n setError(null)\n setUser({ name: config.demoUser.name, email: config.demoUser.email })\n selectWorkspaceId(demoWorkspaceId)\n }, [config.demoUser.name, config.demoUser.email, demoWorkspaceId, selectWorkspaceId])\n\n /**\n * The session signed in, by whatever path (`login` below, a sign-in page on the host's `Arbi`,\n * a restored session): open the user's workspace and resolve who they are.\n */\n const completeSignIn = useCallback(\n async (email: string) => {\n const run = sessionRun.current\n const signedOut = () => run !== sessionRun.current\n setMode('live')\n setStatus('connecting')\n setError(null)\n try {\n storageUserRef.current = normalizeUserKey(email)\n const workspaces = await arbi.workspaces.list()\n if (workspaces?.length) {\n // Prefer the workspace the user last affirmatively selected (persisted),\n // then the configured workspace (there may be several — e.g. a\n // marketing/KM workspace), then whichever happens to be first. Ternary\n // (not `&&`) so an empty value can't leak `\"\"` into `target`.\n const persisted = readPersistedWorkspace(config.apiUrl, storageUserRef.current)\n const preferred = persisted ?? config.workspaceId\n const target =\n (preferred ? workspaces.find((w) => w.external_id === preferred) : undefined) ??\n workspaces[0]\n selectWorkspaceId(target.external_id)\n if (!(await openSelectedWorkspace()))\n throw new Error('Could not open your workspace. Try signing in again.')\n persistWorkspace(config.apiUrl, storageUserRef.current, target.external_id)\n }\n // The profile (name + avatar) comes with the login response. A session restored without\n // a login has none, so fall back to finding ourselves in the workspace roster; the email\n // local part is only the last resort, never the answer when a profile name exists.\n let resolved: ArbiUser = { name: email.split('@')[0], email }\n const me = arbi.user.identity()\n const profile = arbi.user.profile?.()\n if (profile) {\n resolved = userFromProfile(profile, me?.externalId)\n } else {\n try {\n const members = await arbi.workspaces.listUsers()\n const self = members.find((m) => m.user.external_id === me?.externalId)?.user\n if (self) {\n const fullName = [self.given_name, self.family_name].filter(Boolean).join(' ').trim()\n resolved = {\n name: fullName || email.split('@')[0],\n email: self.email || email,\n externalId: self.external_id,\n picture: self.picture ?? null,\n }\n } else if (me?.externalId) {\n resolved.externalId = me.externalId\n }\n } catch {\n // Roster not available (e.g. no workspace) — keep the fallback identity.\n }\n }\n if (signedOut()) return\n setUser(resolved)\n setStatus('authenticated')\n } catch (e) {\n if (signedOut()) return\n // Surface the real error — no silent fallback to a fake session.\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, config.workspaceId, config.apiUrl, selectWorkspaceId, openSelectedWorkspace]\n )\n\n // Every sign-in on the host's `Arbi` lands here, whichever page or kit made it.\n const signingIn = useRef<Promise<void>>(Promise.resolve())\n useEffect(\n () =>\n arbi.onSignedIn?.((login) => {\n signingIn.current = completeSignIn(\n login.profile?.email ??\n arbi.session?.getState().userEmail ??\n arbi.user.identity()?.email ??\n ''\n )\n }),\n [arbi, completeSignIn]\n )\n\n /** Authenticate: a live login when a backend is configured, otherwise the demo workspace. */\n const login = useCallback(\n async (email: string, password: string) => {\n setError(null)\n if (!isLiveConfigured) {\n enterDemo()\n return\n }\n setStatus('connecting')\n setMode('live')\n try {\n // Signed in: `completeSignIn` follows (onSignedIn); done once it is.\n await arbi.login(email, password)\n await signingIn.current\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, enterDemo, isLiveConfigured]\n )\n\n // The session kept on this device signs in again (no password; the key stays encrypted on the\n // device). Run once even under StrictMode.\n const restoreStarted = useRef(false)\n useEffect(() => {\n if (restoreStarted.current || !isLiveConfigured) return\n restoreStarted.current = true\n arbi\n .restore()\n .catch(() => false)\n .then(async (restored) => {\n if (restored) await signingIn.current\n else setStatus('disconnected')\n })\n }, [arbi, isLiveConfigured])\n\n const logout = useCallback(() => {\n sessionRun.current++\n // The SDK stops the session's work (requests, re-logins, opens, the queries in flight) before\n // the server revokes the token.\n if (mode === 'live') {\n void arbi.logout?.()\n }\n // What was typed never outlives the session (it is sealed, but kept for no one now).\n clearSealedDrafts()\n setUser(null)\n selectWorkspaceId(null)\n persistWorkspace(config.apiUrl, storageUserRef.current, null)\n storageUserRef.current = null\n setStatus('disconnected')\n setError(null)\n }, [arbi, mode, config.apiUrl, selectWorkspaceId])\n\n // Affirmative selection: the shared workspace switch (live), then remember it so the next\n // login lands there too. This provider IS the host's navigation, so it alone (with sign-in and\n // ensureWorkspaceOpen, which re-open the host's own selection) changes the workspace; kits reach\n // another workspace with `arbi.workspaces.open`.\n const setWorkspace = useCallback(\n async (id: string) => {\n if (mode === 'live' && arbi.isLoggedIn) {\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n } else {\n selectWorkspaceId(id)\n }\n persistWorkspace(config.apiUrl, storageUserRef.current, id)\n },\n [arbi, mode, config.apiUrl, selectWorkspaceId, switchWorkspace]\n )\n\n // Re-open the selected workspace on the session if the server may have dropped it. Idempotent.\n // A switch in flight is waited out first, then only the selection as of then is opened (none:\n // nothing). Never a remembered or configured workspace: kits call this before reading, and\n // opening another workspace than the selected one would leave the server session in it.\n const ensureWorkspaceOpen = useCallback(async () => {\n if (mode !== 'live' || !arbi.isLoggedIn) return\n await settled()\n if (!session.getState().workspaceId) return\n await openSelectedWorkspace()\n }, [arbi, session, mode, settled, openSelectedWorkspace])\n\n const value = useMemo<ConnectionValue>(\n () => ({\n mode,\n status,\n user,\n workspaceId,\n apiConfigured: isLiveConfigured,\n apiUrl: config.apiUrl,\n deploymentDomain: isLiveConfigured ? arbi.getDeploymentDomain() : undefined,\n error,\n assistantConfig: config.assistantConfig,\n fallbackWorkspaceId: mode === 'live' ? undefined : config.workspaceId,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n }),\n [\n mode,\n status,\n user,\n workspaceId,\n isLiveConfigured,\n config.apiUrl,\n arbi,\n config.assistantConfig,\n config.workspaceId,\n error,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n ]\n )\n\n const account = useConnectionAccount(arbi, user, logout)\n const authenticated = status === 'authenticated'\n const host = useMemo(\n () => ({ account: { client: account, useEnabled: () => authenticated } }),\n [account, authenticated]\n )\n\n return (\n <ConnectionContext.Provider value={value}>\n <ArbiHost config={host}>{children}</ArbiHost>\n </ConnectionContext.Provider>\n )\n}\n\n/**\n * The account client of the settings blocks below: the SDK's, with sign-out going through this\n * connection (so its state is cleared too) and, for a session restored without a login (no SDK\n * profile), the connection user as the profile.\n */\nfunction useConnectionAccount(\n arbi: ReturnType<typeof useArbi>,\n user: ArbiUser | null,\n logout: () => void\n): AccountClient {\n const userRef = useRef(user)\n const logoutRef = useRef(logout)\n logoutRef.current = logout\n const listeners = useRef(new Set<() => void>())\n useEffect(() => {\n userRef.current = user\n listeners.current.forEach((listener) => listener())\n }, [user])\n return useMemo(() => {\n const base = arbiAccountClient(arbi)\n return {\n ...base,\n profile: (): ProfileView | null => {\n const own = base.profile()\n const fallback = userRef.current\n if (own || !fallback) return own\n return {\n ...toProfileView({\n givenName: '',\n familyName: null,\n picture: fallback.picture ?? null,\n email: fallback.email,\n isSso: false,\n }),\n fullName: fallback.name,\n }\n },\n onProfileChange: (listener) => {\n listeners.current.add(listener)\n const off = base.onProfileChange(listener)\n return () => {\n listeners.current.delete(listener)\n off()\n }\n },\n signOut: async ({ everywhere } = {}) => {\n try {\n if (everywhere) await arbi.sessions.logoutAll()\n } finally {\n logoutRef.current()\n }\n },\n }\n }, [arbi])\n}\n\n/** The sign-in layer of `defaultHost`, or null under a host that keeps its own session. */\nexport function useOptionalConnection(): ConnectionValue | null {\n return useContext(ConnectionContext)\n}\n\nexport function useConnection(): ConnectionValue {\n const ctx = useContext(ConnectionContext)\n if (!ctx) throw new Error('useConnection needs the sign-in layer of `defaultHost` above it')\n return ctx\n}\n\nexport const isAuthenticated = (s: ConnectionStatus) => s === 'demo' || s === 'authenticated'\n\n/** The open workspace as the connected kits see it, whoever hosts them. */\nexport interface ConnectedWorkspace {\n /** The selected workspace (the session state's; with a connection, else its fallback). */\n workspaceId: string | null\n /** Signed in to a live backend: workspace-scoped queries may run. */\n live: boolean\n /** The signed-in user (their name and email, e.g. to sign a document). */\n user: ArbiUser | null\n /** The signed-in user's external id. */\n userId: string | undefined\n /** Re-assert the workspace on the server session before a workspace-scoped write. */\n ensureWorkspaceOpen: () => Promise<void>\n /**\n * Go into a workspace: select it (with a connection) and show it (`BlocksEnvironment.\n * openWorkspace`, where a host without a connection also switches its session).\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => Promise<void>\n}\n\nconst keptOpenByHost = async () => {}\n\n/** The signed-in user of a host's own session, from its login profile. */\nfunction sessionUser(arbi: ReturnType<typeof useArbi>): ArbiUser | null {\n if (!arbi.isLoggedIn) return null\n const me = arbi.user.identity()\n const profile = arbi.user.profile()\n if (!me) return null\n return profile\n ? userFromProfile(profile, me.externalId)\n : { name: (me.email ?? '').split('@')[0], email: me.email ?? '', externalId: me.externalId }\n}\n\n/**\n * The workspace for a connected kit: the sign-in layer's (`defaultHost`) when there is one, else the\n * host's own session (an app whose host config has its `arbi` and `session` and keeps its\n * workspace open itself). So a kit runs the same in Clarum and in the ARBI app.\n */\nexport function useConnectedWorkspace(): ConnectedWorkspace {\n const connection = useContext(ConnectionContext)\n const arbi = useArbi()\n const sessionWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const live = connection ? connection.status === 'authenticated' : arbi.isLoggedIn\n const user = connection ? connection.user : live ? sessionUser(arbi) : null\n const userKey = `${user?.externalId ?? ''}|${user?.name ?? ''}|${user?.email ?? ''}`\n const { openWorkspace: showWorkspace } = useBlocksEnvironment()\n return useMemo(\n () => ({\n workspaceId: connection\n ? (connection.workspaceId ?? connection.fallbackWorkspaceId ?? null)\n : sessionWorkspaceId,\n live,\n user,\n userId: user?.externalId,\n ensureWorkspaceOpen: connection?.ensureWorkspaceOpen ?? keptOpenByHost,\n openWorkspace: async (workspaceId: string, options?: { name?: string }) => {\n if (connection) await connection.setWorkspace(workspaceId)\n showWorkspace(workspaceId, options)\n },\n }),\n // `user` is rebuilt each render without a connection: its key says when it changed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [connection, sessionWorkspaceId, live, userKey, showWorkspace]\n )\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/calendar/store.ts","../src/provider/dialog-registry.ts","../src/provider/settings-section.ts","../src/provider/requests.ts","../src/provider/environment.ts"],"names":["create","persist","set","createJSONStorage","snapshot","useSyncExternalStore","listeners","subscribe","useRef","useEffect","notifyStore","confirmDialog","choiceDialog","useHostConfigRecord","openDialog","closeDialog"],"mappings":";;;;;;;;AAqCO,IAAM,uBAAuBA,cAAA,EAA0B;AAAA,EAC5DC,kBAAA;AAAA,IACE,CAACC,IAAAA,MAAS;AAAA,MACR,IAAA,EAAM,IAAA;AAAA,MACN,IAAA,EAAM,IAAA;AAAA,MACN,YAAA,EAAc,IAAA;AAAA,MACd,eAAA,EAAiB,IAAA;AAAA,MACjB,oBAAoB,CAAC,eAAA,KAAoBA,IAAAA,CAAI,EAAE,iBAAiB,CAAA;AAAA,MAChE,SAAS,CAAC,IAAA,KAASA,IAAAA,CAAI,EAAE,MAAM,CAAA;AAAA,MAC/B,SAAS,CAAC,IAAA,KAASA,IAAAA,CAAI,EAAE,MAAM,CAAA;AAAA,MAC/B,iBAAiB,CAAC,YAAA,KAAiBA,IAAAA,CAAI,EAAE,cAAc;AAAA,KACzD,CAAA;AAAA,IACA;AAAA,MACE,IAAA,EAAM,oBAAA;AAAA,MACN,OAAA,EAASC,4BAAA,CAAkB,MAAM,YAAY,CAAA;AAAA,MAC7C,YAAY,CAAC,CAAA,MAAO,EAAE,IAAA,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AgC,CAAA,EAAG,OAAO,WAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,WAAW,CAAA;AACpC,EAAA,IAAI,CAAC,OAAO,QAAA,CAAS,GAAA,CAAI,aAAc,KAAA,GAAQ,OAAA,CAAQ,WAAW,CAAE,CAAA;AACpE,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,oBAAA,GAA0C;AACxD,EAAA,MAAM,WAAA,GAAcC,2BAAoB,CAAE,WAAA;AAC1C,EAAA,OAAO,WAAA,GAAc,uBAAA,CAAwB,WAAW,CAAA,GAAI,kBAAA;AAC9D;AAGO,SAAS,gBAAA,GAA0E;AACxF,EAAA,MAAM,EAAE,UAAA,EAAAC,WAAAA,EAAY,WAAA,EAAAC,YAAAA,KAAgB,oBAAA,EAAqB;AACzD,EAAA,OAAO,EAAE,UAAA,EAAAD,WAAAA,EAAY,WAAA,EAAAC,YAAAA,EAAY;AACnC;AAMO,SAAS,eAAA,GAAqD;AACnE,EAAA,MAAM,EAAE,YAAA,EAAc,UAAA,EAAW,GAAI,oBAAA,EAAqB;AAC1D,EAAA,MAAM,OAAA,GAAU,WAAW,WAAW,CAAA;AACtC,EAAA,OAAO,UAAU,YAAA,GAAe,MAAA;AAClC","file":"chunk-B3NYBMDR.cjs","sourcesContent":["/**\n * The connected calendar's view state: the chosen view is remembered across reloads (localStorage),\n * the anchor date lives for the session, and two requests carry intents from elsewhere into the\n * calendar once it mounts: an event to open (a deep link, a reminder) and a prefilled new event\n * (\"Schedule a call\" from a thread). The host navigates to its calendar page after making one.\n */\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport type { CalendarViewKind } from '../../calendar/types'\n\n/** \"Schedule a call\" from elsewhere (a thread, a DM, a dashboard): the editor opens prefilled. */\nexport interface CalendarComposerPrefill {\n title?: string\n attendees?: { email?: string | null; user_id?: string | null; name?: string | null }[]\n conversationId?: string | null\n /** Add an ARBI call when the event is saved (\"Add ARBI call\" ticked). */\n addCall?: boolean\n}\n\nexport interface PendingCalendarEvent {\n id: string\n recurrenceId?: string | null\n}\n\ninterface CalendarViewState {\n /** `null` until the user picks one: the settings' default view applies. */\n view: CalendarViewKind | null\n /** YYYY-MM-DD anchor; `null` = today. */\n date: string | null\n pendingEvent: PendingCalendarEvent | null\n pendingComposer: CalendarComposerPrefill | null\n setPendingComposer: (prefill: CalendarComposerPrefill | null) => void\n setView: (view: CalendarViewKind) => void\n setDate: (date: string | null) => void\n setPendingEvent: (pending: PendingCalendarEvent | null) => void\n}\n\nexport const useCalendarViewStore = create<CalendarViewState>()(\n persist(\n (set) => ({\n view: null,\n date: null,\n pendingEvent: null,\n pendingComposer: null,\n setPendingComposer: (pendingComposer) => set({ pendingComposer }),\n setView: (view) => set({ view }),\n setDate: (date) => set({ date }),\n setPendingEvent: (pendingEvent) => set({ pendingEvent }),\n }),\n {\n name: 'arbi-calendar-view',\n storage: createJSONStorage(() => localStorage),\n partialize: (s) => ({ view: s.view }),\n }\n )\n)\n\nconst EVT_RE = /^evt-[A-Za-z0-9]{8}$/\n\n/** Ask the calendar to open on an event (ignored unless it is an `evt-` id). */\nexport function requestCalendarEvent(event: PendingCalendarEvent): void {\n if (EVT_RE.test(event.id)) useCalendarViewStore.getState().setPendingEvent(event)\n}\n\n/** Ask the calendar to open the event editor prefilled. */\nexport function requestCalendarComposer(prefill: CalendarComposerPrefill): void {\n useCalendarViewStore.getState().setPendingComposer(prefill)\n}\n","/**\n * The global dialogs: one registry of what is open, so any surface (a kit, a command, code outside\n * React such as an API middleware) opens a dialog by kind, and the one `<ConnectedGlobalDialogs>`\n * mounted in the shell shows it. Each kind is open or not; an open kind holds the props it was\n * opened with. Opening a kind that is already open replaces its props.\n *\n * Kits reach it through the environment (`useBlocksEnvironment().openDialog`), which a host may\n * replace; code outside React calls `openDialog` / `closeDialog` here. Confirm and choice prompts\n * are promise-based instead (`./dialogs`).\n */\nimport { useSyncExternalStore } from 'react'\nimport type { components } from '@arbidocs/client'\nimport type { WorkflowLaunchRequest } from '../agents/workflows/launchRequest'\nimport type { QuotaExceededInfo } from '../connection/billing/ConnectedQuotaDialog'\n\ntype NotificationResponse = components['schemas']['NotificationResponse']\n\n/** Where files are added from: this device, links, or an email account. */\nexport type UploadSource = 'computer' | 'internet' | 'email'\n\n/** What `openShare` shares by email. */\nexport interface ShareRequest {\n resourceType: 'document' | 'conversation'\n resourceExtId: string\n workspaceExtId: string\n resourceName?: string\n /** Whether it is private to its owner now: the dialog offers to share it with the workspace. */\n isPrivate: boolean\n}\n\n/** The upload dialog: files or links already picked, one source, a folder to add them to. */\nexport interface UploadDialogProps {\n /** The tab it opens on (default `upload`). */\n tab?: 'upload' | 'status'\n files?: File[]\n urls?: string[]\n /** Only this source (from an \"Add\" menu). None: every source. */\n source?: UploadSource | null\n /** The folder the files go into. */\n folder?: string | null\n /** Right after a workspace was created: where to go next is offered, and it stays open. */\n newWorkspace?: boolean\n}\n\n/** The create-workspace dialog: in a project (locked to it), or the first-login welcome copy. */\nexport interface CreateWorkspaceDialogProps {\n projectId?: string | null\n variant?: 'default' | 'welcome'\n}\n\n/** Each global dialog, by kind, and the props it is opened with. */\nexport interface BlocksDialogProps {\n /** Add files (upload, links, email). */\n upload: UploadDialogProps\n /** A project's AI usage for the month is used up. */\n quota: QuotaExceededInfo\n /** The first-login snapshot for free users. */\n welcome: Record<string, never>\n /** Share a document or a thread by email. */\n share: ShareRequest\n createWorkspace: CreateWorkspaceDialogProps\n /** Export, copy or move the whole open workspace. */\n transfer: Record<string, never>\n /** Number the selected documents as a production set. */\n productionSet: Record<string, never>\n /** Invite people as contacts. */\n inviteContacts: Record<string, never>\n /** Review a workspace access request (its notification). */\n grantAccess: { notification: NotificationResponse }\n /** Browse, run and edit skills, optionally on one. */\n skillsBrowser: { skillSlug?: string }\n /** Start a workflow with some inputs preset (or at once, `autoStart`). */\n workflowLaunch: WorkflowLaunchRequest\n /** Sign out of this session or all of them. */\n logout: Record<string, never>\n /** Restore an archived workspace. */\n unarchiveWorkspace: { workspaceId: string }\n /** The open conversation's settings. */\n conversationSettings: Record<string, never>\n /** Pick the open conversation's documents. */\n conversationDocuments: Record<string, never>\n}\n\nexport type BlocksDialogKind = keyof BlocksDialogProps\n\n/** The props argument: optional for a kind whose props are all optional. */\nexport type DialogPropsArg<K extends BlocksDialogKind> =\n Record<never, never> extends BlocksDialogProps[K]\n ? [props?: BlocksDialogProps[K]]\n : [props: BlocksDialogProps[K]]\n\ntype OpenDialogs = { readonly [K in BlocksDialogKind]?: BlocksDialogProps[K] }\n\nlet open: OpenDialogs = {}\nconst listeners = new Set<() => void>()\n\nfunction set(next: OpenDialogs) {\n open = next\n listeners.forEach((listener) => listener())\n}\n\n/** Open a dialog (replacing the props of one already open). */\nexport function openDialog<K extends BlocksDialogKind>(kind: K, ...[props]: DialogPropsArg<K>) {\n set({ ...open, [kind]: props ?? {} })\n}\n\n/** Close a dialog (nothing happens when it is not open). */\nexport function closeDialog(kind: BlocksDialogKind): void {\n if (!(kind in open)) return\n const next = { ...open }\n delete next[kind]\n set(next)\n}\n\n/** Close every dialog (signing out). */\nexport function closeAllDialogs(): void {\n if (Object.keys(open).length > 0) set({})\n}\n\n/** The props an open dialog was opened with, or `null` while it is closed. */\nexport function getDialog<K extends BlocksDialogKind>(kind: K): BlocksDialogProps[K] | null {\n return (open[kind] as BlocksDialogProps[K] | undefined) ?? null\n}\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\n/** A dialog's props while it is open, `null` while closed; re-renders when it opens or closes. */\nexport function useDialogProps<K extends BlocksDialogKind>(kind: K): BlocksDialogProps[K] | null {\n const snapshot = () => getDialog(kind)\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n","/**\n * The settings section asked for last, so `openSettings(section)` opens that section in every host.\n *\n * `BlocksEnvironment.openSettings` records the section here before the host shows its settings\n * (a panel, a route); a `ConnectedSettingsPage` without its own `section` prop opens at it and\n * follows every later request, even one for the section asked for before. A host that keeps the\n * open section itself (`section` + `onSectionChange`) routes `openSettings` to its own state.\n */\nimport { useSyncExternalStore } from 'react'\n\nexport interface SettingsSectionRequest {\n section: string\n /** Increases with every request, so asking again for the same section is a new request. */\n seq: number\n}\n\nlet request: SettingsSectionRequest | undefined\nconst listeners = new Set<() => void>()\n\n/** Ask for a settings section; no section asks for none (the page stays where it is). */\nexport function requestSettingsSection(section?: string): void {\n if (!section) return\n request = { section, seq: (request?.seq ?? 0) + 1 }\n listeners.forEach((listener) => listener())\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nconst snapshot = () => request\n\n/** The last settings-section request (`undefined` until there is one). */\nexport function useRequestedSettingsSection(): SettingsSectionRequest | undefined {\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n","/**\n * What an intent asks of the surface it opens, carried across the navigation: the first message\n * of a new conversation (`openNewConversation({ prompt })`) and the email draft to show\n * (`openMail({ draftId })`). The environment records the request before the host navigates; the\n * surface takes it when it mounts, or at once while it is already on screen. Taking clears it, so\n * a request is acted on once, by one surface.\n */\nimport { useEffect, useRef } from 'react'\n\nexport interface IntentRequest<T> {\n /** Record a request (replacing one not taken yet). */\n request(value: T): void\n /** The pending request, cleared: `undefined` when there is none. */\n take(): T | undefined\n /** Calls `listener` whenever a request is made. */\n subscribe(listener: () => void): () => void\n}\n\nfunction intentRequest<T>(): IntentRequest<T> {\n let pending: { value: T } | undefined\n const listeners = new Set<() => void>()\n return {\n request(value) {\n pending = { value }\n listeners.forEach((listener) => listener())\n },\n take() {\n const taken = pending\n pending = undefined\n return taken?.value\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n}\n\n/**\n * Take each request while `enabled`: the one pending on mount and every later one. The latest\n * `onRequest` is called.\n */\nexport function useIntentRequest<T>(\n store: IntentRequest<T>,\n onRequest: (value: T) => void,\n enabled = true\n): void {\n const latest = useRef(onRequest)\n latest.current = onRequest\n useEffect(() => {\n if (!enabled) return\n const take = () => {\n const value = store.take()\n if (value !== undefined) latest.current(value)\n }\n take()\n return store.subscribe(take)\n }, [store, enabled])\n}\n\n/** The first message of the new conversation `openNewConversation({ prompt })` showed. */\nexport const conversationStartRequest = intentRequest<string>()\n\n/** The email draft `openMail({ draftId })` showed. */\nexport const mailDraftRequest = intentRequest<string>()\n","import type { ReactNode } from 'react'\nimport {\n notify as notifyStore,\n useHostConfigRecord,\n type NotifyOptions,\n type NotifyVariant,\n} from '@arbidocs/react/shell'\nimport type { BlockLinkComponent } from '../components/blockLink'\nimport { requestCalendarEvent, type PendingCalendarEvent } from '../connection/calendar/store'\nimport { choiceDialog, confirmDialog, type ChoiceRequest, type ConfirmRequest } from './dialogs'\nimport {\n closeDialog,\n openDialog,\n type BlocksDialogKind,\n type DialogPropsArg,\n type ShareRequest,\n type UploadSource,\n} from './dialog-registry'\nimport { conversationStartRequest, mailDraftRequest } from './requests'\nimport { requestSettingsSection } from './settings-section'\n\n/** What blocks need from the host's runtime configuration (the app's `config.json`). */\nexport interface BlocksRuntimeConfig {\n /** Origin of the ARBI API; `''` means the page's own origin. */\n apiBaseUrl: string\n /** The deployment's domain, e.g. `www.arbidocs.com` (deep links, key derivation, labels). */\n deploymentDomain: string\n /** Where seats are added for this deployment (a Box's licence page); none: its settings. */\n licenceUrl?: string\n}\n\nexport interface OpenDocumentOptions {\n /** 1-based page to scroll to. */\n page?: number\n /** Passage (chunk) to highlight. */\n passageId?: string\n /**\n * The workspace the document is in, when it is not the open one (a document an agent wrote in\n * its own workspace): the host opens that workspace first.\n */\n workspaceId?: string\n /** An earlier version (1-based); none: the current one. */\n version?: number\n /** The viewer tab to show: `pdf` is where a signature request is reviewed and signed. */\n tab?: 'pdf'\n}\n\nexport type { ShareRequest, UploadSource }\n\nexport interface OpenWordEditorOptions {\n /** The comment to show (a mention in it, a reply to it). */\n commentId?: string\n /** The workspace the document is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenConversationOptions {\n /** The message to scroll to. */\n messageId?: string\n /** The open document stays on screen beside the thread (a thread about it). */\n keepDocumentOpen?: boolean\n /** The workspace the thread is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenNewConversationOptions {\n /** Its first message, sent once the new conversation is ready (an ask bar, \"Ask about this\"). */\n prompt?: string\n /** The open document stays on screen beside it (a chat started from it). */\n keepDocumentOpen?: boolean\n}\n\nexport interface OpenWorkflowOptions {\n /** The workflow's editor (default) or its runs. */\n view?: 'builder' | 'runs'\n /** The workspace the workflow is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenMailOptions {\n /** The email draft to show (a draft a workflow step or an agent left), to check and send. */\n draftId?: string\n /** The folder to show (`inbox`, `sent`, `trash`, `outbox`…). Default: the host's own. */\n folder?: string\n}\n\nexport interface OpenCalendarOptions {\n /** The event to open on. */\n event?: PendingCalendarEvent\n}\n\n/** Parts of the product a host can turn off (a setting, a plan): a kit offers them only when on. */\nexport type BlocksFeature = 'workflows' | 'mail' | 'databases'\n\n/** What `openFiles` shows: some files selected, and the list narrowed. */\nexport interface OpenFilesOptions {\n /** Files to select. */\n select?: string[]\n /** Quick filters by key (a label id, `folder:<path>`, `folder:none`): show or hide those files. */\n filters?: Record<string, 'include' | 'exclude'>\n}\n\n/**\n * Something a kit links to (the target of an `open…` intent), for `hrefFor`. `workspaceId` is the\n * workspace it is in, when the kit knows it.\n */\nexport type LinkTarget =\n | { kind: 'document'; documentId: string; workspaceId?: string | null }\n | {\n kind: 'conversation'\n conversationId: string\n workspaceId?: string | null\n messageId?: string\n }\n | { kind: 'workspace'; workspaceId: string }\n /** A project; none: the projects list. */\n | { kind: 'project'; projectId?: string }\n /** A workflow (its editor); none: the workflows list. */\n | { kind: 'workflow'; workflowId?: string; workspaceId?: string | null }\n /** The mailbox, on an email draft when given. */\n | { kind: 'mail'; draftId?: string }\n /** The user's settings, at a section when given. */\n | { kind: 'settings'; section?: string }\n /** The calendar, on an event when given. */\n | { kind: 'calendar'; eventId?: string }\n\n/**\n * The only way blocks reach the host app's environment: the host configuration's `environment`\n * (`<ArbiHost config={{ environment: { navigate, notify, … } }}>`). Blocks never import a router, a\n * toast library or an app store; the host gives what it has, and every field has a safe default so\n * a block renders correctly with no host at all. A nested host overrides only the fields it gives\n * and inherits the rest.\n */\nexport interface BlocksEnvironment {\n /** Router-aware link (keeps navigation in-SPA). Default: a plain `<a href>`. */\n linkComponent?: BlockLinkComponent\n /** Imperative navigation for buttons and keyboard shortcuts. Default: `window.location.assign`. */\n navigate: (href: string) => void\n /** Surface a transient message (and record it in the notification centre). Default: the shared\n * `@arbidocs/react` notify store, rendered by its `<Toaster/>`. */\n notify: (message: ReactNode, kind?: NotifyVariant, options?: NotifyOptions) => void\n /** Ask the user to confirm. Default: the blocks prompt dialog. */\n confirm: (request: ConfirmRequest) => Promise<boolean>\n /** Ask the user to pick one of several choices; `null` when dismissed. Default: the blocks\n * prompt dialog. */\n choose: <T extends string>(request: ChoiceRequest<T>) => Promise<T | null>\n /**\n * Open a global dialog by kind (`BlocksDialogProps`), shown by the one `<ConnectedGlobalDialogs>`\n * in the shell. Default: the blocks dialog registry.\n */\n openDialog: <K extends BlocksDialogKind>(kind: K, ...props: DialogPropsArg<K>) => void\n /** Close a global dialog. Default: the blocks dialog registry. */\n closeDialog: (kind: BlocksDialogKind) => void\n /** Deployment configuration. Default: same-origin API on the page's own host. */\n runtimeConfig: BlocksRuntimeConfig\n /**\n * The address of a target in the host's router, for a real link (open in a new tab, middle-click,\n * copy link) beside the matching `open…` intent: a kit never builds an app path itself, so its\n * links and its navigation agree on every site. `undefined`: no link (the row still opens on a\n * click). Default: none. ARBI-style paths (`/wrk-…/doc-…`): `deepLinkHref`.\n */\n hrefFor: (target: LinkTarget) => string | undefined\n /** Open a document (optionally at a page / passage) wherever the host shows documents.\n * Default: no-op. */\n openDocument: (documentId: string, options?: OpenDocumentOptions) => void\n /**\n * Open a Word document (`opensInWord`) in the host's Word editor, optionally on a comment.\n * Default: `openDocument` (a host whose viewer edits Word documents in place needs no other).\n */\n openWordEditor: (documentId: string, options?: OpenWordEditorOptions) => void\n /** Open a conversation thread, optionally scrolled to a message. Default: no-op. */\n openConversation: (conversationId: string, options?: OpenConversationOptions) => void\n /**\n * Show a new, empty conversation, unbound to any document. With a `prompt` it is sent as the\n * first message once the conversation is ready (recorded for the chat that shows it:\n * `ConnectedConversation`, `ChatPage`). Without one a launch composes into the session's draft\n * after this. Default: no-op.\n */\n openNewConversation: (options?: OpenNewConversationOptions) => void\n /**\n * Open the user's settings, optionally at a section (a `ConnectedSettingsPage` section id).\n * The section is always recorded for `ConnectedSettingsPage` first (`requestSettingsSection`);\n * the host's handler then shows its settings. Default: only that record.\n */\n openSettings: (section?: string) => void\n /** Open a project; no id: the projects list. Default: no-op. */\n openProject: (projectId?: string) => void\n /**\n * Show the calendar page (`ConnectedCalendar`), optionally on an event (recorded for the\n * calendar first: `requestCalendarEvent`). Default: only that record.\n */\n openCalendar: (options?: OpenCalendarOptions) => void\n /**\n * Show the mailbox (`ConnectedMailbox`), optionally on an email draft (recorded for the mailbox\n * first). Absent: the host has no mail, and a kit offers no way to open it.\n */\n openMail?: (options?: OpenMailOptions) => void\n /** Show the host's calls page (call history, scheduled calls). Absent: not offered. */\n openCalls?: () => void\n /** Open the direct chat with a person (the host's messenger). Absent: not offered. */\n openDirectChat?: (userId: string) => void\n /** Open one of my chats (a group or meeting chat) in the host's messenger. Absent: not offered. */\n openChat?: (chatId: string) => void\n /** Show the host's notification centre (`ConnectedNotificationCenter`), optionally on one\n * entry (`focusId`). Absent: not offered. */\n openNotifications?: (options?: { focusId?: string }) => void\n /** Show the host's contacts (a panel it toggles, a page). Absent: not offered. */\n openContacts?: () => void\n /** Show the host's databases page (user-defined tables). Absent: not offered. */\n openDatabases?: () => void\n /** Show the host's tags page (people, organisations and the other tags). Absent: not offered. */\n openTags?: () => void\n /**\n * Open a workflow in the host's Workflows page (its editor, or its runs); no id: the list.\n * Offered only while the `workflows` feature is on (`useOpenWorkflow`). Absent: never.\n */\n openWorkflow?: (workflowId?: string, options?: OpenWorkflowOptions) => void\n /**\n * A React hook: whether a part of the product is on for this user (a setting, a plan). Kits\n * offer what is off nowhere. Default: everything is on.\n */\n useFeature: (feature: BlocksFeature) => boolean\n /** Show the open workspace's files, optionally with some selected and the list narrowed. Default: no-op. */\n openFiles: (options?: OpenFilesOptions) => void\n /**\n * Add files the host's way (its upload dialog), optionally with some already picked, or from one\n * source. Absent: a kit that adds files uploads them itself.\n */\n openUpload?: (files?: File[], options?: { source?: UploadSource }) => void\n /** Open the host's skills browser, optionally at one skill. Absent: not offered. */\n openSkillsBrowser?: (skillSlug?: string) => void\n /** Share a document or a thread by email (the host's share dialog). Absent: not offered. */\n openShare?: (request: ShareRequest) => void\n /**\n * Show a workspace (its own page). Under `defaultHost`'s sign-in layer the kits select it first\n * (`useConnectedWorkspace().openWorkspace`); a host that keeps its own session switches to it\n * here. `name` is for the host's messages. Default: no-op.\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => void\n}\n\nconst noop = () => {}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: (message, kind = 'info', options) => {\n notifyStore[kind](message, options)\n },\n confirm: confirmDialog,\n choose: choiceDialog,\n openDialog,\n closeDialog,\n runtimeConfig: {\n apiBaseUrl: '',\n deploymentDomain: typeof window !== 'undefined' ? window.location.host : '',\n },\n hrefFor: () => undefined,\n openDocument: noop,\n openWordEditor: noop,\n openConversation: noop,\n openNewConversation: noop,\n openSettings: requestSettingsSection,\n openProject: noop,\n openCalendar: (options) => {\n if (options?.event) requestCalendarEvent(options.event)\n },\n useFeature: () => true,\n openFiles: noop,\n openWorkspace: noop,\n}\n\nconst resolved = new WeakMap<object, BlocksEnvironment>()\nconst complete = new WeakSet<BlocksEnvironment>()\n// The intents below that record what they open on: a resolved environment passed on again (a\n// nested host's, `createBlocksEnvironment`'s) records once, not twice.\nconst recording = new WeakSet<object>()\n\nfunction records<F extends object>(intent: F): F {\n recording.add(intent)\n return intent\n}\n\nfunction recordingIntent<F extends object>(\n host: F | undefined,\n wrap: (host: F) => F\n): F | undefined {\n if (!host) return undefined\n return recording.has(host) ? host : records(wrap(host))\n}\n\nfunction resolve(environment: Partial<BlocksEnvironment>): BlocksEnvironment {\n const { openDocument } = environment\n const value: BlocksEnvironment = {\n ...defaultEnvironment,\n openWordEditor: openDocument\n ? (documentId, options) => openDocument(documentId, { workspaceId: options?.workspaceId })\n : noop,\n ...environment,\n // What an intent opens on is recorded for the surface before the host shows it.\n openSettings:\n recordingIntent(environment.openSettings, (openSettings) => (section) => {\n requestSettingsSection(section)\n openSettings(section)\n }) ?? defaultEnvironment.openSettings,\n openCalendar:\n recordingIntent(environment.openCalendar, (openCalendar) => (options) => {\n defaultEnvironment.openCalendar(options)\n openCalendar(options)\n }) ?? defaultEnvironment.openCalendar,\n openMail: recordingIntent(environment.openMail, (openMail) => (options) => {\n if (options?.draftId) mailDraftRequest.request(options.draftId)\n openMail(options)\n }),\n openNewConversation:\n recordingIntent(environment.openNewConversation, (openNewConversation) => (options) => {\n openNewConversation(options)\n // After the host's reset of the new conversation, which clears its draft.\n const prompt = options?.prompt?.trim()\n if (prompt) conversationStartRequest.request(prompt)\n }) ?? noop,\n }\n complete.add(value)\n return value\n}\n\n/**\n * The environment with every field filled in (the defaults where `environment` gives none), and\n * every intent recording what it opens on. A host calls it for code outside React (a store action,\n * a notification handler); passing the result as the host configuration's `environment` uses it\n * as is.\n */\nexport function createBlocksEnvironment(\n environment: Partial<BlocksEnvironment>\n): BlocksEnvironment {\n if (complete.has(environment as BlocksEnvironment)) return environment as BlocksEnvironment\n let value = resolved.get(environment)\n if (!value) resolved.set(environment, (value = resolve(environment)))\n return value\n}\n\n/** The host's environment, every field filled in (the defaults where the host gives none). */\nexport function useBlocksEnvironment(): BlocksEnvironment {\n const environment = useHostConfigRecord().environment as Partial<BlocksEnvironment> | undefined\n return environment ? createBlocksEnvironment(environment) : defaultEnvironment\n}\n\n/** Open and close the global dialogs (`<ConnectedGlobalDialogs>`), the host's way. */\nexport function useBlocksDialogs(): Pick<BlocksEnvironment, 'openDialog' | 'closeDialog'> {\n const { openDialog, closeDialog } = useBlocksEnvironment()\n return { openDialog, closeDialog }\n}\n\n/**\n * How to open a workflow in the host's Workflows page, or `undefined` while there is none (the\n * host has no `openWorkflow`, or the `workflows` feature is off).\n */\nexport function useOpenWorkflow(): BlocksEnvironment['openWorkflow'] {\n const { openWorkflow, useFeature } = useBlocksEnvironment()\n const enabled = useFeature('workflows')\n return enabled ? openWorkflow : undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/ConnectionProvider.tsx"],"names":["createContext","useArbi","useArbiSessionStore","useSwitchWorkspace","useState","useArbiSessionState","useRef","useEffect","closeAllDialogs","useCallback","login","clearSealedDrafts","useMemo","jsx","ArbiHost","arbiAccountClient","toProfileView","useContext","useBlocksEnvironment"],"mappings":";;;;;;;;AA4EA,IAAM,iBAAA,GAAoBA,oBAAsC,IAAI,CAAA;AAQpE,IAAM,wBAAA,GAA2B,wBAAA;AACjC,IAAM,mBAAmB,CAAC,KAAA,KAAkB,KAAA,CAAM,IAAA,GAAO,WAAA,EAAY;AAG9D,IAAM,mBAAA,GAAsB,CAAC,MAAA,EAAgB,OAAA,KAClD,CAAA,EAAG,wBAAwB,CAAA,CAAA,EAAI,MAAA,IAAU,MAAM,CAAA,CAAA,EAAI,gBAAA,CAAiB,OAAO,CAAC,CAAA,CAAA;AAG9E,IAAM,4BAA4B,CAAC,MAAA,KACjC,GAAG,wBAAwB,CAAA,CAAA,EAAI,UAAU,MAAM,CAAA,CAAA;AAEjD,SAAS,sBAAA,CAAuB,QAAgB,OAAA,EAAuC;AACrF,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AACrB,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,YAAA,CAAa,OAAA,CAA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AAA,GAC7D,kBAAA;AAAA,MACJ,IAAA;AAAA,MACA,IAAA;AAAA,MACA,QAAQ,IAAA,EAAM,UAAA;AAAA,MACd,mBAAA,EAAqB,YAAY,mBAAA,IAAuB,cAAA;AAAA,MACxD,aAAA,EAAe,OAAO,WAAA,EAAqB,OAAA,KAAgC;AACzE,QAAA,IAAI,UAAA,EAAY,MAAM,UAAA,CAAW,YAAA,CAAa,WAAW,CAAA;AACzD,QAAA,aAAA,CAAc,aAAa,OAAO,CAAA;AAAA,MACpC;AAAA,KACF,CAAA;AAAA;AAAA;AAAA,IAGA,CAAC,UAAA,EAAY,kBAAA,EAAoB,IAAA,EAAM,SAAS,aAAa;AAAA,GAC/D;AACF","file":"chunk-P6HVJP6Z.cjs","sourcesContent":["/**\n * The demo/live connection layer for a host app. Holds auth + workspace\n * selection state and exposes it via {@link useConnection}, so every surface\n * works identically whether it's talking to a live ARBI backend or the seeded\n * demo workspace. Host-specific values (backend URL, demo identity, default\n * workspace/assistant ids) arrive once through {@link ArbiConnectionConfig}.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react'\nimport {\n arbiAccountClient,\n clearSealedDrafts,\n toProfileView,\n useArbi,\n useArbiSessionState,\n useArbiSessionStore,\n useSwitchWorkspace,\n type AccountClient,\n type LoginProfile,\n type ProfileView,\n} from '@arbidocs/react'\nimport type { ArbiMode, ArbiUser, ConnectionStatus, ArbiConnectionConfig } from './types'\nimport { useBlocksEnvironment } from '../provider/environment'\nimport { ArbiHost } from '../provider/host'\nimport { closeAllDialogs } from '../provider/dialog-registry'\n\ninterface ConnectionValue {\n mode: ArbiMode\n status: ConnectionStatus\n user: ArbiUser | null\n /** The selected workspace: the session state's (`useArbiSessionState`), set by `setWorkspace`. */\n workspaceId: string | null\n apiConfigured: boolean\n apiUrl: string\n /**\n * The deployment domain the user's keys are derived for (`arbi.getDeploymentDomain()`), for the\n * document tools' e-signing. `undefined` in demo mode.\n */\n deploymentDomain: string | undefined\n error: string | null\n /** Default assistant config ext_id (for the AI hooks). */\n assistantConfig?: string\n /**\n * The demo's workspace when none is selected. Never set signed in to a live backend: there the\n * selection is the only workspace (none while a switch is in flight), never a remembered one.\n */\n fallbackWorkspaceId?: string\n /** Authenticate. Live login when a backend is configured, otherwise the demo workspace. */\n login: (email: string, password: string) => Promise<void>\n /** One-click demo entry (no backend required). */\n enterDemo: () => void\n logout: () => void\n /**\n * Affirmatively select a workspace: opens it on the server (via the SDK),\n * updates the app-wide state, and persists the choice so it survives future\n * logins. This is the single entry point for \"the user is now in workspace X\".\n */\n setWorkspace: (id: string) => Promise<void>\n /**\n * Re-assert the selected workspace on the server session (idempotent `/open`).\n * Call before a workspace-scoped write when the session may have lost its open\n * workspace (token re-login, backend restart, session expiry) — the server\n * resolves the workspace from the session, so a dropped `/open` yields\n * \"No active workspace\" until it's re-opened.\n */\n ensureWorkspaceOpen: () => Promise<void>\n}\n\nconst ConnectionContext = createContext<ConnectionValue | null>(null)\n\n/**\n * Persist the affirmatively-selected workspace per backend AND per signed-in user, so a returning\n * user lands back in the workspace they last chose, while the next person on a shared browser\n * never starts from someone else's workspace id. Namespaced by apiUrl so distinct deployments\n * (and the demo workspace) don't clobber each other. Cleared on logout.\n */\nconst WORKSPACE_STORAGE_PREFIX = 'arbi:selectedWorkspace'\nconst normalizeUserKey = (email: string) => email.trim().toLowerCase()\n\n/** Exported for tests. */\nexport const workspaceStorageKey = (apiUrl: string, userKey: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}:${normalizeUserKey(userKey)}`\n\n/** The pre-isolation key (apiUrl only). Never read: removed so it cannot leak across users. */\nconst legacyWorkspaceStorageKey = (apiUrl: string) =>\n `${WORKSPACE_STORAGE_PREFIX}:${apiUrl || 'demo'}`\n\nfunction readPersistedWorkspace(apiUrl: string, userKey: string | null): string | null {\n if (!userKey) return null\n try {\n return window.localStorage.getItem(workspaceStorageKey(apiUrl, userKey))\n } catch {\n return null\n }\n}\n\nfunction persistWorkspace(apiUrl: string, userKey: string | null, id: string | null): void {\n if (!userKey) return\n try {\n if (id) window.localStorage.setItem(workspaceStorageKey(apiUrl, userKey), id)\n else window.localStorage.removeItem(workspaceStorageKey(apiUrl, userKey))\n window.localStorage.removeItem(legacyWorkspaceStorageKey(apiUrl))\n } catch {\n // Storage unavailable (private mode, SSR) — selection stays in-memory only.\n }\n}\n\n/** Shown on the sign-in screen after the session could not be recovered. */\nexport const SESSION_EXPIRED_MESSAGE = 'Your session expired. Sign in again.'\n\n/** The connection user for a profile: its full name, falling back to the email local part. */\nfunction userFromProfile(profile: LoginProfile, externalId?: string): ArbiUser {\n const fullName = [profile.givenName, profile.familyName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ')\n return {\n name: fullName || profile.email.split('@')[0],\n email: profile.email,\n externalId,\n picture: profile.picture,\n }\n}\n\n/**\n * The sign-in layer of a blocks-only site, mounted by its host (`defaultHost`): login, demo mode\n * and the selected workspace, over the host's session state (the selected workspace lives there,\n * so every block reads one value). Its account client is the host's `account` below it.\n */\nexport function ConnectionProvider({\n config,\n children,\n}: {\n config: ArbiConnectionConfig\n children: ReactNode\n}) {\n const arbi = useArbi()\n const session = useArbiSessionStore()\n const { switchWorkspace, openSelectedWorkspace, settled } = useSwitchWorkspace()\n const isLiveConfigured = config.apiUrl.length > 0\n const demoWorkspaceId = config.demoWorkspaceId ?? 'demo-workspace'\n\n const [status, setStatus] = useState<ConnectionStatus>(\n isLiveConfigured ? 'connecting' : 'disconnected'\n )\n const [user, setUser] = useState<ArbiUser | null>(null)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const selectWorkspaceId = session.setWorkspaceId\n const [mode, setMode] = useState<ArbiMode>('demo')\n const [error, setError] = useState<string | null>(null)\n // Dialogs belong to the signed-in session. A first signed-out mount may carry an invitation\n // intent, so clear only after an authenticated (or demo) session actually ends. A workspace\n // switch / sign-in can pass through `connecting` without ending that session.\n const hadDialogSession = useRef(false)\n useEffect(() => {\n if (status === 'authenticated' || status === 'demo') {\n hadDialogSession.current = true\n } else if (status !== 'connecting' && hadDialogSession.current) {\n hadDialogSession.current = false\n closeAllDialogs()\n }\n }, [status])\n // Who the persisted workspace belongs to; set at sign-in, cleared at logout.\n const storageUserRef = useRef<string | null>(null)\n // Moves at each logout: a sign-in still finishing from before it does not sign back in.\n const sessionRun = useRef(0)\n\n // The SDK could not recover the session (token refused, workspace not re-openable): drop to\n // 'disconnected' with a plain message, so the host's gate sends the user to sign in instead of\n // every call failing with a raw backend error. The remembered workspace is kept for next login.\n useEffect(\n () =>\n arbi.onSessionExpired?.(() => {\n storageUserRef.current = null\n setUser(null)\n selectWorkspaceId(null)\n setStatus('disconnected')\n setError(SESSION_EXPIRED_MESSAGE)\n }),\n [arbi, selectWorkspaceId]\n )\n\n // A saved name, picture or email reaches every surface reading `useConnection().user`.\n useEffect(\n () =>\n arbi.user.onProfileChange?.((profile) =>\n setUser((current) => (current ? userFromProfile(profile, current.externalId) : current))\n ),\n [arbi]\n )\n\n const enterDemo = useCallback(() => {\n setMode('demo')\n setStatus('demo')\n setError(null)\n setUser({ name: config.demoUser.name, email: config.demoUser.email })\n selectWorkspaceId(demoWorkspaceId)\n }, [config.demoUser.name, config.demoUser.email, demoWorkspaceId, selectWorkspaceId])\n\n /**\n * The session signed in, by whatever path (`login` below, a sign-in page on the host's `Arbi`,\n * a restored session): open the user's workspace and resolve who they are.\n */\n const completeSignIn = useCallback(\n async (email: string) => {\n const run = sessionRun.current\n const signedOut = () => run !== sessionRun.current\n setMode('live')\n setStatus('connecting')\n setError(null)\n try {\n storageUserRef.current = normalizeUserKey(email)\n const workspaces = await arbi.workspaces.list()\n if (workspaces?.length) {\n // Prefer the workspace the user last affirmatively selected (persisted),\n // then the configured workspace (there may be several — e.g. a\n // marketing/KM workspace), then whichever happens to be first. Ternary\n // (not `&&`) so an empty value can't leak `\"\"` into `target`.\n const persisted = readPersistedWorkspace(config.apiUrl, storageUserRef.current)\n const preferred = persisted ?? config.workspaceId\n const target =\n (preferred ? workspaces.find((w) => w.external_id === preferred) : undefined) ??\n workspaces[0]\n selectWorkspaceId(target.external_id)\n if (!(await openSelectedWorkspace()))\n throw new Error('Could not open your workspace. Try signing in again.')\n persistWorkspace(config.apiUrl, storageUserRef.current, target.external_id)\n }\n // The profile (name + avatar) comes with the login response. A session restored without\n // a login has none, so fall back to finding ourselves in the workspace roster; the email\n // local part is only the last resort, never the answer when a profile name exists.\n let resolved: ArbiUser = { name: email.split('@')[0], email }\n const me = arbi.user.identity()\n const profile = arbi.user.profile?.()\n if (profile) {\n resolved = userFromProfile(profile, me?.externalId)\n } else {\n try {\n const members = await arbi.workspaces.listUsers()\n const self = members.find((m) => m.user.external_id === me?.externalId)?.user\n if (self) {\n const fullName = [self.given_name, self.family_name].filter(Boolean).join(' ').trim()\n resolved = {\n name: fullName || email.split('@')[0],\n email: self.email || email,\n externalId: self.external_id,\n picture: self.picture ?? null,\n }\n } else if (me?.externalId) {\n resolved.externalId = me.externalId\n }\n } catch {\n // Roster not available (e.g. no workspace) — keep the fallback identity.\n }\n }\n if (signedOut()) return\n setUser(resolved)\n setStatus('authenticated')\n } catch (e) {\n if (signedOut()) return\n // Surface the real error — no silent fallback to a fake session.\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, config.workspaceId, config.apiUrl, selectWorkspaceId, openSelectedWorkspace]\n )\n\n // Every sign-in on the host's `Arbi` lands here, whichever page or kit made it.\n const signingIn = useRef<Promise<void>>(Promise.resolve())\n useEffect(\n () =>\n arbi.onSignedIn?.((login) => {\n signingIn.current = completeSignIn(\n login.profile?.email ??\n arbi.session?.getState().userEmail ??\n arbi.user.identity()?.email ??\n ''\n )\n }),\n [arbi, completeSignIn]\n )\n\n /** Authenticate: a live login when a backend is configured, otherwise the demo workspace. */\n const login = useCallback(\n async (email: string, password: string) => {\n setError(null)\n if (!isLiveConfigured) {\n enterDemo()\n return\n }\n setStatus('connecting')\n setMode('live')\n try {\n // Signed in: `completeSignIn` follows (onSignedIn); done once it is.\n await arbi.login(email, password)\n await signingIn.current\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Sign-in failed. Check your credentials.')\n setStatus('error')\n }\n },\n [arbi, enterDemo, isLiveConfigured]\n )\n\n // The session kept on this device signs in again (no password; the key stays encrypted on the\n // device). Run once even under StrictMode.\n const restoreStarted = useRef(false)\n useEffect(() => {\n if (restoreStarted.current || !isLiveConfigured) return\n restoreStarted.current = true\n arbi\n .restore()\n .catch(() => false)\n .then(async (restored) => {\n if (restored) await signingIn.current\n else setStatus('disconnected')\n })\n }, [arbi, isLiveConfigured])\n\n const logout = useCallback(() => {\n sessionRun.current++\n // The SDK stops the session's work (requests, re-logins, opens, the queries in flight) before\n // the server revokes the token.\n if (mode === 'live') {\n void arbi.logout?.()\n }\n // What was typed never outlives the session (it is sealed, but kept for no one now).\n clearSealedDrafts()\n setUser(null)\n selectWorkspaceId(null)\n persistWorkspace(config.apiUrl, storageUserRef.current, null)\n storageUserRef.current = null\n setStatus('disconnected')\n setError(null)\n }, [arbi, mode, config.apiUrl, selectWorkspaceId])\n\n // Affirmative selection: the shared workspace switch (live), then remember it so the next\n // login lands there too. This provider IS the host's navigation, so it alone (with sign-in and\n // ensureWorkspaceOpen, which re-open the host's own selection) changes the workspace; kits reach\n // another workspace with `arbi.workspaces.open`.\n const setWorkspace = useCallback(\n async (id: string) => {\n if (mode === 'live' && arbi.isLoggedIn) {\n if (!(await switchWorkspace({ id }))) throw new Error('Could not open the workspace')\n } else {\n selectWorkspaceId(id)\n }\n persistWorkspace(config.apiUrl, storageUserRef.current, id)\n },\n [arbi, mode, config.apiUrl, selectWorkspaceId, switchWorkspace]\n )\n\n // Re-open the selected workspace on the session if the server may have dropped it. Idempotent.\n // A switch in flight is waited out first, then only the selection as of then is opened (none:\n // nothing). Never a remembered or configured workspace: kits call this before reading, and\n // opening another workspace than the selected one would leave the server session in it.\n const ensureWorkspaceOpen = useCallback(async () => {\n if (mode !== 'live' || !arbi.isLoggedIn) return\n await settled()\n if (!session.getState().workspaceId) return\n await openSelectedWorkspace()\n }, [arbi, session, mode, settled, openSelectedWorkspace])\n\n const value = useMemo<ConnectionValue>(\n () => ({\n mode,\n status,\n user,\n workspaceId,\n apiConfigured: isLiveConfigured,\n apiUrl: config.apiUrl,\n deploymentDomain: isLiveConfigured ? arbi.getDeploymentDomain() : undefined,\n error,\n assistantConfig: config.assistantConfig,\n fallbackWorkspaceId: mode === 'live' ? undefined : config.workspaceId,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n }),\n [\n mode,\n status,\n user,\n workspaceId,\n isLiveConfigured,\n config.apiUrl,\n arbi,\n config.assistantConfig,\n config.workspaceId,\n error,\n login,\n enterDemo,\n logout,\n setWorkspace,\n ensureWorkspaceOpen,\n ]\n )\n\n const account = useConnectionAccount(arbi, user, logout)\n const authenticated = status === 'authenticated'\n const host = useMemo(\n () => ({ account: { client: account, useEnabled: () => authenticated } }),\n [account, authenticated]\n )\n\n return (\n <ConnectionContext.Provider value={value}>\n <ArbiHost config={host}>{children}</ArbiHost>\n </ConnectionContext.Provider>\n )\n}\n\n/**\n * The account client of the settings blocks below: the SDK's, with sign-out going through this\n * connection (so its state is cleared too) and, for a session restored without a login (no SDK\n * profile), the connection user as the profile.\n */\nfunction useConnectionAccount(\n arbi: ReturnType<typeof useArbi>,\n user: ArbiUser | null,\n logout: () => void\n): AccountClient {\n const userRef = useRef(user)\n const logoutRef = useRef(logout)\n logoutRef.current = logout\n const listeners = useRef(new Set<() => void>())\n useEffect(() => {\n userRef.current = user\n listeners.current.forEach((listener) => listener())\n }, [user])\n return useMemo(() => {\n const base = arbiAccountClient(arbi)\n return {\n ...base,\n profile: (): ProfileView | null => {\n const own = base.profile()\n const fallback = userRef.current\n if (own || !fallback) return own\n return {\n ...toProfileView({\n givenName: '',\n familyName: null,\n picture: fallback.picture ?? null,\n email: fallback.email,\n isSso: false,\n }),\n fullName: fallback.name,\n }\n },\n onProfileChange: (listener) => {\n listeners.current.add(listener)\n const off = base.onProfileChange(listener)\n return () => {\n listeners.current.delete(listener)\n off()\n }\n },\n signOut: async ({ everywhere } = {}) => {\n try {\n if (everywhere) await arbi.sessions.logoutAll()\n } finally {\n logoutRef.current()\n }\n },\n }\n }, [arbi])\n}\n\n/** The sign-in layer of `defaultHost`, or null under a host that keeps its own session. */\nexport function useOptionalConnection(): ConnectionValue | null {\n return useContext(ConnectionContext)\n}\n\nexport function useConnection(): ConnectionValue {\n const ctx = useContext(ConnectionContext)\n if (!ctx) throw new Error('useConnection needs the sign-in layer of `defaultHost` above it')\n return ctx\n}\n\nexport const isAuthenticated = (s: ConnectionStatus) => s === 'demo' || s === 'authenticated'\n\n/** The open workspace as the connected kits see it, whoever hosts them. */\nexport interface ConnectedWorkspace {\n /** The selected workspace (the session state's; with a connection, else its fallback). */\n workspaceId: string | null\n /** Signed in to a live backend: workspace-scoped queries may run. */\n live: boolean\n /** The signed-in user (their name and email, e.g. to sign a document). */\n user: ArbiUser | null\n /** The signed-in user's external id. */\n userId: string | undefined\n /** Re-assert the workspace on the server session before a workspace-scoped write. */\n ensureWorkspaceOpen: () => Promise<void>\n /**\n * Go into a workspace: select it (with a connection) and show it (`BlocksEnvironment.\n * openWorkspace`, where a host without a connection also switches its session).\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => Promise<void>\n}\n\nconst keptOpenByHost = async () => {}\n\n/** The signed-in user of a host's own session, from its login profile. */\nfunction sessionUser(arbi: ReturnType<typeof useArbi>): ArbiUser | null {\n if (!arbi.isLoggedIn) return null\n const me = arbi.user.identity()\n const profile = arbi.user.profile()\n if (!me) return null\n return profile\n ? userFromProfile(profile, me.externalId)\n : { name: (me.email ?? '').split('@')[0], email: me.email ?? '', externalId: me.externalId }\n}\n\n/**\n * The workspace for a connected kit: the sign-in layer's (`defaultHost`) when there is one, else the\n * host's own session (an app whose host config has its `arbi` and `session` and keeps its\n * workspace open itself). So a kit runs the same in Clarum and in the ARBI app.\n */\nexport function useConnectedWorkspace(): ConnectedWorkspace {\n const connection = useContext(ConnectionContext)\n const arbi = useArbi()\n const sessionWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const live = connection ? connection.status === 'authenticated' : arbi.isLoggedIn\n const user = connection ? connection.user : live ? sessionUser(arbi) : null\n const userKey = `${user?.externalId ?? ''}|${user?.name ?? ''}|${user?.email ?? ''}`\n const { openWorkspace: showWorkspace } = useBlocksEnvironment()\n return useMemo(\n () => ({\n workspaceId: connection\n ? (connection.workspaceId ?? connection.fallbackWorkspaceId ?? null)\n : sessionWorkspaceId,\n live,\n user,\n userId: user?.externalId,\n ensureWorkspaceOpen: connection?.ensureWorkspaceOpen ?? keptOpenByHost,\n openWorkspace: async (workspaceId: string, options?: { name?: string }) => {\n if (connection) await connection.setWorkspace(workspaceId)\n showWorkspace(workspaceId, options)\n },\n }),\n // `user` is rebuilt each render without a connection: its key says when it changed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [connection, sessionWorkspaceId, live, userKey, showWorkspace]\n )\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connection/calendar/store.ts","../src/provider/dialog-registry.ts","../src/provider/settings-section.ts","../src/provider/requests.ts","../src/provider/environment.ts"],"names":["set","snapshot","listeners","subscribe","useSyncExternalStore","notifyStore","openDialog","closeDialog"],"mappings":";;;;;;AAqCO,IAAM,uBAAuB,MAAA,EAA0B;AAAA,EAC5D,OAAA;AAAA,IACE,CAACA,IAAAA,MAAS;AAAA,MACR,IAAA,EAAM,IAAA;AAAA,MACN,IAAA,EAAM,IAAA;AAAA,MACN,YAAA,EAAc,IAAA;AAAA,MACd,eAAA,EAAiB,IAAA;AAAA,MACjB,oBAAoB,CAAC,eAAA,KAAoBA,IAAAA,CAAI,EAAE,iBAAiB,CAAA;AAAA,MAChE,SAAS,CAAC,IAAA,KAASA,IAAAA,CAAI,EAA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AAM,MAAA,GAAS,OAAA,EAAS,MAAA,EAAQ,IAAA,EAAK;AACrC,MAAA,IAAI,MAAA,EAAQ,wBAAA,CAAyB,OAAA,CAAQ,MAAM,CAAA;AAAA,IACrD,CAAC,CAAA,IAAK;AAAA,GACV;AACA,EAAA,QAAA,CAAS,IAAI,KAAK,CAAA;AAClB,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,wBACd,WAAA,EACmB;AACnB,EAAA,IAAI,QAAA,CAAS,GAAA,CAAI,WAAgC,CAAA,EAAG,OAAO,WAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,WAAW,CAAA;AACpC,EAAA,IAAI,CAAC,OAAO,QAAA,CAAS,GAAA,CAAI,aAAc,KAAA,GAAQ,OAAA,CAAQ,WAAW,CAAE,CAAA;AACpE,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,oBAAA,GAA0C;AACxD,EAAA,MAAM,WAAA,GAAc,qBAAoB,CAAE,WAAA;AAC1C,EAAA,OAAO,WAAA,GAAc,uBAAA,CAAwB,WAAW,CAAA,GAAI,kBAAA;AAC9D;AAGO,SAAS,gBAAA,GAA0E;AACxF,EAAA,MAAM,EAAE,UAAA,EAAAC,WAAAA,EAAY,WAAA,EAAAC,YAAAA,KAAgB,oBAAA,EAAqB;AACzD,EAAA,OAAO,EAAE,UAAA,EAAAD,WAAAA,EAAY,WAAA,EAAAC,YAAAA,EAAY;AACnC;AAMO,SAAS,eAAA,GAAqD;AACnE,EAAA,MAAM,EAAE,YAAA,EAAc,UAAA,EAAW,GAAI,oBAAA,EAAqB;AAC1D,EAAA,MAAM,OAAA,GAAU,WAAW,WAAW,CAAA;AACtC,EAAA,OAAO,UAAU,YAAA,GAAe,MAAA;AAClC","file":"chunk-QZUZPC4J.js","sourcesContent":["/**\n * The connected calendar's view state: the chosen view is remembered across reloads (localStorage),\n * the anchor date lives for the session, and two requests carry intents from elsewhere into the\n * calendar once it mounts: an event to open (a deep link, a reminder) and a prefilled new event\n * (\"Schedule a call\" from a thread). The host navigates to its calendar page after making one.\n */\nimport { create } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport type { CalendarViewKind } from '../../calendar/types'\n\n/** \"Schedule a call\" from elsewhere (a thread, a DM, a dashboard): the editor opens prefilled. */\nexport interface CalendarComposerPrefill {\n title?: string\n attendees?: { email?: string | null; user_id?: string | null; name?: string | null }[]\n conversationId?: string | null\n /** Add an ARBI call when the event is saved (\"Add ARBI call\" ticked). */\n addCall?: boolean\n}\n\nexport interface PendingCalendarEvent {\n id: string\n recurrenceId?: string | null\n}\n\ninterface CalendarViewState {\n /** `null` until the user picks one: the settings' default view applies. */\n view: CalendarViewKind | null\n /** YYYY-MM-DD anchor; `null` = today. */\n date: string | null\n pendingEvent: PendingCalendarEvent | null\n pendingComposer: CalendarComposerPrefill | null\n setPendingComposer: (prefill: CalendarComposerPrefill | null) => void\n setView: (view: CalendarViewKind) => void\n setDate: (date: string | null) => void\n setPendingEvent: (pending: PendingCalendarEvent | null) => void\n}\n\nexport const useCalendarViewStore = create<CalendarViewState>()(\n persist(\n (set) => ({\n view: null,\n date: null,\n pendingEvent: null,\n pendingComposer: null,\n setPendingComposer: (pendingComposer) => set({ pendingComposer }),\n setView: (view) => set({ view }),\n setDate: (date) => set({ date }),\n setPendingEvent: (pendingEvent) => set({ pendingEvent }),\n }),\n {\n name: 'arbi-calendar-view',\n storage: createJSONStorage(() => localStorage),\n partialize: (s) => ({ view: s.view }),\n }\n )\n)\n\nconst EVT_RE = /^evt-[A-Za-z0-9]{8}$/\n\n/** Ask the calendar to open on an event (ignored unless it is an `evt-` id). */\nexport function requestCalendarEvent(event: PendingCalendarEvent): void {\n if (EVT_RE.test(event.id)) useCalendarViewStore.getState().setPendingEvent(event)\n}\n\n/** Ask the calendar to open the event editor prefilled. */\nexport function requestCalendarComposer(prefill: CalendarComposerPrefill): void {\n useCalendarViewStore.getState().setPendingComposer(prefill)\n}\n","/**\n * The global dialogs: one registry of what is open, so any surface (a kit, a command, code outside\n * React such as an API middleware) opens a dialog by kind, and the one `<ConnectedGlobalDialogs>`\n * mounted in the shell shows it. Each kind is open or not; an open kind holds the props it was\n * opened with. Opening a kind that is already open replaces its props.\n *\n * Kits reach it through the environment (`useBlocksEnvironment().openDialog`), which a host may\n * replace; code outside React calls `openDialog` / `closeDialog` here. Confirm and choice prompts\n * are promise-based instead (`./dialogs`).\n */\nimport { useSyncExternalStore } from 'react'\nimport type { components } from '@arbidocs/client'\nimport type { WorkflowLaunchRequest } from '../agents/workflows/launchRequest'\nimport type { QuotaExceededInfo } from '../connection/billing/ConnectedQuotaDialog'\n\ntype NotificationResponse = components['schemas']['NotificationResponse']\n\n/** Where files are added from: this device, links, or an email account. */\nexport type UploadSource = 'computer' | 'internet' | 'email'\n\n/** What `openShare` shares by email. */\nexport interface ShareRequest {\n resourceType: 'document' | 'conversation'\n resourceExtId: string\n workspaceExtId: string\n resourceName?: string\n /** Whether it is private to its owner now: the dialog offers to share it with the workspace. */\n isPrivate: boolean\n}\n\n/** The upload dialog: files or links already picked, one source, a folder to add them to. */\nexport interface UploadDialogProps {\n /** The tab it opens on (default `upload`). */\n tab?: 'upload' | 'status'\n files?: File[]\n urls?: string[]\n /** Only this source (from an \"Add\" menu). None: every source. */\n source?: UploadSource | null\n /** The folder the files go into. */\n folder?: string | null\n /** Right after a workspace was created: where to go next is offered, and it stays open. */\n newWorkspace?: boolean\n}\n\n/** The create-workspace dialog: in a project (locked to it), or the first-login welcome copy. */\nexport interface CreateWorkspaceDialogProps {\n projectId?: string | null\n variant?: 'default' | 'welcome'\n}\n\n/** Each global dialog, by kind, and the props it is opened with. */\nexport interface BlocksDialogProps {\n /** Add files (upload, links, email). */\n upload: UploadDialogProps\n /** A project's AI usage for the month is used up. */\n quota: QuotaExceededInfo\n /** The first-login snapshot for free users. */\n welcome: Record<string, never>\n /** Share a document or a thread by email. */\n share: ShareRequest\n createWorkspace: CreateWorkspaceDialogProps\n /** Export, copy or move the whole open workspace. */\n transfer: Record<string, never>\n /** Number the selected documents as a production set. */\n productionSet: Record<string, never>\n /** Invite people as contacts. */\n inviteContacts: Record<string, never>\n /** Review a workspace access request (its notification). */\n grantAccess: { notification: NotificationResponse }\n /** Browse, run and edit skills, optionally on one. */\n skillsBrowser: { skillSlug?: string }\n /** Start a workflow with some inputs preset (or at once, `autoStart`). */\n workflowLaunch: WorkflowLaunchRequest\n /** Sign out of this session or all of them. */\n logout: Record<string, never>\n /** Restore an archived workspace. */\n unarchiveWorkspace: { workspaceId: string }\n /** The open conversation's settings. */\n conversationSettings: Record<string, never>\n /** Pick the open conversation's documents. */\n conversationDocuments: Record<string, never>\n}\n\nexport type BlocksDialogKind = keyof BlocksDialogProps\n\n/** The props argument: optional for a kind whose props are all optional. */\nexport type DialogPropsArg<K extends BlocksDialogKind> =\n Record<never, never> extends BlocksDialogProps[K]\n ? [props?: BlocksDialogProps[K]]\n : [props: BlocksDialogProps[K]]\n\ntype OpenDialogs = { readonly [K in BlocksDialogKind]?: BlocksDialogProps[K] }\n\nlet open: OpenDialogs = {}\nconst listeners = new Set<() => void>()\n\nfunction set(next: OpenDialogs) {\n open = next\n listeners.forEach((listener) => listener())\n}\n\n/** Open a dialog (replacing the props of one already open). */\nexport function openDialog<K extends BlocksDialogKind>(kind: K, ...[props]: DialogPropsArg<K>) {\n set({ ...open, [kind]: props ?? {} })\n}\n\n/** Close a dialog (nothing happens when it is not open). */\nexport function closeDialog(kind: BlocksDialogKind): void {\n if (!(kind in open)) return\n const next = { ...open }\n delete next[kind]\n set(next)\n}\n\n/** Close every dialog (signing out). */\nexport function closeAllDialogs(): void {\n if (Object.keys(open).length > 0) set({})\n}\n\n/** The props an open dialog was opened with, or `null` while it is closed. */\nexport function getDialog<K extends BlocksDialogKind>(kind: K): BlocksDialogProps[K] | null {\n return (open[kind] as BlocksDialogProps[K] | undefined) ?? null\n}\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\n/** A dialog's props while it is open, `null` while closed; re-renders when it opens or closes. */\nexport function useDialogProps<K extends BlocksDialogKind>(kind: K): BlocksDialogProps[K] | null {\n const snapshot = () => getDialog(kind)\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n","/**\n * The settings section asked for last, so `openSettings(section)` opens that section in every host.\n *\n * `BlocksEnvironment.openSettings` records the section here before the host shows its settings\n * (a panel, a route); a `ConnectedSettingsPage` without its own `section` prop opens at it and\n * follows every later request, even one for the section asked for before. A host that keeps the\n * open section itself (`section` + `onSectionChange`) routes `openSettings` to its own state.\n */\nimport { useSyncExternalStore } from 'react'\n\nexport interface SettingsSectionRequest {\n section: string\n /** Increases with every request, so asking again for the same section is a new request. */\n seq: number\n}\n\nlet request: SettingsSectionRequest | undefined\nconst listeners = new Set<() => void>()\n\n/** Ask for a settings section; no section asks for none (the page stays where it is). */\nexport function requestSettingsSection(section?: string): void {\n if (!section) return\n request = { section, seq: (request?.seq ?? 0) + 1 }\n listeners.forEach((listener) => listener())\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nconst snapshot = () => request\n\n/** The last settings-section request (`undefined` until there is one). */\nexport function useRequestedSettingsSection(): SettingsSectionRequest | undefined {\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n","/**\n * What an intent asks of the surface it opens, carried across the navigation: the first message\n * of a new conversation (`openNewConversation({ prompt })`) and the email draft to show\n * (`openMail({ draftId })`). The environment records the request before the host navigates; the\n * surface takes it when it mounts, or at once while it is already on screen. Taking clears it, so\n * a request is acted on once, by one surface.\n */\nimport { useEffect, useRef } from 'react'\n\nexport interface IntentRequest<T> {\n /** Record a request (replacing one not taken yet). */\n request(value: T): void\n /** The pending request, cleared: `undefined` when there is none. */\n take(): T | undefined\n /** Calls `listener` whenever a request is made. */\n subscribe(listener: () => void): () => void\n}\n\nfunction intentRequest<T>(): IntentRequest<T> {\n let pending: { value: T } | undefined\n const listeners = new Set<() => void>()\n return {\n request(value) {\n pending = { value }\n listeners.forEach((listener) => listener())\n },\n take() {\n const taken = pending\n pending = undefined\n return taken?.value\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n}\n\n/**\n * Take each request while `enabled`: the one pending on mount and every later one. The latest\n * `onRequest` is called.\n */\nexport function useIntentRequest<T>(\n store: IntentRequest<T>,\n onRequest: (value: T) => void,\n enabled = true\n): void {\n const latest = useRef(onRequest)\n latest.current = onRequest\n useEffect(() => {\n if (!enabled) return\n const take = () => {\n const value = store.take()\n if (value !== undefined) latest.current(value)\n }\n take()\n return store.subscribe(take)\n }, [store, enabled])\n}\n\n/** The first message of the new conversation `openNewConversation({ prompt })` showed. */\nexport const conversationStartRequest = intentRequest<string>()\n\n/** The email draft `openMail({ draftId })` showed. */\nexport const mailDraftRequest = intentRequest<string>()\n","import type { ReactNode } from 'react'\nimport {\n notify as notifyStore,\n useHostConfigRecord,\n type NotifyOptions,\n type NotifyVariant,\n} from '@arbidocs/react/shell'\nimport type { BlockLinkComponent } from '../components/blockLink'\nimport { requestCalendarEvent, type PendingCalendarEvent } from '../connection/calendar/store'\nimport { choiceDialog, confirmDialog, type ChoiceRequest, type ConfirmRequest } from './dialogs'\nimport {\n closeDialog,\n openDialog,\n type BlocksDialogKind,\n type DialogPropsArg,\n type ShareRequest,\n type UploadSource,\n} from './dialog-registry'\nimport { conversationStartRequest, mailDraftRequest } from './requests'\nimport { requestSettingsSection } from './settings-section'\n\n/** What blocks need from the host's runtime configuration (the app's `config.json`). */\nexport interface BlocksRuntimeConfig {\n /** Origin of the ARBI API; `''` means the page's own origin. */\n apiBaseUrl: string\n /** The deployment's domain, e.g. `www.arbidocs.com` (deep links, key derivation, labels). */\n deploymentDomain: string\n /** Where seats are added for this deployment (a Box's licence page); none: its settings. */\n licenceUrl?: string\n}\n\nexport interface OpenDocumentOptions {\n /** 1-based page to scroll to. */\n page?: number\n /** Passage (chunk) to highlight. */\n passageId?: string\n /**\n * The workspace the document is in, when it is not the open one (a document an agent wrote in\n * its own workspace): the host opens that workspace first.\n */\n workspaceId?: string\n /** An earlier version (1-based); none: the current one. */\n version?: number\n /** The viewer tab to show: `pdf` is where a signature request is reviewed and signed. */\n tab?: 'pdf'\n}\n\nexport type { ShareRequest, UploadSource }\n\nexport interface OpenWordEditorOptions {\n /** The comment to show (a mention in it, a reply to it). */\n commentId?: string\n /** The workspace the document is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenConversationOptions {\n /** The message to scroll to. */\n messageId?: string\n /** The open document stays on screen beside the thread (a thread about it). */\n keepDocumentOpen?: boolean\n /** The workspace the thread is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenNewConversationOptions {\n /** Its first message, sent once the new conversation is ready (an ask bar, \"Ask about this\"). */\n prompt?: string\n /** The open document stays on screen beside it (a chat started from it). */\n keepDocumentOpen?: boolean\n}\n\nexport interface OpenWorkflowOptions {\n /** The workflow's editor (default) or its runs. */\n view?: 'builder' | 'runs'\n /** The workspace the workflow is in, when it is not the open one. */\n workspaceId?: string\n}\n\nexport interface OpenMailOptions {\n /** The email draft to show (a draft a workflow step or an agent left), to check and send. */\n draftId?: string\n /** The folder to show (`inbox`, `sent`, `trash`, `outbox`…). Default: the host's own. */\n folder?: string\n}\n\nexport interface OpenCalendarOptions {\n /** The event to open on. */\n event?: PendingCalendarEvent\n}\n\n/** Parts of the product a host can turn off (a setting, a plan): a kit offers them only when on. */\nexport type BlocksFeature = 'workflows' | 'mail' | 'databases'\n\n/** What `openFiles` shows: some files selected, and the list narrowed. */\nexport interface OpenFilesOptions {\n /** Files to select. */\n select?: string[]\n /** Quick filters by key (a label id, `folder:<path>`, `folder:none`): show or hide those files. */\n filters?: Record<string, 'include' | 'exclude'>\n}\n\n/**\n * Something a kit links to (the target of an `open…` intent), for `hrefFor`. `workspaceId` is the\n * workspace it is in, when the kit knows it.\n */\nexport type LinkTarget =\n | { kind: 'document'; documentId: string; workspaceId?: string | null }\n | {\n kind: 'conversation'\n conversationId: string\n workspaceId?: string | null\n messageId?: string\n }\n | { kind: 'workspace'; workspaceId: string }\n /** A project; none: the projects list. */\n | { kind: 'project'; projectId?: string }\n /** A workflow (its editor); none: the workflows list. */\n | { kind: 'workflow'; workflowId?: string; workspaceId?: string | null }\n /** The mailbox, on an email draft when given. */\n | { kind: 'mail'; draftId?: string }\n /** The user's settings, at a section when given. */\n | { kind: 'settings'; section?: string }\n /** The calendar, on an event when given. */\n | { kind: 'calendar'; eventId?: string }\n\n/**\n * The only way blocks reach the host app's environment: the host configuration's `environment`\n * (`<ArbiHost config={{ environment: { navigate, notify, … } }}>`). Blocks never import a router, a\n * toast library or an app store; the host gives what it has, and every field has a safe default so\n * a block renders correctly with no host at all. A nested host overrides only the fields it gives\n * and inherits the rest.\n */\nexport interface BlocksEnvironment {\n /** Router-aware link (keeps navigation in-SPA). Default: a plain `<a href>`. */\n linkComponent?: BlockLinkComponent\n /** Imperative navigation for buttons and keyboard shortcuts. Default: `window.location.assign`. */\n navigate: (href: string) => void\n /** Surface a transient message (and record it in the notification centre). Default: the shared\n * `@arbidocs/react` notify store, rendered by its `<Toaster/>`. */\n notify: (message: ReactNode, kind?: NotifyVariant, options?: NotifyOptions) => void\n /** Ask the user to confirm. Default: the blocks prompt dialog. */\n confirm: (request: ConfirmRequest) => Promise<boolean>\n /** Ask the user to pick one of several choices; `null` when dismissed. Default: the blocks\n * prompt dialog. */\n choose: <T extends string>(request: ChoiceRequest<T>) => Promise<T | null>\n /**\n * Open a global dialog by kind (`BlocksDialogProps`), shown by the one `<ConnectedGlobalDialogs>`\n * in the shell. Default: the blocks dialog registry.\n */\n openDialog: <K extends BlocksDialogKind>(kind: K, ...props: DialogPropsArg<K>) => void\n /** Close a global dialog. Default: the blocks dialog registry. */\n closeDialog: (kind: BlocksDialogKind) => void\n /** Deployment configuration. Default: same-origin API on the page's own host. */\n runtimeConfig: BlocksRuntimeConfig\n /**\n * The address of a target in the host's router, for a real link (open in a new tab, middle-click,\n * copy link) beside the matching `open…` intent: a kit never builds an app path itself, so its\n * links and its navigation agree on every site. `undefined`: no link (the row still opens on a\n * click). Default: none. ARBI-style paths (`/wrk-…/doc-…`): `deepLinkHref`.\n */\n hrefFor: (target: LinkTarget) => string | undefined\n /** Open a document (optionally at a page / passage) wherever the host shows documents.\n * Default: no-op. */\n openDocument: (documentId: string, options?: OpenDocumentOptions) => void\n /**\n * Open a Word document (`opensInWord`) in the host's Word editor, optionally on a comment.\n * Default: `openDocument` (a host whose viewer edits Word documents in place needs no other).\n */\n openWordEditor: (documentId: string, options?: OpenWordEditorOptions) => void\n /** Open a conversation thread, optionally scrolled to a message. Default: no-op. */\n openConversation: (conversationId: string, options?: OpenConversationOptions) => void\n /**\n * Show a new, empty conversation, unbound to any document. With a `prompt` it is sent as the\n * first message once the conversation is ready (recorded for the chat that shows it:\n * `ConnectedConversation`, `ChatPage`). Without one a launch composes into the session's draft\n * after this. Default: no-op.\n */\n openNewConversation: (options?: OpenNewConversationOptions) => void\n /**\n * Open the user's settings, optionally at a section (a `ConnectedSettingsPage` section id).\n * The section is always recorded for `ConnectedSettingsPage` first (`requestSettingsSection`);\n * the host's handler then shows its settings. Default: only that record.\n */\n openSettings: (section?: string) => void\n /** Open a project; no id: the projects list. Default: no-op. */\n openProject: (projectId?: string) => void\n /**\n * Show the calendar page (`ConnectedCalendar`), optionally on an event (recorded for the\n * calendar first: `requestCalendarEvent`). Default: only that record.\n */\n openCalendar: (options?: OpenCalendarOptions) => void\n /**\n * Show the mailbox (`ConnectedMailbox`), optionally on an email draft (recorded for the mailbox\n * first). Absent: the host has no mail, and a kit offers no way to open it.\n */\n openMail?: (options?: OpenMailOptions) => void\n /** Show the host's calls page (call history, scheduled calls). Absent: not offered. */\n openCalls?: () => void\n /** Open the direct chat with a person (the host's messenger). Absent: not offered. */\n openDirectChat?: (userId: string) => void\n /** Open one of my chats (a group or meeting chat) in the host's messenger. Absent: not offered. */\n openChat?: (chatId: string) => void\n /** Show the host's notification centre (`ConnectedNotificationCenter`), optionally on one\n * entry (`focusId`). Absent: not offered. */\n openNotifications?: (options?: { focusId?: string }) => void\n /** Show the host's contacts (a panel it toggles, a page). Absent: not offered. */\n openContacts?: () => void\n /** Show the host's databases page (user-defined tables). Absent: not offered. */\n openDatabases?: () => void\n /** Show the host's tags page (people, organisations and the other tags). Absent: not offered. */\n openTags?: () => void\n /**\n * Open a workflow in the host's Workflows page (its editor, or its runs); no id: the list.\n * Offered only while the `workflows` feature is on (`useOpenWorkflow`). Absent: never.\n */\n openWorkflow?: (workflowId?: string, options?: OpenWorkflowOptions) => void\n /**\n * A React hook: whether a part of the product is on for this user (a setting, a plan). Kits\n * offer what is off nowhere. Default: everything is on.\n */\n useFeature: (feature: BlocksFeature) => boolean\n /** Show the open workspace's files, optionally with some selected and the list narrowed. Default: no-op. */\n openFiles: (options?: OpenFilesOptions) => void\n /**\n * Add files the host's way (its upload dialog), optionally with some already picked, or from one\n * source. Absent: a kit that adds files uploads them itself.\n */\n openUpload?: (files?: File[], options?: { source?: UploadSource }) => void\n /** Open the host's skills browser, optionally at one skill. Absent: not offered. */\n openSkillsBrowser?: (skillSlug?: string) => void\n /** Share a document or a thread by email (the host's share dialog). Absent: not offered. */\n openShare?: (request: ShareRequest) => void\n /**\n * Show a workspace (its own page). Under `defaultHost`'s sign-in layer the kits select it first\n * (`useConnectedWorkspace().openWorkspace`); a host that keeps its own session switches to it\n * here. `name` is for the host's messages. Default: no-op.\n */\n openWorkspace: (workspaceId: string, options?: { name?: string }) => void\n}\n\nconst noop = () => {}\n\nconst defaultEnvironment: BlocksEnvironment = {\n navigate: (href) => {\n if (typeof window !== 'undefined') window.location.assign(href)\n },\n notify: (message, kind = 'info', options) => {\n notifyStore[kind](message, options)\n },\n confirm: confirmDialog,\n choose: choiceDialog,\n openDialog,\n closeDialog,\n runtimeConfig: {\n apiBaseUrl: '',\n deploymentDomain: typeof window !== 'undefined' ? window.location.host : '',\n },\n hrefFor: () => undefined,\n openDocument: noop,\n openWordEditor: noop,\n openConversation: noop,\n openNewConversation: noop,\n openSettings: requestSettingsSection,\n openProject: noop,\n openCalendar: (options) => {\n if (options?.event) requestCalendarEvent(options.event)\n },\n useFeature: () => true,\n openFiles: noop,\n openWorkspace: noop,\n}\n\nconst resolved = new WeakMap<object, BlocksEnvironment>()\nconst complete = new WeakSet<BlocksEnvironment>()\n// The intents below that record what they open on: a resolved environment passed on again (a\n// nested host's, `createBlocksEnvironment`'s) records once, not twice.\nconst recording = new WeakSet<object>()\n\nfunction records<F extends object>(intent: F): F {\n recording.add(intent)\n return intent\n}\n\nfunction recordingIntent<F extends object>(\n host: F | undefined,\n wrap: (host: F) => F\n): F | undefined {\n if (!host) return undefined\n return recording.has(host) ? host : records(wrap(host))\n}\n\nfunction resolve(environment: Partial<BlocksEnvironment>): BlocksEnvironment {\n const { openDocument } = environment\n const value: BlocksEnvironment = {\n ...defaultEnvironment,\n openWordEditor: openDocument\n ? (documentId, options) => openDocument(documentId, { workspaceId: options?.workspaceId })\n : noop,\n ...environment,\n // What an intent opens on is recorded for the surface before the host shows it.\n openSettings:\n recordingIntent(environment.openSettings, (openSettings) => (section) => {\n requestSettingsSection(section)\n openSettings(section)\n }) ?? defaultEnvironment.openSettings,\n openCalendar:\n recordingIntent(environment.openCalendar, (openCalendar) => (options) => {\n defaultEnvironment.openCalendar(options)\n openCalendar(options)\n }) ?? defaultEnvironment.openCalendar,\n openMail: recordingIntent(environment.openMail, (openMail) => (options) => {\n if (options?.draftId) mailDraftRequest.request(options.draftId)\n openMail(options)\n }),\n openNewConversation:\n recordingIntent(environment.openNewConversation, (openNewConversation) => (options) => {\n openNewConversation(options)\n // After the host's reset of the new conversation, which clears its draft.\n const prompt = options?.prompt?.trim()\n if (prompt) conversationStartRequest.request(prompt)\n }) ?? noop,\n }\n complete.add(value)\n return value\n}\n\n/**\n * The environment with every field filled in (the defaults where `environment` gives none), and\n * every intent recording what it opens on. A host calls it for code outside React (a store action,\n * a notification handler); passing the result as the host configuration's `environment` uses it\n * as is.\n */\nexport function createBlocksEnvironment(\n environment: Partial<BlocksEnvironment>\n): BlocksEnvironment {\n if (complete.has(environment as BlocksEnvironment)) return environment as BlocksEnvironment\n let value = resolved.get(environment)\n if (!value) resolved.set(environment, (value = resolve(environment)))\n return value\n}\n\n/** The host's environment, every field filled in (the defaults where the host gives none). */\nexport function useBlocksEnvironment(): BlocksEnvironment {\n const environment = useHostConfigRecord().environment as Partial<BlocksEnvironment> | undefined\n return environment ? createBlocksEnvironment(environment) : defaultEnvironment\n}\n\n/** Open and close the global dialogs (`<ConnectedGlobalDialogs>`), the host's way. */\nexport function useBlocksDialogs(): Pick<BlocksEnvironment, 'openDialog' | 'closeDialog'> {\n const { openDialog, closeDialog } = useBlocksEnvironment()\n return { openDialog, closeDialog }\n}\n\n/**\n * How to open a workflow in the host's Workflows page, or `undefined` while there is none (the\n * host has no `openWorkflow`, or the `workflows` feature is off).\n */\nexport function useOpenWorkflow(): BlocksEnvironment['openWorkflow'] {\n const { openWorkflow, useFeature } = useBlocksEnvironment()\n const enabled = useFeature('workflows')\n return enabled ? openWorkflow : undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/dialogs.tsx"],"names":["useMemo","useRef","jsxs","ModalScaffold","jsx","AlertTriangle","testIdOr","Button","useState","Info","AlertCircle"],"mappings":";;;;;;;;;AAyBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY;AACd;AAyBO,SAAS,aAAA,CAAc;AAAA,EAC5B,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA,GAAU,aAAA;AAAA,EACV,SAAA,GAAY,KAAA;AAAA,EACZ,MAAA;AAAA,EACA,MAAA;AAAA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ACR,OAAA,EAAS,EAAE,OAAA,EAAS,yBAAA,EAA2B,QAAQ,wBAAA;AAAyB,UAElF;AAAC;AAAA,GACP;AAEJ;AAGA,eAAsB,cAAc,OAAA,EAA2C;AAC7E,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,IAAQ,SAAA;AAC7B,EAAA,IAAI,SAAS,OAAA,EAAS;AACpB,IAAA,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa;AAAA,MAChC,SAAS,OAAA,CAAQ,OAAA;AAAA,MACjB,KAAA,EAAO,QAAQ,KAAA,IAAS,OAAA;AAAA,MACxB,SAAS,CAAC,EAAE,OAAO,IAAA,EAAM,KAAA,EAAO,MAAM,CAAA;AAAA,MACtC,IAAA,EAAM,MAAA;AAAA,MACN,MAAA,EAAQ;AAAA,KACT,CAAA;AACD,IAAA,OAAO,MAAA,KAAW,IAAA;AAAA,EACpB;AACA,EAAA,OAAO,WAAA,CAAY,KAAA,EAAO,CAAC,MAAA,qBACzBA,cAAA,CAAC,iBAAc,OAAA,EAAkB,IAAA,EAAY,QAAA,EAAU,MAAA,EAAQ,CAChE,CAAA;AACH","file":"chunk-SI222Z3A.cjs","sourcesContent":["/**\n * The one confirmation dialog, and the promise-based prompts built on it — the blocks replacement\n * for `window.confirm` / `window.alert`.\n *\n * - `ConfirmDialog` is the declarative yes/no dialog (with a loading state and optional content).\n * - `confirmDialog()` shows that same dialog from any event handler: each call mounts its own\n * short-lived React root, so no dialog host is needed in the tree.\n * - `choiceDialog()` offers arbitrary choices (Overwrite / Skip / Cancel); an `alert` is one OK.\n *\n * Hosts reach the prompts through `useBlocksEnvironment().confirm` / `.choose` (the defaults),\n * which lets an app swap in its own dialogs without touching callers.\n */\nimport { useMemo, useRef, useState, type ReactElement, type ReactNode } from 'react'\nimport { AlertCircle, AlertTriangle, Info } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { testIdOr } from '../chat/test-id'\nimport { ModalScaffold } from '../settings/ModalScaffold'\n\n/** Every fixed string of the confirm dialog. `confirmText` / `cancelText` props win. */\nexport interface ConfirmDialogLabels {\n confirm: string\n cancel: string\n pleaseWait: string\n}\n\nexport const DEFAULT_CONFIRM_DIALOG_LABELS: ConfirmDialogLabels = {\n confirm: 'Confirm',\n cancel: 'Cancel',\n pleaseWait: 'Please wait...',\n}\n\nexport interface ConfirmDialogProps {\n labels?: Partial<ConfirmDialogLabels>\n isOpen: boolean\n onClose: () => void\n onConfirm: () => void\n title: string\n description: string\n confirmText?: string\n cancelText?: string\n variant?: 'destructive' | 'default'\n isLoading?: boolean\n /** Dialog test id (default `confirmation-modal`). */\n testId?: string\n /** Button ids; defaults are the current ids. */\n testIds?: Partial<Record<'cancel' | 'confirm', string>>\n /** Extra content between the description and the buttons (e.g. an opt-in checkbox). */\n children?: ReactNode\n}\n\n/**\n * Declarative yes/no confirmation with a loading state. An `alertdialog`: initial focus is on\n * Cancel (the safe action) and clicking outside does not dismiss it; Escape and Cancel do.\n */\nexport function ConfirmDialog({\n isOpen,\n onClose,\n onConfirm,\n title,\n description,\n confirmText,\n cancelText,\n variant = 'destructive',\n isLoading = false,\n labels,\n testId,\n testIds,\n children,\n}: ConfirmDialogProps) {\n const l = useMemo(() => ({ ...DEFAULT_CONFIRM_DIALOG_LABELS, ...labels }), [labels])\n const cancelRef = useRef<HTMLButtonElement>(null)\n return (\n <ModalScaffold\n open={isOpen}\n onOpenChange={(next) => {\n if (!next) onClose()\n }}\n role=\"alertdialog\"\n initialFocusRef={cancelRef}\n title={title}\n description={<span className=\"whitespace-pre-line\">{description}</span>}\n showDescription\n icon={\n variant === 'destructive' ? (\n <AlertTriangle className=\"h-5 w-5 text-red-text\" aria-hidden=\"true\" />\n ) : null\n }\n testId={testIdOr(testId, { testId: 'confirmation-modal' })}\n >\n {children}\n <ModalScaffold.Footer>\n <Button\n ref={cancelRef}\n variant=\"outline\"\n onClick={() => onClose()}\n disabled={isLoading}\n data-testid={testIdOr(testIds?.cancel, { testId: 'confirmation-modal-cancel-button' })}\n >\n {cancelText ?? l.cancel}\n </Button>\n <Button\n variant={variant}\n onClick={onConfirm}\n disabled={isLoading}\n data-testid={testIdOr(testIds?.confirm, { testId: 'confirmation-modal-confirm-button' })}\n >\n {isLoading ? l.pleaseWait : (confirmText ?? l.confirm)}\n </Button>\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\ntype ChoiceVariant = 'default' | 'destructive' | 'outline'\n\nexport interface PromptChoice<T extends string> {\n label: string\n value: T\n variant?: ChoiceVariant\n}\n\n/** A dialog offering arbitrary choices (e.g. Overwrite / Skip / Cancel). */\nexport interface ChoiceRequest<T extends string> {\n message: string\n title?: string\n choices: PromptChoice<T>[]\n icon?: 'alert' | 'info'\n /** Dialog test id; each button is `${testId}-${value}-button`. Default `choice-modal`. */\n testId?: string\n}\n\n/**\n * `confirm` — Cancel / Confirm (destructive); `yesno` — No / Yes; `alert` — a single OK\n * (resolves true once acknowledged).\n */\nexport type ConfirmKind = 'confirm' | 'yesno' | 'alert'\n\nexport interface ConfirmRequest {\n message: string\n /** Default: \"Alert\" for `alert`, else \"Confirm\". */\n title?: string\n kind?: ConfirmKind\n}\n\n/** Close animation length before the root is unmounted. */\nconst UNMOUNT_DELAY_MS = 300\n\nfunction PromptDialog<T extends string>({\n request,\n onSettle,\n}: {\n request: ChoiceRequest<T>\n onSettle: (value: T | null) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const { message, title = 'Confirm', choices, icon = 'alert', testId = 'choice-modal' } = request\n const settle = (value: T | null) => {\n setOpen(false)\n onSettle(value)\n }\n return (\n <ModalScaffold\n open={open}\n onOpenChange={(next) => {\n if (!next) settle(null)\n }}\n title={title}\n icon={\n icon === 'info' ? (\n <Info className=\"h-5 w-5 text-blue-text\" aria-hidden=\"true\" />\n ) : (\n <AlertCircle className=\"h-5 w-5\" aria-hidden=\"true\" />\n )\n }\n description={<span className=\"whitespace-pre-line\">{message}</span>}\n showDescription\n testId={testId}\n >\n <ModalScaffold.Footer>\n {choices.map((choice) => (\n <Button\n key={choice.value}\n variant={choice.variant ?? 'default'}\n onClick={() => settle(choice.value)}\n data-testid={`${testId}-${choice.value.toLowerCase()}-button`}\n >\n {choice.label}\n </Button>\n ))}\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\n\n/** Mount a dialog in its own short-lived root; `render` gets the settle callback. */\nfunction mountDialog<R>(\n fallback: R,\n render: (settle: (value: R) => void) => ReactElement\n): Promise<R> {\n if (typeof document === 'undefined') return Promise.resolve(fallback)\n return new Promise((resolve) => {\n const container = document.createElement('div')\n document.body.appendChild(container)\n let settled = false\n void import('react-dom/client').then(({ createRoot }) => {\n const root = createRoot(container)\n const settle = (value: R) => {\n if (settled) return\n settled = true\n resolve(value)\n setTimeout(() => {\n root.unmount()\n container.remove()\n }, UNMOUNT_DELAY_MS)\n }\n root.render(render(settle))\n })\n })\n}\n\n/** Show a choice dialog; resolves with the chosen `value`, or `null` when dismissed. */\nexport function choiceDialog<T extends string>(request: ChoiceRequest<T>): Promise<T | null> {\n return mountDialog<T | null>(null, (settle) => (\n <PromptDialog request={request} onSettle={settle} />\n ))\n}\n\n/** `ConfirmDialog` driven by a promise: open until answered, then closes. */\nfunction PromptConfirm({\n request,\n kind,\n onSettle,\n}: {\n request: ConfirmRequest\n kind: 'confirm' | 'yesno'\n onSettle: (value: boolean) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const settle = (value: boolean) => {\n setOpen(false)\n onSettle(value)\n }\n const yesno = kind === 'yesno'\n return (\n <ConfirmDialog\n isOpen={open}\n onClose={() => settle(false)}\n onConfirm={() => settle(true)}\n title={request.title ?? 'Confirm'}\n description={request.message}\n variant={yesno ? 'default' : 'destructive'}\n {...(yesno\n ? {\n confirmText: 'Yes',\n cancelText: 'No',\n testId: 'yes-no-modal',\n testIds: { confirm: 'yes-no-modal-yes-button', cancel: 'yes-no-modal-no-button' },\n }\n : {})}\n />\n )\n}\n\n/** Show a confirmation; resolves true on Confirm / Yes / OK, false on cancel or dismissal. */\nexport async function confirmDialog(request: ConfirmRequest): Promise<boolean> {\n const kind = request.kind ?? 'confirm'\n if (kind === 'alert') {\n const choice = await choiceDialog({\n message: request.message,\n title: request.title ?? 'Alert',\n choices: [{ label: 'OK', value: 'ok' }],\n icon: 'info',\n testId: 'alert-modal',\n })\n return choice === 'ok'\n }\n return mountDialog(false, (settle) => (\n <PromptConfirm request={request} kind={kind} onSettle={settle} />\n ))\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider/dialogs.tsx"],"names":[],"mappings":";;;;;;;AAyBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,UAAA,EAAY;AACd;AAyBO,SAAS,aAAA,CAAc;AAAA,EAC5B,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA,GAAU,aAAA;AAAA,EACV,SAAA,GAAY,KAAA;AAAA,EACZ,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAA,GAAI,OAAA,CAAQ,OAAO,EAAE,GAAG,6BAAA,EAA+B,GAAG,MAAA,EAAO,CAAA,EAAI,CAAC,MAAM,CAAC,CAAA;AACnF,EAAA,MAAM,SAAA,GAAY,OAA0B,IAAI,CAAA;AAChD,EAAA,uBACE,IAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAM,MAAA;AAAA,MACN,YAAA,EAAc,CAAC,IAAA,KAAS;AACtB,QAAA,IAAI,CAAC,MAAM,OAAA,EAAQ;AAAA,MACrB,CAAA;AAAA,MACA,IAAA,EAAK,aAAA;AAAA,MACL,eAAA,EAAiB,SAAA;AAAA,MACjB,KAAA;AAAA,MACA,WAAA,kBAAa,GAA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,EACpB;AACA,EAAA,OAAO,WAAA,CAAY,KAAA,EAAO,CAAC,MAAA,qBACzB,GAAA,CAAC,iBAAc,OAAA,EAAkB,IAAA,EAAY,QAAA,EAAU,MAAA,EAAQ,CAChE,CAAA;AACH","file":"chunk-U4HWVCRN.js","sourcesContent":["/**\n * The one confirmation dialog, and the promise-based prompts built on it — the blocks replacement\n * for `window.confirm` / `window.alert`.\n *\n * - `ConfirmDialog` is the declarative yes/no dialog (with a loading state and optional content).\n * - `confirmDialog()` shows that same dialog from any event handler: each call mounts its own\n * short-lived React root, so no dialog host is needed in the tree.\n * - `choiceDialog()` offers arbitrary choices (Overwrite / Skip / Cancel); an `alert` is one OK.\n *\n * Hosts reach the prompts through `useBlocksEnvironment().confirm` / `.choose` (the defaults),\n * which lets an app swap in its own dialogs without touching callers.\n */\nimport { useMemo, useRef, useState, type ReactElement, type ReactNode } from 'react'\nimport { AlertCircle, AlertTriangle, Info } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { testIdOr } from '../chat/test-id'\nimport { ModalScaffold } from '../settings/ModalScaffold'\n\n/** Every fixed string of the confirm dialog. `confirmText` / `cancelText` props win. */\nexport interface ConfirmDialogLabels {\n confirm: string\n cancel: string\n pleaseWait: string\n}\n\nexport const DEFAULT_CONFIRM_DIALOG_LABELS: ConfirmDialogLabels = {\n confirm: 'Confirm',\n cancel: 'Cancel',\n pleaseWait: 'Please wait...',\n}\n\nexport interface ConfirmDialogProps {\n labels?: Partial<ConfirmDialogLabels>\n isOpen: boolean\n onClose: () => void\n onConfirm: () => void\n title: string\n description: string\n confirmText?: string\n cancelText?: string\n variant?: 'destructive' | 'default'\n isLoading?: boolean\n /** Dialog test id (default `confirmation-modal`). */\n testId?: string\n /** Button ids; defaults are the current ids. */\n testIds?: Partial<Record<'cancel' | 'confirm', string>>\n /** Extra content between the description and the buttons (e.g. an opt-in checkbox). */\n children?: ReactNode\n}\n\n/**\n * Declarative yes/no confirmation with a loading state. An `alertdialog`: initial focus is on\n * Cancel (the safe action) and clicking outside does not dismiss it; Escape and Cancel do.\n */\nexport function ConfirmDialog({\n isOpen,\n onClose,\n onConfirm,\n title,\n description,\n confirmText,\n cancelText,\n variant = 'destructive',\n isLoading = false,\n labels,\n testId,\n testIds,\n children,\n}: ConfirmDialogProps) {\n const l = useMemo(() => ({ ...DEFAULT_CONFIRM_DIALOG_LABELS, ...labels }), [labels])\n const cancelRef = useRef<HTMLButtonElement>(null)\n return (\n <ModalScaffold\n open={isOpen}\n onOpenChange={(next) => {\n if (!next) onClose()\n }}\n role=\"alertdialog\"\n initialFocusRef={cancelRef}\n title={title}\n description={<span className=\"whitespace-pre-line\">{description}</span>}\n showDescription\n icon={\n variant === 'destructive' ? (\n <AlertTriangle className=\"h-5 w-5 text-red-text\" aria-hidden=\"true\" />\n ) : null\n }\n testId={testIdOr(testId, { testId: 'confirmation-modal' })}\n >\n {children}\n <ModalScaffold.Footer>\n <Button\n ref={cancelRef}\n variant=\"outline\"\n onClick={() => onClose()}\n disabled={isLoading}\n data-testid={testIdOr(testIds?.cancel, { testId: 'confirmation-modal-cancel-button' })}\n >\n {cancelText ?? l.cancel}\n </Button>\n <Button\n variant={variant}\n onClick={onConfirm}\n disabled={isLoading}\n data-testid={testIdOr(testIds?.confirm, { testId: 'confirmation-modal-confirm-button' })}\n >\n {isLoading ? l.pleaseWait : (confirmText ?? l.confirm)}\n </Button>\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\ntype ChoiceVariant = 'default' | 'destructive' | 'outline'\n\nexport interface PromptChoice<T extends string> {\n label: string\n value: T\n variant?: ChoiceVariant\n}\n\n/** A dialog offering arbitrary choices (e.g. Overwrite / Skip / Cancel). */\nexport interface ChoiceRequest<T extends string> {\n message: string\n title?: string\n choices: PromptChoice<T>[]\n icon?: 'alert' | 'info'\n /** Dialog test id; each button is `${testId}-${value}-button`. Default `choice-modal`. */\n testId?: string\n}\n\n/**\n * `confirm` — Cancel / Confirm (destructive); `yesno` — No / Yes; `alert` — a single OK\n * (resolves true once acknowledged).\n */\nexport type ConfirmKind = 'confirm' | 'yesno' | 'alert'\n\nexport interface ConfirmRequest {\n message: string\n /** Default: \"Alert\" for `alert`, else \"Confirm\". */\n title?: string\n kind?: ConfirmKind\n}\n\n/** Close animation length before the root is unmounted. */\nconst UNMOUNT_DELAY_MS = 300\n\nfunction PromptDialog<T extends string>({\n request,\n onSettle,\n}: {\n request: ChoiceRequest<T>\n onSettle: (value: T | null) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const { message, title = 'Confirm', choices, icon = 'alert', testId = 'choice-modal' } = request\n const settle = (value: T | null) => {\n setOpen(false)\n onSettle(value)\n }\n return (\n <ModalScaffold\n open={open}\n onOpenChange={(next) => {\n if (!next) settle(null)\n }}\n title={title}\n icon={\n icon === 'info' ? (\n <Info className=\"h-5 w-5 text-blue-text\" aria-hidden=\"true\" />\n ) : (\n <AlertCircle className=\"h-5 w-5\" aria-hidden=\"true\" />\n )\n }\n description={<span className=\"whitespace-pre-line\">{message}</span>}\n showDescription\n testId={testId}\n >\n <ModalScaffold.Footer>\n {choices.map((choice) => (\n <Button\n key={choice.value}\n variant={choice.variant ?? 'default'}\n onClick={() => settle(choice.value)}\n data-testid={`${testId}-${choice.value.toLowerCase()}-button`}\n >\n {choice.label}\n </Button>\n ))}\n </ModalScaffold.Footer>\n </ModalScaffold>\n )\n}\n\n/** Mount a dialog in its own short-lived root; `render` gets the settle callback. */\nfunction mountDialog<R>(\n fallback: R,\n render: (settle: (value: R) => void) => ReactElement\n): Promise<R> {\n if (typeof document === 'undefined') return Promise.resolve(fallback)\n return new Promise((resolve) => {\n const container = document.createElement('div')\n document.body.appendChild(container)\n let settled = false\n void import('react-dom/client').then(({ createRoot }) => {\n const root = createRoot(container)\n const settle = (value: R) => {\n if (settled) return\n settled = true\n resolve(value)\n setTimeout(() => {\n root.unmount()\n container.remove()\n }, UNMOUNT_DELAY_MS)\n }\n root.render(render(settle))\n })\n })\n}\n\n/** Show a choice dialog; resolves with the chosen `value`, or `null` when dismissed. */\nexport function choiceDialog<T extends string>(request: ChoiceRequest<T>): Promise<T | null> {\n return mountDialog<T | null>(null, (settle) => (\n <PromptDialog request={request} onSettle={settle} />\n ))\n}\n\n/** `ConfirmDialog` driven by a promise: open until answered, then closes. */\nfunction PromptConfirm({\n request,\n kind,\n onSettle,\n}: {\n request: ConfirmRequest\n kind: 'confirm' | 'yesno'\n onSettle: (value: boolean) => void\n}): ReactElement {\n const [open, setOpen] = useState(true)\n const settle = (value: boolean) => {\n setOpen(false)\n onSettle(value)\n }\n const yesno = kind === 'yesno'\n return (\n <ConfirmDialog\n isOpen={open}\n onClose={() => settle(false)}\n onConfirm={() => settle(true)}\n title={request.title ?? 'Confirm'}\n description={request.message}\n variant={yesno ? 'default' : 'destructive'}\n {...(yesno\n ? {\n confirmText: 'Yes',\n cancelText: 'No',\n testId: 'yes-no-modal',\n testIds: { confirm: 'yes-no-modal-yes-button', cancel: 'yes-no-modal-no-button' },\n }\n : {})}\n />\n )\n}\n\n/** Show a confirmation; resolves true on Confirm / Yes / OK, false on cancel or dismissal. */\nexport async function confirmDialog(request: ConfirmRequest): Promise<boolean> {\n const kind = request.kind ?? 'confirm'\n if (kind === 'alert') {\n const choice = await choiceDialog({\n message: request.message,\n title: request.title ?? 'Alert',\n choices: [{ label: 'OK', value: 'ok' }],\n icon: 'info',\n testId: 'alert-modal',\n })\n return choice === 'ok'\n }\n return mountDialog(false, (settle) => (\n <PromptConfirm request={request} kind={kind} onSettle={settle} />\n ))\n}\n"]}
|