@ours.network/messenger-server 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/chunks/{chunk-TVCRVKXD.js → chunk-WILWDPGY.js} +1 -1
  2. package/dist/chunks/{server-AT53QPRP.js → server-IGCRUNBZ.js} +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/web/assets/{abnfDiagram-N423BO3Z-D2Li4Psi.js → abnfDiagram-N423BO3Z-Bllzhn6m.js} +2 -2
  5. package/dist/web/assets/{abnfDiagram-N423BO3Z-D2Li4Psi.js.map → abnfDiagram-N423BO3Z-Bllzhn6m.js.map} +1 -1
  6. package/dist/web/assets/{arc-j4YjVzjX.js → arc-IWSpXzaC.js} +2 -2
  7. package/dist/web/assets/{arc-j4YjVzjX.js.map → arc-IWSpXzaC.js.map} +1 -1
  8. package/dist/web/assets/{architectureDiagram-T3A2C74G-CQo1YEQ-.js → architectureDiagram-T3A2C74G-C-N13EcA.js} +2 -2
  9. package/dist/web/assets/{architectureDiagram-T3A2C74G-CQo1YEQ-.js.map → architectureDiagram-T3A2C74G-C-N13EcA.js.map} +1 -1
  10. package/dist/web/assets/{blockDiagram-VBNYF7ZC-tWgK6cLZ.js → blockDiagram-VBNYF7ZC-Dcl-dLn0.js} +2 -2
  11. package/dist/web/assets/{blockDiagram-VBNYF7ZC-tWgK6cLZ.js.map → blockDiagram-VBNYF7ZC-Dcl-dLn0.js.map} +1 -1
  12. package/dist/web/assets/{browser-Dyn5HxZw.js → browser-vohWR48c.js} +2 -2
  13. package/dist/web/assets/{browser-Dyn5HxZw.js.map → browser-vohWR48c.js.map} +1 -1
  14. package/dist/web/assets/{c4Diagram-5PPSVZJV-VIPdb6Z_.js → c4Diagram-5PPSVZJV-CgxKZUxo.js} +2 -2
  15. package/dist/web/assets/{c4Diagram-5PPSVZJV-VIPdb6Z_.js.map → c4Diagram-5PPSVZJV-CgxKZUxo.js.map} +1 -1
  16. package/dist/web/assets/channel-COoSgXhF.js +2 -0
  17. package/dist/web/assets/{channel-BsAIjvuX.js.map → channel-COoSgXhF.js.map} +1 -1
  18. package/dist/web/assets/{chunk-2GRJ4B5K-CUstnzSJ.js → chunk-2GRJ4B5K-CWmwr5-8.js} +2 -2
  19. package/dist/web/assets/{chunk-2GRJ4B5K-CUstnzSJ.js.map → chunk-2GRJ4B5K-CWmwr5-8.js.map} +1 -1
  20. package/dist/web/assets/{chunk-2Q5K7J3B-A-U7TPbH.js → chunk-2Q5K7J3B-CG2Rx4eF.js} +2 -2
  21. package/dist/web/assets/{chunk-2Q5K7J3B-A-U7TPbH.js.map → chunk-2Q5K7J3B-CG2Rx4eF.js.map} +1 -1
  22. package/dist/web/assets/{chunk-5RXB4S5H-Dm4jGMdn.js → chunk-5RXB4S5H-D9oHujk2.js} +2 -2
  23. package/dist/web/assets/{chunk-5RXB4S5H-Dm4jGMdn.js.map → chunk-5RXB4S5H-D9oHujk2.js.map} +1 -1
  24. package/dist/web/assets/{chunk-5VM5RSS4-CzSdEPg4.js → chunk-5VM5RSS4-DTMS1Ir3.js} +2 -2
  25. package/dist/web/assets/{chunk-5VM5RSS4-CzSdEPg4.js.map → chunk-5VM5RSS4-DTMS1Ir3.js.map} +1 -1
  26. package/dist/web/assets/{chunk-6Q2QTUOP-BE9W3d4Z.js → chunk-6Q2QTUOP-B51Dyq4o.js} +2 -2
  27. package/dist/web/assets/{chunk-6Q2QTUOP-BE9W3d4Z.js.map → chunk-6Q2QTUOP-B51Dyq4o.js.map} +1 -1
  28. package/dist/web/assets/{chunk-GF5L2VYU-C85U_z7m.js → chunk-GF5L2VYU-BFbl-vVS.js} +2 -2
  29. package/dist/web/assets/{chunk-GF5L2VYU-C85U_z7m.js.map → chunk-GF5L2VYU-BFbl-vVS.js.map} +1 -1
  30. package/dist/web/assets/{chunk-JWPE2WC7-RhdlAXn7.js → chunk-JWPE2WC7-Dna5Ng6F.js} +2 -2
  31. package/dist/web/assets/{chunk-JWPE2WC7-RhdlAXn7.js.map → chunk-JWPE2WC7-Dna5Ng6F.js.map} +1 -1
  32. package/dist/web/assets/{chunk-KBJHAD2P-nPsH4GEx.js → chunk-KBJHAD2P-D3W3AEPK.js} +2 -2
  33. package/dist/web/assets/{chunk-KBJHAD2P-nPsH4GEx.js.map → chunk-KBJHAD2P-D3W3AEPK.js.map} +1 -1
  34. package/dist/web/assets/{chunk-RYQCIY6F-DmFo0bza.js → chunk-RYQCIY6F-COpZj9EK.js} +2 -2
  35. package/dist/web/assets/{chunk-RYQCIY6F-DmFo0bza.js.map → chunk-RYQCIY6F-COpZj9EK.js.map} +1 -1
  36. package/dist/web/assets/{chunk-XXDRQBXY-B_ENdEkH.js → chunk-XXDRQBXY-ESXLoTQi.js} +2 -2
  37. package/dist/web/assets/{chunk-XXDRQBXY-B_ENdEkH.js.map → chunk-XXDRQBXY-ESXLoTQi.js.map} +1 -1
  38. package/dist/web/assets/classDiagram-JCYQIIEL-By3hyti-.js +2 -0
  39. package/dist/web/assets/{classDiagram-JCYQIIEL-CF23_zRy.js.map → classDiagram-JCYQIIEL-By3hyti-.js.map} +1 -1
  40. package/dist/web/assets/classDiagram-v2-OCEON4UE-By3hyti-.js +2 -0
  41. package/dist/web/assets/{classDiagram-v2-OCEON4UE-CF23_zRy.js.map → classDiagram-v2-OCEON4UE-By3hyti-.js.map} +1 -1
  42. package/dist/web/assets/{cose-bilkent-JH36ORCC-CgKmjnbJ.js → cose-bilkent-JH36ORCC-CHsMZpIy.js} +2 -2
  43. package/dist/web/assets/{cose-bilkent-JH36ORCC-CgKmjnbJ.js.map → cose-bilkent-JH36ORCC-CHsMZpIy.js.map} +1 -1
  44. package/dist/web/assets/{cynefin-VYW2F7L2-DrwpJrA-.js → cynefin-VYW2F7L2-BveuC6FQ.js} +2 -2
  45. package/dist/web/assets/{cynefin-VYW2F7L2-DrwpJrA-.js.map → cynefin-VYW2F7L2-BveuC6FQ.js.map} +1 -1
  46. package/dist/web/assets/{cynefinDiagram-MW4NZA55-BmDZAoQW.js → cynefinDiagram-MW4NZA55-BEvk24eG.js} +2 -2
  47. package/dist/web/assets/{cynefinDiagram-MW4NZA55-BmDZAoQW.js.map → cynefinDiagram-MW4NZA55-BEvk24eG.js.map} +1 -1
  48. package/dist/web/assets/{dagre-VZM6K2ZE-BBzpKDYo.js → dagre-VZM6K2ZE-BNuEVxqv.js} +2 -2
  49. package/dist/web/assets/{dagre-VZM6K2ZE-BBzpKDYo.js.map → dagre-VZM6K2ZE-BNuEVxqv.js.map} +1 -1
  50. package/dist/web/assets/{diagram-7IWD3JNH-DlnT9CCc.js → diagram-7IWD3JNH-CCpicab3.js} +2 -2
  51. package/dist/web/assets/{diagram-7IWD3JNH-DlnT9CCc.js.map → diagram-7IWD3JNH-CCpicab3.js.map} +1 -1
  52. package/dist/web/assets/{diagram-B4RE2ZJO-BsF_ED_J.js → diagram-B4RE2ZJO-EdYQvXTC.js} +2 -2
  53. package/dist/web/assets/{diagram-B4RE2ZJO-BsF_ED_J.js.map → diagram-B4RE2ZJO-EdYQvXTC.js.map} +1 -1
  54. package/dist/web/assets/{diagram-LBJQPF4R-BQWcBLo2.js → diagram-LBJQPF4R-DdrOqSdO.js} +2 -2
  55. package/dist/web/assets/{diagram-LBJQPF4R-BQWcBLo2.js.map → diagram-LBJQPF4R-DdrOqSdO.js.map} +1 -1
  56. package/dist/web/assets/{diagram-Q27KOJAE-DGQOyvNV.js → diagram-Q27KOJAE-DgSOsvKE.js} +2 -2
  57. package/dist/web/assets/{diagram-Q27KOJAE-DGQOyvNV.js.map → diagram-Q27KOJAE-DgSOsvKE.js.map} +1 -1
  58. package/dist/web/assets/{diagram-UB23O5K3-CnUsSpwC.js → diagram-UB23O5K3-BNjqc8uQ.js} +2 -2
  59. package/dist/web/assets/{diagram-UB23O5K3-CnUsSpwC.js.map → diagram-UB23O5K3-BNjqc8uQ.js.map} +1 -1
  60. package/dist/web/assets/{ebnfDiagram-BXEA7PRR-DyTIxzXx.js → ebnfDiagram-BXEA7PRR-B3DyEi2y.js} +2 -2
  61. package/dist/web/assets/{ebnfDiagram-BXEA7PRR-DyTIxzXx.js.map → ebnfDiagram-BXEA7PRR-B3DyEi2y.js.map} +1 -1
  62. package/dist/web/assets/{erDiagram-JOGREHBK-CSucIlZ9.js → erDiagram-JOGREHBK-BQVjbW1Q.js} +2 -2
  63. package/dist/web/assets/{erDiagram-JOGREHBK-CSucIlZ9.js.map → erDiagram-JOGREHBK-BQVjbW1Q.js.map} +1 -1
  64. package/dist/web/assets/{flowDiagram-UKHOOZJN-IFNqagnU.js → flowDiagram-UKHOOZJN-C8CsMQ8D.js} +2 -2
  65. package/dist/web/assets/{flowDiagram-UKHOOZJN-IFNqagnU.js.map → flowDiagram-UKHOOZJN-C8CsMQ8D.js.map} +1 -1
  66. package/dist/web/assets/{ganttDiagram-PKOTCBZU-Xd_un-JK.js → ganttDiagram-PKOTCBZU-cotKb0jY.js} +2 -2
  67. package/dist/web/assets/{ganttDiagram-PKOTCBZU-Xd_un-JK.js.map → ganttDiagram-PKOTCBZU-cotKb0jY.js.map} +1 -1
  68. package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-BNhcGtRV.js → gitGraphDiagram-DS77QQ5N-C734mugo.js} +2 -2
  69. package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-BNhcGtRV.js.map → gitGraphDiagram-DS77QQ5N-C734mugo.js.map} +1 -1
  70. package/dist/web/assets/{index-cF9iuZ83.js → index-Ds2T7P1J.js} +3 -3
  71. package/dist/web/assets/{index-cF9iuZ83.js.map → index-Ds2T7P1J.js.map} +1 -1
  72. package/dist/web/assets/{infoDiagram-6WML65LV-CPxTivsK.js → infoDiagram-6WML65LV-D-1AvDOC.js} +2 -2
  73. package/dist/web/assets/{infoDiagram-6WML65LV-CPxTivsK.js.map → infoDiagram-6WML65LV-D-1AvDOC.js.map} +1 -1
  74. package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-Dk9ZSY9O.js → ishikawaDiagram-WSZJBQD7-Bzf04wUo.js} +2 -2
  75. package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-Dk9ZSY9O.js.map → ishikawaDiagram-WSZJBQD7-Bzf04wUo.js.map} +1 -1
  76. package/dist/web/assets/{journeyDiagram-NVQOT4AX-7OWZY_Bq.js → journeyDiagram-NVQOT4AX-ClRApsha.js} +2 -2
  77. package/dist/web/assets/{journeyDiagram-NVQOT4AX-7OWZY_Bq.js.map → journeyDiagram-NVQOT4AX-ClRApsha.js.map} +1 -1
  78. package/dist/web/assets/{jsQR-C0lC08lI.js → jsQR-DCYnED3H.js} +2 -2
  79. package/dist/web/assets/{jsQR-C0lC08lI.js.map → jsQR-DCYnED3H.js.map} +1 -1
  80. package/dist/web/assets/{kanban-definition-27J2QSJJ-B3IzrJ9o.js → kanban-definition-27J2QSJJ-B3vpahkj.js} +2 -2
  81. package/dist/web/assets/{kanban-definition-27J2QSJJ-B3IzrJ9o.js.map → kanban-definition-27J2QSJJ-B3vpahkj.js.map} +1 -1
  82. package/dist/web/assets/{linear-BFIcAf7b.js → linear-CHObIfkP.js} +2 -2
  83. package/dist/web/assets/{linear-BFIcAf7b.js.map → linear-CHObIfkP.js.map} +1 -1
  84. package/dist/web/assets/{mermaid.core-B9OcYEtH.js → mermaid.core-bMY6NRgG.js} +5 -5
  85. package/dist/web/assets/{mermaid.core-B9OcYEtH.js.map → mermaid.core-bMY6NRgG.js.map} +1 -1
  86. package/dist/web/assets/{mindmap-definition-FAOFIHXS-DHOtWe3X.js → mindmap-definition-FAOFIHXS-ClBWqYpb.js} +2 -2
  87. package/dist/web/assets/{mindmap-definition-FAOFIHXS-DHOtWe3X.js.map → mindmap-definition-FAOFIHXS-ClBWqYpb.js.map} +1 -1
  88. package/dist/web/assets/{pegDiagram-VL7TDLO6-CIeWZcdg.js → pegDiagram-VL7TDLO6-CUrFILSG.js} +2 -2
  89. package/dist/web/assets/{pegDiagram-VL7TDLO6-CIeWZcdg.js.map → pegDiagram-VL7TDLO6-CUrFILSG.js.map} +1 -1
  90. package/dist/web/assets/{pieDiagram-7S7Q4E2Y-DjPpcoMn.js → pieDiagram-7S7Q4E2Y-B74icddO.js} +2 -2
  91. package/dist/web/assets/{pieDiagram-7S7Q4E2Y-DjPpcoMn.js.map → pieDiagram-7S7Q4E2Y-B74icddO.js.map} +1 -1
  92. package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-R8n4Ymiu.js → quadrantDiagram-CIZ2JOQS-BGSQj6Sl.js} +2 -2
  93. package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-R8n4Ymiu.js.map → quadrantDiagram-CIZ2JOQS-BGSQj6Sl.js.map} +1 -1
  94. package/dist/web/assets/{railroadDiagram-AXF67PYL-DKM6QQR0.js → railroadDiagram-AXF67PYL-BXt6jk6X.js} +2 -2
  95. package/dist/web/assets/{railroadDiagram-AXF67PYL-DKM6QQR0.js.map → railroadDiagram-AXF67PYL-BXt6jk6X.js.map} +1 -1
  96. package/dist/web/assets/{requirementDiagram-LRYGKXZP--dt3XIS7.js → requirementDiagram-LRYGKXZP-BVFvZq_8.js} +2 -2
  97. package/dist/web/assets/{requirementDiagram-LRYGKXZP--dt3XIS7.js.map → requirementDiagram-LRYGKXZP-BVFvZq_8.js.map} +1 -1
  98. package/dist/web/assets/{sankeyDiagram-W5VNT64P-CWNlayyh.js → sankeyDiagram-W5VNT64P-B0PMoe14.js} +2 -2
  99. package/dist/web/assets/{sankeyDiagram-W5VNT64P-CWNlayyh.js.map → sankeyDiagram-W5VNT64P-B0PMoe14.js.map} +1 -1
  100. package/dist/web/assets/{sequenceDiagram-SI44F4Z6-fb7XxMxT.js → sequenceDiagram-SI44F4Z6-Dhc94MMQ.js} +2 -2
  101. package/dist/web/assets/{sequenceDiagram-SI44F4Z6-fb7XxMxT.js.map → sequenceDiagram-SI44F4Z6-Dhc94MMQ.js.map} +1 -1
  102. package/dist/web/assets/{sizeCapture-X5ZJPWSS-ZKWMdmGC.js → sizeCapture-X5ZJPWSS-CYnxwuSf.js} +2 -2
  103. package/dist/web/assets/{sizeCapture-X5ZJPWSS-ZKWMdmGC.js.map → sizeCapture-X5ZJPWSS-CYnxwuSf.js.map} +1 -1
  104. package/dist/web/assets/{stateDiagram-OKZ733FA-BgV_wtOn.js → stateDiagram-OKZ733FA-rB0IH9os.js} +2 -2
  105. package/dist/web/assets/{stateDiagram-OKZ733FA-BgV_wtOn.js.map → stateDiagram-OKZ733FA-rB0IH9os.js.map} +1 -1
  106. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-MUvWiB7d.js +2 -0
  107. package/dist/web/assets/{stateDiagram-v2-UEYNNEHI-B4mXng2Z.js.map → stateDiagram-v2-UEYNNEHI-MUvWiB7d.js.map} +1 -1
  108. package/dist/web/assets/{swimlanes-SLNWSIFB-D4b1o6C9.js → swimlanes-SLNWSIFB-X8id28J1.js} +3 -3
  109. package/dist/web/assets/{swimlanes-SLNWSIFB-D4b1o6C9.js.map → swimlanes-SLNWSIFB-X8id28J1.js.map} +1 -1
  110. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CotU78PY.js +9 -0
  111. package/dist/web/assets/{swimlanesDiagram-ULZ7WXOC-oQc5LSK5.js.map → swimlanesDiagram-ULZ7WXOC-CotU78PY.js.map} +1 -1
  112. package/dist/web/assets/{timeline-definition-Z64GVDOM-BlqKBJ97.js → timeline-definition-Z64GVDOM-BeQYAaES.js} +2 -2
  113. package/dist/web/assets/{timeline-definition-Z64GVDOM-BlqKBJ97.js.map → timeline-definition-Z64GVDOM-BeQYAaES.js.map} +1 -1
  114. package/dist/web/assets/{vennDiagram-T6HMQDX7-BGeGB9Ax.js → vennDiagram-T6HMQDX7-DxOD-8bT.js} +2 -2
  115. package/dist/web/assets/{vennDiagram-T6HMQDX7-BGeGB9Ax.js.map → vennDiagram-T6HMQDX7-DxOD-8bT.js.map} +1 -1
  116. package/dist/web/assets/{wardleyDiagram-T6FBY63Y-CNcMa10r.js → wardleyDiagram-T6FBY63Y-Cvinhg0d.js} +2 -2
  117. package/dist/web/assets/{wardleyDiagram-T6FBY63Y-CNcMa10r.js.map → wardleyDiagram-T6FBY63Y-Cvinhg0d.js.map} +1 -1
  118. package/dist/web/assets/{xychartDiagram-ELKLHX3M-B1f0fpph.js → xychartDiagram-ELKLHX3M-DPeexFVC.js} +2 -2
  119. package/dist/web/assets/{xychartDiagram-ELKLHX3M-B1f0fpph.js.map → xychartDiagram-ELKLHX3M-DPeexFVC.js.map} +1 -1
  120. package/dist/web/index.html +1 -1
  121. package/dist/web/sw.js +1 -1
  122. package/dist/web/version.json +1 -1
  123. package/package.json +1 -1
  124. package/dist/web/assets/channel-BsAIjvuX.js +0 -2
  125. package/dist/web/assets/classDiagram-JCYQIIEL-CF23_zRy.js +0 -2
  126. package/dist/web/assets/classDiagram-v2-OCEON4UE-CF23_zRy.js +0 -2
  127. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-B4mXng2Z.js +0 -2
  128. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-oQc5LSK5.js +0 -9
@@ -311,7 +311,7 @@ ${l.join(`
311
311
  `});++i<e.length;)i&&n.push({type:"text",value:`
312
312
  `}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:`
313
313
  `}),n}function ux(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cx(e,t){const n=zO(e,t),i=n.one(e,void 0),s=OO(n),l=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return s&&l.children.push({type:"text",value:`
314
- `},s),l}function WO(e,t){return e&&"run"in e?async function(n,i){const s=cx(n,{file:i,...t});await e.run(s,i)}:function(n,i){return cx(n,{file:i,...e||t})}}function fx(e){if(e)throw e}var kf,dx;function HO(){if(dx)return kf;dx=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var y;for(y in h);return typeof y>"u"||e.call(h,y)},a=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(i)return i(h,m).value}else return;return h[m]};return kf=function d(){var h,m,p,y,w,S,E=arguments[0],T=1,C=arguments.length,R=!1;for(typeof E=="boolean"&&(R=E,E=arguments[1]||{},T=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});T<C;++T)if(h=arguments[T],h!=null)for(m in h)p=c(E,m),y=c(h,m),E!==y&&(R&&y&&(l(y)||(w=s(y)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&l(p)?p:{},a(E,{name:m,newValue:d(R,S,y)})):typeof y<"u"&&a(E,{name:m,newValue:y}));return E},kf}var KO=HO();const Sf=Od(KO);function Nd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function qO(){const e=[],t={run:n,use:i};return t;function n(...s){let l=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...s);function c(d,...h){const m=e[++l];let p=-1;if(d){a(d);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?XO(m,c)(...h):a(null,...h)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function XO(e,t){let n;return i;function i(...a){const c=e.length>a.length;let d;c&&a.push(s);try{d=e.apply(this,a)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,s):d instanceof Error?s(d):l(d))}function s(a,...c){n||(n=!0,t(a,...c))}function l(a){s(null,a)}}const Gn={basename:YO,dirname:GO,extname:QO,join:ZO,sep:"/"};function YO(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fs(e);let n=0,i=-1,s=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else i<0&&(l=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else a<0&&(l=!0,a=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function GO(e){if(Fs(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QO(e){Fs(e);let t=e.length,n=-1,i=0,s=-1,l=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?s<0?s=t:l!==1&&(l=1):s>-1&&(l=-1)}return s<0||n<0||l===0||l===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function ZO(...e){let t=-1,n;for(;++t<e.length;)Fs(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":JO(n)}function JO(e){Fs(e);const t=e.codePointAt(0)===47;let n=eF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function eF(e,t){let n="",i=0,s=-1,l=0,a=-1,c,d;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(s===a-1||l===1))if(s!==a-1&&l===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",i=0):(n=n.slice(0,d),i=n.length-1-n.lastIndexOf("/")),s=a,l=0;continue}}else if(n.length>0){n="",i=0,s=a,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,l=0}else c===46&&l>-1?l++:l=-1}return n}function Fs(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const tF={cwd:nF};function nF(){return"/"}function jd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rF(e){if(typeof e=="string")e=new URL(e);else if(!jd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return iF(e)}function iF(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const bf=["history","path","basename","stem","extname","dirname"];class zk{constructor(t){let n;t?jd(t)?n={path:t}:typeof t=="string"||oF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":tF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<bf.length;){const l=bf[i];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let s;for(s in n)bf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Gn.basename(this.path):void 0}set basename(t){Ef(t,"basename"),Cf(t,"basename"),this.path=Gn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Gn.dirname(this.path):void 0}set dirname(t){hx(this.basename,"dirname"),this.path=Gn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Gn.extname(this.path):void 0}set extname(t){if(Cf(t,"extname"),hx(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Gn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jd(t)&&(t=rF(t)),Ef(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Gn.basename(this.path,this.extname):void 0}set stem(t){Ef(t,"stem"),Cf(t,"stem"),this.path=Gn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const s=this.message(t,n,i);throw s.fatal=!0,s}info(t,n,i){const s=this.message(t,n,i);return s.fatal=void 0,s}message(t,n,i){const s=new qt(t,n,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Cf(e,t){if(e&&e.includes(Gn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Gn.sep+"`")}function Ef(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hx(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function oF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const sF=function(e){const i=this.constructor.prototype,s=i[e],l=function(){return s.apply(l,arguments)};return Object.setPrototypeOf(l,i),l},aF={}.hasOwnProperty;class Gh extends sF{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qO()}copy(){const t=new Gh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(Sf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Rf("data",this.frozen),this.namespace[t]=n,this):aF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Rf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=n.call(t,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=al(t),i=this.parser||this.Parser;return Tf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Tf("process",this.parser||this.Parser),Pf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(l,a){const c=al(t),d=i.parse(c);i.run(d,c,function(m,p,y){if(m||!p||!y)return h(m);const w=p,S=i.stringify(w,y);cF(S)?y.value=S:y.result=S,h(m,y)});function h(m,p){m||!p?a(m):l?l(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Tf("processSync",this.parser||this.Parser),Pf("processSync",this.compiler||this.Compiler),this.process(t,s),mx("processSync","process",n),i;function s(l,a){n=!0,fx(l),i=a}}run(t,n,i){px(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?l(void 0,i):new Promise(l);function l(a,c){const d=al(n);s.run(t,d,h);function h(m,p,y){const w=p||t;m?c(m):a?a(w):i(void 0,w,y)}}}runSync(t,n){let i=!1,s;return this.run(t,n,l),mx("runSync","run",i),s;function l(a,c){fx(a),s=c,i=!0}}stringify(t,n){this.freeze();const i=al(n),s=this.compiler||this.Compiler;return Pf("stringify",s),px(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Rf("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;d(m,p)}else a(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function a(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(s.settings=Sf(!0,s.settings,h.settings))}function c(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const p=h[m];l(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let p=-1,y=-1;for(;++p<i.length;)if(i[p][0]===h){y=p;break}if(y===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const E=i[y][1];Nd(E)&&Nd(w)&&(w=Sf(!0,E,w)),i[y]=[h,w,...S]}}}}const lF=new Gh().freeze();function Tf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Pf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Rf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function px(e){if(!Nd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function mx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function al(e){return uF(e)?e:new zk(e)}function uF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function cF(e){return typeof e=="string"||fF(e)}function fF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const dF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gx=[],yx={allowDangerousHtml:!0},hF=/^(https?|ircs?|mailto|xmpp)$/i,pF=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Vk(e){const t=mF(e),n=gF(e);return yF(t.runSync(t.parse(n),n),e)}function mF(e){const t=e.rehypePlugins||gx,n=e.remarkPlugins||gx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...yx}:yx;return lF().use(iO).use(n).use(WO,i).use(t)}function gF(e){const t=e.children||"",n=new zk;return typeof t=="string"&&(n.value=t),n}function yF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,l=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||vF;for(const m of pF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+dF+m.id,void 0);return wh(e,h),$L(e,{Fragment:v.Fragment,components:s,ignoreInvalidStyle:!0,jsx:v.jsx,jsxs:v.jsxs,passKeys:!0,passNode:!0});function h(m,p,y){if(m.type==="raw"&&y&&typeof p=="number")return a?y.children.splice(p,1):y.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in wf)if(Object.hasOwn(wf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],E=wf[w];(E===null||E.includes(m.tagName))&&(m.properties[w]=d(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):l?l.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,y)),w&&y&&typeof p=="number")return c&&m.children?y.children.splice(p,1,...m.children):y.children.splice(p,1),p}}}function vF(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||i!==-1&&t>i||hF.test(e.slice(0,t))?e:""}const xF={};function Bk(e){const t=this,n=e||xF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(d1(n)),l.push(W0()),a.push(bN(n))}function mo(e){const t=k.useRef(null);return k.useEffect(()=>(t.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{const n=t.current;n?.isConnected&&requestAnimationFrame(()=>n.focus())}),[]),v.jsx(ck,{open:!0,onOpenChange:n=>{n||e.onClose()},children:v.jsxs(hk,{children:[v.jsx(pk,{className:"modal-backdrop"}),v.jsxs(mk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{children:[v.jsx(yk,{asChild:!0,children:v.jsx("h3",{children:e.title})}),e.description&&v.jsx(vk,{className:"modal-description",children:e.description})]}),v.jsx(xk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:v.jsx(Se,{name:"close"})})})]}),e.tabs,v.jsx("div",{className:"modal-body",children:e.children})]})]})})}const wF=.25,kF=8;let vx=Promise.resolve();function xx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function SF(){const[e,t]=k.useState(xx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(xx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function bF(e,t,n){const i=vx.then(async()=>{const{default:s}=await Mh(async()=>{const{default:l}=await import("./mermaid.core-B9OcYEtH.js").then(a=>a.bp);return{default:l}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return vx=i.then(()=>{},()=>{}),i}function CF(e){return Math.min(kF,Math.max(wF,e))}function EF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[l,a]=k.useState({x:0,y:0}),[c,d]=k.useState(!1),h=()=>{s(1),a({x:0,y:0})},m=(p,y,w)=>{const S=CF(p);if(S===i)return;const E=t.current?.getBoundingClientRect();if(E){const T=(y??E.left+E.width/2)-E.left-E.width/2,C=(w??E.top+E.height/2)-E.top-E.height/2,R=S/i;a(A=>({x:T-R*(T-A.x),y:C-R*(C-A.y)}))}s(S)};return k.useEffect(()=>{const p=y=>{y.key==="+"||y.key==="="?(y.preventDefault(),m(i*1.25)):y.key==="-"?(y.preventDefault(),m(i/1.25)):y.key==="0"&&(y.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),v.jsx(ck,{open:!0,onOpenChange:p=>{p||e.onClose()},children:v.jsxs(hk,{children:[v.jsx(pk,{className:"mermaid-fullscreen-backdrop"}),v.jsxs(mk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[v.jsx(yk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),v.jsxs("div",{className:"mermaid-fullscreen-tools",children:[v.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:v.jsx(Se,{name:"minus"})}),v.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),v.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:v.jsx(Se,{name:"plus"})}),v.jsx(xk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:v.jsx(Se,{name:"close"})})})]}),v.jsx("div",{ref:t,className:"mermaid-fullscreen-viewport"+(c?" dragging":""),onWheel:p=>{p.preventDefault(),m(i*Math.exp(-p.deltaY*.0015),p.clientX,p.clientY)},onDoubleClick:p=>m(i*1.5,p.clientX,p.clientY),onPointerDown:p=>{p.button===0&&(n.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,panX:l.x,panY:l.y},p.currentTarget.setPointerCapture(p.pointerId),d(!0))},onPointerMove:p=>{const y=n.current;!y||y.pointerId!==p.pointerId||a({x:y.panX+p.clientX-y.startX,y:y.panY+p.clientY-y.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,d(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,d(!1)},children:v.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),v.jsx(vk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function TF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,l]=k.useState(""),[a,c]=k.useState("default"),[d,h]=k.useState(!1),m=SF();return k.useEffect(()=>{let p=!0;const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),l(""),bF(y,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&l(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${y}`)?.remove()}},[t,e,m]),s?v.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":a,children:[v.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:v.jsx(Se,{name:"maximize"})}),v.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),d&&v.jsx(EF,{svg:n,theme:a,onClose:()=>h(!1)})]}):v.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const PF=k.memo(function(t){return v.jsx("article",{className:"markdown-body",ref:t.contentRef,children:v.jsx(Vk,{remarkPlugins:[Bk],components:{a:({children:n,...i})=>v.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const l=/language-([\w-]+)/.exec(n??"")?.[1],a=String(i).replace(/\n$/,"");return l==="mermaid"?v.jsx(TF,{source:a}):v.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function RF(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[l,a]=k.useState(null),[c,d]=k.useState("loading"),[h,m]=k.useState(""),[p,y]=k.useState(0),[w,S]=k.useState(""),[E,T]=k.useState(0),[C,R]=k.useState(!1),[A,D]=k.useState(""),[B,I]=k.useState(!1),[q,$]=k.useState(!1),[K,j]=k.useState([]),[Y,W]=k.useState(!1),[ue,Z]=k.useState(null),[ee,ge]=k.useState(!1),[Ce,X]=k.useState("");k.useEffect(()=>{let M=!0,J=null;return d("loading"),ql(t.id).then(he=>{if(M){if(!he){d("missing");return}s(new TextDecoder("utf-8").decode(he)),J=URL.createObjectURL(new Blob([he],{type:"text/markdown;charset=utf-8"})),a(J),d("ready")}}).catch(()=>{M&&d("error")}),()=>{M=!1,J&&URL.revokeObjectURL(J)}},[t.id]),k.useEffect(()=>{const M=()=>{const J=window.getSelection(),he=n.current;if(!J||J.isCollapsed||!he){m(""),y(0);return}if(!he.contains(J.anchorNode)||!he.contains(J.focusNode)){m(""),y(0);return}const me=J.getRangeAt(0),ve=J.toString(),Ee=ve.length-ve.trimStart().length,Re=ve.trim().slice(0,4e3),Be=document.createRange();Be.selectNodeContents(he),Be.setEnd(me.startContainer,me.startOffset);const ft=Be.toString().length+Ee;m(Re),y(YI(he.textContent,Re,ft))};return document.addEventListener("selectionchange",M),()=>document.removeEventListener("selectionchange",M)},[]);const ce=()=>{h&&(S(h),T(p),R(!0),X(""))},P=async()=>{if(q){if(!w||!A.trim())return;j(J=>[...J,{selection:w,comment:A.trim(),occurrence:E}]),D(""),R(!1),X("Comment added to review");return}const M=qI(w,A);if(!(!M||!A.trim()||B)){I(!0),X("");try{await e.onSendText(M,t.id||void 0),D(""),R(!1),X("Feedback sent")}catch(J){X(`Send failed: ${String(J)}`)}finally{I(!1)}}},L=async()=>{if(K.length===0||Y)return;const M=tD(i,K);W(!0),X("");try{e.onSendFile?await e.onSendFile({filename:XI(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(M)},t.id||void 0):await e.onSendText(M,t.id||void 0),j([]),$(!1),X("Review submitted")}catch(J){X(`Review send failed: ${String(J)}`)}finally{W(!1)}},G=async()=>{if(!(!ue||!e.onSendFile||ee)){ge(!0),X("");try{await e.onSendFile(ue,t.id||void 0),Z(null),X("Voice feedback sent")}catch(M){X(`Voice send failed: ${String(M)}`)}finally{ge(!1)}}};return v.jsx(mo,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:v.jsxs("div",{className:"markdown-preview",children:[v.jsxs("div",{className:"markdown-review-toolbar",children:[v.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:M=>M.preventDefault(),onClick:ce,children:[v.jsx(Se,{name:"reply",size:14}),q?"Add review comment":"Quick message",h?` (${h.length})`:""]}),q?v.jsx("button",{className:"btn sm",onClick:()=>{$(!1),j([]),R(!1),X("Review discarded")},children:"Cancel review"}):v.jsxs("button",{className:"btn sm",onClick:()=>{$(!0),j([]),X("Review started — select passages to add comments")},children:[v.jsx(Se,{name:"edit",size:14}),"Start review"]}),l&&v.jsxs("a",{className:"btn sm",href:l,download:t.filename,children:[v.jsx(Se,{name:"download",size:14}),"Download"]}),e.onSendFile&&v.jsx(S1,{disabled:!!ue||ee,onReady:Z,onError:X}),v.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),C&&v.jsxs("div",{className:"markdown-feedback",children:[v.jsx("blockquote",{children:w}),v.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:A,onChange:M=>D(M.target.value)}),v.jsxs("div",{className:"markdown-feedback-actions",children:[v.jsx("button",{className:"btn sm",onClick:()=>R(!1),children:"Cancel"}),v.jsxs("button",{className:"btn sm primary",disabled:!A.trim()||B,onClick:()=>void P(),children:[v.jsx(Se,{name:"send",size:14}),q?"Add to review":B?"Sending…":"Send feedback"]})]})]}),q&&v.jsxs("div",{className:"markdown-review-draft",children:[v.jsxs("div",{className:"markdown-review-draft-head",children:[v.jsxs("strong",{children:["Review · ",K.length," comment",K.length===1?"":"s"]}),v.jsxs("button",{className:"btn sm primary",disabled:K.length===0||Y,onClick:()=>void L(),children:[v.jsx(Se,{name:"send",size:14}),Y?"Submitting…":"Submit review"]})]}),K.map((M,J)=>v.jsxs("div",{className:"markdown-review-comment",children:[v.jsx("span",{children:J+1}),v.jsxs("div",{children:[v.jsx("blockquote",{children:M.selection}),v.jsx("p",{children:M.comment})]}),v.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>j(he=>he.filter((me,ve)=>ve!==J)),children:v.jsx(Se,{name:"close",size:14})})]},`${J}-${M.selection.slice(0,24)}`))]}),ue&&v.jsx(k1,{att:ue,sending:ee,onSend:()=>void G(),onDiscard:()=>Z(null)}),Ce&&v.jsx("div",{className:"markdown-review-status",role:"status",children:Ce}),v.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&v.jsx(PF,{markdown:i,contentRef:n})]})]})})}function AF(e){const{rec:t}=e,[n,i]=k.useState(""),[s,l]=k.useState(null),[a,c]=k.useState(0),[d,h]=k.useState("loading");return k.useEffect(()=>{let m=!0,p=null;return h("loading"),ql(t.id).then(y=>{if(m){if(!y){h("missing");return}i(lD(new TextDecoder("utf-8").decode(y))),c(y.byteLength),p=URL.createObjectURL(new Blob([y],{type:Th(t.mime,t.filename)})),l(p),h("ready")}}).catch(()=>{m&&h("error")}),()=>{m=!1,p&&URL.revokeObjectURL(p)}},[t.id,t.mime,t.filename]),v.jsx(mo,{title:t.filename,description:"HTML preview · sandboxed, static rendering only",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal",children:v.jsxs("div",{className:"html-preview",children:[v.jsxs("div",{className:"html-preview-toolbar",children:[v.jsxs("span",{className:"html-preview-shield",children:[v.jsx(Se,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),s&&v.jsxs("a",{className:"btn sm",href:s,download:t.filename,children:[v.jsx(Se,{name:"download",size:14}),"Download original",a?` · ${$r(a)}`:""]})]}),v.jsxs("div",{className:"html-preview-frame",children:[d==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),d==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),d==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),d==="ready"&&v.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:rD,referrerPolicy:"no-referrer",srcDoc:n})]})]})})}function $k(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const l=e.options.length-1,a=s==="Home"?0:s==="End"?l:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[a];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return v.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>v.jsxs("button",{id:`${e.idPrefix}-${n.id}`,type:"button",role:"tab","aria-selected":e.value===n.id,"aria-controls":e.panelId,tabIndex:e.value===n.id?0:-1,className:"tab"+(e.value===n.id?" active":""),onClick:()=>e.onChange(n.id),onKeyDown:s=>t(s,i),children:[n.label,n.count===void 0?null:v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{children:n.count})]})]},n.id))})}function Id(e){const{message:t}=e,[n,i]=k.useState(null),[s,l]=k.useState(0),a=b0(t.wireId)??{id:t.wireId,dir:t.dir,filename:t.filename??"file",mime:t.mime??"application/octet-stream",size:s,date:t.date};k.useEffect(()=>{let h=!0,m=null;if(t.wireId)return ql(t.wireId).then(p=>{!h||!p||(l(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:Th(a.mime,a.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,a.mime,a.filename]);const c=pd(t)==="photo",d=io(a.mime,a.filename);return v.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[v.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?v.jsx("img",{src:n,alt:a.filename}):v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:d?"mic":"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:c?a.filename||"Photo":d?"Voice message":a.filename}),v.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",bs(a.date),s?` · ${$r(s)}`:""]})]})]}),v.jsxs("span",{className:"shared-media-actions",children:[h1(a.filename)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(a),children:v.jsx(Se,{name:"monitor",size:16})}),Zl(a.filename,a.mime)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(a),children:v.jsx(Se,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:a.filename,title:"Download",children:v.jsx(Se,{name:"download",size:16})})]})]})}function MF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return v.jsx(Id,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return v.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[v.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:e.filename}),v.jsxs("span",{children:[e.versions.length," versions · newest ",bs(e.versions[0].message.date)]})]}),v.jsx(Se,{name:t?"chevronDown":"chevron",size:16})]}),t&&v.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>v.jsx(Id,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function NF(e){const[t,n]=k.useState("photo"),i=e.messages.map((h,m)=>({message:h,key:h.wireId||`${h.date}-${(e.indexOffset??0)+m}`})),s=i.filter(({message:h})=>pd(h)==="photo"),l=i.filter(({message:h})=>pd(h)==="file"),a=QI(l),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:GI(h.text).map(p=>({url:p,message:h,key:m}))),d=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:l.length},{id:"link",label:"Links",count:c.length}];return v.jsx(mo,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:v.jsx($k,{className:"shared-media-tabs",label:"Shared media type",options:d,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:v.jsxs("div",{id:"shared-media-panel",role:"tabpanel","aria-labelledby":`shared-media-tab-${t}`,className:"shared-media-list"+(t==="photo"?" photos":""),children:[t==="photo"&&s.map(h=>v.jsx(Id,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&a.map(h=>v.jsx(MF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>v.jsxs("div",{className:"shared-media-item",children:[v.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:"link",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:h.url}),v.jsx("span",{children:bs(h.message.date)})]})]}),v.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:v.jsx(Se,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&l.length===0||t==="link"&&c.length===0)&&v.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const jF=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),IF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function Uk(e,t=""){return jF.includes(String(e??"").toLowerCase())||IF.test(String(t??""))}function DF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function _F(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),l=Math.max(1,Number(n)||1),a=Math.min(1,l/Math.max(i,s));return{width:Math.max(1,Math.round(i*a)),height:Math.max(1,Math.round(s*a))}}const LF=2048,OF=640,FF=.82,zF=[.84,.7,.56,.44],VF=.94;function BF(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,l=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:l}),s.onerror=()=>{l(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function $F(e,t){return new Promise((n,i)=>{e.toBlob(s=>s?n(s):i(new Error("This browser could not encode the optimized photo.")),"image/jpeg",t)})}async function UF(e,t){if(!Uk(e.type,e.name))throw new Error("This image format cannot be optimized safely in this browser.");const n=Math.max(1,Math.floor(t*VF)),{image:i,release:s}=await BF(e),l=document.createElement("canvas"),a=l.getContext("2d",{alpha:!1});if(!a)throw s(),new Error("Photo optimization is unavailable in this browser.");try{let c=Math.min(LF,Math.max(i.naturalWidth,i.naturalHeight));for(;c>=OF;){const d=_F(i.naturalWidth,i.naturalHeight,c);l.width=d.width,l.height=d.height,a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height),a.drawImage(i,0,0,l.width,l.height);for(const h of zF){const m=await $F(l,h);if(m.size<=n)return{filename:DF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:l.width,height:l.height,originalSize:e.size}}c=Math.floor(c*FF)}}finally{s(),l.width=1,l.height=1}throw new Error("The photo is still too large after optimization.")}const WF=5e4,HF=new Set(["http:","https:","mailto:"]);function Wk(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return HF.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function Hk(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function KF(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
314
+ `},s),l}function WO(e,t){return e&&"run"in e?async function(n,i){const s=cx(n,{file:i,...t});await e.run(s,i)}:function(n,i){return cx(n,{file:i,...e||t})}}function fx(e){if(e)throw e}var kf,dx;function HO(){if(dx)return kf;dx=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var y;for(y in h);return typeof y>"u"||e.call(h,y)},a=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(i)return i(h,m).value}else return;return h[m]};return kf=function d(){var h,m,p,y,w,S,E=arguments[0],T=1,C=arguments.length,R=!1;for(typeof E=="boolean"&&(R=E,E=arguments[1]||{},T=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});T<C;++T)if(h=arguments[T],h!=null)for(m in h)p=c(E,m),y=c(h,m),E!==y&&(R&&y&&(l(y)||(w=s(y)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&l(p)?p:{},a(E,{name:m,newValue:d(R,S,y)})):typeof y<"u"&&a(E,{name:m,newValue:y}));return E},kf}var KO=HO();const Sf=Od(KO);function Nd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function qO(){const e=[],t={run:n,use:i};return t;function n(...s){let l=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...s);function c(d,...h){const m=e[++l];let p=-1;if(d){a(d);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?XO(m,c)(...h):a(null,...h)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function XO(e,t){let n;return i;function i(...a){const c=e.length>a.length;let d;c&&a.push(s);try{d=e.apply(this,a)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,s):d instanceof Error?s(d):l(d))}function s(a,...c){n||(n=!0,t(a,...c))}function l(a){s(null,a)}}const Gn={basename:YO,dirname:GO,extname:QO,join:ZO,sep:"/"};function YO(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Fs(e);let n=0,i=-1,s=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else i<0&&(l=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else a<0&&(l=!0,a=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function GO(e){if(Fs(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function QO(e){Fs(e);let t=e.length,n=-1,i=0,s=-1,l=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?s<0?s=t:l!==1&&(l=1):s>-1&&(l=-1)}return s<0||n<0||l===0||l===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function ZO(...e){let t=-1,n;for(;++t<e.length;)Fs(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":JO(n)}function JO(e){Fs(e);const t=e.codePointAt(0)===47;let n=eF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function eF(e,t){let n="",i=0,s=-1,l=0,a=-1,c,d;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(s===a-1||l===1))if(s!==a-1&&l===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",i=0):(n=n.slice(0,d),i=n.length-1-n.lastIndexOf("/")),s=a,l=0;continue}}else if(n.length>0){n="",i=0,s=a,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,l=0}else c===46&&l>-1?l++:l=-1}return n}function Fs(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const tF={cwd:nF};function nF(){return"/"}function jd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rF(e){if(typeof e=="string")e=new URL(e);else if(!jd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return iF(e)}function iF(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const bf=["history","path","basename","stem","extname","dirname"];class zk{constructor(t){let n;t?jd(t)?n={path:t}:typeof t=="string"||oF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":tF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<bf.length;){const l=bf[i];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let s;for(s in n)bf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Gn.basename(this.path):void 0}set basename(t){Ef(t,"basename"),Cf(t,"basename"),this.path=Gn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Gn.dirname(this.path):void 0}set dirname(t){hx(this.basename,"dirname"),this.path=Gn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Gn.extname(this.path):void 0}set extname(t){if(Cf(t,"extname"),hx(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Gn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jd(t)&&(t=rF(t)),Ef(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Gn.basename(this.path,this.extname):void 0}set stem(t){Ef(t,"stem"),Cf(t,"stem"),this.path=Gn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const s=this.message(t,n,i);throw s.fatal=!0,s}info(t,n,i){const s=this.message(t,n,i);return s.fatal=void 0,s}message(t,n,i){const s=new qt(t,n,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Cf(e,t){if(e&&e.includes(Gn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Gn.sep+"`")}function Ef(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hx(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function oF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const sF=function(e){const i=this.constructor.prototype,s=i[e],l=function(){return s.apply(l,arguments)};return Object.setPrototypeOf(l,i),l},aF={}.hasOwnProperty;class Gh extends sF{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qO()}copy(){const t=new Gh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(Sf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Rf("data",this.frozen),this.namespace[t]=n,this):aF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Rf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=n.call(t,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=al(t),i=this.parser||this.Parser;return Tf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Tf("process",this.parser||this.Parser),Pf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(l,a){const c=al(t),d=i.parse(c);i.run(d,c,function(m,p,y){if(m||!p||!y)return h(m);const w=p,S=i.stringify(w,y);cF(S)?y.value=S:y.result=S,h(m,y)});function h(m,p){m||!p?a(m):l?l(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Tf("processSync",this.parser||this.Parser),Pf("processSync",this.compiler||this.Compiler),this.process(t,s),mx("processSync","process",n),i;function s(l,a){n=!0,fx(l),i=a}}run(t,n,i){px(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?l(void 0,i):new Promise(l);function l(a,c){const d=al(n);s.run(t,d,h);function h(m,p,y){const w=p||t;m?c(m):a?a(w):i(void 0,w,y)}}}runSync(t,n){let i=!1,s;return this.run(t,n,l),mx("runSync","run",i),s;function l(a,c){fx(a),s=c,i=!0}}stringify(t,n){this.freeze();const i=al(n),s=this.compiler||this.Compiler;return Pf("stringify",s),px(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Rf("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;d(m,p)}else a(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function a(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(s.settings=Sf(!0,s.settings,h.settings))}function c(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const p=h[m];l(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let p=-1,y=-1;for(;++p<i.length;)if(i[p][0]===h){y=p;break}if(y===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const E=i[y][1];Nd(E)&&Nd(w)&&(w=Sf(!0,E,w)),i[y]=[h,w,...S]}}}}const lF=new Gh().freeze();function Tf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Pf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Rf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function px(e){if(!Nd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function mx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function al(e){return uF(e)?e:new zk(e)}function uF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function cF(e){return typeof e=="string"||fF(e)}function fF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const dF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gx=[],yx={allowDangerousHtml:!0},hF=/^(https?|ircs?|mailto|xmpp)$/i,pF=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Vk(e){const t=mF(e),n=gF(e);return yF(t.runSync(t.parse(n),n),e)}function mF(e){const t=e.rehypePlugins||gx,n=e.remarkPlugins||gx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...yx}:yx;return lF().use(iO).use(n).use(WO,i).use(t)}function gF(e){const t=e.children||"",n=new zk;return typeof t=="string"&&(n.value=t),n}function yF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,l=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||vF;for(const m of pF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+dF+m.id,void 0);return wh(e,h),$L(e,{Fragment:v.Fragment,components:s,ignoreInvalidStyle:!0,jsx:v.jsx,jsxs:v.jsxs,passKeys:!0,passNode:!0});function h(m,p,y){if(m.type==="raw"&&y&&typeof p=="number")return a?y.children.splice(p,1):y.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in wf)if(Object.hasOwn(wf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],E=wf[w];(E===null||E.includes(m.tagName))&&(m.properties[w]=d(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):l?l.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,y)),w&&y&&typeof p=="number")return c&&m.children?y.children.splice(p,1,...m.children):y.children.splice(p,1),p}}}function vF(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||i!==-1&&t>i||hF.test(e.slice(0,t))?e:""}const xF={};function Bk(e){const t=this,n=e||xF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(d1(n)),l.push(W0()),a.push(bN(n))}function mo(e){const t=k.useRef(null);return k.useEffect(()=>(t.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{const n=t.current;n?.isConnected&&requestAnimationFrame(()=>n.focus())}),[]),v.jsx(ck,{open:!0,onOpenChange:n=>{n||e.onClose()},children:v.jsxs(hk,{children:[v.jsx(pk,{className:"modal-backdrop"}),v.jsxs(mk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{children:[v.jsx(yk,{asChild:!0,children:v.jsx("h3",{children:e.title})}),e.description&&v.jsx(vk,{className:"modal-description",children:e.description})]}),v.jsx(xk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:v.jsx(Se,{name:"close"})})})]}),e.tabs,v.jsx("div",{className:"modal-body",children:e.children})]})]})})}const wF=.25,kF=8;let vx=Promise.resolve();function xx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function SF(){const[e,t]=k.useState(xx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(xx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function bF(e,t,n){const i=vx.then(async()=>{const{default:s}=await Mh(async()=>{const{default:l}=await import("./mermaid.core-bMY6NRgG.js").then(a=>a.bp);return{default:l}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return vx=i.then(()=>{},()=>{}),i}function CF(e){return Math.min(kF,Math.max(wF,e))}function EF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[l,a]=k.useState({x:0,y:0}),[c,d]=k.useState(!1),h=()=>{s(1),a({x:0,y:0})},m=(p,y,w)=>{const S=CF(p);if(S===i)return;const E=t.current?.getBoundingClientRect();if(E){const T=(y??E.left+E.width/2)-E.left-E.width/2,C=(w??E.top+E.height/2)-E.top-E.height/2,R=S/i;a(A=>({x:T-R*(T-A.x),y:C-R*(C-A.y)}))}s(S)};return k.useEffect(()=>{const p=y=>{y.key==="+"||y.key==="="?(y.preventDefault(),m(i*1.25)):y.key==="-"?(y.preventDefault(),m(i/1.25)):y.key==="0"&&(y.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),v.jsx(ck,{open:!0,onOpenChange:p=>{p||e.onClose()},children:v.jsxs(hk,{children:[v.jsx(pk,{className:"mermaid-fullscreen-backdrop"}),v.jsxs(mk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[v.jsx(yk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),v.jsxs("div",{className:"mermaid-fullscreen-tools",children:[v.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:v.jsx(Se,{name:"minus"})}),v.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),v.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:v.jsx(Se,{name:"plus"})}),v.jsx(xk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:v.jsx(Se,{name:"close"})})})]}),v.jsx("div",{ref:t,className:"mermaid-fullscreen-viewport"+(c?" dragging":""),onWheel:p=>{p.preventDefault(),m(i*Math.exp(-p.deltaY*.0015),p.clientX,p.clientY)},onDoubleClick:p=>m(i*1.5,p.clientX,p.clientY),onPointerDown:p=>{p.button===0&&(n.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,panX:l.x,panY:l.y},p.currentTarget.setPointerCapture(p.pointerId),d(!0))},onPointerMove:p=>{const y=n.current;!y||y.pointerId!==p.pointerId||a({x:y.panX+p.clientX-y.startX,y:y.panY+p.clientY-y.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,d(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,d(!1)},children:v.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),v.jsx(vk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function TF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,l]=k.useState(""),[a,c]=k.useState("default"),[d,h]=k.useState(!1),m=SF();return k.useEffect(()=>{let p=!0;const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),l(""),bF(y,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&l(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${y}`)?.remove()}},[t,e,m]),s?v.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":a,children:[v.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:v.jsx(Se,{name:"maximize"})}),v.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),d&&v.jsx(EF,{svg:n,theme:a,onClose:()=>h(!1)})]}):v.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const PF=k.memo(function(t){return v.jsx("article",{className:"markdown-body",ref:t.contentRef,children:v.jsx(Vk,{remarkPlugins:[Bk],components:{a:({children:n,...i})=>v.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const l=/language-([\w-]+)/.exec(n??"")?.[1],a=String(i).replace(/\n$/,"");return l==="mermaid"?v.jsx(TF,{source:a}):v.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function RF(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[l,a]=k.useState(null),[c,d]=k.useState("loading"),[h,m]=k.useState(""),[p,y]=k.useState(0),[w,S]=k.useState(""),[E,T]=k.useState(0),[C,R]=k.useState(!1),[A,D]=k.useState(""),[B,I]=k.useState(!1),[q,$]=k.useState(!1),[K,j]=k.useState([]),[Y,W]=k.useState(!1),[ue,Z]=k.useState(null),[ee,ge]=k.useState(!1),[Ce,X]=k.useState("");k.useEffect(()=>{let M=!0,J=null;return d("loading"),ql(t.id).then(he=>{if(M){if(!he){d("missing");return}s(new TextDecoder("utf-8").decode(he)),J=URL.createObjectURL(new Blob([he],{type:"text/markdown;charset=utf-8"})),a(J),d("ready")}}).catch(()=>{M&&d("error")}),()=>{M=!1,J&&URL.revokeObjectURL(J)}},[t.id]),k.useEffect(()=>{const M=()=>{const J=window.getSelection(),he=n.current;if(!J||J.isCollapsed||!he){m(""),y(0);return}if(!he.contains(J.anchorNode)||!he.contains(J.focusNode)){m(""),y(0);return}const me=J.getRangeAt(0),ve=J.toString(),Ee=ve.length-ve.trimStart().length,Re=ve.trim().slice(0,4e3),Be=document.createRange();Be.selectNodeContents(he),Be.setEnd(me.startContainer,me.startOffset);const ft=Be.toString().length+Ee;m(Re),y(YI(he.textContent,Re,ft))};return document.addEventListener("selectionchange",M),()=>document.removeEventListener("selectionchange",M)},[]);const ce=()=>{h&&(S(h),T(p),R(!0),X(""))},P=async()=>{if(q){if(!w||!A.trim())return;j(J=>[...J,{selection:w,comment:A.trim(),occurrence:E}]),D(""),R(!1),X("Comment added to review");return}const M=qI(w,A);if(!(!M||!A.trim()||B)){I(!0),X("");try{await e.onSendText(M,t.id||void 0),D(""),R(!1),X("Feedback sent")}catch(J){X(`Send failed: ${String(J)}`)}finally{I(!1)}}},L=async()=>{if(K.length===0||Y)return;const M=tD(i,K);W(!0),X("");try{e.onSendFile?await e.onSendFile({filename:XI(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(M)},t.id||void 0):await e.onSendText(M,t.id||void 0),j([]),$(!1),X("Review submitted")}catch(J){X(`Review send failed: ${String(J)}`)}finally{W(!1)}},G=async()=>{if(!(!ue||!e.onSendFile||ee)){ge(!0),X("");try{await e.onSendFile(ue,t.id||void 0),Z(null),X("Voice feedback sent")}catch(M){X(`Voice send failed: ${String(M)}`)}finally{ge(!1)}}};return v.jsx(mo,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:v.jsxs("div",{className:"markdown-preview",children:[v.jsxs("div",{className:"markdown-review-toolbar",children:[v.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:M=>M.preventDefault(),onClick:ce,children:[v.jsx(Se,{name:"reply",size:14}),q?"Add review comment":"Quick message",h?` (${h.length})`:""]}),q?v.jsx("button",{className:"btn sm",onClick:()=>{$(!1),j([]),R(!1),X("Review discarded")},children:"Cancel review"}):v.jsxs("button",{className:"btn sm",onClick:()=>{$(!0),j([]),X("Review started — select passages to add comments")},children:[v.jsx(Se,{name:"edit",size:14}),"Start review"]}),l&&v.jsxs("a",{className:"btn sm",href:l,download:t.filename,children:[v.jsx(Se,{name:"download",size:14}),"Download"]}),e.onSendFile&&v.jsx(S1,{disabled:!!ue||ee,onReady:Z,onError:X}),v.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),C&&v.jsxs("div",{className:"markdown-feedback",children:[v.jsx("blockquote",{children:w}),v.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:A,onChange:M=>D(M.target.value)}),v.jsxs("div",{className:"markdown-feedback-actions",children:[v.jsx("button",{className:"btn sm",onClick:()=>R(!1),children:"Cancel"}),v.jsxs("button",{className:"btn sm primary",disabled:!A.trim()||B,onClick:()=>void P(),children:[v.jsx(Se,{name:"send",size:14}),q?"Add to review":B?"Sending…":"Send feedback"]})]})]}),q&&v.jsxs("div",{className:"markdown-review-draft",children:[v.jsxs("div",{className:"markdown-review-draft-head",children:[v.jsxs("strong",{children:["Review · ",K.length," comment",K.length===1?"":"s"]}),v.jsxs("button",{className:"btn sm primary",disabled:K.length===0||Y,onClick:()=>void L(),children:[v.jsx(Se,{name:"send",size:14}),Y?"Submitting…":"Submit review"]})]}),K.map((M,J)=>v.jsxs("div",{className:"markdown-review-comment",children:[v.jsx("span",{children:J+1}),v.jsxs("div",{children:[v.jsx("blockquote",{children:M.selection}),v.jsx("p",{children:M.comment})]}),v.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>j(he=>he.filter((me,ve)=>ve!==J)),children:v.jsx(Se,{name:"close",size:14})})]},`${J}-${M.selection.slice(0,24)}`))]}),ue&&v.jsx(k1,{att:ue,sending:ee,onSend:()=>void G(),onDiscard:()=>Z(null)}),Ce&&v.jsx("div",{className:"markdown-review-status",role:"status",children:Ce}),v.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&v.jsx(PF,{markdown:i,contentRef:n})]})]})})}function AF(e){const{rec:t}=e,[n,i]=k.useState(""),[s,l]=k.useState(null),[a,c]=k.useState(0),[d,h]=k.useState("loading");return k.useEffect(()=>{let m=!0,p=null;return h("loading"),ql(t.id).then(y=>{if(m){if(!y){h("missing");return}i(lD(new TextDecoder("utf-8").decode(y))),c(y.byteLength),p=URL.createObjectURL(new Blob([y],{type:Th(t.mime,t.filename)})),l(p),h("ready")}}).catch(()=>{m&&h("error")}),()=>{m=!1,p&&URL.revokeObjectURL(p)}},[t.id,t.mime,t.filename]),v.jsx(mo,{title:t.filename,description:"HTML preview · sandboxed, static rendering only",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal",children:v.jsxs("div",{className:"html-preview",children:[v.jsxs("div",{className:"html-preview-toolbar",children:[v.jsxs("span",{className:"html-preview-shield",children:[v.jsx(Se,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),s&&v.jsxs("a",{className:"btn sm",href:s,download:t.filename,children:[v.jsx(Se,{name:"download",size:14}),"Download original",a?` · ${$r(a)}`:""]})]}),v.jsxs("div",{className:"html-preview-frame",children:[d==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),d==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),d==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),d==="ready"&&v.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:rD,referrerPolicy:"no-referrer",srcDoc:n})]})]})})}function $k(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const l=e.options.length-1,a=s==="Home"?0:s==="End"?l:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[a];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return v.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>v.jsxs("button",{id:`${e.idPrefix}-${n.id}`,type:"button",role:"tab","aria-selected":e.value===n.id,"aria-controls":e.panelId,tabIndex:e.value===n.id?0:-1,className:"tab"+(e.value===n.id?" active":""),onClick:()=>e.onChange(n.id),onKeyDown:s=>t(s,i),children:[n.label,n.count===void 0?null:v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{children:n.count})]})]},n.id))})}function Id(e){const{message:t}=e,[n,i]=k.useState(null),[s,l]=k.useState(0),a=b0(t.wireId)??{id:t.wireId,dir:t.dir,filename:t.filename??"file",mime:t.mime??"application/octet-stream",size:s,date:t.date};k.useEffect(()=>{let h=!0,m=null;if(t.wireId)return ql(t.wireId).then(p=>{!h||!p||(l(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:Th(a.mime,a.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,a.mime,a.filename]);const c=pd(t)==="photo",d=io(a.mime,a.filename);return v.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[v.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?v.jsx("img",{src:n,alt:a.filename}):v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:d?"mic":"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:c?a.filename||"Photo":d?"Voice message":a.filename}),v.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",bs(a.date),s?` · ${$r(s)}`:""]})]})]}),v.jsxs("span",{className:"shared-media-actions",children:[h1(a.filename)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(a),children:v.jsx(Se,{name:"monitor",size:16})}),Zl(a.filename,a.mime)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(a),children:v.jsx(Se,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:a.filename,title:"Download",children:v.jsx(Se,{name:"download",size:16})})]})]})}function MF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return v.jsx(Id,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return v.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[v.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:e.filename}),v.jsxs("span",{children:[e.versions.length," versions · newest ",bs(e.versions[0].message.date)]})]}),v.jsx(Se,{name:t?"chevronDown":"chevron",size:16})]}),t&&v.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>v.jsx(Id,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function NF(e){const[t,n]=k.useState("photo"),i=e.messages.map((h,m)=>({message:h,key:h.wireId||`${h.date}-${(e.indexOffset??0)+m}`})),s=i.filter(({message:h})=>pd(h)==="photo"),l=i.filter(({message:h})=>pd(h)==="file"),a=QI(l),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:GI(h.text).map(p=>({url:p,message:h,key:m}))),d=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:l.length},{id:"link",label:"Links",count:c.length}];return v.jsx(mo,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:v.jsx($k,{className:"shared-media-tabs",label:"Shared media type",options:d,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:v.jsxs("div",{id:"shared-media-panel",role:"tabpanel","aria-labelledby":`shared-media-tab-${t}`,className:"shared-media-list"+(t==="photo"?" photos":""),children:[t==="photo"&&s.map(h=>v.jsx(Id,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&a.map(h=>v.jsx(MF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>v.jsxs("div",{className:"shared-media-item",children:[v.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Se,{name:"link",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:h.url}),v.jsx("span",{children:bs(h.message.date)})]})]}),v.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:v.jsx(Se,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&l.length===0||t==="link"&&c.length===0)&&v.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const jF=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),IF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function Uk(e,t=""){return jF.includes(String(e??"").toLowerCase())||IF.test(String(t??""))}function DF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function _F(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),l=Math.max(1,Number(n)||1),a=Math.min(1,l/Math.max(i,s));return{width:Math.max(1,Math.round(i*a)),height:Math.max(1,Math.round(s*a))}}const LF=2048,OF=640,FF=.82,zF=[.84,.7,.56,.44],VF=.94;function BF(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,l=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:l}),s.onerror=()=>{l(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function $F(e,t){return new Promise((n,i)=>{e.toBlob(s=>s?n(s):i(new Error("This browser could not encode the optimized photo.")),"image/jpeg",t)})}async function UF(e,t){if(!Uk(e.type,e.name))throw new Error("This image format cannot be optimized safely in this browser.");const n=Math.max(1,Math.floor(t*VF)),{image:i,release:s}=await BF(e),l=document.createElement("canvas"),a=l.getContext("2d",{alpha:!1});if(!a)throw s(),new Error("Photo optimization is unavailable in this browser.");try{let c=Math.min(LF,Math.max(i.naturalWidth,i.naturalHeight));for(;c>=OF;){const d=_F(i.naturalWidth,i.naturalHeight,c);l.width=d.width,l.height=d.height,a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height),a.drawImage(i,0,0,l.width,l.height);for(const h of zF){const m=await $F(l,h);if(m.size<=n)return{filename:DF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:l.width,height:l.height,originalSize:e.size}}c=Math.floor(c*FF)}}finally{s(),l.width=1,l.height=1}throw new Error("The photo is still too large after optimization.")}const WF=5e4,HF=new Set(["http:","https:","mailto:"]);function Wk(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return HF.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function Hk(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function KF(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
315
315
  `),i=n.filter(a=>a.trim().length>0);if(i.length===0)return t;const s=i.map(a=>a.match(/^[ \t]+/)?.[0]??"");if(s.some(a=>a.length===0))return t;const l=Math.min(...s.map(a=>a.length));return n.map(a=>a.trim().length>0?a.slice(l):a).join(`
316
- `)}).join("")}function qF({children:e}){const t=k.isValidElement(e)?e:null,n=Hk(t?.props.className);return v.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&v.jsx("div",{className:"message-code-language",children:n}),v.jsx("pre",{children:e})]})}const XF=[Bk],YF={a:({node:e,children:t,href:n,...i})=>{const s=Wk(n);return s?v.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):v.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>v.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:qF,code:({node:e,className:t,children:n,...i})=>v.jsx("code",{className:t,"data-language":Hk(t),...i,children:n})},wx=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>WF?v.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):v.jsx("div",{className:n,"data-render-mode":"markdown",children:v.jsx(Vk,{remarkPlugins:XF,components:YF,urlTransform:i=>Wk(i)??"",children:KF(t)})})}),kl={type:"spring",stiffness:430,damping:38,mass:.72},kx=10,Kk=56,GF=18,QF=650;function ZF(e,t){return Math.abs(e)<kx&&Math.abs(t)<kx?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function JF(e){const t=e.at(-1),n=t?e.slice(0,-1).reverse().find(i=>i.x!==t.x&&t.time-i.time<=100):void 0;return n&&t&&t.time>n.time?(t.x-n.x)/(t.time-n.time)*1e3:0}function ez(e,t){const n=JF(t);return n>=0&&(e>=Kk||e>=GF&&n>=QF)}const Dd="ours.chats.listMode",ms="recent";function qk(){try{return globalThis.localStorage}catch{return}}function tz(e=qk()){try{return e?.getItem(Dd)==="identity"?"identity":ms}catch{return ms}}function nz(e,t=qk()){const n=e==="identity"?"identity":ms;try{return t?.setItem(Dd,n),t?.getItem(Dd)===n?n:ms}catch{return ms}}function Rs(e){return typeof e=="string"?e:""}function zl(e,t){const n=Rs(e),i=Rs(t),s=n.normalize().toLowerCase(),l=i.normalize().toLowerCase();return s<l?-1:s>l?1:n<i?-1:n>i?1:0}function rz(e,t){const n=jl(Rs(t.activityAt))-jl(Rs(e.activityAt));if(n!==0)return n;const i=zl(e.name,t.name);return i!==0?i:zl(e.id,t.id)}function _d(e){return[...e].sort(rz)}function Sx(e){return e.contacts.length>0?jl(Rs(e.contacts[0].activityAt)):0}function iz(e,t){const n=new Map,i=[];for(const l of e){const a=l.root||(t?.[l.id]?l.id:null);if(!a){i.push(l);continue}const c=t?.[a]||{label:a,note:""};let d=n.get(a);d||(d={id:`root:${a}`,rootId:a,label:c.label,note:c.note,contacts:[]},n.set(a,d)),d.contacts.push(l)}const s=[...n.values()].map(l=>({...l,contacts:_d(l.contacts)}));return i.length>0&&s.push({id:"rootless",rootId:null,label:"Independent identities",note:"People, agents and apps without a verified Human/root group",contacts:_d(i)}),s.sort((l,a)=>{const c=Sx(a)-Sx(l);if(c!==0)return c;const d=zl(l.label,a.label);return d!==0?d:zl(l.id,a.id)})}const oz=15e3;function Af(e){const{c:t,active:n,grouped:i}=e,[s,l]=k.useState(!1),a=async(h,m)=>{if(!(!h||s)){l(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{l(!1)}}},c=v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),v.jsxs("span",{className:"contact-copy",children:[v.jsxs("span",{className:"contact-row-topline",children:[v.jsx("span",{className:"contact-name",children:t.name}),t.when&&v.jsx("span",{className:"contact-time",children:t.when})]}),v.jsxs("span",{className:"contact-row-bottomline",children:[v.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&v.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&v.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&v.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[v.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void a(e.onApprove,h.currentTarget),children:"Approve"}),v.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void a(e.onReject,h.currentTarget),children:"Reject"})]}),n&&v.jsx(fs.span,{className:"contact-active-glow",layoutId:"active-contact",transition:kl})]}),d="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?v.jsx("div",{className:d,children:c}):v.jsx(fs.button,{type:"button",className:d,onClick:e.onClick,children:c})}function sz(e){const{contacts:t,roots:n,selected:i}=e,[s,l]=k.useState(""),[a,c]=k.useState(()=>tz()),d=C=>C.name.toLowerCase().includes(s.toLowerCase()),h=t.filter(C=>C.status!=="pending"&&d(C)),m=t.filter(C=>C.status==="pending"&&d(C)),p=_d(h),y=iz(h,n),w=h.length===0&&m.length===0,S=C=>{c(nz(C))},E=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],T=(C,R)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(C.key))return;C.preventDefault();const D=C.key==="Home"?"recent":C.key==="End"||R==="recent"?"identity":"recent";S(D),document.getElementById(`conversation-list-${D}`)?.focus()};return v.jsxs("div",{className:"listcol",children:[v.jsxs("div",{className:"listcol-head",children:[v.jsxs("div",{className:"listcol-titlebar",children:[v.jsx("h2",{id:"chat-list-title",className:"listcol-title",tabIndex:-1,children:"Chats"}),v.jsxs("div",{className:"listcol-actions",children:[v.jsxs("button",{className:"btn sm primary",onClick:e.onInvite,children:[v.jsx(Se,{name:"plus",size:15}),"Invite"]}),v.jsx("button",{className:"icon-btn",title:"Settings",onClick:e.onSettings,children:v.jsx(Se,{name:"settings"})})]})]}),v.jsxs("div",{className:"search",children:[v.jsx(Se,{name:"search"}),v.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:C=>l(C.target.value)})]}),v.jsx("div",{className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout",children:E.map(C=>v.jsx("button",{id:`conversation-list-${C.id}`,type:"button",role:"tab","aria-selected":a===C.id,"aria-controls":"conversation-list-panel",tabIndex:a===C.id?0:-1,className:a===C.id?"active":"",onClick:()=>S(C.id),onKeyDown:R=>T(R,C.id),children:C.label},C.id))})]}),v.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${a}`,children:[a==="recent"&&p.length>0&&v.jsx("div",{className:"conversation-group",children:p.map(C=>v.jsx(Af,{c:C,active:i===C.id,onClick:()=>e.onSelect(C.id)},C.id))}),a==="identity"&&y.map(C=>v.jsxs("div",{children:[v.jsxs("div",{className:"group-label",title:C.note,children:[C.rootId&&v.jsx(Se,{name:"clusters"}),v.jsx("span",{children:C.label}),C.note&&v.jsxs("span",{className:"gl-note",children:["· ",C.note]})]}),v.jsx("div",{className:"conversation-group",children:C.contacts.map(R=>v.jsx(Af,{c:R,grouped:C.rootId!==null,active:i===R.id,onClick:()=>e.onSelect(R.id)},R.id))})]},C.id)),m.length>0&&v.jsxs("div",{children:[v.jsx("div",{className:"group-label",children:v.jsx("span",{children:"Pending"})}),v.jsx("div",{className:"conversation-group",children:m.map(C=>v.jsx(Af,{c:C,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(C.id.slice(8)),onReject:()=>e.onRejectPending(C.id.slice(8))},C.id))})]}),w&&v.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]})]})}const Mf=e=>`chat-message-${encodeURIComponent(e)}`,Ld=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function bx(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),c=k.useRef(i);c.current=i;const d=1,h=Kk,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),y=k.useRef(p()),w=R=>{const A=l.current,D=a.current,B=Ld();if(A&&(A.style.transform=R&&!B?`translateX(${R}px)`:""),D){const I=Math.min(1,Math.abs(R)/h);D.style.opacity=String(I),D.style.transform=B?"scale(1)":`scale(${.5+.5*I})`}},S=(R,A)=>{const D=y.current;if(D.id!==R)return;const B=A&&D.mode==="drag"&&ez(D.distance,D.samples);y.current=p(),l.current?.classList.remove("swiping"),a.current?.classList.remove("armed"),w(0);const I=s.current;I?.hasPointerCapture?.(R)&&I.releasePointerCapture(R),B&&c.current()};k.useEffect(()=>{const R=s.current;if(!R)return;const A=D=>S(D.pointerId,!1);return R.addEventListener("lostpointercapture",A),()=>{R.removeEventListener("lostpointercapture",A);const D=y.current.id;D!==-1&&S(D,!1)}},[]);const E=R=>{const A=R.target,D=window.getSelection?.();!n||!R.isPrimary||R.pointerType==="mouse"||R.button!==0||y.current.id!==-1||D&&!D.isCollapsed||A.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(y.current={id:R.pointerId,x0:R.clientX,y0:R.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:R.clientX,time:R.timeStamp}]},w(0))},T=R=>{const A=y.current;if(A.id!==R.pointerId||A.mode==="idle")return;const D=R.clientX-A.x0,B=R.clientY-A.y0,I=window.getSelection?.();if(I&&!I.isCollapsed){S(R.pointerId,!1);return}if(A.mode==="maybe"){const Y=ZF(D,B);if(Y==="pending")return;if(Y==="drag"&&Math.sign(D)===d)A.mode="drag",R.currentTarget.setPointerCapture?.(R.pointerId),l.current?.classList.add("swiping");else{A.mode="idle";return}}R.preventDefault();const q=R.timeStamp;A.samples.push({x:R.clientX,time:q}),A.samples=A.samples.filter(Y=>q-Y.time<=120);let $=D*d;$<0&&($=0),$>h&&($=h+($-h)*.35),$=Math.min($,m),A.distance=$;const K=$*d,j=Math.abs(K)>=h;j!==A.armed&&(A.armed=j,a.current?.classList.toggle("armed",j),j&&navigator.vibrate?.(10)),w(K)},C=R=>{const A=y.current;A.id===R.pointerId&&A.mode==="drag"&&(A.samples.push({x:R.clientX,time:R.timeStamp}),A.distance=Math.max(0,R.clientX-A.x0),A.armed=A.distance>=h),S(R.pointerId,!0)};return v.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:E,onPointerMove:T,onPointerUp:C,onPointerCancel:R=>S(R.pointerId,!1),onLostPointerCapture:R=>S(R.pointerId,!1),children:[n&&v.jsx("span",{className:"swipe-cue",ref:a,"aria-hidden":!0,children:v.jsx(Se,{name:"reply",size:16})}),v.jsx("div",{className:"bubble-wrap",ref:l,children:e.children}),e.after]})}function az(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[l,a]=k.useState(!1),[c,d]=k.useState(null),[h,m]=k.useState(null),[p,y]=k.useState(null),[w,S]=k.useState(null),[E,T]=k.useState(null),[C,R]=k.useState(!1),A=k.useRef(null),D=k.useRef(null),[B,I]=k.useState(null),[q,$]=k.useState(!1),[K,j]=k.useState(!1),[Y,W]=k.useState(!1),[ue,Z]=k.useState(null),[ee,ge]=k.useState(!1),Ce=k.useRef(null),X=k.useRef(null),ce=k.useRef(!1),P=k.useRef(null),L=k.useRef(!1),[G,M]=k.useState(!1),[J,he]=k.useState(0),me=k.useRef(null),ve=k.useRef(!0),Ee=k.useRef(null),Re=k.useRef(0),Be=k.useRef(null),ft=k.useRef(new Map),qe=k.useRef(0),lt=k.useRef(null),_e=k.useRef(null),tn=k.useRef(0),Rt=k.useRef(null),Xe=typeof window<"u"&&window.matchMedia("(max-width: 860px)").matches,mt=(z=!1)=>{R(!1),z&&requestAnimationFrame(()=>A.current?.focus())};k.useEffect(()=>{if(!C||Xe)return;D.current?.querySelector(".idcard-close")?.focus();const z=re=>{re.key==="Escape"&&(re.preventDefault(),mt(!0))};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[C,Xe]),k.useEffect(()=>{s(""),m(null),y(null),d(null),S(null),T(null),R(!1),I(null),$(!1),j(!1),W(!1),Re.current+=1,Z(null),ge(!1),ft.current.clear(),lt.current=null,_e.current=null},[t?.id]),k.useEffect(()=>{if(!p)return;const z=p.reply?.wireId;n.some(O=>O.kind!=="file"&&O.dir==="out"&&!!O.wireId&&!p.wireIds.has(O.wireId)&&O.text===p.text&&(O.replyTo?.wireId??void 0)===z)&&(y(null),m(null),s(O=>O===p.draft?"":O),S(O=>O===p.reply?null:O))},[n,p]);const dt=!!c?.wireId&&n.some(z=>z.wireId===c.wireId),He=k.useMemo(()=>c&&!dt?[...n,c.message]:n,[n,c,dt]);k.useEffect(()=>{dt&&d(null)},[dt]),k.useLayoutEffect(()=>{const z=X.current;if(!z)return;z.style.height="0px";const re=Math.max(44,Math.min(z.scrollHeight,132));z.style.height=`${re}px`,z.style.overflowY=z.scrollHeight>132?"auto":"hidden"},[i,t?.id]);const Dt=z=>{const re=P.current;if(!re)return;const O=Math.max(0,re.scrollHeight-re.clientHeight);if(Math.abs(re.scrollTop-O)<1){lt.current=null,_e.current=null;return}const te=z&&!Ld();lt.current=te?O:null,_e.current=te?re.scrollTop:null,te?re.scrollTo({top:O,behavior:"smooth"}):re.scrollTop=O},_t=()=>{me.current===null&&(me.current=requestAnimationFrame(()=>{me.current=null;const z=P.current;if(!z)return;const re=z.scrollHeight-z.clientHeight-z.scrollTop>48;M(re),re||he(0)}))};k.useLayoutEffect(()=>{if(!t){Ee.current=null,ve.current=!0,tn.current=0;return}const z=P.current;if(!z)return;const re=Ee.current!==t.id,O=tn.current,te=He.length!==O,de=He.at(-1),je=de?de.wireId||`${de.date}:${de.text}`:null,Pe=Rt.current;if(tn.current=He.length,Rt.current=je,!re&&!te&&lt.current===null&&(ve.current=z.scrollHeight-z.clientHeight-z.scrollTop<=48),re||ve.current)Dt(te&&!re&&Ee.current!==null),ve.current=!0;else if(te&&He.length>O&&je!==Pe){const pe=Pe===null?-1:He.findIndex(Oe=>(Oe.wireId||`${Oe.date}:${Oe.text}`)===Pe);he(Oe=>Oe+Math.max(1,He.length-Math.max(0,pe+1)))}Ee.current=t.id,_t()},[t,He.length]),k.useLayoutEffect(()=>{if(L.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const z=P.current,re=document.getElementById(`unread-${Mf(e.unreadOpen.wireId)}`);!z||!re||(z.scrollTop=Math.max(0,re.offsetTop-16),ve.current=!1,L.current=!0,_t())},[e.unreadOpen,He.length]),k.useLayoutEffect(()=>{const z=window.location.hash;if(!z.startsWith("#chat-message-"))return;const re=document.getElementById(z.slice(1));re&&(re.scrollIntoView({block:"center"}),ve.current=!1)},[t?.id,He.length]),k.useLayoutEffect(()=>{const z=Be.current,re=P.current;if(z===null||!re)return;const O=requestAnimationFrame(()=>{Be.current===z&&(re.scrollTop=z.top+re.scrollHeight-z.height,Be.current=null)});return()=>cancelAnimationFrame(O)},[He.length]),k.useEffect(()=>{const z=P.current;if(!z||typeof ResizeObserver>"u")return;const re=z.firstElementChild;if(!re)return;const O=new ResizeObserver(()=>{ve.current&&Dt(lt.current!==null),_t()});return O.observe(re),O.observe(z),()=>{O.disconnect(),me.current!==null&&cancelAnimationFrame(me.current)}},[t?.id]);const Un=async z=>{const re=++Re.current;m(null),W(!0);try{if(z.size>ss&&Uk(z.type,z.name)){const te=await UF(z,ss);if(re!==Re.current)return;I({filename:te.filename,mime:te.mime,bytes:te.bytes,originalSize:te.originalSize});return}if(z.size>ss){m(`"${z.name}" is ${$r(z.size)} — files up to ${$r(ss)} can be sent.`);return}const O=await z.arrayBuffer();if(re!==Re.current)return;I({filename:z.name||"file",mime:z.type||"application/octet-stream",bytes:new Uint8Array(O)})}catch(O){re===Re.current&&m(`Photo optimization failed: ${O instanceof Error?O.message:String(O)}`)}finally{re===Re.current&&W(!1)}},rr=()=>{!B||!e.onSendFile||K||(j(!0),e.onSendFile(B,w?.wireId).then(()=>{I(null),S(null)}).catch(z=>m(`File send failed: ${String(z)} — it was not delivered.`)).finally(()=>j(!1)))},dn=e.onDraftChange;k.useEffect(()=>(dn?.(i.trim().length>0||l),()=>dn?.(!1)),[i,l,dn]);const Q=new Map;for(const z of He)z.wireId&&Q.set(z.wireId,z);const le=k.useMemo(()=>{const z=new Map;for(const re of He)z.set(re,re.kind==="file"?null:re.dir==="in"?d2(t?.announcedName??"",re.text):null);return z},[He,t?.announcedName]),fe=z=>le.get(z)??null,Le=z=>{if(z.dir==="out")return"You";const re=fe(z);return re&&re.variant==="chat"?re.author:t?.name??"Them"},Fe=z=>{if(z.kind==="file")return z.mime?.startsWith("image/")?"Photo":io(z.mime??"",z.filename??"")?"Voice message":z.filename||"File";const re=fe(z);return re?re.text||x2(re):z.text},gt=z=>{if(!z.replyTo)return null;const re=Q.get(z.replyTo.wireId);return re?{author:Le(re),text:Fe(re)}:{author:"",text:"Original message"}};if(!t)return e.emptyOverride?v.jsx(v.Fragment,{children:e.emptyOverride}):v.jsx("div",{className:"detail",children:v.jsxs("div",{className:"detail-empty",children:[v.jsx(Se,{name:"chat"}),v.jsxs("div",{children:[v.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),v.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const Lt=async()=>{const z=i,re=z.trim(),O=!!p&&z===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!re||ce.current||O)return;p&&y(null),ce.current=!0,a(!0),m(null);const te=w,de=te?.wireId,je=new AbortController;let Pe=!1,pe=0;s(""),S(null);const Oe=`optimistic-${++qe.current}`;d({key:Oe,wireId:null,message:{dir:"out",text:re,date:new Date().toISOString(),read:!0,wireId:"",replyTo:de?{wireId:de}:null}});try{const xt=await Promise.race([e.onSend(re,de,je.signal),new Promise((Ye,wt)=>{pe=window.setTimeout(()=>{Pe=!0,je.abort(),wt(new Error("send timeout"))},oz)})]);xt?(ft.current.set(xt,Oe),d(Ye=>Ye?.key===Oe?{...Ye,wireId:xt}:Ye)):d(Ye=>Ye?.key===Oe?null:Ye),y(null)}catch(xt){d(null),s(Ye=>Ye===""?z:Ye),S(Ye=>Ye===null?te:Ye),Pe||!(xt instanceof nd)?(y({draft:z,text:re,reply:te,wireIds:new Set(n.flatMap(Ye=>Ye.wireId?[Ye.wireId]:[]))}),m(`${Pe?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(xt)} — the message was not delivered.`)}finally{window.clearTimeout(pe),ce.current=!1,a(!1)}},nt=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId,nn=z=>{z.wireId&&S({wireId:z.wireId,author:Le(z),text:Fe(z)})};return v.jsxs("div",{className:"detail detail-chat",children:[v.jsxs("div",{className:"detail-head",children:[v.jsxs("div",{className:"conv-peer",children:[v.jsx("button",{className:"icon-btn detail-back",onClick:e.onBack,children:v.jsx(Se,{name:"back"})}),v.jsx("div",{className:"avatar accent",children:t.initials}),v.jsxs("div",{className:"conv-peer-meta",children:[E!==null?v.jsx("input",{className:"field name-edit",value:E,autoFocus:!0,placeholder:t.name,onChange:z=>T(z.target.value),onKeyDown:z=>{z.key==="Enter"?(e.onRename?.(E),T(null)):z.key==="Escape"&&T(null)},onBlur:()=>T(null)}):v.jsxs("div",{className:"conv-peer-name",children:[t.name,e.onRename&&v.jsx("button",{className:"icon-btn name-pencil",title:"Rename (only changes how they appear to you)",onClick:()=>T(t.name),children:v.jsx(Se,{name:"edit",size:13})})]}),e.syncing&&v.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[v.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&(t.roleId?v.jsxs("button",{ref:A,className:"idchip","aria-haspopup":"dialog","aria-expanded":C,"aria-controls":"identity-details",onClick:()=>R(!0),children:[v.jsx(Se,{name:"shield",size:11}),"verified role of ",t.rootName]}):t.status!=="pending"&&v.jsxs("button",{ref:A,className:"idchip quiet","aria-haspopup":"dialog","aria-expanded":C,"aria-controls":"identity-details",onClick:()=>R(!0),children:[v.jsx(Se,{name:"lock",size:11}),"verified identity"]}))]})]}),C&&(Xe?v.jsxs(mo,{title:"Verified identity",onClose:()=>mt(!0),className:"identity-details-modal",contentId:"identity-details",children:[t.roleId&&v.jsxs("p",{children:["This is the role ",v.jsxs("strong",{children:["“",t.roleId,"”"]})," of ",v.jsx("strong",{children:t.rootName})," — the link is cryptographically signed, not self-declared."]}),v.jsx("div",{className:"idcard-fp mono",children:t.id}),v.jsx("p",{className:"idcard-note",children:"This id is the fingerprint of their key. Names are what people show you; the fingerprint is what guarantees you're always talking to the same identity — no one can impersonate it. Renaming only changes how they appear to you."})]}):v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"pop-backdrop","aria-hidden":"true",onClick:()=>mt(!0)}),v.jsxs("div",{id:"identity-details",ref:D,className:"idcard anim-scale",role:"dialog","aria-modal":"false","aria-labelledby":"identity-details-title",children:[v.jsxs("div",{className:"idcard-head",children:[v.jsx("h4",{id:"identity-details-title",children:"Verified identity"}),v.jsx("button",{className:"icon-btn idcard-close","aria-label":"Close verified identity",onClick:()=>mt(!0),children:v.jsx(Se,{name:"close",size:16})})]}),t.roleId&&v.jsxs("p",{children:["This is the role ",v.jsxs("strong",{children:["“",t.roleId,"”"]})," of ",v.jsx("strong",{children:t.rootName})," — the link is cryptographically signed, not self-declared."]}),v.jsx("div",{className:"idcard-fp mono",children:t.id}),v.jsx("p",{className:"idcard-note",children:"This id is the fingerprint of their key. Names are what people show you; the fingerprint is what guarantees you're always talking to the same identity — no one can impersonate it. Renaming only changes how they appear to you."})]})]})),v.jsxs("div",{className:"conv-actions",children:[v.jsxs("button",{className:"btn sm",title:"Shared photos, files, and links",onClick:()=>ge(!0),children:[v.jsx(Se,{name:"paperclip",size:14}),"Media"]}),v.jsxs("button",{className:"btn sm danger",title:"Remove contact",onClick:e.onRemove,children:[v.jsx(Se,{name:"trash",size:14}),"Remove"]})]})]}),v.jsx("div",{className:"messages",ref:P,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:z=>{const re=z.currentTarget,O=re.scrollHeight-re.clientHeight-re.scrollTop;if(lt.current!==null){const te=_e.current;if(te===null||re.scrollTop>=te-1){_e.current=re.scrollTop,O<=4&&(lt.current=null,_e.current=null);return}lt.current=null,_e.current=null}ve.current=O<=48,_t()},onPointerDown:()=>{lt.current=null,_e.current=null},onTouchStart:()=>{lt.current=null,_e.current=null},onWheel:()=>{lt.current=null,_e.current=null},onDragOver:z=>{e.onSendFile&&z.preventDefault()},onDrop:z=>{if(!e.onSendFile)return;z.preventDefault();const re=z.dataTransfer.files?.[0];re&&Un(re)},children:v.jsxs("div",{className:"messages-inner",children:[v.jsxs("div",{className:"e2e-note",children:[v.jsx(Se,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&v.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{ve.current=!1;const z=P.current;Be.current=z?{height:z.scrollHeight,top:z.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),v.jsx(HP,{initial:!1,children:He.map((z,re)=>{const O=z===c?.message?c.key:z.wireId&&ft.current.get(z.wireId)||z.wireId||`${z.date}-${(e.hiddenEarlier??0)+re}`,te=Mf(z.wireId||O),de=He[re-1],je=He[re+1],Pe=fe(z),pe=Bt=>{if(!Bt)return null;const Ct=fe(Bt);return Ct?Ct.variant==="system"?"room:system":`room:chat:${Ct.author}${Ct.role}`:Bt.dir},Oe=pe(z),xt=!!de&&pe(de)===Oe&&Oe!=="room:system",Ye=!!je&&pe(je)===Oe&&Oe!=="room:system",wt=(z.dir==="out"?"out":"in")+(xt?" cont-top":"")+(Ye?" cont-bot":""),At=z.wireId?v.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>nn(z),children:v.jsx(Se,{name:"reply",size:15})}):null;if(Pe&&Pe.variant==="system"){const Bt=Pe.presentation??"system";return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsxs("div",{className:`room-system room-${Bt}-card`,role:"note",children:[Pe.label&&v.jsx("span",{className:"room-system-label",children:Pe.label}),Pe.roomName&&v.jsx("strong",{className:"room-card-name",children:Pe.roomName}),v.jsx(wx,{text:Pe.text,className:"room-system-text message-markdown"}),!!Pe.details?.length&&v.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:Pe.details.map(Ct=>v.jsx("li",{children:Ct},Ct))}),v.jsxs("span",{className:"room-card-provenance",children:[Pe.authoredBy&&v.jsx("span",{className:"room-card-author",children:Pe.authoredBy}),v.jsx("span",{className:"room-system-at",children:bs(Pe.authoredAt||z.date)})]})]})]},O)}if(z.kind==="file"){const Bt=b0(z.wireId)??{id:z.wireId,dir:z.dir,filename:z.filename??"file",mime:z.mime??"application/octet-stream",size:0,date:z.date};return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(bx,{dir:z.dir==="out"?"out":"in",rowClass:wt,canReply:!!z.wireId,onReply:()=>nn(z),after:At,children:v.jsx("div",{className:`ours-message ours-message-file ours-message--${z.dir}`,children:v.jsx(SD,{rec:Bt,receipt:z.receipt,receiptless:z.receiptless,onPreview:Z,onFetch:e.onFetchFile})})})]},O)}const rt=gt(z);return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(bx,{dir:z.dir==="out"?"out":"in",rowClass:wt,canReply:!!z.wireId,onReply:()=>nn(z),after:At,children:v.jsxs("div",{className:`ours-message ours-message--${z.dir}`,children:[rt&&v.jsxs("div",{className:"quote",children:[rt.author&&v.jsx("span",{className:"quote-author",children:rt.author}),v.jsx("span",{className:"quote-text",children:rt.text})]}),Pe&&!xt&&v.jsxs(v.Fragment,{children:[Pe.roomName&&v.jsx("div",{className:"room-message-room",children:Pe.roomName}),v.jsxs("div",{className:"room-author",children:[v.jsx("span",{className:"room-author-name",children:Pe.author}),Pe.role&&v.jsx("span",{className:"room-author-role",children:Pe.role})]})]}),v.jsx(wx,{text:Pe?Pe.text:z.text}),v.jsxs("div",{className:"bubble-at",children:[bs(Pe?.authoredAt||z.date),z.dir==="out"&&v.jsx(C0,{receipt:z.receipt,receiptless:z.receiptless})]})]})})]},O)})}),v.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),G&&v.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":J?`Jump to latest, ${J} new messages`:"Jump to latest",onClick:z=>{const re=z.currentTarget===document.activeElement;he(0),Dt(!0),re&&requestAnimationFrame(()=>P.current?.focus({preventScroll:!0}))},children:[v.jsx("span",{children:"Jump to latest"}),!!J&&v.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:J})]}),h&&v.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>void Lt(),children:"retry"})})]}),v.jsxs("div",{className:"composer-wrap",children:[w&&v.jsxs("div",{className:"reply-bar",children:[v.jsx("div",{className:"reply-bar-line"}),v.jsxs("div",{className:"reply-bar-body",children:[v.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),v.jsx("div",{className:"reply-bar-text",children:w.text})]}),v.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:v.jsx(Se,{name:"close",size:16})})]}),B&&v.jsx(k1,{att:B,sending:K,onSend:rr,onDiscard:()=>I(null)}),Y&&v.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),v.jsxs("div",{className:"composer"+(q?" recording":""),children:[e.onSendFile&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:Ce,type:"file",style:{display:"none"},onChange:z=>{const re=z.target.files?.[0];re&&Un(re),z.target.value=""}}),v.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:K||Y||q,onClick:()=>Ce.current?.click(),children:v.jsx(Se,{name:"paperclip",size:18})}),v.jsx(S1,{disabled:K||Y||!!B,onReady:z=>{$(!1),I(z)},onError:z=>{$(!1),m(z)},onActiveChange:$},t.id)]}),v.jsx("textarea",{ref:X,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":l,onChange:z=>s(z.target.value),onKeyDown:z=>{z.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!z.shiftKey&&(z.preventDefault(),Lt()):z.key==="Escape"&&S(null)}}),v.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:z=>{z.button===0&&document.activeElement===X.current&&z.preventDefault()},onClick:()=>void Lt(),disabled:l||nt||!i.trim(),title:nt?"Delivery status unknown — edit before sending again":void 0,children:[v.jsx(Se,{name:"send",size:16}),v.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),ue&&(Zl(ue.filename,ue.mime)?v.jsx(AF,{rec:ue,onClose:()=>Z(null)}):v.jsx(RF,{rec:ue,onClose:()=>Z(null),onSendText:e.onSend,onSendFile:e.onSendFile})),ee&&v.jsx(NF,{messages:n,indexOffset:e.hiddenEarlier??0,onClose:()=>ge(!1),onPreview:z=>{ge(!1),Z(z)},onJump:z=>{document.getElementById(Mf(z))?.scrollIntoView({behavior:Ld()?"auto":"smooth",block:"center"}),ge(!1)}})]})}const Xk=3;function lz(e,t,n=Xk){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function uz(e,t){return e.filter(n=>n.id!==t)}const cz=6e3,fz=lz,dz=uz;function hz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((a,c,d)=>{const h=Date.now(),m={id:`${a}:${h}:${n.current++}`,cid:a,name:c,preview:"",at:h};t(p=>fz(p,m,Xk))},[]),s=k.useCallback(a=>t(c=>dz(c,a)),[]),l=k.useCallback(a=>t(c=>c.filter(d=>d.cid!==a)),[]);return{toasts:e,push:i,dismiss:s,clear:l}}function pz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,l]=k.useState(!1),[a,c]=k.useState(!1),d=s||a;return k.useEffect(()=>{if(d)return;const h=setTimeout(()=>i(t.id),cz);return()=>clearTimeout(h)},[t.id,d,i]),v.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[v.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[v.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:Ss(t.name)}),v.jsxs("span",{className:"msg-text",children:[v.jsx("strong",{className:"msg-name",children:t.name}),v.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),v.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:v.jsx(Se,{name:"close",size:15})})]})}function mz(e){return v.jsx(v.Fragment,{children:e.items.map(t=>v.jsx(pz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function gz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Mh(()=>import("./browser-Dyn5HxZw.js").then(l=>l.b),[]).then(l=>{l.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),v.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:v.jsx("canvas",{ref:t,"data-testid":"qr-canvas","data-invite":n,width:i,height:i,style:{borderRadius:8,border:"1px solid var(--line)",imageRendering:"pixelated"}})})}function yz(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),l=k.useRef(!0),[a,c]=k.useState("requesting"),[d,h]=k.useState(""),m=k.useCallback(()=>{s.current&&cancelAnimationFrame(s.current),i.current&&(i.current.getTracks().forEach(w=>w.stop()),i.current=null),t.current&&(t.current.srcObject=null)},[]),p=k.useCallback(w=>{i.current=w;const S=t.current;S.srcObject=w,S.setAttribute("playsinline","true"),S.play();const E=n.current,T=E.getContext("2d"),C=()=>{if(l.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const R=S.videoWidth||320,A=S.videoHeight||240;E.width=R,E.height=A,T.drawImage(S,0,0,R,A);const D=T.getImageData(0,0,R,A);Mh(()=>import("./jsQR-C0lC08lI.js").then(B=>B.j),[]).then(B=>{const I=B.default,q=I(D.data,D.width,D.height,{inversionAttempts:"dontInvert"});if(q&&q.data&&l.current){m(),e.onDecode(q.data);return}l.current&&(s.current=requestAnimationFrame(C))})}else s.current=requestAnimationFrame(C)};s.current=requestAnimationFrame(C)},[m,e]);k.useEffect(()=>{if(l.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!l.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!l.current)return;const S=w.name??"";S==="NotAllowedError"||S==="PermissionDeniedError"?c("denied"):S==="NotFoundError"||S==="DevicesNotFoundError"?c("nocamera"):(c("error"),h(w.message??String(w)))}),()=>{l.current=!1,m()}},[]);const y=()=>{m(),e.onClose()};return v.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(a==="requesting"||a==="scanning")&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:a==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),v.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[v.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),v.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),a==="scanning"&&v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx("div",{style:{width:160,height:160,borderRadius:12,border:"2px solid var(--accent)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.4)"}})})]})]}),a==="denied"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Se,{name:"shield",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"Camera permission was denied. To scan QR codes, allow camera access in your browser settings, then try again. Or paste the invite text below instead."})]}),a==="nocamera"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Se,{name:"close",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),a==="error"&&v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:v.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",d||"unknown error",". Paste the invite text below instead."]})}),v.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:y,children:a==="scanning"?v.jsxs(v.Fragment,{children:[v.jsx(Se,{name:"close",size:14}),"Cancel scan"]}):v.jsxs(v.Fragment,{children:[v.jsx(Se,{name:"close",size:14}),"Close scanner"]})})]})}function vz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[l,a]=k.useState(""),[c,d]=k.useState(null),[h,m]=k.useState("one_time"),[p,y]=k.useState(""),[w,S]=k.useState(""),[E,T]=k.useState(!1),[C,R]=k.useState(null),[A,D]=k.useState(null),[B,I]=k.useState(!1),[q,$]=k.useState(null),K=k.useRef(!1),j=async()=>{if(!K.current){K.current=!0,T(!0),D(null),R(null);try{m(i),d(await e.onCreate(i,i==="one_time"&&l.trim()||void 0))}catch(W){D(W instanceof Error?W.message:String(W))}finally{K.current=!1,T(!1)}}},Y=v.jsx($k,{className:"modal-tabs",label:"Invite mode",options:[{id:"generate",label:"Generate invite"},{id:"accept",label:"Accept invite"}],value:t,onChange:n,idPrefix:"invite-tab",panelId:"invite-panel"});return v.jsx(mo,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{K.current||e.onClose()},tabs:Y,children:v.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[v.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",v.jsx("strong",{children:e.identity.name})," · ",v.jsxs("span",{className:"mono",children:["@",yh(e.identity.cid)]})]}),v.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),v.jsx("input",{className:"field",value:l,onChange:W=>a(W.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):v.jsx("p",{className:"onb-warning","data-testid":"public-invite-warning",style:{margin:0,fontSize:"0.9rem"},children:"Anyone with this invite can connect until you revoke it. It has no expiry and stays valid across server restarts."}),v.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:E,onClick:()=>void j(),children:E?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(W=>W.mode==="public").length===0&&v.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(W=>W.mode==="public").map(W=>v.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[v.jsx("span",{className:"mono",children:W.invite_id}),v.jsxs("p",{className:"muted",children:["Created ",W.created?b2(W.created):"unknown"," · Active until revoked · No expiry"]}),q===W.invite_id?v.jsxs("span",{children:[v.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(W.invite_id).then(()=>($(null),e.onRefresh())).catch(ue=>D(String(ue))),children:"Confirm revoke"})," ",v.jsx("button",{className:"btn sm",onClick:()=>$(null),children:"Keep it"})]}):v.jsx("button",{className:"btn sm",onClick:()=>$(W.invite_id),children:"Revoke"})]},W.invite_id))]}),C&&v.jsx("p",{className:"muted",children:C}),A&&v.jsx("p",{className:"onb-error",children:A})]}),t==="generate"&&c&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted","data-testid":h==="public"?"public-result-note":void 0,children:h==="public"?"Shown only on this screen. Copy it now; the text cannot be recovered later. The invite stays active until revoked.":`Send this invite to ${l.trim()||"your contact"}. It can be redeemed once.`}),v.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:W=>W.currentTarget.select()}),h==="one_time"&&v.jsx(gz,{text:c}),v.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>R("Copied to clipboard.")),children:[v.jsx(Se,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&v.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{d(null),a(""),e.onRefresh()},children:"Done — hide invite"}),C&&v.jsx("p",{className:"muted",children:C})]}),t==="accept"&&v.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:W=>{W.preventDefault(),!(!p.trim()||E)&&(T(!0),D(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{R("Invite accepted — the contact will appear once the sender verifies your identity."),y(""),S("")}).catch(ue=>D(String(ue))).finally(()=>T(!1)))},children:[v.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),B?v.jsx(yz,{onDecode:W=>{y(W),I(!1)},onClose:()=>I(!1)}):v.jsxs("button",{type:"button",className:"btn",onClick:()=>I(!0),children:[v.jsx(Se,{name:"monitor",size:15}),"Scan QR code"]}),v.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:W=>y(W.target.value),placeholder:"Paste invite text…"}),v.jsx("input",{className:"field",value:w,onChange:W=>S(W.target.value),placeholder:"Rename them (optional)",maxLength:64}),v.jsx("button",{className:"btn primary",type:"submit",disabled:E||!p.trim(),children:E?"Connecting…":"Add contact"}),C&&v.jsx("p",{className:"muted",children:C}),A&&v.jsx("p",{className:"onb-error",children:A})]})]})})}function xz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[l,a]=k.useState(null),[c,d]=k.useState(e.push.preview),h=mA(),m=!e.workerSupported||e.push.status==="unsupported"?h??"Unavailable — requires a secure browser with service-worker support.":e.push.status==="needs-permission"?h??"Needs permission — allow notifications, then choose Enable or Repair.":e.push.status==="on"?"On — this browser and the server agree on the current Web Push configuration.":e.push.status==="repairing"?"Repairing — checking the browser subscription and server acknowledgement…":e.push.status==="error"?"Repair needed — the browser and server could not confirm the same subscription.":"Off — enable notifications for this browser.";return v.jsxs(mo,{title:"Settings",onClose:e.onClose,wide:!0,children:[v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Display name"}),v.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Your address"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),v.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Public bio"}),v.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),a(null)}}),v.jsx("button",{className:"btn sm",onClick:()=>{a(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>a(String(p)))},children:i?"Saved":"Save bio"}),l&&v.jsx("p",{className:"onb-error",children:l})]}),v.jsxs("label",{style:{display:"flex",gap:9},children:[v.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Notifications"}),v.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&v.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),v.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[v.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>d("full")})," Full — sender and message text or filename"]}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>d("private")})," Private — generic content only"]})]}),v.jsx("p",{className:"muted",children:"Full previews can expose sender names, message text, and filenames on the lock screen. The push provider still sees delivery endpoint, timing, and payload size metadata in either mode."}),v.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&v.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):v.jsx("button",{className:"btn primary",disabled:e.busy||!e.workerSupported||e.push.status==="unsupported",onClick:()=>void e.onPushAction(e.push.status==="error"||e.push.blocked?"repair":"enable",c),children:e.busy?"Repairing…":e.push.status==="error"||e.push.blocked?"Repair":"Enable notifications"})})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"App status"}),v.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.updateAvailable&&v.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Build"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function wz(e,t,n,i,s=6e4){return!t||!t.sha?"current":t.sha===e?(n.remoteSha=null,n.firstMismatchAt=null,"current"):(n.remoteSha=t.sha,(n.firstMismatchAt===null||n.firstMismatchAt===void 0)&&(n.firstMismatchAt=i),n.controllerChanged?"newer-available":i-n.firstMismatchAt>=s?"stuck":"newer-available")}const kz="254d7873c6f3999a326d53c04cafe32fea2f2aed",Sz=15*6e4,bz=6e4,Cz=wz;async function Ez(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Tz(e){const t={remoteSha:null,firstMismatchAt:null,controllerChanged:!1},n=()=>{t.controllerChanged=!0};navigator.serviceWorker?.addEventListener("controllerchange",n);let i=!1;const s=async()=>{const d=await Ez(),h=Cz(kz,d,t,Date.now(),bz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(d.sha))},l=setTimeout(()=>void s(),5e3),a=setInterval(()=>void s(),Sz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(l),clearInterval(a),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Pz(e){try{const t=await navigator.serviceWorker.getRegistrations();await Promise.all(t.map(i=>i.unregister()));const n=await caches.keys();await Promise.all(n.map(i=>caches.delete(i)))}catch{}return location.replace(location.pathname+"?v="+encodeURIComponent(e)),new Promise(()=>{})}function Rz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Cx=[0,100,400,1e3,3e3,6e3],Ex=e=>new Promise(t=>setTimeout(t,e)),Tx={delivered:1,read:2},Px="ours-dark-v3",Rx="#chat-message-",Ax=jl,Az=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function Yk(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const l={dir:s.dir,text:s.text,date:s.date,read:s.read,wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:null,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id};s.wire_id?n.set(s.wire_id,l):i.push(l)}for(const s of t){const l=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:l?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:l?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:l?.receipt})}return[...i,...n.values()].sort((s,l)=>{const a=Ax(s.date)-Ax(l.date);return a===0?s.wireId.localeCompare(l.wireId):a})}function Mz(e){const t={};for(const n of Object.values(e.roots??{}))t[n.root_cid]={label:n.root_name,note:"Verified identity"};return t}function Nz(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],l=ci(e,i.container_id),c=Yk(l,t[i.container_id]??[]).at(-1),d=Dl(i);return{id:i.container_id,name:d,announcedName:i.name,initials:Ss(d),when:c?S2(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?N2(c.filename,c.mime):l?.preview??c?.text??"",unread:l?.unread??0,status:"active",root:s?.root_cid??null,sub:s?`role “${s.role_id}” of ${s.root_name}`:"",roleId:s?.role_id??null,rootName:s?.root_name??null,mine:!1,kind:s?"agent":"person"}}),...e.contacts.pending.map(i=>{const s=Dl(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:Ss(s),when:"",activityAt:"",last:`${i.queued} queued · approval required`,unread:0,status:"pending",root:null,sub:"",roleId:null,rootName:null,mine:!1,kind:"person"}})]}function jz(){return v.jsx(Iz,{})}function Iz(){const e=k.useRef(uA(Jy(window.location.pathname))).current,[t,n]=k.useReducer(nv,e),[i,s]=k.useState(null),l=k.useRef(0),a=k.useRef(null),c=k.useRef(t),d=k.useRef(new aA),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[y,w]=k.useState({}),S=k.useRef(y),[E,T]=k.useState(null),C=k.useRef(new Set),[R,A]=k.useState(null),D=k.useRef(R),B=k.useRef(!1),[I,q]=k.useState([]),[$,K]=k.useState(null),[j,Y]=k.useState(()=>localStorage.getItem(Px)!=="0"),[W,ue]=k.useState(null),[Z,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[ge,Ce]=k.useState({status:"unsupported",preview:"full"}),[X,ce]=k.useState(!1),[P,L]=k.useState(!1),G=k.useRef(null),M=k.useRef(null),[J,he]=k.useState(()=>window.location.hash.startsWith(Rx)),{toasts:me,push:ve,dismiss:Ee,clear:Re}=hz(),Be=k.useCallback((O=!1)=>{L(!1),O&&G.current?.focus()},[]);k.useEffect(()=>{P&&requestAnimationFrame(()=>M.current?.querySelector('[role="menuitem"]')?.focus())},[P]);const ft=O=>{const te=[...M.current?.querySelectorAll('[role="menuitem"]')??[]],de=te.indexOf(document.activeElement);if(O.key==="Escape"){O.preventDefault(),Be(!0);return}if(O.key==="Tab"){O.preventDefault();const Pe=O.shiftKey;L(!1),requestAnimationFrame(()=>{const pe=[...document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(Ye=>Ye.offsetParent!==null&&!M.current?.contains(Ye)),Oe=G.current?pe.indexOf(G.current):-1;(Oe<0?G.current:pe[Oe+(Pe?-1:1)]??G.current)?.focus()});return}if(!["ArrowDown","ArrowUp","Home","End"].includes(O.key)||te.length===0)return;O.preventDefault();const je=O.key==="Home"?0:O.key==="End"?te.length-1:O.key==="ArrowUp"?(de-1+te.length)%te.length:(de+1)%te.length;te[je]?.focus()},qe=k.useCallback(O=>{c.current=nv(c.current,O),n(O)},[]),lt=k.useCallback(O=>{B.current=O},[]);k.useEffect(()=>{c.current=t},[t]),D.current=R,S.current=y,k.useMemo(()=>(hv(Object.values(y).flat()),null),[y]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",j),()=>document.documentElement.classList.remove("theme-dark")),[j]);const _e=k.useCallback(O=>qe({type:"error",message:Az(O)}),[qe]),tn=k.useCallback(()=>{const O=c.current;return{visibility:document.visibilityState,appRoute:O.route.name==="chats"?"chats":"other",selectedContactCid:si(O),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:O.mobileDetailOpen,conversationCoveringDialogOpen:D.current!==null}},[]),Rt=k.useCallback(async(O,te=!0)=>{try{const de=await Qe.conversation(O);return qe({type:"page",contactCid:O,page:de}),de}catch(de){return te&&_e(de),null}},[qe,_e]),Xe=k.useCallback(async(O,te=!0)=>{try{const de=await Qe.files(O);return hv(de.files),w(je=>({...je,[O]:de.files})),de.files}catch(de){return te&&_e(de),null}},[_e]);k.useEffect(()=>Tz({onUpdateAvailable:()=>ee(O=>({...O,updateAvailable:!0})),onStuck:O=>{Pz(O)}}),[]);const mt=k.useCallback(async()=>{const O=await Qe.contacts();return qe({type:"contacts",contacts:{...O,pending:O.pending??[]}}),O},[qe]),dt=k.useCallback(async()=>{try{const[O,te,de]=await Promise.all([Qe.identity(),Qe.contacts(),Qe.buildInfo()]),je={...te,pending:te.pending??[]};return c.current.identity&&c.current.identity.cid!==O.cid&&(R2(),S.current={},w({})),qe({type:"snapshot",identity:O,contacts:je}),K(de),await Promise.all(je.contacts.flatMap(Pe=>[Rt(Pe.container_id,!1),Xe(Pe.container_id,!1)])),si(c.current)}catch(O){return _e(O),null}},[qe,Xe,Rt,_e]),He=k.useCallback(async O=>{await d.current.request(O,async()=>{sA(O,tn())&&(await Qe.markRead(O),await Promise.all([Rt(O),mt()]))}).catch(_e)},[tn,mt,Rt,_e]),Dt=k.useCallback(async O=>{const te=++l.current;a.current?.abort();const de=new AbortController;a.current=de,s(null),Re(O),Xe(O,!1);let je;try{je=await Qe.conversation(O,void 0,de.signal)}catch(rt){de.signal.aborted||_e(rt);return}if(de.signal.aborted||te!==l.current)return;qe({type:"page",contactCid:O,page:je});const Pe=je.unread;let pe=[...je.messages],Oe=je.nextBefore;const xt=new Set,Ye=new Set(pe.map(rt=>rt.wire_id).filter(Boolean)),wt=()=>pe.filter(rt=>rt.dir==="in"&&!rt.read);for(;wt().length<Pe&&Oe&&!xt.has(Oe);){xt.add(Oe);let rt;try{rt=await Qe.conversation(O,Oe,de.signal)}catch{break}if(de.signal.aborted||te!==l.current)return;const Bt=rt.messages.filter(Ct=>!Ct.wire_id||!Ye.has(Ct.wire_id));if(!Bt.length&&rt.nextBefore===Oe)break;for(const Ct of Bt)Ct.wire_id&&Ye.add(Ct.wire_id);pe=[...Bt,...pe],qe({type:"older_page",contactCid:O,page:rt,newer:je.messages}),Oe=rt.nextBefore}const At=wt()[0];At?.wire_id&&te===l.current&&!de.signal.aborted&&s({contactCid:O,wireId:At.wire_id,count:Pe}),await He(O)},[Re,qe,He,Xe,_e]),_t=k.useCallback(async(O,te,de="page")=>{const je=`page:${O}:${de}`,Pe=(m.current.get(je)??0)+1;m.current.set(je,Pe);for(const pe of Cx){if(pe&&await Ex(pe),m.current.get(je)!==Pe)return;const Oe=await Rt(O,!1);if(Oe&&te(Oe))return}},[Rt]),Un=k.useCallback(async(O,te)=>{const de=`file:${O}`,je=(m.current.get(de)??0)+1;m.current.set(de,je);for(const Pe of Cx)if(Pe&&await Ex(Pe),m.current.get(de)!==je||(await Xe(O,!1))?.some(Oe=>Oe.wire_id===te))return},[Xe]),rr=k.useRef(!1);k.useEffect(()=>{if(!J||!t.loaded)return;const O=decodeURIComponent(window.location.hash.slice(Rx.length)),te=si(c.current);if(!O||!te){he(!1);return}if(ci(c.current,te)?.messages.some(de=>de.wire_id===O)){he(!1);return}rr.current||(rr.current=!0,_t(te,de=>de.messages.some(je=>je.wire_id===O),`anchor:${O}`).catch(()=>{}).finally(()=>he(!1)))},[J,_t,t.loaded,t.pages]),k.useMemo(()=>(P2({url:O=>Object.values(S.current).flat().find(de=>de.wire_id===O)?.available?Qe.mediaUrl(O):null,bytes:async O=>{if(!Object.values(S.current).flat().find(je=>je.wire_id===O)?.available)return null;const de=await fetch(Qe.mediaUrl(O),{cache:"no-store",credentials:"same-origin"});if(!de.ok)throw new Error(`Media request failed (HTTP ${de.status})`);return new Uint8Array(await de.arrayBuffer())},fetch:async O=>{const te=Object.values(S.current).flat().find(de=>de.wire_id===O);if(!te)throw new Error("Media record is unavailable");await Qe.fetchFiles([O]),await Xe(te.contact_id)}}),null),[Xe]),k.useEffect(()=>{let O;dA(de=>{ee(de),ov(de.registration).then(Ce).catch(()=>Ce(je=>({...je,status:"error"})))},{shouldDeferReload:()=>B.current||D.current!==null}).then(de=>{O=de}).catch(_e);const te=de=>{de.preventDefault(),ue(de)};return window.addEventListener("beforeinstallprompt",te),()=>{O?.(),window.removeEventListener("beforeinstallprompt",te)}},[_e]),k.useEffect(()=>wA(),[]),k.useEffect(()=>{if(!(!Z.registration||ge.status!=="on"))return oA({registration:Z.registration,identity:Qe.identity,onEvent:p0})},[ge.status,ge.bindingId,Z.registration]),k.useEffect(()=>{const O=()=>Ce(te=>({...te,status:"error"}));return window.addEventListener("ours-push-repair-required",O),()=>window.removeEventListener("ours-push-repair-required",O)},[]),k.useEffect(()=>{window.location.pathname==="/"&&window.history.replaceState(null,"",Jo()),h.current=window.matchMedia("(min-width: 861px)");const O=()=>{const pe=Jy(window.location.pathname);a.current?.abort(),l.current+=1,s(null),qe({type:"route",route:pe}),pe.name==="chats"&&pe.contactCid&&Dt(pe.contactCid)},te=()=>{if(document.visibilityState!=="visible")return;const pe=si(c.current);pe&&He(pe),v0(),Z.registration&&ov(Z.registration).then(Ce).catch(()=>Ce(Oe=>({...Oe,status:"error"})))};window.addEventListener("popstate",O),document.addEventListener("visibilitychange",te);const de=pe=>{const Oe=pe.type==="sync_required"?`${pe.type}:${pe.reason}`:pe.type==="receipt_received"?`${pe.type}:${pe.contact_id}:${pe.kind}:${pe.wire_ids.join(",")}`:`${pe.type}:${pe.contact_id}:${pe.wire_id}`,xt=Date.now(),Ye=p.current.get(Oe)??0;p.current.set(Oe,xt);for(const[wt,At]of p.current)xt-At>6e4&&p.current.delete(wt);xt-Ye<6e4||(async()=>{if(pe.type==="sync_required"){await dt();return}if(mt().catch(_e),pe.type==="file_received"){await Un(pe.contact_id,pe.wire_id);const wt=c.current.contacts.contacts.find(At=>At.container_id===pe.contact_id);si(c.current)!==pe.contact_id&&wt&&ve(pe.contact_id,Dl(wt),"New file");return}if(pe.type==="message_received"){const wt=c.current.contacts.contacts.find(At=>At.container_id===pe.contact_id);await _t(pe.contact_id,At=>At.messages.some(rt=>rt.wire_id===pe.wire_id),`message:${pe.wire_id}`),si(c.current)===pe.contact_id?await He(pe.contact_id):wt&&ve(pe.contact_id,Dl(wt),"New message");return}qe({type:"receipt",contactCid:pe.contact_id,kind:pe.kind,wireIds:pe.wire_ids}),await _t(pe.contact_id,wt=>pe.wire_ids.every(At=>{const rt=wt.messages.find(Bt=>Bt.wire_id===At);return!!rt?.receipt&&Tx[rt.receipt]>=Tx[pe.kind]}),`receipt:${pe.wire_ids.join(",")}`)})().catch(_e)},je=tA(de),Pe=nA(de,pe=>qe({type:"connection",connection:pe}));return dt().then(pe=>{pe&&Dt(pe)}),()=>{Pe(),je(),window.removeEventListener("popstate",O),document.removeEventListener("visibilitychange",te)}},[_t,Un,qe,He,Dt,ve,mt,dt,_e,Z.registration]);const dn=(O,te,de)=>{window.history.pushState(null,"",te),qe({type:"route",route:O,mobileDetailOpen:de})},Q=async O=>{dn({name:"chats",contactCid:O},Jo(O),!0),await Dt(O)},le=async O=>{const te=ci(c.current,O);if(!(!te?.nextBefore||C.current.has(O))){C.current.add(O),T(O);try{const de=await Qe.conversation(O,te.nextBefore);qe({type:"older_page",contactCid:O,page:de,newer:te.messages})}catch(de){_e(de)}finally{C.current.delete(O),T(null)}}},fe=si(t),Le=t.contacts.contacts.find(O=>O.container_id===fe),Fe=k.useMemo(()=>Nz(t,y),[t,y]),gt=Fe.find(O=>O.id===fe)??null,Lt=fe?Yk(ci(t,fe),y[fe]??[]):[],nt=t.identity,nn=t.loaded?fe&&!ci(t,fe)||J?"updating":t.connection!=="live"?"connecting":null:"connecting",z=async(O,te=ge.preview)=>{if(Z.registration){ce(!0),Ce(de=>({...de,status:"repairing",preview:te}));try{Ce(await(O==="enable"?y0(Z.registration,{preview:te}):O==="repair"?vA(Z.registration,te):xA(Z.registration,ge)))}catch(de){Ce(je=>({...je,status:"error"})),_e(de)}finally{ce(!1)}}},re=()=>{q([]),A("invite"),Qe.invites().then(q).catch(_e)};return t.route.name==="not_found"?v.jsxs("div",{className:"centered-screen",children:[v.jsx("h1",{children:"Page not found"}),v.jsx("button",{className:"btn primary",onClick:()=>dn({name:"chats",contactCid:null},Jo()),children:"Open chats"})]}):nt?v.jsx("div",{className:j?"theme-dark":"",style:{height:"100%"},children:v.jsxs("div",{className:"app signal-app",children:[v.jsxs("header",{className:"commandbar",children:[v.jsx("div",{className:"command-brand","aria-label":"ours network",children:v.jsx("span",{children:"Ours"})}),v.jsxs("div",{className:"command-copy",children:[v.jsx("span",{className:"command-kicker",children:"ours / encrypted network"}),v.jsx("strong",{children:"Chats"})]}),v.jsxs("div",{className:"command-actions",children:[W&&v.jsx("button",{className:"command-action",onClick:()=>void W.prompt().then(()=>ue(null)),children:"Install app"}),v.jsxs("button",{className:"command-action",onClick:re,children:[v.jsx(Se,{name:"plus"}),v.jsx("span",{children:"New chat"})]}),v.jsx("button",{className:"icon-btn command-settings",title:"Settings","aria-label":"Settings",onClick:()=>A("settings"),children:v.jsx(Se,{name:"settings"})}),v.jsxs("button",{ref:G,className:"rail-me command-me",title:nt.name,"aria-label":`${nt.name} account menu`,"aria-haspopup":"menu","aria-expanded":P,"aria-controls":"account-menu",onClick:()=>L(O=>!O),children:[Ss(nt.name),v.jsx("span",{className:"conn-dot "+(t.connection==="live"?"on":"off")})]})]})]}),v.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[v.jsx(sz,{contacts:Fe,roots:Mz(t.contacts),selected:fe,onSelect:O=>{O.startsWith("pending:")||Q(O)},onInvite:re,onSettings:()=>A("settings"),onApprovePending:async O=>{try{return await Qe.respondToIntroduction(O,"approve"),await dt(),!0}catch(te){return _e(te),!1}},onRejectPending:async O=>{try{return await Qe.respondToIntroduction(O,"reject"),await dt(),!0}catch(te){return _e(te),!1}}}),v.jsx(az,{contact:gt,messages:Lt,syncing:nn,unreadOpen:i?.contactCid===fe?i:null,hiddenEarlier:ci(t,fe??"")?.hasMore?Math.max(1,(ci(t,fe??"")?.total??Lt.length)-Lt.length):0,onLoadEarlier:fe&&E!==fe?()=>void le(fe):void 0,onBack:()=>{a.current?.abort(),l.current+=1,s(null),dn({name:"chats",contactCid:null},Jo(),!1)},onDraftChange:lt,onSend:async(O,te,de)=>{if(!fe)return;const je=fe,Pe=await Qe.send(je,O,te,de);return qe({type:"sent_message",contactCid:je,message:{dir:"out",text:O,date:new Date().toISOString(),read:!0,wire_id:Pe.wire_id??"",receipt:null,reply_to:te?{wire_id:te}:null}}),Pe.wire_id?_t(je,pe=>pe.messages.some(Oe=>Oe.wire_id===Pe.wire_id),`send:${Pe.wire_id}`):mt().catch(_e),Pe.wire_id??void 0},onSendFile:async(O,te)=>{fe&&(await Qe.sendFile(fe,new Blob([O.bytes],{type:O.mime}),O.filename,O.mime,te),await Promise.all([Xe(fe),Rt(fe,!1)]))},onFetchFile:async O=>{await Qe.fetchFiles([O]),fe&&await Xe(fe)},onRename:O=>{fe&&Qe.renameContact(fe,O).then(dt).catch(_e)},onRemove:()=>{fe&&confirm(`Remove “${Le?.name??"contact"}”?`)&&Qe.removeContact(fe).then(()=>(dn({name:"chats",contactCid:null},Jo(),!1),dt())).catch(_e)}},fe??"no-conversation")]}),v.jsxs("div",{className:"app-banners",children:[Z.offline&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),Z.updateAvailable&&v.jsxs("div",{className:"banner info",children:[v.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>{Z.registration&&rv(Z.registration)},children:"Restart now"})})]}),v.jsx(mz,{items:me,onDismiss:Ee,onOpen:O=>void Q(O)})]}),P&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"pop-backdrop","aria-hidden":"true",onClick:()=>Be(!0)}),v.jsxs("div",{id:"account-menu",ref:M,className:"menu command-menu",role:"menu","aria-label":`${nt.name} account`,onKeyDown:ft,children:[v.jsxs("div",{className:"menu-head",children:[v.jsx("div",{className:"avatar accent lg",children:Ss(nt.name)}),v.jsxs("div",{children:[v.jsx("strong",{children:nt.name}),v.jsxs("div",{className:"faint mono",children:["@",yh(nt.cid)]})]})]}),v.jsxs("button",{className:"menu-item",role:"menuitem",onClick:()=>{L(!1),re()},children:[v.jsx(Se,{name:"plus"}),"Invite a contact"]}),v.jsxs("button",{className:"menu-item",role:"menuitem",onClick:()=>{L(!1),A("settings")},children:[v.jsx(Se,{name:"settings"}),"Settings"]})]})]}),R==="invite"&&v.jsx(vz,{identity:nt,invites:I,onRefresh:async()=>q(await Qe.invites()),onCreate:async(O,te)=>(await Qe.createInvite(O,te)).blob,onAccept:async(O,te)=>{await Qe.addContact(O,te),await dt()},onRevoke:async O=>{await Qe.revokeInvite(O)},onClose:()=>{A(null),dt()}}),R==="settings"&&v.jsx(xz,{identity:nt,push:ge,workerSupported:Z.supported,busy:X,offline:Z.offline,updateAvailable:Z.updateAvailable,build:$,dark:j,onToggleDark:()=>Y(O=>(localStorage.setItem(Px,O?"0":"1"),!O)),onSaveBio:async O=>{await Qe.setBio(O),await dt()},onPushAction:z,onReloadUpdate:()=>{Z.registration&&rv(Z.registration)},onClose:()=>{D.current=null,A(null),fe&&He(fe)}}),t.error&&v.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,v.jsx("button",{className:"linkbtn",onClick:()=>qe({type:"error",message:null}),children:"dismiss"})]})]})}):v.jsx("div",{className:j?"theme-dark":"",style:{height:"100%"},children:v.jsx("div",{className:"centered-screen",children:v.jsx("p",{className:"muted",children:"Loading…"})})})}Rz();const Gk=document.getElementById("root");if(!Gk)throw new Error("missing #root");Jb.createRoot(Gk).render(v.jsx(GP,{reducedMotion:"user",children:v.jsx(jz,{})}));export{Mh as _,Od as g};
317
- //# sourceMappingURL=index-cF9iuZ83.js.map
316
+ `)}).join("")}function qF({children:e}){const t=k.isValidElement(e)?e:null,n=Hk(t?.props.className);return v.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&v.jsx("div",{className:"message-code-language",children:n}),v.jsx("pre",{children:e})]})}const XF=[Bk],YF={a:({node:e,children:t,href:n,...i})=>{const s=Wk(n);return s?v.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):v.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>v.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:qF,code:({node:e,className:t,children:n,...i})=>v.jsx("code",{className:t,"data-language":Hk(t),...i,children:n})},wx=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>WF?v.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):v.jsx("div",{className:n,"data-render-mode":"markdown",children:v.jsx(Vk,{remarkPlugins:XF,components:YF,urlTransform:i=>Wk(i)??"",children:KF(t)})})}),kl={type:"spring",stiffness:430,damping:38,mass:.72},kx=10,Kk=56,GF=18,QF=650;function ZF(e,t){return Math.abs(e)<kx&&Math.abs(t)<kx?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function JF(e){const t=e.at(-1),n=t?e.slice(0,-1).reverse().find(i=>i.x!==t.x&&t.time-i.time<=100):void 0;return n&&t&&t.time>n.time?(t.x-n.x)/(t.time-n.time)*1e3:0}function ez(e,t){const n=JF(t);return n>=0&&(e>=Kk||e>=GF&&n>=QF)}const Dd="ours.chats.listMode",ms="recent";function qk(){try{return globalThis.localStorage}catch{return}}function tz(e=qk()){try{return e?.getItem(Dd)==="identity"?"identity":ms}catch{return ms}}function nz(e,t=qk()){const n=e==="identity"?"identity":ms;try{return t?.setItem(Dd,n),t?.getItem(Dd)===n?n:ms}catch{return ms}}function Rs(e){return typeof e=="string"?e:""}function zl(e,t){const n=Rs(e),i=Rs(t),s=n.normalize().toLowerCase(),l=i.normalize().toLowerCase();return s<l?-1:s>l?1:n<i?-1:n>i?1:0}function rz(e,t){const n=jl(Rs(t.activityAt))-jl(Rs(e.activityAt));if(n!==0)return n;const i=zl(e.name,t.name);return i!==0?i:zl(e.id,t.id)}function _d(e){return[...e].sort(rz)}function Sx(e){return e.contacts.length>0?jl(Rs(e.contacts[0].activityAt)):0}function iz(e,t){const n=new Map,i=[];for(const l of e){const a=l.root||(t?.[l.id]?l.id:null);if(!a){i.push(l);continue}const c=t?.[a]||{label:a,note:""};let d=n.get(a);d||(d={id:`root:${a}`,rootId:a,label:c.label,note:c.note,contacts:[]},n.set(a,d)),d.contacts.push(l)}const s=[...n.values()].map(l=>({...l,contacts:_d(l.contacts)}));return i.length>0&&s.push({id:"rootless",rootId:null,label:"Independent identities",note:"People, agents and apps without a verified Human/root group",contacts:_d(i)}),s.sort((l,a)=>{const c=Sx(a)-Sx(l);if(c!==0)return c;const d=zl(l.label,a.label);return d!==0?d:zl(l.id,a.id)})}const oz=15e3;function Af(e){const{c:t,active:n,grouped:i}=e,[s,l]=k.useState(!1),a=async(h,m)=>{if(!(!h||s)){l(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{l(!1)}}},c=v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),v.jsxs("span",{className:"contact-copy",children:[v.jsxs("span",{className:"contact-row-topline",children:[v.jsx("span",{className:"contact-name",children:t.name}),t.when&&v.jsx("span",{className:"contact-time",children:t.when})]}),v.jsxs("span",{className:"contact-row-bottomline",children:[v.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&v.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&v.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&v.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[v.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void a(e.onApprove,h.currentTarget),children:"Approve"}),v.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void a(e.onReject,h.currentTarget),children:"Reject"})]}),n&&v.jsx(fs.span,{className:"contact-active-glow",layoutId:"active-contact",transition:kl})]}),d="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?v.jsx("div",{className:d,children:c}):v.jsx(fs.button,{type:"button",className:d,onClick:e.onClick,children:c})}function sz(e){const{contacts:t,roots:n,selected:i}=e,[s,l]=k.useState(""),[a,c]=k.useState(()=>tz()),d=C=>C.name.toLowerCase().includes(s.toLowerCase()),h=t.filter(C=>C.status!=="pending"&&d(C)),m=t.filter(C=>C.status==="pending"&&d(C)),p=_d(h),y=iz(h,n),w=h.length===0&&m.length===0,S=C=>{c(nz(C))},E=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],T=(C,R)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(C.key))return;C.preventDefault();const D=C.key==="Home"?"recent":C.key==="End"||R==="recent"?"identity":"recent";S(D),document.getElementById(`conversation-list-${D}`)?.focus()};return v.jsxs("div",{className:"listcol",children:[v.jsxs("div",{className:"listcol-head",children:[v.jsxs("div",{className:"listcol-titlebar",children:[v.jsx("h2",{id:"chat-list-title",className:"listcol-title",tabIndex:-1,children:"Chats"}),v.jsxs("div",{className:"listcol-actions",children:[v.jsxs("button",{className:"btn sm primary",onClick:e.onInvite,children:[v.jsx(Se,{name:"plus",size:15}),"Invite"]}),v.jsx("button",{className:"icon-btn",title:"Settings",onClick:e.onSettings,children:v.jsx(Se,{name:"settings"})})]})]}),v.jsxs("div",{className:"search",children:[v.jsx(Se,{name:"search"}),v.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:C=>l(C.target.value)})]}),v.jsx("div",{className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout",children:E.map(C=>v.jsx("button",{id:`conversation-list-${C.id}`,type:"button",role:"tab","aria-selected":a===C.id,"aria-controls":"conversation-list-panel",tabIndex:a===C.id?0:-1,className:a===C.id?"active":"",onClick:()=>S(C.id),onKeyDown:R=>T(R,C.id),children:C.label},C.id))})]}),v.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${a}`,children:[a==="recent"&&p.length>0&&v.jsx("div",{className:"conversation-group",children:p.map(C=>v.jsx(Af,{c:C,active:i===C.id,onClick:()=>e.onSelect(C.id)},C.id))}),a==="identity"&&y.map(C=>v.jsxs("div",{children:[v.jsxs("div",{className:"group-label",title:C.note,children:[C.rootId&&v.jsx(Se,{name:"clusters"}),v.jsx("span",{children:C.label}),C.note&&v.jsxs("span",{className:"gl-note",children:["· ",C.note]})]}),v.jsx("div",{className:"conversation-group",children:C.contacts.map(R=>v.jsx(Af,{c:R,grouped:C.rootId!==null,active:i===R.id,onClick:()=>e.onSelect(R.id)},R.id))})]},C.id)),m.length>0&&v.jsxs("div",{children:[v.jsx("div",{className:"group-label",children:v.jsx("span",{children:"Pending"})}),v.jsx("div",{className:"conversation-group",children:m.map(C=>v.jsx(Af,{c:C,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(C.id.slice(8)),onReject:()=>e.onRejectPending(C.id.slice(8))},C.id))})]}),w&&v.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]})]})}const Mf=e=>`chat-message-${encodeURIComponent(e)}`,Ld=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function bx(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),c=k.useRef(i);c.current=i;const d=1,h=Kk,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),y=k.useRef(p()),w=R=>{const A=l.current,D=a.current,B=Ld();if(A&&(A.style.transform=R&&!B?`translateX(${R}px)`:""),D){const I=Math.min(1,Math.abs(R)/h);D.style.opacity=String(I),D.style.transform=B?"scale(1)":`scale(${.5+.5*I})`}},S=(R,A)=>{const D=y.current;if(D.id!==R)return;const B=A&&D.mode==="drag"&&ez(D.distance,D.samples);y.current=p(),l.current?.classList.remove("swiping"),a.current?.classList.remove("armed"),w(0);const I=s.current;I?.hasPointerCapture?.(R)&&I.releasePointerCapture(R),B&&c.current()};k.useEffect(()=>{const R=s.current;if(!R)return;const A=D=>S(D.pointerId,!1);return R.addEventListener("lostpointercapture",A),()=>{R.removeEventListener("lostpointercapture",A);const D=y.current.id;D!==-1&&S(D,!1)}},[]);const E=R=>{const A=R.target,D=window.getSelection?.();!n||!R.isPrimary||R.pointerType==="mouse"||R.button!==0||y.current.id!==-1||D&&!D.isCollapsed||A.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(y.current={id:R.pointerId,x0:R.clientX,y0:R.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:R.clientX,time:R.timeStamp}]},w(0))},T=R=>{const A=y.current;if(A.id!==R.pointerId||A.mode==="idle")return;const D=R.clientX-A.x0,B=R.clientY-A.y0,I=window.getSelection?.();if(I&&!I.isCollapsed){S(R.pointerId,!1);return}if(A.mode==="maybe"){const Y=ZF(D,B);if(Y==="pending")return;if(Y==="drag"&&Math.sign(D)===d)A.mode="drag",R.currentTarget.setPointerCapture?.(R.pointerId),l.current?.classList.add("swiping");else{A.mode="idle";return}}R.preventDefault();const q=R.timeStamp;A.samples.push({x:R.clientX,time:q}),A.samples=A.samples.filter(Y=>q-Y.time<=120);let $=D*d;$<0&&($=0),$>h&&($=h+($-h)*.35),$=Math.min($,m),A.distance=$;const K=$*d,j=Math.abs(K)>=h;j!==A.armed&&(A.armed=j,a.current?.classList.toggle("armed",j),j&&navigator.vibrate?.(10)),w(K)},C=R=>{const A=y.current;A.id===R.pointerId&&A.mode==="drag"&&(A.samples.push({x:R.clientX,time:R.timeStamp}),A.distance=Math.max(0,R.clientX-A.x0),A.armed=A.distance>=h),S(R.pointerId,!0)};return v.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:E,onPointerMove:T,onPointerUp:C,onPointerCancel:R=>S(R.pointerId,!1),onLostPointerCapture:R=>S(R.pointerId,!1),children:[n&&v.jsx("span",{className:"swipe-cue",ref:a,"aria-hidden":!0,children:v.jsx(Se,{name:"reply",size:16})}),v.jsx("div",{className:"bubble-wrap",ref:l,children:e.children}),e.after]})}function az(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[l,a]=k.useState(!1),[c,d]=k.useState(null),[h,m]=k.useState(null),[p,y]=k.useState(null),[w,S]=k.useState(null),[E,T]=k.useState(null),[C,R]=k.useState(!1),A=k.useRef(null),D=k.useRef(null),[B,I]=k.useState(null),[q,$]=k.useState(!1),[K,j]=k.useState(!1),[Y,W]=k.useState(!1),[ue,Z]=k.useState(null),[ee,ge]=k.useState(!1),Ce=k.useRef(null),X=k.useRef(null),ce=k.useRef(!1),P=k.useRef(null),L=k.useRef(!1),[G,M]=k.useState(!1),[J,he]=k.useState(0),me=k.useRef(null),ve=k.useRef(!0),Ee=k.useRef(null),Re=k.useRef(0),Be=k.useRef(null),ft=k.useRef(new Map),qe=k.useRef(0),lt=k.useRef(null),_e=k.useRef(null),tn=k.useRef(0),Rt=k.useRef(null),Xe=typeof window<"u"&&window.matchMedia("(max-width: 860px)").matches,mt=(z=!1)=>{R(!1),z&&requestAnimationFrame(()=>A.current?.focus())};k.useEffect(()=>{if(!C||Xe)return;D.current?.querySelector(".idcard-close")?.focus();const z=re=>{re.key==="Escape"&&(re.preventDefault(),mt(!0))};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[C,Xe]),k.useEffect(()=>{s(""),m(null),y(null),d(null),S(null),T(null),R(!1),I(null),$(!1),j(!1),W(!1),Re.current+=1,Z(null),ge(!1),ft.current.clear(),lt.current=null,_e.current=null},[t?.id]),k.useEffect(()=>{if(!p)return;const z=p.reply?.wireId;n.some(O=>O.kind!=="file"&&O.dir==="out"&&!!O.wireId&&!p.wireIds.has(O.wireId)&&O.text===p.text&&(O.replyTo?.wireId??void 0)===z)&&(y(null),m(null),s(O=>O===p.draft?"":O),S(O=>O===p.reply?null:O))},[n,p]);const dt=!!c?.wireId&&n.some(z=>z.wireId===c.wireId),He=k.useMemo(()=>c&&!dt?[...n,c.message]:n,[n,c,dt]);k.useEffect(()=>{dt&&d(null)},[dt]),k.useLayoutEffect(()=>{const z=X.current;if(!z)return;z.style.height="0px";const re=Math.max(44,Math.min(z.scrollHeight,132));z.style.height=`${re}px`,z.style.overflowY=z.scrollHeight>132?"auto":"hidden"},[i,t?.id]);const Dt=z=>{const re=P.current;if(!re)return;const O=Math.max(0,re.scrollHeight-re.clientHeight);if(Math.abs(re.scrollTop-O)<1){lt.current=null,_e.current=null;return}const te=z&&!Ld();lt.current=te?O:null,_e.current=te?re.scrollTop:null,te?re.scrollTo({top:O,behavior:"smooth"}):re.scrollTop=O},_t=()=>{me.current===null&&(me.current=requestAnimationFrame(()=>{me.current=null;const z=P.current;if(!z)return;const re=z.scrollHeight-z.clientHeight-z.scrollTop>48;M(re),re||he(0)}))};k.useLayoutEffect(()=>{if(!t){Ee.current=null,ve.current=!0,tn.current=0;return}const z=P.current;if(!z)return;const re=Ee.current!==t.id,O=tn.current,te=He.length!==O,de=He.at(-1),je=de?de.wireId||`${de.date}:${de.text}`:null,Pe=Rt.current;if(tn.current=He.length,Rt.current=je,!re&&!te&&lt.current===null&&(ve.current=z.scrollHeight-z.clientHeight-z.scrollTop<=48),re||ve.current)Dt(te&&!re&&Ee.current!==null),ve.current=!0;else if(te&&He.length>O&&je!==Pe){const pe=Pe===null?-1:He.findIndex(Oe=>(Oe.wireId||`${Oe.date}:${Oe.text}`)===Pe);he(Oe=>Oe+Math.max(1,He.length-Math.max(0,pe+1)))}Ee.current=t.id,_t()},[t,He.length]),k.useLayoutEffect(()=>{if(L.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const z=P.current,re=document.getElementById(`unread-${Mf(e.unreadOpen.wireId)}`);!z||!re||(z.scrollTop=Math.max(0,re.offsetTop-16),ve.current=!1,L.current=!0,_t())},[e.unreadOpen,He.length]),k.useLayoutEffect(()=>{const z=window.location.hash;if(!z.startsWith("#chat-message-"))return;const re=document.getElementById(z.slice(1));re&&(re.scrollIntoView({block:"center"}),ve.current=!1)},[t?.id,He.length]),k.useLayoutEffect(()=>{const z=Be.current,re=P.current;if(z===null||!re)return;const O=requestAnimationFrame(()=>{Be.current===z&&(re.scrollTop=z.top+re.scrollHeight-z.height,Be.current=null)});return()=>cancelAnimationFrame(O)},[He.length]),k.useEffect(()=>{const z=P.current;if(!z||typeof ResizeObserver>"u")return;const re=z.firstElementChild;if(!re)return;const O=new ResizeObserver(()=>{ve.current&&Dt(lt.current!==null),_t()});return O.observe(re),O.observe(z),()=>{O.disconnect(),me.current!==null&&cancelAnimationFrame(me.current)}},[t?.id]);const Un=async z=>{const re=++Re.current;m(null),W(!0);try{if(z.size>ss&&Uk(z.type,z.name)){const te=await UF(z,ss);if(re!==Re.current)return;I({filename:te.filename,mime:te.mime,bytes:te.bytes,originalSize:te.originalSize});return}if(z.size>ss){m(`"${z.name}" is ${$r(z.size)} — files up to ${$r(ss)} can be sent.`);return}const O=await z.arrayBuffer();if(re!==Re.current)return;I({filename:z.name||"file",mime:z.type||"application/octet-stream",bytes:new Uint8Array(O)})}catch(O){re===Re.current&&m(`Photo optimization failed: ${O instanceof Error?O.message:String(O)}`)}finally{re===Re.current&&W(!1)}},rr=()=>{!B||!e.onSendFile||K||(j(!0),e.onSendFile(B,w?.wireId).then(()=>{I(null),S(null)}).catch(z=>m(`File send failed: ${String(z)} — it was not delivered.`)).finally(()=>j(!1)))},dn=e.onDraftChange;k.useEffect(()=>(dn?.(i.trim().length>0||l),()=>dn?.(!1)),[i,l,dn]);const Q=new Map;for(const z of He)z.wireId&&Q.set(z.wireId,z);const le=k.useMemo(()=>{const z=new Map;for(const re of He)z.set(re,re.kind==="file"?null:re.dir==="in"?d2(t?.announcedName??"",re.text):null);return z},[He,t?.announcedName]),fe=z=>le.get(z)??null,Le=z=>{if(z.dir==="out")return"You";const re=fe(z);return re&&re.variant==="chat"?re.author:t?.name??"Them"},Fe=z=>{if(z.kind==="file")return z.mime?.startsWith("image/")?"Photo":io(z.mime??"",z.filename??"")?"Voice message":z.filename||"File";const re=fe(z);return re?re.text||x2(re):z.text},gt=z=>{if(!z.replyTo)return null;const re=Q.get(z.replyTo.wireId);return re?{author:Le(re),text:Fe(re)}:{author:"",text:"Original message"}};if(!t)return e.emptyOverride?v.jsx(v.Fragment,{children:e.emptyOverride}):v.jsx("div",{className:"detail",children:v.jsxs("div",{className:"detail-empty",children:[v.jsx(Se,{name:"chat"}),v.jsxs("div",{children:[v.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),v.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const Lt=async()=>{const z=i,re=z.trim(),O=!!p&&z===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!re||ce.current||O)return;p&&y(null),ce.current=!0,a(!0),m(null);const te=w,de=te?.wireId,je=new AbortController;let Pe=!1,pe=0;s(""),S(null);const Oe=`optimistic-${++qe.current}`;d({key:Oe,wireId:null,message:{dir:"out",text:re,date:new Date().toISOString(),read:!0,wireId:"",replyTo:de?{wireId:de}:null}});try{const xt=await Promise.race([e.onSend(re,de,je.signal),new Promise((Ye,wt)=>{pe=window.setTimeout(()=>{Pe=!0,je.abort(),wt(new Error("send timeout"))},oz)})]);xt?(ft.current.set(xt,Oe),d(Ye=>Ye?.key===Oe?{...Ye,wireId:xt}:Ye)):d(Ye=>Ye?.key===Oe?null:Ye),y(null)}catch(xt){d(null),s(Ye=>Ye===""?z:Ye),S(Ye=>Ye===null?te:Ye),Pe||!(xt instanceof nd)?(y({draft:z,text:re,reply:te,wireIds:new Set(n.flatMap(Ye=>Ye.wireId?[Ye.wireId]:[]))}),m(`${Pe?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(xt)} — the message was not delivered.`)}finally{window.clearTimeout(pe),ce.current=!1,a(!1)}},nt=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId,nn=z=>{z.wireId&&S({wireId:z.wireId,author:Le(z),text:Fe(z)})};return v.jsxs("div",{className:"detail detail-chat",children:[v.jsxs("div",{className:"detail-head",children:[v.jsxs("div",{className:"conv-peer",children:[v.jsx("button",{className:"icon-btn detail-back",onClick:e.onBack,children:v.jsx(Se,{name:"back"})}),v.jsx("div",{className:"avatar accent",children:t.initials}),v.jsxs("div",{className:"conv-peer-meta",children:[E!==null?v.jsx("input",{className:"field name-edit",value:E,autoFocus:!0,placeholder:t.name,onChange:z=>T(z.target.value),onKeyDown:z=>{z.key==="Enter"?(e.onRename?.(E),T(null)):z.key==="Escape"&&T(null)},onBlur:()=>T(null)}):v.jsxs("div",{className:"conv-peer-name",children:[t.name,e.onRename&&v.jsx("button",{className:"icon-btn name-pencil",title:"Rename (only changes how they appear to you)",onClick:()=>T(t.name),children:v.jsx(Se,{name:"edit",size:13})})]}),e.syncing&&v.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[v.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&(t.roleId?v.jsxs("button",{ref:A,className:"idchip","aria-haspopup":"dialog","aria-expanded":C,"aria-controls":"identity-details",onClick:()=>R(!0),children:[v.jsx(Se,{name:"shield",size:11}),"verified role of ",t.rootName]}):t.status!=="pending"&&v.jsxs("button",{ref:A,className:"idchip quiet","aria-haspopup":"dialog","aria-expanded":C,"aria-controls":"identity-details",onClick:()=>R(!0),children:[v.jsx(Se,{name:"lock",size:11}),"verified identity"]}))]})]}),C&&(Xe?v.jsxs(mo,{title:"Verified identity",onClose:()=>mt(!0),className:"identity-details-modal",contentId:"identity-details",children:[t.roleId&&v.jsxs("p",{children:["This is the role ",v.jsxs("strong",{children:["“",t.roleId,"”"]})," of ",v.jsx("strong",{children:t.rootName})," — the link is cryptographically signed, not self-declared."]}),v.jsx("div",{className:"idcard-fp mono",children:t.id}),v.jsx("p",{className:"idcard-note",children:"This id is the fingerprint of their key. Names are what people show you; the fingerprint is what guarantees you're always talking to the same identity — no one can impersonate it. Renaming only changes how they appear to you."})]}):v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"pop-backdrop","aria-hidden":"true",onClick:()=>mt(!0)}),v.jsxs("div",{id:"identity-details",ref:D,className:"idcard anim-scale",role:"dialog","aria-modal":"false","aria-labelledby":"identity-details-title",children:[v.jsxs("div",{className:"idcard-head",children:[v.jsx("h4",{id:"identity-details-title",children:"Verified identity"}),v.jsx("button",{className:"icon-btn idcard-close","aria-label":"Close verified identity",onClick:()=>mt(!0),children:v.jsx(Se,{name:"close",size:16})})]}),t.roleId&&v.jsxs("p",{children:["This is the role ",v.jsxs("strong",{children:["“",t.roleId,"”"]})," of ",v.jsx("strong",{children:t.rootName})," — the link is cryptographically signed, not self-declared."]}),v.jsx("div",{className:"idcard-fp mono",children:t.id}),v.jsx("p",{className:"idcard-note",children:"This id is the fingerprint of their key. Names are what people show you; the fingerprint is what guarantees you're always talking to the same identity — no one can impersonate it. Renaming only changes how they appear to you."})]})]})),v.jsxs("div",{className:"conv-actions",children:[v.jsxs("button",{className:"btn sm",title:"Shared photos, files, and links",onClick:()=>ge(!0),children:[v.jsx(Se,{name:"paperclip",size:14}),"Media"]}),v.jsxs("button",{className:"btn sm danger",title:"Remove contact",onClick:e.onRemove,children:[v.jsx(Se,{name:"trash",size:14}),"Remove"]})]})]}),v.jsx("div",{className:"messages",ref:P,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:z=>{const re=z.currentTarget,O=re.scrollHeight-re.clientHeight-re.scrollTop;if(lt.current!==null){const te=_e.current;if(te===null||re.scrollTop>=te-1){_e.current=re.scrollTop,O<=4&&(lt.current=null,_e.current=null);return}lt.current=null,_e.current=null}ve.current=O<=48,_t()},onPointerDown:()=>{lt.current=null,_e.current=null},onTouchStart:()=>{lt.current=null,_e.current=null},onWheel:()=>{lt.current=null,_e.current=null},onDragOver:z=>{e.onSendFile&&z.preventDefault()},onDrop:z=>{if(!e.onSendFile)return;z.preventDefault();const re=z.dataTransfer.files?.[0];re&&Un(re)},children:v.jsxs("div",{className:"messages-inner",children:[v.jsxs("div",{className:"e2e-note",children:[v.jsx(Se,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&v.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{ve.current=!1;const z=P.current;Be.current=z?{height:z.scrollHeight,top:z.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),v.jsx(HP,{initial:!1,children:He.map((z,re)=>{const O=z===c?.message?c.key:z.wireId&&ft.current.get(z.wireId)||z.wireId||`${z.date}-${(e.hiddenEarlier??0)+re}`,te=Mf(z.wireId||O),de=He[re-1],je=He[re+1],Pe=fe(z),pe=Bt=>{if(!Bt)return null;const Ct=fe(Bt);return Ct?Ct.variant==="system"?"room:system":`room:chat:${Ct.author}${Ct.role}`:Bt.dir},Oe=pe(z),xt=!!de&&pe(de)===Oe&&Oe!=="room:system",Ye=!!je&&pe(je)===Oe&&Oe!=="room:system",wt=(z.dir==="out"?"out":"in")+(xt?" cont-top":"")+(Ye?" cont-bot":""),At=z.wireId?v.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>nn(z),children:v.jsx(Se,{name:"reply",size:15})}):null;if(Pe&&Pe.variant==="system"){const Bt=Pe.presentation??"system";return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsxs("div",{className:`room-system room-${Bt}-card`,role:"note",children:[Pe.label&&v.jsx("span",{className:"room-system-label",children:Pe.label}),Pe.roomName&&v.jsx("strong",{className:"room-card-name",children:Pe.roomName}),v.jsx(wx,{text:Pe.text,className:"room-system-text message-markdown"}),!!Pe.details?.length&&v.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:Pe.details.map(Ct=>v.jsx("li",{children:Ct},Ct))}),v.jsxs("span",{className:"room-card-provenance",children:[Pe.authoredBy&&v.jsx("span",{className:"room-card-author",children:Pe.authoredBy}),v.jsx("span",{className:"room-system-at",children:bs(Pe.authoredAt||z.date)})]})]})]},O)}if(z.kind==="file"){const Bt=b0(z.wireId)??{id:z.wireId,dir:z.dir,filename:z.filename??"file",mime:z.mime??"application/octet-stream",size:0,date:z.date};return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(bx,{dir:z.dir==="out"?"out":"in",rowClass:wt,canReply:!!z.wireId,onReply:()=>nn(z),after:At,children:v.jsx("div",{className:`ours-message ours-message-file ours-message--${z.dir}`,children:v.jsx(SD,{rec:Bt,receipt:z.receipt,receiptless:z.receiptless,onPreview:Z,onFetch:e.onFetchFile})})})]},O)}const rt=gt(z);return v.jsxs(fs.div,{className:"message-motion",id:te,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:kl,children:[z.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${te}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(bx,{dir:z.dir==="out"?"out":"in",rowClass:wt,canReply:!!z.wireId,onReply:()=>nn(z),after:At,children:v.jsxs("div",{className:`ours-message ours-message--${z.dir}`,children:[rt&&v.jsxs("div",{className:"quote",children:[rt.author&&v.jsx("span",{className:"quote-author",children:rt.author}),v.jsx("span",{className:"quote-text",children:rt.text})]}),Pe&&!xt&&v.jsxs(v.Fragment,{children:[Pe.roomName&&v.jsx("div",{className:"room-message-room",children:Pe.roomName}),v.jsxs("div",{className:"room-author",children:[v.jsx("span",{className:"room-author-name",children:Pe.author}),Pe.role&&v.jsx("span",{className:"room-author-role",children:Pe.role})]})]}),v.jsx(wx,{text:Pe?Pe.text:z.text}),v.jsxs("div",{className:"bubble-at",children:[bs(Pe?.authoredAt||z.date),z.dir==="out"&&v.jsx(C0,{receipt:z.receipt,receiptless:z.receiptless})]})]})})]},O)})}),v.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),G&&v.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":J?`Jump to latest, ${J} new messages`:"Jump to latest",onClick:z=>{const re=z.currentTarget===document.activeElement;he(0),Dt(!0),re&&requestAnimationFrame(()=>P.current?.focus({preventScroll:!0}))},children:[v.jsx("span",{children:"Jump to latest"}),!!J&&v.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:J})]}),h&&v.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>void Lt(),children:"retry"})})]}),v.jsxs("div",{className:"composer-wrap",children:[w&&v.jsxs("div",{className:"reply-bar",children:[v.jsx("div",{className:"reply-bar-line"}),v.jsxs("div",{className:"reply-bar-body",children:[v.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),v.jsx("div",{className:"reply-bar-text",children:w.text})]}),v.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:v.jsx(Se,{name:"close",size:16})})]}),B&&v.jsx(k1,{att:B,sending:K,onSend:rr,onDiscard:()=>I(null)}),Y&&v.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),v.jsxs("div",{className:"composer"+(q?" recording":""),children:[e.onSendFile&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:Ce,type:"file",style:{display:"none"},onChange:z=>{const re=z.target.files?.[0];re&&Un(re),z.target.value=""}}),v.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:K||Y||q,onClick:()=>Ce.current?.click(),children:v.jsx(Se,{name:"paperclip",size:18})}),v.jsx(S1,{disabled:K||Y||!!B,onReady:z=>{$(!1),I(z)},onError:z=>{$(!1),m(z)},onActiveChange:$},t.id)]}),v.jsx("textarea",{ref:X,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":l,onChange:z=>s(z.target.value),onKeyDown:z=>{z.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!z.shiftKey&&(z.preventDefault(),Lt()):z.key==="Escape"&&S(null)}}),v.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:z=>{z.button===0&&document.activeElement===X.current&&z.preventDefault()},onClick:()=>void Lt(),disabled:l||nt||!i.trim(),title:nt?"Delivery status unknown — edit before sending again":void 0,children:[v.jsx(Se,{name:"send",size:16}),v.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),ue&&(Zl(ue.filename,ue.mime)?v.jsx(AF,{rec:ue,onClose:()=>Z(null)}):v.jsx(RF,{rec:ue,onClose:()=>Z(null),onSendText:e.onSend,onSendFile:e.onSendFile})),ee&&v.jsx(NF,{messages:n,indexOffset:e.hiddenEarlier??0,onClose:()=>ge(!1),onPreview:z=>{ge(!1),Z(z)},onJump:z=>{document.getElementById(Mf(z))?.scrollIntoView({behavior:Ld()?"auto":"smooth",block:"center"}),ge(!1)}})]})}const Xk=3;function lz(e,t,n=Xk){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function uz(e,t){return e.filter(n=>n.id!==t)}const cz=6e3,fz=lz,dz=uz;function hz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((a,c,d)=>{const h=Date.now(),m={id:`${a}:${h}:${n.current++}`,cid:a,name:c,preview:"",at:h};t(p=>fz(p,m,Xk))},[]),s=k.useCallback(a=>t(c=>dz(c,a)),[]),l=k.useCallback(a=>t(c=>c.filter(d=>d.cid!==a)),[]);return{toasts:e,push:i,dismiss:s,clear:l}}function pz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,l]=k.useState(!1),[a,c]=k.useState(!1),d=s||a;return k.useEffect(()=>{if(d)return;const h=setTimeout(()=>i(t.id),cz);return()=>clearTimeout(h)},[t.id,d,i]),v.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[v.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[v.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:Ss(t.name)}),v.jsxs("span",{className:"msg-text",children:[v.jsx("strong",{className:"msg-name",children:t.name}),v.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),v.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:v.jsx(Se,{name:"close",size:15})})]})}function mz(e){return v.jsx(v.Fragment,{children:e.items.map(t=>v.jsx(pz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function gz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Mh(()=>import("./browser-vohWR48c.js").then(l=>l.b),[]).then(l=>{l.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),v.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:v.jsx("canvas",{ref:t,"data-testid":"qr-canvas","data-invite":n,width:i,height:i,style:{borderRadius:8,border:"1px solid var(--line)",imageRendering:"pixelated"}})})}function yz(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),l=k.useRef(!0),[a,c]=k.useState("requesting"),[d,h]=k.useState(""),m=k.useCallback(()=>{s.current&&cancelAnimationFrame(s.current),i.current&&(i.current.getTracks().forEach(w=>w.stop()),i.current=null),t.current&&(t.current.srcObject=null)},[]),p=k.useCallback(w=>{i.current=w;const S=t.current;S.srcObject=w,S.setAttribute("playsinline","true"),S.play();const E=n.current,T=E.getContext("2d"),C=()=>{if(l.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const R=S.videoWidth||320,A=S.videoHeight||240;E.width=R,E.height=A,T.drawImage(S,0,0,R,A);const D=T.getImageData(0,0,R,A);Mh(()=>import("./jsQR-DCYnED3H.js").then(B=>B.j),[]).then(B=>{const I=B.default,q=I(D.data,D.width,D.height,{inversionAttempts:"dontInvert"});if(q&&q.data&&l.current){m(),e.onDecode(q.data);return}l.current&&(s.current=requestAnimationFrame(C))})}else s.current=requestAnimationFrame(C)};s.current=requestAnimationFrame(C)},[m,e]);k.useEffect(()=>{if(l.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!l.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!l.current)return;const S=w.name??"";S==="NotAllowedError"||S==="PermissionDeniedError"?c("denied"):S==="NotFoundError"||S==="DevicesNotFoundError"?c("nocamera"):(c("error"),h(w.message??String(w)))}),()=>{l.current=!1,m()}},[]);const y=()=>{m(),e.onClose()};return v.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(a==="requesting"||a==="scanning")&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:a==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),v.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[v.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),v.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),a==="scanning"&&v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx("div",{style:{width:160,height:160,borderRadius:12,border:"2px solid var(--accent)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.4)"}})})]})]}),a==="denied"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Se,{name:"shield",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"Camera permission was denied. To scan QR codes, allow camera access in your browser settings, then try again. Or paste the invite text below instead."})]}),a==="nocamera"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Se,{name:"close",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),a==="error"&&v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:v.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",d||"unknown error",". Paste the invite text below instead."]})}),v.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:y,children:a==="scanning"?v.jsxs(v.Fragment,{children:[v.jsx(Se,{name:"close",size:14}),"Cancel scan"]}):v.jsxs(v.Fragment,{children:[v.jsx(Se,{name:"close",size:14}),"Close scanner"]})})]})}function vz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[l,a]=k.useState(""),[c,d]=k.useState(null),[h,m]=k.useState("one_time"),[p,y]=k.useState(""),[w,S]=k.useState(""),[E,T]=k.useState(!1),[C,R]=k.useState(null),[A,D]=k.useState(null),[B,I]=k.useState(!1),[q,$]=k.useState(null),K=k.useRef(!1),j=async()=>{if(!K.current){K.current=!0,T(!0),D(null),R(null);try{m(i),d(await e.onCreate(i,i==="one_time"&&l.trim()||void 0))}catch(W){D(W instanceof Error?W.message:String(W))}finally{K.current=!1,T(!1)}}},Y=v.jsx($k,{className:"modal-tabs",label:"Invite mode",options:[{id:"generate",label:"Generate invite"},{id:"accept",label:"Accept invite"}],value:t,onChange:n,idPrefix:"invite-tab",panelId:"invite-panel"});return v.jsx(mo,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{K.current||e.onClose()},tabs:Y,children:v.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[v.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",v.jsx("strong",{children:e.identity.name})," · ",v.jsxs("span",{className:"mono",children:["@",yh(e.identity.cid)]})]}),v.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),v.jsx("input",{className:"field",value:l,onChange:W=>a(W.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):v.jsx("p",{className:"onb-warning","data-testid":"public-invite-warning",style:{margin:0,fontSize:"0.9rem"},children:"Anyone with this invite can connect until you revoke it. It has no expiry and stays valid across server restarts."}),v.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:E,onClick:()=>void j(),children:E?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(W=>W.mode==="public").length===0&&v.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(W=>W.mode==="public").map(W=>v.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[v.jsx("span",{className:"mono",children:W.invite_id}),v.jsxs("p",{className:"muted",children:["Created ",W.created?b2(W.created):"unknown"," · Active until revoked · No expiry"]}),q===W.invite_id?v.jsxs("span",{children:[v.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(W.invite_id).then(()=>($(null),e.onRefresh())).catch(ue=>D(String(ue))),children:"Confirm revoke"})," ",v.jsx("button",{className:"btn sm",onClick:()=>$(null),children:"Keep it"})]}):v.jsx("button",{className:"btn sm",onClick:()=>$(W.invite_id),children:"Revoke"})]},W.invite_id))]}),C&&v.jsx("p",{className:"muted",children:C}),A&&v.jsx("p",{className:"onb-error",children:A})]}),t==="generate"&&c&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted","data-testid":h==="public"?"public-result-note":void 0,children:h==="public"?"Shown only on this screen. Copy it now; the text cannot be recovered later. The invite stays active until revoked.":`Send this invite to ${l.trim()||"your contact"}. It can be redeemed once.`}),v.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:W=>W.currentTarget.select()}),h==="one_time"&&v.jsx(gz,{text:c}),v.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>R("Copied to clipboard.")),children:[v.jsx(Se,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&v.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{d(null),a(""),e.onRefresh()},children:"Done — hide invite"}),C&&v.jsx("p",{className:"muted",children:C})]}),t==="accept"&&v.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:W=>{W.preventDefault(),!(!p.trim()||E)&&(T(!0),D(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{R("Invite accepted — the contact will appear once the sender verifies your identity."),y(""),S("")}).catch(ue=>D(String(ue))).finally(()=>T(!1)))},children:[v.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),B?v.jsx(yz,{onDecode:W=>{y(W),I(!1)},onClose:()=>I(!1)}):v.jsxs("button",{type:"button",className:"btn",onClick:()=>I(!0),children:[v.jsx(Se,{name:"monitor",size:15}),"Scan QR code"]}),v.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:W=>y(W.target.value),placeholder:"Paste invite text…"}),v.jsx("input",{className:"field",value:w,onChange:W=>S(W.target.value),placeholder:"Rename them (optional)",maxLength:64}),v.jsx("button",{className:"btn primary",type:"submit",disabled:E||!p.trim(),children:E?"Connecting…":"Add contact"}),C&&v.jsx("p",{className:"muted",children:C}),A&&v.jsx("p",{className:"onb-error",children:A})]})]})})}function xz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[l,a]=k.useState(null),[c,d]=k.useState(e.push.preview),h=mA(),m=!e.workerSupported||e.push.status==="unsupported"?h??"Unavailable — requires a secure browser with service-worker support.":e.push.status==="needs-permission"?h??"Needs permission — allow notifications, then choose Enable or Repair.":e.push.status==="on"?"On — this browser and the server agree on the current Web Push configuration.":e.push.status==="repairing"?"Repairing — checking the browser subscription and server acknowledgement…":e.push.status==="error"?"Repair needed — the browser and server could not confirm the same subscription.":"Off — enable notifications for this browser.";return v.jsxs(mo,{title:"Settings",onClose:e.onClose,wide:!0,children:[v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Display name"}),v.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Your address"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),v.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Public bio"}),v.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),a(null)}}),v.jsx("button",{className:"btn sm",onClick:()=>{a(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>a(String(p)))},children:i?"Saved":"Save bio"}),l&&v.jsx("p",{className:"onb-error",children:l})]}),v.jsxs("label",{style:{display:"flex",gap:9},children:[v.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Notifications"}),v.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&v.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),v.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[v.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>d("full")})," Full — sender and message text or filename"]}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>d("private")})," Private — generic content only"]})]}),v.jsx("p",{className:"muted",children:"Full previews can expose sender names, message text, and filenames on the lock screen. The push provider still sees delivery endpoint, timing, and payload size metadata in either mode."}),v.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&v.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):v.jsx("button",{className:"btn primary",disabled:e.busy||!e.workerSupported||e.push.status==="unsupported",onClick:()=>void e.onPushAction(e.push.status==="error"||e.push.blocked?"repair":"enable",c),children:e.busy?"Repairing…":e.push.status==="error"||e.push.blocked?"Repair":"Enable notifications"})})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"App status"}),v.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.updateAvailable&&v.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Build"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function wz(e,t,n,i,s=6e4){return!t||!t.sha?"current":t.sha===e?(n.remoteSha=null,n.firstMismatchAt=null,"current"):(n.remoteSha=t.sha,(n.firstMismatchAt===null||n.firstMismatchAt===void 0)&&(n.firstMismatchAt=i),n.controllerChanged?"newer-available":i-n.firstMismatchAt>=s?"stuck":"newer-available")}const kz="bfdaf62f987be43dd555ef9a8eaace0ef12e5845",Sz=15*6e4,bz=6e4,Cz=wz;async function Ez(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Tz(e){const t={remoteSha:null,firstMismatchAt:null,controllerChanged:!1},n=()=>{t.controllerChanged=!0};navigator.serviceWorker?.addEventListener("controllerchange",n);let i=!1;const s=async()=>{const d=await Ez(),h=Cz(kz,d,t,Date.now(),bz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(d.sha))},l=setTimeout(()=>void s(),5e3),a=setInterval(()=>void s(),Sz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(l),clearInterval(a),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Pz(e){try{const t=await navigator.serviceWorker.getRegistrations();await Promise.all(t.map(i=>i.unregister()));const n=await caches.keys();await Promise.all(n.map(i=>caches.delete(i)))}catch{}return location.replace(location.pathname+"?v="+encodeURIComponent(e)),new Promise(()=>{})}function Rz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Cx=[0,100,400,1e3,3e3,6e3],Ex=e=>new Promise(t=>setTimeout(t,e)),Tx={delivered:1,read:2},Px="ours-dark-v3",Rx="#chat-message-",Ax=jl,Az=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function Yk(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const l={dir:s.dir,text:s.text,date:s.date,read:s.read,wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:null,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id};s.wire_id?n.set(s.wire_id,l):i.push(l)}for(const s of t){const l=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:l?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:l?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:l?.receipt})}return[...i,...n.values()].sort((s,l)=>{const a=Ax(s.date)-Ax(l.date);return a===0?s.wireId.localeCompare(l.wireId):a})}function Mz(e){const t={};for(const n of Object.values(e.roots??{}))t[n.root_cid]={label:n.root_name,note:"Verified identity"};return t}function Nz(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],l=ci(e,i.container_id),c=Yk(l,t[i.container_id]??[]).at(-1),d=Dl(i);return{id:i.container_id,name:d,announcedName:i.name,initials:Ss(d),when:c?S2(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?N2(c.filename,c.mime):l?.preview??c?.text??"",unread:l?.unread??0,status:"active",root:s?.root_cid??null,sub:s?`role “${s.role_id}” of ${s.root_name}`:"",roleId:s?.role_id??null,rootName:s?.root_name??null,mine:!1,kind:s?"agent":"person"}}),...e.contacts.pending.map(i=>{const s=Dl(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:Ss(s),when:"",activityAt:"",last:`${i.queued} queued · approval required`,unread:0,status:"pending",root:null,sub:"",roleId:null,rootName:null,mine:!1,kind:"person"}})]}function jz(){return v.jsx(Iz,{})}function Iz(){const e=k.useRef(uA(Jy(window.location.pathname))).current,[t,n]=k.useReducer(nv,e),[i,s]=k.useState(null),l=k.useRef(0),a=k.useRef(null),c=k.useRef(t),d=k.useRef(new aA),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[y,w]=k.useState({}),S=k.useRef(y),[E,T]=k.useState(null),C=k.useRef(new Set),[R,A]=k.useState(null),D=k.useRef(R),B=k.useRef(!1),[I,q]=k.useState([]),[$,K]=k.useState(null),[j,Y]=k.useState(()=>localStorage.getItem(Px)!=="0"),[W,ue]=k.useState(null),[Z,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[ge,Ce]=k.useState({status:"unsupported",preview:"full"}),[X,ce]=k.useState(!1),[P,L]=k.useState(!1),G=k.useRef(null),M=k.useRef(null),[J,he]=k.useState(()=>window.location.hash.startsWith(Rx)),{toasts:me,push:ve,dismiss:Ee,clear:Re}=hz(),Be=k.useCallback((O=!1)=>{L(!1),O&&G.current?.focus()},[]);k.useEffect(()=>{P&&requestAnimationFrame(()=>M.current?.querySelector('[role="menuitem"]')?.focus())},[P]);const ft=O=>{const te=[...M.current?.querySelectorAll('[role="menuitem"]')??[]],de=te.indexOf(document.activeElement);if(O.key==="Escape"){O.preventDefault(),Be(!0);return}if(O.key==="Tab"){O.preventDefault();const Pe=O.shiftKey;L(!1),requestAnimationFrame(()=>{const pe=[...document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(Ye=>Ye.offsetParent!==null&&!M.current?.contains(Ye)),Oe=G.current?pe.indexOf(G.current):-1;(Oe<0?G.current:pe[Oe+(Pe?-1:1)]??G.current)?.focus()});return}if(!["ArrowDown","ArrowUp","Home","End"].includes(O.key)||te.length===0)return;O.preventDefault();const je=O.key==="Home"?0:O.key==="End"?te.length-1:O.key==="ArrowUp"?(de-1+te.length)%te.length:(de+1)%te.length;te[je]?.focus()},qe=k.useCallback(O=>{c.current=nv(c.current,O),n(O)},[]),lt=k.useCallback(O=>{B.current=O},[]);k.useEffect(()=>{c.current=t},[t]),D.current=R,S.current=y,k.useMemo(()=>(hv(Object.values(y).flat()),null),[y]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",j),()=>document.documentElement.classList.remove("theme-dark")),[j]);const _e=k.useCallback(O=>qe({type:"error",message:Az(O)}),[qe]),tn=k.useCallback(()=>{const O=c.current;return{visibility:document.visibilityState,appRoute:O.route.name==="chats"?"chats":"other",selectedContactCid:si(O),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:O.mobileDetailOpen,conversationCoveringDialogOpen:D.current!==null}},[]),Rt=k.useCallback(async(O,te=!0)=>{try{const de=await Qe.conversation(O);return qe({type:"page",contactCid:O,page:de}),de}catch(de){return te&&_e(de),null}},[qe,_e]),Xe=k.useCallback(async(O,te=!0)=>{try{const de=await Qe.files(O);return hv(de.files),w(je=>({...je,[O]:de.files})),de.files}catch(de){return te&&_e(de),null}},[_e]);k.useEffect(()=>Tz({onUpdateAvailable:()=>ee(O=>({...O,updateAvailable:!0})),onStuck:O=>{Pz(O)}}),[]);const mt=k.useCallback(async()=>{const O=await Qe.contacts();return qe({type:"contacts",contacts:{...O,pending:O.pending??[]}}),O},[qe]),dt=k.useCallback(async()=>{try{const[O,te,de]=await Promise.all([Qe.identity(),Qe.contacts(),Qe.buildInfo()]),je={...te,pending:te.pending??[]};return c.current.identity&&c.current.identity.cid!==O.cid&&(R2(),S.current={},w({})),qe({type:"snapshot",identity:O,contacts:je}),K(de),await Promise.all(je.contacts.flatMap(Pe=>[Rt(Pe.container_id,!1),Xe(Pe.container_id,!1)])),si(c.current)}catch(O){return _e(O),null}},[qe,Xe,Rt,_e]),He=k.useCallback(async O=>{await d.current.request(O,async()=>{sA(O,tn())&&(await Qe.markRead(O),await Promise.all([Rt(O),mt()]))}).catch(_e)},[tn,mt,Rt,_e]),Dt=k.useCallback(async O=>{const te=++l.current;a.current?.abort();const de=new AbortController;a.current=de,s(null),Re(O),Xe(O,!1);let je;try{je=await Qe.conversation(O,void 0,de.signal)}catch(rt){de.signal.aborted||_e(rt);return}if(de.signal.aborted||te!==l.current)return;qe({type:"page",contactCid:O,page:je});const Pe=je.unread;let pe=[...je.messages],Oe=je.nextBefore;const xt=new Set,Ye=new Set(pe.map(rt=>rt.wire_id).filter(Boolean)),wt=()=>pe.filter(rt=>rt.dir==="in"&&!rt.read);for(;wt().length<Pe&&Oe&&!xt.has(Oe);){xt.add(Oe);let rt;try{rt=await Qe.conversation(O,Oe,de.signal)}catch{break}if(de.signal.aborted||te!==l.current)return;const Bt=rt.messages.filter(Ct=>!Ct.wire_id||!Ye.has(Ct.wire_id));if(!Bt.length&&rt.nextBefore===Oe)break;for(const Ct of Bt)Ct.wire_id&&Ye.add(Ct.wire_id);pe=[...Bt,...pe],qe({type:"older_page",contactCid:O,page:rt,newer:je.messages}),Oe=rt.nextBefore}const At=wt()[0];At?.wire_id&&te===l.current&&!de.signal.aborted&&s({contactCid:O,wireId:At.wire_id,count:Pe}),await He(O)},[Re,qe,He,Xe,_e]),_t=k.useCallback(async(O,te,de="page")=>{const je=`page:${O}:${de}`,Pe=(m.current.get(je)??0)+1;m.current.set(je,Pe);for(const pe of Cx){if(pe&&await Ex(pe),m.current.get(je)!==Pe)return;const Oe=await Rt(O,!1);if(Oe&&te(Oe))return}},[Rt]),Un=k.useCallback(async(O,te)=>{const de=`file:${O}`,je=(m.current.get(de)??0)+1;m.current.set(de,je);for(const Pe of Cx)if(Pe&&await Ex(Pe),m.current.get(de)!==je||(await Xe(O,!1))?.some(Oe=>Oe.wire_id===te))return},[Xe]),rr=k.useRef(!1);k.useEffect(()=>{if(!J||!t.loaded)return;const O=decodeURIComponent(window.location.hash.slice(Rx.length)),te=si(c.current);if(!O||!te){he(!1);return}if(ci(c.current,te)?.messages.some(de=>de.wire_id===O)){he(!1);return}rr.current||(rr.current=!0,_t(te,de=>de.messages.some(je=>je.wire_id===O),`anchor:${O}`).catch(()=>{}).finally(()=>he(!1)))},[J,_t,t.loaded,t.pages]),k.useMemo(()=>(P2({url:O=>Object.values(S.current).flat().find(de=>de.wire_id===O)?.available?Qe.mediaUrl(O):null,bytes:async O=>{if(!Object.values(S.current).flat().find(je=>je.wire_id===O)?.available)return null;const de=await fetch(Qe.mediaUrl(O),{cache:"no-store",credentials:"same-origin"});if(!de.ok)throw new Error(`Media request failed (HTTP ${de.status})`);return new Uint8Array(await de.arrayBuffer())},fetch:async O=>{const te=Object.values(S.current).flat().find(de=>de.wire_id===O);if(!te)throw new Error("Media record is unavailable");await Qe.fetchFiles([O]),await Xe(te.contact_id)}}),null),[Xe]),k.useEffect(()=>{let O;dA(de=>{ee(de),ov(de.registration).then(Ce).catch(()=>Ce(je=>({...je,status:"error"})))},{shouldDeferReload:()=>B.current||D.current!==null}).then(de=>{O=de}).catch(_e);const te=de=>{de.preventDefault(),ue(de)};return window.addEventListener("beforeinstallprompt",te),()=>{O?.(),window.removeEventListener("beforeinstallprompt",te)}},[_e]),k.useEffect(()=>wA(),[]),k.useEffect(()=>{if(!(!Z.registration||ge.status!=="on"))return oA({registration:Z.registration,identity:Qe.identity,onEvent:p0})},[ge.status,ge.bindingId,Z.registration]),k.useEffect(()=>{const O=()=>Ce(te=>({...te,status:"error"}));return window.addEventListener("ours-push-repair-required",O),()=>window.removeEventListener("ours-push-repair-required",O)},[]),k.useEffect(()=>{window.location.pathname==="/"&&window.history.replaceState(null,"",Jo()),h.current=window.matchMedia("(min-width: 861px)");const O=()=>{const pe=Jy(window.location.pathname);a.current?.abort(),l.current+=1,s(null),qe({type:"route",route:pe}),pe.name==="chats"&&pe.contactCid&&Dt(pe.contactCid)},te=()=>{if(document.visibilityState!=="visible")return;const pe=si(c.current);pe&&He(pe),v0(),Z.registration&&ov(Z.registration).then(Ce).catch(()=>Ce(Oe=>({...Oe,status:"error"})))};window.addEventListener("popstate",O),document.addEventListener("visibilitychange",te);const de=pe=>{const Oe=pe.type==="sync_required"?`${pe.type}:${pe.reason}`:pe.type==="receipt_received"?`${pe.type}:${pe.contact_id}:${pe.kind}:${pe.wire_ids.join(",")}`:`${pe.type}:${pe.contact_id}:${pe.wire_id}`,xt=Date.now(),Ye=p.current.get(Oe)??0;p.current.set(Oe,xt);for(const[wt,At]of p.current)xt-At>6e4&&p.current.delete(wt);xt-Ye<6e4||(async()=>{if(pe.type==="sync_required"){await dt();return}if(mt().catch(_e),pe.type==="file_received"){await Un(pe.contact_id,pe.wire_id);const wt=c.current.contacts.contacts.find(At=>At.container_id===pe.contact_id);si(c.current)!==pe.contact_id&&wt&&ve(pe.contact_id,Dl(wt),"New file");return}if(pe.type==="message_received"){const wt=c.current.contacts.contacts.find(At=>At.container_id===pe.contact_id);await _t(pe.contact_id,At=>At.messages.some(rt=>rt.wire_id===pe.wire_id),`message:${pe.wire_id}`),si(c.current)===pe.contact_id?await He(pe.contact_id):wt&&ve(pe.contact_id,Dl(wt),"New message");return}qe({type:"receipt",contactCid:pe.contact_id,kind:pe.kind,wireIds:pe.wire_ids}),await _t(pe.contact_id,wt=>pe.wire_ids.every(At=>{const rt=wt.messages.find(Bt=>Bt.wire_id===At);return!!rt?.receipt&&Tx[rt.receipt]>=Tx[pe.kind]}),`receipt:${pe.wire_ids.join(",")}`)})().catch(_e)},je=tA(de),Pe=nA(de,pe=>qe({type:"connection",connection:pe}));return dt().then(pe=>{pe&&Dt(pe)}),()=>{Pe(),je(),window.removeEventListener("popstate",O),document.removeEventListener("visibilitychange",te)}},[_t,Un,qe,He,Dt,ve,mt,dt,_e,Z.registration]);const dn=(O,te,de)=>{window.history.pushState(null,"",te),qe({type:"route",route:O,mobileDetailOpen:de})},Q=async O=>{dn({name:"chats",contactCid:O},Jo(O),!0),await Dt(O)},le=async O=>{const te=ci(c.current,O);if(!(!te?.nextBefore||C.current.has(O))){C.current.add(O),T(O);try{const de=await Qe.conversation(O,te.nextBefore);qe({type:"older_page",contactCid:O,page:de,newer:te.messages})}catch(de){_e(de)}finally{C.current.delete(O),T(null)}}},fe=si(t),Le=t.contacts.contacts.find(O=>O.container_id===fe),Fe=k.useMemo(()=>Nz(t,y),[t,y]),gt=Fe.find(O=>O.id===fe)??null,Lt=fe?Yk(ci(t,fe),y[fe]??[]):[],nt=t.identity,nn=t.loaded?fe&&!ci(t,fe)||J?"updating":t.connection!=="live"?"connecting":null:"connecting",z=async(O,te=ge.preview)=>{if(Z.registration){ce(!0),Ce(de=>({...de,status:"repairing",preview:te}));try{Ce(await(O==="enable"?y0(Z.registration,{preview:te}):O==="repair"?vA(Z.registration,te):xA(Z.registration,ge)))}catch(de){Ce(je=>({...je,status:"error"})),_e(de)}finally{ce(!1)}}},re=()=>{q([]),A("invite"),Qe.invites().then(q).catch(_e)};return t.route.name==="not_found"?v.jsxs("div",{className:"centered-screen",children:[v.jsx("h1",{children:"Page not found"}),v.jsx("button",{className:"btn primary",onClick:()=>dn({name:"chats",contactCid:null},Jo()),children:"Open chats"})]}):nt?v.jsx("div",{className:j?"theme-dark":"",style:{height:"100%"},children:v.jsxs("div",{className:"app signal-app",children:[v.jsxs("header",{className:"commandbar",children:[v.jsx("div",{className:"command-brand","aria-label":"ours network",children:v.jsx("span",{children:"Ours"})}),v.jsxs("div",{className:"command-copy",children:[v.jsx("span",{className:"command-kicker",children:"ours / encrypted network"}),v.jsx("strong",{children:"Chats"})]}),v.jsxs("div",{className:"command-actions",children:[W&&v.jsx("button",{className:"command-action",onClick:()=>void W.prompt().then(()=>ue(null)),children:"Install app"}),v.jsxs("button",{className:"command-action",onClick:re,children:[v.jsx(Se,{name:"plus"}),v.jsx("span",{children:"New chat"})]}),v.jsx("button",{className:"icon-btn command-settings",title:"Settings","aria-label":"Settings",onClick:()=>A("settings"),children:v.jsx(Se,{name:"settings"})}),v.jsxs("button",{ref:G,className:"rail-me command-me",title:nt.name,"aria-label":`${nt.name} account menu`,"aria-haspopup":"menu","aria-expanded":P,"aria-controls":"account-menu",onClick:()=>L(O=>!O),children:[Ss(nt.name),v.jsx("span",{className:"conn-dot "+(t.connection==="live"?"on":"off")})]})]})]}),v.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[v.jsx(sz,{contacts:Fe,roots:Mz(t.contacts),selected:fe,onSelect:O=>{O.startsWith("pending:")||Q(O)},onInvite:re,onSettings:()=>A("settings"),onApprovePending:async O=>{try{return await Qe.respondToIntroduction(O,"approve"),await dt(),!0}catch(te){return _e(te),!1}},onRejectPending:async O=>{try{return await Qe.respondToIntroduction(O,"reject"),await dt(),!0}catch(te){return _e(te),!1}}}),v.jsx(az,{contact:gt,messages:Lt,syncing:nn,unreadOpen:i?.contactCid===fe?i:null,hiddenEarlier:ci(t,fe??"")?.hasMore?Math.max(1,(ci(t,fe??"")?.total??Lt.length)-Lt.length):0,onLoadEarlier:fe&&E!==fe?()=>void le(fe):void 0,onBack:()=>{a.current?.abort(),l.current+=1,s(null),dn({name:"chats",contactCid:null},Jo(),!1)},onDraftChange:lt,onSend:async(O,te,de)=>{if(!fe)return;const je=fe,Pe=await Qe.send(je,O,te,de);return qe({type:"sent_message",contactCid:je,message:{dir:"out",text:O,date:new Date().toISOString(),read:!0,wire_id:Pe.wire_id??"",receipt:null,reply_to:te?{wire_id:te}:null}}),Pe.wire_id?_t(je,pe=>pe.messages.some(Oe=>Oe.wire_id===Pe.wire_id),`send:${Pe.wire_id}`):mt().catch(_e),Pe.wire_id??void 0},onSendFile:async(O,te)=>{fe&&(await Qe.sendFile(fe,new Blob([O.bytes],{type:O.mime}),O.filename,O.mime,te),await Promise.all([Xe(fe),Rt(fe,!1)]))},onFetchFile:async O=>{await Qe.fetchFiles([O]),fe&&await Xe(fe)},onRename:O=>{fe&&Qe.renameContact(fe,O).then(dt).catch(_e)},onRemove:()=>{fe&&confirm(`Remove “${Le?.name??"contact"}”?`)&&Qe.removeContact(fe).then(()=>(dn({name:"chats",contactCid:null},Jo(),!1),dt())).catch(_e)}},fe??"no-conversation")]}),v.jsxs("div",{className:"app-banners",children:[Z.offline&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),Z.updateAvailable&&v.jsxs("div",{className:"banner info",children:[v.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>{Z.registration&&rv(Z.registration)},children:"Restart now"})})]}),v.jsx(mz,{items:me,onDismiss:Ee,onOpen:O=>void Q(O)})]}),P&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"pop-backdrop","aria-hidden":"true",onClick:()=>Be(!0)}),v.jsxs("div",{id:"account-menu",ref:M,className:"menu command-menu",role:"menu","aria-label":`${nt.name} account`,onKeyDown:ft,children:[v.jsxs("div",{className:"menu-head",children:[v.jsx("div",{className:"avatar accent lg",children:Ss(nt.name)}),v.jsxs("div",{children:[v.jsx("strong",{children:nt.name}),v.jsxs("div",{className:"faint mono",children:["@",yh(nt.cid)]})]})]}),v.jsxs("button",{className:"menu-item",role:"menuitem",onClick:()=>{L(!1),re()},children:[v.jsx(Se,{name:"plus"}),"Invite a contact"]}),v.jsxs("button",{className:"menu-item",role:"menuitem",onClick:()=>{L(!1),A("settings")},children:[v.jsx(Se,{name:"settings"}),"Settings"]})]})]}),R==="invite"&&v.jsx(vz,{identity:nt,invites:I,onRefresh:async()=>q(await Qe.invites()),onCreate:async(O,te)=>(await Qe.createInvite(O,te)).blob,onAccept:async(O,te)=>{await Qe.addContact(O,te),await dt()},onRevoke:async O=>{await Qe.revokeInvite(O)},onClose:()=>{A(null),dt()}}),R==="settings"&&v.jsx(xz,{identity:nt,push:ge,workerSupported:Z.supported,busy:X,offline:Z.offline,updateAvailable:Z.updateAvailable,build:$,dark:j,onToggleDark:()=>Y(O=>(localStorage.setItem(Px,O?"0":"1"),!O)),onSaveBio:async O=>{await Qe.setBio(O),await dt()},onPushAction:z,onReloadUpdate:()=>{Z.registration&&rv(Z.registration)},onClose:()=>{D.current=null,A(null),fe&&He(fe)}}),t.error&&v.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,v.jsx("button",{className:"linkbtn",onClick:()=>qe({type:"error",message:null}),children:"dismiss"})]})]})}):v.jsx("div",{className:j?"theme-dark":"",style:{height:"100%"},children:v.jsx("div",{className:"centered-screen",children:v.jsx("p",{className:"muted",children:"Loading…"})})})}Rz();const Gk=document.getElementById("root");if(!Gk)throw new Error("missing #root");Jb.createRoot(Gk).render(v.jsx(GP,{reducedMotion:"user",children:v.jsx(jz,{})}));export{Mh as _,Od as g};
317
+ //# sourceMappingURL=index-Ds2T7P1J.js.map