ryugi-artifacts 1.37.0 → 1.38.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.
- package/dist/cli.cjs +1 -1
- package/dist/server.cjs +6 -6
- package/dist/viewer/{CloudDocument-CJ_ipZB3.js → CloudDocument-uu0ngWyX.js} +1 -1
- package/dist/viewer/{CloudLiveDocument-BBdNTFk1.js → CloudLiveDocument-DevxqTpE.js} +1 -1
- package/dist/viewer/{DocumentLayout-D7VkWfYp.js → DocumentLayout-m54YZ2wJ.js} +153 -153
- package/dist/viewer/{DocumentPage-g68iWCQi.js → DocumentPage-B9L2Y4un.js} +1 -1
- package/dist/viewer/RailSwitch-CoEg_jiu.js +64 -0
- package/dist/viewer/{abnfDiagram-VCTEODGH-DpouP0T2.js → abnfDiagram-VCTEODGH-C2YYqQWa.js} +1 -1
- package/dist/viewer/{ar-SA-G6X2FPQ2-CIs0M6cz.js → ar-SA-G6X2FPQ2-DrzMW-P9.js} +1 -1
- package/dist/viewer/{architectureDiagram-5GKGNRK7-CtnDfqds.js → architectureDiagram-5GKGNRK7-R-y51-Ku.js} +1 -1
- package/dist/viewer/{az-AZ-76LH7QW2-CL1UnlXq.js → az-AZ-76LH7QW2-3s6h5wuz.js} +1 -1
- package/dist/viewer/{bg-BG-XCXSNQG7-DvB9cGKj.js → bg-BG-XCXSNQG7-B4Kdbf3s.js} +1 -1
- package/dist/viewer/{blockDiagram-I7D4REHJ-BC7SmhJm.js → blockDiagram-I7D4REHJ-2J24bjnN.js} +1 -1
- package/dist/viewer/{bn-BD-2XOGV67Q-BZcPTrQZ.js → bn-BD-2XOGV67Q-DZJsG0hE.js} +1 -1
- package/dist/viewer/{c4Diagram-7LVT6UL2-BrMTJ9Id.js → c4Diagram-7LVT6UL2-yTIDzivZ.js} +1 -1
- package/dist/viewer/{ca-ES-6MX7JW3Y-CwsioDV-.js → ca-ES-6MX7JW3Y-CVq3-S6h.js} +1 -1
- package/dist/viewer/{chunk-4HAMMTFA-BW9OHXXX.js → chunk-4HAMMTFA-yCbyYIjV.js} +1 -1
- package/dist/viewer/{chunk-EIO257PC-evZ7LLJR.js → chunk-EIO257PC-9AowedrU.js} +1 -1
- package/dist/viewer/{chunk-GMAD6QVW-DymYrWbv.js → chunk-GMAD6QVW-D08n9S3v.js} +1 -1
- package/dist/viewer/{chunk-GVQU2GXP-BA0mY8Im.js → chunk-GVQU2GXP-BLOQ9VTL.js} +1 -1
- package/dist/viewer/{chunk-IMKFNOWR-CQUM8qsa.js → chunk-IMKFNOWR-DYhaGSLD.js} +1 -1
- package/dist/viewer/{chunk-L3NEJ4N5-B7BR7bNK.js → chunk-L3NEJ4N5-LTTyeW9m.js} +1 -1
- package/dist/viewer/{chunk-OSK3NFVY-CogMPsX2.js → chunk-OSK3NFVY-Ds-NZkku.js} +1 -1
- package/dist/viewer/{chunk-PWAF6VOD-nozxHfyq.js → chunk-PWAF6VOD-Cp2MzCfW.js} +1 -1
- package/dist/viewer/{chunk-SHT3W25Y-Bl3y_Wyw.js → chunk-SHT3W25Y-CUhJlOwh.js} +1 -1
- package/dist/viewer/{chunk-SVP7TREG-DpbTw4Oa.js → chunk-SVP7TREG-C_xybnIP.js} +1 -1
- package/dist/viewer/{chunk-TICWLB2K-B2URyT37.js → chunk-TICWLB2K-BOT0dV8O.js} +1 -1
- package/dist/viewer/{classDiagram-ZZMXUADV-CfYKDYLK.js → classDiagram-ZZMXUADV-DeueLdnn.js} +1 -1
- package/dist/viewer/{classDiagram-v2-VYDZK3BY-CfYKDYLK.js → classDiagram-v2-VYDZK3BY-DeueLdnn.js} +1 -1
- package/dist/viewer/{cs-CZ-2BRQDIVT-BSKGyExY.js → cs-CZ-2BRQDIVT-BJ_Qm1ae.js} +1 -1
- package/dist/viewer/{cynefinDiagram-5FMLGOSQ-B7_fItfW.js → cynefinDiagram-5FMLGOSQ-D28XVWhT.js} +1 -1
- package/dist/viewer/{da-DK-5WZEPLOC-DnDVit00.js → da-DK-5WZEPLOC-CzZl5mjr.js} +1 -1
- package/dist/viewer/{dagre-GXQ25YYZ-DIh0FvpT.js → dagre-GXQ25YYZ-DQN9grBa.js} +1 -1
- package/dist/viewer/{de-DE-XR44H4JA-D_jncPZb.js → de-DE-XR44H4JA-Bd5tVeYX.js} +1 -1
- package/dist/viewer/{diagram-S7CK7UJ4-bUdCyngg.js → diagram-S7CK7UJ4-BB15poXM.js} +1 -1
- package/dist/viewer/{diagram-UQ7AKVKN-BAPRdbJZ.js → diagram-UQ7AKVKN-DxsaLc3J.js} +1 -1
- package/dist/viewer/{diagram-VX7I27RA-DP2UCj9Q.js → diagram-VX7I27RA-BcXan5sK.js} +1 -1
- package/dist/viewer/{diagram-Z3DM3KII-CVOfYGeQ.js → diagram-Z3DM3KII-BN66uvop.js} +1 -1
- package/dist/viewer/{dist-D04go4Jf.js → dist-7H7IikS0.js} +1 -1
- package/dist/viewer/{dist-DvkVolar.js → dist-B5af8Emr.js} +1 -1
- package/dist/viewer/{dist-CZUMeMGz.js → dist-B7KuJkNX.js} +1 -1
- package/dist/viewer/{dist-D8maRC1O.js → dist-BBf2nMl5.js} +1 -1
- package/dist/viewer/{dist-DEWYK6pe.js → dist-BRlXG2Cd.js} +4 -4
- package/dist/viewer/{dist-CnDjfMsD.js → dist-BadJnj0b.js} +1 -1
- package/dist/viewer/{dist-TOf9ZoGg.js → dist-BbWdGUhi.js} +1 -1
- package/dist/viewer/{dist-BYAXFKoc.js → dist-BffMTqNw.js} +1 -1
- package/dist/viewer/{dist-CB9NdNsK.js → dist-BhSpizNs.js} +1 -1
- package/dist/viewer/{dist-C4Hz_qV8.js → dist-BysnXOGq.js} +1 -1
- package/dist/viewer/{dist-Csek4Dnv.js → dist-BytpoI2u.js} +1 -1
- package/dist/viewer/{dist-WpwoXo38.js → dist-C-6zEer9.js} +1 -1
- package/dist/viewer/{dist-DLn0RkUv.js → dist-CTbQVOnd.js} +1 -1
- package/dist/viewer/{dist-CIrGyXwi.js → dist-CUSOYRz0.js} +1 -1
- package/dist/viewer/{dist-DeDHBO2D.js → dist-D29zK0ja.js} +1 -1
- package/dist/viewer/{dist-CCVFgKFx.js → dist-DYud6yy9.js} +1 -1
- package/dist/viewer/{dist-6KKe1n-5.js → dist-DpFtrFXF.js} +1 -1
- package/dist/viewer/{dist-CelTIxRP.js → dist-DtP-008F.js} +1 -1
- package/dist/viewer/{dist-hBw9lcHo.js → dist-InnlxyT_.js} +1 -1
- package/dist/viewer/{dist-cx1NO1gN.js → dist-MGxf6S1n.js} +1 -1
- package/dist/viewer/{dist-BYHS6rSD.js → dist-MOSvUDTq.js} +1 -1
- package/dist/viewer/{dist-D2M7S4t8.js → dist-UvVAFvcH.js} +1 -1
- package/dist/viewer/{dist-DLmrBitx.js → dist-WzgQkTs2.js} +1 -1
- package/dist/viewer/{dist-BQ5ImSoF.js → dist-_E3Aj9F6.js} +1 -1
- package/dist/viewer/{ebnfDiagram-PWID7BFC-B7K4tFTr.js → ebnfDiagram-PWID7BFC-D2zgsDPd.js} +1 -1
- package/dist/viewer/{el-GR-BZB4AONW-CVJ7JtAM.js → el-GR-BZB4AONW-CttHNP83.js} +1 -1
- package/dist/viewer/{en-B4ZKOASM-B9M_gRPs.js → en-B4ZKOASM-B-HfQzZi.js} +1 -1
- package/dist/viewer/{erDiagram-RLTQ6QDP-CI3fKgME.js → erDiagram-RLTQ6QDP-ErTGP8zQ.js} +1 -1
- package/dist/viewer/{es-ES-U4NZUMDT-DMy5qyoR.js → es-ES-U4NZUMDT-Vx-iVKW-.js} +1 -1
- package/dist/viewer/{eu-ES-A7QVB2H4-Cb2hmR98.js → eu-ES-A7QVB2H4-Ib8tMKoW.js} +1 -1
- package/dist/viewer/{fa-IR-HGAKTJCU-rJZpfNmY.js → fa-IR-HGAKTJCU-Lv_aPgk-.js} +1 -1
- package/dist/viewer/{fi-FI-Z5N7JZ37-DtUJ2iKo.js → fi-FI-Z5N7JZ37-CQgwbIrk.js} +1 -1
- package/dist/viewer/flowDiagram-HODETNUW-Bqor2hGF.js +1 -0
- package/dist/viewer/{fr-FR-RHASNOE6-DREVsyCl.js → fr-FR-RHASNOE6-C4Ru44Oi.js} +1 -1
- package/dist/viewer/{ganttDiagram-EL5Y4UJY-CyB7aiTb.js → ganttDiagram-EL5Y4UJY-Drv79Y3v.js} +1 -1
- package/dist/viewer/{gl-ES-HMX3MZ6V-Bb2cL2bM.js → gl-ES-HMX3MZ6V-DThlmnLh.js} +1 -1
- package/dist/viewer/{he-IL-6SHJWFNN-Ba6OzvdH.js → he-IL-6SHJWFNN-ULh01wM6.js} +1 -1
- package/dist/viewer/{hi-IN-IWLTKZ5I-BQH8MugQ.js → hi-IN-IWLTKZ5I-CEJ8M1c2.js} +1 -1
- package/dist/viewer/{hu-HU-A5ZG7DT2-DmitQMVj.js → hu-HU-A5ZG7DT2-hNfaT-F_.js} +1 -1
- package/dist/viewer/{id-ID-SAP4L64H-tHirO6iK.js → id-ID-SAP4L64H-Co7js2Km.js} +1 -1
- package/dist/viewer/{image-GAAHSSAO-uAdtI-Qu.js → image-GAAHSSAO-DgtUzzOz.js} +1 -1
- package/dist/viewer/index.css +1 -1
- package/dist/viewer/index.html +1 -1
- package/dist/viewer/index.js +10 -10
- package/dist/viewer/index2.css +1 -1
- package/dist/viewer/{infoDiagram-27XIBGKW-3mwgoVdo.js → infoDiagram-27XIBGKW-BYf0CysE.js} +1 -1
- package/dist/viewer/{ishikawaDiagram-5VMMS53U-fiqms6Mp.js → ishikawaDiagram-5VMMS53U-BvquOAn1.js} +1 -1
- package/dist/viewer/{it-IT-JPQ66NNP-Dx7lu_fF.js → it-IT-JPQ66NNP-BvA3qteE.js} +1 -1
- package/dist/viewer/{ja-JP-DBVTYXUO-CY6hNceG.js → ja-JP-DBVTYXUO-erJqG72e.js} +1 -1
- package/dist/viewer/{journeyDiagram-3NMN7TZE-DF3rJFoS.js → journeyDiagram-3NMN7TZE-DnNKDwfs.js} +1 -1
- package/dist/viewer/{kaa-6HZHGXH3-riGvXPys.js → kaa-6HZHGXH3-DzIH7Rqb.js} +1 -1
- package/dist/viewer/{kab-KAB-ZGHBKWFO-BTyfeoEt.js → kab-KAB-ZGHBKWFO-By3avdgg.js} +1 -1
- package/dist/viewer/{kanban-definition-UXKFOSKX-BUL4w8fY.js → kanban-definition-UXKFOSKX-B9QiwX8C.js} +1 -1
- package/dist/viewer/{kk-KZ-P5N5QNE5-D7cdj5Nd.js → kk-KZ-P5N5QNE5-4FLzuc6i.js} +1 -1
- package/dist/viewer/{km-KH-HSX4SM5Z-VdiPZnvs.js → km-KH-HSX4SM5Z-CdPFGR5b.js} +1 -1
- package/dist/viewer/{ko-KR-MTYHY66A-CLRveh3B.js → ko-KR-MTYHY66A-CYaHaKq9.js} +1 -1
- package/dist/viewer/{ku-TR-6OUDTVRD-DDyWy-3l.js → ku-TR-6OUDTVRD-CtAI49du.js} +1 -1
- package/dist/viewer/{lt-LT-XHIRWOB4-CelMFdgS.js → lt-LT-XHIRWOB4-vAgfiXqa.js} +1 -1
- package/dist/viewer/{lv-LV-5QDEKY6T-Dz4j2ySW.js → lv-LV-5QDEKY6T-CAE88lyJ.js} +1 -1
- package/dist/viewer/{mindmap-definition-YA3MSWOX-DI3rSa1D.js → mindmap-definition-YA3MSWOX-DN3K-MJz.js} +1 -1
- package/dist/viewer/{mr-IN-CRQNXWMA-BasynTLZ.js → mr-IN-CRQNXWMA-BdKubZGu.js} +1 -1
- package/dist/viewer/{my-MM-5M5IBNSE-B_b7gZzJ.js → my-MM-5M5IBNSE-BjUDLH3-.js} +1 -1
- package/dist/viewer/{nb-NO-T6EIAALU-RJ1cqASS.js → nb-NO-T6EIAALU-BAJRhjlK.js} +1 -1
- package/dist/viewer/{nl-NL-IS3SIHDZ-hUQ_Ry2W.js → nl-NL-IS3SIHDZ-CtNPoNI1.js} +1 -1
- package/dist/viewer/{nn-NO-6E72VCQL-BMHlpVpN.js → nn-NO-6E72VCQL-KkzjVbef.js} +1 -1
- package/dist/viewer/{oc-FR-POXYY2M6-Cmo92vuC.js → oc-FR-POXYY2M6-Dts72HMP.js} +1 -1
- package/dist/viewer/{pa-IN-N4M65BXN-Cs21hlhC.js → pa-IN-N4M65BXN-DCj3bD0E.js} +1 -1
- package/dist/viewer/{pegDiagram-XKGWAZYB-B-uw75l9.js → pegDiagram-XKGWAZYB-B9yVgNYX.js} +1 -1
- package/dist/viewer/percentages-BXMCSKIN-O1CoKKio.js +1 -0
- package/dist/viewer/{pieDiagram-E7YTZNPT-CrO85yaK.js → pieDiagram-E7YTZNPT-DcsNBHEn.js} +1 -1
- package/dist/viewer/{pl-PL-T2D74RX3-D3GfI8z4.js → pl-PL-T2D74RX3-C2W6GWXZ.js} +1 -1
- package/dist/viewer/{prod-BKwPdSwb.js → prod-Po4zTtll.js} +8 -8
- package/dist/viewer/{pt-BR-5N22H2LF-3UA4Utr-.js → pt-BR-5N22H2LF-Doe9plvU.js} +1 -1
- package/dist/viewer/{pt-PT-UZXXM6DQ-7S3NKrPS.js → pt-PT-UZXXM6DQ-WeGs5YQk.js} +1 -1
- package/dist/viewer/{quadrantDiagram-AXDQQJYC-DUd4OIIP.js → quadrantDiagram-AXDQQJYC-DMAXQxhP.js} +1 -1
- package/dist/viewer/{railroadDiagram-O6MQD6OU-B8-5KSRF.js → railroadDiagram-O6MQD6OU-DhwTtXEx.js} +1 -1
- package/dist/viewer/{requirementDiagram-BXWQKSXE-_DXwRPyU.js → requirementDiagram-BXWQKSXE-QdbLu9xN.js} +1 -1
- package/dist/viewer/{ro-RO-JPDTUUEW-Bn4jg61m.js → ro-RO-JPDTUUEW-CWJCS8ra.js} +1 -1
- package/dist/viewer/{ru-RU-B4JR7IUQ-CIUnAJSf.js → ru-RU-B4JR7IUQ-Dm0UYs8X.js} +1 -1
- package/dist/viewer/{sequenceDiagram-WJ2MYXX4-DaGhhQYi.js → sequenceDiagram-WJ2MYXX4-DQIRgjC_.js} +1 -1
- package/dist/viewer/{si-LK-N5RQ5JYF-C1zzRPhV.js → si-LK-N5RQ5JYF-Cp94Up4l.js} +1 -1
- package/dist/viewer/{sk-SK-C5VTKIMK-4-vDd9yh.js → sk-SK-C5VTKIMK-CzLVUjpy.js} +1 -1
- package/dist/viewer/{sl-SI-NN7IZMDC-CmOYDfsh.js → sl-SI-NN7IZMDC-D0Ukp97r.js} +1 -1
- package/dist/viewer/{stateDiagram-D77RDMKH-CO2ODREI.js → stateDiagram-D77RDMKH-BFz8zLTz.js} +1 -1
- package/dist/viewer/{stateDiagram-v2-MP3YSRHH-UnmLroBp.js → stateDiagram-v2-MP3YSRHH-CVxpckk1.js} +1 -1
- package/dist/viewer/subset-shared.chunk-CAbEFhxt.js +1 -0
- package/dist/viewer/{subset-worker.chunk-BcVohm1G.js → subset-worker.chunk-8SA1nt6u.js} +1 -1
- package/dist/viewer/{sv-SE-XGPEYMSR-Crv8lcm8.js → sv-SE-XGPEYMSR-D5p091oO.js} +1 -1
- package/dist/viewer/{swimlanes-42K2YHIH-DMYal__Y.js → swimlanes-42K2YHIH-Dop4lxzS.js} +1 -1
- package/dist/viewer/{swimlanesDiagram-VR7AAH4N-CkVCVwis.js → swimlanesDiagram-VR7AAH4N-BLjjKFlg.js} +1 -1
- package/dist/viewer/{ta-IN-2NMHFXQM-CjXC30tc.js → ta-IN-2NMHFXQM-44iP3xtJ.js} +1 -1
- package/dist/viewer/{th-TH-HPSO5L25-CG8vWhsv.js → th-TH-HPSO5L25-DAHziL1F.js} +1 -1
- package/dist/viewer/{timeline-definition-24CTP7MA-Cz522IJg.js → timeline-definition-24CTP7MA-yNitNVKe.js} +1 -1
- package/dist/viewer/{tr-TR-DEFEU3FU-BBxajIoT.js → tr-TR-DEFEU3FU-C7eoABmA.js} +1 -1
- package/dist/viewer/{uk-UA-QMV73CPH-Bh4i5zPX.js → uk-UA-QMV73CPH-DW4v3OlW.js} +1 -1
- package/dist/viewer/{vennDiagram-4TSXK5OY-Bj3iQJOq.js → vennDiagram-4TSXK5OY-DMu5PSNX.js} +1 -1
- package/dist/viewer/{vi-VN-M7AON7JQ-BQQT0c6c.js → vi-VN-M7AON7JQ-DL9AvwjG.js} +1 -1
- package/dist/viewer/{wardleyDiagram-VM6X3IG4-CQT_Cggi.js → wardleyDiagram-VM6X3IG4-CzVuJ8IV.js} +1 -1
- package/dist/viewer/{xychartDiagram-S5SC5T6Z-Duw2Urah.js → xychartDiagram-S5SC5T6Z-Cust8Pv8.js} +1 -1
- package/dist/viewer/{zh-CN-LNUGB5OW-2Ra2sNV4.js → zh-CN-LNUGB5OW-bSVEOutP.js} +1 -1
- package/dist/viewer/{zh-HK-E62DVLB3-C3SFOMQC.js → zh-HK-E62DVLB3-CGMwLxet.js} +1 -1
- package/dist/viewer/{zh-TW-RAJ6MFWO-Y9op9XQa.js → zh-TW-RAJ6MFWO-C0EtMJC7.js} +1 -1
- package/package.json +18 -18
- package/dist/viewer/RailSwitch-B19XK2cL.js +0 -64
- package/dist/viewer/flowDiagram-HODETNUW-D8V20Y_N.js +0 -1
- package/dist/viewer/percentages-BXMCSKIN-DXImeTrM.js +0 -1
- package/dist/viewer/subset-shared.chunk-0s89nDq9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{A as r,D as i,E as a,Ea as o,Ka as s,M as c,O as l,Qa as u,Ra as d,j as f,k as p,m,o as h,p as g,ps as _,qa as v,s as y,t as b,u as x,w as S}from"./RailSwitch-B19XK2cL.js";import{$ as C,A as w,B as ee,C as T,D as E,F as D,G as O,H as k,I as A,J 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-D7VkWfYp.js";import{_ as Fe,a as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as He,l as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,u as Ye}from"./index.js";var Xe={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`}]]};Xe.node;var Ze=u(Xe),Qe={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`}]]};Qe.node;var $e=u(Qe),U=e(t(),1);function et({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 tt(e){return e<6e4?r.t(`time.seconds`,{count:Math.floor(e/1e3)}):e<36e5?r.t(`time.minutes`,{count:Math.floor(e/6e4)}):r.t(`time.hours`,{count:Math.floor(e/36e5)})}function nt(e,t,n){switch(e.kind){case`editing`:return n?r.t(`activity.editingSection`,{agent:t,section:n}):r.t(`activity.editing`,{agent:t});case`idle`:return null;case`working`:{let n=r.t(`activity.pending`,{agent:t,count:e.pending});return e.idleMs===null?n:e.idleMs<1e4?r.t(`activity.updatedJustNow`,{left:n}):r.t(`activity.updatedAgo`,{left:n,duration:tt(e.idleMs)})}case`stale`:return r.t(`activity.stale`,{agent:t,duration:tt(e.idleMs),count:e.pending})}}async function rt(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 it(e,t,n){let i=e.fork(),a;try{i.checkout(t);let e=i.getTree(me).roots();if(e.length!==1)throw Error(r.t(`history.contentUnavailable`));let o=M({nodes:n,editable:!1,onError:e=>{throw e}});a=B(o,i);let s=e[0].children()??[],c=new Map,l=(e,t)=>{c.set(e.id,t),e.children()?.forEach(e=>l(e,t))};return s.forEach(e=>l(e,e.id)),{value:o.getEditorState().toJSON(),ids:s.map(e=>e.id),owners:c}}finally{a?.dispose(),i.free()}}var at=/^cid:(\d+@\d+):Map$/;function ot(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=at.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 st=5e4,ct=`background-color: color-mix(in srgb, var(--rc-alert-caution) 22%, transparent); text-decoration: line-through;`,lt=`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 ut(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 dt(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=dt(r,ct):n===`insert`&&(r=dt(r,lt)),{...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 ft(e){return Array.from(e).reverse().join(``)}function pt(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 mt(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>st)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 pt(a.reverse().map(e=>({kind:e.kind,text:ft(e.text)})))}function ht(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(...mt(n.slice(i,a+1),r.slice(i,o+1))),a<n.length-1&&s.push({kind:`equal`,text:n.slice(a+1).join(``)}),pt(s)}function gt(e,t){let n=ht(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 _t(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=ut(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=ut(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 vt(e,t){let n=_t(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=gt(e.oldNode,e.newNode);r.push(...t.oldNodes),i.push(...t.newNodes);break}let t=yt(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 yt(e,t){if(W(e)!==W(t))return null;if(ut(e,t))return{oldNode:e,newNode:t,changed:!1};let n=K(e),r=K(t);if(!n||!r)return null;let i=vt(n,r);return i.changed?{oldNode:J(e,i.oldChildren),newNode:J(t,i.newChildren),changed:!0}:{oldNode:e,newNode:t,changed:!1}}function bt(e,t){let n=yt(e,t);return n?{oldNode:n.oldNode,newNode:n.newNode}:{oldNode:Y(e,`delete`),newNode:Y(t,`insert`)}}function xt(e,t){let n=ht(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 St(e,t){let n=_t(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(...xt(e.oldNode,e.newNode));break}let t=K(e.oldNode),n=K(e.newNode);t&&n?r.push(J(e.newNode,St(t,n))):(r.push(Y(e.oldNode,`delete`)),r.push(Y(e.newNode,`insert`)));break}}return r}function Ct(e,t){if(W(e)!==W(t))return Y(t,`insert`);if(ut(e,t))return t;let n=K(e),r=K(t);return!n||!r?Y(t,`insert`):J(t,St(n,r))}function wt(e,t){let n=_t(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=bt(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 Tt(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(Tt),t}function Et(e,t){let{children:n,text:r,...i}=e,{children:a,text:o,...s}=t;return JSON.stringify(i)!==JSON.stringify(s)||!!(n&&a&&At(n,a).some(e=>e.kind===`modify`&&Et(e.old[0],e.current[0])))}function Dt(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`?r.t(`history.dynamic`,{url:t.url,height:t.initialHeight??320,props:JSON.stringify(t.props??{})}):r.t(`history.pendingIntent`,{intent:t.intent??``}),format:0,detail:0,mode:`normal`,style:``}]}:t.children?{...t,children:t.children.map(Dt)}:t}function Ot(e){return kt(e.map(Dt))}function kt(e){return{root:{type:`root`,version:1,direction:null,format:``,indent:0,children:e}}}function At(e,t){let n=wt(kt(e),kt(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 jt(e,t){return At(e.root.children.map(Tt),t.root.children.map(Tt)).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&&!Et(n,r)?{kind:`modify`,value:Ot([Ct(n,r)]),...t}:{kind:`modify`,before:Ot(e.old),value:Ot(e.current),...t}}let n=e.kind===`delete`?e.old:e.current;return{kind:e.kind,value:Ot(e.kind===`equal`?n:n.map(t=>Y(t,e.kind))),...t}})}function Mt(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 Nt({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]}`,Pt={h1:Z(`headingH1`),h2:Z(`headingH2`),h3:Z(`headingH3`),h4:Z(`headingH4`),h5:Z(`headingH5`),h6:Z(`headingH6`)};function Ft(e){return e.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g,``).replaceAll(/[\s_]+/g,`-`).replaceAll(/^-+|-+$/g,``)}function It(e){return e.type===`comment`?``:e.text?e.text:e.children?e.children.map(It).join(``):``}var Lt=/^["'«‘“‹「『"']/,Rt=/["'»’”›」』"']$/;function zt(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=Ft(i||It(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:Pt[a],id:s||void 0,children:[s&&(0,X.jsx)(`a`,{className:Z(`headingAnchor`),href:`#${s}`,tabIndex:0,children:(0,X.jsx)(d,{"aria-hidden":!0,size:14,strokeWidth:2})}),n]},t)}case`rich-quote`:case`quote`:{let r=(i||It(e)).trim(),a=Lt.test(r),o=Rt.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)(w,{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)(w,{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:`${A.details} ${N.details}`,open:e.open||void 0,children:[(0,X.jsxs)(`summary`,{className:`${A.summary} ${N.summary}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`${A.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:`${A.summaryText} ${N.summaryText}`,children:r})]}),(0,X.jsx)(`div`,{className:`${A.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:k(e.text)},children:e.text},t);case`comment`:return(0,X.jsx)(Nt,{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 Bt=e=>`${H[e]} ${Te[e]}`,Vt=[[1,`textBold`],[2,`textItalic`],[4,`textStrikethrough`],[8,`textUnderline`],[16,`textCode`],[32,`textSubscript`],[64,`textSuperscript`],[128,`textHighlight`]];function Ht(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 Ut(e,t){let n=e.text,r=e.format||0;for(let[e,i]of Vt)r&e&&(n=(0,X.jsx)(`span`,{className:Bt(i),children:n},`${t}-${e}`));return e.style&&(n=(0,X.jsx)(`span`,{style:Ht(e.style),children:n},t)),n}function Wt(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 Gt=e=>`${H.alert} ${Te.alert} rich-alert-${e}`;function Kt(e,t,n){switch(e.type){case`alert-quote`:return(0,U.createElement)(`div`,{key:t,className:Gt(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 qt(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 Jt(e,t,n,r){return t?(r.blockAnchor??qt)(e,t,n):e}function Yt(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 Jt(n?n(t,s,[r],()=>Kt(t,s,r)):Kt(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,()=>Ut(l,s)):Ut(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)=>Yt(e,t,n,r,`${s}-${i}`,void 0,o)));let f=e.getTextContent?e.getTextContent():void 0,p=c?.[l.type];return Jt(p?p(l,s,d,()=>zt(l,s,d,r,f)):zt(l,s,d,r,f),a,s,o)}function Xt(e,t,n){let r=Mt({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=Wt(a),c=a.root?.children,l=null;return o.read(()=>{let e=O(),t=new Map,a=e.getChildren().map((e,a)=>Yt(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=Mt({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=O(),t=new Map,a=e.getChildren().map((e,a)=>Yt(e,r,i,t,`nested-${a}`,c?.[a]?.$?.blockId,n));s=(0,X.jsx)(X.Fragment,{children:a})}),s}}}function Zt({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)(()=>Xt(e,c?[...D,...c]:D,{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)(C,{config:s,mode:`renderer`,variant:t,children:(0,X.jsx)(oe,{definitions:m.definitions,displayNumberMap:m.displayNumberMap,children:(0,X.jsx)(ee,{value:f??h,children:(0,X.jsx)(a,{..._,style:i,children:p})})})})})})}var Qt=[T],$t=864e5,en=e=>String(e).padStart(2,`0`),tn=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function nn(e,t=Date.now()){if(!(e>0))return r.t(`time.notRecorded`);let n=new Date(e*1e3),i=new Date(t),a=Math.round((tn(i)-tn(n))/$t);if(a===0)return r.t(`time.today`);if(a===1)return r.t(`time.yesterday`);let o=n.getFullYear()===i.getFullYear();return new Intl.DateTimeFormat(c[r.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=`${en(n.getHours())}:${en(n.getMinutes())}`;return t?`${r}:${en(n.getSeconds())}`:r}function $(e){return e>0?`${nn(e)} ${Q(e)}`:r.t(`time.notRecorded`)}var rn={human:`history.sourceHuman`,agent:`history.sourceAgent`,session:`history.sourceSession`,unknown:`history.sourceUnknown`};function an(e){let{session:t,selected:n}=e;return t&&n?t.history.groups.find(e=>e.entries.includes(n)):void 0}function on(e){return e.session?.history.entries.at(-1)?.change.timestamp??0}function sn({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":f(`history.previousChange`),disabled:n===0||r,onClick:()=>e.navigate(-1),children:(0,X.jsx)(Fe,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":f(`history.nextChange`),disabled:n>=t-1||r,onClick:()=>e.navigate(1),children:(0,X.jsx)(v,{size:14,"aria-hidden":`true`})})]})}function cn({model:e}){return(0,X.jsx)(`button`,{type:`button`,className:`history-filter`,"aria-pressed":e.onlyChanges,onClick:e.toggleOnly,children:f(`history.onlyChanges`)})}function ln({model:e}){return e.pending?(0,X.jsxs)(`div`,{className:`history-update`,role:`status`,children:[(0,X.jsx)(`span`,{children:e.streaming?f(`history.waitingEdits`):f(`history.newContent`,{time:Q(on(e))})}),(0,X.jsxs)(`button`,{type:`button`,disabled:e.streaming||e.loading,onClick:e.refresh,children:[(0,X.jsx)($e,{size:12,"aria-hidden":`true`}),f(`history.refresh`)]})]}):null}function un({model:e}){let{selected:t,blocks:n,count:r}=e,i=an(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":f(`history.range`),children:[(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:f(`history.from`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:t?$(t.change.timestamp):f(`history.pickPoint`)}),i?(0,X.jsx)(`span`,{children:f(rn[i.source])}):null]}),(0,X.jsx)(`dt`,{children:f(`history.to`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:f(`history.latestVersion`)}),(0,X.jsx)(`span`,{children:$(on(e))})]})]}),(0,X.jsxs)(`div`,{className:`history-controls`,children:[(0,X.jsx)(`span`,{children:f(`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)(cn,{model:e}),(0,X.jsx)(sn,{model:e})]})]})}function dn({model:e}){let[t,n]=(0,U.useState)(50),[r,i]=(0,U.useState)(()=>new Set),{session:a,selected:o,blocks:c}=e;if(!a)return null;let{groups:l,entries:u,shallow:d}=a.history,p=l.findIndex(e=>o!==null&&e.entries.includes(o)),m=new Map;for(let e of c)e.group&&m.set(e.group,(m.get(e.group)??0)+1);let h=l.slice(0,t),g=e=>nn(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":f(`history.timeline`),children:h.map((t,n)=>{let i=t.entries.at(-1),a=g(t),c=n===0||a!==g(h[n-1]),l=n===p?`selected`:n===0?`latest`:n<p?`range`:`outside`,u=r.has(t.id),d=n<p?m.get(t):void 0;return(0,X.jsxs)(`li`,{className:`history-node`,"data-state":l,"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":l===`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:f(rn[t.source])}),l===`latest`?(0,X.jsx)(`span`,{className:`history-tag`,children:f(`history.latest`)}):null,l===`selected`?(0,X.jsx)(`span`,{className:`history-tag history-start`,children:f(`history.start`)}):null]}),(0,X.jsxs)(`span`,{className:`history-meta`,children:[f(`history.commits`,{count:t.entries.length}),d?(0,X.jsx)(`span`,{className:`history-changed`,children:f(`history.changedSuffix`,{count:d})}):null]})]}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon history-expand`,"aria-label":f(u?`history.collapseCommits`:`history.expandCommits`),"aria-expanded":u,onClick:()=>_(t.id),children:(0,X.jsx)(s,{size:14,"aria-hidden":`true`})})]}),u?(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===o?`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||f(`history.sourceUnknown`)})]},t.id))}):null]},t.id)})}),t<l.length?(0,X.jsx)(`button`,{type:`button`,className:`history-more`,onClick:()=>n(e=>e+50),children:f(`history.loadEarlier`)}):(0,X.jsxs)(`p`,{className:`history-end`,children:[f(d?`history.shallow`:`history.earliest`),` · `,f(`history.summary`,{edits:f(`history.edits`,{count:l.length}),commits:f(`history.commits`,{count:u.length})}),(0,X.jsx)(`br`,{}),f(`history.clockNote`)]})]})}function fn({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:f(`history.agentEditing`)}),(0,X.jsx)(`span`,{children:f(`history.agentEditingBody`)})]}):(0,X.jsx)(`strong`,{children:f(`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 pn({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`}),f(`history.failed`)]}),(0,X.jsx)(`code`,{children:e.error}),(0,X.jsx)(`span`,{children:f(`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:f(`common.retry`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-quiet`,onClick:e.close,children:f(`history.backToComments`)})]})]})}function mn({model:e}){return(0,X.jsxs)(`aside`,{className:`history-panel`,"aria-label":f(`history.title`),children:[(0,X.jsxs)(`header`,{className:`history-panel-head`,children:[(0,X.jsx)(`h2`,{children:f(`history.title`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":f(`history.close`),onClick:e.close,children:(0,X.jsx)(o,{size:14,"aria-hidden":`true`})})]}),(0,X.jsx)(ln,{model:e}),e.error?(0,X.jsx)(pn,{model:e}):e.session?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(un,{model:e}),(0,X.jsx)(dn,{model:e})]}):(0,X.jsx)(fn,{streaming:e.streaming})]})}function hn({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:f(`history.chooseStart`)}),(0,X.jsx)(`small`,{children:f(`history.compareWithLatest`,{time:$(on(e))})})]}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:f(`common.done`)})]});return(0,X.jsx)(`div`,{ref:n,className:`history-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":f(`history.chooseStart`),children:(0,X.jsx)(Le,{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)(dn,{model:e})})})})}var gn=[je,E,...Qt],_n={[j]:I,[se]:Me,[ce]:ue,[ie]:V},vn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function yn({model:e,theme:t,title:n,narrow:r,bodyRef:i,onPick:a}){let{session:o,selected:s,blocks:c,count:l,changeIndex:u,loading:d,error:p,streaming:m,onlyChanges:h}=e,g=e=>(0,X.jsx)(Zt,{value:e,variant:`article`,theme:t,extraNodes:gn,rendererConfig:_n}),_=-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:f(`history.compareFrom`)}),(0,X.jsxs)(`strong`,{children:[f(`history.toLatest`,{from:s?$(s.change.timestamp):f(`history.pickPoint`)}),(0,X.jsx)(v,{size:12,"aria-hidden":`true`})]})]}),(0,X.jsx)(cn,{model:e}),(0,X.jsx)(sn,{model:e})]}):null,r?(0,X.jsx)(ln,{model:e}):null,p?r?(0,X.jsxs)(`div`,{role:`alert`,className:`history-message`,children:[f(`history.readFailed`,{error:p}),(0,X.jsx)(`button`,{type:`button`,disabled:m,onClick:e.refresh,children:f(`common.retry`)})]}):(0,X.jsx)(`p`,{className:`history-message`,children:f(`history.unreadable`)}):d||!o?(0,X.jsx)(`div`,{role:`status`,className:`history-message`,children:f(m?`history.waitingEdits`:`history.computing`)}):(0,X.jsxs)(`div`,{ref:i,"aria-label":f(`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}),l?null:(0,X.jsx)(`p`,{role:`status`,className:`history-note`,children:f(`history.noDiff`)}),c.map((t,n)=>{if(t.kind===`equal`)return h?(0,X.jsx)(`button`,{type:`button`,className:`history-fold`,onClick:e.showAll,children:(0,X.jsx)(`span`,{children:f(`history.unchanged`,{count:t.value.root.children.length})})},n):(0,X.jsx)(`section`,{className:`history-hunk history-equal`,children:g(t.value)},n);_++;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":_===u?``: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:f(vn[t.kind])}),t.author?(0,X.jsxs)(`span`,{children:[$(t.author.change.timestamp),t.group?` · ${f(rn[t.group.source])}`:``]}):null]}),t.before?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`history-before`,children:g(t.before)}),(0,X.jsx)(`div`,{className:`history-after`,children:g(t.value)})]}):(0,X.jsx)(`div`,{className:r,children:g(t.value)})]},n)}),(0,X.jsx)(`p`,{className:`history-end`,children:f(`history.endOfDiff`)})]})]})}var bn=e=>JSON.stringify(e.frontiers()),xn=(e,t)=>t===void 0?void 0:e[t];function Sn({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),f=(0,U.useRef)(null),p=(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=m(`(max-width: 1100px)`),k=(0,U.useRef)(null),A=(0,U.useCallback)(async()=>{if(!e)return;let n=++p.current;g(!0),v(null);let r=e.fork();try{let i=await rt(r),a=it(r,r.frontiers(),t);if(p.current!==n){r.free();return}let o=f.current;f.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(bn(e)!==bn(r)),o?.free()}catch(e){r.free(),p.current===n&&v(e.message)}finally{p.current===n&&g(!1)}},[e,t]);if((0,U.useEffect)(()=>{if(a)return()=>{p.current++,f.current?.free(),f.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&&!f.current&&A()},[a,A,n]),(0,U.useEffect)(()=>{if(a&&e)return e.subscribe(()=>b(f.current!==null&&bn(e)!==bn(f.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=it(s.doc,l.frontiers,t),{entries:r,groups:i}=s.history,a=ot(s.doc,r.slice(r.indexOf(l)+1),[n,s.latest]),o=new Map(i.flatMap(e=>e.entries.map(t=>[t,e]))),c=jt(n.value,s.latest.value).map(e=>{if(e.kind===`equal`)return e;let t=[xn(s.latest.ids,e.newIndex),xn(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)(yn,{model:M,theme:r,title:i,narrow:O,bodyRef:k,onPick:()=>D(!0)}),O&&E?(0,X.jsx)(hn,{model:M,onDismiss:()=>D(!1)}):null]}),panel:O?null:(0,X.jsx)(mn,{model:M})}}function Cn({left:e,top:t,quote:n,initial:r,restored:i,leaving:a,onChange:o,onSubmit:s,onCancel:c,ref:l}){return(0,X.jsx)(`div`,{ref:l,...{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:f(`document.draftRestored`)}):null]}),(0,X.jsx)(S,{autoFocus:!0,initial:r,placeholder:f(`document.draftPlaceholder`),onChange:o,onSubmit:s,onCancel:c})]})})}function wn({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)(Ze,{size:14,className:`x2lah0s x17nrqe2`}),f(`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:f(`document.copy`)})]})}var Tn=(e,t)=>`${e}\n${t}`;function En(){let e=new Map;return{save(t,n){n.trim()?e.set(t,n):e.delete(t)},take(t){return e.get(t)??``}}}function Dn(e){let t=(0,U.useMemo)(En,[]),[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(Tn(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(Tn(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 On(e){return{left:e.offsetLeft,right:Math.min(e.offsetLeft+e.offsetWidth,window.innerWidth-16)}}function kn({editor:e,threads:t,actions:n,agent:r,canComment:i,selection:a,clearSelection:o,onCreate:s,onMain:c,history:l,children:u}){let d=Dn(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)(wn,{ref:d.toolbarRef,...ve(a,On(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)(Cn,{ref:d.panelRef,...de(f.target,On(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 An({id:e,title:t,activity:n,agentSection:r,offline:i,openComments:a,cloud:o,compact:s=!1,onDone:c,agent:l=`Agent`,history:u}){let d=nt(n,l,r);return h(e,o?{...t?{title:t}:{},online:o.online,comments:a,activity:d,activityTone:n.kind===`stale`?`warning`:n.kind===`working`?`quiet`:`live`,retrying:i,reason:o.reason,history:u?.available,historyOpen:u?.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})]}),d?(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`}),d]}):null,i?(0,X.jsx)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`,children:f(`document.notSynced`)}):null,u?.open?(0,X.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`,children:[(0,X.jsx)(Ve,{size:11,"aria-hidden":`true`}),f(`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?f(`share.computerOnline`):f(`share.computerOffline`)]}):null,u?(0,X.jsx)(b,{comments:a,open:u.open,available:u.available,onComments:u.close,onHistory:u.toggle}):null,c?(0,X.jsx)(`button`,{type:`button`,onClick:c,className:`x12ulsxz xaope02 xc342km x1kogg8i x19ckca5 xs0jrwl xqfszdh x4z9k3i x1s688f x1ypdohk`,children:f(`common.done`)}):o||s?null:(0,X.jsx)(ze,{artifact:`document/${e}`})]})}function jn(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,Ye.blockIds),heading:e.slice(0,r+1).filter(e=>e.heading).pop()?.text??``}}var Mn=crypto.randomUUID(),Nn=300,Pn={quote:``,blockIds:[],heading:``};function Fn(e){let t=window.getSelection(),n=e.getRootElement();if(!t||t.isCollapsed||!n?.contains(t.anchorNode)||!n.contains(t.focusNode))return Pn;let r=t.toString().trim().slice(0,Ye.quote);return r?e.read(()=>{let e=O().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{...Pn,quote:r};let o=e.map(e=>({id:Se(e,_e)||``,heading:e.getType()===`heading`,text:e.getTextContent().slice(0,Ye.heading)}));return{quote:r,...jn(o,i,a)}}):Pn}function In(e,t,n,r){let i=(0,U.useRef)(Pn);(0,U.useEffect)(()=>{if(!e)return;let n=0,a=()=>{let n=Fn(e);JSON.stringify(n)!==JSON.stringify(i.current)&&(i.current=n,r({type:`selection`,artifact:t,tab:Mn,human:!0,...n}))},o=()=>{clearTimeout(n),n=window.setTimeout(a,Nn)};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:Mn,human:!1,...i.current})},[n,t,r])}var Ln=[`pending`],Rn=`x-ryugi-document-features`,zn=e=>{let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)};function Bn({id:e,channel:t,send:n}){let r=(t,n,r)=>fetch(`/api/document/${e}/${t}`,{method:`POST`,headers:{"Content-Type":r,[Rn]:Ln.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 Vn(e){let t=L(),n=(e.connect??Ie)({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:zn(e),features:Ln})},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 Hn(e){let t=(0,U.useMemo)(L,[]),n=`document/${e}`,{live:r,send:i}=Ke(e=>{e.artifact===n&&t.emit(e)},()=>t.emit({type:`open`}));return{transport:(0,U.useMemo)(()=>Bn({id:e,channel:t,send:i}),[e,t,i]),live:r}}function Un(e,t){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let n=Vn({url:We(e),artifact:`document/${e}`,contentBase:t,onPresence:a,connect:t=>qe(e,t,t=>He({...t,cloudId:e,known:Ge()}))});return r(n),()=>{n.close(),r(null),a(null)}},[e,t]),{transport:n,presence:i}}var Wn={count:0,firstKey:null},Gn=e=>e.read(()=>{let e=O().getChildren().filter(e=>e.getType()===`pending`).map(e=>e.getKey());return{count:e.length,firstKey:e[0]??null}});function Kn(e){let[t,n]=(0,U.useState)(Wn);return(0,U.useEffect)(()=>{if(!e){n(Wn);return}let t=e=>n(t=>t.count===e.count&&t.firstKey===e.firstKey?t:e);return t(Gn(e.getEditorState())),e.registerUpdateListener(({editorState:e})=>t(Gn(e)))},[e]),t}function qn(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 Jn({left:e,top:t,placement:n,canComment:r,canEdit:i,onComment:a,onEdit:o}){let s=(0,U.useRef)(null),c=[r?{label:f(`common.comment`),Icon:Ze,run:a,primary:!0}:null,i?{label:f(`document.editText`),Icon:Ce,run:o,primary:!1}:null].filter(e=>e!==null);return(0,U.useLayoutEffect)(()=>{x(s.current,[{opacity:0,transform:`scale(0.96)`},{opacity:1,transform:`none`}],{duration:160,easing:y})},[]),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 Yn={state:{kmuXW:`x2lah0s`,kGuDYH:`xfifm61`,$$css:!0},waitingAgent:{kMwMTN:`x7zghnd`,$$css:!0},answered:{kMwMTN:`xh0clw4`,$$css:!0},resolved:{kMwMTN:`xddlp02`,$$css:!0}},Xn=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Zn({thread:e,agent:t=`Agent`,actions:n,active:r=!1,offline:o=!1}){let s=p(e),c=e.status===`resolved`,l=c?{label:f(`common.resolved`),tone:Yn.resolved}:s===`agent`?{label:f(`document.waitingAgentReply`,{agent:t}),tone:Yn.waitingAgent}:s===`human`?{label:f(`document.agentReplied`,{agent:t}),tone:Yn.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`}}[!!r|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||f(`document.wholeBlock`)}),l?(0,X.jsx)(`span`,{..._(Yn.state,l.tone),children:l.label}):null]}),c&&!r?null:e.messages.map(e=>{let{label:t,initial:n}=i(e);return(0,X.jsxs)(`div`,{className:`x14vqqas`,children:[(0,X.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x4z9k3i x1s688f`,children:[(0,X.jsx)(a,{human:e.author===`human`,initial:n,name:e.name,src:e.avatar}),t,(0,X.jsx)(`span`,{className:`xddlp02 xo1l8bm xfifm61`,children:Xn(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?f(`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)(S,{placeholder:f(`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:f(c?`common.reopen`:`common.resolve`)})]}):null]})}var Qn=.5,$n=e=>e===78?Qn:e;function er({threads:e,agent:t=`Agent`,actions:n,offline:r,draft:i,onCreate:a,onCancelDraft:o,activeId:s,snap:c,onSnap:l}){let u=(0,U.useRef)(null),d=e.filter(e=>!e.messages.every(e=>e.deleted)),m=d.filter(e=>p(e)===`agent`).length,h=r?f(`document.offlineNoComments`):m>0?f(`document.waitingCount`,{count:m,agent:t}):null;return(0,U.useEffect)(()=>{let e=s?u.current?.querySelector(`[data-thread="${CSS.escape(s)}"]`):null,t=e?.closest(`[data-sheet-body]`);e&&t&&(t.scrollTo({top:t.scrollTop+e.getBoundingClientRect().top-t.getBoundingClientRect().top-8,behavior:`smooth`}),x(e,[{backgroundColor:`rgba(232, 194, 74, 0.24)`},{backgroundColor:`transparent`}],{duration:600,delay:250,easing:y}))},[s]),(0,X.jsx)(Le,{snaps:[78,Qn,1],snap:c,onSnap:l,onScrim:()=>l(Qn),header:(0,X.jsxs)(`span`,{className:`x78zum5 x1pha0wt x17d4w8g xu0aao5 x17qtykl xwib8y2 xqfszdh x1jvydc1 x1s688f`,children:[f(`document.sheetComments`,{count:d.length}),h?(0,X.jsxs)(`span`,{className:`xddlp02 xfifm61 xo1l8bm`,children:[`· `,h]}):null]}),children:(0,X.jsxs)(`div`,{ref:u,className:`x17qtykl xwxc41k`,children:[i&&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:i.quote}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`x1717udv xc342km xjbqb8w xddlp02 x4z9k3i x1ypdohk`,children:f(`common.cancel`)})]}),(0,X.jsx)(`div`,{className:`x1xmf6yo x1qyh8g1 xso031l x1q0q8m5 x1iz93xd`,children:(0,X.jsx)(S,{autoFocus:!0,placeholder:f(`document.agentPlaceholder`),onSubmit:e=>a(i,e).then(e=>(e&&o(),e))})})]}):null,d.length===0&&!i?(0,X.jsx)(`div`,{className:`xr9q8rw xddlp02 xqfszdh x4z9k3i x2b8uid`,children:f(`document.noComments`)}):null,d.map(e=>(0,X.jsx)(Zn,{thread:e,agent:t,actions:n,active:e.id===s,offline:r},e.id))]})})}var tr=52;function nr({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($n)},children:[f?.content,(0,X.jsx)(`div`,{hidden:!!f,children:p})]}),s&&!b&&!f?(0,X.jsx)(Jn,{...Ee(s,{left:8,right:(m?.clientWidth??0)-8},170,44,{top:m?.getBoundingClientRect().top??0,height:window.innerHeight,reserved:Ue(v,window.innerHeight-tr)}),canComment:i,canEdit:a,onComment:()=>{x(s),y(Qn),C()},onEdit:()=>{u(s),c()}}):null,(0,X.jsx)(`div`,{hidden:!!f,className:`xixxii4 x1ozmhy9 xu96u03 x3m8u43 x1ey2m1c x1355qak x47corl`,children:(0,X.jsx)(er,{threads:t,agent:r,actions:n,offline:o,draft:b,onCreate:l,onCancelDraft:()=>x(null),activeId:g,snap:v,onSnap:y})})]})}var rr=200;function ir(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,rr)};return document.addEventListener(`selectionchange`,a),()=>{clearTimeout(n),document.removeEventListener(`selectionchange`,a)}},[e,t]),[n,()=>r(null)]}var ar=[...D.filter(e=>!fe.some(t=>t.getType()===(`getType`in e?e.getType():e.replace.getType()))),...fe];function or(){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 sr(e){(0,U.useEffect)(()=>{if(!e)return;let t=document.createElement(`base`);return t.href=e,document.head.prepend(t),()=>t.remove()},[e])}function cr({id:e}){let{transport:t,live:n}=Hn(e);return(0,X.jsx)(lr,{id:e,transport:t,live:n})}function lr({id:e,transport:t,live:n,cloud:r,fallback:i}){let[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),[u,d]=(0,U.useState)(l),[p,h]=(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=or(),{artifact:re,channel:P}=t,ie=!r||r.online,F=!r||r.canEdit,I=m(g),[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),d(n.comments??l());let i=oe?{left:window.scrollX,top:window.scrollY,behavior:`instant`}:null;c(r),i&&requestAnimationFrame(()=>{e||window.scrollTo(i)})}catch(t){e||h(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`&&d(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&&d(e.comments)},[C]);sr(a?.contentBase),In(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]),Re(`document`);let B=Kn(j),le=qn(B.count>0&&!_),ue=et({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=u.threads.filter(e=>e.status===`open`).length,[me,ge]=ir(j,N),_e=(0,U.useCallback)(()=>O(!1),[]),ve=Sn({doc:s,nodes:ar,streaming:_,theme:ne?`dark`:`light`,title:a?.title||e,open:A,onClose:_e}),V=(0,U.useCallback)(async e=>{try{return d(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(p)return(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:p});if(!s)return i??(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:f(`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)(An,{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)(nr,{editor:j,threads:u.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)(kn,{editor:j,threads:u.threads,actions:ye,agent:a?.agent,canComment:ie,selection:me,clearSelection:ge,onCreate:H,onMain:te,history:ve,children:Se}),(0,X.jsx)(Je,{warnings:a?.warnings??[]})]})}export{lr as DocumentView,cr as default,Un as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{A as r,D as i,E as a,Ka as o,M as s,O as c,Oa as l,Ra as u,ga as d,j as f,k as p,m,o as h,p as g,s as _,ss as v,t as y,u as b,w as x,za as S}from"./RailSwitch-CoEg_jiu.js";import{$ as C,A as w,B as ee,C as T,D as E,F as D,G as O,H as k,I as A,J 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-m54YZ2wJ.js";import{_ as Fe,a as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as He,l as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,u as Ye}from"./index.js";var Xe={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`}]]};Xe.node;var Ze=o(Xe),Qe={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`}]]};Qe.node;var $e=o(Qe),U=e(t(),1);function et({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 tt(e){return e<6e4?r.t(`time.seconds`,{count:Math.floor(e/1e3)}):e<36e5?r.t(`time.minutes`,{count:Math.floor(e/6e4)}):r.t(`time.hours`,{count:Math.floor(e/36e5)})}function nt(e,t,n){switch(e.kind){case`editing`:return n?r.t(`activity.editingSection`,{agent:t,section:n}):r.t(`activity.editing`,{agent:t});case`idle`:return null;case`working`:{let n=r.t(`activity.pending`,{agent:t,count:e.pending});return e.idleMs===null?n:e.idleMs<1e4?r.t(`activity.updatedJustNow`,{left:n}):r.t(`activity.updatedAgo`,{left:n,duration:tt(e.idleMs)})}case`stale`:return r.t(`activity.stale`,{agent:t,duration:tt(e.idleMs),count:e.pending})}}async function rt(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 it(e,t,n){let i=e.fork(),a;try{i.checkout(t);let e=i.getTree(me).roots();if(e.length!==1)throw Error(r.t(`history.contentUnavailable`));let o=M({nodes:n,editable:!1,onError:e=>{throw e}});a=B(o,i);let s=e[0].children()??[],c=new Map,l=(e,t)=>{c.set(e.id,t),e.children()?.forEach(e=>l(e,t))};return s.forEach(e=>l(e,e.id)),{value:o.getEditorState().toJSON(),ids:s.map(e=>e.id),owners:c}}finally{a?.dispose(),i.free()}}var at=/^cid:(\d+@\d+):Map$/;function ot(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=at.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 st=5e4,ct=`background-color: color-mix(in srgb, var(--rc-alert-caution) 22%, transparent); text-decoration: line-through;`,lt=`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 ut(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 dt(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=dt(r,ct):n===`insert`&&(r=dt(r,lt)),{...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 ft(e){return Array.from(e).reverse().join(``)}function pt(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 mt(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>st)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 pt(a.reverse().map(e=>({kind:e.kind,text:ft(e.text)})))}function ht(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(...mt(n.slice(i,a+1),r.slice(i,o+1))),a<n.length-1&&s.push({kind:`equal`,text:n.slice(a+1).join(``)}),pt(s)}function gt(e,t){let n=ht(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 _t(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=ut(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=ut(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 vt(e,t){let n=_t(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=gt(e.oldNode,e.newNode);r.push(...t.oldNodes),i.push(...t.newNodes);break}let t=yt(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 yt(e,t){if(W(e)!==W(t))return null;if(ut(e,t))return{oldNode:e,newNode:t,changed:!1};let n=K(e),r=K(t);if(!n||!r)return null;let i=vt(n,r);return i.changed?{oldNode:J(e,i.oldChildren),newNode:J(t,i.newChildren),changed:!0}:{oldNode:e,newNode:t,changed:!1}}function bt(e,t){let n=yt(e,t);return n?{oldNode:n.oldNode,newNode:n.newNode}:{oldNode:Y(e,`delete`),newNode:Y(t,`insert`)}}function xt(e,t){let n=ht(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 St(e,t){let n=_t(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(...xt(e.oldNode,e.newNode));break}let t=K(e.oldNode),n=K(e.newNode);t&&n?r.push(J(e.newNode,St(t,n))):(r.push(Y(e.oldNode,`delete`)),r.push(Y(e.newNode,`insert`)));break}}return r}function Ct(e,t){if(W(e)!==W(t))return Y(t,`insert`);if(ut(e,t))return t;let n=K(e),r=K(t);return!n||!r?Y(t,`insert`):J(t,St(n,r))}function wt(e,t){let n=_t(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=bt(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 Tt(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(Tt),t}function Et(e,t){let{children:n,text:r,...i}=e,{children:a,text:o,...s}=t;return JSON.stringify(i)!==JSON.stringify(s)||!!(n&&a&&At(n,a).some(e=>e.kind===`modify`&&Et(e.old[0],e.current[0])))}function Dt(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`?r.t(`history.dynamic`,{url:t.url,height:t.initialHeight??320,props:JSON.stringify(t.props??{})}):r.t(`history.pendingIntent`,{intent:t.intent??``}),format:0,detail:0,mode:`normal`,style:``}]}:t.children?{...t,children:t.children.map(Dt)}:t}function Ot(e){return kt(e.map(Dt))}function kt(e){return{root:{type:`root`,version:1,direction:null,format:``,indent:0,children:e}}}function At(e,t){let n=wt(kt(e),kt(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 jt(e,t){return At(e.root.children.map(Tt),t.root.children.map(Tt)).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&&!Et(n,r)?{kind:`modify`,value:Ot([Ct(n,r)]),...t}:{kind:`modify`,before:Ot(e.old),value:Ot(e.current),...t}}let n=e.kind===`delete`?e.old:e.current;return{kind:e.kind,value:Ot(e.kind===`equal`?n:n.map(t=>Y(t,e.kind))),...t}})}function Mt(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 Nt({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]}`,Pt={h1:Z(`headingH1`),h2:Z(`headingH2`),h3:Z(`headingH3`),h4:Z(`headingH4`),h5:Z(`headingH5`),h6:Z(`headingH6`)};function Ft(e){return e.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g,``).replaceAll(/[\s_]+/g,`-`).replaceAll(/^-+|-+$/g,``)}function It(e){return e.type===`comment`?``:e.text?e.text:e.children?e.children.map(It).join(``):``}var Lt=/^["'«‘“‹「『"']/,Rt=/["'»’”›」』"']$/;function zt(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=Ft(i||It(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:Pt[a],id:s||void 0,children:[s&&(0,X.jsx)(`a`,{className:Z(`headingAnchor`),href:`#${s}`,tabIndex:0,children:(0,X.jsx)(l,{"aria-hidden":!0,size:14,strokeWidth:2})}),n]},t)}case`rich-quote`:case`quote`:{let r=(i||It(e)).trim(),a=Lt.test(r),o=Rt.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)(w,{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)(w,{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:`${A.details} ${N.details}`,open:e.open||void 0,children:[(0,X.jsxs)(`summary`,{className:`${A.summary} ${N.summary}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`${A.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:`${A.summaryText} ${N.summaryText}`,children:r})]}),(0,X.jsx)(`div`,{className:`${A.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:k(e.text)},children:e.text},t);case`comment`:return(0,X.jsx)(Nt,{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 Bt=e=>`${H[e]} ${Te[e]}`,Vt=[[1,`textBold`],[2,`textItalic`],[4,`textStrikethrough`],[8,`textUnderline`],[16,`textCode`],[32,`textSubscript`],[64,`textSuperscript`],[128,`textHighlight`]];function Ht(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 Ut(e,t){let n=e.text,r=e.format||0;for(let[e,i]of Vt)r&e&&(n=(0,X.jsx)(`span`,{className:Bt(i),children:n},`${t}-${e}`));return e.style&&(n=(0,X.jsx)(`span`,{style:Ht(e.style),children:n},t)),n}function Wt(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 Gt=e=>`${H.alert} ${Te.alert} rich-alert-${e}`;function Kt(e,t,n){switch(e.type){case`alert-quote`:return(0,U.createElement)(`div`,{key:t,className:Gt(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 qt(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 Jt(e,t,n,r){return t?(r.blockAnchor??qt)(e,t,n):e}function Yt(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 Jt(n?n(t,s,[r],()=>Kt(t,s,r)):Kt(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,()=>Ut(l,s)):Ut(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)=>Yt(e,t,n,r,`${s}-${i}`,void 0,o)));let f=e.getTextContent?e.getTextContent():void 0,p=c?.[l.type];return Jt(p?p(l,s,d,()=>zt(l,s,d,r,f)):zt(l,s,d,r,f),a,s,o)}function Xt(e,t,n){let r=Mt({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=Wt(a),c=a.root?.children,l=null;return o.read(()=>{let e=O(),t=new Map,a=e.getChildren().map((e,a)=>Yt(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=Mt({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=O(),t=new Map,a=e.getChildren().map((e,a)=>Yt(e,r,i,t,`nested-${a}`,c?.[a]?.$?.blockId,n));s=(0,X.jsx)(X.Fragment,{children:a})}),s}}}function Zt({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)(()=>Xt(e,c?[...D,...c]:D,{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)(C,{config:s,mode:`renderer`,variant:t,children:(0,X.jsx)(oe,{definitions:m.definitions,displayNumberMap:m.displayNumberMap,children:(0,X.jsx)(ee,{value:f??h,children:(0,X.jsx)(a,{..._,style:i,children:p})})})})})})}var Qt=[T],$t=864e5,en=e=>String(e).padStart(2,`0`),tn=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function nn(e,t=Date.now()){if(!(e>0))return r.t(`time.notRecorded`);let n=new Date(e*1e3),i=new Date(t),a=Math.round((tn(i)-tn(n))/$t);if(a===0)return r.t(`time.today`);if(a===1)return r.t(`time.yesterday`);let o=n.getFullYear()===i.getFullYear();return new Intl.DateTimeFormat(s[r.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=`${en(n.getHours())}:${en(n.getMinutes())}`;return t?`${r}:${en(n.getSeconds())}`:r}function $(e){return e>0?`${nn(e)} ${Q(e)}`:r.t(`time.notRecorded`)}var rn={human:`history.sourceHuman`,agent:`history.sourceAgent`,session:`history.sourceSession`,unknown:`history.sourceUnknown`};function an(e){let{session:t,selected:n}=e;return t&&n?t.history.groups.find(e=>e.entries.includes(n)):void 0}function on(e){return e.session?.history.entries.at(-1)?.change.timestamp??0}function sn({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":f(`history.previousChange`),disabled:n===0||r,onClick:()=>e.navigate(-1),children:(0,X.jsx)(Fe,{size:14,"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":f(`history.nextChange`),disabled:n>=t-1||r,onClick:()=>e.navigate(1),children:(0,X.jsx)(S,{size:14,"aria-hidden":`true`})})]})}function cn({model:e}){return(0,X.jsx)(`button`,{type:`button`,className:`history-filter`,"aria-pressed":e.onlyChanges,onClick:e.toggleOnly,children:f(`history.onlyChanges`)})}function ln({model:e}){return e.pending?(0,X.jsxs)(`div`,{className:`history-update`,role:`status`,children:[(0,X.jsx)(`span`,{children:e.streaming?f(`history.waitingEdits`):f(`history.newContent`,{time:Q(on(e))})}),(0,X.jsxs)(`button`,{type:`button`,disabled:e.streaming||e.loading,onClick:e.refresh,children:[(0,X.jsx)($e,{size:12,"aria-hidden":`true`}),f(`history.refresh`)]})]}):null}function un({model:e}){let{selected:t,blocks:n,count:r}=e,i=an(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":f(`history.range`),children:[(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:f(`history.from`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:t?$(t.change.timestamp):f(`history.pickPoint`)}),i?(0,X.jsx)(`span`,{children:f(rn[i.source])}):null]}),(0,X.jsx)(`dt`,{children:f(`history.to`)}),(0,X.jsxs)(`dd`,{children:[(0,X.jsx)(`strong`,{children:f(`history.latestVersion`)}),(0,X.jsx)(`span`,{children:$(on(e))})]})]}),(0,X.jsxs)(`div`,{className:`history-controls`,children:[(0,X.jsx)(`span`,{children:f(`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)(cn,{model:e}),(0,X.jsx)(sn,{model:e})]})]})}function dn({model:e}){let[t,n]=(0,U.useState)(50),[r,i]=(0,U.useState)(()=>new Set),{session:a,selected:o,blocks:s}=e;if(!a)return null;let{groups:c,entries:l,shallow:d}=a.history,p=c.findIndex(e=>o!==null&&e.entries.includes(o)),m=new Map;for(let e of s)e.group&&m.set(e.group,(m.get(e.group)??0)+1);let h=c.slice(0,t),g=e=>nn(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":f(`history.timeline`),children:h.map((t,n)=>{let i=t.entries.at(-1),a=g(t),s=n===0||a!==g(h[n-1]),c=n===p?`selected`:n===0?`latest`:n<p?`range`:`outside`,l=r.has(t.id),d=n<p?m.get(t):void 0;return(0,X.jsxs)(`li`,{className:`history-node`,"data-state":c,"data-upper":n<=p?`in`:`out`,"data-lower":n<p?`in`:`out`,"data-day":s?``:void 0,children:[s?(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":c===`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:f(rn[t.source])}),c===`latest`?(0,X.jsx)(`span`,{className:`history-tag`,children:f(`history.latest`)}):null,c===`selected`?(0,X.jsx)(`span`,{className:`history-tag history-start`,children:f(`history.start`)}):null]}),(0,X.jsxs)(`span`,{className:`history-meta`,children:[f(`history.commits`,{count:t.entries.length}),d?(0,X.jsx)(`span`,{className:`history-changed`,children:f(`history.changedSuffix`,{count:d})}):null]})]}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon history-expand`,"aria-label":f(l?`history.collapseCommits`:`history.expandCommits`),"aria-expanded":l,onClick:()=>_(t.id),children:(0,X.jsx)(u,{size:14,"aria-hidden":`true`})})]}),l?(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===o?`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||f(`history.sourceUnknown`)})]},t.id))}):null]},t.id)})}),t<c.length?(0,X.jsx)(`button`,{type:`button`,className:`history-more`,onClick:()=>n(e=>e+50),children:f(`history.loadEarlier`)}):(0,X.jsxs)(`p`,{className:`history-end`,children:[f(d?`history.shallow`:`history.earliest`),` · `,f(`history.summary`,{edits:f(`history.edits`,{count:c.length}),commits:f(`history.commits`,{count:l.length})}),(0,X.jsx)(`br`,{}),f(`history.clockNote`)]})]})}function fn({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:f(`history.agentEditing`)}),(0,X.jsx)(`span`,{children:f(`history.agentEditingBody`)})]}):(0,X.jsx)(`strong`,{children:f(`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 pn({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`}),f(`history.failed`)]}),(0,X.jsx)(`code`,{children:e.error}),(0,X.jsx)(`span`,{children:f(`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:f(`common.retry`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-quiet`,onClick:e.close,children:f(`history.backToComments`)})]})]})}function mn({model:e}){return(0,X.jsxs)(`aside`,{className:`history-panel`,"aria-label":f(`history.title`),children:[(0,X.jsxs)(`header`,{className:`history-panel-head`,children:[(0,X.jsx)(`h2`,{children:f(`history.title`)}),(0,X.jsx)(`button`,{type:`button`,className:`history-icon`,"aria-label":f(`history.close`),onClick:e.close,children:(0,X.jsx)(d,{size:14,"aria-hidden":`true`})})]}),(0,X.jsx)(ln,{model:e}),e.error?(0,X.jsx)(pn,{model:e}):e.session?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(un,{model:e}),(0,X.jsx)(dn,{model:e})]}):(0,X.jsx)(fn,{streaming:e.streaming})]})}function hn({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:f(`history.chooseStart`)}),(0,X.jsx)(`small`,{children:f(`history.compareWithLatest`,{time:$(on(e))})})]}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:f(`common.done`)})]});return(0,X.jsx)(`div`,{ref:n,className:`history-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":f(`history.chooseStart`),children:(0,X.jsx)(Le,{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)(dn,{model:e})})})})}var gn=[je,E,...Qt],_n={[j]:I,[se]:Me,[ce]:ue,[ie]:V},vn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function yn({model:e,theme:t,title:n,narrow:r,bodyRef:i,onPick:a}){let{session:o,selected:s,blocks:c,count:l,changeIndex:u,loading:d,error:p,streaming:m,onlyChanges:h}=e,g=e=>(0,X.jsx)(Zt,{value:e,variant:`article`,theme:t,extraNodes:gn,rendererConfig:_n}),_=-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:f(`history.compareFrom`)}),(0,X.jsxs)(`strong`,{children:[f(`history.toLatest`,{from:s?$(s.change.timestamp):f(`history.pickPoint`)}),(0,X.jsx)(S,{size:12,"aria-hidden":`true`})]})]}),(0,X.jsx)(cn,{model:e}),(0,X.jsx)(sn,{model:e})]}):null,r?(0,X.jsx)(ln,{model:e}):null,p?r?(0,X.jsxs)(`div`,{role:`alert`,className:`history-message`,children:[f(`history.readFailed`,{error:p}),(0,X.jsx)(`button`,{type:`button`,disabled:m,onClick:e.refresh,children:f(`common.retry`)})]}):(0,X.jsx)(`p`,{className:`history-message`,children:f(`history.unreadable`)}):d||!o?(0,X.jsx)(`div`,{role:`status`,className:`history-message`,children:f(m?`history.waitingEdits`:`history.computing`)}):(0,X.jsxs)(`div`,{ref:i,"aria-label":f(`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}),l?null:(0,X.jsx)(`p`,{role:`status`,className:`history-note`,children:f(`history.noDiff`)}),c.map((t,n)=>{if(t.kind===`equal`)return h?(0,X.jsx)(`button`,{type:`button`,className:`history-fold`,onClick:e.showAll,children:(0,X.jsx)(`span`,{children:f(`history.unchanged`,{count:t.value.root.children.length})})},n):(0,X.jsx)(`section`,{className:`history-hunk history-equal`,children:g(t.value)},n);_++;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":_===u?``: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:f(vn[t.kind])}),t.author?(0,X.jsxs)(`span`,{children:[$(t.author.change.timestamp),t.group?` · ${f(rn[t.group.source])}`:``]}):null]}),t.before?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`history-before`,children:g(t.before)}),(0,X.jsx)(`div`,{className:`history-after`,children:g(t.value)})]}):(0,X.jsx)(`div`,{className:r,children:g(t.value)})]},n)}),(0,X.jsx)(`p`,{className:`history-end`,children:f(`history.endOfDiff`)})]})]})}var bn=e=>JSON.stringify(e.frontiers()),xn=(e,t)=>t===void 0?void 0:e[t];function Sn({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),f=(0,U.useRef)(null),p=(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=m(`(max-width: 1100px)`),k=(0,U.useRef)(null),A=(0,U.useCallback)(async()=>{if(!e)return;let n=++p.current;g(!0),v(null);let r=e.fork();try{let i=await rt(r),a=it(r,r.frontiers(),t);if(p.current!==n){r.free();return}let o=f.current;f.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(bn(e)!==bn(r)),o?.free()}catch(e){r.free(),p.current===n&&v(e.message)}finally{p.current===n&&g(!1)}},[e,t]);if((0,U.useEffect)(()=>{if(a)return()=>{p.current++,f.current?.free(),f.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&&!f.current&&A()},[a,A,n]),(0,U.useEffect)(()=>{if(a&&e)return e.subscribe(()=>b(f.current!==null&&bn(e)!==bn(f.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=it(s.doc,l.frontiers,t),{entries:r,groups:i}=s.history,a=ot(s.doc,r.slice(r.indexOf(l)+1),[n,s.latest]),o=new Map(i.flatMap(e=>e.entries.map(t=>[t,e]))),c=jt(n.value,s.latest.value).map(e=>{if(e.kind===`equal`)return e;let t=[xn(s.latest.ids,e.newIndex),xn(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)(yn,{model:M,theme:r,title:i,narrow:O,bodyRef:k,onPick:()=>D(!0)}),O&&E?(0,X.jsx)(hn,{model:M,onDismiss:()=>D(!1)}):null]}),panel:O?null:(0,X.jsx)(mn,{model:M})}}function Cn({left:e,top:t,quote:n,initial:r,restored:i,leaving:a,onChange:o,onSubmit:s,onCancel:c,ref:l}){return(0,X.jsx)(`div`,{ref:l,...{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:f(`document.draftRestored`)}):null]}),(0,X.jsx)(x,{autoFocus:!0,initial:r,placeholder:f(`document.draftPlaceholder`),onChange:o,onSubmit:s,onCancel:c})]})})}function wn({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)(Ze,{size:14,className:`x2lah0s x17nrqe2`}),f(`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:f(`document.copy`)})]})}var Tn=(e,t)=>`${e}\n${t}`;function En(){let e=new Map;return{save(t,n){n.trim()?e.set(t,n):e.delete(t)},take(t){return e.get(t)??``}}}function Dn(e){let t=(0,U.useMemo)(En,[]),[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(Tn(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(Tn(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 On(e){return{left:e.offsetLeft,right:Math.min(e.offsetLeft+e.offsetWidth,window.innerWidth-16)}}function kn({editor:e,threads:t,actions:n,agent:r,canComment:i,selection:a,clearSelection:o,onCreate:s,onMain:c,history:l,children:u}){let d=Dn(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)(wn,{ref:d.toolbarRef,...ve(a,On(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)(Cn,{ref:d.panelRef,...de(f.target,On(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 An({id:e,title:t,activity:n,agentSection:r,offline:i,openComments:a,cloud:o,compact:s=!1,onDone:c,agent:l=`Agent`,history:u}){let d=nt(n,l,r);return h(e,o?{...t?{title:t}:{},online:o.online,comments:a,activity:d,activityTone:n.kind===`stale`?`warning`:n.kind===`working`?`quiet`:`live`,retrying:i,reason:o.reason,history:u?.available,historyOpen:u?.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})]}),d?(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`}),d]}):null,i?(0,X.jsx)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`,children:f(`document.notSynced`)}):null,u?.open?(0,X.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`,children:[(0,X.jsx)(Ve,{size:11,"aria-hidden":`true`}),f(`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?f(`share.computerOnline`):f(`share.computerOffline`)]}):null,u?(0,X.jsx)(y,{comments:a,open:u.open,available:u.available,onComments:u.close,onHistory:u.toggle}):null,c?(0,X.jsx)(`button`,{type:`button`,onClick:c,className:`x12ulsxz xaope02 xc342km x1kogg8i x19ckca5 xs0jrwl xqfszdh x4z9k3i x1s688f x1ypdohk`,children:f(`common.done`)}):o||s?null:(0,X.jsx)(ze,{artifact:`document/${e}`})]})}function jn(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,Ye.blockIds),heading:e.slice(0,r+1).filter(e=>e.heading).pop()?.text??``}}var Mn=crypto.randomUUID(),Nn=300,Pn={quote:``,blockIds:[],heading:``};function Fn(e){let t=window.getSelection(),n=e.getRootElement();if(!t||t.isCollapsed||!n?.contains(t.anchorNode)||!n.contains(t.focusNode))return Pn;let r=t.toString().trim().slice(0,Ye.quote);return r?e.read(()=>{let e=O().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{...Pn,quote:r};let o=e.map(e=>({id:Se(e,_e)||``,heading:e.getType()===`heading`,text:e.getTextContent().slice(0,Ye.heading)}));return{quote:r,...jn(o,i,a)}}):Pn}function In(e,t,n,r){let i=(0,U.useRef)(Pn);(0,U.useEffect)(()=>{if(!e)return;let n=0,a=()=>{let n=Fn(e);JSON.stringify(n)!==JSON.stringify(i.current)&&(i.current=n,r({type:`selection`,artifact:t,tab:Mn,human:!0,...n}))},o=()=>{clearTimeout(n),n=window.setTimeout(a,Nn)};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:Mn,human:!1,...i.current})},[n,t,r])}var Ln=[`pending`],Rn=`x-ryugi-document-features`,zn=e=>{let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)};function Bn({id:e,channel:t,send:n}){let r=(t,n,r)=>fetch(`/api/document/${e}/${t}`,{method:`POST`,headers:{"Content-Type":r,[Rn]:Ln.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 Vn(e){let t=L(),n=(e.connect??Ie)({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:zn(e),features:Ln})},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 Hn(e){let t=(0,U.useMemo)(L,[]),n=`document/${e}`,{live:r,send:i}=Ke(e=>{e.artifact===n&&t.emit(e)},()=>t.emit({type:`open`}));return{transport:(0,U.useMemo)(()=>Bn({id:e,channel:t,send:i}),[e,t,i]),live:r}}function Un(e,t){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let n=Vn({url:We(e),artifact:`document/${e}`,contentBase:t,onPresence:a,connect:t=>qe(e,t,t=>He({...t,cloudId:e,known:Ge()}))});return r(n),()=>{n.close(),r(null),a(null)}},[e,t]),{transport:n,presence:i}}var Wn={count:0,firstKey:null},Gn=e=>e.read(()=>{let e=O().getChildren().filter(e=>e.getType()===`pending`).map(e=>e.getKey());return{count:e.length,firstKey:e[0]??null}});function Kn(e){let[t,n]=(0,U.useState)(Wn);return(0,U.useEffect)(()=>{if(!e){n(Wn);return}let t=e=>n(t=>t.count===e.count&&t.firstKey===e.firstKey?t:e);return t(Gn(e.getEditorState())),e.registerUpdateListener(({editorState:e})=>t(Gn(e)))},[e]),t}function qn(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 Jn({left:e,top:t,placement:n,canComment:r,canEdit:i,onComment:a,onEdit:o}){let s=(0,U.useRef)(null),c=[r?{label:f(`common.comment`),Icon:Ze,run:a,primary:!0}:null,i?{label:f(`document.editText`),Icon:Ce,run:o,primary:!1}:null].filter(e=>e!==null);return(0,U.useLayoutEffect)(()=>{b(s.current,[{opacity:0,transform:`scale(0.96)`},{opacity:1,transform:`none`}],{duration:160,easing:_})},[]),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 Yn={state:{kmuXW:`x2lah0s`,kGuDYH:`xfifm61`,$$css:!0},waitingAgent:{kMwMTN:`x7zghnd`,$$css:!0},answered:{kMwMTN:`xh0clw4`,$$css:!0},resolved:{kMwMTN:`xddlp02`,$$css:!0}},Xn=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Zn({thread:e,agent:t=`Agent`,actions:n,active:r=!1,offline:o=!1}){let s=p(e),c=e.status===`resolved`,l=c?{label:f(`common.resolved`),tone:Yn.resolved}:s===`agent`?{label:f(`document.waitingAgentReply`,{agent:t}),tone:Yn.waitingAgent}:s===`human`?{label:f(`document.agentReplied`,{agent:t}),tone:Yn.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`}}[!!r|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||f(`document.wholeBlock`)}),l?(0,X.jsx)(`span`,{...v(Yn.state,l.tone),children:l.label}):null]}),c&&!r?null:e.messages.map(e=>{let{label:t,initial:n}=i(e);return(0,X.jsxs)(`div`,{className:`x14vqqas`,children:[(0,X.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x4z9k3i x1s688f`,children:[(0,X.jsx)(a,{human:e.author===`human`,initial:n,name:e.name,src:e.avatar}),t,(0,X.jsx)(`span`,{className:`xddlp02 xo1l8bm xfifm61`,children:Xn(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?f(`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)(x,{placeholder:f(`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:f(c?`common.reopen`:`common.resolve`)})]}):null]})}var Qn=.5,$n=e=>e===78?Qn:e;function er({threads:e,agent:t=`Agent`,actions:n,offline:r,draft:i,onCreate:a,onCancelDraft:o,activeId:s,snap:c,onSnap:l}){let u=(0,U.useRef)(null),d=e.filter(e=>!e.messages.every(e=>e.deleted)),m=d.filter(e=>p(e)===`agent`).length,h=r?f(`document.offlineNoComments`):m>0?f(`document.waitingCount`,{count:m,agent:t}):null;return(0,U.useEffect)(()=>{let e=s?u.current?.querySelector(`[data-thread="${CSS.escape(s)}"]`):null,t=e?.closest(`[data-sheet-body]`);e&&t&&(t.scrollTo({top:t.scrollTop+e.getBoundingClientRect().top-t.getBoundingClientRect().top-8,behavior:`smooth`}),b(e,[{backgroundColor:`rgba(232, 194, 74, 0.24)`},{backgroundColor:`transparent`}],{duration:600,delay:250,easing:_}))},[s]),(0,X.jsx)(Le,{snaps:[78,Qn,1],snap:c,onSnap:l,onScrim:()=>l(Qn),header:(0,X.jsxs)(`span`,{className:`x78zum5 x1pha0wt x17d4w8g xu0aao5 x17qtykl xwib8y2 xqfszdh x1jvydc1 x1s688f`,children:[f(`document.sheetComments`,{count:d.length}),h?(0,X.jsxs)(`span`,{className:`xddlp02 xfifm61 xo1l8bm`,children:[`· `,h]}):null]}),children:(0,X.jsxs)(`div`,{ref:u,className:`x17qtykl xwxc41k`,children:[i&&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:i.quote}),(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`x1717udv xc342km xjbqb8w xddlp02 x4z9k3i x1ypdohk`,children:f(`common.cancel`)})]}),(0,X.jsx)(`div`,{className:`x1xmf6yo x1qyh8g1 xso031l x1q0q8m5 x1iz93xd`,children:(0,X.jsx)(x,{autoFocus:!0,placeholder:f(`document.agentPlaceholder`),onSubmit:e=>a(i,e).then(e=>(e&&o(),e))})})]}):null,d.length===0&&!i?(0,X.jsx)(`div`,{className:`xr9q8rw xddlp02 xqfszdh x4z9k3i x2b8uid`,children:f(`document.noComments`)}):null,d.map(e=>(0,X.jsx)(Zn,{thread:e,agent:t,actions:n,active:e.id===s,offline:r},e.id))]})})}var tr=52;function nr({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($n)},children:[f?.content,(0,X.jsx)(`div`,{hidden:!!f,children:p})]}),s&&!b&&!f?(0,X.jsx)(Jn,{...Ee(s,{left:8,right:(m?.clientWidth??0)-8},170,44,{top:m?.getBoundingClientRect().top??0,height:window.innerHeight,reserved:Ue(v,window.innerHeight-tr)}),canComment:i,canEdit:a,onComment:()=>{x(s),y(Qn),C()},onEdit:()=>{u(s),c()}}):null,(0,X.jsx)(`div`,{hidden:!!f,className:`xixxii4 x1ozmhy9 xu96u03 x3m8u43 x1ey2m1c x1355qak x47corl`,children:(0,X.jsx)(er,{threads:t,agent:r,actions:n,offline:o,draft:b,onCreate:l,onCancelDraft:()=>x(null),activeId:g,snap:v,onSnap:y})})]})}var rr=200;function ir(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,rr)};return document.addEventListener(`selectionchange`,a),()=>{clearTimeout(n),document.removeEventListener(`selectionchange`,a)}},[e,t]),[n,()=>r(null)]}var ar=[...D.filter(e=>!fe.some(t=>t.getType()===(`getType`in e?e.getType():e.replace.getType()))),...fe];function or(){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 sr(e){(0,U.useEffect)(()=>{if(!e)return;let t=document.createElement(`base`);return t.href=e,document.head.prepend(t),()=>t.remove()},[e])}function cr({id:e}){let{transport:t,live:n}=Hn(e);return(0,X.jsx)(lr,{id:e,transport:t,live:n})}function lr({id:e,transport:t,live:n,cloud:r,fallback:i}){let[a,o]=(0,U.useState)(null),[s,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(c),[p,h]=(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=or(),{artifact:re,channel:P}=t,ie=!r||r.online,F=!r||r.canEdit,I=m(g),[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),d(n.comments??c());let i=oe?{left:window.scrollX,top:window.scrollY,behavior:`instant`}:null;l(r),i&&requestAnimationFrame(()=>{e||window.scrollTo(i)})}catch(t){e||h(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`&&d(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&&d(e.comments)},[C]);sr(a?.contentBase),In(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]),Re(`document`);let B=Kn(j),le=qn(B.count>0&&!_),ue=et({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=u.threads.filter(e=>e.status===`open`).length,[me,ge]=ir(j,N),_e=(0,U.useCallback)(()=>O(!1),[]),ve=Sn({doc:s,nodes:ar,streaming:_,theme:ne?`dark`:`light`,title:a?.title||e,open:A,onClose:_e}),V=(0,U.useCallback)(async e=>{try{return d(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(p)return(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:p});if(!s)return i??(0,X.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:f(`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)(An,{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)(nr,{editor:j,threads:u.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)(kn,{editor:j,threads:u.threads,actions:ye,agent:a?.agent,canComment:ie,selection:me,clearSelection:ge,onCreate:H,onMain:te,history:ve,children:Se}),(0,X.jsx)(Je,{warnings:a?.warnings??[]})]})}export{lr as DocumentView,cr as default,Un as t};
|