ryugi-artifacts 1.31.7 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/cli.cjs +496 -82
  2. package/dist/server.cjs +241 -53
  3. package/dist/viewer/CloudDocument-DBhwAPZX.js +1 -0
  4. package/dist/viewer/CloudLiveDocument-ceRinz2F.js +1 -0
  5. package/dist/viewer/{DocumentLayout-CbIehGxV.js → DocumentLayout-DUPesXt0.js} +141 -141
  6. package/dist/viewer/DocumentPage-p78IN0UO.js +1 -0
  7. package/dist/viewer/RailSwitch-B8Aht-FG.js +64 -0
  8. package/dist/viewer/{abnfDiagram-VCTEODGH-BwImveX1.js → abnfDiagram-VCTEODGH-Dz0T5wEI.js} +1 -1
  9. package/dist/viewer/{ar-SA-G6X2FPQ2-RpzZk-vo.js → ar-SA-G6X2FPQ2-Bytlrg0S.js} +1 -1
  10. package/dist/viewer/{architectureDiagram-5GKGNRK7-BhX61Vlu.js → architectureDiagram-5GKGNRK7-OYoo3ME7.js} +1 -1
  11. package/dist/viewer/{az-AZ-76LH7QW2-BVSWK8b7.js → az-AZ-76LH7QW2-w9f06xDk.js} +1 -1
  12. package/dist/viewer/{bg-BG-XCXSNQG7-Bpt9s0jR.js → bg-BG-XCXSNQG7-CEWDLlq7.js} +1 -1
  13. package/dist/viewer/{blockDiagram-I7D4REHJ-CljkTIL7.js → blockDiagram-I7D4REHJ-CAowR37U.js} +1 -1
  14. package/dist/viewer/{bn-BD-2XOGV67Q-BdFSuTbl.js → bn-BD-2XOGV67Q-DBNpDzHO.js} +1 -1
  15. package/dist/viewer/{c4Diagram-7LVT6UL2-D0iRCL-u.js → c4Diagram-7LVT6UL2-Dzzhg0Hl.js} +1 -1
  16. package/dist/viewer/{ca-ES-6MX7JW3Y-ClAdQpRf.js → ca-ES-6MX7JW3Y-Det2dq0q.js} +1 -1
  17. package/dist/viewer/{chunk-4HAMMTFA-Bp0_MHBC.js → chunk-4HAMMTFA-DZl9uS5D.js} +1 -1
  18. package/dist/viewer/{chunk-EIO257PC-C-qOSRvN.js → chunk-EIO257PC-CjCjUdBc.js} +1 -1
  19. package/dist/viewer/{chunk-GMAD6QVW-BFJ7kK_w.js → chunk-GMAD6QVW-CDRo04Dc.js} +1 -1
  20. package/dist/viewer/{chunk-GVQU2GXP-UaddXAPq.js → chunk-GVQU2GXP-BhrYhgpE.js} +1 -1
  21. package/dist/viewer/{chunk-IMKFNOWR-BSXuSZSV.js → chunk-IMKFNOWR-BfAgQjlN.js} +1 -1
  22. package/dist/viewer/{chunk-L3NEJ4N5-CCNBKnXZ.js → chunk-L3NEJ4N5-D-FTstxq.js} +1 -1
  23. package/dist/viewer/{chunk-OSK3NFVY-C6IbO0Jr.js → chunk-OSK3NFVY-CJgUgQQ4.js} +1 -1
  24. package/dist/viewer/{chunk-PWAF6VOD-kCQKhtQ5.js → chunk-PWAF6VOD-DWHqbvtp.js} +1 -1
  25. package/dist/viewer/{chunk-SHT3W25Y-CjszVd1a.js → chunk-SHT3W25Y-CBzt56Er.js} +1 -1
  26. package/dist/viewer/{chunk-SVP7TREG-BQ5ECbFL.js → chunk-SVP7TREG-b6pmQaqb.js} +1 -1
  27. package/dist/viewer/{chunk-TICWLB2K-CM3SXgeB.js → chunk-TICWLB2K-DIPK-gAO.js} +1 -1
  28. package/dist/viewer/{classDiagram-ZZMXUADV-CklLnwGV.js → classDiagram-ZZMXUADV-DgM9EY-7.js} +1 -1
  29. package/dist/viewer/{classDiagram-v2-VYDZK3BY-CklLnwGV.js → classDiagram-v2-VYDZK3BY-DgM9EY-7.js} +1 -1
  30. package/dist/viewer/{cs-CZ-2BRQDIVT-C9yZWjpH.js → cs-CZ-2BRQDIVT-CXEgS6Pi.js} +1 -1
  31. package/dist/viewer/{cynefinDiagram-5FMLGOSQ-pHGN68P6.js → cynefinDiagram-5FMLGOSQ-BQkxO3xf.js} +1 -1
  32. package/dist/viewer/{da-DK-5WZEPLOC-DNfdbnAi.js → da-DK-5WZEPLOC-D2twM2eB.js} +1 -1
  33. package/dist/viewer/{dagre-GXQ25YYZ-Cu5hDNcZ.js → dagre-GXQ25YYZ-DD_-ARQM.js} +1 -1
  34. package/dist/viewer/{de-DE-XR44H4JA-Dtf5rElI.js → de-DE-XR44H4JA-QQ3wzCUN.js} +1 -1
  35. package/dist/viewer/{diagram-S7CK7UJ4-BKmGJRFo.js → diagram-S7CK7UJ4-C6UhooWh.js} +1 -1
  36. package/dist/viewer/{diagram-UQ7AKVKN-CiImTxYb.js → diagram-UQ7AKVKN-CmOvdTfi.js} +1 -1
  37. package/dist/viewer/{diagram-VX7I27RA-KDRajhma.js → diagram-VX7I27RA-BQrnggcb.js} +1 -1
  38. package/dist/viewer/{diagram-Z3DM3KII-BaftiW-B.js → diagram-Z3DM3KII-eqq_bLYp.js} +1 -1
  39. package/dist/viewer/{dist-DnVCAc8Q.js → dist-A6XqCKp3.js} +1 -1
  40. package/dist/viewer/{dist-DH1y51Ji.js → dist-BHQRLarc.js} +1 -1
  41. package/dist/viewer/{dist-PRMB1ALz.js → dist-BVD4SXRG.js} +1 -1
  42. package/dist/viewer/{dist-BvAcUpu2.js → dist-C2_czco-.js} +1 -1
  43. package/dist/viewer/{dist-DZY6VV6F.js → dist-CBPL9nOI.js} +1 -1
  44. package/dist/viewer/{dist-vSbmlgLw.js → dist-CBa9iIgE.js} +1 -1
  45. package/dist/viewer/{dist-BIwkt9qv.js → dist-COWTq4PW.js} +1 -1
  46. package/dist/viewer/{dist-Dr0sIPMq.js → dist-CRFROhiU.js} +1 -1
  47. package/dist/viewer/{dist-CGMkgipD.js → dist-Cm3PtUTh.js} +1 -1
  48. package/dist/viewer/{dist-BwXQ338V.js → dist-CmuZXMYX.js} +1 -1
  49. package/dist/viewer/{dist-CmvbQIrE.js → dist-CvMMV1bh.js} +1 -1
  50. package/dist/viewer/{dist-hmKSLQSf.js → dist-D6ZK8Xjb.js} +1 -1
  51. package/dist/viewer/{dist-KWTwuZjj.js → dist-D9ubIHs9.js} +1 -1
  52. package/dist/viewer/{dist-BPjjkXfR.js → dist-DlqN5LCW.js} +1 -1
  53. package/dist/viewer/{dist-CJ7SqDZz.js → dist-Dvmx2QWc.js} +1 -1
  54. package/dist/viewer/{dist-Bf8Gpkfz.js → dist-DwneAiRo.js} +4 -4
  55. package/dist/viewer/{dist-y8ORXHnh.js → dist-IvjL_4Fz.js} +1 -1
  56. package/dist/viewer/{dist-Dzz8z2UZ.js → dist-MgwwM__x.js} +1 -1
  57. package/dist/viewer/{dist-BZ58JpdA.js → dist-QND2Lmk5.js} +1 -1
  58. package/dist/viewer/{dist-C4SdA9EW.js → dist-YskcL8-n.js} +1 -1
  59. package/dist/viewer/{dist-B15eZXtk.js → dist-lBA58Q6O.js} +1 -1
  60. package/dist/viewer/{dist-C12tszp1.js → dist-lONhpLQT.js} +1 -1
  61. package/dist/viewer/{dist-u48wpMGh.js → dist-v3HQ_tBw.js} +1 -1
  62. package/dist/viewer/{dist-DycRP_OX.js → dist-vk9ofs_t.js} +1 -1
  63. package/dist/viewer/{ebnfDiagram-PWID7BFC-BrG8iNXQ.js → ebnfDiagram-PWID7BFC-0s9Mm78H.js} +1 -1
  64. package/dist/viewer/{el-GR-BZB4AONW-DqICvPRG.js → el-GR-BZB4AONW-DFIcTo3i.js} +1 -1
  65. package/dist/viewer/{en-B4ZKOASM-dczwLo2Q.js → en-B4ZKOASM-BEswEOpC.js} +1 -1
  66. package/dist/viewer/{erDiagram-RLTQ6QDP-1lXVLQAr.js → erDiagram-RLTQ6QDP-A9ucHzt3.js} +1 -1
  67. package/dist/viewer/{es-ES-U4NZUMDT-B5LCvezC.js → es-ES-U4NZUMDT-Dsyjlq5a.js} +1 -1
  68. package/dist/viewer/{eu-ES-A7QVB2H4-AxW11Jr4.js → eu-ES-A7QVB2H4-BAIIFqxX.js} +1 -1
  69. package/dist/viewer/{fa-IR-HGAKTJCU-CrextBTW.js → fa-IR-HGAKTJCU-C3OpuRE4.js} +1 -1
  70. package/dist/viewer/{fi-FI-Z5N7JZ37-DW0oU7X0.js → fi-FI-Z5N7JZ37-CGZNrctb.js} +1 -1
  71. package/dist/viewer/flowDiagram-HODETNUW-D_xWrdzr.js +1 -0
  72. package/dist/viewer/{fr-FR-RHASNOE6-D1WTztbV.js → fr-FR-RHASNOE6-DABvCzvT.js} +1 -1
  73. package/dist/viewer/{ganttDiagram-EL5Y4UJY-OHjITozZ.js → ganttDiagram-EL5Y4UJY-DqLWQJWV.js} +1 -1
  74. package/dist/viewer/{gl-ES-HMX3MZ6V-Bz6k3trL.js → gl-ES-HMX3MZ6V-D-FsubUP.js} +1 -1
  75. package/dist/viewer/{he-IL-6SHJWFNN-BB9LB2-0.js → he-IL-6SHJWFNN-DKZYdZfW.js} +1 -1
  76. package/dist/viewer/{hi-IN-IWLTKZ5I-Dz-hDa8B.js → hi-IN-IWLTKZ5I-Dg6zlEAV.js} +1 -1
  77. package/dist/viewer/{hu-HU-A5ZG7DT2-Bty6njMB.js → hu-HU-A5ZG7DT2-N2pu49mS.js} +1 -1
  78. package/dist/viewer/{id-ID-SAP4L64H-C4usOGls.js → id-ID-SAP4L64H-L0ROzOqC.js} +1 -1
  79. package/dist/viewer/{image-GAAHSSAO-vAX85uOY.js → image-GAAHSSAO-CPsuFbpQ.js} +1 -1
  80. package/dist/viewer/index.html +6 -6
  81. package/dist/viewer/index.js +10 -10
  82. package/dist/viewer/index2.css +1 -1
  83. package/dist/viewer/{infoDiagram-27XIBGKW-BqzIrdk1.js → infoDiagram-27XIBGKW-DpFxmo2_.js} +1 -1
  84. package/dist/viewer/{ishikawaDiagram-5VMMS53U-Di-DEKXa.js → ishikawaDiagram-5VMMS53U-8EYGUU-2.js} +1 -1
  85. package/dist/viewer/{it-IT-JPQ66NNP-mzQckg9k.js → it-IT-JPQ66NNP-BV10T_YH.js} +1 -1
  86. package/dist/viewer/{ja-JP-DBVTYXUO-C7-H-cmZ.js → ja-JP-DBVTYXUO-BCaJwh3E.js} +1 -1
  87. package/dist/viewer/{journeyDiagram-3NMN7TZE-I0j1KMEL.js → journeyDiagram-3NMN7TZE-DaFiGmqB.js} +1 -1
  88. package/dist/viewer/{kaa-6HZHGXH3-CmNCMCJy.js → kaa-6HZHGXH3-B1skt76W.js} +1 -1
  89. package/dist/viewer/{kab-KAB-ZGHBKWFO-ItB_9BGI.js → kab-KAB-ZGHBKWFO-Cw1z7bNO.js} +1 -1
  90. package/dist/viewer/{kanban-definition-UXKFOSKX-DTBDnl3B.js → kanban-definition-UXKFOSKX-XFPAw_KL.js} +1 -1
  91. package/dist/viewer/{kk-KZ-P5N5QNE5-DFvprYF4.js → kk-KZ-P5N5QNE5-BPyIEorg.js} +1 -1
  92. package/dist/viewer/{km-KH-HSX4SM5Z-CYlJRLqM.js → km-KH-HSX4SM5Z-DuqV3Xms.js} +1 -1
  93. package/dist/viewer/{ko-KR-MTYHY66A-DdWMyWM6.js → ko-KR-MTYHY66A-C40qKz7C.js} +1 -1
  94. package/dist/viewer/{ku-TR-6OUDTVRD-BzvpGeMQ.js → ku-TR-6OUDTVRD-Bbrtxcjm.js} +1 -1
  95. package/dist/viewer/{lt-LT-XHIRWOB4-BYo85Qu7.js → lt-LT-XHIRWOB4-B_qXWIwM.js} +1 -1
  96. package/dist/viewer/{lv-LV-5QDEKY6T-CosJufMV.js → lv-LV-5QDEKY6T-8_k-NVNn.js} +1 -1
  97. package/dist/viewer/{mindmap-definition-YA3MSWOX-D8dIeGOr.js → mindmap-definition-YA3MSWOX-CJw_BzHI.js} +1 -1
  98. package/dist/viewer/{mr-IN-CRQNXWMA-DZw4xisJ.js → mr-IN-CRQNXWMA-Cr6mk0h0.js} +1 -1
  99. package/dist/viewer/{my-MM-5M5IBNSE-CJaPw4-2.js → my-MM-5M5IBNSE-zfvalQ4P.js} +1 -1
  100. package/dist/viewer/{nb-NO-T6EIAALU-7G70nMbl.js → nb-NO-T6EIAALU-B0R5LoPU.js} +1 -1
  101. package/dist/viewer/{nl-NL-IS3SIHDZ-C2N5LLwv.js → nl-NL-IS3SIHDZ-DByEOQ_2.js} +1 -1
  102. package/dist/viewer/{nn-NO-6E72VCQL-hN3Y-orF.js → nn-NO-6E72VCQL-DUupf9du.js} +1 -1
  103. package/dist/viewer/{oc-FR-POXYY2M6-C6zKnltp.js → oc-FR-POXYY2M6-C4GiSVlQ.js} +1 -1
  104. package/dist/viewer/{pa-IN-N4M65BXN-D9LFkWXb.js → pa-IN-N4M65BXN-BmpOpAle.js} +1 -1
  105. package/dist/viewer/{pegDiagram-XKGWAZYB-B0RvoMQk.js → pegDiagram-XKGWAZYB-DAjil8NL.js} +1 -1
  106. package/dist/viewer/percentages-BXMCSKIN-B-KINBvQ.js +1 -0
  107. package/dist/viewer/{pieDiagram-E7YTZNPT-ewOACQMR.js → pieDiagram-E7YTZNPT-CaXmRdry.js} +1 -1
  108. package/dist/viewer/{pl-PL-T2D74RX3-B7Srn8r-.js → pl-PL-T2D74RX3-DuE4eY9G.js} +1 -1
  109. package/dist/viewer/{prod-BrYSC5BZ.js → prod-CJIb7nxS.js} +8 -8
  110. package/dist/viewer/{pt-BR-5N22H2LF-DYyT3f2b.js → pt-BR-5N22H2LF-KH_3-_Pi.js} +1 -1
  111. package/dist/viewer/{pt-PT-UZXXM6DQ-rOtMHOEe.js → pt-PT-UZXXM6DQ-BF4pZvjU.js} +1 -1
  112. package/dist/viewer/{quadrantDiagram-AXDQQJYC-7uBvJywd.js → quadrantDiagram-AXDQQJYC-CttUyhBS.js} +1 -1
  113. package/dist/viewer/{railroadDiagram-O6MQD6OU-CjrkD1Sv.js → railroadDiagram-O6MQD6OU-CbnAU0MT.js} +1 -1
  114. package/dist/viewer/{requirementDiagram-BXWQKSXE-CtK-_ZfU.js → requirementDiagram-BXWQKSXE-DvKdUhZQ.js} +1 -1
  115. package/dist/viewer/{ro-RO-JPDTUUEW-DlX5UQ5g.js → ro-RO-JPDTUUEW-Brpa20Xr.js} +1 -1
  116. package/dist/viewer/{ru-RU-B4JR7IUQ-DMkmBI_w.js → ru-RU-B4JR7IUQ-PktJmPKO.js} +1 -1
  117. package/dist/viewer/{sequenceDiagram-WJ2MYXX4-FH_hVozp.js → sequenceDiagram-WJ2MYXX4-CJoSlXfo.js} +1 -1
  118. package/dist/viewer/{si-LK-N5RQ5JYF-syGIcUZu.js → si-LK-N5RQ5JYF-ChiCBRoh.js} +1 -1
  119. package/dist/viewer/{sk-SK-C5VTKIMK-DNPJXh_n.js → sk-SK-C5VTKIMK-CqJFB_HV.js} +1 -1
  120. package/dist/viewer/{sl-SI-NN7IZMDC-DRPcTij4.js → sl-SI-NN7IZMDC-DVLqmOJ1.js} +1 -1
  121. package/dist/viewer/{stateDiagram-D77RDMKH-l7B99Ka0.js → stateDiagram-D77RDMKH-DMn_ZLVi.js} +1 -1
  122. package/dist/viewer/{stateDiagram-v2-MP3YSRHH-C0UvR7x5.js → stateDiagram-v2-MP3YSRHH-CEKv_pDb.js} +1 -1
  123. package/dist/viewer/subset-shared.chunk-P48EEdkR.js +1 -0
  124. package/dist/viewer/{subset-worker.chunk-DlQBa_39.js → subset-worker.chunk-D7vPNmxj.js} +1 -1
  125. package/dist/viewer/{sv-SE-XGPEYMSR-S3tp2Wzl.js → sv-SE-XGPEYMSR-BE0Rox_P.js} +1 -1
  126. package/dist/viewer/{swimlanes-42K2YHIH-B13WRxod.js → swimlanes-42K2YHIH-Z13RXAJ2.js} +1 -1
  127. package/dist/viewer/{swimlanesDiagram-VR7AAH4N-D1UZKMPA.js → swimlanesDiagram-VR7AAH4N-2F-sMn5C.js} +1 -1
  128. package/dist/viewer/{ta-IN-2NMHFXQM-DZwig901.js → ta-IN-2NMHFXQM-BytzkZT9.js} +1 -1
  129. package/dist/viewer/{th-TH-HPSO5L25-C4AAMO23.js → th-TH-HPSO5L25-8djIgrrS.js} +1 -1
  130. package/dist/viewer/{timeline-definition-24CTP7MA-DIMtwmk3.js → timeline-definition-24CTP7MA-BBemmJjg.js} +1 -1
  131. package/dist/viewer/{tr-TR-DEFEU3FU-qZqNQn0v.js → tr-TR-DEFEU3FU-s5K56Q5P.js} +1 -1
  132. package/dist/viewer/{uk-UA-QMV73CPH-DCpn5eCj.js → uk-UA-QMV73CPH-BR4VH6DS.js} +1 -1
  133. package/dist/viewer/{vennDiagram-4TSXK5OY-Cm6chrYK.js → vennDiagram-4TSXK5OY-BF17eruu.js} +1 -1
  134. package/dist/viewer/{vi-VN-M7AON7JQ-Mx8GQ3WP.js → vi-VN-M7AON7JQ-B0ic3hAd.js} +1 -1
  135. package/dist/viewer/{wardleyDiagram-VM6X3IG4-BJBCh83b.js → wardleyDiagram-VM6X3IG4-D-8trXu4.js} +1 -1
  136. package/dist/viewer/{xychartDiagram-S5SC5T6Z-Dwt5Yi9Q.js → xychartDiagram-S5SC5T6Z-B596erre.js} +1 -1
  137. package/dist/viewer/{zh-CN-LNUGB5OW-uVvmbpx_.js → zh-CN-LNUGB5OW-CYANBkOM.js} +1 -1
  138. package/dist/viewer/{zh-HK-E62DVLB3-B10Y5kIG.js → zh-HK-E62DVLB3-BWpz93gC.js} +1 -1
  139. package/dist/viewer/{zh-TW-RAJ6MFWO-siER1xfy.js → zh-TW-RAJ6MFWO-CACFXFA3.js} +1 -1
  140. package/package.json +3 -1
  141. package/dist/viewer/CloudDocument-qU9Y5IS3.js +0 -1
  142. package/dist/viewer/CloudLiveDocument-BjQZue8V.js +0 -1
  143. package/dist/viewer/DocumentPage-BYXyKDdx.js +0 -1
  144. package/dist/viewer/RailSwitch-Dz65rESU.js +0 -58
  145. package/dist/viewer/flowDiagram-HODETNUW-BaTzUU_D.js +0 -1
  146. package/dist/viewer/percentages-BXMCSKIN-B8SN6v6b.js +0 -1
  147. package/dist/viewer/subset-shared.chunk-8gQsHXf4.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{C as r,E as i,Jo as a,Oa as o,Pa as s,S as c,T as l,b as u,ka as d,m as f,o as p,p as m,pa as h,s as g,t as _,u as v,v as y,w as b,x}from"./RailSwitch-B8Aht-FG.js";import{$ as S,A as C,B as w,C as ee,D as T,F as E,G as D,H as O,I as k,J as A,Jn as j,K as M,L as N,M as te,N as ne,O as re,P,Q as ie,R as F,S as I,T as L,U as ae,V as R,W as z,X as oe,Y as se,Z as ce,_ as B,a as le,b as ue,c as de,d as fe,et as pe,g as me,h as he,i as ge,j as _e,l as ve,m as V,n as ye,nt as H,o as be,p as xe,q as Se,qn as Ce,r as we,rt as Te,s as Ee,t as De,tt as Oe,u as ke,v as Ae,w as je,x as Me,y as Ne,z as Pe}from"./DocumentLayout-DUPesXt0.js";import{a as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,i as Ve,l as He,m as Ue,n as We,o as Ge,r as Ke,s as qe,u as Je}from"./index.js";var Ye={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};Ye.node;var Xe=s(Ye),Ze={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};Ze.node;var Qe=s(Ze),U=e(t(),1);function $e({streaming:e,pending:t,agentActiveAt:n,now:r}){if(e)return{kind:`editing`};if(t===0)return{kind:`idle`};if(n===void 0)return{kind:`working`,pending:t,idleMs:null};let i=Math.max(0,r-n);return i>3e5?{kind:`stale`,pending:t,idleMs:i}:{kind:`working`,pending:t,idleMs:i}}function et(e){return e<6e4?b.t(`time.seconds`,{count:Math.floor(e/1e3)}):e<36e5?b.t(`time.minutes`,{count:Math.floor(e/6e4)}):b.t(`time.hours`,{count:Math.floor(e/36e5)})}function tt(e,t,n){switch(e.kind){case`editing`:return n?b.t(`activity.editingSection`,{agent:t,section:n}):b.t(`activity.editing`,{agent:t});case`idle`:return null;case`working`:{let n=b.t(`activity.pending`,{agent:t,count:e.pending});return e.idleMs===null?n:e.idleMs<1e4?b.t(`activity.updatedJustNow`,{left:n}):b.t(`activity.updatedAgo`,{left:n,duration:et(e.idleMs)})}case`stale`:return b.t(`activity.stale`,{agent:t,duration:et(e.idleMs),count:e.pending})}}async function nt(e){await new Promise(e=>setTimeout(e,0));let t=[...e.getAllChanges().values()].flat().sort((e,t)=>e.lamport-t.lamport||e.peer.localeCompare(t.peer)||e.counter-t.counter),n=e.shallowSinceFrontiers(),r=e.frontiersToVV(n),i=[],a=[];try{for(let n of t){r.setLast({peer:n.peer,counter:n.counter+n.length-1});let t={id:`${n.counter}@${n.peer}`,change:n,frontiers:e.vvToFrontiers(r)};i.push(t);let o=n.message===`human`?`human`:n.message?.startsWith(`agent:`)?`agent`:n.message?.startsWith(`session `)?`session`:`unknown`,s=a.at(-1),c=s?.entries.at(-1)?.change;s&&c&&o!==`unknown`&&s.source===o&&c.peer===n.peer&&c.timestamp>0&&n.timestamp>=c.timestamp&&n.timestamp-c.timestamp<=60?(s.entries.push(t),s.id=t.id):a.push({id:t.id,source:o,entries:[t]}),i.length%200==0&&await new Promise(e=>setTimeout(e,0))}}finally{r.free()}return{entries:i,groups:a.reverse(),shallow:n.length>0}}function rt(e,t,n){let r=e.fork(),i;try{r.checkout(t);let e=r.getTree(me).roots();if(e.length!==1)throw Error(b.t(`history.contentUnavailable`));let a=M({nodes:n,editable:!1,onError:e=>{throw e}});i=B(a,r);let o=e[0].children()??[],s=new Map,c=(e,t)=>{s.set(e.id,t),e.children()?.forEach(e=>c(e,t))};return o.forEach(e=>c(e,e.id)),{value:a.getEditorState().toJSON(),ids:o.map(e=>e.id),owners:s}}finally{i?.dispose(),r.free()}}var it=/^cid:(\d+@\d+):Map$/;function at(e,t,n){let r=new Map(n.flatMap(e=>[...e.owners])),i=e.getTree(me),a=new Map,o=new Map(t.map((e,t)=>[e,t])),s=(e,t)=>{let n=a.get(e);(!n||o.get(n)<o.get(t))&&a.set(e,t)};for(let n of t){let{peer:t,counter:i,length:a}=n.change;for(let o of e.getChangedContainersIn({peer:t,counter:i},a)){let t=e.getContainerById(o);for(;t;){let e=it.exec(t.id)?.[1],i=e&&r.get(e);if(i){s(i,n);break}t=t.parent()}}}let c=e=>e&&t.find(({change:t})=>t.peer===e.peer&&t.counter<=e.counter&&e.counter<t.counter+t.length);for(let e of new Set(r.values())){if(!i.isNodeDeleted(e))continue;let t=c(i.getNodeByID(e)?.getLastMoveId());t&&s(e,t)}return a}var ot=5e4,st=`background-color: color-mix(in srgb, var(--rc-alert-caution) 22%, transparent); text-decoration: line-through;`,ct=`background-color: color-mix(in srgb, var(--rc-alert-tip) 22%, transparent);`;function W(e){let t=e;return t.type===`heading`?`heading:${t.tag}`:t.type===`list`?`list:${t.listType}`:t.type||`unknown`}function lt(e,t){return JSON.stringify(e)===JSON.stringify(t)}function G(e){let t=e;return t.type===`text`&&typeof t.text==`string`}function K(e){let t=e;return Array.isArray(t.children)?t.children:null}function ut(e,t){let n=typeof e==`string`?e.trim():``;return n?`${n}${n.endsWith(`;`)?``:`;`} ${t}`:t}function q(e,t,n){let{style:r}=e;return n===`delete`?r=ut(r,st):n===`insert`&&(r=ut(r,ct)),{...e,text:t,style:r}}function J(e,t){return{...e,children:t}}function Y(e,t){if(G(e))return q(e,e.text,t);let n=K(e);return n?J(e,n.map(e=>Y(e,t))):e}function dt(e){return Array.from(e).reverse().join(``)}function ft(e){let t=[];for(let n of e){if(!n.text)continue;let e=t.at(-1);e&&e.kind===n.kind?e.text+=n.text:t.push({...n})}return t}function pt(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{kind:`insert`,text:t.join(``)}];if(r===0)return[{kind:`delete`,text:e.join(``)}];if(n*r>ot)return[{kind:`delete`,text:e.join(``)},{kind:`insert`,text:t.join(``)}];let i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r;for(;o>0&&s>0;)if(e[o-1]===t[s-1]){let t=a.at(-1);t&&t.kind===`equal`?t.text+=e[o-1]:a.push({kind:`equal`,text:e[o-1]}),o--,s--}else if(i[o-1][s]>=i[o][s-1]){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}else{let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}for(;o>0;){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}for(;s>0;){let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}return ft(a.reverse().map(e=>({kind:e.kind,text:dt(e.text)})))}function mt(e,t){let n=Array.from(e),r=Array.from(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.length-1,o=r.length-1;for(;a>=i&&o>=i&&n[a]===r[o];)a--,o--;let s=[];return i>0&&s.push({kind:`equal`,text:n.slice(0,i).join(``)}),s.push(...pt(n.slice(i,a+1),r.slice(i,o+1))),a<n.length-1&&s.push({kind:`equal`,text:n.slice(a+1).join(``)}),ft(s)}function ht(e,t){let n=mt(e.text,t.text),r=[],i=[],a=!1;for(let o of n)o.text&&(o.kind===`equal`?(r.push(q(e,o.text)),i.push(q(t,o.text))):(a=!0,o.kind===`delete`?r.push(q(e,o.text,`delete`)):i.push(q(t,o.text,`insert`))));return{oldNodes:r.length>0?r:[e],newNodes:i.length>0?i:[t],changed:a}}function gt(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++){let r=Math.max(i[a-1][n],i[a][n-1]);if(W(e[a-1])===W(t[n-1])){let o=lt(e[a-1],t[n-1])?2:1;i[a][n]=Math.max(r,i[a-1][n-1]+o)}else i[a][n]=r}let a=[],o=n,s=r;for(;o>0&&s>0;){if(W(e[o-1])===W(t[s-1])){let n=lt(e[o-1],t[s-1]),r=n?2:1;if(i[o][s]===i[o-1][s-1]+r){a.push(n?{kind:`equal`,node:e[o-1]}:{kind:`modify`,oldNode:e[o-1],newNode:t[s-1]}),o--,s--;continue}}i[o-1][s]>=i[o][s-1]?(a.push({kind:`delete`,node:e[o-1]}),o--):(a.push({kind:`insert`,node:t[s-1]}),s--)}for(;o>0;)a.push({kind:`delete`,node:e[--o]});for(;s>0;)a.push({kind:`insert`,node:t[--s]});return a.reverse(),a}function _t(e,t){let n=gt(e,t),r=[],i=[],a=!1;for(let e of n)switch(e.kind){case`equal`:r.push(e.node),i.push(e.node);break;case`delete`:a=!0,r.push(Y(e.node,`delete`));break;case`insert`:a=!0,i.push(Y(e.node,`insert`));break;case`modify`:{if(a=!0,G(e.oldNode)&&G(e.newNode)){let t=ht(e.oldNode,e.newNode);r.push(...t.oldNodes),i.push(...t.newNodes);break}let t=vt(e.oldNode,e.newNode);t?(r.push(t.oldNode),i.push(t.newNode)):(r.push(Y(e.oldNode,`delete`)),i.push(Y(e.newNode,`insert`)));break}}return{oldChildren:r,newChildren:i,changed:a}}function vt(e,t){if(W(e)!==W(t))return null;if(lt(e,t))return{oldNode:e,newNode:t,changed:!1};let n=K(e),r=K(t);if(!n||!r)return null;let i=_t(n,r);return i.changed?{oldNode:J(e,i.oldChildren),newNode:J(t,i.newChildren),changed:!0}:{oldNode:e,newNode:t,changed:!1}}function yt(e,t){let n=vt(e,t);return n?{oldNode:n.oldNode,newNode:n.newNode}:{oldNode:Y(e,`delete`),newNode:Y(t,`insert`)}}function bt(e,t){let n=mt(e.text,t.text),r=[];for(let i of n)i.text&&(i.kind===`equal`?r.push(q(t,i.text)):i.kind===`delete`?r.push(q(e,i.text,`delete`)):r.push(q(t,i.text,`insert`)));return r}function xt(e,t){let n=gt(e,t),r=[];for(let e of n)switch(e.kind){case`equal`:r.push(e.node);break;case`delete`:r.push(Y(e.node,`delete`));break;case`insert`:r.push(Y(e.node,`insert`));break;case`modify`:{if(G(e.oldNode)&&G(e.newNode)){r.push(...bt(e.oldNode,e.newNode));break}let t=K(e.oldNode),n=K(e.newNode);t&&n?r.push(J(e.newNode,xt(t,n))):(r.push(Y(e.oldNode,`delete`)),r.push(Y(e.newNode,`insert`)));break}}return r}function St(e,t){if(W(e)!==W(t))return Y(t,`insert`);if(lt(e,t))return t;let n=K(e),r=K(t);return!n||!r?Y(t,`insert`):J(t,xt(n,r))}function Ct(e,t){let n=gt(e.root.children,t.root.children),r=[];for(let e of n)switch(e.kind){case`equal`:{let t=r.at(-1);t&&t.type===`equal`?t.nodes.push(e.node):r.push({type:`equal`,nodes:[e.node]});break}case`modify`:{let t=yt(e.oldNode,e.newNode);r.push({type:`delete`,nodes:[t.oldNode]},{type:`insert`,nodes:[t.newNode]})}break;case`delete`:r.push({type:`delete`,nodes:[Y(e.node,`delete`)]});break;case`insert`:r.push({type:`insert`,nodes:[Y(e.node,`insert`)]})}return r}function wt(e){let t={...e};if(t.$){let{blockId:e,...n}=t.$;Object.keys(n).length?t.$=n:delete t.$}return t.children&&=t.children.map(wt),t}function Tt(e,t){let{children:n,text:r,...i}=e,{children:a,text:o,...s}=t;return JSON.stringify(i)!==JSON.stringify(s)||!!(n&&a&&kt(n,a).some(e=>e.kind===`modify`&&Tt(e.old[0],e.current[0])))}function Et(e){let t=e;return t.type===`dynamic`||t.type===`pending`?{type:`paragraph`,version:1,direction:null,format:``,indent:0,children:[{type:`text`,version:1,text:t.type===`dynamic`?b.t(`history.dynamic`,{url:t.url,height:t.initialHeight??320,props:JSON.stringify(t.props??{})}):b.t(`history.pendingIntent`,{intent:t.intent??``}),format:0,detail:0,mode:`normal`,style:``}]}:t.children?{...t,children:t.children.map(Et)}:t}function Dt(e){return Ot(e.map(Et))}function Ot(e){return{root:{type:`root`,version:1,direction:null,format:``,indent:0,children:e}}}function kt(e,t){let n=Ct(Ot(e),Ot(t)),r=[],i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];if(s.type===`equal`){r.push({kind:`equal`,old:e.slice(i,i+s.nodes.length),current:t.slice(a,a+s.nodes.length),oldIndex:i,newIndex:a}),i+=s.nodes.length,a+=s.nodes.length;continue}let c=0,l=0;for(;o<n.length&&n[o].type!==`equal`;){let e=n[o++];e.type===`delete`?c+=e.nodes.length:l+=e.nodes.length}o--;for(let n=0;n<Math.max(c,l);n++){let o=n<c?[e[i+n]]:[],s=n<l?[t[a+n]]:[];r.push({kind:o.length&&s.length?`modify`:o.length?`delete`:`insert`,old:o,current:s,oldIndex:o.length?i+n:void 0,newIndex:s.length?a+n:void 0})}i+=c,a+=l}return r}function At(e,t){return kt(e.root.children.map(wt),t.root.children.map(wt)).map(e=>{let t={oldIndex:e.oldIndex,newIndex:e.newIndex};if(e.kind===`modify`){let n=e.old[0],r=e.current[0];return n.type===r.type&&!Tt(n,r)?{kind:`modify`,value:Dt([St(n,r)]),...t}:{kind:`modify`,before:Dt(e.old),value:Dt(e.current),...t}}let n=e.kind===`delete`?e.old:e.current;return{kind:e.kind,value:Dt(e.kind===`equal`?n:n.map(t=>Y(t,e.kind))),...t}})}function jt(e){let t=M(e);return t._headless=!0,[`registerDecoratorListener`,`registerRootListener`,`registerMutationListener`,`getRootElement`,`setRootElement`,`getElementByKey`,`focus`,`blur`].forEach(e=>{t[e]=()=>{(function(e,...t){throw function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);return n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(e,...t)})(439,e)}}),t}var X=n();function Mt({text:e}){let t=(0,U.useRef)(null),n=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let r=t.current;if(!r)return;let i=r.parentNode;if(!i)return;let a=n.current;return!a||a.parentNode!==i?(a=document.createComment(e),i.insertBefore(a,r),n.current=a):a.data!==e&&(a.data=e),()=>{n.current?.parentNode&&n.current.parentNode.removeChild(n.current),n.current=null}},[e]),(0,X.jsx)(`template`,{suppressHydrationWarning:!0,"data-rich-comment-anchor":``,ref:t})}var Z=e=>`${H[e]} ${Te[e]}`,Nt={h1:Z(`headingH1`),h2:Z(`headingH2`),h3:Z(`headingH3`),h4:Z(`headingH4`),h5:Z(`headingH5`),h6:Z(`headingH6`)};function Pt(e){return e.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g,``).replaceAll(/[\s_]+/g,`-`).replaceAll(/^-+|-+$/g,``)}function Ft(e){return e.type===`comment`?``:e.text?e.text:e.children?e.children.map(Ft).join(``):``}var It=/^["'«‘“‹「『"']/,Lt=/["'»’”›」』"']$/;function Rt(e,t,n,r,i){switch(e.type){case`root`:return(0,X.jsx)(X.Fragment,{children:n});case`paragraph`:{let r=e.format?{textAlign:e.format}:void 0;return(0,X.jsx)(`p`,{className:Z(`paragraph`),style:r,children:n??(0,X.jsx)(`br`,{})},t)}case`heading`:{let a=e.tag,o=Pt(i||Ft(e)),s=o;if(o){let e=r.get(o);e===void 0?r.set(o,1):(s=`${o}-${e}`,r.set(o,e+1))}return(0,X.jsxs)(a,{className:Nt[a],id:s||void 0,children:[s&&(0,X.jsx)(`a`,{className:Z(`headingAnchor`),href:`#${s}`,tabIndex:0,children:(0,X.jsx)(j,{"aria-hidden":!0,size:14,strokeWidth:2})}),n]},t)}case`rich-quote`:case`quote`:{let r=(i||Ft(e)).trim(),a=It.test(r),o=Lt.test(r),s=e.attribution;return(0,X.jsxs)(`blockquote`,{className:Z(`quote`),"data-no-close-quote":o?``:void 0,"data-no-open-quote":a?``:void 0,children:[n,s&&(0,X.jsxs)(`footer`,{className:Z(`quoteAttribution`),children:[`— `,s]})]},t)}case`list`:{let r=e.listType===`number`?`ol`:`ul`,i=e.listType===`number`?Z(`listOl`):e.listType===`check`?`${Z(`checklist`)} ${Z(`listUl`)}`:Z(`listUl`);return(0,X.jsx)(r,{className:i,start:e.start===1?void 0:e.start,children:n},t)}case`listitem`:{let r=e.checked!==void 0,i=e.children?.some(e=>e.type===`list`),a=typeof e.value==`number`&&e.value>1?e.value:void 0,o;return o=i?Z(`listNestedItem`):r?e.checked?`${Z(`listItem`)} ${Z(`listItemChecked`)}`:`${Z(`listItem`)} ${Z(`listItemUnchecked`)}`:Z(`listItem`),(0,X.jsx)(`li`,{className:o,value:a,children:n},t)}case`link`:return(0,X.jsxs)(`a`,{className:Z(`link`),href:e.url,rel:e.rel||`noopener`,target:e.target||`_blank`,children:[(0,X.jsx)(C,{href:e.url}),n]},t);case`autolink`:return(0,X.jsxs)(`a`,{className:Z(`link`),href:e.url,rel:`noopener`,target:`_blank`,children:[(0,X.jsx)(C,{href:e.url}),n]},t);case`horizontalrule`:return(0,X.jsx)(`hr`,{className:Z(`hr`)},t);case`table`:return(0,X.jsx)(`div`,{className:Z(`tableScrollableWrapper`),children:(0,X.jsx)(`table`,{className:Z(`table`),children:n})},t);case`tablerow`:return(0,X.jsx)(`tr`,{children:n},t);case`tablecell`:{let r=e.headerState?`th`:`td`,i=e.headerState?Z(`tableCellHeader`):Z(`tableCell`);return(0,X.jsx)(r,{className:i,colSpan:e.colSpan>1?e.colSpan:void 0,children:n},t)}case`details`:{let r=e.summary||``;return(0,X.jsxs)(`details`,{className:`${k.details} ${N.details}`,open:e.open||void 0,children:[(0,X.jsxs)(`summary`,{className:`${k.summary} ${N.summary}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`${k.chevron} ${N.chevron}`,children:(0,X.jsx)(`svg`,{fill:`none`,height:`20`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,viewBox:`0 0 20 20`,width:`20`,children:(0,X.jsx)(`path`,{d:`M8 6L12 10L8 14`})})}),(0,X.jsx)(`span`,{className:`${k.summaryText} ${N.summaryText}`,children:r})]}),(0,X.jsx)(`div`,{className:`${k.content} ${N.content}`,children:n})]},t)}case`spoiler`:return(0,X.jsx)(`span`,{className:Z(`spoiler`),role:`button`,tabIndex:0,children:n},t);case`tag`:return(0,X.jsx)(`span`,{className:Z(`tag`),style:{backgroundColor:O(e.text)},children:e.text},t);case`comment`:return(0,X.jsx)(Mt,{text:e.text??``},t);case`ruby`:return(0,U.createElement)(pe,{key:t,rendererKey:`Ruby`,defaultRenderer:re,props:{reading:e.reading??``,children:n}});case`code`:return(0,X.jsx)(`pre`,{className:`rich-code-block`,children:(0,X.jsx)(`code`,{children:n})},t);case`code-highlight`:return(0,X.jsx)(`span`,{children:e.text},t);case`linebreak`:return(0,X.jsx)(`br`,{},t);case`tab`:return(0,X.jsx)(`span`,{children:` `},t);default:return null}}var zt=e=>`${H[e]} ${Te[e]}`,Bt=[[1,`textBold`],[2,`textItalic`],[4,`textStrikethrough`],[8,`textUnderline`],[16,`textCode`],[32,`textSubscript`],[64,`textSuperscript`],[128,`textHighlight`]];function Vt(e){let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();if(!r||!i)continue;let a=r.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase());t[a]=i}return t}function Ht(e,t){let n=e.text,r=e.format||0;for(let[e,i]of Bt)r&e&&(n=(0,X.jsx)(`span`,{className:zt(i),children:n},`${t}-${e}`));return e.style&&(n=(0,X.jsx)(`span`,{style:Vt(e.style),children:n},t)),n}function Ut(e){let t={},n=new Set,r={},i=1;function a(e){if(e.type===`footnote`&&e.identifier){let t=e.identifier;n.has(t)||(n.add(t),r[t]=i++)}if(e.type===`footnote-section`&&e.definitions&&Object.assign(t,e.definitions),e.children)for(let t of e.children)a(t);if(e.root&&a(e.root),e.content&&typeof e.content==`object`&&e.content.root&&a(e.content),e.cells&&Array.isArray(e.cells))for(let t of e.cells)t&&t.root&&a(t)}a(e);for(let e of n)e in t||(t[e]=``);return{definitions:t,displayNumberMap:r}}var Wt=e=>`${H.alert} ${Te.alert} rich-alert-${e}`;function Gt(e,t,n){switch(e.type){case`alert-quote`:return(0,U.createElement)(`div`,{key:t,className:Wt(e.alertType)},n);case`banner`:return(0,U.createElement)(`div`,{key:t,className:`rich-banner rich-banner-${e.bannerType}`},n);case`grid-container`:return(0,U.createElement)(`div`,{key:t,className:`${F.container} ${Pe.container}`},n);default:return(0,U.isValidElement)(n)?(0,U.cloneElement)(n,{key:t}):n}}function Kt(e,t,n){return(0,U.isValidElement)(e)&&typeof e.type==`string`?(0,U.cloneElement)(e,{"data-block-id":t}):(0,X.jsx)(`div`,{className:`rich-block-anchor`,"data-block-id":t,children:e},`${n}-block-anchor`)}function qt(e,t,n,r){return t?(r.blockAnchor??Kt)(e,t,n):e}function Jt(e,t,n,r,i,a,o){let s=e.getKey?e.getKey():i,{builtinNodeOverrides:c}=o;if(typeof e.decorate==`function`){let r=null;try{r=e.decorate(t,n)}catch{}if(r!=null){let t=e.exportJSON?e.exportJSON():{},n=c?.[t.type];return qt(n?n(t,s,[r],()=>Gt(t,s,r)):Gt(t,s,r),a,s,o)}}let l=e.exportJSON?e.exportJSON():{};if(l.type===`text`){let e=c?.text;return e?e(l,s,null,()=>Ht(l,s)):Ht(l,s)}let u=typeof e.getChildren==`function`?e.getChildren():[];Array.isArray(l.children)&&l.children.length===0&&u.length>0&&(l.children=u.map(e=>({type:typeof e.getType==`function`?e.getType():e.__type})));let d=null;u.length>0&&(d=u.map((e,i)=>Jt(e,t,n,r,`${s}-${i}`,void 0,o)));let f=e.getTextContent?e.getTextContent():void 0,p=c?.[l.type];return qt(p?p(l,s,d,()=>Rt(l,s,d,r,f)):Rt(l,s,d,r,f),a,s,o)}function Yt(e,t,n){let r=jt({nodes:t,theme:R,editable:!1,onError:e=>{console.error(`[RichRenderer]`,e)}}),i={namespace:`ssr`,theme:R},a=te(e),o=r.parseEditorState(a);r.setEditorState(o);let s=Ut(a),c=a.root?.children,l=null;return o.read(()=>{let e=D(),t=new Map,a=e.getChildren().map((e,a)=>Jt(e,r,i,t,`ssr-${a}`,c?.[a]?.$?.blockId,n));l=(0,X.jsx)(X.Fragment,{children:a})}),{content:l,footnoteData:s,renderNestedContent:e=>{let r=jt({nodes:t,theme:R,editable:!1,onError:e=>{console.error(`[RichRenderer:nested]`,e)}}),i={namespace:`ssr-nested`,theme:R},a=te(e),o=r.parseEditorState(a);r.setEditorState(o);let s=null,c=a.root?.children;return o.read(()=>{let e=D(),t=new Map,a=e.getChildren().map((e,a)=>Jt(e,r,i,t,`nested-${a}`,c?.[a]?.$?.blockId,n));s=(0,X.jsx)(X.Fragment,{children:a})}),s}}}function Xt({value:e,variant:t=`article`,theme:n=`light`,className:r,style:i,as:a=`div`,nested:o=!1,rendererConfig:s,extraNodes:c,builtinNodeOverrides:l,blockAnchor:u}){let d=Oe(t),f=ae(),{content:p,footnoteData:m,renderNestedContent:h}=(0,U.useMemo)(()=>Yt(e,c?[...E,...c]:E,{blockAnchor:u,builtinNodeOverrides:l}),[u,l,c,e]),g=[`rich-content`,d,r].filter(Boolean).join(` `),_=typeof a==`string`?{suppressHydrationWarning:!0,className:g,"data-rich-nested":o?`true`:void 0,"data-theme":n}:{};return(0,X.jsx)(ne,{className:d,theme:n,children:(0,X.jsx)(P,{colorScheme:n,children:(0,X.jsx)(S,{config:s,mode:`renderer`,variant:t,children:(0,X.jsx)(oe,{definitions:m.definitions,displayNumberMap:m.displayNumberMap,children:(0,X.jsx)(w,{value:f??h,children:(0,X.jsx)(a,{..._,style:i,children:p})})})})})})}var Zt=[ee],Qt=864e5,$t=e=>String(e).padStart(2,`0`),en=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function tn(e,t=Date.now()){if(!(e>0))return b.t(`time.notRecorded`);let n=new Date(e*1e3),r=new Date(t),a=Math.round((en(r)-en(n))/Qt);if(a===0)return b.t(`time.today`);if(a===1)return b.t(`time.yesterday`);let o=n.getFullYear()===r.getFullYear();return new Intl.DateTimeFormat(i[b.language],o?{month:`long`,day:`numeric`}:{year:`numeric`,month:`long`,day:`numeric`}).format(n)}function Q(e,t=!1){if(!(e>0))return`--:--`;let n=new Date(e*1e3),r=`${$t(n.getHours())}:${$t(n.getMinutes())}`;return t?`${r}:${$t(n.getSeconds())}`:r}function $(e){return e>0?`${tn(e)} ${Q(e)}`:b.t(`time.notRecorded`)}var nn={human:`history.sourceHuman`,agent:`history.sourceAgent`,session:`history.sourceSession`,unknown:`history.sourceUnknown`};function rn(e){let{session:t,selected:n}=e;return t&&n?t.history.groups.find(e=>e.entries.includes(n)):void 0}function an(e){return e.session?.history.entries.at(-1)?.change.timestamp??0}function on({model:e}){let{count:t,changeIndex:n,loading:r}=e;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`history-count`,children:[t?n+1:0,` / `,t]}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":l(`history.previousChange`),disabled:n===0||r,onClick:()=>e.navigate(-1),children:(0,X.jsx)(ze,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":l(`history.nextChange`),disabled:n>=t-1||r,onClick:()=>e.navigate(1),children:(0,X.jsx)(d,{size:14,"aria-hidden":`true`})})]})}function sn({model:e}){return(0,X.jsx)(`button`,{type:`button`,className:`history-filter`,"aria-pressed":e.onlyChanges,onClick:e.toggleOnly,children:l(`history.onlyChanges`)})}function cn({model:e}){return e.pending?(0,X.jsxs)(`div`,{className:`history-update`,role:`status`,children:[(0,X.jsx)(`span`,{children:e.streaming?l(`history.waitingEdits`):l(`history.newContent`,{time:Q(an(e))})}),(0,X.jsxs)(`button`,{type:`button`,disabled:e.streaming||e.loading,onClick:e.refresh,children:[(0,X.jsx)(Qe,{size:12,"aria-hidden":`true`}),l(`history.refresh`)]})]}):null}function ln({model:e}){let{selected:t,blocks:n,count:r}=e,i=rn(e),a=n.filter(e=>e.kind===`insert`||e.kind===`modify`).length,o=n.filter(e=>e.kind===`delete`||e.kind===`modify`).length;return(0,X.jsxs)(`section`,{className:`history-compare`,"aria-label":l(`history.range`),children:[(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:l(`history.from`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:t?$(t.change.timestamp):l(`history.pickPoint`)}),i?(0,X.jsx)(`span`,{children:l(nn[i.source])}):null]}),(0,X.jsx)(`dt`,{children:l(`history.to`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:l(`history.latestVersion`)}),(0,X.jsx)(`span`,{children:$(an(e))})]})]}),(0,X.jsxs)(`div`,{className:`history-controls`,children:[(0,X.jsx)(`span`,{children:l(`history.changes`,{count:r})}),(0,X.jsxs)(`span`,{className:`history-plus`,children:[`+`,a]}),(0,X.jsxs)(`span`,{className:`history-minus`,children:[`−`,o]}),(0,X.jsx)(`span`,{className:`history-spacer`}),(0,X.jsx)(sn,{model:e}),(0,X.jsx)(on,{model:e})]})]})}function un({model:e}){let[t,n]=(0,U.useState)(50),[r,i]=(0,U.useState)(()=>new Set),{session:a,selected:s,blocks:c}=e;if(!a)return null;let{groups:u,entries:d,shallow:f}=a.history,p=u.findIndex(e=>s!==null&&e.entries.includes(s)),m=new Map;for(let e of c)e.group&&m.set(e.group,(m.get(e.group)??0)+1);let h=u.slice(0,t),g=e=>tn(e.entries.at(-1).change.timestamp),_=e=>i(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ol`,{className:`history-timeline`,"aria-label":l(`history.timeline`),children:h.map((t,n)=>{let i=t.entries.at(-1),a=g(t),c=n===0||a!==g(h[n-1]),u=n===p?`selected`:n===0?`latest`:n<p?`range`:`outside`,d=r.has(t.id),f=n<p?m.get(t):void 0;return(0,X.jsxs)(`li`,{className:`history-node`,"data-state":u,"data-upper":n<=p?`in`:`out`,"data-lower":n<p?`in`:`out`,"data-day":c?``:void 0,children:[c?(0,X.jsx)(`div`,{className:`history-day`,children:a}):null,(0,X.jsxs)(`div`,{className:`history-row`,children:[(0,X.jsx)(`span`,{className:`history-dot`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,className:`history-select`,"aria-current":u===`selected`?`true`:void 0,onClick:()=>e.select(i),children:[(0,X.jsxs)(`span`,{className:`history-line`,children:[(0,X.jsx)(`strong`,{children:Q(i.change.timestamp)}),(0,X.jsx)(`span`,{children:l(nn[t.source])}),u===`latest`?(0,X.jsx)(`span`,{className:`history-tag`,children:l(`history.latest`)}):null,u===`selected`?(0,X.jsx)(`span`,{className:`history-tag history-start`,children:l(`history.start`)}):null]}),(0,X.jsxs)(`span`,{className:`history-meta`,children:[l(`history.commits`,{count:t.entries.length}),f?(0,X.jsx)(`span`,{className:`history-changed`,children:l(`history.changedSuffix`,{count:f})}):null]})]}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon history-expand`,"aria-label":l(d?`history.collapseCommits`:`history.expandCommits`),"aria-expanded":d,onClick:()=>_(t.id),children:(0,X.jsx)(o,{size:14,"aria-hidden":`true`})})]}),d?(0,X.jsx)(`div`,{className:`history-raw`,children:[...t.entries].reverse().map(t=>(0,X.jsxs)(`button`,{type:`button`,title:t.change.message,"aria-current":t===s?`true`:void 0,onClick:()=>e.select(t),children:[(0,X.jsx)(`span`,{children:Q(t.change.timestamp,!0)}),(0,X.jsx)(`code`,{children:t.change.message||l(`history.sourceUnknown`)})]},t.id))}):null]},t.id)})}),t<u.length?(0,X.jsx)(`button`,{type:`button`,className:`history-more`,onClick:()=>n(e=>e+50),children:l(`history.loadEarlier`)}):(0,X.jsxs)(`p`,{className:`history-end`,children:[l(f?`history.shallow`:`history.earliest`),` · `,l(`history.summary`,{edits:l(`history.edits`,{count:u.length}),commits:l(`history.commits`,{count:d.length})}),(0,X.jsx)(`br`,{}),l(`history.clockNote`)]})]})}function dn({streaming:e}){return(0,X.jsxs)(`div`,{className:`history-waiting`,children:[(0,X.jsx)(`p`,{role:`status`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`strong`,{children:l(`history.agentEditing`)}),(0,X.jsx)(`span`,{children:l(`history.agentEditingBody`)})]}):(0,X.jsx)(`strong`,{children:l(`history.loading`)})}),(0,X.jsx)(`div`,{className:`history-skeleton`,"aria-hidden":`true`,children:[150,130,160,120].map(e=>(0,X.jsx)(`span`,{style:{width:e}},e))})]})}function fn({model:e}){return(0,X.jsxs)(`div`,{role:`alert`,className:`history-failure`,children:[(0,X.jsxs)(`strong`,{children:[(0,X.jsx)(Be,{size:15,"aria-hidden":`true`}),l(`history.failed`)]}),(0,X.jsx)(`code`,{children:e.error}),(0,X.jsx)(`span`,{children:l(`history.failedBody`)}),(0,X.jsxs)(`span`,{className:`history-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`history-button`,disabled:e.streaming,onClick:e.refresh,children:l(`common.retry`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-quiet`,onClick:e.close,children:l(`history.backToComments`)})]})]})}function pn({model:e}){return(0,X.jsxs)(`aside`,{className:`history-panel`,"aria-label":l(`history.title`),children:[(0,X.jsxs)(`header`,{className:`history-panel-head`,children:[(0,X.jsx)(`h2`,{children:l(`history.title`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":l(`history.close`),onClick:e.close,children:(0,X.jsx)(h,{size:14,"aria-hidden":`true`})})]}),(0,X.jsx)(cn,{model:e}),e.error?(0,X.jsx)(fn,{model:e}):e.session?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ln,{model:e}),(0,X.jsx)(un,{model:e})]}):(0,X.jsx)(dn,{streaming:e.streaming})]})}function mn({model:e,onDismiss:t}){let n=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=document.activeElement,t=n.current,r=()=>[...t?.querySelectorAll(`button:not(:disabled), a[href], input:not(:disabled), [tabindex="0"]`)??[]];r()[0]?.focus();let i=e=>{if(e.key!==`Tab`)return;let t=r();e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),t.at(-1)?.focus()):!e.shiftKey&&document.activeElement===t.at(-1)&&(e.preventDefault(),t[0]?.focus())};return t?.addEventListener(`keydown`,i),()=>{t?.removeEventListener(`keydown`,i),e?.focus()}},[]);let r=(0,X.jsxs)(`div`,{className:`history-sheet-head`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:l(`history.chooseStart`)}),(0,X.jsx)(`small`,{children:l(`history.compareWithLatest`,{time:$(an(e))})})]}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:l(`common.done`)})]});return(0,X.jsx)(`div`,{ref:n,className:`history-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":l(`history.chooseStart`),children:(0,X.jsx)(qe,{snaps:[0,.85],snap:.85,onSnap:e=>{e===0&&t()},onScrim:t,header:r,children:(0,X.jsx)(`div`,{className:`history-sheet-body`,children:(0,X.jsx)(un,{model:e})})})})}var hn=[je,T,...Zt],gn={[A]:I,[se]:Me,[ce]:ue,[ie]:V},_n={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function vn({model:e,theme:t,title:n,narrow:r,bodyRef:i,onPick:a}){let{session:o,selected:s,blocks:c,count:u,changeIndex:f,loading:p,error:m,streaming:h,onlyChanges:g}=e,_=e=>(0,X.jsx)(Xt,{value:e,variant:`article`,theme:t,extraNodes:hn,rendererConfig:gn}),v=-1;return(0,X.jsxs)(`div`,{className:`history-view`,children:[r?(0,X.jsxs)(`div`,{className:`history-strip`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`history-pick`,onClick:a,children:[(0,X.jsx)(`span`,{children:l(`history.compareFrom`)}),(0,X.jsxs)(`strong`,{children:[l(`history.toLatest`,{from:s?$(s.change.timestamp):l(`history.pickPoint`)}),(0,X.jsx)(d,{size:12,"aria-hidden":`true`})]})]}),(0,X.jsx)(sn,{model:e}),(0,X.jsx)(on,{model:e})]}):null,r?(0,X.jsx)(cn,{model:e}):null,m?r?(0,X.jsxs)(`div`,{role:`alert`,className:`history-message`,children:[l(`history.readFailed`,{error:m}),(0,X.jsx)(`button`,{type:`button`,disabled:h,onClick:e.refresh,children:l(`common.retry`)})]}):(0,X.jsx)(`p`,{className:`history-message`,children:l(`history.unreadable`)}):p||!o?(0,X.jsx)(`div`,{role:`status`,className:`history-message`,children:l(h?`history.waitingEdits`:`history.computing`)}):(0,X.jsxs)(`div`,{ref:i,"aria-label":l(`history.diffBody`),className:`history-content`,children:[o.latest.value.root.children.some(e=>e.type===`heading`&&e.tag===`h1`)?null:(0,X.jsx)(`h1`,{children:n}),u?null:(0,X.jsx)(`p`,{role:`status`,className:`history-note`,children:l(`history.noDiff`)}),c.map((t,n)=>{if(t.kind===`equal`)return g?(0,X.jsx)(`button`,{type:`button`,className:`history-fold`,onClick:e.showAll,children:(0,X.jsx)(`span`,{children:l(`history.unchanged`,{count:t.value.root.children.length})})},n):(0,X.jsx)(`section`,{className:`history-hunk history-equal`,children:_(t.value)},n);v++;let r=t.before?null:t.kind===`insert`?`history-after`:t.kind===`delete`?`history-before`:`history-merged`;return(0,X.jsxs)(`section`,{"data-history-change":``,"data-current":v===f?``:void 0,className:`history-hunk history-${t.kind}`,children:[(0,X.jsxs)(`div`,{className:`history-caption`,children:[(0,X.jsx)(`span`,{className:`history-kind`,children:l(_n[t.kind])}),t.author?(0,X.jsxs)(`span`,{children:[$(t.author.change.timestamp),t.group?` · ${l(nn[t.group.source])}`:``]}):null]}),t.before?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`history-before`,children:_(t.before)}),(0,X.jsx)(`div`,{className:`history-after`,children:_(t.value)})]}):(0,X.jsx)(`div`,{className:r,children:_(t.value)})]},n)}),(0,X.jsx)(`p`,{className:`history-end`,children:l(`history.endOfDiff`)})]})]})}var yn=e=>JSON.stringify(e.frontiers()),bn=(e,t)=>t===void 0?void 0:e[t];function xn({doc:e,nodes:t,streaming:n,theme:r,title:i,open:a,onClose:o}){let[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(null),d=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(0),[h,g]=(0,U.useState)(!0),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)([]),[C,w]=(0,U.useState)(!1),[ee,T]=(0,U.useState)(0),[E,D]=(0,U.useState)(!1),O=f(`(max-width: 1100px)`),k=(0,U.useRef)(null),A=(0,U.useCallback)(async()=>{if(!e)return;let n=++m.current;g(!0),v(null);let r=e.fork();try{let i=await nt(r),a=rt(r,r.frontiers(),t);if(m.current!==n){r.free();return}let o=p.current;p.current=r;let s=(d.current&&i.entries.find(e=>e.id===d.current.id))??i.groups[1]?.entries.at(-1)??i.entries[0]??null;d.current=s,u(s),c({doc:r,history:i,latest:a}),b(yn(e)!==yn(r)),o?.free()}catch(e){r.free(),m.current===n&&v(e.message)}finally{m.current===n&&g(!1)}},[e,t]);if((0,U.useEffect)(()=>{if(a)return()=>{m.current++,p.current?.free(),p.current=null,d.current=null,c(null),u(null),S([]),b(!1),v(null),g(!0),D(!1),w(!1)}},[a,e]),(0,U.useEffect)(()=>{a&&!n&&!p.current&&A()},[a,A,n]),(0,U.useEffect)(()=>{if(a&&e)return e.subscribe(()=>b(p.current!==null&&yn(e)!==yn(p.current)))},[e,a]),(0,U.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&(E?D(!1):o())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a,o,E]),(0,U.useEffect)(()=>{if(!s||!l)return;let e=!1;g(!0);let n=setTimeout(()=>{try{let n=rt(s.doc,l.frontiers,t),{entries:r,groups:i}=s.history,a=at(s.doc,r.slice(r.indexOf(l)+1),[n,s.latest]),o=new Map(i.flatMap(e=>e.entries.map(t=>[t,e]))),c=At(n.value,s.latest.value).map(e=>{if(e.kind===`equal`)return e;let t=[bn(s.latest.ids,e.newIndex),bn(n.ids,e.oldIndex)].map(e=>e&&a.get(e)).find(Boolean);return t?{...e,author:t,group:o.get(t)}:e});e||(S(c),T(0),v(null))}catch(t){e||v(t.message)}finally{e||g(!1)}},0);return()=>{e=!0,clearTimeout(n)}},[s,l,t]),!a||!e)return null;let j=x.filter(e=>e.kind!==`equal`).length,M={session:s,selected:l,blocks:x,count:j,changeIndex:ee,loading:h,error:_,pending:y,streaming:n,onlyChanges:C,select:e=>{d.current=e,u(e),D(!1)},navigate:e=>{let t=Math.max(0,Math.min(j-1,ee+e));T(t),k.current?.querySelectorAll(`[data-history-change]`)[t]?.scrollIntoView?.({block:`center`,behavior:`instant`})},toggleOnly:()=>w(e=>!e),showAll:()=>w(!1),refresh:()=>void A(),close:o};return{content:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(vn,{model:M,theme:r,title:i,narrow:O,bodyRef:k,onPick:()=>D(!0)}),O&&E?(0,X.jsx)(mn,{model:M,onDismiss:()=>D(!1)}):null]}),panel:O?null:(0,X.jsx)(pn,{model:M})}}function Sn({left:e,top:t,quote:n,initial:r,restored:i,leaving:a,onChange:o,onSubmit:s,onCancel:c,ref:u}){return(0,X.jsx)(`div`,{ref:u,...{0:{className:`x10l6tqk x1u8a7rm xj6ak53 xowlrko xllfotl xatqbsq x1u6ievf`},1:{className:`x10l6tqk x1u8a7rm xj6ak53 x1u6ievf xxp0q0x x12l1aco xn0cd8s x47corl`}}[!!a|0],style:{left:e,top:t},children:(0,X.jsxs)(ye,{active:!0,children:[(0,X.jsxs)(`div`,{className:`x78zum5 x1pha0wt x167g77z xz9dl7a x1hr3lfm xqfszdh x1j6dyjg`,children:[(0,X.jsxs)(`span`,{className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv xddlp02`,children:[`“`,n,`”`]}),i?(0,X.jsx)(`span`,{className:`x2lah0s x7zghnd`,children:l(`document.draftRestored`)}):null]}),(0,X.jsx)(y,{autoFocus:!0,initial:r,placeholder:l(`document.draftPlaceholder`),onChange:o,onSubmit:s,onCancel:c})]})})}function Cn({left:e,top:t,onComment:n,onCopy:r,ref:i}){return(0,X.jsxs)(`div`,{ref:i,className:`x10l6tqk x1u8a7rm x78zum5 x6s0dn4 x195vfkc xc9qbxq x9f619 x9ms5i6 xmkeg23 x1y0btm7 xgcsv5v x1q4ynmn x12ilycc x1d5q07e xi1bcxy x773k2o xa3vuyk`,style:{left:e,top:t},onMouseDown:e=>e.preventDefault(),children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xo2rkog xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x1fkwv27`,children:[(0,X.jsx)(Xe,{size:14,className:`x2lah0s x17nrqe2`}),l(`common.comment`)]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`x2lah0s x1i1rx1s xlup9mm xj3msbq xcn5yip`})]}):null,(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`x78zum5 x6s0dn4 x17d4w8g x1fgtraw xt970qd x1awh872 xc342km xu4hgxq xjbqb8w xj0l527 x2230gt xqfszdh xfifm61 xk50ysn x1ypdohk x1de99jn xaatb59 x1y3gkto x1uczgqu x1fkwv27 x1bo0w0s`,children:l(`document.copy`)})]})}var wn=(e,t)=>`${e}\n${t}`;function Tn(){let e=new Map;return{save(t,n){n.trim()?e.set(t,n):e.delete(t)},take(t){return e.get(t)??``}}}function En(e){let t=(0,U.useMemo)(Tn,[]),[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(``),s=(0,U.useRef)(0),c=(0,U.useRef)(null),l=(0,U.useRef)(null);le(i?null:n?.target.range??null);let u=(0,U.useCallback)(n=>{window.clearTimeout(s.current);let i=t.take(wn(n.blockId,n.quote));o.current=i,a(!1),r({target:n,initial:i}),window.getSelection()?.removeAllRanges(),e()},[t,e]),d=(0,U.useCallback)(e=>{n&&(t.save(wn(n.target.blockId,n.target.quote),e?o.current:``),a(!0),s.current=window.setTimeout(()=>{r(null),a(!1)},120))},[n,t]);return(0,U.useEffect)(()=>{if(!n||i)return;let e=e=>{let t=e.target;c.current?.contains(t)||l.current?.contains(t)||d(!0)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[n,i,d]),(0,U.useEffect)(()=>()=>window.clearTimeout(s.current),[]),{draft:n,leaving:i,restored:!!n?.initial,open:u,close:d,onText:e=>{o.current=e},panelRef:c,toolbarRef:l}}function Dn(e){return{left:e.offsetLeft,right:Math.min(e.offsetLeft+e.offsetWidth,window.innerWidth-16)}}function On({editor:e,threads:t,actions:n,agent:r,canComment:i,selection:a,clearSelection:o,onCreate:s,onMain:c,history:l,children:u}){let d=En(o),{draft:f}=d;return(0,X.jsx)(De,{editor:e,threads:t,actions:n,agent:r,onMain:c,history:l,overlay:e=>(0,X.jsxs)(X.Fragment,{children:[a&&!f?(0,X.jsx)(Cn,{ref:d.toolbarRef,...ve(a,Dn(e),128,36,8),onComment:i?()=>d.open(a):void 0,onCopy:()=>{navigator.clipboard?.writeText(a.quote),window.getSelection()?.removeAllRanges(),o()}}):null,f?(0,X.jsx)(Sn,{ref:d.panelRef,...de(f.target,Dn(e),340,8),quote:f.target.quote,initial:f.initial,restored:d.restored,leaving:d.leaving,onChange:d.onText,onSubmit:e=>s(f.target,e).then(e=>(e&&d.close(!1),e)),onCancel:()=>d.close(!0)},`${f.target.blockId}:${f.target.quote}`):null]}),children:u})}function kn({id:e,title:t,activity:n,agentSection:r,offline:i,openComments:a,cloud:o,compact:s=!1,onDone:c,agent:u=`Agent`,history:d}){let f=tt(n,u,r);return p(e,o?{...t?{title:t}:{},online:o.online,comments:a,activity:f,activityTone:n.kind===`stale`?`warning`:n.kind===`working`?`quiet`:`live`,retrying:i,reason:o.reason,history:d?.available,historyOpen:d?.open}:null)&&!s?null:(0,X.jsxs)(`header`,{...{0:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1v2ro7d x4l9tsp x1rozbrz xqfszdh`},1:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1rozbrz xqfszdh x1hr3lfm x883omv`}}[!!s|0],children:[s?null:(0,X.jsxs)(`span`,{className:`xddlp02 xfifm61 xuxw1ft`,children:[`document / `,(0,X.jsx)(`span`,{className:`xo2rkog x1s688f`,children:e})]}),f?(0,X.jsxs)(`span`,{...{0:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla xlssvyo x19ay2w6 x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv`},2:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`},1:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`},3:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`}}[(n.kind===`working`)<<1|n.kind===`stale`],children:[n.kind===`stale`?null:(0,X.jsx)(`i`,{className:`x1v4s8kt xols6we x16rqkct xtwfq29`}),f]}):null,i?(0,X.jsx)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`,children:l(`document.notSynced`)}):null,d?.open?(0,X.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`,children:[(0,X.jsx)(Ue,{size:11,"aria-hidden":`true`}),l(`document.readOnlyHistory`)]}):null,o?.reason&&!s?(0,X.jsx)(`span`,{className:`xb3r6kr xddlp02 xfifm61 xuxw1ft xlyipyv`,children:o.reason}):null,(0,X.jsx)(`span`,{className:`x98rzlu`}),o?(0,X.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g x1bo0w0s xfifm61 xuxw1ft`,children:[(0,X.jsx)(`i`,{...{0:{className:`xci0xqf x1hagigm x16rqkct xxwmxtg`},1:{className:`xci0xqf x1hagigm x16rqkct xux1nz0`}}[!!o.online|0]}),o.online?l(`share.computerOnline`):l(`share.computerOffline`)]}):null,d?(0,X.jsx)(_,{comments:a,open:d.open,available:d.available,onComments:d.close,onHistory:d.toggle}):null,c?(0,X.jsx)(`button`,{type:`button`,onClick:c,className:`x12ulsxz xaope02 xc342km x1kogg8i x19ckca5 xs0jrwl xqfszdh x4z9k3i x1s688f x1ypdohk`,children:l(`common.done`)}):o||s?null:(0,X.jsx)(Le,{artifact:`document/${e}`})]})}function An(e,t,n){let[r,i]=t<=n?[t,n]:[n,t];return{blockIds:e.slice(r,i+1).flatMap(e=>e.id?[e.id]:[]).slice(0,He.blockIds),heading:e.slice(0,r+1).filter(e=>e.heading).pop()?.text??``}}var jn=crypto.randomUUID(),Mn=300,Nn={quote:``,blockIds:[],heading:``};function Pn(e){let t=window.getSelection(),n=e.getRootElement();if(!t||t.isCollapsed||!n?.contains(t.anchorNode)||!n.contains(t.focusNode))return Nn;let r=t.toString().trim().slice(0,He.quote);return r?e.read(()=>{let e=D().getChildren(),n=t=>{let n=t&&z(t)?.getTopLevelElement();return n?e.findIndex(e=>e.is(n)):-1},i=n(t.anchorNode),a=n(t.focusNode);if(i<0||a<0)return{...Nn,quote:r};let o=e.map(e=>({id:Se(e,_e)||``,heading:e.getType()===`heading`,text:e.getTextContent().slice(0,He.heading)}));return{quote:r,...An(o,i,a)}}):Nn}function Fn(e,t,n,r){let i=(0,U.useRef)(Nn);(0,U.useEffect)(()=>{if(!e)return;let n=0,a=()=>{let n=Pn(e);JSON.stringify(n)!==JSON.stringify(i.current)&&(i.current=n,r({type:`selection`,artifact:t,tab:jn,human:!0,...n}))},o=()=>{clearTimeout(n),n=window.setTimeout(a,Mn)};return document.addEventListener(`selectionchange`,o),()=>{clearTimeout(n),document.removeEventListener(`selectionchange`,o)}},[e,t,r]),(0,U.useEffect)(()=>{n&&i.current.quote&&r({type:`selection`,artifact:t,tab:jn,human:!1,...i.current})},[n,t,r])}var In=[`pending`],Ln=`x-ryugi-document-features`,Rn=e=>{let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)};function zn({id:e,channel:t,send:n}){let r=(t,n,r)=>fetch(`/api/document/${e}/${t}`,{method:`POST`,headers:{"Content-Type":r,[Ln]:In.join(`,`)},body:n});return{artifact:`document/${e}`,channel:t,send:n,async meta(){let t=await fetch(`/api/artifacts/document/${e}`,{cache:`no-store`});return t.ok?await t.json():null},async state(){let t=await fetch(`/api/document/${e}/state`,{cache:`no-store`}),n=await t.json();if(!t.ok||!n.snapshot)throw Error(n.error??`load failed (${t.status})`);return n},async update(e){let t=await r(`update`,e,`application/octet-stream`);if(!t.ok)throw Error(`update failed (${t.status})`)},async comment(e){let t=await r(`comments`,JSON.stringify(e),`application/json`);if(!t.ok)throw Error(`comment failed (${t.status})`);return(await t.json()).comments}}}function Bn(e){let t=L(),n=(e.connect??Ve)({url:e.url,artifact:e.artifact,WebSocket:e.WebSocket,retryMs:e.retryMs,onPresence:e.onPresence,onEvent:e=>t.emit(e),onOnline:()=>t.emit({type:`open`})});return{artifact:e.artifact,channel:t,close:n.close,async meta(){let t=await n.request({op:`meta`});return/^https?:\/\//.test(t.contentBase??``)?t:{...t,contentBase:e.contentBase}},state:()=>n.request({op:`state`}),async update(e){await n.request({op:`update`,bytes:Rn(e),features:In})},async comment(e){return(await n.request({op:`comment`,comment:e})).comments},send(e){let{type:t}=e;t===`selection`?n.request({op:`selection`,selection:e}).catch(()=>{}):(t===`loaded`||t===`runtime-error`)&&n.request({op:`client`,message:e}).catch(()=>{})}}}function Vn(e){let t=(0,U.useMemo)(L,[]),n=`document/${e}`,{live:r,send:i}=Re(e=>{e.artifact===n&&t.emit(e)},()=>t.emit({type:`open`}));return{transport:(0,U.useMemo)(()=>zn({id:e,channel:t,send:i}),[e,t,i]),live:r}}function Hn(e,t){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let n=Bn({url:We(e),artifact:`document/${e}`,contentBase:t,onPresence:a,connect:t=>Ke({...t,cloudId:e,known:Fe()})});return r(n),()=>{n.close(),r(null),a(null)}},[e,t]),{transport:n,presence:i}}var Un={count:0,firstKey:null},Wn=e=>e.read(()=>{let e=D().getChildren().filter(e=>e.getType()===`pending`).map(e=>e.getKey());return{count:e.length,firstKey:e[0]??null}});function Gn(e){let[t,n]=(0,U.useState)(Un);return(0,U.useEffect)(()=>{if(!e){n(Un);return}let t=e=>n(t=>t.count===e.count&&t.firstKey===e.firstKey?t:e);return t(Wn(e.getEditorState())),e.registerUpdateListener(({editorState:e})=>t(Wn(e)))},[e]),t}function Kn(e,t=15e3){let[n,r]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{if(!e)return;r(Date.now());let n=setInterval(()=>r(Date.now()),t);return()=>clearInterval(n)},[e,t]),n}function qn({left:e,top:t,placement:n,canComment:r,canEdit:i,onComment:a,onEdit:o}){let s=(0,U.useRef)(null),c=[r?{label:l(`common.comment`),Icon:Xe,run:a,primary:!0}:null,i?{label:l(`document.editText`),Icon:Ce,run:o,primary:!1}:null].filter(e=>e!==null);return(0,U.useLayoutEffect)(()=>{v(s.current,[{opacity:0,transform:`scale(0.96)`},{opacity:1,transform:`none`}],{duration:160,easing:g})},[]),c.length===0?null:(0,X.jsxs)(`div`,{ref:s,"data-edit-menu":!0,"data-placement":n,...{0:{className:`x10l6tqk x1u8a7rm x78zum5 xdt5ytf x1cy8zhl`},1:{className:`x10l6tqk x1u8a7rm x78zum5 x1cy8zhl x3ieub6`}}[n===`above`|0],style:{left:e,top:t,transformOrigin:n===`above`?`22px 100%`:`22px 0`},onMouseDown:e=>e.preventDefault(),children:[(0,X.jsx)(`span`,{className:`xsmyaan x1kpxq89 xyqm7xq x1qp53xl x1cum3z5 xf6xdpg x1158fpu`}),(0,X.jsx)(`div`,{className:`x78zum5 xn3w4p2 xfn1xvj x4pepcl xf6xdpg x1dam6yx`,children:c.map(({label:e,Icon:t,run:n,primary:r})=>(0,X.jsxs)(`button`,{type:`button`,onClick:n,...{0:{className:`x78zum5 x6s0dn4 x17d4w8g xn3w4p2 xt970qd xaope02 xc342km x1q4ynmn xjbqb8w x116urgp xqirfc3 xqfszdh xif65rj x1ypdohk`},1:{className:`x78zum5 x6s0dn4 x17d4w8g xn3w4p2 xt970qd xaope02 xc342km x1q4ynmn xjbqb8w x116urgp xqfszdh xif65rj x1ypdohk xfungia x1s688f`}}[!!r|0],children:[(0,X.jsx)(t,{size:16,"aria-hidden":!0}),e]},e))})]})}var Jn={state:{kmuXW:`x2lah0s`,kGuDYH:`xfifm61`,$$css:!0},waitingAgent:{kMwMTN:`x7zghnd`,$$css:!0},answered:{kMwMTN:`xh0clw4`,$$css:!0},resolved:{kMwMTN:`xddlp02`,$$css:!0}},Yn=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Xn({thread:e,agent:t=`Agent`,actions:n,active:i=!1,offline:o=!1}){let s=r(e),c=e.status===`resolved`,d=c?{label:l(`common.resolved`),tone:Jn.resolved}:s===`agent`?{label:l(`document.waitingAgentReply`,{agent:t}),tone:Jn.waitingAgent}:s===`human`?{label:l(`document.agentReplied`,{agent:t}),tone:Jn.answered}:null;return(0,X.jsxs)(`div`,{"data-thread":e.id,...{0:{className:`xxlmvz2 x178xt8z x13fuv20 xxu5053 xqfszdh xo2rkog`},1:{className:`xxlmvz2 x178xt8z x13fuv20 xxu5053 xqfszdh xo2rkog xggygye`}}[!!i|0],children:[(0,X.jsxs)(`div`,{className:`x78zum5 x1pha0wt x167g77z x1lqa7cf x1vo0akb x19ypqd9 x13ym6ox x4z9k3i`,children:[(0,X.jsx)(`span`,{className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x1bo0w0s`,children:e.anchor.quote||l(`document.wholeBlock`)}),d?(0,X.jsx)(`span`,{...a(Jn.state,d.tone),children:d.label}):null]}),c&&!i?null:e.messages.map(e=>{let{label:t,initial:n}=x(e);return(0,X.jsxs)(`div`,{className:`x14vqqas`,children:[(0,X.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x4z9k3i x1s688f`,children:[(0,X.jsx)(u,{human:e.author===`human`,initial:n,name:e.name,src:e.avatar}),t,(0,X.jsx)(`span`,{className:`xddlp02 xo1l8bm xfifm61`,children:Yn(e.editedAt??e.at)})]}),(0,X.jsx)(`div`,{...{0:{className:`x1gslohp xxpkpgd x1jvydc1 x1dbl2gt x126k92a xj0a0fe`},1:{className:`x1gslohp xxpkpgd x1jvydc1 x1dbl2gt x126k92a xj0a0fe xc7n51q`}}[!!e.deleted|0],children:e.deleted?l(`common.deleted`):e.text})]},e.id)}),n?(0,X.jsxs)(`div`,{className:`x78zum5 x6s0dn4 xou54vl x1anpbxc xxpkpgd`,children:[c?null:(0,X.jsx)(`div`,{className:`x98rzlu xeuugli x1qyh8g1 xso031l x1q0q8m5 x1iz93xd`,children:(0,X.jsx)(y,{placeholder:l(`common.reply`),onSubmit:t=>n.reply(e.id,t)})}),o?null:(0,X.jsx)(`button`,{type:`button`,onClick:()=>c?n.reopen(e.id):n.resolve(e.id),className:`x2lah0s x1gg8mnh xt970qd xdqyycr x1w5wx5t xc342km xjbqb8w x1bo0w0s xqfszdh x4z9k3i x1ypdohk`,children:l(c?`common.reopen`:`common.resolve`)})]}):null]})}var Zn=.5,Qn=e=>e===78?Zn:e;function $n({threads:e,agent:t=`Agent`,actions:n,offline:i,draft:a,onCreate:o,onCancelDraft:s,activeId:c,snap:u,onSnap:d}){let f=(0,U.useRef)(null),p=e.filter(e=>!e.messages.every(e=>e.deleted)),m=p.filter(e=>r(e)===`agent`).length,h=i?l(`document.offlineNoComments`):m>0?l(`document.waitingCount`,{count:m,agent:t}):null;return(0,U.useEffect)(()=>{let e=c?f.current?.querySelector(`[data-thread="${CSS.escape(c)}"]`):null,t=e?.closest(`[data-sheet-body]`);e&&t&&(t.scrollTo({top:t.scrollTop+e.getBoundingClientRect().top-t.getBoundingClientRect().top-8,behavior:`smooth`}),v(e,[{backgroundColor:`rgba(232, 194, 74, 0.24)`},{backgroundColor:`transparent`}],{duration:600,delay:250,easing:g}))},[c]),(0,X.jsx)(qe,{snaps:[78,Zn,1],snap:u,onSnap:d,onScrim:()=>d(Zn),header:(0,X.jsxs)(`span`,{className:`x78zum5 x1pha0wt x17d4w8g xu0aao5 x17qtykl xwib8y2 xqfszdh x1jvydc1 x1s688f`,children:[l(`document.sheetComments`,{count:p.length}),h?(0,X.jsxs)(`span`,{className:`xddlp02 xfifm61 xo1l8bm`,children:[`· `,h]}):null]}),children:(0,X.jsxs)(`div`,{ref:f,className:`x17qtykl xwxc41k`,children:[a&&n?(0,X.jsxs)(`div`,{className:`x10dr8xq xqfszdh`,children:[(0,X.jsxs)(`div`,{className:`x78zum5 x1pha0wt x167g77z x4z9k3i`,children:[(0,X.jsx)(`span`,{className:`x98rzlu xeuugli x1lqa7cf x1vo0akb x19ypqd9 x13ym6ox xb3r6kr xuxw1ft xlyipyv x1bo0w0s`,children:a.quote}),(0,X.jsx)(`button`,{type:`button`,onClick:s,className:`x1717udv xc342km xjbqb8w xddlp02 x4z9k3i x1ypdohk`,children:l(`common.cancel`)})]}),(0,X.jsx)(`div`,{className:`x1xmf6yo x1qyh8g1 xso031l x1q0q8m5 x1iz93xd`,children:(0,X.jsx)(y,{autoFocus:!0,placeholder:l(`document.agentPlaceholder`),onSubmit:e=>o(a,e).then(e=>(e&&s(),e))})})]}):null,p.length===0&&!a?(0,X.jsx)(`div`,{className:`xr9q8rw xddlp02 xqfszdh x4z9k3i x2b8uid`,children:l(`document.noComments`)}):null,p.map(e=>(0,X.jsx)(Xn,{thread:e,agent:t,actions:n,active:e.id===c,offline:i},e.id))]})})}var er=52;function tr({editor:e,threads:t,actions:n,agent:r,canComment:i,canEdit:a,offline:o,selection:s,clearSelection:c,onCreate:l,onEdit:u,onMain:d,history:f,children:p}){let[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(78),[b,x]=(0,U.useState)(null),S=ge(e,t,m);be(S,t,g),le(b?.range??null);let C=()=>{window.getSelection()?.removeAllRanges(),c()};return(0,X.jsxs)(`main`,{ref:e=>{h(e),d?.(e)},className:`x1n2onr6 x1cnzs8 x17qtykl x1ffnkcp`,children:[(0,X.jsxs)(`article`,{onClick:e=>{let t=we(S,e.clientX,e.clientY);_(t),t&&y(Qn)},children:[f?.content,(0,X.jsx)(`div`,{hidden:!!f,children:p})]}),s&&!b&&!f?(0,X.jsx)(qn,{...Ee(s,{left:8,right:(m?.clientWidth??0)-8},170,44,{top:m?.getBoundingClientRect().top??0,height:window.innerHeight,reserved:Ie(v,window.innerHeight-er)}),canComment:i,canEdit:a,onComment:()=>{x(s),y(Zn),C()},onEdit:()=>{u(s),c()}}):null,(0,X.jsx)(`div`,{hidden:!!f,className:`xixxii4 x1ozmhy9 xu96u03 x3m8u43 x1ey2m1c x1355qak x47corl`,children:(0,X.jsx)($n,{threads:t,agent:r,actions:n,offline:o,draft:b,onCreate:l,onCancelDraft:()=>x(null),activeId:g,snap:v,onSnap:y})})]})}var nr=200;function rr(e,t){let[n,r]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!e||!t)return;let n=0,i=()=>{let n=window.getSelection(),i=e.getRootElement();if(!n||n.isCollapsed||n.rangeCount===0||!i?.contains(n.anchorNode)){r(null);return}let a=n.toString().trim(),o=e.read(()=>{let e=n.anchorNode&&z(n.anchorNode)?.getTopLevelElement(),t=n.focusNode&&z(n.focusNode)?.getTopLevelElement();return!e||!t||!e.is(t)?null:Se(e,_e)||null});if(!o||!a){r(null);return}let s=n.getRangeAt(0),c=[...s.getClientRects()],l=c[0]??s.getBoundingClientRect(),u=c.at(-1)??l,d=t.getBoundingClientRect();r({blockId:o,quote:a.slice(0,500),left:l.left-d.left,bottom:u.bottom-d.top,top:l.top-d.top,right:u.right-d.left,range:s.cloneRange()})},a=()=>{clearTimeout(n),n=window.setTimeout(i,nr)};return document.addEventListener(`selectionchange`,a),()=>{clearTimeout(n),document.removeEventListener(`selectionchange`,a)}},[e,t]),[n,()=>r(null)]}var ir=[...E.filter(e=>!fe.some(t=>t.getType()===(`getType`in e?e.getType():e.replace.getType()))),...fe];function ar(){let e=(0,U.useMemo)(()=>window.matchMedia(`(prefers-color-scheme: dark)`),[]),[t,n]=(0,U.useState)(e.matches);return(0,U.useEffect)(()=>{let t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[e]),t}function or(e){(0,U.useEffect)(()=>{if(!e)return;let t=document.createElement(`base`);return t.href=e,document.head.prepend(t),()=>t.remove()},[e])}function sr({id:e}){let{transport:t,live:n}=Vn(e);return(0,X.jsx)(cr,{id:e,transport:t,live:n})}function cr({id:e,transport:t,live:n,cloud:r,fallback:i}){let[a,o]=(0,U.useState)(null),[s,u]=(0,U.useState)(null),[d,p]=(0,U.useState)(c),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(void 0),[x,S]=(0,U.useState)(0),C=(0,U.useCallback)(e=>{e!==void 0&&S(e-Date.now())},[]),[w,ee]=(0,U.useState)(null),[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(!1),k=!r||r.online&&!T,A=D&&k;(0,U.useEffect)(()=>{k||O(!1)},[k]),(0,U.useEffect)(()=>{if(!r)return;let t=t=>{t.source===window.parent&&t.origin===location.origin&&t.data?.type===`ryugi:document-history`&&t.data.id===e&&(t.data.action===`close`?O(!1):t.data.action===`toggle`&&k&&O(e=>!e))};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e,r,k]);let[j,M]=(0,U.useState)(null),[N,te]=(0,U.useState)(null),ne=ar(),{artifact:re,channel:P}=t,ie=!r||r.online,F=!r||r.canEdit,I=f(m),[L,ae]=(0,U.useState)(!1),R=I?L&&F:F,z=(0,U.useCallback)(async()=>{let e=await t.meta();e&&o(e)},[t]),oe=i!=null;(0,U.useEffect)(()=>{let e=!1;return(async()=>{try{await z();let n=await t.state();if(e)return;let r=new Ae;r.setRecordTimestamp(!0),r.setChangeMergeInterval(20),r.import(he(n.snapshot)),v(!!n.streaming),b(n.agentActiveAt),C(n.now),p(n.comments??c());let i=oe?{left:window.scrollX,top:window.scrollY,behavior:`instant`}:null;u(r),i&&requestAnimationFrame(()=>{e||window.scrollTo(i)})}catch(t){e||g(t.message)}})(),()=>{e=!0}},[t,z,C,oe]),(0,U.useEffect)(()=>P.subscribe(e=>{e.type===`change`?z():e.type===`doc-status`?(v(e.streaming),b(e.agentActiveAt),C(e.now)):e.type===`doc-comments`&&p(e.comments)}),[P,z,C]),(0,U.useEffect)(()=>{j?.setEditable(R&&!A)},[j,R,A]),(0,U.useEffect)(()=>{F||ae(!1)},[F]);let se=(0,U.useCallback)(e=>{v(!!e.streaming),b(e.agentActiveAt),C(e.now),e.comments&&p(e.comments)},[C]);or(a?.contentBase),Fn(j,re,n&&!A,t.send);let ce=(0,U.useMemo)(()=>({artifact:re,contentBase:a?.contentBase??``,channel:P,send:t.send}),[re,a?.contentBase,P,t]);(0,U.useEffect)(()=>{document.title=a?.title||e},[a?.title,e]),Je(`document`);let B=Gn(j),le=Kn(B.count>0&&!_),ue=$e({streaming:_,pending:B.count,agentActiveAt:y,now:le+x}),de=a?.agent??`Agent`,fe=(0,U.useMemo)(()=>({nextKey:B.firstKey,agent:de,activity:ue.kind}),[B.firstKey,de,ue.kind]),pe=d.threads.filter(e=>e.status===`open`).length,[me,ge]=rr(j,N),_e=(0,U.useCallback)(()=>O(!1),[]),ve=xn({doc:s,nodes:ir,streaming:_,theme:ne?`dark`:`light`,title:a?.title||e,open:A,onClose:_e}),V=(0,U.useCallback)(async e=>{try{return p(await t.comment(e)),!0}catch{return!1}},[t]),ye=(0,U.useMemo)(()=>({reply:(e,t)=>V({op:`reply`,threadId:e,text:t}),edit:(e,t,n)=>void V({op:`edit`,threadId:e,messageId:t,text:n}),remove:(e,t)=>void V({op:`delete`,threadId:e,messageId:t}),resolve:e=>void V({op:`resolve`,threadId:e}),reopen:e=>void V({op:`reopen`,threadId:e})}),[V]),H=(0,U.useCallback)((e,t)=>V({op:`create`,blockId:e.blockId,quote:e.quote,text:t}),[V]),be=(0,U.useCallback)(e=>{if(!j)return;j.setEditable(!0),ae(!0),j.getRootElement()?.focus({preventScroll:!0});let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e.range)},[j]);if(h)return(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:h});if(!s)return i??(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:l(`common.loading`)});let Se=(0,X.jsx)(Ne.Provider,{value:ce,children:(0,X.jsx)(xe.Provider,{value:fe,children:(0,X.jsx)(ke,{transport:t,agent:a?.agent,doc:s,theme:ne?`dark`:`light`,onAgentSection:ee,onOffline:E,onState:se,onEditorReady:M})})});return(0,X.jsxs)(`div`,{className:`x1us19tq x1rozbrz xo2rkog`,className:`ryugi-doc ${{className:`x1us19tq x1rozbrz xo2rkog`}.className??``}`,children:[(0,X.jsx)(kn,{id:e,title:a?.title||e,agent:a?.agent,activity:ue,agentSection:w,offline:T,openComments:pe,cloud:r,compact:I,onDone:I&&L?()=>ae(!1):void 0,history:{available:k,open:A,toggle:()=>O(e=>!e),close:_e}}),I?(0,X.jsx)(tr,{editor:j,threads:d.threads,actions:ye,agent:a?.agent,canComment:ie,canEdit:F,offline:!(!r||r.online),selection:L?null:me,clearSelection:ge,onCreate:H,onEdit:be,onMain:te,history:ve,children:Se}):(0,X.jsx)(On,{editor:j,threads:d.threads,actions:ye,agent:a?.agent,canComment:ie,selection:me,clearSelection:ge,onCreate:H,onMain:te,history:ve,children:Se}),(0,X.jsx)(Ge,{warnings:a?.warnings??[]})]})}export{cr as DocumentView,sr as default,Hn as t};