termdock 1.4.295 → 1.4.297

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 (367) hide show
  1. package/.desktop-dist/main.js +35 -2
  2. package/README.en.md +257 -0
  3. package/README.md +284 -133
  4. package/dist/client/assets/App-BbqtNY2x.js +177 -0
  5. package/dist/client/assets/App-BbqtNY2x.js.br +0 -0
  6. package/dist/client/assets/App-BbqtNY2x.js.gz +0 -0
  7. package/dist/client/assets/{ChangeWalkthroughPanel-Dv5XRtRh.js → ChangeWalkthroughPanel-CvQJIp_C.js} +1 -1
  8. package/dist/client/assets/ChangeWalkthroughPanel-CvQJIp_C.js.br +0 -0
  9. package/dist/client/assets/ChangeWalkthroughPanel-CvQJIp_C.js.gz +0 -0
  10. package/dist/client/assets/CollaborationMainWorkspace-B0OgRtyR.js +1 -0
  11. package/dist/client/assets/CollaborationMainWorkspace-B0OgRtyR.js.br +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-B0OgRtyR.js.gz +0 -0
  13. package/dist/client/assets/CollaborationTaskContent-C01GXOEq.js +2 -0
  14. package/dist/client/assets/ComputerControlView-CW1uA133.js +4 -0
  15. package/dist/client/assets/ComputerControlView-CW1uA133.js.br +0 -0
  16. package/dist/client/assets/ComputerControlView-CW1uA133.js.gz +0 -0
  17. package/dist/client/assets/{DagPlayground-mq69dKyr.js → DagPlayground-CdE3tQsl.js} +1 -1
  18. package/dist/client/assets/DagPlayground-CdE3tQsl.js.br +0 -0
  19. package/dist/client/assets/DagPlayground-CdE3tQsl.js.gz +0 -0
  20. package/dist/client/assets/{DiffLab-BqdHYGi5.js → DiffLab-BLGNnazd.js} +1 -1
  21. package/dist/client/assets/DiffLab-BLGNnazd.js.br +0 -0
  22. package/dist/client/assets/DiffLab-BLGNnazd.js.gz +0 -0
  23. package/dist/client/assets/{DiffReview-BvzGxpuc.js → DiffReview-CYw3ASI6.js} +1 -1
  24. package/dist/client/assets/DiffReview-CYw3ASI6.js.br +0 -0
  25. package/dist/client/assets/DiffReview-CYw3ASI6.js.gz +0 -0
  26. package/dist/client/assets/{DiffReviewLab-DrfddB7x.js → DiffReviewLab-CySIuWq_.js} +1 -1
  27. package/dist/client/assets/DiffReviewLab-CySIuWq_.js.br +0 -0
  28. package/dist/client/assets/DiffReviewLab-CySIuWq_.js.gz +0 -0
  29. package/dist/client/assets/{DiffViewer-3bJV_A5s.js → DiffViewer-WsYvN75z.js} +13 -13
  30. package/dist/client/assets/DiffViewer-WsYvN75z.js.br +0 -0
  31. package/dist/client/assets/DiffViewer-WsYvN75z.js.gz +0 -0
  32. package/dist/client/assets/{ModelPreview-CX7VtoJB.js → ModelPreview-Dnlx9ByX.js} +1 -1
  33. package/dist/client/assets/ModelPreview-Dnlx9ByX.js.br +0 -0
  34. package/dist/client/assets/ModelPreview-Dnlx9ByX.js.gz +0 -0
  35. package/dist/client/assets/RightSidebar-Cp5b_y0u.js +1678 -0
  36. package/dist/client/assets/RightSidebar-Cp5b_y0u.js.br +0 -0
  37. package/dist/client/assets/RightSidebar-Cp5b_y0u.js.gz +0 -0
  38. package/dist/client/assets/{abnfDiagram-VCTEODGH-PJwhLTPH.js → abnfDiagram-VCTEODGH-CK1mGFRQ.js} +1 -1
  39. package/dist/client/assets/abnfDiagram-VCTEODGH-CK1mGFRQ.js.br +0 -0
  40. package/dist/client/assets/abnfDiagram-VCTEODGH-CK1mGFRQ.js.gz +0 -0
  41. package/dist/client/assets/app-DfACMixk.js +35 -0
  42. package/dist/client/assets/app-DfACMixk.js.br +0 -0
  43. package/dist/client/assets/app-DfACMixk.js.gz +0 -0
  44. package/dist/client/assets/{arc-l3FXjCEl.js → arc-yZE1gqDl.js} +1 -1
  45. package/dist/client/assets/arc-yZE1gqDl.js.br +0 -0
  46. package/dist/client/assets/arc-yZE1gqDl.js.gz +0 -0
  47. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DdNbKi-4.js → architectureDiagram-5GKGNRK7-U5XSC7cY.js} +1 -1
  48. package/dist/client/assets/architectureDiagram-5GKGNRK7-U5XSC7cY.js.br +0 -0
  49. package/dist/client/assets/architectureDiagram-5GKGNRK7-U5XSC7cY.js.gz +0 -0
  50. package/dist/client/assets/{blockDiagram-I7D4REHJ-Cu63oaxR.js → blockDiagram-I7D4REHJ-pVJnntSG.js} +1 -1
  51. package/dist/client/assets/blockDiagram-I7D4REHJ-pVJnntSG.js.br +0 -0
  52. package/dist/client/assets/blockDiagram-I7D4REHJ-pVJnntSG.js.gz +0 -0
  53. package/dist/client/assets/{c4Diagram-7LVT6UL2-DQiV_yk6.js → c4Diagram-7LVT6UL2-Bwz0AJJV.js} +1 -1
  54. package/dist/client/assets/c4Diagram-7LVT6UL2-Bwz0AJJV.js.br +0 -0
  55. package/dist/client/assets/c4Diagram-7LVT6UL2-Bwz0AJJV.js.gz +0 -0
  56. package/dist/client/assets/channel-qqjDJtcZ.js +1 -0
  57. package/dist/client/assets/{chunk-2Q5K7J3B-COKJ79Ld.js → chunk-2Q5K7J3B-CXJ1kP4X.js} +1 -1
  58. package/dist/client/assets/{chunk-5VM5RSS4-BfV-m7oa.js → chunk-5VM5RSS4-Dpdum_2z.js} +1 -1
  59. package/dist/client/assets/{chunk-F27PBJKO-sLDCEnU8.js → chunk-F27PBJKO-BCG5Zi_-.js} +1 -1
  60. package/dist/client/assets/chunk-F27PBJKO-BCG5Zi_-.js.br +0 -0
  61. package/dist/client/assets/chunk-F27PBJKO-BCG5Zi_-.js.gz +0 -0
  62. package/dist/client/assets/{chunk-IMKFNOWR-DYu5qS7g.js → chunk-IMKFNOWR-BM-GcNcv.js} +1 -1
  63. package/dist/client/assets/chunk-IMKFNOWR-BM-GcNcv.js.br +0 -0
  64. package/dist/client/assets/chunk-IMKFNOWR-BM-GcNcv.js.gz +0 -0
  65. package/dist/client/assets/{chunk-JWPE2WC7-DixkILcl.js → chunk-JWPE2WC7-BWiXpQT9.js} +1 -1
  66. package/dist/client/assets/{chunk-POPQ4Y6H-CfW5Vm_-.js → chunk-POPQ4Y6H-vQSslMNv.js} +1 -1
  67. package/dist/client/assets/{chunk-SVP7TREG-nJnbUFzs.js → chunk-SVP7TREG-Aqfz6nPA.js} +1 -1
  68. package/dist/client/assets/chunk-SVP7TREG-Aqfz6nPA.js.br +0 -0
  69. package/dist/client/assets/chunk-SVP7TREG-Aqfz6nPA.js.gz +0 -0
  70. package/dist/client/assets/{chunk-TICWLB2K-BwyiSQgx.js → chunk-TICWLB2K-DDjekMd0.js} +1 -1
  71. package/dist/client/assets/chunk-TICWLB2K-DDjekMd0.js.br +0 -0
  72. package/dist/client/assets/chunk-TICWLB2K-DDjekMd0.js.gz +0 -0
  73. package/dist/client/assets/{chunk-XXDRQBXY-TCk4c2XN.js → chunk-XXDRQBXY-BegIBcFg.js} +1 -1
  74. package/dist/client/assets/classDiagram-ZZMXUADV-BDuBrfNz.js +1 -0
  75. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BDuBrfNz.js +1 -0
  76. package/dist/client/assets/{cose-bilkent-JH36ORCC-rroo-EOb.js → cose-bilkent-JH36ORCC-B2izFsBY.js} +1 -1
  77. package/dist/client/assets/cose-bilkent-JH36ORCC-B2izFsBY.js.br +0 -0
  78. package/dist/client/assets/cose-bilkent-JH36ORCC-B2izFsBY.js.gz +0 -0
  79. package/dist/client/assets/{cynefin-OW5HDTMX-CkFeV85k.js → cynefin-OW5HDTMX-C7HA99Zc.js} +1 -1
  80. package/dist/client/assets/cynefin-OW5HDTMX-C7HA99Zc.js.br +0 -0
  81. package/dist/client/assets/{cynefin-OW5HDTMX-CkFeV85k.js.gz → cynefin-OW5HDTMX-C7HA99Zc.js.gz} +0 -0
  82. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-hBwpU_bW.js → cynefinDiagram-5FMLGOSQ-vNIzcCYl.js} +1 -1
  83. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vNIzcCYl.js.br +0 -0
  84. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-vNIzcCYl.js.gz +0 -0
  85. package/dist/client/assets/{dagre-GXQ25YYZ-B321-hdp.js → dagre-GXQ25YYZ-Bv9WHNT9.js} +1 -1
  86. package/dist/client/assets/dagre-GXQ25YYZ-Bv9WHNT9.js.br +0 -0
  87. package/dist/client/assets/dagre-GXQ25YYZ-Bv9WHNT9.js.gz +0 -0
  88. package/dist/client/assets/{diagram-S7CK7UJ4-bY87_ptA.js → diagram-S7CK7UJ4-DFg5UNic.js} +1 -1
  89. package/dist/client/assets/diagram-S7CK7UJ4-DFg5UNic.js.br +0 -0
  90. package/dist/client/assets/diagram-S7CK7UJ4-DFg5UNic.js.gz +0 -0
  91. package/dist/client/assets/{diagram-UQ7AKVKN--cez0H_o.js → diagram-UQ7AKVKN-BFQsCAs7.js} +1 -1
  92. package/dist/client/assets/diagram-UQ7AKVKN-BFQsCAs7.js.br +0 -0
  93. package/dist/client/assets/diagram-UQ7AKVKN-BFQsCAs7.js.gz +0 -0
  94. package/dist/client/assets/{diagram-VSXAHHWV-BupH_VRK.js → diagram-VSXAHHWV-C4R8TKEv.js} +1 -1
  95. package/dist/client/assets/diagram-VSXAHHWV-C4R8TKEv.js.br +0 -0
  96. package/dist/client/assets/diagram-VSXAHHWV-C4R8TKEv.js.gz +0 -0
  97. package/dist/client/assets/{diagram-VX7I27RA-DewqaxvF.js → diagram-VX7I27RA-CL75HIf0.js} +1 -1
  98. package/dist/client/assets/diagram-VX7I27RA-CL75HIf0.js.br +0 -0
  99. package/dist/client/assets/diagram-VX7I27RA-CL75HIf0.js.gz +0 -0
  100. package/dist/client/assets/{diagram-Z3DM3KII-wDumcTuR.js → diagram-Z3DM3KII-CfJampuO.js} +1 -1
  101. package/dist/client/assets/diagram-Z3DM3KII-CfJampuO.js.br +0 -0
  102. package/dist/client/assets/diagram-Z3DM3KII-CfJampuO.js.gz +0 -0
  103. package/dist/client/assets/{ebnfDiagram-PWID7BFC-C0OY91We.js → ebnfDiagram-PWID7BFC-Ct53jhNd.js} +1 -1
  104. package/dist/client/assets/ebnfDiagram-PWID7BFC-Ct53jhNd.js.br +0 -0
  105. package/dist/client/assets/ebnfDiagram-PWID7BFC-Ct53jhNd.js.gz +0 -0
  106. package/dist/client/assets/{erDiagram-RLTQ6QDP-Cw9aNqvJ.js → erDiagram-RLTQ6QDP-BgL2xOOa.js} +1 -1
  107. package/dist/client/assets/erDiagram-RLTQ6QDP-BgL2xOOa.js.br +0 -0
  108. package/dist/client/assets/erDiagram-RLTQ6QDP-BgL2xOOa.js.gz +0 -0
  109. package/dist/client/assets/{flowDiagram-HODETNUW-BC7XUXeI.js → flowDiagram-HODETNUW-Cp4Nu5jY.js} +1 -1
  110. package/dist/client/assets/{flowDiagram-HODETNUW-BC7XUXeI.js.br → flowDiagram-HODETNUW-Cp4Nu5jY.js.br} +0 -0
  111. package/dist/client/assets/flowDiagram-HODETNUW-Cp4Nu5jY.js.gz +0 -0
  112. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DovhJIz5.js → ganttDiagram-EL5Y4UJY-DI0rdyPX.js} +1 -1
  113. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DI0rdyPX.js.br +0 -0
  114. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DI0rdyPX.js.gz +0 -0
  115. package/dist/client/assets/{gestureArbiter-wjVok2Lg.js → gestureArbiter-Belsq4xq.js} +1 -1
  116. package/dist/client/assets/gestureArbiter-Belsq4xq.js.br +0 -0
  117. package/dist/client/assets/gestureArbiter-Belsq4xq.js.gz +0 -0
  118. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-BmrbbyW1.js → gitGraphDiagram-WWUBYQGX-C0H4loQP.js} +1 -1
  119. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0H4loQP.js.br +0 -0
  120. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C0H4loQP.js.gz +0 -0
  121. package/dist/client/assets/index-CYmI1EsU.css +1 -0
  122. package/dist/client/assets/index-CYmI1EsU.css.br +0 -0
  123. package/dist/client/assets/index-CYmI1EsU.css.gz +0 -0
  124. package/dist/client/assets/{infoDiagram-27XIBGKW-CQEu4Jwy.js → infoDiagram-27XIBGKW-BN4RpQTL.js} +1 -1
  125. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BPqibqsm.js → ishikawaDiagram-5VMMS53U-BZQ5qZB_.js} +1 -1
  126. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BZQ5qZB_.js.br +0 -0
  127. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BZQ5qZB_.js.gz +0 -0
  128. package/dist/client/assets/{journeyDiagram-3NMN7TZE-DIkhubnf.js → journeyDiagram-3NMN7TZE-Q8bx0_N4.js} +1 -1
  129. package/dist/client/assets/journeyDiagram-3NMN7TZE-Q8bx0_N4.js.br +0 -0
  130. package/dist/client/assets/journeyDiagram-3NMN7TZE-Q8bx0_N4.js.gz +0 -0
  131. package/dist/client/assets/{kanban-definition-UXKFOSKX-CBT0DIUR.js → kanban-definition-UXKFOSKX-D7JhGtpO.js} +1 -1
  132. package/dist/client/assets/kanban-definition-UXKFOSKX-D7JhGtpO.js.br +0 -0
  133. package/dist/client/assets/kanban-definition-UXKFOSKX-D7JhGtpO.js.gz +0 -0
  134. package/dist/client/assets/{layout-C1CMlOIU.js → layout-DERUg0xU.js} +1 -1
  135. package/dist/client/assets/layout-DERUg0xU.js.br +0 -0
  136. package/dist/client/assets/layout-DERUg0xU.js.gz +0 -0
  137. package/dist/client/assets/{linear-C4gyqor0.js → linear-lNTe4x00.js} +1 -1
  138. package/dist/client/assets/linear-lNTe4x00.js.br +0 -0
  139. package/dist/client/assets/linear-lNTe4x00.js.gz +0 -0
  140. package/dist/client/assets/{mermaid.core-CMfa4ncd.js → mermaid.core-WHCwLQDQ.js} +5 -5
  141. package/dist/client/assets/mermaid.core-WHCwLQDQ.js.br +0 -0
  142. package/dist/client/assets/mermaid.core-WHCwLQDQ.js.gz +0 -0
  143. package/dist/client/assets/{mindmap-definition-YA3MSWOX-C-JmgKOI.js → mindmap-definition-YA3MSWOX-BouapA4v.js} +1 -1
  144. package/dist/client/assets/mindmap-definition-YA3MSWOX-BouapA4v.js.br +0 -0
  145. package/dist/client/assets/mindmap-definition-YA3MSWOX-BouapA4v.js.gz +0 -0
  146. package/dist/client/assets/{passwordBootstrap-BmUG2IwA.js → passwordBootstrap-E0piP814.js} +1 -1
  147. package/dist/client/assets/passwordBootstrap-E0piP814.js.br +0 -0
  148. package/dist/client/assets/passwordBootstrap-E0piP814.js.gz +0 -0
  149. package/dist/client/assets/{pegDiagram-XKGWAZYB-IY-AEKQa.js → pegDiagram-XKGWAZYB-Curpo5Rq.js} +1 -1
  150. package/dist/client/assets/pegDiagram-XKGWAZYB-Curpo5Rq.js.br +0 -0
  151. package/dist/client/assets/pegDiagram-XKGWAZYB-Curpo5Rq.js.gz +0 -0
  152. package/dist/client/assets/{pieDiagram-E7YTZNPT-9Qq43qED.js → pieDiagram-E7YTZNPT-BLQCHaOG.js} +1 -1
  153. package/dist/client/assets/pieDiagram-E7YTZNPT-BLQCHaOG.js.br +0 -0
  154. package/dist/client/assets/pieDiagram-E7YTZNPT-BLQCHaOG.js.gz +0 -0
  155. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-BjQncx5i.js → quadrantDiagram-AXDQQJYC-PViFqGao.js} +1 -1
  156. package/dist/client/assets/quadrantDiagram-AXDQQJYC-PViFqGao.js.br +0 -0
  157. package/dist/client/assets/quadrantDiagram-AXDQQJYC-PViFqGao.js.gz +0 -0
  158. package/dist/client/assets/{railroadDiagram-O6MQD6OU-Cr1rL0wZ.js → railroadDiagram-O6MQD6OU-BtHo1LpT.js} +1 -1
  159. package/dist/client/assets/railroadDiagram-O6MQD6OU-BtHo1LpT.js.br +0 -0
  160. package/dist/client/assets/railroadDiagram-O6MQD6OU-BtHo1LpT.js.gz +0 -0
  161. package/dist/client/assets/rdpSession-O_f9ejOI.js +1 -0
  162. package/dist/client/assets/rdpSession-O_f9ejOI.js.br +0 -0
  163. package/dist/client/assets/rdpSession-O_f9ejOI.js.gz +0 -0
  164. package/dist/client/assets/{referenceLongPress-ConC5-ym.js → referenceLongPress-BZr7Lqzh.js} +1 -1
  165. package/dist/client/assets/referenceLongPress-BZr7Lqzh.js.br +0 -0
  166. package/dist/client/assets/referenceLongPress-BZr7Lqzh.js.gz +0 -0
  167. package/dist/client/assets/{requirementDiagram-BXWQKSXE-DU2q_iZg.js → requirementDiagram-BXWQKSXE-BUm81HUU.js} +1 -1
  168. package/dist/client/assets/requirementDiagram-BXWQKSXE-BUm81HUU.js.br +0 -0
  169. package/dist/client/assets/requirementDiagram-BXWQKSXE-BUm81HUU.js.gz +0 -0
  170. package/dist/client/assets/rfb-CxsXsMUX.js +5 -0
  171. package/dist/client/assets/rfb-CxsXsMUX.js.br +0 -0
  172. package/dist/client/assets/rfb-CxsXsMUX.js.gz +0 -0
  173. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-BYlx9kXC.js → sankeyDiagram-P5KCCOFB-B-_-aZ_y.js} +1 -1
  174. package/dist/client/assets/sankeyDiagram-P5KCCOFB-B-_-aZ_y.js.br +0 -0
  175. package/dist/client/assets/sankeyDiagram-P5KCCOFB-B-_-aZ_y.js.gz +0 -0
  176. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-D_uAKme-.js → sequenceDiagram-WJ2MYXX4-DT6LDIfx.js} +1 -1
  177. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DT6LDIfx.js.br +0 -0
  178. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DT6LDIfx.js.gz +0 -0
  179. package/dist/client/assets/{sizeCapture-INFHLROL-H_uqscf4.js → sizeCapture-INFHLROL-CTYerd9j.js} +1 -1
  180. package/dist/client/assets/sizeCapture-INFHLROL-CTYerd9j.js.br +0 -0
  181. package/dist/client/assets/sizeCapture-INFHLROL-CTYerd9j.js.gz +0 -0
  182. package/dist/client/assets/{sparkles-D2z4Ue6G.js → sparkles-CgaUBIwH.js} +1 -1
  183. package/dist/client/assets/{stateDiagram-D77RDMKH-BvsQjIIW.js → stateDiagram-D77RDMKH-CQbb5x2_.js} +1 -1
  184. package/dist/client/assets/stateDiagram-D77RDMKH-CQbb5x2_.js.br +0 -0
  185. package/dist/client/assets/stateDiagram-D77RDMKH-CQbb5x2_.js.gz +0 -0
  186. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CJAVXcx1.js +1 -0
  187. package/dist/client/assets/{swimlanes-42K2YHIH-LmUJag-p.js → swimlanes-42K2YHIH-BHZ4X2Fd.js} +1 -1
  188. package/dist/client/assets/swimlanes-42K2YHIH-BHZ4X2Fd.js.br +0 -0
  189. package/dist/client/assets/swimlanes-42K2YHIH-BHZ4X2Fd.js.gz +0 -0
  190. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-VL2nyI27.js +8 -0
  191. package/dist/client/assets/{timeline-definition-24CTP7MA-DZ5n0Pim.js → timeline-definition-24CTP7MA-BrjH6R6w.js} +1 -1
  192. package/dist/client/assets/timeline-definition-24CTP7MA-BrjH6R6w.js.br +0 -0
  193. package/dist/client/assets/timeline-definition-24CTP7MA-BrjH6R6w.js.gz +0 -0
  194. package/dist/client/assets/{triangle-alert-Ct6iIBmv.js → triangle-alert-C9IHD_eF.js} +1 -1
  195. package/dist/client/assets/{vennDiagram-4TSXK5OY-BkTA_Ciz.js → vennDiagram-4TSXK5OY-C9f5jYgk.js} +1 -1
  196. package/dist/client/assets/{vennDiagram-4TSXK5OY-BkTA_Ciz.js.br → vennDiagram-4TSXK5OY-C9f5jYgk.js.br} +0 -0
  197. package/dist/client/assets/vennDiagram-4TSXK5OY-C9f5jYgk.js.gz +0 -0
  198. package/dist/client/assets/{videoCompression-VZIoFnyJ.js → videoCompression-DJaU8exd.js} +1 -1
  199. package/dist/client/assets/videoCompression-DJaU8exd.js.br +0 -0
  200. package/dist/client/assets/videoCompression-DJaU8exd.js.gz +0 -0
  201. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-7hzU176j.js → wardleyDiagram-VM6X3IG4-6ljFvtiC.js} +1 -1
  202. package/dist/client/assets/wardleyDiagram-VM6X3IG4-6ljFvtiC.js.br +0 -0
  203. package/dist/client/assets/wardleyDiagram-VM6X3IG4-6ljFvtiC.js.gz +0 -0
  204. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-Bx4P96Bb.js → xychartDiagram-S5SC5T6Z-BaR2hm3e.js} +1 -1
  205. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BaR2hm3e.js.br +0 -0
  206. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BaR2hm3e.js.gz +0 -0
  207. package/dist/client/index.html +2 -2
  208. package/dist/client/index.html.br +0 -0
  209. package/dist/client/index.html.gz +0 -0
  210. package/dist/client/sw.js +1 -1
  211. package/dist/client/sw.js.br +0 -0
  212. package/dist/client/sw.js.gz +0 -0
  213. package/dist/server/agent/collaborationCli.js +45 -4
  214. package/dist/server/agent/collaborationDeliveryWorker.js +1 -1
  215. package/dist/server/agent/collaborationGroupRoutes.js +0 -2
  216. package/dist/server/agent/collaborationPeerTransport.js +8 -2
  217. package/dist/server/agent/collaborationResultPresentation.js +14 -0
  218. package/dist/server/agent/collaborationRoutes.js +18 -2
  219. package/dist/server/agent/collaborationService.js +46 -2
  220. package/dist/server/agent/collaborationStore.js +12 -21
  221. package/dist/server/agent/collaborationTaskBundles.js +121 -0
  222. package/dist/server/agent/collaborationTaskCli.js +54 -0
  223. package/dist/server/agent/collaborationTaskRoutes.js +58 -0
  224. package/dist/server/agent/collaborationTaskService.js +355 -0
  225. package/dist/server/agent/collaborationTaskStore.js +835 -0
  226. package/dist/server/agent/collaborationTaskTypes.js +1 -0
  227. package/dist/server/agent/collaborationTaskWorkspace.js +165 -0
  228. package/dist/server/agent/collaborationTeam.js +16 -0
  229. package/dist/server/agent/executionArchives.js +52 -0
  230. package/dist/server/entry.js +17 -2
  231. package/dist/server/federation/runtime.js +30 -7
  232. package/dist/server/routes/computer.js +198 -0
  233. package/dist/server/routes/computerTarget.js +23 -0
  234. package/dist/server/routes/guacamoleProtocol.js +55 -0
  235. package/dist/server/routes/rdp.js +162 -0
  236. package/dist/server/routes/terminal.js +441 -362
  237. package/dist/server/shared/computerPreferences.js +29 -0
  238. package/dist/server/utils/computerCredentials.js +88 -0
  239. package/dist/server/utils/sharedSampling.js +93 -0
  240. package/dist/server/utils/terminalOutputDelivery.js +8 -1
  241. package/dist/server/utils/tmuxMetadataWriter.js +61 -0
  242. package/package.json +4 -1
  243. package/runtime-manifest.json +4 -4
  244. package/dist/client/assets/App-D-cerXsD.js +0 -158
  245. package/dist/client/assets/App-D-cerXsD.js.br +0 -0
  246. package/dist/client/assets/App-D-cerXsD.js.gz +0 -0
  247. package/dist/client/assets/ChangeWalkthroughPanel-Dv5XRtRh.js.br +0 -0
  248. package/dist/client/assets/ChangeWalkthroughPanel-Dv5XRtRh.js.gz +0 -0
  249. package/dist/client/assets/DagPlayground-mq69dKyr.js.br +0 -0
  250. package/dist/client/assets/DagPlayground-mq69dKyr.js.gz +0 -0
  251. package/dist/client/assets/DiffLab-BqdHYGi5.js.br +0 -0
  252. package/dist/client/assets/DiffLab-BqdHYGi5.js.gz +0 -0
  253. package/dist/client/assets/DiffReview-BvzGxpuc.js.br +0 -0
  254. package/dist/client/assets/DiffReview-BvzGxpuc.js.gz +0 -0
  255. package/dist/client/assets/DiffReviewLab-DrfddB7x.js.br +0 -0
  256. package/dist/client/assets/DiffReviewLab-DrfddB7x.js.gz +0 -0
  257. package/dist/client/assets/DiffViewer-3bJV_A5s.js.br +0 -0
  258. package/dist/client/assets/DiffViewer-3bJV_A5s.js.gz +0 -0
  259. package/dist/client/assets/ModelPreview-CX7VtoJB.js.br +0 -0
  260. package/dist/client/assets/ModelPreview-CX7VtoJB.js.gz +0 -0
  261. package/dist/client/assets/RightSidebar-BK6vWNw3.js +0 -1678
  262. package/dist/client/assets/RightSidebar-BK6vWNw3.js.br +0 -0
  263. package/dist/client/assets/RightSidebar-BK6vWNw3.js.gz +0 -0
  264. package/dist/client/assets/abnfDiagram-VCTEODGH-PJwhLTPH.js.br +0 -0
  265. package/dist/client/assets/abnfDiagram-VCTEODGH-PJwhLTPH.js.gz +0 -0
  266. package/dist/client/assets/app-C7pXMvSE.js +0 -35
  267. package/dist/client/assets/app-C7pXMvSE.js.br +0 -0
  268. package/dist/client/assets/app-C7pXMvSE.js.gz +0 -0
  269. package/dist/client/assets/arc-l3FXjCEl.js.br +0 -0
  270. package/dist/client/assets/arc-l3FXjCEl.js.gz +0 -0
  271. package/dist/client/assets/architectureDiagram-5GKGNRK7-DdNbKi-4.js.br +0 -0
  272. package/dist/client/assets/architectureDiagram-5GKGNRK7-DdNbKi-4.js.gz +0 -0
  273. package/dist/client/assets/blockDiagram-I7D4REHJ-Cu63oaxR.js.br +0 -0
  274. package/dist/client/assets/blockDiagram-I7D4REHJ-Cu63oaxR.js.gz +0 -0
  275. package/dist/client/assets/c4Diagram-7LVT6UL2-DQiV_yk6.js.br +0 -0
  276. package/dist/client/assets/c4Diagram-7LVT6UL2-DQiV_yk6.js.gz +0 -0
  277. package/dist/client/assets/channel-CwC957gi.js +0 -1
  278. package/dist/client/assets/chunk-F27PBJKO-sLDCEnU8.js.br +0 -0
  279. package/dist/client/assets/chunk-F27PBJKO-sLDCEnU8.js.gz +0 -0
  280. package/dist/client/assets/chunk-IMKFNOWR-DYu5qS7g.js.br +0 -0
  281. package/dist/client/assets/chunk-IMKFNOWR-DYu5qS7g.js.gz +0 -0
  282. package/dist/client/assets/chunk-SVP7TREG-nJnbUFzs.js.br +0 -0
  283. package/dist/client/assets/chunk-SVP7TREG-nJnbUFzs.js.gz +0 -0
  284. package/dist/client/assets/chunk-TICWLB2K-BwyiSQgx.js.br +0 -0
  285. package/dist/client/assets/chunk-TICWLB2K-BwyiSQgx.js.gz +0 -0
  286. package/dist/client/assets/classDiagram-ZZMXUADV-CmoJ7-rE.js +0 -1
  287. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CmoJ7-rE.js +0 -1
  288. package/dist/client/assets/cose-bilkent-JH36ORCC-rroo-EOb.js.br +0 -0
  289. package/dist/client/assets/cose-bilkent-JH36ORCC-rroo-EOb.js.gz +0 -0
  290. package/dist/client/assets/cynefin-OW5HDTMX-CkFeV85k.js.br +0 -0
  291. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-hBwpU_bW.js.br +0 -0
  292. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-hBwpU_bW.js.gz +0 -0
  293. package/dist/client/assets/dagre-GXQ25YYZ-B321-hdp.js.br +0 -0
  294. package/dist/client/assets/dagre-GXQ25YYZ-B321-hdp.js.gz +0 -0
  295. package/dist/client/assets/diagram-S7CK7UJ4-bY87_ptA.js.br +0 -0
  296. package/dist/client/assets/diagram-S7CK7UJ4-bY87_ptA.js.gz +0 -0
  297. package/dist/client/assets/diagram-UQ7AKVKN--cez0H_o.js.br +0 -0
  298. package/dist/client/assets/diagram-UQ7AKVKN--cez0H_o.js.gz +0 -0
  299. package/dist/client/assets/diagram-VSXAHHWV-BupH_VRK.js.br +0 -0
  300. package/dist/client/assets/diagram-VSXAHHWV-BupH_VRK.js.gz +0 -0
  301. package/dist/client/assets/diagram-VX7I27RA-DewqaxvF.js.br +0 -0
  302. package/dist/client/assets/diagram-VX7I27RA-DewqaxvF.js.gz +0 -0
  303. package/dist/client/assets/diagram-Z3DM3KII-wDumcTuR.js.br +0 -0
  304. package/dist/client/assets/diagram-Z3DM3KII-wDumcTuR.js.gz +0 -0
  305. package/dist/client/assets/ebnfDiagram-PWID7BFC-C0OY91We.js.br +0 -0
  306. package/dist/client/assets/ebnfDiagram-PWID7BFC-C0OY91We.js.gz +0 -0
  307. package/dist/client/assets/erDiagram-RLTQ6QDP-Cw9aNqvJ.js.br +0 -0
  308. package/dist/client/assets/erDiagram-RLTQ6QDP-Cw9aNqvJ.js.gz +0 -0
  309. package/dist/client/assets/flowDiagram-HODETNUW-BC7XUXeI.js.gz +0 -0
  310. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DovhJIz5.js.br +0 -0
  311. package/dist/client/assets/ganttDiagram-EL5Y4UJY-DovhJIz5.js.gz +0 -0
  312. package/dist/client/assets/gestureArbiter-wjVok2Lg.js.br +0 -0
  313. package/dist/client/assets/gestureArbiter-wjVok2Lg.js.gz +0 -0
  314. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BmrbbyW1.js.br +0 -0
  315. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BmrbbyW1.js.gz +0 -0
  316. package/dist/client/assets/index-BeD4iJ6L.css +0 -1
  317. package/dist/client/assets/index-BeD4iJ6L.css.br +0 -0
  318. package/dist/client/assets/index-BeD4iJ6L.css.gz +0 -0
  319. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BPqibqsm.js.br +0 -0
  320. package/dist/client/assets/ishikawaDiagram-5VMMS53U-BPqibqsm.js.gz +0 -0
  321. package/dist/client/assets/journeyDiagram-3NMN7TZE-DIkhubnf.js.br +0 -0
  322. package/dist/client/assets/journeyDiagram-3NMN7TZE-DIkhubnf.js.gz +0 -0
  323. package/dist/client/assets/kanban-definition-UXKFOSKX-CBT0DIUR.js.br +0 -0
  324. package/dist/client/assets/kanban-definition-UXKFOSKX-CBT0DIUR.js.gz +0 -0
  325. package/dist/client/assets/layout-C1CMlOIU.js.br +0 -0
  326. package/dist/client/assets/layout-C1CMlOIU.js.gz +0 -0
  327. package/dist/client/assets/linear-C4gyqor0.js.br +0 -0
  328. package/dist/client/assets/linear-C4gyqor0.js.gz +0 -0
  329. package/dist/client/assets/mermaid.core-CMfa4ncd.js.br +0 -0
  330. package/dist/client/assets/mermaid.core-CMfa4ncd.js.gz +0 -0
  331. package/dist/client/assets/mindmap-definition-YA3MSWOX-C-JmgKOI.js.br +0 -0
  332. package/dist/client/assets/mindmap-definition-YA3MSWOX-C-JmgKOI.js.gz +0 -0
  333. package/dist/client/assets/passwordBootstrap-BmUG2IwA.js.br +0 -0
  334. package/dist/client/assets/passwordBootstrap-BmUG2IwA.js.gz +0 -0
  335. package/dist/client/assets/pegDiagram-XKGWAZYB-IY-AEKQa.js.br +0 -0
  336. package/dist/client/assets/pegDiagram-XKGWAZYB-IY-AEKQa.js.gz +0 -0
  337. package/dist/client/assets/pieDiagram-E7YTZNPT-9Qq43qED.js.br +0 -0
  338. package/dist/client/assets/pieDiagram-E7YTZNPT-9Qq43qED.js.gz +0 -0
  339. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BjQncx5i.js.br +0 -0
  340. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BjQncx5i.js.gz +0 -0
  341. package/dist/client/assets/railroadDiagram-O6MQD6OU-Cr1rL0wZ.js.br +0 -0
  342. package/dist/client/assets/railroadDiagram-O6MQD6OU-Cr1rL0wZ.js.gz +0 -0
  343. package/dist/client/assets/referenceLongPress-ConC5-ym.js.br +0 -0
  344. package/dist/client/assets/referenceLongPress-ConC5-ym.js.gz +0 -0
  345. package/dist/client/assets/requirementDiagram-BXWQKSXE-DU2q_iZg.js.br +0 -0
  346. package/dist/client/assets/requirementDiagram-BXWQKSXE-DU2q_iZg.js.gz +0 -0
  347. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BYlx9kXC.js.br +0 -0
  348. package/dist/client/assets/sankeyDiagram-P5KCCOFB-BYlx9kXC.js.gz +0 -0
  349. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D_uAKme-.js.br +0 -0
  350. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-D_uAKme-.js.gz +0 -0
  351. package/dist/client/assets/sizeCapture-INFHLROL-H_uqscf4.js.br +0 -0
  352. package/dist/client/assets/sizeCapture-INFHLROL-H_uqscf4.js.gz +0 -0
  353. package/dist/client/assets/stateDiagram-D77RDMKH-BvsQjIIW.js.br +0 -0
  354. package/dist/client/assets/stateDiagram-D77RDMKH-BvsQjIIW.js.gz +0 -0
  355. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DNgoExtD.js +0 -1
  356. package/dist/client/assets/swimlanes-42K2YHIH-LmUJag-p.js.br +0 -0
  357. package/dist/client/assets/swimlanes-42K2YHIH-LmUJag-p.js.gz +0 -0
  358. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BRuArMR5.js +0 -8
  359. package/dist/client/assets/timeline-definition-24CTP7MA-DZ5n0Pim.js.br +0 -0
  360. package/dist/client/assets/timeline-definition-24CTP7MA-DZ5n0Pim.js.gz +0 -0
  361. package/dist/client/assets/vennDiagram-4TSXK5OY-BkTA_Ciz.js.gz +0 -0
  362. package/dist/client/assets/videoCompression-VZIoFnyJ.js.br +0 -0
  363. package/dist/client/assets/videoCompression-VZIoFnyJ.js.gz +0 -0
  364. package/dist/client/assets/wardleyDiagram-VM6X3IG4-7hzU176j.js.br +0 -0
  365. package/dist/client/assets/wardleyDiagram-VM6X3IG4-7hzU176j.js.gz +0 -0
  366. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Bx4P96Bb.js.br +0 -0
  367. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Bx4P96Bb.js.gz +0 -0
@@ -0,0 +1,177 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-DJaU8exd.js","assets/app-DfACMixk.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CYmI1EsU.css","assets/CollaborationTaskContent-C01GXOEq.js","assets/RightSidebar-Cp5b_y0u.js","assets/gestureArbiter-Belsq4xq.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-CYw3ASI6.js","assets/sparkles-CgaUBIwH.js","assets/DiffViewer-WsYvN75z.js","assets/referenceLongPress-BZr7Lqzh.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-C9IHD_eF.js","assets/ChangeWalkthroughPanel-CvQJIp_C.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-B0OgRtyR.js"])))=>i.map(i=>d[i]);
2
+ import{ae as er,bu as s,aa as Jl,d7 as Hr,G as r8,de as Ko,d3 as fa,d5 as ts,a$ as ec,a5 as Dd,cK as n8,d4 as ad,cv as Ou,b4 as ao,j as Fu,ad as p0,cl as Wf,cS as s8,ar as bc,bt as Tu,g as i8,cF as gh,Y as a8,b9 as om,bE as lm,cB as o8,ax as l8,ce as c8,a3 as Cb,cc as u8,cz as _b,a8 as d8,af as h8,L as En,C as ci,X as Wn,f as f8,d as ol,be as p8,a_ as cm,dc as Jr,bC as r1,db as sr,aC as m8,dj as g8,v as x8,bK as b8,bY as y8,bO as v8,cx as xg,cy as bg,cA as yg,W as vg,bX as w8,cL as A8,t as Gf,d2 as T8,_ as Tc,b7 as S8,i as C8,aY as Xo,T as Eo,da as _8,cf as L8,am as k8,aj as jh,aW as I8,bV as E8,bW as N8,P as Lb,V as wg,bL as R8,bw as kb,n as Ys,aL as $u,Z as xh,cT as Vf,bD as M8,ch as D8,bB as Ib,d9 as j8,bd as rl,dg as B8,B as Zl,e as lo,u as Q8,ai as P8,N as um,cs as O8,h as ll,bp as F8,bq as $8,ao as Eb,aA as Nb,b_ as Rb,av as Eu,c as Mb,d6 as Db,a4 as dm,aI as U8,S as Bh,bk as Qh,a as jb,aq as z8,ac as H8,d0 as W8,m as bh,b$ as m0,a6 as Kl,bA as Ag,cp as Sc,cw as G8,c3 as V8,cP as q8,cR as Bb,bx as Y8,bz as Qb,cD as Z8,cE as K8,c0 as X8,cC as J8,cm as ew,cj as tw,cg as rw,c2 as nw,ct as sw,bN as iw,bM as Pb,co as aw,aw as ow,by as Tg,aG as lw,aZ as cw,D as uw,aF as Sg,bG as dw,c4 as Ob,q as hw,p as fw,bJ as pw,bH as mw,z as gw,c1 as xw,l as bw,cu as yw,r as vw,bZ as ww,at as Aw,az as Tw,aB as Sw,b8 as O0,bi as Cw,cZ as _w,bj as Lw,an as kw,c$ as Iw,Q as Ew,ah as Nw,ab as Rw,A as Mw,b6 as Dw,ap as jw,M as Bw,dd as Qw,bP as lc,b3 as Pw,b0 as Ow,b1 as Fw,b2 as $w,aU as qf,bQ as Uw,c8 as zw,ci as Hw,b5 as Ww,aX as Gw,cQ as Cg,al as Vw,a7 as qw,U as Yw,cX as Zw,dh as On,cN as Kw,aT as Xw,ba as _g,c7 as Jw,cJ as jd,cW as F0,c_ as e9,c9 as t9,cO as r9,cG as n9,cV as Yf,cH as s9,cI as i9,d8 as a9,ak as o9,cr as $0,H as l9,bF as c9,bs as Bd,br as u9,c5 as Lg,ca as d9,c6 as Uc,cb as h9,a2 as f9,a9 as p9,s as m9}from"./app-DfACMixk.js";import{b,R as S,r as ki,a as g9}from"./dnd-BCFAPC0L.js";import{b as x9,c as b9,F as Ec,S as y9,e as v9,h as w9,r as A9,y as T9,d as S9,u as C9}from"./gestureArbiter-Belsq4xq.js";import{L as _9,l as L9}from"./terminal-C7X98Amf.js";import{T as n1,L as g0,C as Uu,M as k9,G as I9}from"./triangle-alert-C9IHD_eF.js";import{r as E9}from"./react-XDCjal2T.js";import{u as s1,G as N9}from"./referenceLongPress-BZr7Lqzh.js";const R9=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Fb=er("archive",R9);const M9=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],D9=er("arrow-down-a-z",M9);const j9=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],B9=er("arrow-down",j9);const Q9=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$b=er("arrow-up",Q9);const P9=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Ub=er("bell",P9);const O9=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],od=er("bot",O9);const F9=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],$9=er("box",F9);const U9=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],z9=er("cable",U9);const H9=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],W9=er("calendar-clock",H9);const G9=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],V9=er("camera",G9);const q9=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]],Y9=er("chart-bar",q9);const Z9=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],K9=er("circle-dot",Z9);const X9=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ph=er("circle-question-mark",X9);const J9=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],zu=er("circle",J9);const eA=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],tA=er("clipboard-paste",eA);const rA=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],zb=er("clipboard",rA);const nA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],Hu=er("clock-3",nA);const sA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],iA=er("clock",sA);const aA=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],oA=er("code",aA);const lA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Cl=er("columns-2",lA);const cA=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],uA=er("corner-down-left",cA);const dA=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Wu=er("download",dA);const hA=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ld=er("external-link",hA);const fA=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],pA=er("file-code",fA);const mA=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],gA=er("file-up",mA);const xA=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Hb=er("file",xA);const bA=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],c0=er("folder-open",bA);const yA=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],i1=er("folder-search",yA);const vA=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],wA=er("folder-tree",vA);const AA=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]],kg=er("grid-2x2",AA);const TA=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],hf=er("grip-vertical",TA);const SA=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],CA=er("hash",SA);const _A=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],wc=er("history",_A);const LA=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],kA=er("house",LA);const IA=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Wb=er("keyboard",IA);const EA=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Gb=er("layers",EA);const NA=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],x0=er("layout-grid",NA);const RA=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],MA=er("maximize",RA);const DA=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],a1=er("message-circle",DA);const jA=[["path",{d:"M5 12h14",key:"1ays0h"}]],Vb=er("minus",jA);const BA=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],QA=er("minimize",BA);const PA=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],OA=er("monitor-smartphone",PA);const FA=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],$A=er("moon",FA);const UA=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],zA=er("move",UA);const HA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],WA=er("panel-right-close",HA);const GA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],VA=er("panel-left",GA);const qA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],YA=er("panel-right-open",qA);const ZA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],qb=er("panel-right",ZA);const KA=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],XA=er("paperclip",KA);const JA=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],eT=er("pause",JA);const tT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],rT=er("pen-line",tT);const nT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],sT=er("pencil-line",nT);const iT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Gu=er("pin",iT);const aT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Vu=er("pin-off",aT);const oT=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Oh=er("play",oT);const lT=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],cT=er("plug",lT);const uT=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],dT=er("power",uT);const hT=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],vn=er("refresh-cw",hT);const fT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Yb=er("rotate-ccw",fT);const pT=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],mT=er("rotate-cw",pT);const gT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],Ig=er("rows-2",gT);const xT=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Vl=er("search",xT);const bT=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Nu=er("send",bT);const yT=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],vT=er("settings",yT);const wT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],AT=er("shield-alert",wT);const TT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ST=er("shield-check",TT);const CT=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],hm=er("sliders-horizontal",CT);const _T=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Zb=er("square",_T);const LT=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],kT=er("stethoscope",LT);const IT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ET=er("sun",IT);const NT=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Zs=er("trash-2",NT);const RT=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],MT=er("type",RT);const DT=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],jT=er("unlink",DT);const BT=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Kb=er("unplug",BT);const QT=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Xb=er("video",QT);const PT=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],OT=er("volume-1",PT);const FT=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],$T=er("volume-2",FT);const UT=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],zT=er("wand-sparkles",UT);const HT=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],Qd=er("workflow",HT);function WT(e,t){return e==="webgl"&&t}function GT(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function VT(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function qT(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function YT(e,t){return!e&&t}function ZT({workspace:e,children:t,rightInset:r=0}){const n=!!e;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:a=>{a&&(a.inert=n)},"aria-hidden":n?!0:void 0,style:{visibility:n?"hidden":void 0},className:"relative flex h-full w-full min-h-0 flex-col overflow-visible app-chrome-bg",children:t}),n&&s.jsx("div",{"data-collaboration-workspace-frame":!0,className:"absolute inset-y-0 left-0",style:{right:r},children:e})]})}const yc=Jl(e=>({drafts:{},setDraft:(t,r)=>e(n=>({drafts:{...n.drafts,[t]:r}})),groupId:null,open:t=>e({groupId:t}),terminal:()=>e({groupId:null})}));function KT({state:e,onCopy:t,copied:r}){const{t:n}=Hr(),[a,l]=b.useState(null),c=e.caAvailable&&e.onboardingUrl?new URL("/ca",e.onboardingUrl).href:null;return b.useEffect(()=>{let h=!1;return l(null),c&&r8.toDataURL(c,{width:180,margin:2,errorCorrectionLevel:"M"}).then(p=>{h||l(p)}).catch(()=>{}),()=>{h=!0}},[c]),s.jsxs("div",{className:"space-y-3 text-xs leading-relaxed text-muted-foreground",children:[s.jsx("p",{children:n("settings.mobileSetupIntro")}),e.httpsEnabled&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2 p-3",children:[s.jsx("h3",{className:"font-medium text-foreground",children:n("settings.mobileSetupDownload")}),c?s.jsxs(s.Fragment,{children:[a&&s.jsx("img",{src:a,alt:n("settings.mobileSetupDownload"),className:"h-44 w-44 rounded-lg"}),s.jsxs("button",{type:"button",onClick:()=>t(c),className:"flex w-full items-center justify-between gap-3 rounded-lg bg-surface p-2 text-left",children:[s.jsx("span",{className:"break-all",children:c}),s.jsx("span",{className:"shrink-0 text-primary",children:n(r?"rightSidebar.copied":"common.copy")})]})]}):s.jsx("p",{children:n("settings.caMissing")}),s.jsx("p",{children:n("settings.mobileSetupIos")}),s.jsx("p",{children:n("settings.mobileSetupAndroid")})]}),s.jsx("h3",{className:"font-medium text-foreground",children:e.httpsEnabled?n("settings.mobileSetupConnect"):n("settings.localAccess")}),s.jsx("p",{children:n("settings.mobileSetupConnectHint")})]})}const Fh=Jl(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function Eg(){const e=Ko(),t=e.visualViewport,r=document.documentElement.style,n=g=>g===void 0?"?":Math.round(g),a=g=>r.getPropertyValue(g)||"?";let l=document.activeElement?.parentElement,c=null;for(;l&&!c;)c=l.querySelector('[data-mobile-keyboard="true"]'),l=l.parentElement;const h=c?.getBoundingClientRect(),p=document.getElementById("root")?.getBoundingClientRect();return[`VVP ${n(t?.height)} off ${n(t?.offsetTop)} win ${e.innerHeight}`,`base ${a("--app-base-vh")} kb ${a("--kb-height")} move ${a("--kb-translate-y")}`,`bar ${n(h?.top)}…${n(h?.bottom)} h ${n(h?.height)} root ${n(p?.bottom)}`,`safe ${a("--safe-top-inset")}/${a("--safe-bottom-inset")} frame ${e!==window?"child":"root"} focus ${document.activeElement?.tagName??"?"}`].join(`
3
+ `)}function XT({onClose:e}){const[t,r]=S.useState(Eg);return S.useEffect(()=>{const n=window.setInterval(()=>r(Eg()),200);return()=>window.clearInterval(n)},[]),s.jsxs("div",{className:"pointer-events-none fixed inset-x-2 z-toast rounded-lg border border-border/15 bg-surface p-2 text-foreground md:hidden",style:{top:"calc(var(--safe-top-inset, 0px) + 40px)"},children:[s.jsx("button",{type:"button",className:"pointer-events-auto absolute right-1 top-1 px-2 py-1 text-xs",onPointerDown:n=>n.preventDefault(),onClick:e,"aria-label":"关闭布局诊断",children:"×"}),s.jsx("pre",{className:"pr-5 font-mono text-[10px] leading-tight",children:t})]})}const JT={x:0,y:0,width:1,height:1};function Cc(e){return"id"in e?[e.id]:[...Cc(e.first),...Cc(e.second)]}function fm(e,t=0,r=new Set){if(!e||typeof e!="object"||t>24)return null;const n=e;if(typeof n.id=="string"&&n.id&&!r.has(n.id))return r.add(n.id),{id:n.id};if(!["x","y"].includes(String(n.axis))||!Number.isFinite(n.ratio))return null;const a=fm(n.first,t+1,r),l=fm(n.second,t+1,r);return a&&l?{axis:n.axis,ratio:Math.max(.02,Math.min(.98,Number(n.ratio))),first:a,second:l}:a??l}function qu(e,t){if("id"in e)return t.has(e.id)?e:null;const r=qu(e.first,t),n=qu(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function $h(e,t,r,n){return"id"in e?e.id===t?{axis:n==="left"||n==="right"?"x":"y",ratio:.5,first:n==="left"||n==="top"?{id:r}:e,second:n==="left"||n==="top"?e:{id:r}}:e:{...e,first:$h(e.first,t,r,n),second:$h(e.second,t,r,n)}}function eS(e,t,r,n){if(t===r||!Cc(e).includes(t)||!Cc(e).includes(r))return e;if(n==="center"){const a=l=>"id"in l?{id:l.id===t?r:l.id===r?t:l.id}:{...l,first:a(l.first),second:a(l.second)};return a(e)}return $h(qu(e,new Set(Cc(e).filter(a=>a!==t))),r,t,n)}function u0(e,t){if(e.length===1)return{id:e[0]};if(t==="grid"&&e.length>2){const r=Math.ceil(e.length/2);return{axis:"y",ratio:.5,first:u0(e.slice(0,r),"horizontal"),second:u0(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:u0(e.slice(1),t)}}function pm(e,t=JT,r=""){if("id"in e)return{panes:[{id:e.id,rect:t}],dividers:[]};const n={...t},a={...t};e.axis==="x"?(n.width*=e.ratio,a.x+=n.width,a.width-=n.width):(n.height*=e.ratio,a.y+=n.height,a.height-=n.height);const l=pm(e.first,n,r+"0"),c=pm(e.second,a,r+"1");return{panes:[...l.panes,...c.panes],dividers:[{path:r,node:e,rect:t},...l.dividers,...c.dividers]}}function Ru(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:Ru(e.first,t.slice(1),r)}:{...e,second:Ru(e.second,t.slice(1),r)}:{...e,ratio:r}}function Jb(e){return"id"in e||"id"in e.first||"id"in e.second||e.first.axis===e.axis||e.second.axis===e.axis||!("id"in e.first.first)||!("id"in e.first.second)||!("id"in e.second.first)||!("id"in e.second.second)?null:e.axis==="y"?{ids:[e.first.first.id,e.first.second.id,e.second.first.id,e.second.second.id],top:e.first.ratio,bottom:e.second.ratio,left:e.ratio,right:e.ratio}:{ids:[e.first.first.id,e.second.first.id,e.first.second.id,e.second.second.id],top:e.ratio,bottom:e.ratio,left:e.first.ratio,right:e.second.ratio}}function Zf(e,t,r){const n=Jb(e);if(!n)return e;const[a,l,c,h]=n.ids.map(p=>({id:p}));return t==="top"||t==="bottom"?{axis:"y",ratio:(n.left+n.right)/2,first:{axis:"x",ratio:t==="top"?r:n.top,first:a,second:l},second:{axis:"x",ratio:t==="bottom"?r:n.bottom,first:c,second:h}}:{axis:"x",ratio:(n.top+n.bottom)/2,first:{axis:"y",ratio:t==="left"?r:n.left,first:a,second:c},second:{axis:"y",ratio:t==="right"?r:n.right,first:l,second:h}}}function tS(e,t,r,n,a){const l=(p,g,x)=>{if(p.length===1)return p[0];const y=x?.length===p.length&&x.every(A=>Number.isFinite(A)&&A>0)?x:p.map(()=>1);return{axis:g,ratio:y[0]/y.reduce((A,v)=>A+v,0),first:p[0],second:l(p.slice(1),g,y.slice(1))}};if(t!=="grid")return l(e.map(p=>({id:p})),t==="vertical"?"y":"x",r);const c=Math.ceil(Math.sqrt(e.length)),h=[];for(let p=0;p<e.length;p+=c){const g=e.slice(p,p+c).map(y=>({id:y})),x=n?.length===c?n.slice(0,g.length):void 0;x&&g.length<c&&(x[x.length-1]+=n.slice(g.length).reduce((y,A)=>y+A,0)),h.push(l(g,"x",x))}return l(h,"y",a)}let rS;function ff(){try{const e="termdock-collaboration-panel-client",t=localStorage.getItem(e);if(t)return t;const r=crypto.randomUUID();return localStorage.setItem(e,r),r}catch{return rS??=crypto.randomUUID()}}let Ng=Promise.resolve();function al(e,t){t&&(e={groups:{[t]:e}});const r=ff(),n=Ng.catch(()=>{}).then(()=>fa({collaborationPanel:{clientId:r,state:e}}));return Ng=n,n.then(()=>{})}function Rg(e,t,r,n,a,l){return{x:a>0?Math.max(0,Math.min(1,(e-r)/a)):.5,y:l>0?Math.max(0,Math.min(1,(t-n)/l)):.5}}function e3(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function t3(e){const t=Object.entries(e?.groups??{}).filter(([,r])=>r.floatingGroupId).map(([r])=>r);return e?.floatingGroupId&&!e.groups?.[e.floatingGroupId]&&t.push(e.floatingGroupId),t}const nS=e=>e.startsWith("@collaboration:"),Mg=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function sS({groupId:e}){const t=ts(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||ts.getState().hosts[e]===r.current)&&t(e,a),r.current=a},[e,t]);return s.jsx("div",{ref:n,className:"h-full min-h-0 min-w-0 bg-surface"})}function Dg({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:l=!1}){const c=ts(se=>se.docks),h=JSON.stringify(t.map(se=>se.id)),p=Object.entries(c).filter(([,se])=>t.some(je=>je.id===se.sessionId)),g=JSON.stringify(p),x=b.useRef(null),[y,A]=b.useState(()=>n??u0(t.map(se=>se.id),l?"vertical":r)),v=b.useRef(y);v.current=y;const[L,I]=b.useState(!1),E=ts(se=>se.activePaneId),[R,P]=b.useState(null),[Q,$]=b.useState(null),[W,B]=b.useState(null),q=b.useRef(r),ne=b.useRef(t.map(se=>se.id)),Be=b.useRef({}),fe=b.useRef(!1),X=()=>{fe.current&&(fe.current=!1,al({layouts:{[e]:v.current}}).catch(()=>{fe.current=!0,P("布局保存失败,调整后重试")}))};b.useEffect(()=>{let se=!1;return ec().then(je=>{if(se)return;const de=je.collaborationPanels?.[ff()];for(const Ee of t3(de)){const _e=e3(de,Ee);_e.mode==="docked"&&_e.dock&&t.some(re=>re.id===_e.dock.sessionId)&&!ts.getState().docks[Ee]&&ts.getState().setDock(Ee,_e.dock)}let Oe=fm(de?.layouts?.[e]);if(Oe&&de?.floatingGroupId){const Ee=_e=>"id"in _e?{id:_e.id==="@collaboration"?Dd(de.floatingGroupId):_e.id}:{..._e,first:Ee(_e.first),second:Ee(_e.second)};Oe=Ee(Oe)}Oe&&A(Oe),I(!0)}).catch(()=>{se||P("布局加载失败,请刷新重试")}),()=>{se=!0}},[e]);const Qe=se=>{fe.current=!0,v.current=se,A(se)};b.useLayoutEffect(()=>{if(!L)return;const se=JSON.parse(h),je=q.current!==r;q.current=r;let de=je?u0(se,r):v.current;const Oe=ne.current;if(!je&&Oe.length===se.length&&Oe.every(re=>se.includes(re))&&Oe.some((re,Fe)=>re!==se[Fe])){const re=new Map(Oe.map((wt,Xe)=>[wt,se[Xe]])),Fe=wt=>"id"in wt?{id:re.get(wt.id)??wt.id}:{...wt,first:Fe(wt.first),second:Fe(wt.second)};de=Fe(de)}ne.current=se;const Ee=new Set([...se,...p.map(([re])=>Dd(re))]);de=qu(de,Ee)??u0(se,r);for(const re of se)Cc(de).includes(re)||(de={axis:"x",ratio:.5,first:de,second:{id:re}});const _e={};for(const[re,Fe]of p){const wt=Dd(re),Xe=`${Fe.sessionId}:${Fe.side}`;if(_e[re]=Xe,(!Cc(de).includes(wt)||Be.current[re]&&Be.current[re]!==Xe)&&(de=qu(de,new Set([...Ee].filter(ee=>ee!==wt))),de=$h(de,Fe.sessionId,wt,Fe.side)),Fe.preferredWidth&&(Fe.side==="left"||Fe.side==="right")){const ee=(Ue,Le)=>{if("id"in Ue)return Ue;const te="id"in Ue.first&&Ue.first.id===wt,ye="id"in Ue.second&&Ue.second.id===wt;if(Ue.axis==="x"&&(te||ye)&&Ue.ratio===.5){const xe=(x.current?.clientWidth||window.innerWidth)*Le.width,Ne=Math.max(.1,Math.min(.45,Fe.preferredWidth/Math.max(1,xe)));return{...Ue,ratio:te?Ne:1-Ne}}const ot={...Le},le={...Le};return Ue.axis==="x"?(ot.width*=Ue.ratio,le.x+=ot.width,le.width-=ot.width):(ot.height*=Ue.ratio,le.y+=ot.height,le.height-=ot.height),{...Ue,first:ee(Ue.first,ot),second:ee(Ue.second,le)}};de=ee(de,{x:0,y:0,width:1,height:1})}}Be.current=_e,JSON.stringify(de)!==JSON.stringify(v.current)&&(Qe(de),X())},[L,h,r,g]),b.useEffect(()=>{const se=()=>X();return window.addEventListener("pagehide",se),()=>{window.removeEventListener("pagehide",se),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),se()}},[e]);const Pe=pm(y),ue=Jb(y),Ce=[...t,...p.map(([se])=>({id:Dd(se),content:s.jsx(sS,{groupId:se})}))],tt=b.useRef(null),we=b.useRef(W);we.current=W;const ce=b.useRef(null);b.useEffect(()=>{const se=x.current;if(!se||!L)return;const je=Oe=>{if(Oe.button!==0||!(Oe.target instanceof Element))return;const Ee=Oe.target.closest("[data-split-pane-title], [data-panel-drag-title]"),_e=Oe.target.closest("button, a, input, textarea, select, summary");if(!Ee||_e&&_e!==Ee)return;const re=Ee.closest("[data-layout-pane]");if(!re||!se.contains(re))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const Fe=re.getBoundingClientRect();tt.current={id:re.dataset.layoutPane,x:Oe.clientX,y:Oe.clientY,moved:!1,originX:Oe.clientX-Fe.left,originY:Oe.clientY-Fe.top,scale:Math.min(.8,480/Math.max(1,Fe.width),320/Math.max(1,Fe.height))},se.setPointerCapture?.(Oe.pointerId)},de=Oe=>{const Ee=Oe.target;if(!(Ee instanceof Element))return;const _e=Ee.closest("[data-layout-pane]");if(!(!_e||!se.contains(_e))){if(Oe.type==="pointerdown"&&ts.getState().activePaneId!==_e.dataset.layoutPane){const re=document.activeElement;re instanceof HTMLElement&&re.closest("[data-layout-pane]")&&!_e.contains(re)&&re.blur();const Fe=window.getSelection();Fe?.anchorNode&&!_e.contains(Fe.anchorNode)&&Fe.removeAllRanges()}ts.getState().setActivePane(_e.dataset.layoutPane)}};return se.addEventListener("pointerdown",de,!0),se.addEventListener("focusin",de,!0),se.addEventListener("pointerdown",je,!0),()=>{se.removeEventListener("pointerdown",je,!0),se.removeEventListener("pointerdown",de,!0),se.removeEventListener("focusin",de,!0)}},[L]);const $e=(se,je)=>{const de=x.current?.getBoundingClientRect(),Oe=ce.current;if(!de||!Oe)return;const Ee=Oe.axis==="x"?de.width*Oe.rect.width:de.height*Oe.rect.height,_e=Oe.axis==="x"?de.left+de.width*Oe.rect.x:de.top+de.height*Oe.rect.y,re=Math.min(.45,(l?48:120)/Math.max(1,Ee)),Fe=Math.max(re,Math.min(1-re,((Oe.axis==="x"?se:je)-_e)/Math.max(1,Ee)));Qe(Oe.side?Zf(v.current,Oe.side,Fe):Ru(v.current,Oe.path,Fe))},ke=ue?[{key:"top",side:"top",axis:"x",x:ue.top,y:0,length:(ue.left+ue.right)/2},{key:"bottom",side:"bottom",axis:"x",x:ue.bottom,y:(ue.left+ue.right)/2,length:1-(ue.left+ue.right)/2},{key:"left",side:"left",axis:"y",x:0,y:ue.left,length:(ue.top+ue.bottom)/2},{key:"right",side:"right",axis:"y",x:(ue.top+ue.bottom)/2,y:ue.right,length:1-(ue.top+ue.bottom)/2}].map(se=>({...se,rect:{x:0,y:0,width:1,height:1},path:void 0})):Pe.dividers.map(se=>({key:se.path,path:se.path,side:void 0,axis:se.node.axis,rect:se.rect,x:se.rect.x+(se.node.axis==="x"?se.rect.width*se.node.ratio:0),y:se.rect.y+(se.node.axis==="y"?se.rect.height*se.node.ratio:0),length:se.node.axis==="x"?se.rect.height:se.rect.width}));return s.jsxs("div",{ref:x,"data-split-container":"true",className:"relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-border [&_[data-split-pane-title]]:touch-none [&_[data-panel-drag-title]]:touch-none",onPointerMove:se=>{if(ce.current){se.preventDefault(),$e(se.clientX,se.clientY);return}const je=tt.current,de=x.current?.getBoundingClientRect();if(!je||!de||!je.moved&&Math.hypot(se.clientX-je.x,se.clientY-je.y)<6)return;je.moved=!0,$({id:je.id,dx:se.clientX-je.x,dy:se.clientY-je.y,originX:je.originX,originY:je.originY,scale:je.scale});const Oe=(se.clientX-de.left)/de.width,Ee=(se.clientY-de.top)/de.height,_e=Pe.panes.find(ee=>Oe>=ee.rect.x&&Oe<=ee.rect.x+ee.rect.width&&Ee>=ee.rect.y&&Ee<=ee.rect.y+ee.rect.height);if(!_e||_e.id===je.id){we.current=null,B(null);return}const re=(Oe-_e.rect.x)/_e.rect.width,Fe=(Ee-_e.rect.y)/_e.rect.height,wt=Math.min(re,1-re,Fe,1-Fe)>.25?"center":re<1-re&&re<=Fe&&re<=1-Fe?"left":1-re<=Fe&&1-re<=1-Fe?"right":Fe<1-Fe?"top":"bottom",Xe={id:_e.id,side:wt};we.current=Xe,B(Xe)},onPointerUp:se=>{ce.current&&(ce.current=null,X()),tt.current?.moved&&we.current&&(Qe(eS(v.current,tt.current.id,we.current.id,we.current.side)),X()),tt.current=null,we.current=null,B(null),$(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),se.currentTarget.hasPointerCapture?.(se.pointerId)&&se.currentTarget.releasePointerCapture(se.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ce.current=null,tt.current=null,we.current=null,B(null),$(null),X()},onKeyDownCapture:se=>{se.key==="Escape"&&(tt.current=null,we.current=null,B(null),$(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})))},onPointerCancel:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ce.current=null,tt.current=null,we.current=null,B(null),$(null),X()},children:[Q&&s.jsx("div",{"aria-hidden":"true","data-drag-placeholder":"true",className:"pointer-events-none absolute border-2 border-dashed border-primary/30 bg-primary/5",style:Mg(Pe.panes.find(se=>se.id===Q.id)?.rect??{x:0,y:0,width:0,height:0})}),Ce.map(se=>{const je=Pe.panes.find(Oe=>Oe.id===se.id)?.rect,de=!je||!!a&&se.id!==a;return s.jsxs("div",{"data-layout-pane":se.id,"data-pane-active":E===se.id,className:`${E===se.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${Q?.id===se.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...Mg(a===se.id?{x:0,y:0,width:1,height:1}:je??{x:0,y:0,width:0,height:0}),padding:Ce.length>1?"0.5px":0,transition:"none",visibility:de?"hidden":void 0,...Q?.id===se.id?{transform:`translate(${Q.dx}px, ${Q.dy}px) scale(${Q.scale})`,transformOrigin:`${Q.originX}px ${Q.originY}px`}:{}},onDragStart:Oe=>{Oe.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Oe.preventDefault()},children:[se.content,l&&Ce.length>1&&!nS(se.id)&&s.jsx("button",{type:"button","data-panel-drag-title":"true","aria-label":"拖动面板到其他区域",className:"swiper-no-swiping absolute right-1 top-1 z-20 rounded bg-surface p-1 text-muted-foreground",children:s.jsx(hf,{size:14})}),W?.id===se.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:W.side==="bottom"?"50%":0,bottom:W.side==="top"?"50%":0,left:W.side==="right"?"50%":0,right:W.side==="left"?"50%":0}})]},se.id)}),!a&&ke.map(se=>s.jsx("button",{type:"button",role:"separator","aria-label":se.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[se.side]}半段分隔线`:"调整分屏大小","aria-orientation":se.axis==="x"?"vertical":"horizontal",disabled:!L,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${se.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${se.x*100}%`,top:`${se.y*100}%`,...se.axis==="x"?{height:`${se.length*100}%`}:{width:`${se.length*100}%`}},onPointerDown:je=>{je.preventDefault(),je.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ce.current=se,x.current?.setPointerCapture?.(je.pointerId)},onDoubleClick:()=>{Qe(se.side?Zf(v.current,se.side,.5):Ru(v.current,se.path,.5)),X()},onKeyDown:je=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(je.key))return;je.preventDefault();const de=se.side?ue[se.side]:Pe.dividers.find(Ee=>Ee.path===se.path).node.ratio,Oe=Math.max(.05,Math.min(.95,de+(["ArrowRight","ArrowDown"].includes(je.key)?.03:-.03)));Qe(se.side?Zf(v.current,se.side,Oe):Ru(v.current,se.path,Oe)),X()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${se.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},se.key)),R&&s.jsx("div",{role:"alert",className:"absolute bottom-1 left-1 z-20 rounded bg-surface px-2 py-1 text-[10px] text-destructive",children:R})]})}let mm=0,jg=!1,i0=0;function iS(){if(jg||typeof window>"u")return;jg=!0;const e=()=>{mm=performance.now()};window.addEventListener("pointerdown",()=>{i0+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{i0=Math.max(0,i0-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{i0=0,e()})}function o1(e,t=500){iS();let r=!1,n,a;const l=()=>{if(r)return;if(i0>0||performance.now()-mm<400){a=setTimeout(l,100);return}const c=()=>{if(!r){if(i0>0||performance.now()-mm<400){a=setTimeout(l,100);return}e()}};"requestIdleCallback"in window?n=window.requestIdleCallback(c):a=setTimeout(c,16)};return a=setTimeout(l,t),()=>{r=!0,clearTimeout(a),n!==void 0&&window.cancelIdleCallback(n)}}function aS(e){const[t,r]=b.useState(e);return b.useEffect(()=>o1(()=>r(e),0),[e]),t}function oS(e,t,r){b.useEffect(()=>{e&&n8(e,!0)},[e,r])}const Si=[];for(let e=0;e<256;++e)Si.push((e+256).toString(16).slice(1));function lS(e,t=0){return(Si[e[t+0]]+Si[e[t+1]]+Si[e[t+2]]+Si[e[t+3]]+"-"+Si[e[t+4]]+Si[e[t+5]]+"-"+Si[e[t+6]]+Si[e[t+7]]+"-"+Si[e[t+8]]+Si[e[t+9]]+"-"+Si[e[t+10]]+Si[e[t+11]]+Si[e[t+12]]+Si[e[t+13]]+Si[e[t+14]]+Si[e[t+15]]).toLowerCase()}let Kf;const cS=new Uint8Array(16);function uS(){if(!Kf){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Kf=crypto.getRandomValues.bind(crypto)}return Kf(cS)}const dS=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Bg={randomUUID:dS};function hS(e,t,r){e=e||{};const n=e.random??e.rng?.()??uS();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,lS(n)}function r3(e,t,r){return Bg.randomUUID&&!e?Bg.randomUUID():hS(e)}const n3="\x1B[?2026h",fS="\x1B[?2026l",s3="\x1Bc";function pS(e){return e.replace(/(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|(?:\x1b[P_X^]|[\x90\x98\x9e\x9f])[\s\S]*?(?:\x1b\\|\x9c|$)|(?:\x1b\[|\x9b)\?([\d;]+)([hl])|(?:\x1b\[|\x9b)[\d;]*!p|\x1bc/g,(t,r,n)=>{if(t===s3||t.endsWith("!p"))return t+n3;if(r===void 0)return t;const a=r.split(";").filter(l=>Number(l)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function mS(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=pS(t.replace(/^(?:\x1bc)+/,""));return[`${s3}${n3}${r}${fS}`]}function gS(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function xS(e){return[["10",e.foreground],["11",e.background]].map(([t,r])=>{const n=/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec(r);if(!n)return"";const a=n.slice(1).map(l=>l.repeat(2)).join("/");return`\x1B]${t};rgb:${a}\x1B\\`}).join("")}const bS={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},yS={F1:"P",F2:"Q",F3:"R",F4:"S"},vS={Insert:2,Delete:3,PageUp:5,PageDown:6,F5:15,F6:17,F7:18,F8:19,F9:20,F10:21,F11:23,F12:24};function wS(e,t=!1){if(e.metaKey||e.isComposing||e.keyCode===229||e.getModifierState?.("AltGraph"))return null;const{key:r,shiftKey:n,altKey:a,ctrlKey:l}=e,c=1+Number(n)+2*Number(a)+4*Number(l),h=c===1?"":`;${c}`,p=bS[r];if(p)return c!==1?`\x1B[1${h}${p}`:`\x1B${t?"O":"["}${p}`;const g=yS[r];if(g)return c!==1?`\x1B[1${h}${g}`:`\x1BO${g}`;if(r==="Insert"&&!a&&(n||l))return null;const x=vS[r];if(x)return`\x1B[${x}${h}~`;if(r==="Tab")return a?`\x1B${n?"\x1B[Z":" "}`:n?"\x1B[Z":" ";if(r==="Escape")return a?"\x1B\x1B":"\x1B";if(r==="Enter")return a?"\x1B\r":null;if(r==="Backspace")return l||a?`${a?"\x1B":""}${l?"\b":""}`:null;if(r.length!==1)return null;if(l){const y=r.toUpperCase();let A;return/^[A-Z]$/.test(y)?A=y.charCodeAt(0)-64:r===" "||r==="@"||r==="2"?A=0:"[\\]^_".includes(r)?A=r.charCodeAt(0)-64:/^[3-7]$/.test(r)?A=Number(r)+24:r==="?"||r==="8"?A=127:r==="/"&&(A=31),A===void 0?null:`${a?"\x1B":""}${String.fromCharCode(A)}`}return a?`\x1B${r}`:null}class Mu extends Error{}async function i3(e){if(!e.type.startsWith("image/")||e.size===0)throw new Error("Clipboard image is empty");const t=e.type==="image/jpeg"?"jpg":e.type.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png",r=new File([e],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${t}`,{type:e.type}),{files:n}=await ad("/tmp",[r]);if(!n[0]?.path)throw new Error("Upload did not return an image path");return n[0].path}async function Uh(e){const t=ao();if(t?.readClipboardImage){const r=await t.readClipboardImage();return r?.byteLength?new File([r],"clipboard.png",{type:"image/png"}):null}if(typeof e?.read!="function")return null;for(const r of await e.read()){const n=r.types.find(c=>c.startsWith("image/"));if(!n)continue;const a=await r.getType(n),l=n==="image/jpeg"?"jpg":n.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png";return new File([a],`termdock-clipboard-${Date.now()}.${l}`,{type:n})}return null}async function a3(e){if(typeof e?.read!="function")return[];const t=[],r={"video/mp4":"mp4","video/quicktime":"mov","video/x-m4v":"m4v","video/webm":"webm","video/ogg":"ogv","video/mpeg":"mpeg","video/x-msvideo":"avi","video/x-matroska":"mkv","video/3gpp":"3gp","video/3gpp2":"3g2"};for(const n of await e.read()){const a=n.types.find(p=>p.startsWith("video/"));if(!a)continue;const l=await n.getType(a);if(!l.size)throw new Error("Clipboard video is empty");const c=a.split(";")[0].toLowerCase(),h=r[c]||c.slice(6).replace(/[^a-z0-9]/g,"")||"mp4";t.push(new File([l],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${h}`,{type:a}))}return t}async function o3(){const e=Ou()?.targetPeerId;let t;try{t=await ao()?.readClipboardFiles?.({localServiceId:e})}catch(a){const l=a instanceof Error?a.message:String(a),c="TERMDOCK_CLIPBOARD_VIDEO_ERROR:",h=l.indexOf(c);if(h!==-1)throw new Mu(l.slice(h+c.length).trim());const p=l.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw p?new Mu(p[1]):a}if(Ou()?.targetPeerId!==e)throw new Error("目标服务已切换,请重新粘贴");const r=[],n=[];for(const a of t??[])if(a.path&&e)n.push(a.path);else if(a.bytes){if(a.type?.startsWith("video/")&&a.bytes.byteLength===0)throw new Mu("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");r.push(new File([a.bytes],a.name,{type:a.type||"application/octet-stream"}))}else throw new Error("剪贴板未提供可读取的文件");return{files:r,paths:n}}async function l3(e){if(!e.length)return[];const{files:t}=await ad("/tmp",e);if(t.length!==e.length||t.some(r=>!r.path))throw new Error("Upload did not return every file path");return t.map(r=>r.path)}function qs(e){return{dispose:e}}function AS(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function TS(...e){return qs(()=>AS(e))}var c3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},Mc=class{constructor(){this._store=new c3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Mc.None=Object.freeze({dispose(){}});var U0=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},u3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),cd=u3?"node":navigator.userAgent,SS=u3?"node":navigator.platform,CS=cd.includes("Firefox");cd.includes("Chrome");var _S=cd.includes("Edge"),d3=/^((?!chrome|android).)*safari/i.test(cd);function LS(){if(!d3)return 0;let e=cd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}SS.indexOf("Linux")>=0;var ni=0,si=0,ii=0,_s=0,to={css:"#00000000",rgba:0},ra;(e=>{function t(a,l,c,h){return h!==void 0?`#${cc(a)}${cc(l)}${cc(c)}${cc(h)}`:`#${cc(a)}${cc(l)}${cc(c)}`}e.toCss=t;function r(a,l,c,h=255){return(a<<24|l<<16|c<<8|h)>>>0}e.toRgba=r;function n(a,l,c,h){return{css:e.toCss(a,l,c,h),rgba:e.toRgba(a,l,c,h)}}e.toColor=n})(ra||={});var Su;(e=>{function t(p,g){if(_s=(g.rgba&255)/255,_s===1)return{css:g.css,rgba:g.rgba};let x=g.rgba>>24&255,y=g.rgba>>16&255,A=g.rgba>>8&255,v=p.rgba>>24&255,L=p.rgba>>16&255,I=p.rgba>>8&255;ni=v+Math.round((x-v)*_s),si=L+Math.round((y-L)*_s),ii=I+Math.round((A-I)*_s);let E=ra.toCss(ni,si,ii),R=ra.toRgba(ni,si,ii);return{css:E,rgba:R}}e.blend=t;function r(p){return(p.rgba&255)===255}e.isOpaque=r;function n(p,g,x){let y=_c.ensureContrastRatio(p.rgba,g.rgba,x);if(y)return ra.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let g=(p.rgba|255)>>>0;return[ni,si,ii]=_c.toChannels(g),{css:ra.toCss(ni,si,ii),rgba:g}}e.opaque=a;function l(p,g){return _s=Math.round(g*255),[ni,si,ii]=_c.toChannels(p.rgba),{css:ra.toCss(ni,si,ii,_s),rgba:ra.toRgba(ni,si,ii,_s)}}e.opacity=l;function c(p,g){return _s=p.rgba&255,l(p,_s*g/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(Su||={});var kS;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return ni=parseInt(a.slice(1,2).repeat(2),16),si=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),ra.toColor(ni,si,ii);case 5:return ni=parseInt(a.slice(1,2).repeat(2),16),si=parseInt(a.slice(2,3).repeat(2),16),ii=parseInt(a.slice(3,4).repeat(2),16),_s=parseInt(a.slice(4,5).repeat(2),16),ra.toColor(ni,si,ii,_s);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let l=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return ni=parseInt(l[1],10),si=parseInt(l[2],10),ii=parseInt(l[3],10),_s=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),ra.toColor(ni,si,ii,_s);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ni,si,ii,_s]=t.getImageData(0,0,1,1).data,_s!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ra.toRgba(ni,si,ii,_s),css:a}}e.toColor=n})(kS||={});var Ki;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,l){let c=n/255,h=a/255,p=l/255,g=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return g*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(Ki||={});var _c;(e=>{function t(c,h){if(_s=(h&255)/255,_s===1)return h;let p=h>>24&255,g=h>>16&255,x=h>>8&255,y=c>>24&255,A=c>>16&255,v=c>>8&255;return ni=y+Math.round((p-y)*_s),si=A+Math.round((g-A)*_s),ii=v+Math.round((x-v)*_s),ra.toRgba(ni,si,ii)}e.blend=t;function r(c,h,p){let g=Ki.relativeLuminance(c>>8),x=Ki.relativeLuminance(h>>8);if(ml(g,x)<p){if(x<g){let v=n(c,h,p),L=ml(g,Ki.relativeLuminance(v>>8));if(L<p){let I=a(c,h,p),E=ml(g,Ki.relativeLuminance(I>>8));return L>E?v:I}return v}let y=a(c,h,p),A=ml(g,Ki.relativeLuminance(y>>8));if(A<p){let v=n(c,h,p),L=ml(g,Ki.relativeLuminance(v>>8));return A>L?y:v}return y}}e.ensureContrastRatio=r;function n(c,h,p){let g=c>>24&255,x=c>>16&255,y=c>>8&255,A=h>>24&255,v=h>>16&255,L=h>>8&255,I=ml(Ki.relativeLuminance2(A,v,L),Ki.relativeLuminance2(g,x,y));for(;I<p&&(A>0||v>0||L>0);)A-=Math.max(0,Math.ceil(A*.1)),v-=Math.max(0,Math.ceil(v*.1)),L-=Math.max(0,Math.ceil(L*.1)),I=ml(Ki.relativeLuminance2(A,v,L),Ki.relativeLuminance2(g,x,y));return(A<<24|v<<16|L<<8|255)>>>0}e.reduceLuminance=n;function a(c,h,p){let g=c>>24&255,x=c>>16&255,y=c>>8&255,A=h>>24&255,v=h>>16&255,L=h>>8&255,I=ml(Ki.relativeLuminance2(A,v,L),Ki.relativeLuminance2(g,x,y));for(;I<p&&(A<255||v<255||L<255);)A=Math.min(255,A+Math.ceil((255-A)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),L=Math.min(255,L+Math.ceil((255-L)*.1)),I=ml(Ki.relativeLuminance2(A,v,L),Ki.relativeLuminance2(g,x,y));return(A<<24|v<<16|L<<8|255)>>>0}e.increaseLuminance=a;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(_c||={});function cc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ml(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Fs(e){if(!e)throw new Error("value must not be falsy");return e}function l1(e){return 57508<=e&&e<=57558}function IS(e){return 57520<=e&&e<=57527}function ES(e){return 57344<=e&&e<=63743}function NS(e){return 9472<=e&&e<=9631}function RS(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function MS(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!RS(e)&&!l1(e)&&!ES(e)}function h3(e){return l1(e)||NS(e)}function DS(){return{css:{canvas:Pd(),cell:Pd()},device:{canvas:Pd(),cell:Pd(),char:{width:0,height:0,left:0,top:0}}}}function Pd(){return{width:0,height:0}}function jS(e,t,r=0){return(e-(Math.round(t)*2-r))%(Math.round(t)*2)}var De;(e=>(e.LINE_H=Object.freeze({type:2,data:"M0,.5 L1,.5",strokeWidth:1}),e.LINE_V=Object.freeze({type:2,data:"M.5,0 L.5,1",strokeWidth:1}),e.FADE_RIGHT=Object.freeze({type:2,data:"M0,.5 L.28,.5 M.32,.5 L.52,.5 M.60,.5 L.72,.5 M.84,.5 L.90,.5",strokeWidth:1}),e.FADE_LEFT=Object.freeze({type:2,data:"M.10,.5 L.16,.5 M.28,.5 L.40,.5 M.48,.5 L.68,.5 M.72,.5 L1,.5",strokeWidth:1}),e.FADE_DOWN=Object.freeze({type:2,data:"M.5,0 L.5,.28 M.5,.32 L.5,.52 M.5,.60 L.5,.72 M.5,.84 L.5,.90",strokeWidth:1}),e.FADE_UP=Object.freeze({type:2,data:"M.5,.10 L.5,.16 M.5,.28 L.5,.40 M.5,.48 L.5,.68 M.5,.72 L.5,1",strokeWidth:1}),e.CURVE_DOWN_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_DOWN_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.CURVE_UP_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_UP_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.NODE_FILL=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5"}),e.NODE_STROKE=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5",strokeWidth:1}),e.NODE_LINE_RIGHT=Object.freeze({type:3,data:"M1,.5 L.85,.5",strokeWidth:1}),e.NODE_LINE_LEFT=Object.freeze({type:3,data:"M0,.5 L.15,.5",strokeWidth:1}),e.NODE_LINE_DOWN=Object.freeze({type:3,data:"M.5,1 L.5,.7",strokeWidth:1}),e.NODE_LINE_UP=Object.freeze({type:3,data:"M.5,0 L.5,.3",strokeWidth:1})))(De||={});var BS={"─":{type:2,data:"M0,.5 L1,.5",strokeWidth:1},"━":{type:2,data:"M0,.5 L1,.5",strokeWidth:3},"│":{type:2,data:"M.5,0 L.5,1",strokeWidth:1},"┃":{type:2,data:"M.5,0 L.5,1",strokeWidth:3},"┄":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:1},"┅":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:3},"┆":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:1},"┇":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:3},"┈":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:1},"┉":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:3},"┊":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:1},"┋":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:3},"┌":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},"┍":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┎":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┏":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3},"┐":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},"┑":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┒":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┓":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3},"└":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},"┕":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┖":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┗":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3},"┘":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},"┙":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┚":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┛":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3},"├":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},"┝":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┞":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┟":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┠":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┡":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┢":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┣":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3},"┤":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},"┥":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┦":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┧":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┨":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┩":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┪":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┫":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3},"┬":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},"┭":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┮":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┯":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┰":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┱":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┲":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┳":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3},"┴":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:1},"┵":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┶":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┷":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┸":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┹":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┺":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┻":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:3},"┼":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:1},"┽":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┾":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┿":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"╀":[{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"╁":[{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╂":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"╃":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"╄":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"╅":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"╆":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"╇":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:3}],"╈":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3}],"╉":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3}],"╊":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3}],"╋":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:3},"╌":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:1},"╍":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:3},"╎":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:1},"╏":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:3},"═":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"║":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╒":{type:2,data:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╓":{type:2,data:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╔":{type:2,data:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╕":{type:2,data:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╖":{type:2,data:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`,strokeWidth:1},"╗":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`,strokeWidth:1},"╘":{type:2,data:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`,strokeWidth:1},"╙":{type:2,data:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╚":{type:2,data:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`,strokeWidth:1},"╛":{type:2,data:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`,strokeWidth:1},"╜":{type:2,data:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`,strokeWidth:1},"╝":{type:2,data:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`,strokeWidth:1},"╞":{type:2,data:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╟":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`,strokeWidth:1},"╠":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╡":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╢":{type:2,data:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╣":{type:2,data:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`,strokeWidth:1},"╤":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`,strokeWidth:1},"╥":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╦":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╧":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╨":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╩":{type:2,data:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╪":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╫":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╬":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╭":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╮":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╯":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╰":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╱":{type:2,data:"M1,0 L0,1",strokeWidth:1},"╲":{type:2,data:"M0,0 L1,1",strokeWidth:1},"╳":{type:2,data:"M1,0 L0,1 M0,0 L1,1",strokeWidth:1},"╴":{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},"╵":{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},"╶":{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},"╷":{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},"╸":{type:2,data:"M.5,.5 L0,.5",strokeWidth:3},"╹":{type:2,data:"M.5,.5 L.5,0",strokeWidth:3},"╺":{type:2,data:"M.5,.5 L1,.5",strokeWidth:3},"╻":{type:2,data:"M.5,.5 L.5,1",strokeWidth:3},"╼":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"╽":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╾":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"╿":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"▀":{type:0,data:[{x:0,y:0,w:8,h:4}]},"▁":{type:0,data:[{x:0,y:7,w:8,h:1}]},"▂":{type:0,data:[{x:0,y:6,w:8,h:2}]},"▃":{type:0,data:[{x:0,y:5,w:8,h:3}]},"▄":{type:0,data:[{x:0,y:4,w:8,h:4}]},"▅":{type:0,data:[{x:0,y:3,w:8,h:5}]},"▆":{type:0,data:[{x:0,y:2,w:8,h:6}]},"▇":{type:0,data:[{x:0,y:1,w:8,h:7}]},"█":{type:0,data:[{x:0,y:0,w:8,h:8}]},"▉":{type:0,data:[{x:0,y:0,w:7,h:8}]},"▊":{type:0,data:[{x:0,y:0,w:6,h:8}]},"▋":{type:0,data:[{x:0,y:0,w:5,h:8}]},"▌":{type:0,data:[{x:0,y:0,w:4,h:8}]},"▍":{type:0,data:[{x:0,y:0,w:3,h:8}]},"▎":{type:0,data:[{x:0,y:0,w:2,h:8}]},"▏":{type:0,data:[{x:0,y:0,w:1,h:8}]},"▐":{type:0,data:[{x:4,y:0,w:4,h:8}]},"░":{type:1,data:[[1,0],[0,0]]},"▒":{type:1,data:[[1,0],[0,1]]},"▓":{type:1,data:[[1,1],[1,0]]},"▔":{type:0,data:[{x:0,y:0,w:8,h:1}]},"▕":{type:0,data:[{x:7,y:0,w:1,h:8}]},"▖":{type:0,data:[{x:0,y:4,w:4,h:4}]},"▗":{type:0,data:[{x:4,y:4,w:4,h:4}]},"▘":{type:0,data:[{x:0,y:0,w:4,h:4}]},"▙":{type:0,data:[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"▚":{type:0,data:[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}]},"▛":{type:0,data:[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}]},"▜":{type:0,data:[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}]},"▝":{type:0,data:[{x:4,y:0,w:4,h:4}]},"▞":{type:0,data:[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}]},"▟":{type:0,data:[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"":{type:5,data:{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.7,.03 L.7,.1 L.355,.1 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2}},"":{type:5,data:{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2}},"":{type:5,data:{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1}},"":{type:5,data:{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1}},"":{type:5,data:{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0.8069,0.6075 Q0.7991,0.612,0.7815,0.6218 T0.7542,0.6369 T0.7282,0.6508 T0.7016,0.6644 T0.6778,0.6758 T0.6551,0.6854 T0.637,0.6911 T0.622,0.6936 Q0.6186,0.6936,0.6128,0.6942 T0.6018,0.6952 T0.5894,0.6956 T0.5757,0.6952 T0.561,0.693 T0.5451,0.6879 Q0.5342,0.6834,0.5193,0.6756 T0.4925,0.6614 T0.4673,0.6485 T0.4436,0.6389 T0.4239,0.6363 T0.4089,0.6422 Q0.4045,0.6467,0.3958,0.6554 T0.3843,0.6669 T0.3748,0.6746 T0.3613,0.683 T0.3442,0.6903 L0.3499,0.6956 Q0.3584,0.7042,0.3679,0.7177 T0.3836,0.7403 T0.4019,0.7583 T0.4295,0.7703 Q0.4688,0.7785,0.5203,0.7605 Q0.4902,0.7817,0.449,0.7911 T0.3696,0.8001 Q0.3567,0.7997,0.341,0.7942 T0.3111,0.7813 T0.2805,0.766 T0.2493,0.753 T0.218,0.7472 T0.187,0.754 Q0.1762,0.7589,0.1653,0.7681 T0.1453,0.7895 T0.1308,0.818 T0.1264,0.8507 L0.1264,0.858 Q0.1453,0.8462,0.1607,0.8433 T0.1899,0.8452 T0.2226,0.8625 Q0.2344,0.8707,0.2485,0.8752 T0.2813,0.8831 T0.3089,0.889 Q0.2981,0.8915,0.2846,0.8956 T0.2603,0.9037 T0.2368,0.9115 T0.2129,0.9174 T0.1894,0.9194 T0.1653,0.9155 Q0.1504,0.9115,0.1328,0.9196 T0.0986,0.9421 T0.0655,0.9708 T0.0317,0.9943 T0,1 Q0.001,0.94,0.0017,0.6508 T0.0024,0.2322 Q0.002,0.2109,0.0007,0.1379 T0,0.0249 Q0.0058,0.0253,0.009,0.0257 T0.0156,0.0288 T0.0203,0.0333 T0.0264,0.0422 T0.0349,0.0539 Q0.044,0.0657,0.0542,0.072 T0.0752,0.0789 T0.096,0.0775 T0.1175,0.0694 T0.1379,0.0573 T0.1579,0.0432 Q0.2141,0,0.2673,0.0318 Q0.2588,0.0318,0.2517,0.033 T0.239,0.0361 T0.2276,0.0424 T0.218,0.0504 T0.2085,0.0612 T0.1997,0.0732 T0.1899,0.0875 T0.1795,0.1028 Q0.1748,0.1093,0.1507,0.1234 T0.1186,0.1448 Q0.0999,0.1612,0.1108,0.1783 Q0.1162,0.1877,0.1238,0.1928 T0.1404,0.1979 T0.158,0.1967 T0.1775,0.1895 T0.1963,0.1791 T0.2151,0.1663 T0.2314,0.1534 T0.2458,0.141 T0.2561,0.1322 Q0.2815,0.1106,0.3017,0.101 T0.344,0.0926 T0.3919,0.1077 Q0.4099,0.1175,0.4265,0.1206 T0.4588,0.1202 T0.488,0.1098 T0.5176,0.0914 Q0.5071,0.1032,0.4963,0.1122 T0.4722,0.1285 T0.4497,0.1401 T0.4223,0.1518 T0.3943,0.1636 Q0.374,0.1726,0.3623,0.1863 T0.3482,0.2162 Q0.3445,0.2403,0.3608,0.2605 T0.4072,0.2876 Q0.4194,0.2909,0.4326,0.2899 T0.457,0.2856 T0.4805,0.2764 T0.5032,0.264 T0.5256,0.2497 T0.5478,0.2352 T0.5698,0.2222 T0.5921,0.2118 Q0.6982,0.173,0.81,0.2436 Q0.833,0.2583,0.8496,0.2674 T0.887,0.2846 T0.925,0.294 T0.9617,0.2911 T1,0.2746 Q0.9817,0.2946,0.96,0.3056 T0.9175,0.3191 T0.8731,0.3209 T0.8277,0.3164 T0.7818,0.3109 T0.7359,0.3101 T0.6907,0.3197 T0.647,0.3448 Q0.6443,0.3472,0.6333,0.3562 T0.6194,0.3674 T0.6076,0.3766 T0.594,0.386 T0.5815,0.3931 T0.5661,0.4007 T0.5501,0.4064 L0.5556,0.4121 Q0.5627,0.4198,0.5722,0.4251 T0.5926,0.4337 T0.6131,0.439 T0.6343,0.4431 T0.6521,0.4468 Q0.6762,0.4529,0.7056,0.4463 Q0.6772,0.4623,0.6543,0.471 T0.604,0.4814 Q0.5962,0.4818,0.5815,0.4825 T0.5591,0.4835 T0.5393,0.4857 T0.519,0.4908 T0.5007,0.4996 T0.4812,0.5141 T0.4627,0.5353 L0.4549,0.5451 L0.4661,0.543 Q0.4759,0.541,0.4909,0.55 T0.5315,0.5796 T0.5684,0.6083 Q0.5799,0.6161,0.5915,0.6212 T0.6181,0.6308 L0.6331,0.6353 Q0.6514,0.6418,0.7004,0.633 T0.8069,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.011,0.0469 Q0.0152,0.0412,0.02,0.0361 T0.0292,0.0281 T0.0365,0.0253 Q0.0426,0.0257,0.0461,0.0263 T0.0534,0.03 T0.0582,0.0345 T0.0645,0.0434 T0.0723,0.0546 Q0.0807,0.0653,0.0897,0.0712 T0.1081,0.0775 T0.1255,0.0765 T0.1438,0.0695 T0.1605,0.0593 T0.1772,0.0473 Q0.2388,0,0.2927,0.0326 L0.2614,0.0767 L0.2581,0.0767 Q0.2494,0.0767,0.2444,0.0773 T0.2359,0.0789 T0.2291,0.0842 T0.2233,0.0922 T0.2146,0.1054 T0.2026,0.1236 Q0.1943,0.1354,0.1843,0.1444 T0.1675,0.1574 T0.1526,0.1654 T0.1429,0.1701 Q0.1436,0.1717,0.1446,0.1733 Q0.1504,0.1823,0.1581,0.1866 T0.1733,0.1915 T0.1909,0.1884 T0.2085,0.1809 T0.2265,0.169 T0.2427,0.1564 T0.2575,0.1436 T0.2688,0.1338 Q0.2969,0.1101,0.3195,0.0995 T0.3643,0.0901 T0.4114,0.1048 Q0.4279,0.1138,0.4426,0.1168 T0.4705,0.117 T0.4945,0.1089 T0.5186,0.0942 L0.5211,0.0926 L0.5289,0.0922 Q0.5411,0.095,0.5189,0.1203 Q0.505,0.1358,0.4913,0.1474 T0.4634,0.167 T0.4389,0.1796 T0.4121,0.1909 T0.3866,0.2011 Q0.3782,0.2047,0.3727,0.2092 Q0.3717,0.2117,0.3714,0.2141 Q0.3695,0.2263,0.3751,0.2388 T0.394,0.2616 T0.4253,0.2761 Q0.4398,0.2785,0.4513,0.2779 T0.4756,0.2724 T0.4987,0.2616 T0.5216,0.2476 T0.5453,0.2321 T0.5703,0.217 T0.5976,0.2043 Q0.7015,0.166,0.8099,0.2345 Q0.8361,0.2512,0.8572,0.2616 T0.9006,0.2779 T0.9432,0.281 T0.9819,0.2663 L0.9887,0.2671 Q1,0.272,0.9768,0.2969 Q0.9558,0.3193,0.9319,0.333 T0.8858,0.3513 T0.8391,0.3569 T0.793,0.3546 T0.7485,0.3497 T0.7065,0.3473 T0.6681,0.3522 T0.6344,0.3699 Q0.5963,0.4005,0.5847,0.4082 Q0.595,0.4139,0.6079,0.4174 T0.6367,0.4237 T0.6586,0.4278 Q0.6793,0.4331,0.7044,0.4278 Q0.7057,0.4278,0.707,0.4274 Q0.7067,0.429,0.7062,0.4313 T0.7036,0.4398 T0.6993,0.4513 T0.6931,0.4619 T0.6851,0.4698 Q0.6573,0.4857,0.6336,0.4947 T0.5831,0.5053 Q0.577,0.5057,0.5615,0.5065 T0.5394,0.508 T0.5221,0.51 T0.5042,0.5139 T0.4905,0.5204 Q0.5008,0.5232,0.515,0.5328 T0.549,0.5585 T0.5799,0.5824 Q0.5905,0.5897,0.6013,0.5946 T0.6262,0.6036 T0.6409,0.6081 Q0.6567,0.6134,0.7035,0.605 T0.8028,0.5816 L0.7974,0.5922 T0.7867,0.6134 L0.7812,0.624 Q0.7799,0.6248,0.7786,0.6252 Q0.7709,0.6297,0.7573,0.6372 T0.7346,0.6499 T0.7123,0.6621 T0.6897,0.6741 T0.6686,0.6847 T0.648,0.6941 T0.6297,0.7013 T0.6129,0.7062 T0.5995,0.7076 Q0.5992,0.7076,0.5831,0.7092 T0.5529,0.7092 T0.525,0.7019 Q0.5105,0.6958,0.4824,0.6811 T0.4356,0.6586 T0.4079,0.6533 Q0.3872,0.6741,0.3827,0.6782 Q0.3872,0.6835,0.3934,0.6929 T0.4037,0.7078 T0.4142,0.7198 T0.4284,0.7304 T0.4466,0.7365 Q0.4824,0.7443,0.5292,0.728 L0.5292,0.7294 T0.529,0.7333 T0.5284,0.7392 T0.5266,0.7463 T0.5236,0.7539 T0.5186,0.7612 T0.5111,0.7679 Q0.5086,0.77,0.5056,0.7716 Q0.4466,0.8104,0.3591,0.8091 Q0.344,0.8091,0.3246,0.802 T0.2893,0.7863 T0.2543,0.77 T0.2206,0.76 T0.1894,0.7643 Q0.1804,0.7684,0.1733,0.7753 Q0.1591,0.7892,0.1601,0.8169 Q0.1784,0.8067,0.1938,0.8053 T0.2212,0.8087 T0.2507,0.825 Q0.2614,0.8324,0.2744,0.8365 T0.3053,0.844 T0.332,0.8499 L0.303,0.894 L0.2998,0.8948 Q0.2904,0.8968,0.278,0.9009 T0.2554,0.9086 T0.233,0.9158 T0.2099,0.9213 T0.1868,0.9229 T0.1633,0.9192 Q0.1517,0.916,0.1367,0.9241 T0.1065,0.9462 T0.0753,0.9737 T0.041,0.9955 T0.0061,1 Q0,0.9984,0.0068,0.9845 Q0.009,0.9804,0.0123,0.9755 Q0.0187,0.9666,0.0261,0.9606 T0.0374,0.9555 Q0.0481,0.958,0.0629,0.949 T0.0931,0.9262 T0.1247,0.8987 T0.1597,0.8777 T0.1949,0.8752 Q0.213,0.8805,0.2343,0.8772 Q0.2249,0.8736,0.2172,0.8683 Q0.1914,0.8511,0.1738,0.8497 T0.1349,0.8617 Q0.1304,0.865,0.1273,0.8646 T0.1242,0.8605 L0.1239,0.8536 Q0.1226,0.8295,0.1354,0.8016 T0.1723,0.7496 Q0.1914,0.7308,0.2104,0.7219 Q0.2259,0.7145,0.2425,0.7141 T0.273,0.7182 T0.3022,0.7296 T0.3301,0.7439 T0.3569,0.7571 T0.3821,0.7643 Q0.373,0.7561,0.3598,0.7367 T0.3382,0.7088 L0.3327,0.7035 Q0.3282,0.699,0.3353,0.6884 T0.3517,0.6692 L0.3611,0.6607 Q0.3711,0.657,0.3751,0.6554 T0.3837,0.6507 T0.3898,0.6458 T0.3979,0.637 T0.4111,0.6236 Q0.4172,0.6175,0.4234,0.6138 Q0.4327,0.6081,0.4439,0.6077 T0.4655,0.6105 T0.4884,0.6201 T0.5113,0.633 T0.5347,0.6468 T0.5573,0.6578 Q0.5705,0.6635,0.5833,0.665 T0.6112,0.665 T0.6286,0.6635 Q0.6421,0.6631,0.6718,0.6501 Q0.626,0.6578,0.6089,0.6517 Q0.6063,0.6509,0.6002,0.6491 T0.5884,0.6454 T0.5757,0.6409 T0.561,0.6344 T0.5466,0.6256 Q0.536,0.6183,0.5108,0.5989 T0.4722,0.5712 T0.4527,0.564 L0.4418,0.5661 Q0.4308,0.5681,0.4366,0.5563 Q0.4401,0.5485,0.4476,0.5392 L0.455,0.5298 Q0.4631,0.5188,0.4714,0.51 T0.4866,0.4947 T0.5021,0.4831 T0.516,0.4749 T0.53,0.4694 T0.5428,0.4657 T0.5558,0.4637 T0.5674,0.4629 T0.5795,0.4625 Q0.5489,0.4543,0.534,0.4384 L0.5286,0.4327 Q0.5244,0.4282,0.5318,0.4174 T0.5486,0.398 L0.5579,0.3899 Q0.567,0.387,0.5749,0.3834 T0.5878,0.3772 T0.6012,0.3687 T0.6126,0.3603 T0.6268,0.3487 T0.6421,0.3361 Q0.6567,0.3242,0.6712,0.3159 T0.7009,0.3034 T0.7277,0.2973 T0.7556,0.2961 T0.7809,0.2977 T0.8074,0.301 Q0.8096,0.3014,0.8109,0.3016 T0.8143,0.302 T0.818,0.3026 Q0.8012,0.2936,0.7767,0.2781 Q0.6718,0.2117,0.5744,0.2476 Q0.5637,0.2516,0.5492,0.2604 T0.5218,0.2779 T0.4923,0.2965 T0.461,0.3124 T0.4282,0.3216 T0.394,0.3206 Q0.3637,0.3136,0.3474,0.2936 T0.3353,0.2459 Q0.3385,0.2247,0.355,0.2023 Q0.3646,0.1892,0.3763,0.179 Q0.3898,0.1672,0.4063,0.1595 Q0.3927,0.1562,0.3785,0.1485 Q0.3604,0.1387,0.3453,0.1354 T0.3161,0.1354 T0.2899,0.1458 T0.2627,0.166 Q0.262,0.1664,0.254,0.1733 T0.2414,0.1841 T0.2267,0.196 T0.2094,0.2086 T0.1915,0.2196 T0.1725,0.2288 T0.1546,0.2337 T0.1373,0.2343 T0.1223,0.228 T0.1097,0.2145 Q0.0962,0.1929,0.1258,0.1582 Q0.131,0.1517,0.1371,0.1464 Q0.1462,0.1387,0.156,0.1321 T0.1752,0.1205 T0.1878,0.1134 Q0.1891,0.1117,0.1947,0.103 T0.2035,0.0899 T0.2125,0.0781 T0.2243,0.064 Q0.1949,0.0616,0.1672,0.0828 Q0.153,0.0934,0.1412,0.1009 T0.1146,0.1146 T0.0873,0.1213 T0.0616,0.116 T0.0374,0.0962 Q0.0339,0.0909,0.0295,0.0846 T0.024,0.0767 T0.0202,0.0728 T0.0148,0.0704 T0.0068,0.0697 Q0.0003,0.0693,0.0058,0.0567 Q0.0077,0.0522,0.011,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.1934,0.6075 Q0.2012,0.612,0.2188,0.6218 T0.2459,0.6369 T0.2718,0.6508 T0.2983,0.6644 T0.322,0.6758 T0.3447,0.6854 T0.363,0.6911 T0.3783,0.6936 Q0.3796,0.6936,0.396,0.6952 T0.4265,0.6952 T0.4548,0.6879 Q0.4656,0.6834,0.4805,0.6756 T0.5073,0.6614 T0.5327,0.6485 T0.5564,0.6389 T0.5759,0.6363 T0.5909,0.6422 Q0.5953,0.6467,0.604,0.6554 T0.6155,0.6669 T0.6251,0.6746 T0.6387,0.683 T0.6556,0.6903 L0.6498,0.6956 Q0.6414,0.7042,0.6319,0.7177 T0.6162,0.7403 T0.5979,0.7583 T0.5703,0.7703 Q0.5313,0.7785,0.4799,0.7605 Q0.5097,0.7817,0.5508,0.7911 T0.6302,0.8001 Q0.6431,0.7997,0.659,0.7942 T0.6888,0.7813 T0.7194,0.766 T0.7506,0.753 T0.7819,0.7472 T0.8131,0.754 Q0.8239,0.7589,0.8346,0.7681 T0.8544,0.7895 T0.8689,0.818 T0.8737,0.8507 L0.8733,0.858 Q0.8591,0.849,0.8474,0.845 T0.8242,0.8421 T0.8021,0.8482 T0.7772,0.8625 Q0.7653,0.8707,0.7513,0.8752 T0.7184,0.8831 T0.6908,0.889 Q0.7017,0.8915,0.7152,0.8956 T0.7396,0.9037 T0.7633,0.9115 T0.7872,0.9174 T0.8107,0.9194 T0.8347,0.9155 Q0.8493,0.9115,0.8671,0.9196 T0.9015,0.9421 T0.9345,0.9708 T0.9682,0.9943 T0.9997,1 Q0.999,0.94,0.9983,0.6508 T0.9976,0.2322 Q0.9976,0.2109,0.9992,0.1379 T1,0.0249 Q0.9949,0.0249,0.9917,0.0257 T0.9863,0.0273 T0.9817,0.0308 T0.9776,0.0357 T0.9721,0.0437 T0.9651,0.0539 Q0.956,0.0657,0.9456,0.072 T0.9247,0.0789 T0.904,0.0775 T0.8823,0.0694 T0.862,0.0573 T0.8422,0.0432 Q0.7856,0,0.7328,0.0318 Q0.7392,0.0318,0.7452,0.0324 T0.756,0.0345 T0.7657,0.0386 T0.7741,0.0437 T0.7821,0.0506 T0.7894,0.0588 T0.7966,0.0683 T0.8039,0.0787 T0.8119,0.0904 T0.8202,0.1028 Q0.8249,0.1093,0.849,0.1234 T0.8811,0.1448 Q0.8998,0.1612,0.8893,0.1783 Q0.8835,0.1877,0.8759,0.1928 T0.8593,0.1979 T0.8417,0.1967 T0.8222,0.1895 T0.8034,0.1791 T0.7848,0.1663 T0.7687,0.1534 T0.7543,0.141 T0.744,0.1322 Q0.7186,0.1106,0.6984,0.101 T0.6559,0.0926 T0.6082,0.1077 Q0.5899,0.1175,0.5733,0.1206 T0.5411,0.1202 T0.5122,0.1098 T0.4822,0.0914 Q0.4927,0.1032,0.5036,0.1122 T0.5276,0.1285 T0.5503,0.1401 T0.5777,0.1518 T0.6055,0.1636 Q0.6258,0.1726,0.6375,0.1863 T0.6519,0.2162 Q0.6556,0.2403,0.6392,0.2605 T0.5926,0.2876 Q0.5804,0.2909,0.5672,0.2899 T0.5428,0.2856 T0.5193,0.2764 T0.4966,0.264 T0.4744,0.2497 T0.4523,0.2352 T0.4301,0.2222 T0.4077,0.2118 Q0.3021,0.173,0.1903,0.2436 Q0.1669,0.2583,0.1504,0.2674 T0.1129,0.2846 T0.075,0.294 T0.0384,0.2911 T0,0.2746 Q0.021,0.297,0.0459,0.3082 T0.0953,0.3207 T0.146,0.3193 T0.1988,0.3131 T0.2508,0.3095 T0.3029,0.3176 T0.3529,0.3448 Q0.3566,0.348,0.3652,0.355 T0.3771,0.3645 T0.3877,0.3731 T0.3993,0.3815 T0.4103,0.3884 T0.4226,0.3953 T0.4352,0.4009 T0.4497,0.4064 L0.4443,0.4121 Q0.4372,0.4198,0.4277,0.4251 T0.4072,0.4337 T0.3867,0.439 T0.3656,0.4431 T0.3481,0.4468 Q0.3241,0.4529,0.2943,0.4463 Q0.3227,0.4623,0.3458,0.471 T0.3959,0.4814 Q0.404,0.4818,0.4187,0.4825 T0.4409,0.4835 T0.4605,0.4857 T0.4809,0.4908 T0.4992,0.4996 T0.5186,0.5141 T0.5371,0.5353 L0.5449,0.5451 L0.5337,0.543 Q0.5242,0.541,0.5091,0.55 T0.4683,0.5796 T0.4314,0.6083 Q0.4203,0.6161,0.4086,0.6212 T0.382,0.6308 T0.3667,0.6353 Q0.3485,0.6418,0.2995,0.633 T0.1934,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.989,0.0469 Q0.9829,0.0379,0.9753,0.0316 T0.9635,0.0253 Q0.9574,0.0257,0.9539,0.0263 T0.9466,0.03 T0.9418,0.0345 T0.9355,0.0434 T0.9277,0.0546 Q0.9193,0.0653,0.9103,0.0712 T0.8919,0.0775 T0.8745,0.0765 T0.8564,0.0695 T0.8396,0.0593 T0.8228,0.0473 Q0.7612,0,0.7073,0.0326 L0.7386,0.0767 L0.7419,0.0767 Q0.7506,0.0767,0.7556,0.0773 T0.7641,0.0789 T0.7709,0.0842 T0.7767,0.0922 T0.7854,0.1054 T0.7974,0.1236 Q0.8057,0.1354,0.8157,0.1444 T0.8325,0.1574 T0.8474,0.1654 T0.8571,0.1701 Q0.8564,0.1717,0.8554,0.1733 Q0.8503,0.1815,0.844,0.186 T0.8301,0.1909 T0.8153,0.1903 T0.7993,0.1845 T0.7836,0.1758 T0.768,0.1648 T0.754,0.1535 T0.741,0.1425 T0.7312,0.1338 Q0.7031,0.1101,0.6805,0.0995 T0.6357,0.0901 T0.5886,0.1048 Q0.5721,0.1138,0.5574,0.1168 T0.5295,0.117 T0.5055,0.1089 T0.4814,0.0942 L0.4789,0.0926 L0.4711,0.0922 Q0.4589,0.095,0.4811,0.1203 Q0.495,0.1358,0.5087,0.1474 T0.5366,0.167 T0.5611,0.1796 T0.5879,0.1909 T0.6134,0.2011 Q0.6218,0.2047,0.6273,0.2092 Q0.6283,0.2117,0.6286,0.2141 Q0.6305,0.2263,0.6249,0.2388 T0.606,0.2616 T0.5747,0.2761 Q0.5602,0.2785,0.5487,0.2779 T0.5245,0.2724 T0.5015,0.2616 T0.4784,0.2476 T0.4547,0.2321 T0.4297,0.217 T0.4024,0.2043 Q0.2985,0.166,0.1901,0.2345 Q0.1694,0.248,0.1523,0.2569 T0.1165,0.2726 T0.0818,0.2812 T0.0494,0.2796 T0.0181,0.2663 L0.0116,0.2671 Q0,0.272,0.0232,0.2969 Q0.0468,0.3222,0.0742,0.3365 T0.1278,0.3542 T0.1807,0.3564 T0.233,0.352 T0.2815,0.3473 T0.3269,0.3509 T0.3656,0.3699 Q0.4037,0.4005,0.4153,0.4082 Q0.405,0.4139,0.3921,0.4174 T0.3633,0.4237 T0.3414,0.4278 Q0.3207,0.4331,0.2956,0.4278 Q0.2943,0.4278,0.293,0.4274 Q0.2933,0.429,0.2938,0.4313 T0.2964,0.4398 T0.3007,0.4513 T0.3069,0.4619 T0.3149,0.4698 Q0.3427,0.4857,0.3664,0.4947 T0.4169,0.5053 Q0.423,0.5057,0.4385,0.5065 T0.4606,0.508 T0.4779,0.51 T0.4958,0.5139 T0.5095,0.5204 Q0.4992,0.5232,0.485,0.5328 T0.451,0.5585 T0.4201,0.5824 Q0.4095,0.5897,0.3987,0.5946 T0.3738,0.6036 T0.3591,0.6081 Q0.3433,0.6134,0.2965,0.605 T0.1972,0.5816 L0.2026,0.5922 T0.2133,0.6134 L0.2188,0.624 Q0.2201,0.6248,0.2214,0.6252 Q0.2291,0.6297,0.2486,0.6405 T0.2786,0.657 T0.3066,0.6721 T0.3353,0.6866 T0.3598,0.6972 T0.383,0.7051 T0.4005,0.7076 Q0.4008,0.7076,0.4169,0.7092 T0.4471,0.7092 T0.475,0.7019 Q0.4895,0.6958,0.5176,0.6811 T0.5644,0.6586 T0.5921,0.6533 Q0.6128,0.6741,0.6173,0.6782 Q0.6131,0.6835,0.6068,0.6929 T0.5963,0.7078 T0.5858,0.7198 T0.5716,0.7304 T0.5534,0.7365 Q0.5179,0.7443,0.4708,0.728 L0.4708,0.7294 T0.471,0.7333 T0.4716,0.7392 T0.4734,0.7463 T0.4764,0.7539 T0.4814,0.7612 T0.4889,0.7679 Q0.4914,0.77,0.4944,0.7716 Q0.5534,0.8104,0.6409,0.8091 Q0.6521,0.8091,0.6654,0.8053 T0.6907,0.7959 T0.7157,0.7838 T0.741,0.772 T0.7652,0.7631 T0.7888,0.7594 T0.8106,0.7643 Q0.8196,0.7684,0.8267,0.7753 Q0.8409,0.7892,0.8399,0.8169 Q0.8216,0.8067,0.8062,0.8053 T0.7788,0.8087 T0.7493,0.825 Q0.7386,0.8324,0.7256,0.8365 T0.6947,0.844 T0.668,0.8499 L0.697,0.894 L0.7002,0.8948 Q0.7099,0.8968,0.7222,0.9009 T0.7446,0.9086 T0.767,0.9158 T0.7901,0.9213 T0.8132,0.9229 T0.8367,0.9192 Q0.8483,0.916,0.8633,0.9241 T0.8937,0.9462 T0.9248,0.9737 T0.959,0.9955 T0.9939,1 Q1,0.9984,0.9932,0.9845 Q0.991,0.9804,0.9877,0.9755 Q0.9813,0.9666,0.9739,0.9606 T0.9626,0.9555 Q0.9519,0.958,0.9372,0.949 T0.9071,0.9262 T0.8753,0.8987 T0.8403,0.8777 T0.8051,0.8752 Q0.787,0.8805,0.7657,0.8772 Q0.7751,0.8736,0.7828,0.8683 Q0.8086,0.8511,0.8262,0.8497 T0.8651,0.8617 Q0.8696,0.865,0.8727,0.8646 T0.8758,0.8605 L0.8761,0.8536 Q0.8774,0.8295,0.8646,0.8016 T0.8277,0.7496 Q0.8086,0.7308,0.7896,0.7219 Q0.7741,0.7145,0.7575,0.7141 T0.727,0.7182 T0.6978,0.7296 T0.6699,0.7439 T0.6433,0.7571 T0.6179,0.7643 Q0.627,0.7561,0.6402,0.7367 T0.6618,0.7088 L0.6673,0.7035 Q0.6718,0.699,0.6647,0.6884 T0.6483,0.6692 L0.6389,0.6607 Q0.6289,0.657,0.6249,0.6554 T0.6163,0.6507 T0.6102,0.6458 T0.6021,0.637 T0.5889,0.6236 Q0.5828,0.6175,0.5766,0.6138 Q0.5673,0.6081,0.5561,0.6077 T0.5345,0.6105 T0.5116,0.6201 T0.4887,0.633 T0.4653,0.6468 T0.4427,0.6578 Q0.4295,0.6635,0.4167,0.665 T0.3888,0.665 T0.3714,0.6635 Q0.3579,0.6631,0.3282,0.6501 Q0.374,0.6578,0.3911,0.6517 Q0.3937,0.6509,0.4024,0.6482 T0.4179,0.6434 T0.4348,0.6364 T0.4534,0.6256 Q0.464,0.6183,0.4892,0.5989 T0.5278,0.5712 T0.5476,0.564 L0.5582,0.5661 Q0.5692,0.5681,0.5634,0.5563 Q0.5599,0.5485,0.5524,0.5392 L0.545,0.5298 Q0.5369,0.5188,0.5286,0.51 T0.5134,0.4947 T0.4979,0.4831 T0.484,0.4749 T0.47,0.4694 T0.4572,0.4657 T0.4442,0.4637 T0.4326,0.4629 T0.4205,0.4625 Q0.4511,0.4543,0.466,0.4384 L0.4714,0.4327 Q0.4795,0.4237,0.4469,0.394 L0.4421,0.3899 Q0.433,0.387,0.4251,0.3834 T0.4122,0.3772 T0.3988,0.3687 T0.3874,0.3603 T0.3732,0.3487 T0.3579,0.3361 Q0.3433,0.3242,0.3288,0.3159 T0.2993,0.3034 T0.2725,0.2973 T0.2446,0.2961 T0.2193,0.2977 T0.1926,0.301 Q0.1855,0.3022,0.182,0.3026 Q0.1991,0.2936,0.2233,0.2781 Q0.3282,0.2117,0.4256,0.2476 Q0.4363,0.2516,0.451,0.2604 T0.4784,0.2779 T0.5077,0.2965 T0.539,0.3124 T0.5718,0.3216 T0.606,0.3206 Q0.6363,0.3136,0.6526,0.2936 T0.6647,0.2459 Q0.6615,0.2247,0.645,0.2023 Q0.6354,0.1892,0.6237,0.179 Q0.6102,0.1672,0.5937,0.1595 Q0.6073,0.1562,0.6215,0.1485 Q0.6396,0.1387,0.6547,0.1354 T0.6839,0.1354 T0.7101,0.1458 T0.7373,0.166 Q0.738,0.1664,0.746,0.1733 T0.7586,0.1841 T0.7733,0.196 T0.7907,0.2086 T0.8086,0.2196 T0.8275,0.2288 T0.8454,0.2337 T0.8627,0.2343 T0.8777,0.228 T0.8903,0.2145 Q0.9038,0.1929,0.8742,0.1582 Q0.869,0.1517,0.8629,0.1464 Q0.8538,0.1387,0.844,0.1321 T0.8248,0.1205 T0.8122,0.1134 Q0.8109,0.1117,0.8053,0.103 T0.7965,0.0899 T0.7875,0.0781 T0.7757,0.064 Q0.8051,0.0616,0.8328,0.0828 Q0.847,0.0934,0.8588,0.1009 T0.8854,0.1146 T0.9127,0.1213 T0.9384,0.116 T0.9626,0.0962 Q0.9664,0.0909,0.9706,0.0846 T0.976,0.0767 T0.9798,0.0728 T0.9852,0.0704 T0.9932,0.0697 Q0.9997,0.0693,0.9942,0.0567 Q0.9923,0.0522,0.989,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0.9099,0.1158 L0.9099,0.1888 L0.9951,0.1888 L0.9951,0.1158 L0.9099,0.1158 Z M0.9075,0.1116 L0.9976,0.1116 Q1,0.1116,1,0.1137 L1,0.1909 Q1,0.193,0.9976,0.193 L0.9075,0.193 Q0.905,0.193,0.905,0.1909 L0.905,0.1137 Q0.905,0.1116,0.9075,0.1116 Z M0.7852,0.6086 L0.7852,0.682 L0.8704,0.682 L0.8704,0.6086 L0.7852,0.6086 Z M0.7828,0.6044 L0.8729,0.6044 Q0.8753,0.6044,0.8753,0.6065 L0.8753,0.6841 Q0.8753,0.6862,0.8729,0.6862 L0.7828,0.6862 Q0.7803,0.6862,0.7803,0.6841 L0.7803,0.6065 Q0.7803,0.6044,0.7828,0.6044 Z M0.66,0.1137 L0.7501,0.1137 L0.7501,0.1909 L0.66,0.1909 L0.66,0.1137 Z M0.6624,0.4102 L0.6624,0.4836 L0.7477,0.4836 L0.7477,0.4102 L0.6624,0.4102 Z M0.66,0.406 L0.7501,0.406 Q0.7526,0.406,0.7526,0.4081 L0.7526,0.4857 Q0.7526,0.4878,0.7501,0.4878 L0.66,0.4878 Q0.6576,0.4878,0.6576,0.4857 L0.6576,0.4081 Q0.6576,0.406,0.66,0.406 Z M0.6624,0.7131 L0.6624,0.7865 L0.7477,0.7865 L0.7477,0.7131 L0.6624,0.7131 Z M0.66,0.7089 L0.7501,0.7089 Q0.7526,0.7089,0.7526,0.711 L0.7526,0.7886 Q0.7526,0.7907,0.7501,0.7907 L0.66,0.7907 Q0.6576,0.7907,0.6576,0.7886 L0.6576,0.711 Q0.6576,0.7089,0.66,0.7089 Z M0.5407,0.2227 L0.5407,0.2836 L0.6113,0.2836 L0.6113,0.2227 L0.5407,0.2227 Z M0.5309,0.206 L0.621,0.206 Q0.623,0.206,0.6249,0.2068 T0.6281,0.2089 T0.6301,0.2116 T0.6308,0.2143 L0.6308,0.2919 Q0.6308,0.2957,0.6276,0.298 T0.621,0.3003 L0.5309,0.3003 Q0.5265,0.3003,0.5239,0.2976 T0.5212,0.2919 L0.5212,0.2143 Q0.5212,0.211,0.5244,0.2085 T0.5309,0.206 Z M0.5407,0.3184 L0.5407,0.3792 L0.6113,0.3792 L0.6113,0.3184 L0.5407,0.3184 Z M0.5309,0.3016 L0.621,0.3016 Q0.6254,0.3016,0.6281,0.3043 T0.6308,0.31 L0.6308,0.3876 Q0.6308,0.3914,0.6276,0.3937 T0.621,0.396 L0.5309,0.396 Q0.5265,0.396,0.5239,0.3932 T0.5212,0.3876 L0.5212,0.31 Q0.5212,0.3062,0.5244,0.3039 T0.5309,0.3016 Z M0.5309,0.4081 L0.621,0.4081 L0.621,0.4857 L0.5309,0.4857 L0.5309,0.4081 Z M0.5309,0.5059 L0.621,0.5059 L0.621,0.5835 L0.5309,0.5835 L0.5309,0.5059 Z M0.5407,0.6149 L0.5407,0.6758 L0.6113,0.6758 L0.6113,0.6149 L0.5407,0.6149 Z M0.5309,0.5982 L0.621,0.5982 Q0.6254,0.5982,0.6281,0.6009 T0.6308,0.6065 L0.6308,0.6841 Q0.6308,0.6879,0.6276,0.6902 T0.621,0.6925 L0.5309,0.6925 Q0.5265,0.6925,0.5239,0.6898 T0.5212,0.6841 L0.5212,0.6065 Q0.5212,0.6028,0.5244,0.6005 T0.5309,0.5982 Z M0.4062,0.1137 L0.4963,0.1137 L0.4963,0.1909 L0.4062,0.1909 L0.4062,0.1137 Z M0.4062,0.2143 L0.4963,0.2143 L0.4963,0.2919 L0.4062,0.2919 L0.4062,0.2143 Z M0.4184,0.4186 L0.4184,0.4753 L0.4842,0.4753 L0.4842,0.4186 L0.4184,0.4186 Z M0.4062,0.3977 L0.4963,0.3977 Q0.5017,0.3977,0.5051,0.401 T0.5085,0.4081 L0.5085,0.4857 Q0.5085,0.4904,0.5046,0.4933 T0.4963,0.4962 L0.4062,0.4962 Q0.4009,0.4962,0.3975,0.4929 T0.3941,0.4857 L0.3941,0.4081 Q0.3941,0.4035,0.398,0.4006 T0.4062,0.3977 Z M0.4062,0.5059 L0.4963,0.5059 L0.4963,0.5835 L0.4062,0.5835 L0.4062,0.5059 Z M0.4087,0.7131 L0.4087,0.7865 L0.4939,0.7865 L0.4939,0.7131 L0.4087,0.7131 Z M0.4062,0.7089 L0.4963,0.7089 Q0.4988,0.7089,0.4988,0.711 L0.4988,0.7886 Q0.4988,0.7907,0.4963,0.7907 L0.4062,0.7907 Q0.4038,0.7907,0.4038,0.7886 L0.4038,0.711 Q0.4038,0.7089,0.4062,0.7089 Z M0.2689,0.1137 L0.359,0.1137 L0.359,0.1909 L0.2689,0.1909 L0.2689,0.1137 Z M0.2689,0.2143 L0.359,0.2143 L0.359,0.2919 L0.2689,0.2919 L0.2689,0.2143 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.31 L0.359,0.31 L0.359,0.3876 L0.2689,0.3876 L0.2689,0.31 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.4081 L0.359,0.4081 L0.359,0.4857 L0.2689,0.4857 L0.2689,0.4081 Z M0.2689,0.5059 L0.359,0.5059 L0.359,0.5835 L0.2689,0.5835 L0.2689,0.5059 Z M0.2689,0.711 L0.359,0.711 L0.359,0.7886 L0.2689,0.7886 L0.2689,0.711 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.1374,0.1137 L0.2275,0.1137 L0.2275,0.1909 L0.1374,0.1909 L0.1374,0.1137 Z M0.1374,0.2143 L0.2275,0.2143 L0.2275,0.2919 L0.1374,0.2919 L0.1374,0.2143 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.31 L0.2275,0.31 L0.2275,0.3876 L0.1374,0.3876 L0.1374,0.31 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.4081 L0.2275,0.4081 L0.2275,0.4857 L0.1374,0.4857 L0.1374,0.4081 Z M0.1374,0.5059 L0.2275,0.5059 L0.2275,0.5835 L0.1374,0.5835 L0.1374,0.5059 Z M0.1374,0.6065 L0.2275,0.6065 L0.2275,0.6841 L0.1374,0.6841 L0.1374,0.6065 Z M0.1374,0.711 L0.2275,0.711 L0.2275,0.7886 L0.1374,0.7886 L0.1374,0.711 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0,0.1137 L0.0901,0.1137 L0.0901,0.1909 L0,0.1909 L0,0.1137 Z M0,0.2143 L0.0901,0.2143 L0.0901,0.2919 L0,0.2919 L0,0.2143 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.31 L0.0901,0.31 L0.0901,0.3876 L0,0.3876 L0,0.31 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.4081 L0.0901,0.4081 L0.0901,0.4857 L0,0.4857 L0,0.4081 Z M0,0.5059 L0.0901,0.5059 L0.0901,0.5835 L0,0.5835 L0,0.5059 Z M0,0.6065 L0.0901,0.6065 L0.0901,0.6841 L0,0.6841 L0,0.6065 Z M0,0.711 L0.0901,0.711 L0.0901,0.7886 L0,0.7886 L0,0.711 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M0.0901,0.1158 L0.0901,0.1888 L0.0049,0.1888 L0.0049,0.1158 L0.0901,0.1158 Z M0.0925,0.1116 L0.0024,0.1116 Q0,0.1116,0,0.1137 L0,0.1909 Q0,0.193,0.0024,0.193 L0.0925,0.193 Q0.095,0.193,0.095,0.1909 L0.095,0.1137 Q0.095,0.1116,0.0925,0.1116 Z M0.2148,0.6086 L0.2148,0.682 L0.1296,0.682 L0.1296,0.6086 L0.2148,0.6086 Z M0.2172,0.6044 L0.1271,0.6044 Q0.1247,0.6044,0.1247,0.6065 L0.1247,0.6841 Q0.1247,0.6862,0.1271,0.6862 L0.2172,0.6862 Q0.2197,0.6862,0.2197,0.6841 L0.2197,0.6065 Q0.2197,0.6044,0.2172,0.6044 Z M0.34,0.1137 L0.2499,0.1137 L0.2499,0.1909 L0.34,0.1909 L0.34,0.1137 Z M0.3376,0.4102 L0.3376,0.4836 L0.2523,0.4836 L0.2523,0.4102 L0.3376,0.4102 Z M0.34,0.406 L0.2499,0.406 Q0.2474,0.406,0.2474,0.4081 L0.2474,0.4857 Q0.2474,0.4878,0.2499,0.4878 L0.34,0.4878 Q0.3424,0.4878,0.3424,0.4857 L0.3424,0.4081 Q0.3424,0.406,0.34,0.406 Z M0.3376,0.7131 L0.3376,0.7865 L0.2523,0.7865 L0.2523,0.7131 L0.3376,0.7131 Z M0.34,0.7089 L0.2499,0.7089 Q0.2474,0.7089,0.2474,0.711 L0.2474,0.7886 Q0.2474,0.7907,0.2499,0.7907 L0.34,0.7907 Q0.3424,0.7907,0.3424,0.7886 L0.3424,0.711 Q0.3424,0.7089,0.34,0.7089 Z M0.4593,0.2227 L0.4593,0.2836 L0.3887,0.2836 L0.3887,0.2227 L0.4593,0.2227 Z M0.4691,0.206 L0.379,0.206 Q0.3746,0.206,0.3719,0.2087 T0.3692,0.2143 L0.3692,0.2919 Q0.3692,0.2957,0.3724,0.298 T0.379,0.3003 L0.4691,0.3003 Q0.4735,0.3003,0.4761,0.2976 T0.4788,0.2919 L0.4788,0.2143 Q0.4788,0.211,0.4756,0.2085 T0.4691,0.206 Z M0.4593,0.3184 L0.4593,0.3792 L0.3887,0.3792 L0.3887,0.3184 L0.4593,0.3184 Z M0.4691,0.3016 L0.379,0.3016 Q0.3746,0.3016,0.3719,0.3043 T0.3692,0.31 L0.3692,0.3876 Q0.3692,0.3914,0.3724,0.3937 T0.379,0.396 L0.4691,0.396 Q0.4735,0.396,0.4761,0.3932 T0.4788,0.3876 L0.4788,0.31 Q0.4788,0.3062,0.4756,0.3039 T0.4691,0.3016 Z M0.4691,0.4081 L0.379,0.4081 L0.379,0.4857 L0.4691,0.4857 L0.4691,0.4081 Z M0.4691,0.5059 L0.379,0.5059 L0.379,0.5835 L0.4691,0.5835 L0.4691,0.5059 Z M0.4593,0.6149 L0.4593,0.6758 L0.3887,0.6758 L0.3887,0.6149 L0.4593,0.6149 Z M0.4691,0.5982 L0.379,0.5982 Q0.3746,0.5982,0.3719,0.6009 T0.3692,0.6065 L0.3692,0.6841 Q0.3692,0.6879,0.3724,0.6902 T0.379,0.6925 L0.4691,0.6925 Q0.4735,0.6925,0.4761,0.6898 T0.4788,0.6841 L0.4788,0.6065 Q0.4788,0.6028,0.4756,0.6005 T0.4691,0.5982 Z M0.5938,0.1137 L0.5037,0.1137 L0.5037,0.1909 L0.5938,0.1909 L0.5938,0.1137 Z M0.5938,0.2143 L0.5037,0.2143 L0.5037,0.2919 L0.5938,0.2919 L0.5938,0.2143 Z M0.5816,0.4186 L0.5816,0.4753 L0.5158,0.4753 L0.5158,0.4186 L0.5816,0.4186 Z M0.5938,0.3977 L0.5037,0.3977 Q0.4983,0.3977,0.4949,0.401 T0.4915,0.4081 L0.4915,0.4857 Q0.4915,0.4904,0.4954,0.4933 T0.5037,0.4962 L0.5938,0.4962 Q0.5991,0.4962,0.6025,0.4929 T0.6059,0.4857 L0.6059,0.4081 Q0.6059,0.4035,0.602,0.4006 T0.5938,0.3977 Z M0.5938,0.5059 L0.5037,0.5059 L0.5037,0.5835 L0.5938,0.5835 L0.5938,0.5059 Z M0.5913,0.7131 L0.5913,0.7865 L0.5061,0.7865 L0.5061,0.7131 L0.5913,0.7131 Z M0.5938,0.7089 L0.5037,0.7089 Q0.5012,0.7089,0.5012,0.711 L0.5012,0.7886 Q0.5012,0.7907,0.5037,0.7907 L0.5938,0.7907 Q0.5962,0.7907,0.5962,0.7886 L0.5962,0.711 Q0.5962,0.7089,0.5938,0.7089 Z M0.7311,0.1137 L0.641,0.1137 L0.641,0.1909 L0.7311,0.1909 L0.7311,0.1137 Z M0.7311,0.2143 L0.641,0.2143 L0.641,0.2919 L0.7311,0.2919 L0.7311,0.2143 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.31 L0.641,0.31 L0.641,0.3876 L0.7311,0.3876 L0.7311,0.31 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.4081 L0.641,0.4081 L0.641,0.4857 L0.7311,0.4857 L0.7311,0.4081 Z M0.7311,0.5059 L0.641,0.5059 L0.641,0.5835 L0.7311,0.5835 L0.7311,0.5059 Z M0.7311,0.711 L0.641,0.711 L0.641,0.7886 L0.7311,0.7886 L0.7311,0.711 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.8626,0.1137 L0.7725,0.1137 L0.7725,0.1909 L0.8626,0.1909 L0.8626,0.1137 Z M0.8626,0.2143 L0.7725,0.2143 L0.7725,0.2919 L0.8626,0.2919 L0.8626,0.2143 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.31 L0.7725,0.31 L0.7725,0.3876 L0.8626,0.3876 L0.8626,0.31 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.4081 L0.7725,0.4081 L0.7725,0.4857 L0.8626,0.4857 L0.8626,0.4081 Z M0.8626,0.5059 L0.7725,0.5059 L0.7725,0.5835 L0.8626,0.5835 L0.8626,0.5059 Z M0.8626,0.6065 L0.7725,0.6065 L0.7725,0.6841 L0.8626,0.6841 L0.8626,0.6065 Z M0.8626,0.711 L0.7725,0.711 L0.7725,0.7886 L0.8626,0.7886 L0.8626,0.711 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M1,0.1137 L0.9099,0.1137 L0.9099,0.1909 L1,0.1909 L1,0.1137 Z M1,0.2143 L0.9099,0.2143 L0.9099,0.2919 L1,0.2919 L1,0.2143 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.31 L0.9099,0.31 L0.9099,0.3876 L1,0.3876 L1,0.31 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.4081 L0.9099,0.4081 L0.9099,0.4857 L1,0.4857 L1,0.4081 Z M1,0.5059 L0.9099,0.5059 L0.9099,0.5835 L1,0.5835 L1,0.5059 Z M1,0.6065 L0.9099,0.6065 L0.9099,0.6841 L1,0.6841 L1,0.6065 Z M1,0.711 L0.9099,0.711 L0.9099,0.7886 L1,0.7886 L1,0.711 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0.8574,0.3217 L0.8574,0.4098 L0.9691,0.4098 L0.9691,0.3217 L0.8574,0.3217 Z M0.8419,0.2978 L0.9846,0.2978 Q0.9892,0.2978,0.9928,0.2997 T0.9982,0.3043 T1,0.31 L1,0.4216 Q1,0.427,0.9951,0.4304 T0.9846,0.4337 L0.8419,0.4337 Q0.8352,0.4337,0.8308,0.4299 T0.8265,0.4216 L0.8265,0.31 Q0.8265,0.3062,0.829,0.3035 T0.835,0.2993 T0.8419,0.2978 Z M0.8574,0.888 L0.8574,0.9757 L0.9691,0.9757 L0.9691,0.888 L0.8574,0.888 Z M0.8419,0.8637 L0.9846,0.8637 Q0.9892,0.8637,0.9928,0.8658 T0.9982,0.8706 T1,0.8758 L1,0.9878 Q1,0.9929,0.9951,0.9964 T0.9846,1 L0.8419,1 Q0.8352,1,0.8308,0.996 T0.8265,0.9878 L0.8265,0.8758 Q0.8265,0.8708,0.8314,0.8672 T0.8419,0.8637 Z M0.6509,0.169 L0.6509,0.2706 L0.7806,0.2706 L0.7806,0.169 L0.6509,0.169 Z M0.6442,0.159 L0.7868,0.159 Q0.7899,0.159,0.7917,0.1604 T0.7935,0.164 L0.7935,0.2756 Q0.7935,0.2781,0.7915,0.2796 T0.7868,0.281 L0.6442,0.281 Q0.6416,0.281,0.6395,0.2794 T0.6375,0.2756 L0.6375,0.164 Q0.6375,0.1619,0.6398,0.1604 T0.6442,0.159 Z M0.6632,0.6044 L0.6632,0.6858 L0.7678,0.6858 L0.7678,0.6044 L0.6632,0.6044 Z M0.6442,0.5742 L0.7868,0.5742 Q0.7951,0.5742,0.8007,0.5791 T0.8064,0.5893 L0.8064,0.7013 Q0.8064,0.7076,0.8002,0.712 T0.7868,0.7164 L0.6442,0.7164 Q0.6359,0.7164,0.6305,0.7114 T0.6251,0.7013 L0.6251,0.5893 Q0.6251,0.5847,0.6282,0.5812 T0.6357,0.5759 T0.6442,0.5742 Z M0.4264,0.164 L0.5695,0.164 L0.5695,0.2756 L0.4264,0.2756 L0.4264,0.164 Z M0.4325,0.315 L0.4325,0.4165 L0.5628,0.4165 L0.5628,0.315 L0.4325,0.315 Z M0.4264,0.3049 L0.5695,0.3049 Q0.5721,0.3049,0.5739,0.3064 T0.5757,0.31 L0.5757,0.4216 Q0.5757,0.4237,0.5736,0.4251 T0.5695,0.4266 L0.4264,0.4266 Q0.4238,0.4266,0.422,0.4251 T0.4202,0.4216 L0.4202,0.31 Q0.4202,0.3087,0.4207,0.3077 T0.4222,0.306 T0.4243,0.3052 T0.4264,0.3049 Z M0.4264,0.4476 L0.5695,0.4476 L0.5695,0.5596 L0.4264,0.5596 L0.4264,0.4476 Z M0.4392,0.7408 L0.4392,0.8326 L0.5561,0.8326 L0.5561,0.7408 L0.4392,0.7408 Z M0.4264,0.7206 L0.5695,0.7206 Q0.5747,0.7206,0.5783,0.724 T0.5819,0.7307 L0.5819,0.8427 Q0.5819,0.8469,0.5778,0.8498 T0.5695,0.8528 L0.4264,0.8528 Q0.4207,0.8528,0.4171,0.8496 T0.4135,0.8427 L0.4135,0.7307 Q0.4135,0.7265,0.4176,0.7236 T0.4264,0.7206 Z M0.2178,0.164 L0.3605,0.164 L0.3605,0.2756 L0.2178,0.2756 L0.2178,0.164 Z M0.2178,0.31 L0.3605,0.31 L0.3605,0.4216 L0.2178,0.4216 L0.2178,0.31 Z M0.2178,0.5893 L0.3605,0.5893 L0.3605,0.7013 L0.2178,0.7013 L0.2178,0.5893 Z M0.2178,0.7307 L0.3605,0.7307 L0.3605,0.8427 L0.2178,0.8427 L0.2178,0.7307 Z M0.2178,0.8758 L0.3605,0.8758 L0.3605,0.9878 L0.2178,0.9878 L0.2178,0.8758 Z M0,0.164 L0.1432,0.164 L0.1432,0.2756 L0,0.2756 L0,0.164 Z M0,0.31 L0.1432,0.31 L0.1432,0.4216 L0,0.4216 L0,0.31 Z M0,0.4476 L0.1432,0.4476 L0.1432,0.5596 L0,0.5596 L0,0.4476 Z M0,0.5893 L0.1432,0.5893 L0.1432,0.7013 L0,0.7013 L0,0.5893 Z M0,0.7307 L0.1432,0.7307 L0.1432,0.8427 L0,0.8427 L0,0.7307 Z M0,0.8758 L0.1432,0.8758 L0.1432,0.9878 L0,0.9878 L0,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M0.1432,0.3217 L0.1432,0.4098 L0.0309,0.4098 L0.0309,0.3217 L0.1432,0.3217 Z M0.1586,0.2978 L0.0154,0.2978 Q0.0088,0.2978,0.0044,0.3016 T0,0.31 L0,0.4216 Q0,0.427,0.0049,0.4304 T0.0154,0.4337 L0.1586,0.4337 Q0.1648,0.4337,0.1694,0.4299 T0.174,0.4216 L0.174,0.31 Q0.174,0.3062,0.1715,0.3035 T0.1653,0.2993 T0.1586,0.2978 Z M0.1432,0.888 L0.1432,0.9757 L0.0309,0.9757 L0.0309,0.888 L0.1432,0.888 Z M0.1586,0.8637 L0.0154,0.8637 Q0.0108,0.8637,0.0072,0.8658 T0.0018,0.8706 T0,0.8758 L0,0.9878 Q0,0.9929,0.0049,0.9964 T0.0154,1 L0.1586,1 Q0.1648,1,0.1694,0.996 T0.174,0.9878 L0.174,0.8758 Q0.174,0.8725,0.1715,0.8695 T0.1653,0.8651 T0.1586,0.8637 Z M0.3496,0.169 L0.3496,0.2706 L0.2194,0.2706 L0.2194,0.169 L0.3496,0.169 Z M0.3563,0.159 L0.2132,0.159 Q0.2106,0.159,0.2088,0.1604 T0.207,0.164 L0.207,0.2756 Q0.207,0.2781,0.2091,0.2796 T0.2132,0.281 L0.3563,0.281 Q0.3589,0.281,0.3607,0.2794 T0.3625,0.2756 L0.3625,0.164 Q0.3625,0.1619,0.3605,0.1604 T0.3563,0.159 Z M0.3368,0.6044 L0.3368,0.6858 L0.2327,0.6858 L0.2327,0.6044 L0.3368,0.6044 Z M0.3563,0.5742 L0.2132,0.5742 Q0.2049,0.5742,0.1993,0.5791 T0.1936,0.5893 L0.1936,0.7013 Q0.1936,0.7076,0.2001,0.712 T0.2132,0.7164 L0.3563,0.7164 Q0.3641,0.7164,0.3697,0.7114 T0.3754,0.7013 L0.3754,0.5893 Q0.3754,0.5847,0.3723,0.5812 T0.3648,0.5759 T0.3563,0.5742 Z M0.5736,0.164 L0.431,0.164 L0.431,0.2756 L0.5736,0.2756 L0.5736,0.164 Z M0.5675,0.315 L0.5675,0.4165 L0.4377,0.4165 L0.4377,0.315 L0.5675,0.315 Z M0.5736,0.3049 L0.431,0.3049 Q0.4284,0.3049,0.4264,0.3064 T0.4243,0.31 L0.4243,0.4216 Q0.4243,0.4237,0.4266,0.4251 T0.431,0.4266 L0.5736,0.4266 Q0.5767,0.4266,0.5785,0.4251 T0.5803,0.4216 L0.5803,0.31 Q0.5803,0.3087,0.5798,0.3077 T0.5783,0.306 T0.5762,0.3052 T0.5736,0.3049 Z M0.5736,0.4476 L0.431,0.4476 L0.431,0.5596 L0.5736,0.5596 L0.5736,0.4476 Z M0.5613,0.7408 L0.5613,0.8326 L0.4439,0.8326 L0.4439,0.7408 L0.5613,0.7408 Z M0.5736,0.7206 L0.431,0.7206 Q0.4253,0.7206,0.4217,0.724 T0.4181,0.7307 L0.4181,0.8427 Q0.4181,0.8469,0.4222,0.8498 T0.431,0.8528 L0.5736,0.8528 Q0.5778,0.8528,0.5808,0.8511 T0.5855,0.8471 T0.587,0.8427 L0.587,0.7307 Q0.587,0.7265,0.5826,0.7236 T0.5736,0.7206 Z M0.7827,0.164 L0.6395,0.164 L0.6395,0.2756 L0.7827,0.2756 L0.7827,0.164 Z M0.7827,0.31 L0.6395,0.31 L0.6395,0.4216 L0.7827,0.4216 L0.7827,0.31 Z M0.7827,0.5893 L0.6395,0.5893 L0.6395,0.7013 L0.7827,0.7013 L0.7827,0.5893 Z M0.7827,0.7307 L0.6395,0.7307 L0.6395,0.8427 L0.7827,0.8427 L0.7827,0.7307 Z M0.7827,0.8758 L0.6395,0.8758 L0.6395,0.9878 L0.7827,0.9878 L0.7827,0.8758 Z M1,0.164 L0.8574,0.164 L0.8574,0.2756 L1,0.2756 L1,0.164 Z M1,0.31 L0.8574,0.31 L0.8574,0.4216 L1,0.4216 L1,0.31 Z M1,0.4476 L0.8574,0.4476 L0.8574,0.5596 L1,0.5596 L1,0.4476 Z M1,0.5893 L0.8574,0.5893 L0.8574,0.7013 L1,0.7013 L1,0.5893 Z M1,0.7307 L0.8574,0.7307 L0.8574,0.8427 L1,0.8427 L1,0.7307 Z M1,0.8758 L0.8574,0.8758 L0.8574,0.9878 L1,0.9878 L1,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.0008,0.9979 Q0.0008,1,0.0032,1 Q0.0482,1,0.0602,0.9975 Q0.0667,0.9963,0.0847,0.9917 T0.1084,0.9859 Q0.1124,0.9851,0.1221,0.9851 L0.1253,0.9851 L0.1285,0.9851 Q0.1518,0.9851,0.1655,0.9809 Q0.1695,0.9801,0.1731,0.9788 T0.1791,0.9766 T0.1839,0.9747 T0.1888,0.9732 L0.1936,0.972 T0.1988,0.9712 T0.2048,0.971 L0.2096,0.971 Q0.2201,0.9714,0.2233,0.9714 T0.2345,0.9693 Q0.2386,0.9685,0.2502,0.9674 T0.2715,0.966 L0.2811,0.9656 Q0.2916,0.9647,0.2916,0.9573 Q0.2916,0.954,0.2892,0.9515 T0.2819,0.9486 Q0.2755,0.9482,0.2683,0.9482 Q0.2643,0.9482,0.2582,0.9484 T0.2498,0.9486 Q0.2426,0.9486,0.2402,0.9473 Q0.2386,0.9469,0.2317,0.943 T0.2161,0.937 Q0.2104,0.9357,0.1992,0.933 T0.1831,0.9291 Q0.1807,0.9287,0.1783,0.9285 T0.1739,0.928 T0.1703,0.9276 T0.1675,0.9272 T0.1655,0.9266 T0.1639,0.9253 Q0.1598,0.9216,0.1462,0.9216 L0.143,0.9216 L0.1398,0.9216 L0.1365,0.9216 Q0.1197,0.9195,0.1197,0.9154 L0.1197,0.9154 Q0.1205,0.9121,0.1373,0.9088 T0.1703,0.9054 Q0.1791,0.9054,0.1863,0.904 T0.1984,0.9011 T0.2064,0.8992 Q0.2402,0.8967,0.2506,0.8934 Q0.2538,0.8926,0.2602,0.8899 T0.2707,0.8872 Q0.2715,0.8872,0.2731,0.8876 Q0.2795,0.8884,0.2884,0.8884 Q0.3068,0.8884,0.3092,0.8826 L0.3092,0.8797 Q0.3092,0.8772,0.3076,0.8747 T0.3044,0.8706 T0.3028,0.8681 Q0.3076,0.8656,0.3237,0.8656 Q0.3317,0.8656,0.3622,0.8623 Q0.3655,0.8623,0.3867,0.8617 T0.4217,0.8602 Q0.4241,0.8598,0.4289,0.8598 L0.4345,0.8598 L0.441,0.8598 Q0.4578,0.8598,0.4667,0.8586 Q0.4739,0.8573,0.4851,0.8567 T0.5004,0.8552 Q0.5012,0.8552,0.5108,0.855 T0.5269,0.853 T0.5333,0.8461 Q0.5333,0.8445,0.5325,0.8432 T0.5309,0.8409 T0.5289,0.8391 T0.5261,0.8378 L0.5229,0.837 T0.5185,0.8362 T0.5133,0.8355 T0.5076,0.8349 T0.502,0.8341 Q0.4932,0.8324,0.4859,0.8324 Q0.4827,0.8324,0.4787,0.8328 T0.4731,0.8333 Q0.4707,0.8333,0.4683,0.8324 Q0.4482,0.825,0.4394,0.825 Q0.4369,0.825,0.4345,0.8254 Q0.4225,0.827,0.4153,0.827 Q0.4088,0.827,0.4064,0.8258 Q0.3976,0.8204,0.3751,0.8204 Q0.3703,0.8204,0.3667,0.8214 T0.3622,0.8225 Q0.3598,0.8225,0.3558,0.82 Q0.351,0.8175,0.3402,0.8167 T0.3177,0.8156 T0.3028,0.8146 L0.2956,0.8121 T0.2871,0.8094 T0.2771,0.8073 T0.2635,0.8063 Q0.261,0.8063,0.2586,0.8067 Q0.2378,0.8071,0.2273,0.8071 Q0.2072,0.8071,0.2024,0.8051 Q0.1976,0.8034,0.1932,0.8026 T0.1867,0.8013 T0.1847,0.8001 L0.1847,0.7993 Q0.1855,0.7984,0.1855,0.7978 T0.1859,0.7966 T0.1867,0.7959 T0.188,0.7955 T0.1896,0.7951 T0.1916,0.7949 T0.1944,0.7945 T0.1984,0.7941 T0.2032,0.7939 Q0.212,0.7926,0.2325,0.7918 T0.2562,0.7905 Q0.2691,0.7893,0.2787,0.7847 Q0.2835,0.7827,0.2968,0.7791 T0.3149,0.7756 Q0.3189,0.7756,0.3305,0.7733 T0.3446,0.771 L0.3454,0.771 Q0.3462,0.771,0.3498,0.7721 T0.3574,0.774 T0.3655,0.7748 Q0.3703,0.7748,0.3743,0.7731 T0.3823,0.7708 T0.3916,0.77 T0.3992,0.7694 Q0.4008,0.7694,0.4076,0.7688 T0.4205,0.7675 L0.4305,0.7665 Q0.4345,0.7657,0.4402,0.7617 T0.4458,0.7545 Q0.4458,0.7503,0.4353,0.7487 Q0.4297,0.7478,0.4209,0.7462 T0.4044,0.7433 T0.3904,0.7416 L0.3847,0.7416 Q0.3807,0.7416,0.3747,0.7422 T0.3663,0.7428 T0.3606,0.7424 Q0.3582,0.742,0.3562,0.7418 T0.3522,0.7412 T0.3482,0.7406 T0.3446,0.7401 T0.341,0.7397 T0.3373,0.7393 T0.3341,0.7391 L0.3293,0.7391 Q0.3277,0.7395,0.3253,0.7395 Q0.3205,0.7395,0.3052,0.7387 T0.2835,0.7379 Q0.2755,0.7379,0.253,0.7325 Q0.2506,0.7316,0.2462,0.731 T0.2382,0.7296 T0.2305,0.7271 T0.2181,0.7234 T0.2048,0.7196 T0.2,0.7155 Q0.2,0.7142,0.2016,0.713 Q0.208,0.7059,0.2285,0.6978 T0.2618,0.6898 Q0.2739,0.6898,0.2831,0.6848 T0.2956,0.6794 Q0.3028,0.6786,0.3289,0.6765 T0.3566,0.674 Q0.3582,0.674,0.3855,0.6723 T0.4406,0.6688 T0.4755,0.6653 Q0.5004,0.6607,0.5124,0.6599 L0.5165,0.6599 Q0.5213,0.6599,0.5277,0.6605 T0.5373,0.6611 Q0.543,0.6611,0.5494,0.6599 Q0.592,0.6524,0.6,0.6524 Q0.6064,0.6524,0.61,0.6499 T0.6161,0.6474 Q0.6177,0.6474,0.6261,0.6495 T0.6418,0.6516 L0.6482,0.6516 Q0.653,0.6512,0.6651,0.6506 T0.6876,0.6493 T0.7084,0.6477 T0.7229,0.645 Q0.7269,0.6437,0.7333,0.6437 Q0.7373,0.6437,0.7458,0.6443 T0.7574,0.645 Q0.7614,0.645,0.7631,0.6445 T0.7655,0.6441 Q0.7671,0.6441,0.7723,0.6448 T0.7823,0.6454 Q0.788,0.6454,0.7952,0.6445 Q0.8233,0.6408,0.8723,0.6367 Q0.9012,0.6342,0.9092,0.6342 L0.9165,0.6342 L0.9205,0.6342 Q0.9277,0.6342,0.9382,0.6323 T0.9526,0.6304 Q0.9534,0.6304,0.9594,0.6307 T0.9695,0.6309 Q0.9976,0.6309,0.9992,0.6234 Q1,0.6201,1,0.618 Q1,0.6089,0.9775,0.608 Q0.9703,0.6076,0.9582,0.6076 Q0.9518,0.6076,0.9394,0.6078 T0.9213,0.608 Q0.9036,0.608,0.8972,0.6072 Q0.894,0.6068,0.8871,0.6058 T0.8751,0.6039 T0.8627,0.6024 T0.8506,0.6018 L0.8474,0.6018 Q0.841,0.6022,0.8281,0.6041 T0.8112,0.606 Q0.8096,0.606,0.808,0.6056 Q0.7783,0.6002,0.7647,0.6002 Q0.7598,0.6002,0.7454,0.6006 T0.7261,0.601 Q0.7221,0.601,0.7145,0.6022 T0.7036,0.6035 Q0.6996,0.6035,0.6964,0.6022 Q0.6723,0.5902,0.6442,0.5902 Q0.6426,0.5902,0.6386,0.5904 T0.6337,0.5906 Q0.6273,0.5906,0.6249,0.5894 L0.6177,0.5856 T0.6116,0.5838 T0.6016,0.5825 T0.5855,0.5823 Q0.5719,0.5823,0.5574,0.5798 T0.5373,0.5774 L0.5341,0.5774 Q0.5293,0.5778,0.5213,0.5786 T0.51,0.5794 Q0.5036,0.5794,0.4988,0.5769 Q0.4932,0.574,0.4771,0.574 Q0.4723,0.574,0.4631,0.5745 T0.4498,0.5749 Q0.4418,0.5749,0.4394,0.5736 Q0.4353,0.5724,0.4305,0.5715 T0.4225,0.5707 T0.4145,0.5705 T0.4056,0.5699 Q0.4008,0.5691,0.398,0.5689 T0.394,0.5689 T0.3908,0.5686 T0.3855,0.5674 Q0.3831,0.567,0.3811,0.5662 T0.3779,0.5645 T0.3743,0.563 T0.3695,0.5624 Q0.3655,0.5624,0.3594,0.5635 T0.3494,0.5645 T0.3406,0.5635 T0.3325,0.5624 Q0.3309,0.5624,0.3301,0.5628 L0.3141,0.5628 Q0.2635,0.5628,0.2506,0.5612 Q0.2474,0.5608,0.2434,0.5608 Q0.2402,0.5608,0.2349,0.561 T0.2273,0.5612 Q0.2209,0.5612,0.2177,0.5595 Q0.2145,0.557,0.2145,0.5558 Q0.2169,0.5537,0.2345,0.5521 Q0.2876,0.5475,0.3028,0.5425 Q0.3068,0.5413,0.3149,0.5396 T0.3309,0.5367 T0.3478,0.5338 T0.3606,0.5309 Q0.3631,0.5305,0.3755,0.5259 T0.3968,0.5214 Q0.3992,0.5214,0.4024,0.5218 T0.4096,0.5222 Q0.4161,0.5222,0.4213,0.5209 T0.4313,0.5185 T0.4402,0.5172 Q0.4418,0.5168,0.447,0.5168 L0.4558,0.5168 T0.4639,0.5162 T0.4707,0.5141 T0.4731,0.5102 Q0.4731,0.5089,0.4723,0.5081 Q0.4699,0.5019,0.4627,0.4994 T0.4369,0.4965 Q0.4273,0.4961,0.4193,0.4946 T0.4048,0.4915 T0.3952,0.4894 Q0.392,0.4886,0.388,0.4886 Q0.3847,0.4886,0.3775,0.4892 T0.3647,0.4898 Q0.3598,0.4898,0.355,0.4894 Q0.3165,0.4861,0.3141,0.4853 Q0.2779,0.4774,0.2715,0.4774 Q0.2699,0.4774,0.2683,0.4776 T0.2627,0.4778 Q0.2498,0.4778,0.2281,0.4762 Q0.2241,0.4749,0.2233,0.4737 Q0.2249,0.472,0.2321,0.4708 Q0.2402,0.4695,0.2554,0.4695 L0.2675,0.4695 L0.2795,0.4695 Q0.294,0.4695,0.2996,0.4679 Q0.3141,0.4629,0.3373,0.4616 Q0.3414,0.4612,0.3466,0.4606 T0.3582,0.4589 T0.3687,0.4562 T0.3727,0.4525 Q0.3727,0.4509,0.3703,0.4492 Q0.3639,0.4455,0.3474,0.4419 T0.3213,0.4384 L0.3157,0.4384 L0.31,0.4384 Q0.294,0.4384,0.2859,0.4363 Q0.2795,0.4347,0.2691,0.4347 L0.2618,0.4347 L0.2546,0.4347 Q0.2458,0.4347,0.2394,0.4338 Q0.2257,0.4318,0.2193,0.4303 T0.2092,0.4266 T0.2052,0.4224 T0.2024,0.4154 T0.196,0.4052 Q0.1912,0.3994,0.1867,0.3949 T0.1807,0.3884 T0.1791,0.3849 Q0.1791,0.3824,0.1839,0.3745 Q0.1871,0.3687,0.1944,0.3637 T0.2072,0.3561 T0.2221,0.3501 T0.2321,0.3463 Q0.2353,0.3455,0.241,0.3445 T0.2522,0.3428 T0.2639,0.3411 T0.2731,0.3384 T0.2956,0.3351 T0.3197,0.3326 Q0.3213,0.3322,0.3237,0.3322 T0.3325,0.3331 T0.3414,0.3339 Q0.3478,0.3339,0.3518,0.3314 Q0.3606,0.3264,0.3703,0.3264 Q0.3775,0.3264,0.3847,0.3293 Q0.3888,0.331,0.396,0.331 Q0.4024,0.331,0.4116,0.3295 T0.4265,0.3266 T0.4414,0.3227 T0.4514,0.3202 Q0.4578,0.3181,0.4839,0.3152 T0.5112,0.3123 T0.5177,0.3119 T0.5285,0.3111 T0.5398,0.3096 T0.549,0.3065 T0.5526,0.3015 Q0.5526,0.2999,0.5518,0.2982 Q0.547,0.2903,0.5386,0.2883 T0.5165,0.2862 Q0.5116,0.2862,0.5056,0.2866 T0.4972,0.287 Q0.4884,0.287,0.4787,0.2833 Q0.4594,0.2758,0.4265,0.2758 Q0.4169,0.2758,0.4129,0.2766 Q0.4112,0.2771,0.4104,0.2771 Q0.4088,0.2771,0.4056,0.2748 T0.3968,0.2721 Q0.3695,0.2696,0.359,0.2659 Q0.355,0.2646,0.351,0.2646 T0.3426,0.2661 T0.3365,0.2675 T0.3333,0.2659 Q0.3277,0.2605,0.3116,0.2553 T0.2859,0.2501 L0.2843,0.2501 L0.2819,0.2501 Q0.2779,0.2501,0.2723,0.2493 T0.2586,0.2472 T0.2474,0.2455 Q0.1799,0.236,0.1719,0.236 Q0.1663,0.236,0.1606,0.235 T0.1502,0.2316 T0.1454,0.2265 Q0.1454,0.2223,0.1558,0.2173 Q0.1679,0.2115,0.1859,0.2092 T0.2185,0.207 T0.2353,0.2057 Q0.2369,0.2049,0.2502,0.2041 T0.2799,0.2022 T0.302,0.2007 Q0.3084,0.1999,0.3245,0.1954 T0.347,0.1908 Q0.3502,0.1908,0.3534,0.1916 Q0.3663,0.197,0.388,0.197 Q0.404,0.197,0.4088,0.1929 Q0.4096,0.192,0.4108,0.192 T0.4177,0.1945 T0.4277,0.197 T0.4369,0.1949 Q0.4442,0.1908,0.4843,0.1875 Q0.4892,0.1871,0.4968,0.1839 T0.5084,0.1808 L0.5108,0.1808 Q0.5213,0.1825,0.5454,0.1825 Q0.5823,0.1825,0.5992,0.1779 Q0.6096,0.1746,0.6217,0.1746 Q0.6249,0.1746,0.6309,0.1748 T0.6394,0.175 Q0.6434,0.175,0.6466,0.1746 Q0.6474,0.1746,0.6594,0.1738 T0.6787,0.1713 T0.6892,0.1659 Q0.6924,0.1634,0.6924,0.1593 Q0.6924,0.1547,0.6888,0.151 T0.6795,0.1472 Q0.6779,0.1472,0.6763,0.1477 Q0.6699,0.1493,0.6667,0.1493 Q0.661,0.1493,0.6506,0.1456 Q0.6329,0.1394,0.6129,0.1394 Q0.6048,0.1394,0.5992,0.1377 T0.5888,0.136 T0.5803,0.1377 T0.5751,0.1394 Q0.5711,0.1394,0.5639,0.1369 Q0.5365,0.1273,0.5116,0.1273 Q0.4876,0.1273,0.4667,0.1253 Q0.4627,0.1248,0.4542,0.1211 T0.4337,0.1174 L0.4305,0.1174 Q0.4217,0.1178,0.4153,0.119 T0.408,0.1203 Q0.4056,0.1203,0.4,0.117 Q0.3976,0.1153,0.396,0.1136 T0.3932,0.1112 T0.39,0.1099 T0.3847,0.1095 Q0.3799,0.1095,0.3687,0.1103 Q0.355,0.1112,0.3434,0.1141 T0.3301,0.117 Q0.3261,0.117,0.3229,0.1145 Q0.3181,0.1116,0.3052,0.1087 T0.2787,0.1043 T0.2546,0.1029 Q0.2506,0.1029,0.2474,0.1033 Q0.2418,0.1037,0.2349,0.1054 T0.2249,0.107 Q0.2225,0.107,0.2193,0.1066 Q0.2024,0.1024,0.1863,0.1024 Q0.1823,0.1024,0.1562,0.0971 T0.1269,0.0917 T0.1161,0.0896 T0.106,0.0854 Q0.1076,0.0846,0.11,0.0842 Q0.1173,0.0821,0.1261,0.0821 Q0.1301,0.0821,0.1369,0.0825 T0.1462,0.083 Q0.1494,0.083,0.151,0.0825 T0.1831,0.0813 T0.2201,0.0784 T0.243,0.074 T0.2667,0.0718 Q0.2707,0.0718,0.2755,0.0724 T0.2843,0.073 T0.2936,0.0724 T0.3024,0.0705 T0.3072,0.068 T0.3092,0.0657 T0.3108,0.0647 Q0.3116,0.0643,0.3133,0.0643 L0.3157,0.0643 L0.3181,0.0643 Q0.3446,0.0643,0.3446,0.0556 T0.3205,0.0469 L0.3189,0.0469 Q0.3157,0.0469,0.3157,0.0465 Q0.3084,0.0427,0.2835,0.0386 Q0.2739,0.0369,0.2675,0.0342 T0.2538,0.0299 Q0.249,0.029,0.245,0.029 T0.2378,0.0303 T0.2321,0.0315 Q0.2305,0.0315,0.2273,0.0307 Q0.2201,0.0286,0.2004,0.0272 T0.1775,0.0245 Q0.1735,0.0228,0.1663,0.0226 T0.1522,0.0197 T0.1345,0.0145 T0.1124,0.0079 Q0.0996,0.0033,0.0671,0.0044 T0.0297,0.0041 Q0.0169,0,0.0024,0.0017 Q0,0.0021,0,0.0037 Z M0.0064,0.9954 L0.0056,0.0058 Q0.0177,0.005,0.0281,0.0083 Q0.0345,0.01,0.0675,0.0089 T0.1108,0.012 Q0.1221,0.0162,0.1329,0.0187 T0.1498,0.0236 T0.1606,0.0268 T0.1691,0.0274 T0.1759,0.0286 Q0.1807,0.0303,0.2,0.0315 T0.2257,0.0348 Q0.2305,0.0361,0.2337,0.0361 Q0.2361,0.0361,0.2398,0.0348 T0.2466,0.0336 Q0.249,0.0336,0.2522,0.034 Q0.2586,0.0353,0.2655,0.0382 T0.2827,0.0427 Q0.3068,0.0469,0.3124,0.0502 Q0.3157,0.0523,0.3237,0.0523 L0.3277,0.0523 L0.3309,0.0523 Q0.3398,0.0523,0.3398,0.0556 Q0.3398,0.0581,0.3341,0.0587 T0.3205,0.0593 T0.3092,0.0603 T0.3036,0.0643 T0.2932,0.068 Q0.2884,0.0684,0.2843,0.0684 Q0.2811,0.0684,0.2763,0.0678 T0.2667,0.0672 Q0.2586,0.0672,0.2422,0.0697 T0.2177,0.0747 Q0.2137,0.0759,0.1831,0.0767 T0.1494,0.0784 L0.1474,0.0784 T0.1398,0.078 T0.1285,0.0776 Q0.1173,0.0776,0.1084,0.08 Q0.1004,0.0817,0.1004,0.0846 Q0.1004,0.0867,0.104,0.0888 T0.1124,0.0923 T0.1213,0.0948 T0.1269,0.0958 T0.155,0.1014 T0.1863,0.107 Q0.2016,0.107,0.2185,0.1107 Q0.2217,0.1116,0.2257,0.1116 Q0.2289,0.1116,0.2365,0.1099 T0.2482,0.1074 L0.2538,0.1074 Q0.2683,0.1074,0.2912,0.1107 T0.3197,0.1182 Q0.3245,0.1215,0.3301,0.1215 Q0.3333,0.1215,0.3454,0.1184 T0.3687,0.1145 Q0.3735,0.1141,0.3779,0.1139 T0.3843,0.1134 T0.3871,0.1132 Q0.3896,0.1132,0.39,0.1136 T0.392,0.1161 T0.3968,0.1203 Q0.404,0.1248,0.408,0.1248 Q0.4096,0.1248,0.4165,0.1234 T0.4305,0.1215 L0.4337,0.1215 Q0.4442,0.1215,0.4518,0.1251 T0.4659,0.1294 Q0.4876,0.1319,0.5116,0.1319 T0.5622,0.141 Q0.5703,0.1439,0.5751,0.1439 Q0.5791,0.1439,0.5831,0.1423 T0.5888,0.1406 Q0.592,0.1406,0.5944,0.1412 T0.6012,0.1427 T0.6129,0.1435 Q0.6313,0.1435,0.649,0.1497 Q0.6602,0.1535,0.6667,0.1535 Q0.6715,0.1535,0.6779,0.1522 Q0.6787,0.1518,0.6795,0.1518 Q0.6827,0.1518,0.6847,0.1541 T0.6867,0.1593 Q0.6867,0.1618,0.6851,0.1634 Q0.6835,0.1655,0.6775,0.1667 T0.6598,0.169 T0.6458,0.1705 T0.6402,0.1709 Q0.6378,0.1709,0.6321,0.1705 T0.6225,0.1701 Q0.6096,0.1701,0.5968,0.1738 Q0.5823,0.1779,0.5446,0.1779 Q0.5205,0.1779,0.5116,0.1767 Q0.51,0.1763,0.5084,0.1763 Q0.5028,0.1763,0.4944,0.1796 T0.4835,0.1829 L0.4771,0.1833 T0.4659,0.1844 L0.4546,0.1858 T0.443,0.1881 T0.4337,0.1912 Q0.4321,0.1916,0.4305,0.1916 Q0.4273,0.1916,0.4209,0.1895 T0.412,0.1875 Q0.408,0.1875,0.4056,0.19 Q0.4024,0.1925,0.388,0.1925 Q0.3663,0.1925,0.3558,0.1879 Q0.3518,0.1862,0.3462,0.1862 Q0.3373,0.1862,0.3213,0.191 T0.3012,0.1962 Q0.2964,0.1966,0.2799,0.1976 T0.2494,0.1997 T0.2313,0.2024 L0.2313,0.2024 L0.2293,0.2024 L0.2261,0.2024 L0.2217,0.2024 Q0.204,0.2024,0.1851,0.2047 T0.1526,0.2136 Q0.1406,0.2198,0.1406,0.226 Q0.1406,0.2319,0.1518,0.2362 T0.1719,0.2406 Q0.1791,0.2406,0.2466,0.2497 Q0.2498,0.2501,0.2574,0.2516 T0.2711,0.2538 T0.2819,0.2547 L0.2851,0.2547 Q0.2851,0.2543,0.2859,0.2543 Q0.294,0.2543,0.3096,0.2592 T0.3285,0.2684 Q0.3317,0.2721,0.3373,0.2721 Q0.3406,0.2721,0.3462,0.2708 T0.3542,0.2696 Q0.3558,0.2696,0.3574,0.27 Q0.3679,0.2737,0.3968,0.2762 Q0.3984,0.2766,0.4004,0.2779 L0.4044,0.2804 T0.4096,0.2816 Q0.412,0.2816,0.4145,0.2808 Q0.4177,0.2804,0.4249,0.2804 Q0.4586,0.2804,0.4763,0.287 Q0.4867,0.2912,0.4972,0.2912 Q0.5004,0.2912,0.5064,0.2908 T0.5165,0.2903 Q0.5293,0.2903,0.5361,0.2922 T0.547,0.3003 L0.547,0.3011 Q0.547,0.3036,0.5414,0.3049 T0.5249,0.3067 T0.51,0.3082 Q0.5092,0.3082,0.4831,0.3111 T0.4498,0.3161 Q0.408,0.3264,0.3952,0.3264 Q0.3896,0.3264,0.3863,0.3252 Q0.3783,0.3223,0.3703,0.3223 Q0.359,0.3223,0.3494,0.3277 Q0.347,0.3293,0.343,0.3293 Q0.3414,0.3293,0.3353,0.3285 T0.3253,0.3277 T0.3181,0.3285 Q0.3149,0.3289,0.2952,0.3306 T0.2699,0.3347 Q0.2675,0.3364,0.2598,0.3372 T0.2434,0.3395 T0.2297,0.3426 L0.2205,0.3461 T0.2048,0.3523 T0.1908,0.3606 T0.1791,0.3725 Q0.1743,0.3803,0.1743,0.3845 Q0.1743,0.3874,0.1763,0.3901 T0.1827,0.3976 T0.1912,0.4073 T0.198,0.4189 T0.2032,0.4276 T0.2137,0.4326 T0.2386,0.438 Q0.2458,0.4392,0.2562,0.4392 L0.2639,0.4392 L0.2699,0.4392 Q0.2795,0.4392,0.2843,0.4405 Q0.2932,0.443,0.3092,0.443 L0.3157,0.443 L0.3213,0.443 Q0.3293,0.443,0.3458,0.4463 T0.3671,0.4525 Q0.3598,0.4558,0.3373,0.4571 Q0.3124,0.4587,0.298,0.4637 Q0.294,0.465,0.2811,0.465 L0.2703,0.465 L0.2586,0.465 Q0.241,0.465,0.2305,0.4666 Q0.2185,0.4687,0.2185,0.4728 Q0.2185,0.4745,0.2205,0.4764 T0.2241,0.4791 L0.2265,0.4803 L0.2273,0.4803 Q0.2506,0.4824,0.261,0.4824 Q0.2675,0.4824,0.2699,0.482 Q0.2699,0.4815,0.2707,0.4815 Q0.2771,0.4815,0.3124,0.4898 Q0.3173,0.4907,0.3229,0.4913 T0.3386,0.4925 T0.3542,0.4936 T0.3663,0.494 Q0.3711,0.494,0.3787,0.4936 T0.3888,0.4932 Q0.392,0.4932,0.3944,0.4936 T0.4032,0.4959 T0.4181,0.499 T0.4369,0.5006 Q0.449,0.501,0.455,0.5021 T0.4639,0.5048 T0.4675,0.5093 L0.4675,0.5097 Q0.4675,0.5106,0.4663,0.511 T0.4622,0.5116 L0.4566,0.512 T0.4486,0.5124 T0.4402,0.5127 Q0.4345,0.5131,0.4257,0.5153 T0.4096,0.5176 Q0.4064,0.5176,0.4024,0.5172 L0.3968,0.5172 Q0.3863,0.5172,0.3731,0.522 T0.359,0.5268 Q0.355,0.528,0.3317,0.5321 T0.3004,0.5388 Q0.2867,0.5433,0.2337,0.5479 Q0.2096,0.55,0.2096,0.5562 Q0.2096,0.5591,0.2145,0.5628 Q0.2193,0.5662,0.2289,0.5662 Q0.2313,0.5662,0.2373,0.5657 T0.2458,0.5653 L0.2498,0.5653 Q0.2635,0.5674,0.3124,0.5674 Q0.3261,0.5674,0.3301,0.567 L0.3317,0.567 Q0.3341,0.567,0.3394,0.568 T0.3486,0.5691 Q0.3542,0.5691,0.3606,0.5678 T0.3699,0.5666 T0.3759,0.5686 T0.3839,0.5718 T0.3908,0.573 T0.3964,0.5734 T0.4048,0.5742 T0.4165,0.5751 T0.4277,0.5757 T0.4369,0.5778 Q0.4426,0.5794,0.4538,0.5794 Q0.4586,0.5794,0.4679,0.5792 T0.4811,0.579 Q0.4924,0.579,0.4956,0.5807 Q0.502,0.584,0.5108,0.584 L0.5137,0.584 T0.5173,0.5838 L0.5205,0.5834 L0.5237,0.583 L0.5269,0.5825 T0.5305,0.5821 T0.5341,0.5819 L0.5365,0.5819 Q0.5414,0.5819,0.5562,0.5842 T0.5855,0.5865 Q0.5912,0.5865,0.5948,0.5867 T0.6012,0.5869 T0.6064,0.5873 T0.61,0.5877 T0.6133,0.5886 T0.6157,0.5896 L0.6185,0.591 T0.6217,0.5931 Q0.6265,0.5952,0.6369,0.5952 L0.6418,0.5952 L0.6466,0.5952 Q0.6723,0.5952,0.6932,0.606 Q0.698,0.608,0.7044,0.608 Q0.7084,0.608,0.7161,0.6068 T0.7261,0.6056 Q0.7309,0.6056,0.7454,0.6051 T0.7647,0.6047 Q0.7775,0.6047,0.8072,0.6101 Q0.8096,0.6105,0.812,0.6105 Q0.8177,0.6105,0.8297,0.6085 T0.8474,0.606 L0.8506,0.606 Q0.8562,0.606,0.8647,0.607 T0.8831,0.6095 T0.8964,0.6118 Q0.9036,0.6122,0.9221,0.6122 L0.9406,0.6122 L0.959,0.6122 L0.9767,0.6122 Q0.9952,0.613,0.9952,0.6172 Q0.9952,0.6176,0.9944,0.6221 Q0.9936,0.6259,0.9574,0.6259 L0.955,0.6259 L0.9526,0.6259 Q0.9478,0.6259,0.9373,0.628 T0.9205,0.63 L0.9173,0.63 Q0.9133,0.6296,0.9084,0.6296 Q0.9004,0.6296,0.8715,0.6321 Q0.8233,0.6367,0.7944,0.64 Q0.7888,0.6408,0.7839,0.6408 T0.7739,0.6402 T0.7671,0.6396 Q0.7639,0.6396,0.7622,0.64 Q0.7614,0.6404,0.759,0.6404 Q0.7574,0.6404,0.749,0.6398 T0.7357,0.6392 Q0.7261,0.6392,0.7213,0.6412 Q0.7173,0.6425,0.7032,0.6437 T0.6711,0.6458 T0.6474,0.647 Q0.645,0.6474,0.6418,0.6474 Q0.6353,0.6474,0.6277,0.6454 T0.6161,0.6433 Q0.6104,0.6433,0.6072,0.6456 T0.6,0.6479 Q0.5912,0.6479,0.5486,0.6557 Q0.5422,0.657,0.5373,0.657 Q0.5349,0.657,0.5289,0.6564 T0.5173,0.6557 L0.5124,0.6557 Q0.4996,0.6562,0.4739,0.6611 Q0.4675,0.6624,0.4398,0.6645 T0.3851,0.668 T0.3558,0.6698 Q0.355,0.6698,0.3285,0.6721 T0.2948,0.6752 Q0.2892,0.6761,0.2843,0.6786 T0.2747,0.6831 T0.2618,0.6852 Q0.253,0.6852,0.2394,0.6893 T0.2141,0.6993 T0.1968,0.7105 Q0.1944,0.713,0.1944,0.7155 Q0.1944,0.7196,0.2012,0.7229 T0.2177,0.7285 T0.2281,0.7308 Q0.2321,0.7329,0.2365,0.7339 T0.245,0.7356 T0.2514,0.7366 Q0.2522,0.737,0.2554,0.7379 T0.2614,0.7393 T0.2679,0.7406 T0.2755,0.7416 T0.2835,0.742 Q0.29,0.742,0.3048,0.7428 T0.3253,0.7437 L0.3301,0.7437 L0.3333,0.7437 Q0.3341,0.7437,0.3598,0.7466 Q0.3639,0.7474,0.3671,0.7474 T0.3759,0.7466 T0.3855,0.7457 Q0.388,0.7457,0.3904,0.7462 Q0.3984,0.7466,0.4137,0.7495 T0.4349,0.7532 T0.441,0.7557 Q0.441,0.7599,0.4289,0.7619 Q0.4257,0.7628,0.4197,0.7634 T0.4072,0.7644 T0.3984,0.7652 Q0.3968,0.7652,0.3912,0.7655 T0.3811,0.7665 T0.3719,0.7694 Q0.3695,0.7702,0.3655,0.7702 T0.3546,0.7686 T0.3462,0.7665 L0.3446,0.7665 Q0.3406,0.7665,0.3293,0.769 T0.3149,0.7715 Q0.3084,0.7715,0.2952,0.7748 T0.2763,0.781 Q0.2675,0.7847,0.2554,0.7864 Q0.253,0.7864,0.2325,0.7874 T0.2024,0.7893 Q0.2008,0.7893,0.1984,0.7897 T0.1948,0.7901 T0.1916,0.7903 T0.1888,0.7908 T0.1867,0.7914 T0.1847,0.7922 L0.1831,0.793 T0.1819,0.7943 L0.1811,0.7959 T0.1799,0.7976 Q0.1791,0.7993,0.1791,0.8001 Q0.1791,0.8034,0.1831,0.8051 T0.1932,0.8078 T0.2,0.8092 Q0.2072,0.8117,0.2257,0.8117 Q0.2337,0.8117,0.2586,0.8109 L0.2635,0.8109 Q0.2707,0.8109,0.2767,0.8117 T0.2859,0.8136 T0.2936,0.8163 T0.3012,0.8187 Q0.3068,0.82,0.3277,0.8206 T0.3526,0.8237 Q0.3582,0.8266,0.3622,0.8266 Q0.3647,0.8266,0.3687,0.8258 T0.3751,0.825 Q0.396,0.825,0.404,0.8291 Q0.408,0.8316,0.4161,0.8316 Q0.4217,0.8316,0.4353,0.8295 L0.4394,0.8295 Q0.4466,0.8295,0.4659,0.8366 Q0.4699,0.8378,0.4747,0.8378 Q0.4763,0.8378,0.4807,0.8374 T0.4884,0.837 Q0.494,0.837,0.5004,0.8382 Q0.5052,0.8391,0.5124,0.8399 Q0.5221,0.8411,0.5249,0.8422 T0.5277,0.8461 Q0.5277,0.8482,0.5233,0.849 T0.5112,0.8501 T0.4996,0.8511 Q0.4964,0.8519,0.4851,0.8523 T0.4659,0.8544 Q0.4578,0.8557,0.4402,0.8557 L0.4349,0.8557 L0.4297,0.8557 L0.4209,0.8557 Q0.408,0.8565,0.3867,0.8571 T0.3614,0.8582 Q0.3317,0.8611,0.3237,0.8611 L0.3225,0.8611 L0.3213,0.8611 Q0.2972,0.8611,0.2972,0.8681 Q0.2972,0.8714,0.3008,0.8747 T0.3044,0.8805 Q0.3044,0.881,0.3036,0.8814 Q0.3012,0.8839,0.2851,0.8839 Q0.2779,0.8839,0.2739,0.883 Q0.2723,0.8826,0.2699,0.8826 T0.2643,0.8835 T0.259,0.8853 T0.2542,0.8876 T0.249,0.8893 Q0.2386,0.8922,0.2056,0.8946 Q0.2016,0.8951,0.1916,0.898 T0.1703,0.9009 Q0.1518,0.9009,0.1337,0.9044 T0.1149,0.9146 L0.1149,0.9158 Q0.1149,0.9175,0.1157,0.9187 T0.1173,0.921 T0.1201,0.9226 T0.1233,0.9237 T0.1269,0.9245 L0.1305,0.9251 T0.1337,0.9255 L0.1357,0.9258 Q0.139,0.9262,0.1446,0.9262 T0.1542,0.9266 T0.1598,0.9282 Q0.1614,0.9303,0.1647,0.9314 T0.1739,0.9328 T0.1815,0.9336 Q0.1863,0.9345,0.1976,0.9372 T0.2145,0.9415 Q0.2225,0.9432,0.2285,0.9467 T0.2378,0.9515 Q0.2426,0.9531,0.2514,0.9531 Q0.2538,0.9531,0.2602,0.9529 T0.2707,0.9527 Q0.2763,0.9527,0.2815,0.9531 T0.2867,0.9569 T0.2811,0.9614 Q0.2434,0.9627,0.2329,0.9652 Q0.2249,0.9672,0.2241,0.9672 L0.2096,0.9668 L0.2056,0.9668 Q0.2,0.9668,0.196,0.9672 T0.1884,0.9687 T0.1815,0.9708 T0.1731,0.9737 T0.1639,0.9772 Q0.1518,0.9805,0.1285,0.9805 L0.1253,0.9805 Q0.1124,0.9805,0.1076,0.9818 Q0.1012,0.983,0.0831,0.9876 T0.0594,0.9934 Q0.049,0.9954,0.0064,0.9954 Z M0.0032,0.9979 L0.0024,0.0037 Q0.0161,0.0021,0.0289,0.0062 Q0.0337,0.0075,0.0671,0.0066 T0.1116,0.01 T0.1337,0.0166 T0.151,0.022 Q0.1582,0.0249,0.1659,0.0251 T0.1767,0.0265 Q0.1807,0.0278,0.2,0.0292 T0.2265,0.0328 Q0.2305,0.034,0.2329,0.034 T0.239,0.0326 T0.2458,0.0311 T0.253,0.0319 Q0.2578,0.0332,0.2614,0.0342 T0.2667,0.0363 T0.2723,0.0384 T0.2827,0.0406 Q0.3084,0.0448,0.3141,0.0485 Q0.3149,0.0494,0.3225,0.0494 T0.3361,0.0504 T0.3422,0.0554 T0.3357,0.0606 T0.3205,0.0618 T0.31,0.0626 Q0.3092,0.0626,0.3056,0.0659 T0.2932,0.0701 Q0.2884,0.0709,0.2843,0.0709 Q0.2811,0.0709,0.2759,0.0701 T0.2667,0.0693 Q0.2586,0.0693,0.2422,0.0718 T0.2193,0.0763 Q0.2137,0.0784,0.1831,0.079 T0.1502,0.0805 Q0.1494,0.0809,0.147,0.0809 Q0.1454,0.0809,0.1386,0.0803 T0.1277,0.0796 Q0.1173,0.0796,0.1092,0.0821 Q0.1036,0.0834,0.1036,0.0854 Q0.1036,0.0879,0.1129,0.0908 T0.1269,0.0937 Q0.1293,0.0937,0.1558,0.0991 T0.1863,0.1045 Q0.2016,0.1045,0.2193,0.1087 Q0.2225,0.1091,0.2249,0.1091 Q0.2289,0.1091,0.2357,0.1076 T0.2482,0.1054 Q0.2506,0.1049,0.2546,0.1049 Q0.2699,0.1049,0.2924,0.1085 T0.3213,0.1165 Q0.3253,0.119,0.3301,0.119 Q0.3325,0.119,0.3446,0.1161 T0.3687,0.1124 Q0.3831,0.1112,0.3863,0.1112 T0.3908,0.1118 T0.3936,0.1145 T0.3984,0.1186 Q0.4048,0.1228,0.408,0.1228 Q0.4096,0.1228,0.4161,0.1213 T0.4305,0.1195 L0.4337,0.1195 Q0.4426,0.1195,0.4474,0.1211 T0.4566,0.1246 T0.4667,0.1273 Q0.4876,0.1298,0.5116,0.1298 Q0.5365,0.1298,0.5631,0.1389 Q0.5703,0.1414,0.5751,0.1414 Q0.5783,0.1414,0.5819,0.1398 T0.5888,0.1381 Q0.5928,0.1381,0.5984,0.1398 T0.6129,0.1414 Q0.6321,0.1414,0.6498,0.1477 Q0.661,0.1514,0.6667,0.1514 Q0.6707,0.1514,0.6771,0.1501 Q0.6787,0.1497,0.6795,0.1497 Q0.6835,0.1497,0.6863,0.1526 T0.6892,0.1593 Q0.6892,0.1626,0.6876,0.1647 Q0.6851,0.1672,0.6799,0.1686 T0.6695,0.1705 T0.6566,0.1715 T0.6458,0.1725 Q0.6434,0.173,0.6402,0.173 Q0.6378,0.173,0.6317,0.1727 T0.6225,0.1725 Q0.6096,0.1725,0.5984,0.1759 Q0.5823,0.1804,0.5454,0.1804 Q0.5205,0.1804,0.5116,0.1788 L0.5084,0.1788 Q0.5036,0.1788,0.4956,0.1819 T0.4843,0.185 Q0.4434,0.1887,0.4353,0.1929 Q0.4321,0.1945,0.4289,0.1945 T0.4197,0.1922 T0.4112,0.19 T0.4072,0.1912 Q0.4032,0.1949,0.388,0.1949 Q0.3663,0.1949,0.3542,0.19 Q0.351,0.1883,0.3462,0.1883 Q0.3406,0.1883,0.3321,0.1906 T0.3153,0.1954 T0.302,0.1983 Q0.2972,0.1991,0.2859,0.1997 T0.2643,0.201 T0.245,0.2024 T0.2337,0.2041 Q0.2321,0.2045,0.2181,0.2045 T0.1851,0.207 T0.1542,0.2157 Q0.143,0.2211,0.143,0.226 Q0.143,0.2314,0.153,0.2348 T0.1719,0.2381 Q0.1791,0.2381,0.2474,0.2476 Q0.2506,0.248,0.2558,0.2489 T0.2651,0.2505 T0.2739,0.252 T0.2819,0.2526 Q0.2835,0.2526,0.2851,0.2522 L0.2859,0.2522 Q0.2948,0.2522,0.3104,0.2574 T0.3309,0.2671 Q0.3333,0.2696,0.3365,0.2696 Q0.339,0.2696,0.3442,0.2684 T0.3526,0.2671 T0.3582,0.2679 Q0.3687,0.2717,0.3968,0.2742 Q0.4,0.2746,0.4036,0.2771 T0.4096,0.2796 Q0.4112,0.2796,0.4137,0.2787 Q0.4169,0.2779,0.4257,0.2779 Q0.4594,0.2779,0.4779,0.2849 Q0.4876,0.2891,0.4972,0.2891 Q0.4996,0.2891,0.506,0.2887 T0.5165,0.2883 Q0.5253,0.2883,0.5305,0.2889 T0.541,0.292 T0.5494,0.299 L0.5494,0.3015 Q0.5494,0.3036,0.5466,0.3051 T0.5386,0.3073 T0.5285,0.3086 T0.5181,0.3094 T0.5108,0.3102 Q0.5068,0.3107,0.494,0.3121 L0.4683,0.315 T0.4506,0.3181 Q0.449,0.3181,0.4426,0.32 T0.4313,0.3229 T0.4197,0.3256 T0.4064,0.3281 T0.3952,0.3289 Q0.3888,0.3289,0.3855,0.3273 Q0.3783,0.3243,0.3703,0.3243 Q0.3598,0.3243,0.351,0.3297 Q0.3478,0.3314,0.3422,0.3314 Q0.3398,0.3314,0.3337,0.3306 T0.3245,0.3297 T0.3189,0.3306 Q0.3149,0.3314,0.2956,0.3328 T0.2715,0.3368 Q0.2691,0.338,0.2635,0.3391 T0.2522,0.3407 T0.2406,0.3424 T0.2313,0.3447 Q0.2305,0.3447,0.2213,0.348 T0.206,0.354 T0.1924,0.3621 T0.1815,0.3733 Q0.1767,0.3816,0.1767,0.3849 Q0.1767,0.387,0.1783,0.3893 T0.1847,0.3961 T0.1936,0.4063 T0.2004,0.4181 T0.2052,0.4264 T0.2145,0.4309 T0.2386,0.4359 Q0.2458,0.4372,0.2554,0.4372 Q0.2578,0.4372,0.2627,0.437 T0.2699,0.4367 Q0.2795,0.4367,0.2851,0.4384 Q0.294,0.4409,0.3092,0.4409 Q0.3116,0.4409,0.3157,0.4407 T0.3213,0.4405 Q0.3301,0.4405,0.3466,0.444 T0.3687,0.4509 Q0.3703,0.4517,0.3703,0.4525 Q0.3703,0.4575,0.3373,0.4596 Q0.3133,0.4608,0.2988,0.4658 Q0.294,0.4674,0.2803,0.4674 Q0.2763,0.4674,0.2687,0.4672 T0.257,0.467 Q0.2402,0.467,0.2313,0.4687 Q0.2209,0.4708,0.2209,0.4737 Q0.2209,0.4741,0.2213,0.4749 T0.2229,0.4764 L0.2249,0.4774 T0.2265,0.4778 L0.2273,0.4782 Q0.2498,0.4803,0.2618,0.4803 Q0.2667,0.4803,0.2691,0.4799 Q0.2699,0.4795,0.2715,0.4795 Q0.2779,0.4795,0.3133,0.4873 Q0.3181,0.4886,0.3233,0.4892 T0.3386,0.4905 T0.3542,0.4915 T0.3655,0.4919 Q0.3703,0.4919,0.3779,0.4915 T0.3888,0.4911 T0.3952,0.4915 Q0.3976,0.4919,0.4008,0.4927 L0.4072,0.4944 T0.4149,0.4961 T0.4249,0.4975 T0.4369,0.4985 Q0.449,0.499,0.4554,0.5 T0.4651,0.5031 T0.4699,0.5085 Q0.4707,0.5093,0.4707,0.5097 Q0.4707,0.5114,0.4687,0.5124 T0.4631,0.5139 T0.4562,0.5145 T0.4478,0.5147 L0.4402,0.5147 Q0.4353,0.5151,0.4265,0.5174 T0.4096,0.5197 L0.4024,0.5197 Q0.4,0.5193,0.3968,0.5193 Q0.3896,0.5193,0.3831,0.5209 T0.3703,0.5253 T0.3598,0.5288 Q0.3558,0.5301,0.3321,0.5342 T0.302,0.5409 Q0.2876,0.5454,0.2337,0.55 Q0.2112,0.5521,0.2112,0.5558 Q0.2112,0.5574,0.2161,0.5612 Q0.2201,0.5637,0.2281,0.5637 Q0.2305,0.5637,0.2361,0.5633 T0.2442,0.5628 Q0.2474,0.5628,0.2498,0.5633 Q0.2635,0.5653,0.3133,0.5653 Q0.3261,0.5653,0.3301,0.5649 L0.3325,0.5649 Q0.3349,0.5649,0.3402,0.5657 T0.3494,0.5666 Q0.3542,0.5666,0.3598,0.5657 Q0.3663,0.5645,0.3695,0.5645 Q0.3735,0.5645,0.3775,0.5666 T0.3847,0.5695 Q0.3888,0.5707,0.3912,0.5709 T0.3968,0.5711 T0.4048,0.572 Q0.4096,0.5724,0.4165,0.5726 T0.4281,0.5734 T0.4378,0.5757 Q0.4418,0.5774,0.4522,0.5774 Q0.4562,0.5774,0.4655,0.5769 T0.4795,0.5765 Q0.4932,0.5765,0.4972,0.579 Q0.5028,0.5819,0.51,0.5819 Q0.5141,0.5819,0.5221,0.5809 T0.5341,0.5798 L0.5373,0.5798 Q0.5422,0.5798,0.557,0.5821 T0.5855,0.5844 L0.5936,0.5844 L0.5992,0.5844 T0.604,0.5848 T0.6076,0.5852 T0.6108,0.5859 T0.6137,0.5865 T0.6161,0.5873 T0.6181,0.5881 T0.6209,0.5896 L0.6233,0.591 Q0.6265,0.5927,0.6353,0.5927 L0.6402,0.5927 L0.645,0.5927 Q0.6723,0.5927,0.6948,0.6039 Q0.6988,0.606,0.7036,0.606 Q0.7076,0.606,0.7153,0.6045 T0.7261,0.6031 Q0.7309,0.6031,0.7454,0.6027 T0.7647,0.6022 Q0.7783,0.6022,0.808,0.608 L0.812,0.608 Q0.8169,0.608,0.8293,0.6062 T0.8474,0.6039 L0.8506,0.6039 Q0.857,0.6039,0.8655,0.6049 T0.8835,0.6074 T0.8972,0.6093 Q0.9036,0.6101,0.9213,0.6101 L0.9398,0.6101 L0.959,0.6101 L0.9767,0.6101 Q0.9976,0.6109,0.9976,0.6176 Q0.9976,0.6188,0.9968,0.6226 Q0.9952,0.6284,0.9671,0.6284 L0.959,0.6284 L0.9526,0.6284 Q0.9486,0.6284,0.9382,0.6302 T0.9205,0.6321 L0.9173,0.6321 Q0.9133,0.6317,0.9092,0.6317 Q0.9012,0.6317,0.8715,0.6346 Q0.8233,0.6387,0.7944,0.6421 Q0.7888,0.6429,0.7831,0.6429 Q0.7783,0.6429,0.7731,0.6425 T0.7663,0.6421 L0.7622,0.6421 Q0.7614,0.6425,0.7586,0.6425 T0.7474,0.6421 T0.7349,0.6416 Q0.7261,0.6416,0.7221,0.6429 Q0.7173,0.645,0.7032,0.646 T0.6711,0.6479 T0.6482,0.6491 Q0.645,0.6495,0.6418,0.6495 Q0.6353,0.6495,0.6273,0.6474 T0.6161,0.6454 Q0.612,0.6454,0.6088,0.6477 T0.6,0.6499 Q0.5912,0.6499,0.5494,0.6578 Q0.5422,0.6591,0.5373,0.6591 Q0.5341,0.6591,0.5281,0.6584 T0.5173,0.6578 L0.5124,0.6578 Q0.5004,0.6582,0.4747,0.6632 Q0.4675,0.6649,0.4398,0.6667 T0.3851,0.6703 T0.3566,0.6719 Q0.3534,0.6723,0.3406,0.6734 T0.3141,0.6757 T0.2948,0.6773 Q0.2908,0.6781,0.2819,0.6829 T0.2618,0.6877 Q0.2482,0.6877,0.2273,0.6958 T0.1992,0.7117 Q0.1976,0.7138,0.1976,0.7155 Q0.1976,0.7188,0.2032,0.7213 T0.2181,0.7258 T0.2289,0.7292 Q0.2337,0.7308,0.2378,0.7316 L0.2458,0.7333 T0.2522,0.7345 Q0.2747,0.7399,0.2835,0.7399 Q0.29,0.7399,0.3048,0.7408 T0.3253,0.7416 Q0.3277,0.7416,0.3297,0.7414 T0.3341,0.7412 L0.3598,0.7445 Q0.3639,0.7449,0.3663,0.7449 Q0.3695,0.7449,0.3751,0.7443 T0.3855,0.7437 L0.3904,0.7437 Q0.3984,0.7441,0.4141,0.7472 T0.4353,0.7507 Q0.4434,0.752,0.4434,0.7553 Q0.4434,0.7578,0.439,0.7605 T0.4297,0.764 Q0.4257,0.7648,0.4201,0.7655 T0.4076,0.7665 T0.3984,0.7673 Q0.3968,0.7673,0.3912,0.7677 T0.3815,0.7688 T0.3735,0.771 T0.3655,0.7727 Q0.3606,0.7727,0.3534,0.7708 T0.3458,0.769 L0.3446,0.769 Q0.3414,0.769,0.3297,0.7713 T0.3149,0.7735 Q0.3092,0.7735,0.296,0.7771 T0.2771,0.7831 Q0.2683,0.7872,0.2554,0.7885 Q0.253,0.7889,0.2325,0.7897 T0.2032,0.7914 Q0.2008,0.7918,0.198,0.792 T0.194,0.7924 T0.1912,0.7928 T0.1888,0.793 T0.1867,0.7934 T0.1851,0.7943 T0.1843,0.7953 T0.1835,0.7968 T0.1823,0.7984 T0.1815,0.8001 Q0.1815,0.8022,0.1847,0.8032 T0.1932,0.8053 T0.2008,0.8071 Q0.2072,0.8092,0.2265,0.8092 Q0.2361,0.8092,0.2586,0.8088 L0.2635,0.8088 Q0.2731,0.8088,0.2795,0.8098 T0.2928,0.8134 T0.302,0.8167 Q0.306,0.8179,0.3277,0.8183 T0.3542,0.8221 Q0.359,0.8246,0.3622,0.8246 Q0.3639,0.8246,0.3675,0.8237 T0.3751,0.8229 Q0.3968,0.8229,0.4048,0.8275 Q0.4088,0.8291,0.4161,0.8291 Q0.4225,0.8291,0.4353,0.8275 Q0.4369,0.827,0.4394,0.827 Q0.4474,0.827,0.4675,0.8345 Q0.4707,0.8358,0.4739,0.8358 Q0.4755,0.8358,0.4799,0.8353 T0.4876,0.8349 Q0.494,0.8349,0.5012,0.8362 L0.5076,0.837 T0.5133,0.8376 T0.5181,0.8382 T0.5221,0.8391 L0.5253,0.8399 T0.5277,0.8409 L0.5293,0.8422 T0.5301,0.8438 L0.5301,0.8461 Q0.5301,0.8499,0.5249,0.8511 T0.5112,0.8526 T0.5004,0.8532 Q0.4964,0.854,0.4851,0.8546 T0.4667,0.8565 Q0.4578,0.8577,0.441,0.8577 L0.4345,0.8577 L0.4289,0.8577 L0.4209,0.8577 Q0.4153,0.8582,0.4088,0.8586 T0.3968,0.8592 T0.3855,0.8594 T0.3755,0.8596 T0.3675,0.86 T0.3622,0.8602 Q0.3317,0.8635,0.3237,0.8635 Q0.2996,0.8635,0.2996,0.8681 Q0.2996,0.8698,0.3032,0.8733 T0.3068,0.8797 L0.3068,0.8822 Q0.3052,0.8859,0.2859,0.8859 Q0.2787,0.8859,0.2739,0.8851 L0.2699,0.8851 Q0.2659,0.8851,0.259,0.888 T0.2498,0.8913 Q0.2394,0.8946,0.2056,0.8971 Q0.2032,0.8971,0.1928,0.9002 T0.1703,0.9034 Q0.1526,0.9034,0.1353,0.9067 T0.1173,0.915 L0.1173,0.9158 Q0.1173,0.9166,0.1177,0.9175 T0.1189,0.9191 T0.1205,0.9204 T0.1229,0.9212 T0.1257,0.922 T0.1285,0.9226 T0.1309,0.9231 T0.1337,0.9235 T0.1365,0.9237 L0.1446,0.9237 T0.1554,0.9243 T0.1614,0.9268 T0.1659,0.9293 T0.1743,0.9303 T0.1823,0.9316 Q0.1863,0.932,0.1912,0.9332 T0.2028,0.9361 T0.2153,0.939 Q0.2233,0.9411,0.2297,0.9448 T0.2386,0.9494 Q0.2426,0.9506,0.2506,0.9506 Q0.253,0.9506,0.2594,0.9504 T0.2699,0.9502 Q0.2763,0.9502,0.2819,0.9511 Q0.2851,0.9511,0.2871,0.9529 T0.2892,0.9573 Q0.2892,0.9627,0.2811,0.9635 Q0.2434,0.9652,0.2337,0.9672 Q0.2257,0.9693,0.2241,0.9693 Q0.2217,0.9693,0.2096,0.9689 L0.2056,0.9689 Q0.1976,0.9689,0.1924,0.9699 T0.1787,0.9741 L0.1647,0.9793 Q0.1518,0.983,0.1285,0.983 L0.1261,0.983 L0.1237,0.983 Q0.1124,0.983,0.1076,0.9838 Q0.102,0.9851,0.0839,0.9896 T0.0602,0.9954 T0.0406,0.9971 T0.0153,0.9979 L0.0032,0.9979 Z",type:0}},"":{type:5,data:{d:"M0.9992,0.998 Q0.9992,1,0.9968,1 Q0.9521,1,0.9392,0.998 Q0.9335,0.997,0.9152,0.9921 T0.8913,0.9862 Q0.8873,0.9852,0.8783,0.9852 L0.8747,0.9852 L0.871,0.9852 Q0.8483,0.9852,0.8345,0.9812 Q0.8289,0.9792,0.8228,0.9773 T0.8135,0.9743 T0.8054,0.9723 T0.7948,0.9713 L0.7908,0.9713 L0.777,0.9713 T0.7656,0.9693 Q0.7616,0.9683,0.7498,0.9674 T0.7283,0.9664 L0.7186,0.9654 Q0.708,0.9644,0.708,0.9575 Q0.708,0.9545,0.7109,0.952 T0.7178,0.9486 L0.7315,0.9486 L0.7417,0.9486 L0.7502,0.9486 Q0.7575,0.9486,0.7599,0.9476 Q0.7616,0.9466,0.7685,0.9426 T0.7843,0.9377 Q0.7899,0.9357,0.8009,0.9332 T0.8175,0.9298 Q0.82,0.9288,0.8228,0.9283 T0.8277,0.9278 T0.8313,0.9273 T0.8341,0.9263 T0.8362,0.9258 Q0.8402,0.9219,0.854,0.9219 L0.8569,0.9219 L0.8597,0.9219 L0.8637,0.9219 Q0.88,0.9199,0.88,0.9159 L0.88,0.9149 Q0.88,0.913,0.8719,0.911 T0.852,0.9075 T0.8297,0.906 Q0.8224,0.906,0.8167,0.905 T0.8074,0.9031 T0.8001,0.9006 T0.794,0.8991 Q0.7599,0.8971,0.7494,0.8942 Q0.7461,0.8932,0.7397,0.8902 T0.7299,0.8872 L0.7267,0.8872 Q0.721,0.8882,0.7121,0.8882 Q0.6926,0.8882,0.691,0.8833 L0.691,0.8803 Q0.691,0.8773,0.6922,0.8749 T0.6955,0.8704 L0.6975,0.8684 Q0.6926,0.8655,0.6764,0.8655 Q0.6683,0.8655,0.6375,0.8625 Q0.6358,0.8625,0.629,0.862 T0.6148,0.8615 T0.5973,0.861 T0.5791,0.8605 L0.5718,0.8605 L0.5661,0.8605 L0.5596,0.8605 Q0.5426,0.8605,0.5337,0.8586 Q0.5264,0.8576,0.515,0.8571 T0.4996,0.8556 Q0.498,0.8556,0.4947,0.8551 T0.4882,0.8546 T0.4809,0.8541 T0.474,0.8531 T0.4692,0.8506 T0.4672,0.8467 Q0.4672,0.8437,0.468,0.8422 T0.4704,0.8398 T0.4736,0.8383 T0.4781,0.8368 T0.4838,0.8358 T0.4911,0.8353 T0.4988,0.8338 Q0.5069,0.8328,0.5142,0.8328 Q0.5174,0.8328,0.5215,0.8333 T0.5264,0.8338 Q0.5296,0.8338,0.532,0.8328 Q0.5523,0.8249,0.5604,0.8249 L0.5653,0.8249 Q0.5775,0.8269,0.5848,0.8269 Q0.5912,0.8269,0.5937,0.8259 Q0.6026,0.821,0.6253,0.821 Q0.6294,0.821,0.6334,0.822 T0.6383,0.8229 Q0.6399,0.8229,0.644,0.82 Q0.6504,0.817,0.6723,0.816 T0.6975,0.814 Q0.6999,0.814,0.7048,0.8121 T0.7129,0.8091 T0.7226,0.8071 T0.7372,0.8061 L0.7421,0.8061 Q0.7624,0.8071,0.7721,0.8071 Q0.7924,0.8071,0.7981,0.8051 Q0.8021,0.8032,0.807,0.8027 T0.8135,0.8017 T0.8151,0.8002 L0.8151,0.7992 Q0.8143,0.7962,0.8127,0.7957 T0.8045,0.7943 Q0.7997,0.7943,0.7964,0.7933 Q0.7883,0.7933,0.7676,0.7923 T0.7437,0.7903 Q0.7307,0.7893,0.7218,0.7844 Q0.7194,0.7834,0.7141,0.7819 L0.7036,0.7789 T0.693,0.7765 T0.6853,0.7755 Q0.6805,0.7755,0.6691,0.773 T0.6553,0.7705 Q0.6545,0.7705,0.6545,0.7715 Q0.6537,0.7715,0.65,0.7725 T0.6423,0.774 T0.635,0.7745 Q0.6294,0.7745,0.6257,0.773 T0.618,0.771 T0.6083,0.77 T0.601,0.7695 Q0.5985,0.7695,0.5921,0.769 T0.5795,0.7676 T0.5702,0.7666 Q0.5653,0.7656,0.5596,0.7616 T0.5539,0.7547 Q0.5539,0.7498,0.5645,0.7488 Q0.5693,0.7478,0.5852,0.7448 T0.6099,0.7418 L0.6148,0.7418 Q0.6196,0.7418,0.6253,0.7423 T0.6338,0.7428 L0.6399,0.7428 Q0.6431,0.7418,0.6488,0.7409 T0.6586,0.7394 T0.6659,0.7389 L0.6707,0.7389 Q0.6723,0.7399,0.6748,0.7399 Q0.6796,0.7399,0.6946,0.7389 T0.7161,0.7379 Q0.7251,0.7379,0.7478,0.7319 Q0.7494,0.7319,0.7539,0.7315 T0.762,0.73 T0.7697,0.727 T0.7818,0.723 T0.7948,0.7196 T0.7997,0.7151 Q0.7997,0.7141,0.7989,0.7132 Q0.7924,0.7062,0.7717,0.6978 T0.738,0.6894 Q0.7267,0.6894,0.717,0.6845 T0.7048,0.6795 Q0.6975,0.6785,0.6711,0.6766 T0.6431,0.6746 Q0.6415,0.6736,0.6144,0.6721 T0.5596,0.6686 T0.5247,0.6657 Q0.4996,0.6607,0.4874,0.6597 L0.4834,0.6597 Q0.4785,0.6597,0.4724,0.6607 T0.4631,0.6617 Q0.4574,0.6617,0.4501,0.6597 Q0.4088,0.6518,0.4006,0.6518 Q0.3933,0.6518,0.3901,0.6499 T0.3844,0.6479 T0.3739,0.6499 T0.3585,0.6518 L0.352,0.6518 Q0.3471,0.6508,0.335,0.6503 T0.3122,0.6494 T0.2912,0.6479 T0.2766,0.6449 Q0.2733,0.6439,0.2668,0.6439 Q0.2628,0.6439,0.2543,0.6444 T0.2425,0.6449 T0.2368,0.6439 L0.2344,0.6439 Q0.2336,0.6439,0.2283,0.6444 T0.2182,0.6449 Q0.2117,0.6449,0.2052,0.6439 Q0.1768,0.6409,0.1281,0.637 Q0.0989,0.634,0.0916,0.634 L0.0835,0.634 L0.0795,0.634 Q0.0722,0.634,0.0616,0.632 T0.0479,0.6301 Q0.0462,0.6301,0.0406,0.6306 T0.0308,0.6311 Q0.0032,0.6311,0.0008,0.6231 Q0,0.6202,0,0.6182 Q0,0.6083,0.0227,0.6083 Q0.03,0.6073,0.0422,0.6073 Q0.0487,0.6073,0.0608,0.6078 T0.0787,0.6083 Q0.0973,0.6083,0.103,0.6073 Q0.1062,0.6063,0.1131,0.6053 T0.1253,0.6039 T0.1375,0.6024 T0.1492,0.6014 L0.1533,0.6014 Q0.1598,0.6024,0.1723,0.6044 T0.189,0.6063 Q0.1906,0.6063,0.1922,0.6053 Q0.2214,0.6004,0.236,0.6004 Q0.2409,0.6004,0.2551,0.6009 T0.2741,0.6014 Q0.2782,0.6014,0.2859,0.6024 T0.2968,0.6034 Q0.3009,0.6034,0.3041,0.6024 Q0.3277,0.5905,0.356,0.5905 L0.3613,0.5905 L0.3666,0.5905 Q0.3731,0.5905,0.3755,0.5895 Q0.382,0.5856,0.3844,0.5846 T0.3938,0.5831 T0.4144,0.5826 T0.4428,0.5801 T0.4631,0.5776 L0.4663,0.5776 Q0.4704,0.5776,0.4785,0.5786 T0.4899,0.5796 Q0.4964,0.5796,0.5012,0.5767 Q0.5069,0.5737,0.5223,0.5737 Q0.5272,0.5737,0.5369,0.5742 T0.5499,0.5747 Q0.558,0.5747,0.5612,0.5737 Q0.5661,0.5717,0.5714,0.5712 T0.5835,0.5702 T0.5945,0.5692 T0.6018,0.5687 L0.6062,0.5687 T0.6095,0.5682 T0.6148,0.5678 Q0.6172,0.5668,0.6196,0.5653 T0.6245,0.5633 T0.631,0.5628 T0.6407,0.5638 T0.6504,0.5648 T0.6594,0.5638 T0.6675,0.5628 L0.6707,0.5628 L0.6861,0.5628 Q0.7364,0.5628,0.7494,0.5608 L0.7567,0.5608 L0.7652,0.5608 L0.7729,0.5608 Q0.7794,0.5608,0.7818,0.5589 Q0.7851,0.5569,0.7859,0.5559 Q0.7835,0.5539,0.7656,0.5519 Q0.7121,0.547,0.6975,0.543 Q0.6934,0.541,0.6853,0.5396 L0.6691,0.5366 T0.6525,0.5336 T0.6391,0.5312 Q0.6367,0.5302,0.6245,0.5257 T0.6034,0.5213 L0.5977,0.5213 Q0.5945,0.5223,0.5904,0.5223 Q0.5839,0.5223,0.5787,0.5208 T0.5685,0.5183 T0.5596,0.5173 Q0.558,0.5173,0.5552,0.5168 T0.5495,0.5163 L0.5434,0.5163 T0.5373,0.5158 T0.532,0.5148 T0.5284,0.5129 T0.5272,0.5104 L0.5272,0.5074 Q0.5304,0.5015,0.5377,0.499 T0.5629,0.4965 Q0.5734,0.4955,0.5811,0.4946 T0.5953,0.4916 T0.605,0.4896 Q0.6083,0.4886,0.6123,0.4886 Q0.6148,0.4886,0.6225,0.4891 T0.635,0.4896 L0.6456,0.4896 Q0.6837,0.4857,0.6861,0.4857 Q0.7226,0.4768,0.7283,0.4768 Q0.7307,0.4768,0.732,0.4773 T0.7372,0.4777 Q0.7502,0.4777,0.7721,0.4758 Q0.7753,0.4748,0.777,0.4738 Q0.7745,0.4718,0.768,0.4708 Q0.7599,0.4688,0.7445,0.4688 Q0.7405,0.4688,0.7324,0.4693 T0.721,0.4698 Q0.7056,0.4698,0.6999,0.4679 Q0.6861,0.4629,0.6626,0.4619 Q0.6586,0.4609,0.6533,0.4604 T0.6419,0.459 T0.6314,0.456 T0.6269,0.452 Q0.6269,0.451,0.6302,0.4491 Q0.6358,0.4451,0.6525,0.4416 T0.6788,0.4382 L0.6845,0.4382 L0.6902,0.4382 Q0.7064,0.4382,0.7145,0.4362 Q0.7202,0.4342,0.7307,0.4342 L0.7356,0.4342 L0.7409,0.4342 L0.7453,0.4342 Q0.7543,0.4342,0.7607,0.4332 Q0.7778,0.4313,0.7847,0.4288 T0.7932,0.4248 T0.7972,0.4169 T0.8045,0.4045 L0.8094,0.3986 T0.8135,0.3942 L0.8167,0.3912 T0.8191,0.3887 T0.8204,0.3867 T0.8208,0.3848 Q0.8208,0.3818,0.8167,0.3739 Q0.8127,0.3689,0.8054,0.3635 T0.7924,0.3556 T0.7778,0.3497 T0.768,0.3462 Q0.764,0.3442,0.7478,0.3427 T0.7267,0.3383 Q0.7234,0.3363,0.7044,0.3348 T0.6805,0.3323 L0.6764,0.3323 T0.6679,0.3328 T0.6586,0.3333 Q0.6521,0.3333,0.648,0.3314 Q0.6391,0.3264,0.6294,0.3264 Q0.6229,0.3264,0.6156,0.3294 Q0.6115,0.3304,0.6042,0.3304 Q0.5977,0.3304,0.5888,0.3289 T0.5738,0.3264 T0.5584,0.3225 L0.5491,0.3195 Q0.5418,0.3185,0.5162,0.3155 T0.4895,0.3121 T0.4826,0.3116 T0.4716,0.3111 T0.4607,0.3096 T0.4513,0.3066 T0.4477,0.3017 Q0.4477,0.2997,0.4485,0.2977 Q0.4526,0.2898,0.4611,0.2878 T0.4842,0.2859 Q0.4882,0.2859,0.4943,0.2864 T0.5028,0.2868 Q0.5118,0.2868,0.5215,0.2829 Q0.5401,0.276,0.5734,0.276 Q0.5831,0.276,0.5872,0.277 L0.5904,0.277 T0.5949,0.2745 T0.6034,0.272 Q0.631,0.269,0.6407,0.2661 Q0.6448,0.2641,0.6488,0.2641 T0.6573,0.2656 T0.6634,0.2671 Q0.6659,0.2671,0.6675,0.2651 Q0.6723,0.2601,0.6886,0.2552 T0.7137,0.2502 L0.7153,0.2502 L0.7178,0.2502 Q0.7218,0.2502,0.7279,0.2493 T0.7417,0.2468 T0.7526,0.2453 Q0.8208,0.2354,0.8281,0.2354 Q0.8337,0.2354,0.8394,0.2344 T0.8496,0.2315 T0.854,0.2265 Q0.854,0.2216,0.8443,0.2176 Q0.8354,0.2127,0.8216,0.2102 T0.7972,0.2072 T0.777,0.2067 T0.7648,0.2057 Q0.7632,0.2047,0.7498,0.2038 T0.7202,0.2018 T0.6983,0.1998 Q0.6918,0.1998,0.676,0.1949 T0.6537,0.1899 Q0.6496,0.1899,0.6472,0.1919 Q0.6342,0.1968,0.6123,0.1968 Q0.5961,0.1968,0.5912,0.1929 Q0.5904,0.1919,0.5892,0.1919 T0.5823,0.1944 T0.5722,0.1968 T0.5637,0.1949 Q0.5556,0.1909,0.5158,0.1869 Q0.5109,0.1869,0.5032,0.1835 T0.4915,0.18 Q0.4907,0.18,0.4891,0.181 Q0.4793,0.182,0.455,0.182 Q0.4177,0.182,0.4015,0.1771 Q0.3901,0.1741,0.3779,0.1741 Q0.3747,0.1741,0.369,0.1746 T0.3609,0.1751 Q0.3569,0.1751,0.3536,0.1741 Q0.3512,0.1741,0.3459,0.1736 T0.3358,0.1726 T0.3256,0.1716 T0.3167,0.1696 T0.3106,0.1662 Q0.3082,0.1632,0.3082,0.1592 Q0.3082,0.1543,0.3114,0.1508 T0.3204,0.1474 L0.3236,0.1474 Q0.3301,0.1494,0.3333,0.1494 Q0.339,0.1494,0.3496,0.1454 Q0.3674,0.1385,0.3869,0.1385 Q0.395,0.1385,0.4011,0.137 T0.4116,0.1355 T0.4197,0.1375 T0.425,0.1395 Q0.429,0.1395,0.4355,0.1365 Q0.4631,0.1266,0.4882,0.1266 Q0.5126,0.1266,0.5337,0.1246 Q0.5369,0.1246,0.5458,0.1207 T0.5661,0.1167 L0.5693,0.1167 Q0.5791,0.1177,0.5852,0.1187 T0.5921,0.1197 Q0.5945,0.1197,0.6002,0.1167 Q0.6026,0.1147,0.605,0.1123 T0.6091,0.1093 T0.6156,0.1088 T0.6318,0.1098 Q0.6456,0.1108,0.6569,0.1137 T0.6707,0.1167 Q0.674,0.1167,0.6772,0.1147 Q0.6821,0.1108,0.6946,0.1083 T0.721,0.1044 T0.7453,0.1029 L0.7526,0.1029 Q0.7583,0.1039,0.7652,0.1053 T0.7753,0.1068 Q0.7778,0.1068,0.7802,0.1058 Q0.7981,0.1019,0.8143,0.1019 Q0.8175,0.1019,0.8439,0.0964 T0.8735,0.091 Q0.8759,0.091,0.8836,0.089 T0.8938,0.0851 Q0.8929,0.0841,0.8905,0.0841 Q0.8832,0.0821,0.8735,0.0821 Q0.8694,0.0821,0.8629,0.0826 T0.854,0.0831 Q0.8508,0.0831,0.8491,0.0821 Q0.8475,0.0821,0.8171,0.0811 T0.7802,0.0781 T0.7571,0.0737 T0.7332,0.0712 Q0.7299,0.0712,0.7247,0.0717 T0.7161,0.0722 L0.7064,0.0722 Q0.7032,0.0712,0.7003,0.0707 T0.6959,0.0692 T0.693,0.0678 T0.6914,0.0663 T0.6902,0.0648 T0.689,0.0643 L0.6869,0.0643 L0.6845,0.0643 L0.6821,0.0643 Q0.6553,0.0643,0.6553,0.0554 T0.6796,0.0465 L0.6813,0.0465 L0.6845,0.0465 Q0.6918,0.0425,0.717,0.0376 Q0.7226,0.0366,0.7267,0.0356 T0.7324,0.0336 T0.7376,0.0317 T0.747,0.0297 Q0.7518,0.0287,0.7551,0.0287 T0.762,0.0297 T0.768,0.0307 L0.7729,0.0307 Q0.7802,0.0277,0.7997,0.0267 T0.8224,0.0237 Q0.8273,0.0227,0.8341,0.0223 T0.8475,0.0193 T0.8654,0.0143 T0.8873,0.0079 Q0.9002,0.003,0.9331,0.004 T0.97,0.004 Q0.9838,0,0.9976,0.001 Q1,0.001,1,0.003 Z M0.9935,0.996 L0.9951,0.0049 Q0.9822,0.0049,0.9716,0.0079 Q0.9659,0.0099,0.9327,0.0089 T0.8897,0.0119 Q0.8775,0.0158,0.8666,0.0183 T0.85,0.0237 Q0.8418,0.0267,0.8341,0.0272 T0.8248,0.0277 Q0.82,0.0297,0.8001,0.0312 T0.7745,0.0346 Q0.7697,0.0356,0.7664,0.0356 Q0.764,0.0356,0.7603,0.0341 T0.7534,0.0326 Q0.751,0.0326,0.7478,0.0336 Q0.7429,0.0346,0.7397,0.0356 T0.7344,0.0376 T0.7283,0.0401 T0.7178,0.0425 Q0.6926,0.0465,0.6878,0.0495 Q0.6845,0.0514,0.6764,0.0514 L0.6723,0.0514 L0.6691,0.0514 Q0.6602,0.0514,0.6602,0.0554 Q0.6602,0.0574,0.6659,0.0579 T0.6796,0.0589 T0.691,0.0603 T0.6967,0.0643 T0.7072,0.0673 Q0.7121,0.0682,0.7153,0.0682 T0.7238,0.0678 T0.7332,0.0673 Q0.7413,0.0673,0.7579,0.0692 T0.7818,0.0742 Q0.7867,0.0752,0.8171,0.0762 T0.8508,0.0781 L0.852,0.0781 T0.8601,0.0776 T0.8719,0.0772 Q0.8832,0.0772,0.8921,0.0791 Q0.8994,0.0811,0.8994,0.0841 T0.8933,0.0895 T0.8812,0.094 T0.8735,0.0959 T0.8451,0.1014 T0.8143,0.1068 Q0.7989,0.1068,0.7818,0.1098 Q0.7778,0.1108,0.7745,0.1108 T0.768,0.1103 T0.7603,0.1088 T0.7518,0.1068 L0.7461,0.1068 Q0.7315,0.1068,0.7088,0.1103 T0.6805,0.1177 Q0.6756,0.1207,0.6699,0.1207 Q0.6667,0.1207,0.6545,0.1177 T0.631,0.1147 Q0.6269,0.1137,0.6225,0.1133 T0.616,0.1128 L0.6123,0.1128 T0.6103,0.1133 L0.6083,0.1157 T0.6034,0.1197 Q0.5961,0.1246,0.5921,0.1246 Q0.5904,0.1246,0.5835,0.1231 T0.5693,0.1217 L0.5661,0.1217 Q0.558,0.1217,0.5535,0.1231 T0.5446,0.1266 T0.5345,0.1296 Q0.5126,0.1316,0.4882,0.1316 T0.438,0.1405 Q0.4298,0.1434,0.425,0.1434 Q0.4209,0.1434,0.4173,0.1419 T0.4112,0.1405 T0.4027,0.1419 T0.3869,0.1434 Q0.3682,0.1434,0.3512,0.1494 Q0.3398,0.1533,0.3333,0.1533 Q0.3285,0.1533,0.3228,0.1513 L0.3212,0.1513 Q0.3179,0.1513,0.3155,0.1538 T0.3131,0.1592 Q0.3131,0.1612,0.3147,0.1632 Q0.3171,0.1652,0.3232,0.1667 T0.3406,0.1691 T0.3544,0.1701 L0.3601,0.1701 L0.3678,0.1701 L0.3771,0.1701 Q0.3909,0.1701,0.4031,0.1731 Q0.4177,0.178,0.4558,0.178 Q0.4793,0.178,0.4882,0.1761 L0.4915,0.1761 Q0.498,0.1761,0.5061,0.179 T0.5158,0.183 Q0.5166,0.183,0.5231,0.1835 T0.5341,0.1845 T0.545,0.1855 T0.5572,0.1874 T0.5661,0.1909 Q0.5677,0.1919,0.5702,0.1919 T0.5791,0.1894 T0.588,0.1869 Q0.5921,0.1869,0.5945,0.1899 Q0.5977,0.1919,0.6123,0.1919 Q0.6334,0.1919,0.6448,0.1879 Q0.6488,0.186,0.6537,0.186 Q0.6626,0.186,0.6784,0.1909 T0.6983,0.1958 Q0.704,0.1968,0.7206,0.1973 T0.7506,0.1993 T0.7689,0.2018 L0.7705,0.2018 L0.7741,0.2018 L0.7786,0.2018 Q0.8248,0.2018,0.8475,0.2136 Q0.8597,0.2196,0.8597,0.2255 T0.8483,0.2359 T0.8281,0.2404 Q0.8208,0.2404,0.7534,0.2493 Q0.7502,0.2502,0.7425,0.2512 T0.7287,0.2532 T0.7178,0.2542 L0.7153,0.2542 L0.7137,0.2542 Q0.7064,0.2542,0.6906,0.2591 T0.6715,0.2681 T0.6626,0.272 Q0.6594,0.272,0.6541,0.2705 T0.6464,0.269 T0.6431,0.27 Q0.6318,0.273,0.6034,0.276 Q0.6018,0.276,0.5998,0.2774 T0.5957,0.2799 T0.5904,0.2809 L0.5856,0.2809 Q0.5823,0.2799,0.575,0.2799 Q0.541,0.2799,0.5239,0.2868 Q0.5134,0.2908,0.5028,0.2908 Q0.4996,0.2908,0.4935,0.2903 T0.4842,0.2898 Q0.4704,0.2898,0.4635,0.2918 T0.4534,0.2997 L0.4534,0.3007 Q0.4534,0.3037,0.459,0.3046 T0.4753,0.3066 T0.4899,0.3076 Q0.4907,0.3076,0.5166,0.3106 T0.5507,0.3155 Q0.5921,0.3264,0.605,0.3264 Q0.6107,0.3264,0.6131,0.3254 Q0.6212,0.3225,0.6294,0.3225 Q0.6407,0.3225,0.6513,0.3274 Q0.6529,0.3294,0.6569,0.3294 Q0.6594,0.3294,0.665,0.3284 T0.6748,0.3274 T0.6821,0.3284 Q0.6861,0.3294,0.6967,0.3299 T0.7165,0.3314 T0.7299,0.3343 Q0.7324,0.3363,0.7486,0.3383 T0.7697,0.3422 Q0.7713,0.3432,0.7774,0.3452 T0.7887,0.3492 T0.8005,0.3546 T0.8127,0.3625 T0.8208,0.3719 Q0.8256,0.3798,0.8256,0.3848 Q0.8256,0.3877,0.8236,0.3902 T0.8171,0.3976 T0.809,0.4075 T0.8021,0.4189 T0.7968,0.4273 T0.7867,0.4322 T0.7616,0.4382 Q0.7543,0.4392,0.7437,0.4392 L0.7364,0.4392 L0.7299,0.4392 Q0.7202,0.4392,0.7161,0.4402 Q0.7072,0.4431,0.691,0.4431 L0.6845,0.4431 L0.6788,0.4431 Q0.6707,0.4431,0.6545,0.4461 T0.6334,0.452 Q0.6399,0.456,0.6626,0.457 Q0.6878,0.458,0.7024,0.4639 Q0.7064,0.4649,0.7186,0.4649 L0.7295,0.4649 L0.7413,0.4649 Q0.7591,0.4649,0.7697,0.4669 Q0.7818,0.4688,0.7818,0.4728 Q0.7818,0.4748,0.7798,0.4763 T0.7753,0.4787 L0.7737,0.4797 L0.7729,0.4797 Q0.7494,0.4827,0.7388,0.4827 Q0.7332,0.4827,0.7307,0.4817 L0.7291,0.4817 Q0.7226,0.4817,0.6878,0.4896 Q0.6829,0.4906,0.6772,0.4911 T0.6618,0.4921 T0.646,0.4931 T0.6342,0.4936 T0.6212,0.4931 T0.6115,0.4926 Q0.6083,0.4926,0.6058,0.4931 T0.5969,0.4955 T0.5819,0.499 T0.5629,0.5005 Q0.5572,0.5005,0.5527,0.501 T0.545,0.502 T0.5397,0.503 T0.5361,0.5045 T0.5337,0.5064 T0.5328,0.5094 L0.532,0.5094 Q0.532,0.5104,0.5337,0.5109 T0.5381,0.5114 T0.5438,0.5119 T0.5515,0.5124 L0.5604,0.5124 Q0.5661,0.5134,0.5746,0.5153 T0.5912,0.5173 L0.5977,0.5173 L0.6026,0.5173 Q0.6139,0.5173,0.6273,0.5218 T0.6407,0.5272 Q0.6448,0.5282,0.6683,0.5321 T0.6991,0.5381 Q0.7137,0.543,0.7664,0.548 Q0.7908,0.55,0.7908,0.5559 Q0.7908,0.5589,0.7859,0.5628 Q0.781,0.5658,0.7713,0.5658 Q0.7689,0.5658,0.7628,0.5653 T0.7543,0.5648 T0.7502,0.5658 Q0.7364,0.5678,0.6878,0.5678 Q0.674,0.5678,0.6699,0.5668 L0.6683,0.5668 Q0.6659,0.5668,0.6606,0.5678 T0.6513,0.5687 Q0.6464,0.5687,0.6391,0.5678 Q0.6334,0.5668,0.6302,0.5668 T0.6241,0.5687 T0.6164,0.5717 Q0.6123,0.5727,0.6099,0.5727 L0.6062,0.5727 T0.6022,0.5732 T0.5953,0.5737 Q0.5904,0.5747,0.5839,0.5747 T0.5726,0.5752 T0.5629,0.5776 T0.5458,0.5796 Q0.5418,0.5796,0.5324,0.5791 T0.5191,0.5786 Q0.5077,0.5786,0.5045,0.5806 Q0.498,0.5836,0.4899,0.5836 Q0.4858,0.5836,0.4777,0.5826 T0.4655,0.5816 L0.4631,0.5816 Q0.4582,0.5816,0.4436,0.5841 T0.4144,0.5865 L0.4051,0.5865 L0.3986,0.5865 T0.3933,0.587 T0.3897,0.5875 T0.3869,0.5885 T0.3844,0.5895 T0.3812,0.591 T0.3779,0.5925 Q0.3739,0.5955,0.3633,0.5955 L0.3585,0.5955 L0.3536,0.5955 Q0.3277,0.5955,0.3066,0.6053 Q0.3017,0.6083,0.296,0.6083 Q0.2912,0.6083,0.2839,0.6068 T0.2741,0.6053 Q0.2693,0.6053,0.2547,0.6048 T0.236,0.6044 Q0.2222,0.6044,0.193,0.6103 L0.1882,0.6103 Q0.1825,0.6103,0.1703,0.6083 T0.1525,0.6063 L0.15,0.6063 Q0.1436,0.6063,0.135,0.6073 T0.1168,0.6098 T0.1038,0.6113 Q0.0973,0.6123,0.0787,0.6123 L0.06,0.6123 L0.0414,0.6123 L0.0235,0.6123 Q0.0049,0.6133,0.0049,0.6172 L0.0057,0.6222 Q0.0073,0.6261,0.043,0.6261 L0.0454,0.6261 L0.0479,0.6261 Q0.0527,0.6261,0.0633,0.6281 T0.0803,0.6301 L0.0835,0.6301 L0.0916,0.6301 Q0.0998,0.6301,0.129,0.632 Q0.1768,0.636,0.206,0.64 Q0.2117,0.6409,0.2165,0.6409 Q0.2206,0.6409,0.2263,0.6405 T0.2336,0.64 L0.2384,0.64 L0.2409,0.64 T0.251,0.6395 T0.2644,0.639 Q0.2741,0.639,0.279,0.6409 Q0.283,0.6429,0.2972,0.6439 T0.3293,0.6459 T0.3528,0.6469 L0.3577,0.6469 Q0.3642,0.6469,0.3723,0.6449 T0.3844,0.6429 Q0.3901,0.6429,0.3933,0.6454 T0.4006,0.6479 Q0.4088,0.6479,0.4517,0.6558 Q0.4582,0.6568,0.4623,0.6568 Q0.4655,0.6568,0.4716,0.6563 T0.4826,0.6558 L0.4882,0.6558 Q0.5004,0.6558,0.5255,0.6607 Q0.5328,0.6627,0.5604,0.6647 T0.6152,0.6682 T0.644,0.6696 T0.6719,0.6721 T0.7056,0.6756 Q0.7113,0.6756,0.7198,0.6805 T0.738,0.6855 Q0.7453,0.6855,0.7551,0.6879 T0.7741,0.6939 T0.7912,0.7018 T0.8029,0.7102 Q0.8054,0.7132,0.8054,0.7151 Q0.8054,0.7191,0.8009,0.7216 T0.7908,0.7255 T0.779,0.7285 T0.7721,0.731 Q0.7672,0.7329,0.7632,0.7339 T0.7551,0.7354 T0.7486,0.7369 Q0.7478,0.7369,0.7445,0.7379 T0.7388,0.7394 T0.7324,0.7404 L0.7242,0.7413 T0.7161,0.7418 Q0.7105,0.7418,0.6955,0.7428 T0.6748,0.7438 L0.6699,0.7438 L0.6667,0.7438 Q0.6659,0.7438,0.6407,0.7468 Q0.6367,0.7478,0.6334,0.7478 T0.6245,0.7468 T0.6148,0.7458 L0.6099,0.7458 Q0.6018,0.7468,0.5864,0.7498 T0.5653,0.7532 T0.5596,0.7557 Q0.5596,0.7596,0.571,0.7616 Q0.5742,0.7626,0.5803,0.7631 T0.5929,0.7641 T0.6018,0.7656 L0.6087,0.7656 T0.6192,0.7666 T0.6277,0.7695 Q0.631,0.7705,0.6342,0.7705 Q0.6383,0.7705,0.6452,0.7685 T0.6537,0.7666 L0.6553,0.7666 Q0.6602,0.7666,0.6711,0.769 T0.6853,0.7715 Q0.691,0.7715,0.7048,0.775 T0.7242,0.7814 Q0.7324,0.7854,0.7445,0.7864 Q0.7478,0.7864,0.768,0.7873 T0.7972,0.7893 Q0.7989,0.7893,0.8017,0.7898 T0.8054,0.7903 L0.8082,0.7903 T0.811,0.7908 T0.8131,0.7913 T0.8151,0.7918 L0.8167,0.7928 T0.8179,0.7943 T0.8191,0.7957 T0.8204,0.7977 T0.8208,0.8002 Q0.8208,0.8032,0.8171,0.8051 T0.8074,0.8081 T0.7997,0.8091 Q0.7932,0.8121,0.7737,0.8121 Q0.7664,0.8121,0.7413,0.8111 L0.7364,0.8111 Q0.7275,0.8111,0.7214,0.8121 T0.7084,0.8155 T0.6991,0.819 Q0.6934,0.82,0.6723,0.8205 T0.6472,0.8239 Q0.6423,0.8269,0.6375,0.8269 Q0.6358,0.8269,0.6338,0.8264 T0.6294,0.8254 T0.6253,0.8249 Q0.6042,0.8249,0.5961,0.8289 Q0.5921,0.8318,0.5839,0.8318 Q0.5783,0.8318,0.5645,0.8299 L0.5604,0.8299 Q0.5531,0.8299,0.5337,0.8368 Q0.5296,0.8378,0.5255,0.8378 Q0.5239,0.8378,0.5195,0.8373 T0.5118,0.8368 Q0.5061,0.8368,0.4996,0.8388 Q0.4947,0.8388,0.4882,0.8398 Q0.4777,0.8417,0.4753,0.8427 T0.4728,0.8467 Q0.4728,0.8487,0.4769,0.8492 T0.4886,0.8501 T0.5004,0.8516 Q0.5036,0.8516,0.515,0.8521 T0.5345,0.8546 Q0.5426,0.8556,0.5596,0.8556 L0.5649,0.8556 L0.5702,0.8556 L0.5791,0.8556 Q0.5921,0.8566,0.6135,0.8571 T0.6383,0.8586 Q0.6683,0.8615,0.6764,0.8615 L0.6776,0.8615 L0.6788,0.8615 Q0.7032,0.8615,0.7032,0.8684 Q0.7032,0.8714,0.6995,0.8749 T0.6959,0.8803 L0.6959,0.8813 Q0.6991,0.8843,0.7153,0.8843 Q0.7218,0.8843,0.7259,0.8833 L0.7299,0.8833 Q0.7324,0.8833,0.7348,0.8838 T0.7393,0.8848 T0.7433,0.8863 L0.7474,0.8882 T0.751,0.8892 Q0.7616,0.8922,0.7948,0.8952 Q0.7981,0.8952,0.8082,0.8981 T0.8297,0.9011 T0.8528,0.9026 T0.8747,0.907 T0.8856,0.9149 L0.8856,0.9159 Q0.8856,0.9179,0.8848,0.9189 T0.8828,0.9209 T0.88,0.9228 T0.8767,0.9243 T0.8731,0.9248 T0.8698,0.9253 T0.8666,0.9258 L0.8646,0.9258 Q0.8621,0.9258,0.8577,0.9263 T0.85,0.9268 T0.8439,0.9273 T0.8402,0.9278 Q0.8386,0.9298,0.8358,0.9308 T0.8305,0.9322 T0.8244,0.9332 T0.8183,0.9337 Q0.8135,0.9347,0.8025,0.9372 T0.7859,0.9416 Q0.7778,0.9436,0.7717,0.9471 T0.7624,0.9515 Q0.7575,0.9535,0.7486,0.9535 Q0.7461,0.9535,0.7397,0.953 T0.7291,0.9525 Q0.7234,0.9525,0.7186,0.953 T0.7137,0.957 T0.7194,0.9614 Q0.7567,0.9634,0.7664,0.9654 Q0.7745,0.9674,0.7762,0.9674 L0.7908,0.9674 Q0.7924,0.9664,0.7948,0.9664 Q0.8029,0.9664,0.8082,0.9679 T0.8224,0.9723 T0.8362,0.9773 Q0.8483,0.9812,0.871,0.9812 L0.8751,0.9812 Q0.8873,0.9812,0.8929,0.9822 T0.9165,0.9876 T0.9408,0.9931 Q0.9513,0.996,0.9935,0.996 Z M0.9968,0.998 L0.9976,0.003 Q0.9838,0.002,0.9708,0.0059 Q0.9659,0.0069,0.9327,0.0059 T0.8881,0.0099 Q0.8767,0.0138,0.8658,0.0163 T0.8491,0.0218 Q0.8418,0.0247,0.8341,0.0247 T0.8232,0.0257 Q0.8191,0.0277,0.7997,0.0292 T0.7737,0.0326 Q0.7697,0.0336,0.7672,0.0336 T0.7612,0.0321 T0.7543,0.0307 T0.747,0.0317 Q0.7397,0.0326,0.7336,0.0356 T0.717,0.0406 Q0.6918,0.0445,0.6861,0.0475 Q0.6845,0.0485,0.6772,0.0485 T0.6638,0.05 T0.6577,0.0549 T0.6642,0.0598 T0.6796,0.0613 T0.6902,0.0623 Q0.691,0.0623,0.6946,0.0658 T0.7064,0.0702 L0.7161,0.0702 Q0.7194,0.0702,0.7242,0.0697 T0.7332,0.0692 Q0.7413,0.0692,0.7579,0.0717 T0.781,0.0762 Q0.7867,0.0781,0.8171,0.0786 T0.85,0.0801 L0.8532,0.0801 Q0.8548,0.0801,0.8613,0.0796 T0.8727,0.0791 Q0.8832,0.0791,0.8913,0.0811 Q0.897,0.0831,0.897,0.0851 Q0.897,0.088,0.8873,0.0905 T0.8735,0.093 Q0.871,0.093,0.8447,0.0984 T0.8143,0.1039 Q0.7981,0.1039,0.781,0.1078 Q0.7778,0.1088,0.7745,0.1088 T0.7644,0.1073 T0.7518,0.1048 L0.7453,0.1048 Q0.7299,0.1048,0.7076,0.1083 T0.6788,0.1157 Q0.6748,0.1187,0.6699,0.1187 Q0.6675,0.1187,0.6557,0.1157 T0.6318,0.1118 Q0.6164,0.1108,0.6135,0.1108 T0.6095,0.1113 T0.6067,0.1142 T0.6018,0.1187 Q0.5953,0.1227,0.5921,0.1227 Q0.5904,0.1227,0.5839,0.1212 T0.5693,0.1187 L0.5661,0.1187 Q0.558,0.1187,0.5527,0.1207 T0.5434,0.1246 T0.5337,0.1266 Q0.5126,0.1296,0.4882,0.1296 T0.4371,0.1385 Q0.4298,0.1414,0.425,0.1414 Q0.4225,0.1414,0.4189,0.1395 T0.4112,0.1375 Q0.4079,0.1375,0.4019,0.1395 T0.3869,0.1414 Q0.3682,0.1414,0.3504,0.1474 Q0.3398,0.1513,0.3333,0.1513 Q0.3293,0.1513,0.3228,0.1494 L0.3204,0.1494 Q0.3179,0.1494,0.3155,0.1508 T0.3118,0.1543 T0.3106,0.1592 T0.3127,0.1642 T0.32,0.1677 T0.3305,0.1701 T0.3435,0.1716 T0.3544,0.1721 Q0.3569,0.1731,0.3601,0.1731 Q0.3625,0.1731,0.3686,0.1726 T0.3779,0.1721 Q0.3901,0.1721,0.4023,0.1751 Q0.4177,0.18,0.455,0.18 Q0.4793,0.18,0.4882,0.178 L0.4915,0.178 Q0.4964,0.178,0.5045,0.1815 T0.5158,0.185 Q0.5564,0.1889,0.5645,0.1929 Q0.5677,0.1939,0.571,0.1939 Q0.575,0.1939,0.5807,0.1919 T0.5888,0.1899 T0.5929,0.1909 Q0.5969,0.1949,0.6123,0.1949 Q0.6334,0.1949,0.6456,0.1899 Q0.6488,0.1879,0.6537,0.1879 Q0.661,0.1879,0.6772,0.1929 T0.6983,0.1978 Q0.704,0.1988,0.7206,0.1998 T0.7502,0.2018 T0.7664,0.2038 Q0.7672,0.2038,0.7818,0.2043 T0.8151,0.2067 T0.8459,0.2156 Q0.8573,0.2206,0.8573,0.2255 Q0.8573,0.2295,0.8516,0.2324 T0.8394,0.2369 T0.8281,0.2384 Q0.8208,0.2384,0.7526,0.2473 Q0.7494,0.2483,0.7421,0.2493 T0.7287,0.2512 T0.7178,0.2522 L0.7153,0.2522 L0.7137,0.2522 Q0.7056,0.2522,0.6898,0.2572 T0.6691,0.2671 Q0.6667,0.269,0.6634,0.269 Q0.661,0.269,0.6557,0.2681 T0.6472,0.2671 Q0.6448,0.2671,0.6415,0.2681 Q0.631,0.271,0.6034,0.274 Q0.5994,0.274,0.5961,0.2765 T0.5904,0.2789 L0.5864,0.2789 Q0.5831,0.2779,0.5742,0.2779 Q0.541,0.2779,0.5223,0.2849 Q0.5126,0.2888,0.5028,0.2888 Q0.5004,0.2888,0.4943,0.2883 T0.4842,0.2878 Q0.4704,0.2878,0.4627,0.2898 T0.4509,0.2987 Q0.4501,0.2997,0.4501,0.3007 Q0.4501,0.3046,0.4574,0.3066 T0.4765,0.3091 T0.4899,0.3096 Q0.4931,0.3106,0.5061,0.3121 T0.5316,0.315 T0.5499,0.3175 Q0.5507,0.3175,0.5572,0.3195 T0.5685,0.3225 T0.5803,0.3254 T0.5933,0.3279 T0.605,0.3284 T0.6148,0.3274 Q0.6221,0.3244,0.6294,0.3244 Q0.6399,0.3244,0.6496,0.3294 Q0.6529,0.3314,0.6577,0.3314 Q0.6602,0.3314,0.6663,0.3304 T0.6756,0.3294 T0.6813,0.3304 Q0.6837,0.3304,0.6873,0.3309 L0.6946,0.3318 T0.7024,0.3323 T0.7105,0.3328 T0.7178,0.3338 T0.7238,0.3348 T0.7283,0.3363 Q0.7324,0.3383,0.7482,0.3403 T0.7689,0.3442 Q0.7697,0.3442,0.779,0.3477 T0.794,0.3536 T0.8074,0.3615 T0.8183,0.3729 Q0.8232,0.3808,0.8232,0.3848 Q0.8232,0.3867,0.8216,0.3892 T0.8151,0.3961 T0.8062,0.406 T0.7997,0.4179 T0.7952,0.4263 T0.7855,0.4308 T0.7616,0.4362 Q0.7543,0.4372,0.7445,0.4372 L0.7372,0.4372 L0.7307,0.4372 Q0.7202,0.4372,0.7153,0.4382 Q0.7064,0.4402,0.691,0.4402 L0.6845,0.4402 L0.6788,0.4402 Q0.6699,0.4402,0.6533,0.4436 T0.6318,0.451 Q0.6302,0.451,0.6302,0.452 Q0.6302,0.457,0.6626,0.459 Q0.6869,0.4609,0.7015,0.4659 Q0.7064,0.4669,0.7202,0.4669 L0.7311,0.4669 L0.7429,0.4669 Q0.7599,0.4669,0.7689,0.4688 Q0.7794,0.4708,0.7794,0.4738 L0.7786,0.4748 T0.777,0.4763 T0.7749,0.4773 L0.7737,0.4777 L0.7729,0.4777 Q0.7502,0.4797,0.738,0.4797 L0.7315,0.4797 L0.7291,0.4797 Q0.7226,0.4797,0.6869,0.4876 Q0.6821,0.4886,0.6768,0.4891 T0.6614,0.4901 T0.6456,0.4916 L0.6342,0.4916 Q0.6294,0.4916,0.6217,0.4911 T0.6115,0.4906 Q0.6083,0.4906,0.6054,0.4911 T0.5961,0.4936 T0.5815,0.4965 T0.5629,0.4985 Q0.5507,0.4985,0.5442,0.4995 T0.5345,0.5025 T0.5304,0.5084 L0.5296,0.5094 Q0.5296,0.5114,0.5316,0.5124 T0.5373,0.5138 T0.5442,0.5143 L0.5523,0.5143 L0.5604,0.5143 Q0.5637,0.5153,0.5677,0.5158 T0.5742,0.5173 T0.5811,0.5188 T0.5904,0.5193 L0.5977,0.5193 L0.6026,0.5193 Q0.6107,0.5193,0.6168,0.5208 T0.6294,0.5252 T0.6399,0.5292 Q0.6448,0.5302,0.6679,0.5341 T0.6983,0.541 Q0.7129,0.545,0.7664,0.55 Q0.7883,0.5519,0.7883,0.5559 Q0.7883,0.5579,0.7843,0.5608 T0.7721,0.5638 Q0.7697,0.5638,0.764,0.5633 T0.7559,0.5628 L0.7502,0.5628 Q0.7364,0.5648,0.6869,0.5648 L0.6699,0.5648 L0.6675,0.5648 Q0.665,0.5648,0.6602,0.5658 T0.6513,0.5668 Q0.6464,0.5668,0.6399,0.5658 Q0.6342,0.5648,0.6302,0.5648 T0.6225,0.5668 T0.6156,0.5697 Q0.6107,0.5707,0.6087,0.5707 T0.6034,0.5712 T0.5953,0.5717 Q0.5904,0.5727,0.5835,0.5727 T0.5718,0.5732 T0.562,0.5757 Q0.558,0.5767,0.5483,0.5767 L0.5349,0.5767 L0.5207,0.5767 Q0.5069,0.5767,0.5028,0.5786 Q0.4972,0.5816,0.4899,0.5816 Q0.4858,0.5816,0.4781,0.5806 T0.4663,0.5796 L0.4631,0.5796 Q0.4582,0.5796,0.4432,0.5821 T0.4144,0.5846 L0.4071,0.5846 L0.4011,0.5846 T0.3958,0.5851 T0.3921,0.5856 T0.3889,0.5861 T0.3865,0.5865 T0.384,0.5875 L0.382,0.5885 L0.3796,0.5895 L0.3771,0.5905 Q0.3731,0.5925,0.365,0.5925 L0.3601,0.5925 L0.3552,0.5925 Q0.3277,0.5925,0.3049,0.6044 Q0.3017,0.6053,0.296,0.6053 Q0.292,0.6053,0.2847,0.6044 T0.2741,0.6034 Q0.2693,0.6034,0.2547,0.6029 T0.236,0.6024 Q0.2222,0.6024,0.1922,0.6073 Q0.1906,0.6083,0.1882,0.6083 Q0.1833,0.6083,0.1711,0.6063 T0.1533,0.6044 Q0.1517,0.6034,0.1492,0.6034 Q0.1436,0.6034,0.135,0.6048 T0.1168,0.6078 T0.103,0.6093 Q0.0973,0.6103,0.0787,0.6103 L0.0604,0.6103 L0.0414,0.6103 L0.0235,0.6103 Q0.0024,0.6113,0.0024,0.6172 Q0.0024,0.6192,0.0032,0.6231 Q0.0049,0.6281,0.0333,0.6281 L0.0414,0.6281 L0.0479,0.6281 Q0.0519,0.6281,0.0624,0.6301 T0.0803,0.632 L0.0835,0.632 L0.0916,0.632 Q0.0989,0.632,0.1281,0.634 L0.206,0.6419 Q0.2117,0.6429,0.2174,0.6429 Q0.2214,0.6429,0.2271,0.6424 T0.2344,0.6419 L0.2376,0.6419 Q0.2393,0.6429,0.2417,0.6429 T0.2526,0.6419 T0.2652,0.6409 Q0.2741,0.6409,0.2782,0.6429 T0.2968,0.6459 T0.3293,0.6479 T0.352,0.6489 Q0.3552,0.6499,0.3585,0.6499 Q0.365,0.6499,0.3731,0.6474 T0.3844,0.6449 Q0.3885,0.6449,0.3917,0.6474 T0.4006,0.6499 Q0.4088,0.6499,0.4509,0.6578 Q0.4574,0.6588,0.4631,0.6588 Q0.4655,0.6588,0.4716,0.6583 T0.4834,0.6578 L0.4874,0.6578 Q0.5004,0.6588,0.5255,0.6637 Q0.532,0.6647,0.56,0.6667 T0.6148,0.6701 T0.644,0.6716 Q0.6464,0.6726,0.6594,0.6736 T0.6861,0.6756 T0.7048,0.6775 Q0.7097,0.6775,0.7186,0.6825 T0.738,0.6874 Q0.7518,0.6874,0.7729,0.6958 T0.8005,0.7122 Q0.8029,0.7141,0.8029,0.7151 Q0.8029,0.7191,0.7968,0.7216 T0.7818,0.726 T0.7705,0.729 L0.764,0.731 T0.7583,0.7324 T0.753,0.7334 T0.7486,0.7349 Q0.7251,0.7399,0.7161,0.7399 Q0.7097,0.7399,0.6951,0.7409 T0.6748,0.7418 L0.6703,0.7418 L0.6667,0.7418 Q0.6659,0.7418,0.6399,0.7448 L0.6334,0.7448 Q0.631,0.7448,0.6249,0.7443 T0.6148,0.7438 L0.6099,0.7438 Q0.601,0.7448,0.5856,0.7473 T0.5645,0.7507 Q0.5572,0.7517,0.5572,0.7547 T0.5616,0.7606 T0.5702,0.7646 Q0.5734,0.7646,0.5779,0.7651 T0.5864,0.7661 T0.5949,0.7671 T0.6018,0.7676 L0.6071,0.7676 T0.6135,0.7681 T0.62,0.769 T0.6269,0.771 T0.6342,0.7725 Q0.6391,0.7725,0.6464,0.7705 T0.6541,0.7685 L0.6553,0.7685 Q0.6586,0.7685,0.6699,0.771 T0.6853,0.7735 Q0.6902,0.7735,0.704,0.777 T0.7226,0.7834 Q0.7315,0.7873,0.7445,0.7883 Q0.747,0.7883,0.7676,0.7893 T0.7972,0.7913 Q0.7989,0.7913,0.8017,0.7918 T0.8058,0.7923 T0.809,0.7928 T0.8114,0.7933 T0.8131,0.7938 T0.8147,0.7943 T0.8159,0.7953 L0.8171,0.7967 T0.8175,0.7982 Q0.8183,0.7992,0.8183,0.8002 Q0.8183,0.8022,0.8155,0.8032 T0.807,0.8051 T0.7989,0.8071 Q0.7932,0.8091,0.7737,0.8091 L0.7413,0.8091 L0.7372,0.8091 Q0.7275,0.8091,0.721,0.8101 T0.7072,0.8136 T0.6983,0.817 Q0.6942,0.818,0.6825,0.818 T0.6602,0.819 T0.6456,0.822 Q0.6415,0.8249,0.6375,0.8249 Q0.6367,0.8249,0.6326,0.8239 T0.6253,0.8229 Q0.6034,0.8229,0.5953,0.8279 Q0.5912,0.8289,0.5848,0.8289 Q0.5775,0.8289,0.5645,0.8279 Q0.5629,0.8269,0.5604,0.8269 Q0.5523,0.8269,0.5328,0.8348 Q0.5296,0.8358,0.5264,0.8358 Q0.5247,0.8358,0.5203,0.8353 T0.5126,0.8348 Q0.5061,0.8348,0.4988,0.8358 Q0.4947,0.8368,0.4882,0.8378 Q0.4826,0.8388,0.4797,0.8388 T0.474,0.8398 T0.4704,0.8422 T0.4696,0.8462 T0.472,0.8501 T0.4781,0.8521 T0.4854,0.8526 L0.4935,0.8526 T0.4996,0.8536 Q0.5036,0.8536,0.515,0.8546 T0.5337,0.8566 Q0.5426,0.8576,0.5596,0.8576 L0.5657,0.8576 L0.571,0.8576 L0.5791,0.8576 Q0.5921,0.8586,0.6135,0.8591 T0.6383,0.8605 Q0.6683,0.8635,0.6764,0.8635 Q0.6999,0.8635,0.6999,0.8684 Q0.6999,0.8694,0.6967,0.8734 T0.6934,0.8803 L0.6934,0.8823 Q0.6951,0.8863,0.7137,0.8863 Q0.7218,0.8863,0.7267,0.8853 L0.7299,0.8853 Q0.734,0.8853,0.7409,0.8882 T0.7502,0.8912 Q0.7607,0.8942,0.794,0.8971 Q0.7972,0.8971,0.8078,0.9001 T0.8297,0.9031 Q0.8475,0.9031,0.8646,0.9065 T0.8824,0.9149 L0.8824,0.9159 Q0.8824,0.9169,0.882,0.9179 T0.8808,0.9194 L0.8792,0.9204 T0.8767,0.9214 T0.8743,0.9224 T0.8715,0.9228 L0.8686,0.9228 T0.8662,0.9233 T0.8637,0.9238 L0.8556,0.9238 T0.8447,0.9243 T0.8386,0.9268 Q0.837,0.9278,0.835,0.9288 T0.8305,0.9303 T0.8244,0.9308 T0.8175,0.9318 Q0.8127,0.9327,0.8017,0.9352 T0.7851,0.9397 Q0.777,0.9416,0.7705,0.9451 T0.7616,0.9496 Q0.7575,0.9505,0.7494,0.9505 L0.7405,0.9505 L0.7307,0.9505 Q0.7234,0.9505,0.7178,0.9515 Q0.7145,0.9515,0.7125,0.9535 T0.7105,0.9575 Q0.7105,0.9624,0.7194,0.9634 Q0.7567,0.9654,0.7664,0.9674 Q0.7745,0.9693,0.7762,0.9693 L0.7908,0.9693 L0.7948,0.9693 Q0.8005,0.9693,0.8058,0.9698 T0.8143,0.9718 T0.824,0.9753 T0.8354,0.9792 Q0.8483,0.9832,0.871,0.9832 L0.8739,0.9832 L0.8767,0.9832 Q0.8873,0.9832,0.8921,0.9842 Q0.8978,0.9852,0.9157,0.9896 T0.94,0.996 Q0.9424,0.996,0.9469,0.9965 T0.9566,0.997 T0.9676,0.9975 T0.9781,0.998 L0.9874,0.998 L0.9943,0.998 L0.9968,0.998 Z",type:0}},"":{type:5,data:{d:"M1,0.5071 L0.8623,0.7102 L0.5865,0.7102 L0.4489,0.5071 L0.5865,0.3045 L0.8623,0.3045 Z M0.4135,0.7974 L0.2758,1 L0,1 L0,0.5944 L0.2758,0.5944 Z M0.4135,0.2026 L0.2758,0.4056 L0,0.4056 L0,0 L0.2758,0 Z",type:0}},"":{type:5,data:{d:"M0.9726,0.5071 L0.8451,0.3184 L0.59,0.3184 L0.4624,0.5071 L0.59,0.6955 L0.8451,0.6955 Z M1,0.5071 L0.8588,0.716 L0.5768,0.716 L0.4355,0.5071 L0.5768,0.2982 L0.8588,0.2982 Z M0.401,0.7911 L0.2735,0.6028 L0.0236,0.6028 L0.0236,0.9799 L0.2735,0.9799 Z M0.4284,0.7911 L0.2872,1 L0,1 L0,0.5826 L0.2872,0.5826 Z M0.401,0.2089 L0.2735,0.0201 L0.0236,0.0201 L0.0236,0.3972 L0.2735,0.3972 Z M0.4284,0.2089 L0.2872,0.4174 L0,0.4174 L0,0 L0.2872,0 Z",type:0}},"":{type:5,data:{d:"M1,0.4996 Q1,0.5365,0.9924,0.568 T0.9718,0.6177 T0.9433,0.6363 L0.9425,0.6367 Q0.9355,0.6367,0.9285,0.6326 L0.9308,0.6326 Q0.9129,0.6195,0.9013,0.587 T0.8871,0.5164 T0.8943,0.4373 T0.9254,0.3687 L0.9254,0.3691 Q0.9339,0.3628,0.9425,0.3628 Q0.9584,0.3628,0.9716,0.3811 T0.9924,0.431 T1,0.4996 Z M0.9234,0.6321 L0.8776,0.7169 Q0.8791,0.732,0.8791,0.7441 Q0.8791,0.781,0.8716,0.8123 T0.8508,0.862 T0.8224,0.8809 L0.8216,0.8809 Q0.8154,0.8809,0.8092,0.8775 L0.8088,0.8775 Q0.7905,0.8633,0.7792,0.8297 T0.766,0.7571 T0.775,0.6768 T0.8088,0.6086 L0.7431,0.6065 Q0.719,0.6313,0.7072,0.6705 T0.6965,0.7487 T0.7097,0.823 T0.7423,0.8763 L0.7913,0.8775 L0.7314,0.9895 L0.4648,0.5038 L0.7299,0.0176 L0.7882,0.1229 L0.7404,0.1212 Q0.7244,0.138,0.7136,0.1617 T0.6982,0.2108 T0.6943,0.2632 T0.7003,0.3144 T0.7159,0.3586 T0.7396,0.3909 L0.8072,0.3926 Q0.7894,0.3796,0.7777,0.3479 T0.7635,0.2789 T0.7697,0.2011 T0.7987,0.1326 Q0.8092,0.1225,0.8204,0.1225 Q0.8321,0.1225,0.8426,0.1332 T0.8609,0.1623 T0.8731,0.2062 T0.8776,0.2592 Q0.8776,0.268,0.8768,0.2815 L0.9219,0.3628 L0.8644,0.3612 Q0.8403,0.3855,0.8284,0.4247 T0.8177,0.5029 T0.8309,0.5772 T0.8632,0.6305 Z M0.6759,0.6384 Q0.6576,0.625,0.6457,0.5914 T0.6319,0.5185 T0.6407,0.4375 T0.6751,0.3691 L0.609,0.367 Q0.5849,0.3918,0.5731,0.431 T0.5626,0.509 T0.5758,0.5833 T0.6082,0.6367 Z M0.6459,0.0025 L0.391,0.4551 L0.0035,0.4551 L0.246,0 Z M0.6553,1 L0.2421,1 L0,0.5449 L0.3875,0.5449 Z",type:0}},"":{type:5,data:{d:"M0.4996,0 Q0.5562,0,0.5961,0.0166 T0.6364,0.0566 L0.6368,0.0575 Q0.6368,0.0646,0.6324,0.0713 L0.6324,0.0692 Q0.6196,0.0868,0.5872,0.0986 T0.5166,0.1128 T0.4373,0.1057 T0.3689,0.0747 L0.3694,0.0747 Q0.3627,0.0663,0.3627,0.0575 Q0.3627,0.0336,0.4028,0.0168 T0.4996,0 Z M0.6324,0.0768 L0.717,0.1225 Q0.7321,0.1212,0.744,0.1212 Q0.8007,0.1212,0.8406,0.1378 T0.8809,0.1779 L0.8813,0.1783 Q0.8813,0.1846,0.8778,0.1909 Q0.8636,0.2093,0.8299,0.2208 T0.7573,0.2343 T0.6769,0.2253 T0.6089,0.1913 L0.6067,0.2567 Q0.6315,0.281,0.6707,0.2928 T0.7489,0.3035 T0.8231,0.2903 T0.8764,0.258 L0.8778,0.2085 L0.9898,0.2685 L0.504,0.5352 L0.0177,0.2701 L0.1227,0.2118 L0.1213,0.2596 Q0.1457,0.2836,0.1851,0.2955 T0.2635,0.3062 T0.3377,0.293 T0.3911,0.2605 L0.3928,0.193 Q0.38,0.2106,0.3483,0.2221 T0.2792,0.2364 T0.2013,0.2303 T0.1324,0.2013 Q0.1222,0.1909,0.1222,0.1795 Q0.1222,0.156,0.1623,0.1393 T0.2591,0.1225 Q0.2679,0.1225,0.2817,0.1233 L0.3627,0.078 L0.3609,0.1359 Q0.3857,0.1598,0.4249,0.1718 T0.5031,0.1825 T0.5773,0.1693 T0.6306,0.1367 Z M0.6386,0.3242 Q0.6253,0.3427,0.5917,0.3544 T0.5186,0.3683 T0.4376,0.3595 T0.3689,0.3251 L0.3671,0.3909 Q0.3915,0.4148,0.4309,0.4268 T0.5093,0.4375 T0.5835,0.4243 T0.6368,0.3918 Z M0.0027,0.354 L0.4553,0.6091 L0.4553,0.9962 L0,0.7542 Z M1,0.3448 L1,0.7576 L0.5447,1 L0.5447,0.6128 Z",type:0}},"":{type:5,data:{d:"M0,0.7699 Q0,0.7172,0.0277,0.6731 T0.103,0.6032 T0.2066,0.5774 Q0.2487,0.5774,0.2865,0.5922 T0.3526,0.6339 L0.3935,0.6715 Q0.4218,0.6984,0.438,0.7336 T0.4541,0.8075 Q0.4541,0.8602,0.4264,0.9046 T0.3511,0.9745 T0.2475,1 Q0.2054,1,0.1676,0.9852 T0.1016,0.9435 L0.0606,0.9059 Q0.0317,0.879,0.0159,0.8438 T0,0.7699 Z M0.5459,0.7699 Q0.5459,0.7172,0.5736,0.6731 T0.6489,0.6032 T0.7525,0.5774 Q0.7946,0.5774,0.8324,0.5922 T0.8984,0.6339 L0.9394,0.6715 Q0.9579,0.6892,0.9714,0.7105 T0.9925,0.7567 T1,0.8075 Q1,0.8602,0.9723,0.9046 T0.897,0.9745 T0.7934,1 Q0.7513,1,0.7135,0.9852 T0.6474,0.9435 L0.6065,0.9059 Q0.5776,0.879,0.5617,0.8438 T0.5459,0.7699 Z M0,0.1925 Q0,0.1398,0.0277,0.0957 T0.103,0.0258 T0.2066,0 Q0.2487,0,0.2865,0.0148 T0.3526,0.0565 L0.3935,0.0941 Q0.4218,0.121,0.438,0.1562 T0.4541,0.2301 Q0.4541,0.2828,0.4264,0.3269 T0.3511,0.3968 T0.2475,0.4226 Q0.2054,0.4226,0.1676,0.4078 T0.1016,0.3661 L0.0606,0.3285 Q0.0317,0.3016,0.0159,0.2664 T0,0.1925 Z M0.5459,0.1925 Q0.5459,0.1398,0.5736,0.0957 T0.6489,0.0258 T0.7525,0 Q0.7946,0,0.8324,0.0148 T0.8984,0.0565 L0.9394,0.0941 Q0.9677,0.121,0.9838,0.1562 T1,0.2301 Q1,0.2828,0.9723,0.3269 T0.897,0.3968 T0.7934,0.4226 Q0.7513,0.4226,0.7135,0.4078 T0.6474,0.3661 L0.6065,0.3285 Q0.5874,0.3108,0.5741,0.2895 T0.5534,0.2433 T0.5459,0.1925 Z M0.3301,0.6403 Q0.3306,0.6403,0.3312,0.6409 L0.3272,0.6371 L0.3272,0.6371 Z M0.8759,0.6403 Q0.8765,0.6403,0.8771,0.6409 Q0.8748,0.6387,0.8725,0.6371 L0.8731,0.6371 Z M0.3301,0.0629 Q0.3306,0.0629,0.3312,0.0634 L0.3272,0.0597 L0.3272,0.0602 Z M0.8759,0.0629 Q0.8765,0.0629,0.8771,0.0634 Q0.8748,0.0613,0.8725,0.0597 Q0.8731,0.0597,0.8731,0.0602 Z M0.779,0.4113 L0.7501,0.3849 Q0.7046,0.3844,0.6636,0.3661 Q0.7132,0.407,0.779,0.4113 Z M0.7957,0.4118 Q0.8477,0.4113,0.8918,0.3874 T0.9619,0.3223 T0.9885,0.2323 L0.9585,0.2048 Q0.9538,0.2769,0.8987,0.3282 T0.7657,0.3844 Z M0.9879,0.2167 Q0.9827,0.1554,0.9388,0.1097 Q0.9585,0.1478,0.959,0.1898 Z M0.2331,0.4113 L0.2043,0.3849 Q0.1587,0.3844,0.1177,0.3661 Q0.1673,0.407,0.2331,0.4113 Z M0.2499,0.4118 Q0.2885,0.4118,0.324,0.3973 T0.3852,0.3589 T0.4264,0.3019 T0.4426,0.2323 L0.4126,0.2048 Q0.408,0.2769,0.3529,0.3282 T0.2198,0.3844 Z M0.442,0.2167 Q0.4368,0.1554,0.393,0.1097 Q0.4126,0.1478,0.4132,0.1903 Z M0.779,0.9887 L0.7501,0.9624 Q0.7046,0.9618,0.6636,0.9435 Q0.7132,0.9844,0.779,0.9887 Z M0.7957,0.9892 Q0.8477,0.9887,0.8918,0.9648 T0.9619,0.8997 T0.9885,0.8097 L0.9585,0.7823 Q0.9538,0.8543,0.8987,0.9056 T0.7657,0.9618 Z M0.9879,0.7941 Q0.9827,0.7328,0.9388,0.6871 Q0.9585,0.7253,0.959,0.7672 Z M0.2331,0.9887 L0.2043,0.9624 Q0.1587,0.9618,0.1177,0.9435 Q0.1673,0.9844,0.2331,0.9887 Z M0.2499,0.9892 Q0.3018,0.9887,0.3459,0.9648 T0.416,0.8997 T0.4426,0.8102 L0.4126,0.7823 Q0.408,0.8543,0.3529,0.9056 T0.2198,0.9618 Z M0.442,0.7941 Q0.4368,0.7328,0.393,0.6871 Q0.4126,0.7253,0.4132,0.7672 Z M0.3191,0.6452 Q0.2943,0.622,0.2643,0.6091 T0.2066,0.5962 Q0.1795,0.5962,0.1497,0.6091 T0.0949,0.6441 T0.0537,0.6995 T0.0375,0.7699 Q0.0375,0.8419,0.0941,0.8941 Q0.1189,0.9172,0.1489,0.9304 T0.2066,0.9435 Q0.2337,0.9435,0.2634,0.9304 T0.3182,0.8952 T0.3595,0.8398 T0.3756,0.7699 Q0.3756,0.6978,0.3191,0.6452 Z M0.026,0.7731 L0.026,0.7699 Q0.026,0.6935,0.0854,0.6376 Q0.0658,0.6538,0.0514,0.6739 T0.0289,0.718 T0.0202,0.7677 Z M0.0271,0.7892 L0.0208,0.7833 Q0.0254,0.8419,0.0681,0.886 Q0.0664,0.8828,0.0646,0.879 Q0.0329,0.8382,0.0271,0.7892 Z M0.3866,0.7823 Q0.382,0.8511,0.3278,0.9016 Q0.3843,0.8565,0.3918,0.7871 Z M0.3872,0.7677 L0.393,0.7726 L0.393,0.7699 Q0.393,0.7349,0.3791,0.7038 Q0.3739,0.6973,0.3681,0.6914 Q0.3866,0.7274,0.3872,0.7677 Z M0.865,0.6452 Q0.8402,0.622,0.8102,0.6091 T0.7525,0.5962 Q0.7305,0.5962,0.7072,0.6043 T0.6619,0.628 T0.6223,0.6642 T0.5941,0.7124 T0.5834,0.7699 Q0.5834,0.8419,0.6399,0.8941 Q0.6561,0.9097,0.6757,0.9207 T0.7149,0.9376 T0.7525,0.9435 Q0.7796,0.9435,0.8093,0.9304 T0.8641,0.8952 T0.9054,0.8398 T0.9215,0.7699 Q0.9215,0.6978,0.865,0.6452 Z M0.5718,0.7731 L0.5718,0.7699 Q0.5718,0.6935,0.6313,0.6376 Q0.6013,0.6618,0.584,0.6954 T0.5661,0.7677 Z M0.573,0.7892 L0.5666,0.7833 Q0.5713,0.8419,0.614,0.886 Q0.6122,0.8828,0.6105,0.879 Q0.5788,0.8382,0.573,0.7892 Z M0.9325,0.7823 Q0.9279,0.8511,0.8736,0.9016 Q0.9308,0.8565,0.9377,0.7871 Z M0.9331,0.7672 L0.9388,0.7726 L0.9388,0.7699 Q0.9388,0.7349,0.925,0.7038 Q0.9198,0.6973,0.914,0.6914 Q0.9325,0.7274,0.9331,0.7672 Z M0.3191,0.0677 Q0.2943,0.0446,0.2643,0.0317 T0.2066,0.0188 Q0.1795,0.0188,0.1497,0.0317 T0.0949,0.0667 T0.0537,0.122 T0.0375,0.1925 Q0.0375,0.2645,0.0941,0.3167 Q0.1189,0.3398,0.1489,0.353 T0.2066,0.3661 Q0.2337,0.3661,0.2634,0.353 T0.3182,0.3177 T0.3595,0.2624 T0.3756,0.1925 Q0.3756,0.1204,0.3191,0.0677 Z M0.026,0.1957 L0.026,0.1925 Q0.026,0.1161,0.0854,0.0602 Q0.0554,0.0844,0.0381,0.118 T0.0202,0.1903 Z M0.0271,0.2118 L0.0208,0.2059 Q0.0254,0.2645,0.0681,0.3086 Q0.0664,0.3054,0.0646,0.3016 Q0.0329,0.2608,0.0271,0.2118 Z M0.3866,0.2048 Q0.382,0.2737,0.3278,0.3242 Q0.3849,0.279,0.3918,0.2097 Z M0.3872,0.1903 L0.393,0.1952 L0.393,0.1925 Q0.393,0.1581,0.3791,0.1263 Q0.3739,0.1199,0.3681,0.114 Q0.3866,0.15,0.3872,0.1903 Z M0.865,0.0677 Q0.8402,0.0446,0.8102,0.0317 T0.7525,0.0188 Q0.7253,0.0188,0.6956,0.0317 T0.6408,0.0667 T0.5995,0.122 T0.5834,0.1925 Q0.5834,0.2645,0.6399,0.3167 Q0.6647,0.3398,0.6947,0.353 T0.7525,0.3661 Q0.7796,0.3661,0.8093,0.353 T0.8641,0.3177 T0.9054,0.2624 T0.9215,0.1925 Q0.9215,0.1204,0.865,0.0677 Z M0.5718,0.1957 L0.5718,0.1925 Q0.5718,0.1161,0.6313,0.0602 Q0.6013,0.0844,0.584,0.118 T0.5661,0.1903 Z M0.573,0.2118 L0.5666,0.2059 Q0.5713,0.2645,0.614,0.3086 Q0.6122,0.3054,0.6105,0.3016 Q0.5788,0.2608,0.573,0.2118 Z M0.9325,0.2048 Q0.9279,0.2737,0.8736,0.3242 Q0.9308,0.279,0.9377,0.2097 Z M0.9331,0.1898 L0.9388,0.1952 L0.9388,0.1925 Q0.9388,0.1575,0.925,0.1263 Q0.9198,0.1199,0.914,0.114 Q0.9325,0.15,0.9331,0.1898 Z",type:0}},"":{type:5,data:{d:"M0.7639,0.1974 L0.9593,0.1974 L0.9593,0.1443 L0.7639,0.1443 L0.7639,0.1974 Z M0.7586,0.109 L0.9727,0.109 Q0.9839,0.109,0.992,0.1153 T1,0.1291 L1,0.382 Q1,0.3906,0.9912,0.3964 T0.9727,0.4021 L0.7586,0.4021 Q0.7468,0.4021,0.739,0.3956 T0.7313,0.382 L0.7313,0.1291 Q0.7313,0.1246,0.7339,0.1207 T0.7406,0.1143 T0.7495,0.1104 T0.7586,0.109 Z M0.7639,0.6575 L0.9593,0.6575 L0.9593,0.6044 L0.7639,0.6044 L0.7639,0.6575 Z M0.7313,0.8347 L0.7313,0.5843 Q0.7313,0.5757,0.7401,0.5699 T0.7586,0.5641 L0.9706,0.5641 Q0.9818,0.5641,0.9898,0.5705 T0.9979,0.5843 L0.9979,0.8347 Q0.9979,0.8433,0.989,0.8491 T0.9706,0.8549 L0.7586,0.8549 Q0.7468,0.8549,0.739,0.8483 T0.7313,0.8347 Z M0,1 L0,0 L0.7607,0 L0.7607,1 L0,1 Z",type:0}},"":{type:5,data:{d:"M0.9764,0.0029 L0.3179,0.4552 L0,0.4552 L0,0 Z M1,1 L0,1 L0,0.5448 L0.3091,0.5448 Z",type:0}},"":{type:5,data:{d:"M0.0236,0.0029 L0.6824,0.4552 L1,0.4552 L1,0 Z M0,1 L1,1 L1,0.5448 L0.6912,0.5448 Z",type:0}},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z M.25,.15 L1,.15 L1,.85 L.25,.85 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z M0,.15 L1,.15 L1,.85 L0,.85 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z M0,.15 L.75,.15 L.75,.85 L0,.85 Z"},"":{type:5,data:{d:"M0.6574,0.303 Q0.623,0.291,0.5852,0.285 T0.5082,0.279 T0.4311,0.285 T0.359,0.303 L0.3082,0.248 Q0.3525,0.232,0.4041,0.2235 T0.5082,0.215 T0.6123,0.2235 T0.7082,0.248 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.8557,0.582 L0.7656,0.551 Q0.7852,0.53,0.7951,0.507 T0.8049,0.46 Q0.8049,0.424,0.782,0.3905 T0.718,0.332 T0.6221,0.293 T0.5082,0.279 L0.5082,0.215 Q0.5607,0.215,0.6123,0.2235 T0.709,0.248 T0.7918,0.287 T0.8557,0.3375 T0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.582 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.482,0.705,0.4557,0.703 T0.4049,0.697 L0.4311,0.635 Q0.4508,0.638,0.4697,0.6395 T0.5082,0.641 Q0.5672,0.641,0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 Q0.8049,0.436,0.7951,0.413 T0.7656,0.369 L0.8557,0.338 Q0.882,0.365,0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 L0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 T0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 L0.9098,0.46 Q0.9098,0.492,0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.338 L0.2508,0.369 Q0.2311,0.39,0.2213,0.413 T0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 Q0.5279,0.641,0.5467,0.6395 T0.5852,0.635 L0.6115,0.697 Q0.5869,0.701,0.5607,0.703 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.1607,0.582 Q0.1344,0.555,0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.3375 T0.2246,0.287 T0.3074,0.248 T0.4041,0.2235 T0.5082,0.215 L0.5082,0.279 Q0.4492,0.279,0.3943,0.293 T0.2984,0.332 T0.2344,0.3905 T0.2115,0.46 Q0.2115,0.484,0.2213,0.507 T0.2508,0.551 Z",type:0},scaleType:1},"":De.LINE_H,"":De.LINE_V,"":De.FADE_RIGHT,"":De.FADE_LEFT,"":De.FADE_DOWN,"":De.FADE_UP,"":De.CURVE_DOWN_RIGHT,"":De.CURVE_DOWN_LEFT,"":De.CURVE_UP_RIGHT,"":De.CURVE_UP_LEFT,"":[De.LINE_V,De.CURVE_UP_RIGHT],"":[De.LINE_V,De.CURVE_DOWN_RIGHT],"":[De.CURVE_DOWN_RIGHT,De.CURVE_UP_RIGHT],"":[De.LINE_V,De.CURVE_UP_LEFT],"":[De.LINE_V,De.CURVE_DOWN_LEFT],"":[De.CURVE_DOWN_LEFT,De.CURVE_UP_LEFT],"":[De.LINE_H,De.CURVE_DOWN_LEFT],"":[De.LINE_H,De.CURVE_DOWN_RIGHT],"":[De.CURVE_DOWN_LEFT,De.CURVE_DOWN_RIGHT],"":[De.LINE_H,De.CURVE_UP_LEFT],"":[De.LINE_H,De.CURVE_UP_RIGHT],"":[De.CURVE_UP_LEFT,De.CURVE_UP_RIGHT],"":[De.LINE_V,De.CURVE_UP_LEFT,De.CURVE_UP_RIGHT],"":[De.LINE_V,De.CURVE_DOWN_LEFT,De.CURVE_DOWN_RIGHT],"":[De.LINE_H,De.CURVE_DOWN_LEFT,De.CURVE_UP_LEFT],"":[De.LINE_H,De.CURVE_DOWN_RIGHT,De.CURVE_UP_RIGHT],"":[De.LINE_V,De.CURVE_DOWN_RIGHT,De.CURVE_UP_LEFT],"":[De.LINE_V,De.CURVE_DOWN_LEFT,De.CURVE_UP_RIGHT],"":[De.LINE_H,De.CURVE_DOWN_RIGHT,De.CURVE_UP_LEFT],"":[De.LINE_H,De.CURVE_DOWN_LEFT,De.CURVE_UP_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE],"":De.NODE_STROKE,"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_LEFT],"":[De.NODE_STROKE,De.NODE_LINE_LEFT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_DOWN],"":[De.NODE_STROKE,De.NODE_LINE_DOWN],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP],"":[De.NODE_STROKE,De.NODE_LINE_UP],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_UP],"":[De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_UP],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT],"":[De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_LEFT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_LEFT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_FILL,De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"":[De.NODE_STROKE,De.NODE_LINE_UP,De.NODE_LINE_DOWN,De.NODE_LINE_LEFT,De.NODE_LINE_RIGHT],"🬀":Cr(1),"🬁":Cr(2),"🬂":Cr(3),"🬃":Cr(4),"🬄":Cr(5),"🬅":Cr(6),"🬆":Cr(7),"🬇":Cr(8),"🬈":Cr(9),"🬉":Cr(10),"🬊":Cr(11),"🬋":Cr(12),"🬌":Cr(13),"🬍":Cr(14),"🬎":Cr(15),"🬏":Cr(16),"🬐":Cr(17),"🬑":Cr(18),"🬒":Cr(19),"🬓":Cr(20),"🬔":Cr(22),"🬕":Cr(23),"🬖":Cr(24),"🬗":Cr(25),"🬘":Cr(26),"🬙":Cr(27),"🬚":Cr(28),"🬛":Cr(29),"🬜":Cr(30),"🬝":Cr(31),"🬞":Cr(32),"🬟":Cr(33),"🬠":Cr(34),"🬡":Cr(35),"🬢":Cr(36),"🬣":Cr(37),"🬤":Cr(38),"🬥":Cr(39),"🬦":Cr(40),"🬧":Cr(41),"🬨":Cr(43),"🬩":Cr(44),"🬪":Cr(45),"🬫":Cr(46),"🬬":Cr(47),"🬭":Cr(48),"🬮":Cr(49),"🬯":Cr(50),"🬰":Cr(51),"🬱":Cr(52),"🬲":Cr(53),"🬳":Cr(54),"🬴":Cr(55),"🬵":Cr(56),"🬶":Cr(57),"🬷":Cr(58),"🬸":Cr(59),"🬹":Cr(60),"🬺":Cr(61),"🬻":Cr(62),"🬼":{type:3,data:"M0,0.6667 L0,1 L0.5,1 Z"},"🬽":{type:3,data:"M0,0.6667 L0,1 L1,1 Z"},"🬾":{type:3,data:"M0,0.3333 L0,1 L0.5,1 Z"},"🬿":{type:3,data:"M0,0.3333 L0,1 L1,1 Z"},"🭀":{type:3,data:"M0,0 L0,1 L0.5,1 Z"},"🭁":{type:3,data:"M0,0.3333 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭂":{type:3,data:"M0,0.3333 L1,0 L1,1 L0,1 Z"},"🭃":{type:3,data:"M0,0.6667 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭄":{type:3,data:"M0,0.6667 L1,0 L1,1 L0,1 Z"},"🭅":{type:3,data:"M0,1 L0.5,0 L1,0 L1,1 Z"},"🭆":{type:3,data:"M0,0.6667 L1,0.3333 L1,1 L0,1 Z"},"🭇":{type:3,data:"M0.5,1 L1,0.6667 L1,1 Z"},"🭈":{type:3,data:"M0,1 L1,0.6667 L1,1 Z"},"🭉":{type:3,data:"M0.5,1 L1,0.3333 L1,1 Z"},"🭊":{type:3,data:"M0,1 L1,0.3333 L1,1 Z"},"🭋":{type:3,data:"M0.5,1 L1,0 L1,1 Z"},"🭌":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.3333 Z"},"🭍":{type:3,data:"M0,0 L0,1 L1,1 L1,0.3333 Z"},"🭎":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.6667 Z"},"🭏":{type:3,data:"M0,0 L0,1 L1,1 L1,0.6667 Z"},"🭐":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 Z"},"🭑":{type:3,data:"M0,0.3333 L0,1 L1,1 L1,0.6667 Z"},"🭒":{type:3,data:"M0,0.6667 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭓":{type:3,data:"M0,0.6667 L1,1 L1,0 L0,0 Z"},"🭔":{type:3,data:"M0,0.3333 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭕":{type:3,data:"M0,0.3333 L1,1 L1,0 L0,0 Z"},"🭖":{type:3,data:"M0,0 L0.5,1 L1,1 L1,0 Z"},"🭗":{type:3,data:"M0,0.3333 L0,0 L0.5,0 Z"},"🭘":{type:3,data:"M0,0.3333 L0,0 L1,0 Z"},"🭙":{type:3,data:"M0,0.6667 L0,0 L0.5,0 Z"},"🭚":{type:3,data:"M0,0.6667 L0,0 L1,0 Z"},"🭛":{type:3,data:"M0,1 L0,0 L0.5,0 Z"},"🭜":{type:3,data:"M0,0.6667 L0,0 L1,0 L1,0.3333 Z"},"🭝":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.6667 Z"},"🭞":{type:3,data:"M0,1 L0,0 L1,0 L1,0.6667 Z"},"🭟":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.3333 Z"},"🭠":{type:3,data:"M0,1 L0,0 L1,0 L1,0.3333 Z"},"🭡":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 Z"},"🭢":{type:3,data:"M0.5,0 L1,0 L1,0.3333 Z"},"🭣":{type:3,data:"M0,0 L1,0 L1,0.3333 Z"},"🭤":{type:3,data:"M0.5,0 L1,0 L1,0.6667 Z"},"🭥":{type:3,data:"M0,0 L1,0 L1,0.6667 Z"},"🭦":{type:3,data:"M0.5,0 L1,0 L1,1 Z"},"🭧":{type:3,data:"M0,0.3333 L1,0.6667 L1,0 L0,0 Z"},"🭨":{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z"},"🭩":{type:3,data:"M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z"},"🭪":{type:3,data:"M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z"},"🭫":{type:3,data:"M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z"},"🭬":{type:3,data:"M0,0 L0.5,0.5 L0,1 Z"},"🭭":{type:3,data:"M0,0 L1,0 L0.5,0.5 Z"},"🭮":{type:3,data:"M1,0 L1,1 L0.5,0.5 Z"},"🭯":{type:3,data:"M0,1 L1,1 L0.5,0.5 Z"},"🭰":{type:0,data:[{x:1,y:0,w:1,h:8}]},"🭱":{type:0,data:[{x:2,y:0,w:1,h:8}]},"🭲":{type:0,data:[{x:3,y:0,w:1,h:8}]},"🭳":{type:0,data:[{x:4,y:0,w:1,h:8}]},"🭴":{type:0,data:[{x:5,y:0,w:1,h:8}]},"🭵":{type:0,data:[{x:6,y:0,w:1,h:8}]},"🭶":{type:0,data:[{x:0,y:1,w:8,h:1}]},"🭷":{type:0,data:[{x:0,y:2,w:8,h:1}]},"🭸":{type:0,data:[{x:0,y:3,w:8,h:1}]},"🭹":{type:0,data:[{x:0,y:4,w:8,h:1}]},"🭺":{type:0,data:[{x:0,y:5,w:8,h:1}]},"🭻":{type:0,data:[{x:0,y:6,w:8,h:1}]},"🭼":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🭽":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭾":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭿":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🮀":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮁":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮂":{type:0,data:[{x:0,y:0,w:8,h:2}]},"🮃":{type:0,data:[{x:0,y:0,w:8,h:3}]},"🮄":{type:0,data:[{x:0,y:0,w:8,h:5}]},"🮅":{type:0,data:[{x:0,y:0,w:8,h:6}]},"🮆":{type:0,data:[{x:0,y:0,w:8,h:7}]},"🮇":{type:0,data:[{x:6,y:0,w:2,h:8}]},"🮈":{type:0,data:[{x:5,y:0,w:3,h:8}]},"🮉":{type:0,data:[{x:3,y:0,w:5,h:8}]},"🮊":{type:0,data:[{x:2,y:0,w:6,h:8}]},"🮋":{type:0,data:[{x:1,y:0,w:7,h:8}]},"🮌":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},"🮍":{type:1,data:[[1,0],[0,1]],clipPath:"M0.5,0 L1,0 L1,1 L0.5,1 Z"},"🮎":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},"🮏":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},"🮐":{type:1,data:[[0,1],[1,0]]},"🮑":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},{type:0,data:[{x:0,y:0,w:8,h:4}]}],"🮒":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},{type:0,data:[{x:0,y:4,w:8,h:4}]}],"🮔":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},{type:0,data:[{x:4,y:0,w:4,h:8}]}],"🮕":{type:0,data:[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}]},"🮖":{type:0,data:[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}]},"🮗":{type:0,data:[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},"🮘":{type:2,data:"M-0.25,-0.25 L1.25,1.25 M-0.25,0 L1,1.25 M-0.25,0.25 L0.75,1.25 M-0.25,0.5 L0.5,1.25 M0,-0.25 L1.25,1 M0.25,-0.25 L1.25,0.75 M0.5,-0.25 L1.25,0.5 M-0.25,0.75 L0.25,1.25 M0.75,-0.25 L1.25,0.25",strokeWidth:1},"🮙":{type:2,data:"M-0.25,0.5 L0.5,-0.25 M-0.25,0.75 L0.75,-0.25 M-0.25,1 L1,-0.25 M-0.25,1.25 L1.25,-0.25 M0,1.25 L1.25,0 M0.25,1.25 L1.25,0.25 M0.5,1.25 L1.25,0.5 M-0.25,0.25 L0.25,-0.25 M0.75,1.25 L1.25,0.75",strokeWidth:1},"🮚":{type:5,data:{d:"M0,0 L.5,.5 L0,1 L1,1 L.5,.5 L1,0",type:0}},"🮛":{type:5,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1",type:0}},"🮜":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L0,1 Z"},"🮝":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,1 Z"},"🮞":{type:1,data:[[1,0],[0,1]],clipPath:"M1,0 L1,1 L0,1 Z"},"🮟":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,1 L0,1 Z"},"🮠":{type:2,data:"M.5,0 L0,.5",strokeWidth:1},"🮡":{type:2,data:"M.5,0 L1,.5",strokeWidth:1},"🮢":{type:2,data:"M0,.5 L.5,1",strokeWidth:1},"🮣":{type:2,data:"M1,.5 L.5,1",strokeWidth:1},"🮤":{type:2,data:"M.5,0 L0,.5 L.5,1",strokeWidth:1},"🮥":{type:2,data:"M.5,0 L1,.5 L.5,1",strokeWidth:1},"🮦":{type:2,data:"M0,.5 L.5,1 L1,.5",strokeWidth:1},"🮧":{type:2,data:"M0,.5 L.5,0 L1,.5",strokeWidth:1},"🮨":{type:2,data:"M.5,0 L0,.5 M1,.5 L.5,1",strokeWidth:1},"🮩":{type:2,data:"M.5,0 L1,.5 M0,.5 L.5,1",strokeWidth:1},"🮪":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5",strokeWidth:1},"🮫":{type:2,data:"M.5,0 L0,.5 L.5,1 L1,.5",strokeWidth:1},"🮬":{type:2,data:"M0,.5 L.5,0 L1,.5 L.5,1",strokeWidth:1},"🮭":{type:2,data:"M1,.5 L.5,0 L0,.5 L.5,1",strokeWidth:1},"🮮":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5 Z",strokeWidth:1},"🮯":{type:2,data:"M0,.5 L1,.5 M.5,.35 L.5,.65",strokeWidth:1},"🮰":{type:3,data:"M0.1,0.2 L0.1,.8 L.4,.6 L.9,0.6 Z",scaleType:1},"🮱":{type:4,data:{d:"M.1,.525 L.35,.675 L.9,.35",type:1},scaleType:1},"🮲":{type:3,data:"M.29,.27 L0.13,.56 L.22,.59 L.35,0.35 L.67,.35 L.57,.57 L.71,.76 L.22,.76 L.42,1 L.53,.98 L.43,.86 L.9,.86 L.71,.6 L1,.6 L1,.52 L.83,.52 L.92,.36 L1,.36 L1,.27Z M.99,.13 A.12,.12,0,1,1,.75,.13 A.12,.12,0,1,1,.99,.13"},"🮳":{type:3,data:"M0,.27 L.3,.27 L.55,.12 L.63,.18 L.33,.36 L0,.36 M0,.52 L.33,.52 L.59,.89 L.73,.89 L.73,.98 L.53,.98 L.28,.6 L0,.6"},"🮴":{type:4,data:{d:"M.15,.55 L.5,.4 L.5,.45 L.65,.45 L.65,.35 L.85,.35 L.85,.625 L.5,.625 L.5,.7 Z",type:0},scaleType:1},"🮵":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.15,.5 L.5,.35 L.5,.425 L.85,.425 L.85,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮶":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.85,.5 L.5,.35 L.5,.425 L.15,.425 L.15,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮷":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.675 L.2,.5 L.35,.5 L.35,.325 L.65,.325 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮸":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.325 L.2,.5 L.35,.5 L.35,.675 L.65,.675 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮹":{type:5,data:{d:"M1,.89 L.11,.89 L.11,.37 L.36,.12 L.74,.12 L.96,.34 L1,.34 L1,.405 L.92,.405 L.69,.185 L.41,.185 L.21,.42 L.21,.825 L1,.825 Z",type:0}},"🮺":{type:5,data:{d:"M0,.89 L0,.825 L.78,.825 L.78,.53 L.7,.415 L0,.415 L0,.35 L.75,.35 L.88,.48 L.88,.89 Z",type:0}},"🮻":{type:5,data:{d:"M.31,.275 L.44,.275 L.44,.47 L.05,.47 L.05,.405 L.31,.405 Z M.56,.275 L.69,.275 L.69,.405 L.95,.405 L.95,.47 L.56,.47 Z M.05,.53 L.44,.53 L.44,.725 L.31,.725 L.31,.595 L.05,.595 Z M.56,.53 L.95,.53 L.95,.595 L.69,.595 L.69,.725 L.56,.725 Z",type:0},scaleType:1},"🮼":[{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0,.935 L.885,.935 L.885,.065 L0,.065 Z"},{type:3,data:"M.67,.5 A.17,.085,0,1,1,.33,.5 A.17,.085,0,1,1,.67,.5",scaleType:1}],"🮽":{type:4,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1 Z",type:1}},"🮾":{type:4,data:{d:"M1,.5 L.5,1",type:1}},"🮿":{type:4,data:{d:"M.5,0 L1,.5 L.5,1 L0,.5 Z",type:1}},"🯀":{type:3,data:"M.16,.445 A.02,.01,0,0,1,.39,.33 L.5,.375 L.61,.33 A.02,.01,0,0,1,.84,.445 L.75,.5 L.84,.555 A.02,.01,0,0,1,.61,.67 L.5,.625 L.39,.67 A.02,.01,0,0,1,.16,.555 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",scaleType:1},"🯁":{type:3,data:"M0.142308,0.924 Q0.130770,0.924,0.120193,0.922 T0.101924,0.916 T0.089424,0.9065 T0.084616,0.895 V0.025 Q0.084616,0.019,0.089424,0.0135 T0.101924,0.004 T0.120193,-0.002 T0.142308,-0.004 Q0.150000,-0.004,0.157693,-0.003 T0.173078,0.000 L0.430770,0.085 Q0.451924,0.059,0.494232,0.041 T0.587501,0.013 T0.692309,-0.0005 T0.800001,-0.004 H1 V0.055 H0.800001 Q0.771155,0.055,0.742309,0.056 T0.685578,0.060 T0.630770,0.0685 T0.580770,0.0825 T0.543270,0.1045 T0.528847,0.133 V0.647 H0.530770 Q0.596155,0.645,0.659616,0.638 T0.782693,0.6165 T0.893270,0.5805 T1,0.531 V0.623 Q0.934616,0.644,0.880770,0.6595 T0.769232,0.685 T0.650963,0.700 T0.528847,0.707 V0.787 Q0.528847,0.802,0.543270,0.8155 T0.580770,0.8375 T0.630770,0.8515 T0.685578,0.860 T0.742309,0.864 T0.800001,0.865 H1 V0.924 H0.800001 Q0.746155,0.924,0.692309,0.9205 T0.587501,0.907 T0.494232,0.879 T0.430770,0.835 L0.173078,0.920 Q0.165386,0.922,0.157693,0.923 T0.142308,0.924 Z M0.2,0.841 L0.415385,0.770 V0.150 L0.2,0.079 V0.841 Z M1,0.698 Q0.973077,0.694,0.969231,0.6885 T0.965385,0.677 Q0.965385,0.672,0.969231,0.6665 T1,0.657 V0.698 Z"},"🯂":{type:3,data:"M0,0.623 V0.531 Q0.044231,0.512,0.0625,0.4905 T0.092308,0.4465 T0.108654,0.4005 T0.113462,0.354 V0.351 Q0.113462,0.345,0.117308,0.3395 T0.129808,0.3305 T0.148846,0.3245 T0.171154,0.323 H0.501923 Q0.532692,0.323,0.563462,0.3185 T0.617308,0.303 T0.651923,0.2765 T0.663462,0.2435 V0.241 Q0.663462,0.219,0.657692,0.197 T0.639423,0.1545 T0.604808,0.115 T0.549615,0.082 T0.475577,0.0615 T0.392308,0.055 H0 V-0.004 H1 V0.055 H0.667308 Q0.694231,0.071,0.713462,0.09 T0.746154,0.129 T0.766346,0.1705 T0.775,0.213 H1 V0.316 Q0.971154,0.305,0.955769,0.2965 T0.920192,0.2825 T0.876923,0.2745 T0.830769,0.272 H0.773077 Q0.767308,0.297,0.743269,0.319 T0.680769,0.355 T0.595192,0.375 T0.501923,0.381 H0.227308 Q0.223462,0.415,0.211,0.4485 T0.172692,0.5135 T0.108269,0.573 T0,0.623 Z M0.611538,0.924 H0 V0.865 H0.611538 Q0.642308,0.865,0.673077,0.8605 T0.727885,0.845 T0.762308,0.8185 T0.773077,0.787 V0.785 Q0.773077,0.769,0.762308,0.7535 T0.727885,0.727 T0.673077,0.7115 T0.611538,0.707 H0.059615 Q0.048077,0.707,0.037115,0.7045 T0,0.694 V0.653 Q0.026923,0.648,0.037115,0.646 T0.059615,0.644 H0.722692 Q0.753462,0.644,0.784231,0.6395 T0.839038,0.624 T0.873846,0.5975 T0.884615,0.566 V0.564 Q0.884615,0.548,0.873846,0.532 T0.839038,0.5055 T0.784231,0.49 T0.722692,0.4855 H0.392308 Q0.380769,0.4855,0.370192,0.483 T0.351923,0.4765 T0.339423,0.467 T0.334615,0.4555 T0.339423,0.444 T0.351923,0.4345 T0.370192,0.428 T0.392308,0.4255 H0.832692 Q0.855769,0.4255,0.878846,0.4235 T0.922115,0.416 T0.957692,0.4015 T1,0.3815 V0.4685 Q0.975,0.4705,0.966346,0.4725 T0.95,0.4765 Q0.961538,0.4835,0.969231,0.4915 T1,0.5075 V0.6205 Q0.965385,0.6455,0.926923,0.665 T0.84,0.6935 Q0.866923,0.7115,0.877596,0.7345 T0.894231,0.7855 V0.787 Q0.894231,0.815,0.876923,0.8425 T0.820192,0.8895 T0.726923,0.916 T0.611538,0.924 Z"},"🯃":{type:3,data:"M0,0.473 V0.386 Q0.025490,0.378,0.028431,0.3695 T0.031373,0.352 V0.35 Q0.031373,0.342,0.028431,0.333 T0,0.316 V0.213 H0.652941 Q0.684314,0.213,0.715686,0.2085 T0.770588,0.193 T0.804902,0.1665 T0.815686,0.135 V0.133 Q0.815686,0.117,0.804902,0.101 T0.770588,0.0745 T0.715686,0.0595 T0.652941,0.055 H0 V-0.004 H0.652941 Q0.707843,-0.004,0.761765,0.004 T0.856863,0.031 T0.915686,0.0775 T0.933333,0.133 V0.135 Q0.933333,0.163,0.915686,0.1905 T0.856863,0.237 T0.761765,0.264 T0.652941,0.272 H0.109804 Q0.131373,0.29,0.140196,0.31 T0.149020,0.35 V0.352 Q0.149020,0.37,0.142157,0.388 T0.118627,0.4225 T0.076471,0.452 T0,0.473 Z M0,0.625 V0.513 Q0.029412,0.526,0.032353,0.54 T0.035294,0.568 V0.57 Q0.035294,0.584,0.032353,0.598 T0,0.625 Z"},"🯄":{type:3,data:"M0.019231,1.085 V-0.165 H0.980769 V1.085 H0.019231 Z M0.446154,0.527 H0.553846 Q0.553846,0.511,0.5625,0.495 T0.591346,0.466 T0.631731,0.4405 T0.666346,0.4135 T0.688462,0.3825 T0.696154,0.35 Q0.696154,0.33,0.682692,0.311 T0.641346,0.2785 T0.575,0.259 T0.498077,0.253 T0.421154,0.259 T0.356731,0.279 T0.315385,0.3125 T0.301923,0.352 V0.357 H0.409615 V0.354 Q0.409615,0.345,0.414423,0.335 T0.431731,0.318 T0.4625,0.3075 T0.498077,0.304 Q0.517308,0.304,0.534615,0.307 T0.564423,0.3165 T0.582692,0.332 T0.588462,0.35 Q0.588462,0.366,0.572115,0.3805 T0.535577,0.4075 T0.496154,0.4335 T0.465385,0.4625 T0.45,0.4945 T0.446154,0.527 Z M0.5,0.667 Q0.519231,0.667,0.5375,0.664 T0.569231,0.654 T0.588462,0.637 T0.594231,0.617 T0.588462,0.5975 T0.569231,0.581 T0.5375,0.571 T0.5,0.568 T0.4625,0.571 T0.430769,0.581 T0.411538,0.5975 T0.405769,0.617 T0.411538,0.637 T0.430769,0.654 T0.4625,0.664 T0.5,0.667 Z",scaleType:1},"🯅":{type:5,data:{d:"M.44,.425 L.44,.51 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.51 L.56,.425 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯆":{type:5,data:{d:"M.44,.425 L.44,.46 L.23,.385 L.19,.43 L.44,.51 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.61,.735 L.7,.71 L.56,.56 L.56,.51 L.81,.43 L.77,.385 L.56,.46 L.56,.425 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯇":{type:5,data:{d:"M.44,.425 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.425 Z M.18,.53 L.23,.575 L.81,.43 L.77,.385 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯈":{type:5,data:{d:"M.44,.425 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.62,.735 L.71,.71 L.56,.56 L.56,.425 Z M.23,.385 L.18,.43 L.77,.575 L.81,.53 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯉":{type:5,data:{d:"M.44,.425 L.45,.495 L.15,.645 L.34,.645 L.34,.7 L.44,.7 L.44,.645 L.56,.645 L.56,.7 L.66,.7 L.66,.645 L.84,.645 L.54,.495 L.56,.425 Z M.39,.6 L.5,.55 L.60,.6 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯊":{type:5,data:{d:"M.26,.375 L.5,.255 L.74,.375 L.74,.665 L.5,.55 L.26,.665 Z M.37,.395 L.37,.54 L.5,.475 L.63,.54 L.63,.395 L.5,.33 Z",type:0},scaleType:1},"🯋":{type:5,data:{d:"M.09,.41 L.32,.295 L.5,.375 L.68,.295 L.91,.41 L.75,.5 L.91,.59 L.68,.705 L.5,.625 L.32,.705 L.09,.59 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",type:0},scaleType:1},"🯌":{type:5,data:{d:"M.55,.305 L.88,.305 L.88,.355 L.65,.355 L.65,.47 L.88,.47 L.88,.52 L.55,.52 Z",type:0},scaleType:1},"🯍":{type:5,data:{d:"M.38,.39 L.5,.33 L.62,.39 L.62,.53 L.5,.47 L.38,.53 Z",type:0},scaleType:1},"🯎":{type:3,data:"M0,0 L0.6667,0 L0.6667,1 L0,1 Z"},"🯏":{type:3,data:"M0,0 L0.3333,0 L0.3333,1 L0,1 Z"},"🯐":{type:2,data:"M1,.5 L0,1",strokeWidth:1},"🯑":{type:2,data:"M1,0 L0,.5",strokeWidth:1},"🯒":{type:2,data:"M0,0 L1,.5",strokeWidth:1},"🯓":{type:2,data:"M0,.5 L1,1",strokeWidth:1},"🯔":{type:2,data:"M0,0 L.5,1",strokeWidth:1},"🯕":{type:2,data:"M.5,0 L1,1",strokeWidth:1},"🯖":{type:2,data:"M1,0 L.5,1",strokeWidth:1},"🯗":{type:2,data:"M.5,0 L0,1",strokeWidth:1},"🯘":{type:2,data:"M0,0 L.5,.5 L1,0",strokeWidth:1},"🯙":{type:2,data:"M1,0 L.5,.5 L1,1",strokeWidth:1},"🯚":{type:2,data:"M0,1 L.5,.5 L1,1",strokeWidth:1},"🯛":{type:2,data:"M0,0 L.5,.5 L0,1",strokeWidth:1},"🯜":{type:2,data:"M0,0 L.5,1 L1,0",strokeWidth:1},"🯝":{type:2,data:"M1,0 L0,.5 L1,1",strokeWidth:1},"🯞":{type:2,data:"M0,1 L.5,0 L1,1",strokeWidth:1},"🯟":{type:2,data:"M0,0 L1,.5 L0,1",strokeWidth:1},"🯠":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0",type:1}},"🯡":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1",type:1}},"🯢":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1",type:1}},"🯣":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1",type:1}},"🯤":{type:0,data:[{x:2,y:0,w:4,h:4}]},"🯥":{type:0,data:[{x:2,y:4,w:4,h:4}]},"🯦":{type:0,data:[{x:0,y:2,w:4,h:4}]},"🯧":{type:0,data:[{x:4,y:2,w:4,h:4}]},"🯨":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0 Z",type:0}},"🯩":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1 Z",type:0}},"🯪":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1 Z",type:0}},"🯫":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1 Z",type:0}},"🯬":{type:5,data:{d:"M1,0 L.5,0 C.5,.276,.724,.5,1,.5 Z",type:0}},"🯭":{type:5,data:{d:"M0,1 L.5,1 C.5,.724,.276,.5,0,.5 Z",type:0}},"🯮":{type:5,data:{d:"M1,1 L1,.5 C.724,.5,.5,.724,.5,1 Z",type:0}},"🯯":{type:5,data:{d:"M0,0 L0,.5 C.276,.5,.5,.276,.5,0 Z",type:0}},"🯰":{type:5,data:{d:Uo(126),type:0},scaleType:1},"🯱":{type:5,data:{d:Uo(48),type:0},scaleType:1},"🯲":{type:5,data:{d:Uo(109),type:0},scaleType:1},"🯳":{type:5,data:{d:Uo(121),type:0},scaleType:1},"🯴":{type:5,data:{d:Uo(51),type:0},scaleType:1},"🯵":{type:5,data:{d:Uo(91),type:0},scaleType:1},"🯶":{type:5,data:{d:Uo(95),type:0},scaleType:1},"🯷":{type:5,data:{d:Uo(114),type:0},scaleType:1},"🯸":{type:5,data:{d:Uo(127),type:0},scaleType:1},"🯹":{type:5,data:{d:Uo(123),type:0},scaleType:1},"🯺":{type:5,data:{d:"M.5,.175 C.2,.175,.15,.305,.15,.435 L.05,.63 L.35,.63 C.35,.682,.42,.76,.5,.76 C.58,.76,.65,.682,.65,.63 L.95,.63 L.85,.435 C.85,.305,.8,.175,.5,.175 Z",type:0},scaleType:1},...Object.fromEntries(Array.from({length:256},(e,t)=>[String.fromCodePoint(10240+t),{type:6,data:t}]))},QS=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function Cr(e){return{type:2,data:()=>{let t=[],r=[.375,.25,.375],n=[0,3/8,5/8];for(let a=0;a<3;a++){let l=e>>a*2&1,c=e>>a*2+1&1;l&&c?t.push(`M0,${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L0,${n[a]+r[a]} Z`):l?t.push(`M0,${n[a]} L${.5},${n[a]} L${.5},${n[a]+r[a]} L0,${n[a]+r[a]} Z`):c&&t.push(`M${.5},${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L${.5},${n[a]+r[a]} Z`)}return t.join(" ")}}}function Uo(e){let t=[];if(e&64){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.2125} L${r+.075},${.175} L${n-.075},${.175} L${n},${.2125} L${n-.075},${.25} L${r+.075},${.25} Z`)}if(e&32){let r=.7999999999999999,n=.95-.15/2,a=.95,l=.175+.075+.015,c=.5-.015;t.push(`M${n},${l} L${a},${l+.0375} L${a},${c-.0375} L${n},${c} L${r},${c-.0375} L${r},${l+.0375} Z`)}if(e&16){let r=.7999999999999999,n=.95-.15/2,a=.95,l=.5+.015,c=.825-.075-.015;t.push(`M${n},${l} L${a},${l+.0375} L${a},${c-.0375} L${n},${c} L${r},${c-.0375} L${r},${l+.0375} Z`)}if(e&8){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.7875} L${r+.075},${.75} L${n-.075},${.75} L${n},${.7875} L${n-.075},${.825} L${r+.075},${.825} Z`)}if(e&4&&t.push(`M${.125},${.515} L${.2},${.515+.0375} L${.2},${.735-.0375} L${.125},${.735} L${.05},${.735-.0375} L${.05},${.515+.0375} Z`),e&2&&t.push(`M${.125},${.265} L${.2},${.265+.0375} L${.2},${.485-.0375} L${.125},${.485} L${.05},${.485-.0375} L${.05},${.265+.0375} Z`),e&1){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.5} L${r+.075},${.4625} L${n-.075},${.4625} L${n},${.5} L${n-.075},${.5375} L${r+.075},${.5375} Z`)}return t.join(" ")}var wi=0,ti=0,zo=!1,gl=!1,Od=!1,oa,z0=0,PS=class{constructor(e,t,r,n,a,l){this._terminal=e,this._optionService=t,this._selectionRenderModel=r,this._decorationService=n,this._coreBrowserService=a,this._themeService=l,this.result={fg:0,bg:0,ext:0}}resolve(e,t,r,n,a){this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,ti=0,wi=0,gl=!1,zo=!1,Od=!1,oa=this._themeService.colors,z0=0;let l=e.getCode();if(l!==0&&e.extended.underlineStyle===4){let c=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));z0=t*n%(Math.round(c)*2)}if(z0===0&&QS.has(l)&&(z0=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",c=>{c.backgroundColorRGB&&(ti=c.backgroundColorRGB.rgba>>8&16777215,gl=!0),c.foregroundColorRGB&&(wi=c.foregroundColorRGB.rgba>>8&16777215,zo=!0)}),Od=this._selectionRenderModel.isCellSelected(this._terminal,t,r),Od){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ti=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ti=(this.result.fg&16777215)<<8|255;break;default:ti=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ti=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ti=(this.result.bg&16777215)<<8|255;break}ti=_c.blend(ti,(this._coreBrowserService.isFocused?oa.selectionBackgroundOpaque:oa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ti=(this._coreBrowserService.isFocused?oa.selectionBackgroundOpaque:oa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(gl=!0,oa.selectionForeground&&(wi=oa.selectionForeground.rgba>>8&16777215,zo=!0),h3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)wi=(this._coreBrowserService.isFocused?oa.selectionBackgroundOpaque:oa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:wi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:wi=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:wi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:wi=(this.result.fg&16777215)<<8|255;break;default:wi=this._themeService.colors.foreground.rgba}wi=_c.blend(wi,(this._coreBrowserService.isFocused?oa.selectionBackgroundOpaque:oa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}zo=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",c=>{c.backgroundColorRGB&&(ti=c.backgroundColorRGB.rgba>>8&16777215,gl=!0),c.foregroundColorRGB&&(wi=c.foregroundColorRGB.rgba>>8&16777215,zo=!0)}),gl&&(Od?ti=e.bg&-16777216&-134217729|ti|50331648:ti=e.bg&-16777216|ti|50331648),zo&&(wi=e.fg&-16777216&-67108865|wi|50331648),this.result.fg&67108864&&(gl&&!zo&&((this.result.bg&50331648)===0?wi=this.result.fg&-134217728|oa.background.rgba>>8&16777215&16777215|50331648:wi=this.result.fg&-134217728|this.result.bg&67108863,zo=!0),!gl&&zo&&((this.result.fg&50331648)===0?ti=this.result.bg&-67108864|oa.foreground.rgba>>8&16777215&16777215|50331648:ti=this.result.bg&-67108864|this.result.fg&67108863,gl=!0)),oa=void 0,this.result.bg=gl?ti:this.result.bg,this.result.fg=zo?wi:this.result.fg,this.result.ext&=536870911,this.result.ext|=z0<<29&3758096384}},OS=.5,f3=CS||_S?"bottom":"ideographic";function FS(e,t,r,n,a,l,c,h,p,g,x,y,A=0){let v=BS[t];if(v){let L=Array.isArray(v)?v:[v];for(let I of L)$S(e,I,r,n,a,l,c,h,p,g,x,y,A);return!0}return!1}function $S(e,t,r,n,a,l,c,h,p,g,x,y,A=0){let v=a,L=l,I=r,E=n;switch(t.scaleType===1&&(v=c,L=h,I=r+(a-c)/2,E=n+(l-h)/2),t.clipPath&&(e.save(),YS(e,t.clipPath,I,E,v,L)),t.type){case 0:US(e,t.data,I,E,v,L);break;case 1:VS(e,t.data,I,E,v,L,A);break;case 2:qS(e,t.data,I,E,v,L,g,x,t.strokeWidth);break;case 3:HS(e,t.data,I,E,v,L,g,t.strokeWidth);break;case 4:GS(e,t.data,I,E,v,L,g,y);break;case 5:ZS(e,t.data,I,E,v,L,p,g,x);break;case 6:zS(e,t.data,I,E,v,L);break}t.clipPath&&e.restore()}function US(e,t,r,n,a,l){for(let c=0;c<t.length;c++){let h=t[c],p=a/8,g=l/8;e.fillRect(r+h.x*p,n+h.y*g,h.w*p,h.h*g)}}var Qg=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function zS(e,t,r,n,a,l){let c=a/8,h=l*.1,p=l*.8/8,g=Math.min(c,p);for(let x=0;x<8;x++)if(t&1<<x){let y=Qg[x*2],A=Qg[x*2+1],v=r+(y+1)*c,L=n+h+(A+1)*p;e.beginPath(),e.arc(v,L,g,0,Math.PI*2),e.fill()}}function HS(e,t,r,n,a,l,c,h){let p=typeof t=="string"?t:t(0,0);e.beginPath();let g=0,x=0,y=0,A=0,v="";for(let L of p.split(" ")){let I=L[0],E=L.substring(1).split(",");if(I==="Z"){e.closePath(),v=I;continue}if(I==="V"){let P=n+parseFloat(E[0])*l;e.lineTo(g,P),x=P,y=g,A=x,v=I;continue}if(I==="H"){let P=r+parseFloat(E[0])*a;e.lineTo(P,x),g=P,y=g,A=x,v=I;continue}if(!E[0]||!E[1])continue;if(I==="A"){let P=parseFloat(E[0])*a,Q=parseFloat(E[1])*l,$=parseFloat(E[2])*Math.PI/180,W=parseInt(E[3],10),B=parseInt(E[4],10),q=r+parseFloat(E[5])*a,ne=n+parseFloat(E[6])*l;WS(e,g,x,P,Q,$,W,B,q,ne),g=q,x=ne;continue}let R=E.map((P,Q)=>{let $=parseFloat(P);return Q%2===0?r+$*a:n+$*l});if(I==="M")e.moveTo(R[0],R[1]),g=R[0],x=R[1],y=g,A=x;else if(I==="L")e.lineTo(R[0],R[1]),g=R[0],x=R[1],y=g,A=x;else if(I==="Q")e.quadraticCurveTo(R[0],R[1],R[2],R[3]),y=R[0],A=R[1],g=R[2],x=R[3];else if(I==="T"){let P,Q;v==="Q"||v==="T"?(P=2*g-y,Q=2*x-A):(P=g,Q=x),e.quadraticCurveTo(P,Q,R[0],R[1]),y=P,A=Q,g=R[0],x=R[1]}else I==="C"&&(e.bezierCurveTo(R[0],R[1],R[2],R[3],R[4],R[5]),y=R[2],A=R[3],g=R[4],x=R[5]);v=I}h!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=c*h,e.stroke()):e.fill()}function WS(e,t,r,n,a,l,c,h,p,g){if(n===0||a===0){e.lineTo(p,g);return}n=Math.abs(n),a=Math.abs(a);let x=Math.cos(l),y=Math.sin(l),A=(t-p)/2,v=(r-g)/2,L=x*A+y*v,I=-y*A+x*v,E=n*n,R=a*a,P=L*L,Q=I*I,$=P/E+Q/R;if($>1){let ce=Math.sqrt($);n*=ce,a*=ce,E=n*n,R=a*a}let W=(E*R-E*Q-R*P)/(E*Q+R*P);W<0&&(W=0);let B=(c===h?-1:1)*Math.sqrt(W),q=B*(n*I/a),ne=B*-(a*L/n),Be=x*q-y*ne+(t+p)/2,fe=y*q+x*ne+(r+g)/2,X=(L-q)/n,Qe=(I-ne)/a,Pe=(-L-q)/n,ue=(-I-ne)/a,Ce=Math.atan2(Qe,X),tt=Math.atan2(ue,Pe)-Ce;h===0&&tt>0?tt-=2*Math.PI:h===1&&tt<0&&(tt+=2*Math.PI);let we=Ce+tt;e.ellipse(Be,fe,n,a,l,Ce,we,h===0)}function GS(e,t,r,n,a,l,c,h){e.save(),e.fillRect(r,n,a,l),h&&(e.fillStyle=h,e.strokeStyle=h),e.lineWidth=c,e.lineCap="square",e.beginPath();for(let p of t.d.split(" ")){let g=p[0],x=p.substring(1).split(",");if(!x[0]||!x[1]){g==="Z"&&e.closePath();continue}let y=x.map((A,v)=>{let L=parseFloat(A);return v%2===0?r+L*a:n+L*l});g==="M"?e.moveTo(y[0],y[1]):g==="L"&&e.lineTo(y[0],y[1])}t.type===1?e.stroke():e.fill(),e.restore()}var Pg=new Map;function VS(e,t,r,n,a,l,c=0){let h=Pg.get(t);h||(h=new Map,Pg.set(t,h));let p=e.fillStyle;if(typeof p!="string")throw new Error(`Unexpected fillStyle type "${p}"`);let g=h.get(p);if(!g){let A=t[0].length,v=t.length,L=e.canvas.ownerDocument.createElement("canvas");L.width=A,L.height=v;let I=Fs(L.getContext("2d")),E=new ImageData(A,v),R,P,Q,$;if(p.startsWith("#"))R=parseInt(p.slice(1,3),16),P=parseInt(p.slice(3,5),16),Q=parseInt(p.slice(5,7),16),$=p.length>7&&parseInt(p.slice(7,9),16)||1;else if(p.startsWith("rgba"))[R,P,Q,$]=p.substring(5,p.length-1).split(",").map(W=>parseFloat(W));else throw new Error(`Unexpected fillStyle color format "${p}" when drawing pattern glyph`);for(let W=0;W<v;W++)for(let B=0;B<A;B++)E.data[(W*A+B)*4]=R,E.data[(W*A+B)*4+1]=P,E.data[(W*A+B)*4+2]=Q,E.data[(W*A+B)*4+3]=t[W][B]*($*255);I.putImageData(E,0,0),g=Fs(e.createPattern(L,null)),h.set(p,g)}let x=c>>1&1,y=c&1;x!==0||y!==0?g.setTransform(new DOMMatrix().translateSelf(-x,-y)):g.setTransform(new DOMMatrix),e.fillStyle=g,e.fillRect(r,n,a,l)}function qS(e,t,r,n,a,l,c,h,p){e.save(),e.beginPath(),e.rect(r,n,a,l),e.clip(),e.beginPath();let g;if(typeof t=="function"){let y=.15/l*a;g=t(.15,y)}else g=t;let x={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let y of g.split(" ")){let A=y[0];if(A==="Z"){e.closePath(),x.lastCommand=A;continue}let v=p3[A];if(!v){h.error(`Could not find drawing instructions for "${A}"`);continue}let L=y.substring(1).split(",");!L[0]||!L[1]||(v(e,m3(L,a,l,r,n,!0,c,0,0,!1),x),x.lastCommand=A)}p!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=c*p,e.stroke()):e.fill(),e.closePath(),e.restore()}function YS(e,t,r,n,a,l){e.beginPath();for(let c of t.split(" ")){let h=c[0];if(h==="Z"){e.closePath();continue}let p=c.substring(1).split(",");if(!p[0]||!p[1])continue;let g=r+parseFloat(p[0])*a,x=n+parseFloat(p[1])*l;h==="M"?e.moveTo(g,x):h==="L"&&e.lineTo(g,x)}e.clip()}function ZS(e,t,r,n,a,l,c,h,p){let g=new Path2D;g.rect(r,n,a,l),e.clip(g),e.beginPath();let x=c/12;e.lineWidth=h*x;let y={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let A of t.d.split(" ")){let v=A[0];if(v==="Z"){e.closePath(),y.lastCommand=v;continue}let L=p3[v];if(!L){p.error(`Could not find drawing instructions for "${v}"`);continue}let I=A.substring(1).split(",");!I[0]||!I[1]||(L(e,m3(I,a,l,r,n,!1,h,(t.leftPadding??0)*(x/2),(t.rightPadding??0)*(x/2)),y),y.lastCommand=v)}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function Og(e,t,r=0){return Math.max(Math.min(e,t),r)}var p3={C:(e,t,r)=>{e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),r.lastControlX=t[2],r.lastControlY=t[3],r.currentX=t[4],r.currentY=t[5]},L:(e,t,r)=>{e.lineTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},M:(e,t,r)=>{e.moveTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},Q:(e,t,r)=>{e.quadraticCurveTo(t[0],t[1],t[2],t[3]),r.lastControlX=t[0],r.lastControlY=t[1],r.currentX=t[2],r.currentY=t[3]},T:(e,t,r)=>{let n,a;r.lastCommand==="Q"||r.lastCommand==="T"?(n=2*r.currentX-r.lastControlX,a=2*r.currentY-r.lastControlY):(n=r.currentX,a=r.currentY),e.quadraticCurveTo(n,a,t[0],t[1]),r.lastControlX=n,r.lastControlY=a,r.currentX=t[0],r.currentY=t[1]}};function m3(e,t,r,n,a,l,c,h=0,p=0,g=!0){let x=e.map(y=>parseFloat(y)||parseInt(y));if(x.length<2)throw new Error("Too few arguments for instruction");for(let y=0;y<x.length;y+=2){if(x[y]*=t-h*c-p*c,l&&x[y]!==0){let A=Math.round(x[y]+.5)-.5;x[y]=g?Og(A,t,0):A}x[y]+=n+h*c}for(let y=1;y<x.length;y+=2){if(x[y]*=r,l&&x[y]!==0){let A=Math.round(x[y]+.5)-.5;x[y]=g?Og(A,r,0):A}x[y]+=a}return x}var Fg=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},$g=class{constructor(){this._data=new Fg}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new Fg),this._data.get(e,t).set(r,n,a)}get(e,t,r,n){return this._data.get(e,t)?.get(r,n)}clear(){this._data.clear()}},g3=class{constructor(e){this._tasks=[],this._i=0,this._logService=e}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t,r=0,n=e.timeRemaining(),a;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),a=e.timeRemaining(),r*1.5>a){n-t<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=a}this.clear()}},KS=class extends g3{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let r=performance.now()+t;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},XS=class extends g3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},JS="requestIdleCallback"in globalThis?XS:KS,a0=class x3{constructor(){this.fg=0,this.bg=0,this.extended=new b3}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new x3;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},b3=class y3{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new y3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ko=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return qs(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let l=qs(()=>{let c=this._listeners.indexOf(a);c!==-1&&this._listeners.splice(c,1)});return n&&(Array.isArray(n)?n.push(l):n.add(l)),l},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:r,thisArgs:n}=this._listeners[0];r.call(n,t);return}default:{let r=this._listeners.slice();for(let{fn:n,thisArgs:a}of r)n.call(a,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},Ac;(e=>{function t(l,c){return l(h=>c.fire(h))}e.forward=t;function r(l,c){return(h,p,g)=>l(x=>h.call(p,c(x)),void 0,g)}e.map=r;function n(...l){return(c,h,p)=>{let g=new c3;for(let x of l)g.add(x(y=>c.call(h,y)));return p&&(Array.isArray(p)?p.push(g):p.add(g)),g}}e.any=n;function a(l,c,h){return c(h),l(p=>c(p))}e.runAndSubscribe=a})(Ac||={});var Ug={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},H0=2,W0,zl=class r0{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new $g,this._cacheMapCombined=new $g,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new a0,this._textureSize=512,this._onAddTextureAtlasCanvas=new ko,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new ko,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=w3(t,this._config.deviceCellWidth*4+H0*2,this._config.deviceCellHeight+H0*2),this._tmpCtx=Fs(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose(),this._onRemoveTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new JS(this._logService);for(let r=33;r<126;r++)t.enqueue(()=>{if(!this._cacheMap.get(r,0,0,0)){let n=this._drawToCache(r,0,0,0,!1,void 0);this._cacheMap.set(r,0,0,0,n)}})}beginFrame(){let t=this._requestClearModel;return this._requestClearModel=!1,t}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(r0.maxAtlasPages&&this._pages.length>=Math.max(4,r0.maxAtlasPages)){let r=this._pages.filter(g=>g.canvas.width*2<=(r0.maxTextureSize||4096)).sort((g,x)=>x.canvas.width!==g.canvas.width?x.canvas.width-g.canvas.width:x.percentageUsed-g.percentageUsed),n=-1,a=0;for(let g=0;g<r.length;g++)if(r[g].canvas.width!==a)n=g,a=r[g].canvas.width;else if(g-n===3)break;let l=r.slice(n,n+4);if(l.length<4||l.some(g=>g.canvas.width!==l[0].canvas.width)){let g=new uc(this._document,this._textureSize);return this._pages.push(g),this._activePages.push(g),this._onAddTextureAtlasCanvas.fire(g.canvas),g}let c=l.map(g=>g.glyphs[0].texturePage).sort((g,x)=>g-x),h=this.pages.length-l.length,p=this._mergePages(l,h);p.version=++uc.nextVersion;for(let g=c.length-1;g>=0;g--)this._deletePage(c[g]);this.pages.push(p),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(p.canvas)}let t=new uc(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(t,r){let n=t[0].canvas.width*2,a=new uc(this._document,n,t);for(let[l,c]of t.entries()){let h=l*c.canvas.width%n,p=Math.floor(l/2)*c.canvas.height;a.ctx.drawImage(c.canvas,h,p);for(let x of c.glyphs)x.texturePage=r,x.sizeClipSpace.x=x.size.x/n,x.sizeClipSpace.y=x.size.y/n,x.texturePosition.x+=h,x.texturePosition.y+=p,x.texturePositionClipSpace.x=x.texturePosition.x/n,x.texturePositionClipSpace.y=x.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(c.canvas);let g=this._activePages.indexOf(c);g!==-1&&this._activePages.splice(g,1)}return a}_deletePage(t){this._pages.splice(t,1);for(let r=t;r<this._pages.length;r++){let n=this._pages[r];for(let a of n.glyphs)a.texturePage--;n.version=++uc.nextVersion}}getRasterizedGlyphCombinedChar(t,r,n,a,l,c){return this._getFromCacheMap(this._cacheMapCombined,t,r,n,a,l,c)}getRasterizedGlyph(t,r,n,a,l,c){return this._getFromCacheMap(this._cacheMap,t,r,n,a,l,c)}_getFromCacheMap(t,r,n,a,l,c,h){return W0=t.get(r,n,a,l),W0||(W0=this._drawToCache(r,n,a,l,c,h),t.set(r,n,a,l,W0)),W0}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,r,n,a){if(this._config.allowTransparency)return to;let l;switch(t){case 16777216:case 33554432:l=this._getColorFromAnsiIndex(r);break;case 50331648:let c=a0.toColorRGB(r);l=ra.toColor(c[0],c[1],c[2]);break;default:n?l=Su.opaque(this._config.colors.foreground):l=this._config.colors.background;break}return this._config.allowTransparency||(l=Su.opaque(l)),l}_getForegroundColor(t,r,n,a,l,c,h,p,g,x){let y=this._getMinimumContrastColor(t,r,n,a,l,c,h,g,p,x);if(y)return y;let A;switch(l){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&g&&c<8&&(c+=8),A=this._getColorFromAnsiIndex(c);break;case 50331648:let v=a0.toColorRGB(c);A=ra.toColor(v[0],v[1],v[2]);break;default:h?A=this._config.colors.background:A=this._config.colors.foreground}return this._config.allowTransparency&&(A=Su.opaque(A)),p&&(A=Su.multiplyOpacity(A,OS)),A}_resolveBackgroundRgba(t,r,n){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(t,r,n,a){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&a&&r<8&&(r+=8),this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(t,r,n,a,l,c,h,p,g,x){if(this._config.minimumContrastRatio===1||x)return;let y=this._getContrastCache(g),A=y.getColor(t,a);if(A!==void 0)return A??void 0;let v=this._resolveBackgroundRgba(r,n,h),L=this._resolveForegroundRgba(l,c,h,p),I=_c.ensureContrastRatio(v,L,this._config.minimumContrastRatio/(g?2:1));if(!I){y.setColor(t,a,null);return}let E=ra.toColor(I>>24&255,I>>16&255,I>>8&255);return y.setColor(t,a,E),E}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,r,n,a,l,c){let h=typeof t=="number"?String.fromCharCode(t):t;c&&this._tmpCanvas.parentElement!==c&&(this._tmpCanvas.style.display="none",c.append(this._tmpCanvas));let p=Math.min(this._config.deviceCellWidth*Math.max(h.length,2)+H0*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<p&&(this._tmpCanvas.width=p);let g=Math.min(this._config.deviceCellHeight+H0*4,this._textureSize);if(this._tmpCanvas.height<g&&(this._tmpCanvas.height=g),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=r,this._workAttributeData.extended.ext=a,!!this._workAttributeData.isInvisible())return Ug;let x=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),A=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),L=!!this._workAttributeData.isUnderline(),I=!!this._workAttributeData.isStrikethrough(),E=!!this._workAttributeData.isOverline(),R=this._workAttributeData.getFgColor(),P=this._workAttributeData.getFgColorMode(),Q=this._workAttributeData.getBgColor(),$=this._workAttributeData.getBgColorMode();if(y){let ke=R;R=Q,Q=ke;let se=P;P=$,$=se}let W=this._getBackgroundColor($,Q,y,A);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let B=x?this._config.fontWeightBold:this._config.fontWeight,q=v?"italic":"";this._tmpCtx.font=`${q} ${B} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=f3;let ne=h.length===1&&l1(h.charCodeAt(0)),Be=h.length===1&&IS(h.charCodeAt(0)),fe=this._getForegroundColor(r,$,Q,n,P,R,y,A,x,h3(h.charCodeAt(0)));this._tmpCtx.fillStyle=fe.css;let X=Be?0:H0*2,Qe=!1;if(this._config.customGlyphs!==!1){let ke=this._workAttributeData.getUnderlineVariantOffset();Qe=FS(this._tmpCtx,h,X,X,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,W.css,ke)}let Pe=!ne,ue;if(typeof t=="number"?ue=this._unicodeService.wcwidth(t):ue=this._unicodeService.getStringCellWidth(t),L){this._tmpCtx.save();let ke=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),se=ke%2===1?.5:0;if(this._tmpCtx.lineWidth=ke,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())Pe=!1,this._tmpCtx.strokeStyle=`rgb(${a0.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{Pe=!1;let Fe=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&Fe<8&&(Fe+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(Fe).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let je=X,de=Math.ceil(X+this._config.deviceCharHeight)-se-(l?ke*2:0),Oe=de+ke*2,Ee=this._workAttributeData.getUnderlineVariantOffset(),_e=0,re=0;for(let Fe=0;Fe<ue;Fe++){let wt=!1;this._tmpCtx.save(),_e=de,re=Oe;let Xe=je+Fe*this._config.deviceCellWidth,ee=je+(Fe+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Xe,de),this._tmpCtx.lineTo(ee,de),this._tmpCtx.moveTo(Xe,Oe),this._tmpCtx.lineTo(ee,Oe);break;case 3:_e=this._config.deviceCharHeight+1,re=_e+3*this._config.devicePixelRatio;let Ue=new Path2D;Ue.rect(Xe,_e,this._config.deviceCellWidth,re-_e),this._tmpCtx.clip(Ue);let Le=this._config.deviceCellWidth,te=re-_e,ye=Le/6,ot=te/3,le=[[0,2,1,3,2.4,3,0,.6],[5.5,0,2.5,3,1.1,3,4.1,0],[4,0,6,2,6,.6,5.4,0]];for(let Ge of le){this._tmpCtx.beginPath();for(let pt=0;pt<Ge.length;pt+=2){let Pt=Xe+Ge[pt]*ye,hr=re-Ge[pt+1]*ot;pt===0?this._tmpCtx.moveTo(Pt,hr):this._tmpCtx.lineTo(Pt,hr)}this._tmpCtx.closePath(),this._tmpCtx.fill()}wt=!0;break;case 4:let xe=Ee===0?0:Ee>=ke?ke*2-Ee:ke-Ee;Ee>=ke||xe===0?(this._tmpCtx.setLineDash([Math.round(ke),Math.round(ke)]),this._tmpCtx.moveTo(Xe+xe,de),this._tmpCtx.lineTo(ee,de)):(this._tmpCtx.setLineDash([Math.round(ke),Math.round(ke)]),this._tmpCtx.moveTo(Xe,de),this._tmpCtx.lineTo(Xe+xe,de),this._tmpCtx.moveTo(Xe+xe+ke,de),this._tmpCtx.lineTo(ee,de)),Ee=jS(ee-Xe,ke,Ee);break;case 5:let Ne=.6,yt=.3,gt=ee-Xe,At=Math.floor(Ne*gt),Ft=Math.floor(yt*gt),Z=gt-At-Ft;this._tmpCtx.setLineDash([At,Ft,Z]),this._tmpCtx.moveTo(Xe,de),this._tmpCtx.lineTo(ee,de);break;default:this._tmpCtx.moveTo(Xe,de),this._tmpCtx.lineTo(ee,de);break}wt||this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!Qe&&this._config.fontSize>=12&&!this._config.allowTransparency&&h!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let Fe=this._tmpCtx.measureText(h);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in Fe&&Fe.actualBoundingBoxDescent>0){this._tmpCtx.save();let wt=new Path2D;wt.rect(je,_e-Math.ceil(ke/2),this._config.deviceCellWidth*ue,re-_e+Math.ceil(ke/2)),this._tmpCtx.clip(wt),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=W.css,this._tmpCtx.strokeText(h,X,X+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(E){let ke=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),se=ke%2===1?.5:0;this._tmpCtx.lineWidth=ke,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(X,X+se),this._tmpCtx.lineTo(X+this._config.deviceCharWidth*ue,X+se),this._tmpCtx.stroke()}if(Qe||this._tmpCtx.fillText(h,X,X+this._config.deviceCharHeight),h==="_"&&!this._config.allowTransparency){let ke=Xf(this._tmpCtx.getImageData(X,X,this._config.deviceCellWidth,this._config.deviceCellHeight),W,fe,Pe);if(ke)for(let se=1;se<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(h,X,X+this._config.deviceCharHeight-se),ke=Xf(this._tmpCtx.getImageData(X,X,this._config.deviceCellWidth,this._config.deviceCellHeight),W,fe,Pe),!!ke);se++);}if(I){let ke=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),se=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=ke,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(X,X+Math.floor(this._config.deviceCharHeight/2)-se),this._tmpCtx.lineTo(X+this._config.deviceCharWidth*ue,X+Math.floor(this._config.deviceCharHeight/2)-se),this._tmpCtx.stroke()}this._tmpCtx.restore();let Ce=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),tt;if(this._config.allowTransparency?tt=eC(Ce):tt=Xf(Ce,W,fe,Pe),tt)return Ug;let we=this._findGlyphBoundingBox(Ce,this._workBoundingBox,p,Be,Qe,X),ce,$e;for(;;){if(this._activePages.length===0){let ke=this._createNewPage();ce=ke,$e=ke.currentRow,$e.height=we.size.y;break}ce=this._activePages[this._activePages.length-1],$e=ce.currentRow;for(let ke of this._activePages)we.size.y<=ke.currentRow.height&&(ce=ke,$e=ke.currentRow);for(let ke=this._activePages.length-1;ke>=0;ke--)for(let se of this._activePages[ke].fixedRows)se.height<=$e.height&&we.size.y<=se.height&&(ce=this._activePages[ke],$e=se);if(we.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new uc(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),ce=this._overflowSizePage,$e=this._overflowSizePage.currentRow,$e.x+we.size.x>=ce.canvas.width&&($e.x=0,$e.y+=$e.height,$e.height=0);break}if($e.y+we.size.y>=ce.canvas.height||$e.height>we.size.y+2){let ke=!1;if(ce.currentRow.y+ce.currentRow.height+we.size.y>=ce.canvas.height){let se;for(let je of this._activePages)if(je.currentRow.y+je.currentRow.height+we.size.y<je.canvas.height){se=je;break}if(se)ce=se;else if(r0.maxAtlasPages&&this._pages.length>=r0.maxAtlasPages&&$e.y+we.size.y<=ce.canvas.height&&$e.height>=we.size.y&&$e.x+we.size.x<=ce.canvas.width)ke=!0;else{let je=this._createNewPage();ce=je,$e=je.currentRow,$e.height=we.size.y,ke=!0}}ke||(ce.currentRow.height>0&&ce.fixedRows.push(ce.currentRow),$e={x:0,y:ce.currentRow.y+ce.currentRow.height,height:we.size.y},ce.fixedRows.push($e),ce.currentRow={x:0,y:$e.y+$e.height,height:0})}if($e.x+we.size.x<=ce.canvas.width)break;$e===ce.currentRow?($e.x=0,$e.y+=$e.height,$e.height=0):ce.fixedRows.splice(ce.fixedRows.indexOf($e),1)}return we.texturePage=this._pages.indexOf(ce),we.texturePosition.x=$e.x,we.texturePosition.y=$e.y,we.texturePositionClipSpace.x=$e.x/ce.canvas.width,we.texturePositionClipSpace.y=$e.y/ce.canvas.height,we.sizeClipSpace.x/=ce.canvas.width,we.sizeClipSpace.y/=ce.canvas.height,$e.height=Math.max($e.height,we.size.y),$e.x+=we.size.x,ce.ctx.putImageData(Ce,we.texturePosition.x-this._workBoundingBox.left,we.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,we.size.x,we.size.y),ce.addGlyph(we),ce.version=++uc.nextVersion,we}_findGlyphBoundingBox(t,r,n,a,l,c){r.top=0;let h=a?this._config.deviceCellHeight:this._tmpCanvas.height,p=a?this._config.deviceCellWidth:n,g=!1;for(let x=0;x<h;x++){for(let y=0;y<p;y++){let A=x*this._tmpCanvas.width*4+y*4+3;if(t.data[A]!==0){r.top=x,g=!0;break}}if(g)break}r.left=0,g=!1;for(let x=0;x<c+p;x++){for(let y=0;y<h;y++){let A=y*this._tmpCanvas.width*4+x*4+3;if(t.data[A]!==0){r.left=x,g=!0;break}}if(g)break}r.right=p,g=!1;for(let x=c+p-1;x>=c;x--){for(let y=0;y<h;y++){let A=y*this._tmpCanvas.width*4+x*4+3;if(t.data[A]!==0){r.right=x,g=!0;break}}if(g)break}r.bottom=h,g=!1;for(let x=h-1;x>=0;x--){for(let y=0;y<p;y++){let A=x*this._tmpCanvas.width*4+y*4+3;if(t.data[A]!==0){r.bottom=x,g=!0;break}}if(g)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:r.right-r.left+1,y:r.bottom-r.top+1},sizeClipSpace:{x:r.right-r.left+1,y:r.bottom-r.top+1},offset:{x:-r.left+c+(a||l?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-r.top+c+(a||l?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},v3=class gm{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++gm.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=w3(t,r,r),this.ctx=Fs(this.canvas.getContext("2d",{alpha:!0})),n)if(n.length===4)this._glyphs=this._glyphs.concat(n[0].glyphs,n[1].glyphs,n[2].glyphs,n[3].glyphs),this._usedPixels=n[0]._usedPixels+n[1]._usedPixels+n[2]._usedPixels+n[3]._usedPixels;else for(let a=0;a<n.length;++a)this._glyphs=this._glyphs.concat(n[a].glyphs),this._usedPixels+=n[a]._usedPixels}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version=++gm.nextVersion}};v3.nextVersion=0;var uc=v3;function Xf(e,t,r,n){let a=t.rgba>>>24,l=t.rgba>>>16&255,c=t.rgba>>>8&255,h=r.rgba>>>24,p=r.rgba>>>16&255,g=r.rgba>>>8&255,x=Math.floor((Math.abs(a-h)+Math.abs(l-p)+Math.abs(c-g))/12),y=!0;for(let A=0;A<e.data.length;A+=4)e.data[A]===a&&e.data[A+1]===l&&e.data[A+2]===c||n&&Math.abs(e.data[A]-a)+Math.abs(e.data[A+1]-l)+Math.abs(e.data[A+2]-c)<x?e.data[A+3]=0:y=!1;return y}function eC(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function w3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function tC(e,t,r,n,a,l,c,h,p=!0){let g={foreground:l.foreground,background:l.background,cursor:to,cursorAccent:to,selectionForeground:to,selectionBackgroundTransparent:to,selectionBackgroundOpaque:to,selectionInactiveBackgroundTransparent:to,selectionInactiveBackgroundOpaque:to,overviewRulerBorder:to,scrollbarSliderBackground:to,scrollbarSliderHoverBackground:to,scrollbarSliderActiveBackground:to,ansi:l.ansi.slice(),contrastCache:l.contrastCache,halfContrastCache:l.halfContrastCache};return{customGlyphs:p,devicePixelRatio:c,deviceMaxTextureSize:h,letterSpacing:a.letterSpacing,lineHeight:a.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:r,deviceCharHeight:n,fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.fontWeight,fontWeightBold:a.fontWeightBold,allowTransparency:a.allowTransparency,drawBoldTextInBrightColors:a.drawBoldTextInBrightColors,minimumContrastRatio:a.minimumContrastRatio,colors:g}}function zg(e,t){for(let r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.deviceMaxTextureSize===t.deviceMaxTextureSize&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCellWidth===t.deviceCellWidth&&e.deviceCellHeight===t.deviceCellHeight&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function rC(e){return(e&50331648)===16777216||(e&50331648)===33554432}var so=[];function A3(e,t,r,n,a,l,c,h,p,g=!0){let x=tC(n,a,l,c,t,r,h,p,g);for(let L=0;L<so.length;L++){let I=so[L],E=I.ownedBy.indexOf(e);if(E>=0){if(zg(I.config,x))return I.atlas;I.ownedBy.length===1?(I.atlas.dispose(),so.splice(L,1)):I.ownedBy.splice(E,1);break}}for(let L=0;L<so.length;L++){let I=so[L];if(zg(I.config,x))return I.ownedBy.push(e),I.atlas}let y=e._core,A=y._logService,v={atlas:new zl(document,x,y.unicodeService,A),config:x,ownedBy:[e]};return so.push(v),v.atlas}function Hg(e){for(let t=0;t<so.length;t++){let r=so[t].ownedBy.indexOf(e);if(r!==-1){so[t].ownedBy.length===1?(so[t].atlas.dispose(),so.splice(t,1)):so[t].ownedBy.splice(r,1);break}}}var nC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._isIdlePaused=!1,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&(this._restartInterval(),this._resetIdleTimer())}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}restartBlinkAnimation(){this._isIdlePaused&&this._resetIdleTimer(),!this.isPaused&&(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(e=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0){this._restartInterval(t);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(t);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},600)},e)}pause(){this.isCursorVisible=!0,this._isIdlePaused=!1,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this._resetIdleTimer(),this.restartBlinkAnimation()}_resetIdleTimer(){this._isIdlePaused=!1,this._idleTimeout&&this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=this._coreBrowserService.window.setTimeout(()=>{this._stopBlinkingDueToIdle()},3e5)}_stopBlinkingDueToIdle(){this.isCursorVisible=!0,this._isIdlePaused=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0,this._renderCallback()}};function Wg(e,t,r){let n=new t.ResizeObserver(a=>{let l=a.find(p=>p.target===e);if(!l)return;if(!("devicePixelContentBoxSize"in l)){n?.disconnect(),n=void 0;return}let c=l.devicePixelContentBoxSize[0].inlineSize,h=l.devicePixelContentBoxSize[0].blockSize;c>0&&h>0&&r(c,h)});try{n.observe(e,{box:["device-pixel-content-box"]})}catch{n.disconnect(),n=void 0}return qs(()=>n?.disconnect())}function sC(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var iC=class T3 extends a0{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new b3,this.combinedData=""}static fromCharData(t){let r=new T3;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?sC(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(t){if(this.getFgColorMode()!==t.getFgColorMode()||this.getFgColor()!==t.getFgColor()||this.getBgColorMode()!==t.getBgColorMode()||this.getBgColor()!==t.getBgColor()||this.isInverse()!==t.isInverse()||this.isBold()!==t.isBold()||this.isUnderline()!==t.isUnderline())return!1;if(this.isUnderline()){if(this.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let r=this.isUnderlineColorDefault(),n=t.isUnderlineColorDefault();if(!(r&&n)&&(r!==n||this.getUnderlineColor()!==t.getUnderlineColor()||this.getUnderlineColorMode()!==t.getUnderlineColorMode()))return!1}return!(this.isOverline()!==t.isOverline()||this.isBlink()!==t.isBlink()||this.isInvisible()!==t.isInvisible()||this.isItalic()!==t.isItalic()||this.isDim()!==t.isDim()||this.isStrikethrough()!==t.isStrikethrough())}},aC=class extends Mc{constructor(e,t,r){super(),this._renderCallback=e,this._coreBrowserService=t,this._optionsService=r,this._intervalDuration=0,this._blinkOn=!0,this._needsBlinkInViewport=!1,this._isViewportVisible=!0,this._register(this._optionsService.onSpecificOptionChange("blinkIntervalDuration",n=>{this.setIntervalDuration(n)})),this.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration),this._register(qs(()=>this._clearInterval()))}get isBlinkOn(){return this._blinkOn}get isEnabled(){return this._intervalDuration>0}setNeedsBlinkInViewport(e){this._needsBlinkInViewport!==e&&(this._needsBlinkInViewport=e,this._updateIntervalState())}setViewportVisible(e){this._isViewportVisible!==e&&(this._isViewportVisible=e,this._updateIntervalState())}setIntervalDuration(e){e!==this._intervalDuration&&(this._intervalDuration=e,this._clearInterval(),this._updateIntervalState())}_updateIntervalState(){if(this._intervalDuration>0&&this._needsBlinkInViewport&&this._isViewportVisible){if(this._interval!==void 0)return;let e=this._blinkOn;this._blinkOn=!0,this._interval=this._coreBrowserService.window.setInterval(()=>{this._blinkOn=!this._blinkOn,this._renderCallback()},this._intervalDuration),e||this._renderCallback();return}this._clearInterval(),this._blinkOn||(this._blinkOn=!0,this._renderCallback())}_clearInterval(){this._interval!==void 0&&(this._coreBrowserService.window.clearInterval(this._interval),this._interval=void 0)}},S3=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function C3(e,t,r,n){let a=Fs(e.createProgram());if(e.attachShader(a,Fs(Gg(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,Fs(Gg(e,e.FRAGMENT_SHADER,r,n))),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS))return a;n.error(e.getProgramInfoLog(a)),e.deleteProgram(a)}function Gg(e,t,r,n){let a=Fs(e.createShader(t));if(e.shaderSource(a,r),e.compileShader(a),e.getShaderParameter(a,e.COMPILE_STATUS))return a;n.error(e.getShaderInfoLog(a)),e.deleteShader(a)}function oC(e,t){let r=Math.min(e.length*2,t),n=new Float32Array(r);for(let a=0;a<e.length;a++)n[a]=e[a];return n}var lC=class{constructor(t){this.texture=t,this.version=-1}},cC=`#version 300 es
4
+ layout (location = 0) in vec2 a_unitquad;
5
+ layout (location = 1) in vec2 a_cellpos;
6
+ layout (location = 2) in vec2 a_offset;
7
+ layout (location = 3) in vec2 a_size;
8
+ layout (location = 4) in float a_texpage;
9
+ layout (location = 5) in vec2 a_texcoord;
10
+ layout (location = 6) in vec2 a_texsize;
11
+
12
+ uniform mat4 u_projection;
13
+ uniform vec2 u_resolution;
14
+
15
+ out vec2 v_texcoord;
16
+ flat out int v_texpage;
17
+
18
+ void main() {
19
+ vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
20
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
21
+ v_texpage = int(a_texpage);
22
+ v_texcoord = a_texcoord + a_unitquad * a_texsize;
23
+ }`;function uC(e){let t="";for(let r=1;r<e;r++)t+=` else if (v_texpage == ${r}) { outColor = texture(u_texture[${r}], v_texcoord); }`;return`#version 300 es
24
+ precision lowp float;
25
+
26
+ in vec2 v_texcoord;
27
+ flat in int v_texpage;
28
+
29
+ uniform sampler2D u_texture[${e}];
30
+
31
+ out vec4 outColor;
32
+
33
+ void main() {
34
+ if (v_texpage == 0) {
35
+ outColor = texture(u_texture[0], v_texcoord);
36
+ } ${t}
37
+ }`}var Cs=0,us,Jf=0,G0=0,dC=class extends Mc{constructor(t,r,n,a,l){super(),this._terminal=t,this._gl=r,this._dimensions=n,this._optionsService=a,this._logService=l,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let c=this._gl;zl.maxAtlasPages===void 0&&(zl.maxAtlasPages=Math.min(32,Fs(c.getParameter(c.MAX_TEXTURE_IMAGE_UNITS))),zl.maxTextureSize=Fs(c.getParameter(c.MAX_TEXTURE_SIZE))),this._program=Fs(C3(c,cC,uC(zl.maxAtlasPages),this._logService)),this._register(qs(()=>c.deleteProgram(this._program))),this._projectionLocation=Fs(c.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Fs(c.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Fs(c.getUniformLocation(this._program,"u_texture"));let h=this._vertexArrayObject=c.createVertexArray();this._register(qs(()=>c.deleteVertexArray(h))),c.bindVertexArray(h);let p=new Float32Array([0,0,1,0,0,1,1,1]),g=c.createBuffer();this._register(qs(()=>c.deleteBuffer(g))),c.bindBuffer(c.ARRAY_BUFFER,g),c.bufferData(c.ARRAY_BUFFER,p,c.STATIC_DRAW),c.enableVertexAttribArray(0),c.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=c.createBuffer();this._register(qs(()=>c.deleteBuffer(y))),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y),c.bufferData(c.ELEMENT_ARRAY_BUFFER,x,c.STATIC_DRAW),this._attributesBuffer=Fs(c.createBuffer()),this._register(qs(()=>c.deleteBuffer(this._attributesBuffer))),c.bindBuffer(c.ARRAY_BUFFER,this._attributesBuffer),c.enableVertexAttribArray(2),c.vertexAttribPointer(2,2,c.FLOAT,!1,44,0),c.vertexAttribDivisor(2,1),c.enableVertexAttribArray(3),c.vertexAttribPointer(3,2,c.FLOAT,!1,44,2*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(3,1),c.enableVertexAttribArray(4),c.vertexAttribPointer(4,1,c.FLOAT,!1,44,4*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(4,1),c.enableVertexAttribArray(5),c.vertexAttribPointer(5,2,c.FLOAT,!1,44,5*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(5,1),c.enableVertexAttribArray(6),c.vertexAttribPointer(6,2,c.FLOAT,!1,44,7*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(6,1),c.enableVertexAttribArray(1),c.vertexAttribPointer(1,2,c.FLOAT,!1,44,9*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(1,1),c.useProgram(this._program);let A=new Int32Array(zl.maxAtlasPages);for(let v=0;v<zl.maxAtlasPages;v++)A[v]=v;c.uniform1iv(this._textureLocation,A),c.uniformMatrix4fv(this._projectionLocation,!1,S3),this._atlasTextures=[];for(let v=0;v<zl.maxAtlasPages;v++){let L=new lC(Fs(c.createTexture()));this._register(qs(()=>c.deleteTexture(L.texture))),c.activeTexture(c.TEXTURE0+v),c.bindTexture(c.TEXTURE_2D,L.texture),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,1,1,0,c.RGBA,c.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[v]=L}c.enable(c.BLEND),c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,r,n,a,l,c,h,p,g){this._updateCell(this._vertices.attributes,t,r,n,a,l,c,h,p,g)}_updateCell(t,r,n,a,l,c,h,p,g,x){if(Cs=(n*this._terminal.cols+r)*11,a===0||a===void 0){t.fill(0,Cs,Cs+11-1-2);return}this._atlas&&(p&&p.length>1?us=this._atlas.getRasterizedGlyphCombinedChar(p,l,c,h,!1,this._terminal.element):us=this._atlas.getRasterizedGlyph(a,l,c,h,!1,this._terminal.element),Jf=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),l!==x&&us.offset.x>Jf?(G0=us.offset.x-Jf,t[Cs]=-(us.offset.x-G0)+this._dimensions.device.char.left,t[Cs+1]=-us.offset.y+this._dimensions.device.char.top,t[Cs+2]=(us.size.x-G0)/this._dimensions.device.canvas.width,t[Cs+3]=us.size.y/this._dimensions.device.canvas.height,t[Cs+4]=us.texturePage,t[Cs+5]=us.texturePositionClipSpace.x+G0/this._atlas.pages[us.texturePage].canvas.width,t[Cs+6]=us.texturePositionClipSpace.y,t[Cs+7]=us.sizeClipSpace.x-G0/this._atlas.pages[us.texturePage].canvas.width,t[Cs+8]=us.sizeClipSpace.y):(t[Cs]=-us.offset.x+this._dimensions.device.char.left,t[Cs+1]=-us.offset.y+this._dimensions.device.char.top,t[Cs+2]=us.size.x/this._dimensions.device.canvas.width,t[Cs+3]=us.size.y/this._dimensions.device.canvas.height,t[Cs+4]=us.texturePage,t[Cs+5]=us.texturePositionClipSpace.x,t[Cs+6]=us.texturePositionClipSpace.y,t[Cs+7]=us.sizeClipSpace.x,t[Cs+8]=us.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&MS(a,g,us.size.x,this._dimensions.device.cell.width)&&(t[Cs+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,r=t.cols*t.rows*11;this._vertices.count!==r?this._vertices.attributes=new Float32Array(r):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==r?this._vertices.attributesBuffers[n]=new Float32Array(r):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=r,n=0;for(let a=0;a<t.rows;a++)for(let l=0;l<t.cols;l++)this._vertices.attributes[n+9]=l/t.cols,this._vertices.attributes[n+10]=a/t.rows,n+=11}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),t.uniform2f(this._resolutionLocation,this._dimensions.device.canvas.width,this._dimensions.device.canvas.height),this.clear()}render(t){if(!this._atlas)return;let r=this._gl;r.useProgram(this._program),r.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],a=0;for(let l=0;l<t.lineLengths.length;l++){let c=l*this._terminal.cols*11,h=this._vertices.attributes.subarray(c,c+t.lineLengths[l]*11);n.set(h,a),a+=h.length}r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,n.subarray(0,a),r.STREAM_DRAW);for(let l=0;l<this._atlas.pages.length;l++)this._atlas.pages[l].version!==this._atlasTextures[l].version&&this._bindAtlasPageTexture(r,this._atlas,l);r.drawElementsInstanced(r.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,a/11)}setAtlas(t){this._atlas=t,this.invalidateAtlasTextures()}invalidateAtlasTextures(){for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(t,r,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r.pages[n].canvas),this._atlasTextures[n].version=r.pages[n].version}setDimensions(t){this._dimensions=t}},hC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,r,n,a=!1){if(this.selectionStart=r,this.selectionEnd=n,!r||!n||r[0]===n[0]&&r[1]===n[1]){this.clear();return}let l=t.buffers.active.ydisp,c=r[1]-l,h=n[1]-l,p=Math.max(c,0),g=Math.min(h,t.rows-1);if(p>=t.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=a,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=r[0],this.endCol=n[0]}isCellSelected(t,r,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&n>=this.viewportCappedStartRow&&r<this.endCol&&n<=this.viewportCappedEndRow:r<this.startCol&&n>=this.viewportCappedStartRow&&r>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&r>=this.startCol):!1}};function fC(){return new hC}var pC=2147483648,mC=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=fC()}resize(t,r){let n=t*r*4;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(r))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},gC=`#version 300 es
38
+ layout (location = 0) in vec2 a_position;
39
+ layout (location = 1) in vec2 a_size;
40
+ layout (location = 2) in vec4 a_color;
41
+ layout (location = 3) in vec2 a_unitquad;
42
+
43
+ uniform mat4 u_projection;
44
+
45
+ out vec4 v_color;
46
+
47
+ void main() {
48
+ vec2 zeroToOne = a_position + (a_unitquad * a_size);
49
+ gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
50
+ v_color = a_color;
51
+ }`,xC=`#version 300 es
52
+ precision lowp float;
53
+
54
+ in vec4 v_color;
55
+
56
+ out vec4 outColor;
57
+
58
+ void main() {
59
+ outColor = v_color;
60
+ }`,Jo=8,ep=Jo*Float32Array.BYTES_PER_ELEMENT,bC=20*Jo,Vg=class{constructor(){this.attributes=new Float32Array(bC),this.count=0}},xl=0,qg=0,Yg=0,Zg=0,Kg=0,Xg=0,Jg=0,yC=class extends Mc{constructor(t,r,n,a,l){super(),this._terminal=t,this._gl=r,this._dimensions=n,this._themeService=a,this._logService=l,this._vertices=new Vg,this._verticesCursor=new Vg;let c=this._gl;this._program=Fs(C3(c,gC,xC,this._logService)),this._register(qs(()=>c.deleteProgram(this._program))),this._projectionLocation=Fs(c.getUniformLocation(this._program,"u_projection"));let h=this._vertexArrayObject=c.createVertexArray();this._register(qs(()=>c.deleteVertexArray(h))),c.bindVertexArray(h);let p=new Float32Array([0,0,1,0,0,1,1,1]),g=c.createBuffer();this._register(qs(()=>c.deleteBuffer(g))),c.bindBuffer(c.ARRAY_BUFFER,g),c.bufferData(c.ARRAY_BUFFER,p,c.STATIC_DRAW),c.enableVertexAttribArray(3),c.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let x=new Uint8Array([0,1,2,3]),y=c.createBuffer();this._register(qs(()=>c.deleteBuffer(y))),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y),c.bufferData(c.ELEMENT_ARRAY_BUFFER,x,c.STATIC_DRAW),this._attributesBuffer=Fs(c.createBuffer()),this._register(qs(()=>c.deleteBuffer(this._attributesBuffer))),c.bindBuffer(c.ARRAY_BUFFER,this._attributesBuffer),c.enableVertexAttribArray(0),c.vertexAttribPointer(0,2,c.FLOAT,!1,ep,0),c.vertexAttribDivisor(0,1),c.enableVertexAttribArray(1),c.vertexAttribPointer(1,2,c.FLOAT,!1,ep,2*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(1,1),c.enableVertexAttribArray(2),c.vertexAttribPointer(2,4,c.FLOAT,!1,ep,4*Float32Array.BYTES_PER_ELEMENT),c.vertexAttribDivisor(2,1),this._updateCachedColors(a.colors),this._register(this._themeService.onChangeColors(A=>{this._updateCachedColors(A),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let r=this._gl;r.useProgram(this._program),r.bindVertexArray(this._vertexArrayObject),r.uniformMatrix4fv(this._projectionLocation,!1,S3),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.bufferData(r.ARRAY_BUFFER,t.attributes,r.DYNAMIC_DRAW),r.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,r.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let r=this._terminal,n=this._vertices,a=1,l,c,h,p,g,x,y,A,v,L,I;for(l=0;l<r.rows;l++){for(h=-1,p=0,g=0,x=!1,c=0;c<r.cols;c++)y=(l*r.cols+c)*4,A=t.cells[y+1],v=t.cells[y+2],L=!!(v&67108864),(A!==p||v!==g&&(x||L))&&((p!==0||x&&g!==0)&&(I=a++*Jo,this._updateRectangle(n,I,g,p,h,c,l)),h=c,p=A,g=v,x=L);(p!==0||x&&g!==0)&&(I=a++*Jo,this._updateRectangle(n,I,g,p,h,r.cols,l))}n.count=a}updateCursor(t){let r=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){r.count=0;return}let a,l=0;(n.style==="bar"||n.style==="outline")&&(a=l++*Jo,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(a=l++*Jo,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(a=l++*Jo,this._addRectangleFloat(r.attributes,a,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),a=l++*Jo,this._addRectangleFloat(r.attributes,a,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),r.count=l}_updateRectangle(t,r,n,a,l,c,h){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:xl=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:xl=(n&16777215)<<8;break;default:xl=this._themeService.colors.foreground.rgba}else switch(a&50331648){case 16777216:case 33554432:xl=this._themeService.colors.ansi[a&255].rgba;break;case 50331648:xl=(a&16777215)<<8;break;default:xl=this._themeService.colors.background.rgba}t.attributes.length<r+Jo&&(t.attributes=oC(t.attributes,(this._terminal.rows*this._terminal.cols+1)*Jo)),qg=l*this._dimensions.device.cell.width,Yg=h*this._dimensions.device.cell.height,Zg=(xl>>24&255)/255,Kg=(xl>>16&255)/255,Xg=(xl>>8&255)/255,Jg=1,this._addRectangle(t.attributes,r,qg,Yg,(c-l)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Zg,Kg,Xg,Jg)}_addRectangle(t,r,n,a,l,c,h,p,g,x){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=l/this._dimensions.device.canvas.width,t[r+3]=c/this._dimensions.device.canvas.height,t[r+4]=h,t[r+5]=p,t[r+6]=g,t[r+7]=x}_addRectangleFloat(t,r,n,a,l,c,h){t[r]=n/this._dimensions.device.canvas.width,t[r+1]=a/this._dimensions.device.canvas.height,t[r+2]=l/this._dimensions.device.canvas.width,t[r+3]=c/this._dimensions.device.canvas.height,t[r+4]=h[0],t[r+5]=h[1],t[r+6]=h[2],t[r+7]=h[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},vC=class extends Mc{constructor(e,t,r,n,a,l,c,h){super(),this._container=t,this._alpha=a,this._coreBrowserService=l,this._optionsService=c,this._themeService=h,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${r}-layer`),this._canvas.style.zIndex=n.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(p=>{this._refreshCharAtlas(e,p),this.reset(e)})),this._register(qs(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Fs(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,r){}handleSelectionChanged(e,t,r,n=!1){}_setTransparency(e,t){if(t===this._alpha)return;let r=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,r),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=A3(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,r=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,r*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,r,n){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,n*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,n*this._deviceCellHeight))}_fillCharTrueColor(e,t,r,n){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=f3,this._clipCell(r,n,t.getWidth()),this._ctx.fillText(t.getChars(),r*this._deviceCellWidth+this._deviceCharLeft,n*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,r){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,r*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,r){let n=t?e.options.fontWeightBold:e.options.fontWeight;return`${r?"italic":""} ${n} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},wC=class extends vC{constructor(t,r,n,a,l,c,h){super(n,t,"link",r,!0,l,c,h),this._register(a.onShowLinkUnderline(p=>this._handleShowLinkUnderline(p))),this._register(a.onHideLinkUnderline(p=>this._handleHideLinkUnderline(p)))}resize(t,r){super.resize(t,r),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&rC(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let r=t.y1+1;r<t.y2;r++)this._fillBottomLineAtCells(0,r,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},AC=class{constructor(t,r,n,a){this._node=t,this._type=r,this._handler=n,this._options=a,t.addEventListener(r,n,a)}dispose(){!this._node||!this._handler||(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function tp(e,t,r,n){return new AC(e,t,r,n)}var TC=class extends Mc{constructor(e,t,r,n,a,l,c,h,p,g=!0,x){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=r,this._coreBrowserService=n,this._coreService=a,this._decorationService=l,this._logService=c,this._optionsService=h,this._themeService=p,this._customGlyphs=g,this._cursorBlinkStateManager=this._register(new U0),this._charAtlasDisposable=this._register(new U0),this._observerDisposable=this._register(new U0),this._model=new mC,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._workCell=new iC,this._rectangleRenderer=this._register(new U0),this._glyphRenderer=this._register(new U0),this._onChangeTextureAtlas=this._register(new ko),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ko),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ko),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new ko),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new ko),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let y={antialias:!1,depth:!1,preserveDrawingBuffer:x};if(this._gl=this._canvas.getContext("webgl2",y),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new PS(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new wC(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,h,this._themeService)],this.dimensions=DS(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(h.onOptionChange(()=>this._handleOptionsChanged())),this._textBlinkStateManager=this._register(new aC(()=>this._requestRedrawViewport(),this._coreBrowserService,this._optionsService)),this._resetBlinkingRowState(),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(tp(this._canvas,"webglcontextlost",A=>{this._logService.debug("webglcontextlost event received"),A.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,this._logService.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(A)},3e3)})),this._register(tp(this._canvas,"webglcontextrestored",A=>{this._logService.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Hg(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Wg(this._canvas,this._coreBrowserService.window,(A,v)=>this._setCanvasDevicePixelDimensions(A,v)),this._register(this._coreBrowserService.onWindowChange(A=>{this._observerDisposable.value=Wg(this._canvas,A,(v,L)=>this._setCanvasDevicePixelDimensions(v,L))})),this._register(tp(this._coreBrowserService.mainDocument,"mousedown",()=>this._cursorBlinkStateManager.value?.restartBlinkAnimation())),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(qs(()=>{clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0;for(let A of this._renderLayers)A.dispose();this._canvas.parentElement?.removeChild(this._canvas),Hg(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._resetBlinkingRowState();for(let r of this._renderLayers)r.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1),this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0})}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleViewportVisibilityChange(e){this._textBlinkStateManager.setViewportVisible(e)}handleSelectionChanged(e,t,r){for(let n of this._renderLayers)n.handleSelectionChanged(this._terminal,e,t,r);this._model.selection.update(this._core,e,t,r),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new yC(this._terminal,this._gl,this.dimensions,this._themeService,this._logService),this._glyphRenderer.value=new dC(this._terminal,this._gl,this.dimensions,this._optionsService,this._logService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=A3(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize,this._customGlyphs);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=TS(Ac.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Ac.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._resetBlinkingRowState(),this._textBlinkStateManager.setNeedsBlinkInViewport(!1),this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let a of this._renderLayers)a.handleGridChanged(this._terminal,e,t);if(!this._glyphRenderer.value||!this._rectangleRenderer.value)return;this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t);let r=!1,n=0;for(;this._charAtlas&&this._glyphRenderer.value.beginFrame()&&n++<32;)r=!0,this._clearModel(!0),this._updateModel(0,this._terminal.rows-1);r&&this._glyphRenderer.value.invalidateAtlasTextures(),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor()}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new nC(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let r=this._core,n=this._workCell,a,l,c,h,p,g,x,y,A,v,L,I,E,R,P,Q,$;e=e2(e,r.rows-1,0),t=e2(t,r.rows-1,0);let W=this._coreService.decPrivateModes.cursorStyle??r.options.cursorStyle??"block",B=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,q=B-r.buffer.ydisp,ne=Math.min(this._terminal.buffer.active.cursorX,r.cols-1),Be=-1,fe=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let X=!1;for(l=e;l<=t;l++){c=l+r.buffer.ydisp;let Qe=r.buffer.lines.get(c);if(!Qe){for(this._model.lineLengths[l]=0,Q=0;Q<r.cols;Q++)$=(l*r.cols+Q)*4,X=!0,this._nullModelCell(Q,l,$,0,0,0);this._setRowBlinkState(l,!1);continue}h=Qe;let Pe=!1;for(this._model.lineLengths[l]=0,L=B===c,x=0,p=this._characterJoinerService.getJoinedCharacters(c),Q=0;Q<r.cols;Q++){if(a=this._cellColorResolver.result.bg,h.loadCell(Q,n),Q===0&&(a=this._cellColorResolver.result.bg),g=!1,y=Q>=x,A=Q,p.length>0&&Q===p[0][0]&&y){v=p.shift();let ue=this._model.selection.isCellSelected(this._terminal,v[0],c);for(P=v[0]+1;P<v[1];P++)y&&=ue===this._model.selection.isCellSelected(this._terminal,P,c);y&&=!L||ne<v[0]||ne>=v[1],y?(g=!0,n=new SC(n,h.translateToString(!0,v[0],v[1]),v[1]-v[0]),A=v[1]-1):x=v[1]}if(I=n.getChars(),E=n.getCode(),P=(l*r.cols+Q)*4,!Pe&&n.isBlink()&&(Pe=!0),this._cellColorResolver.resolve(n,Q,c,this.dimensions.device.cell.width,this.dimensions.device.cell.height),fe&&c===B&&(Q===ne&&(this._model.cursor={x:ne,y:q,width:n.getWidth(),style:this._coreBrowserService.isFocused?W:r.options.cursorInactiveStyle,cursorWidth:r.options.cursorWidth,dpr:this._devicePixelRatio},Be=ne+n.getWidth()-1),Q>=ne&&Q<=Be&&(this._coreBrowserService.isFocused&&W==="block"||this._coreBrowserService.isFocused===!1&&r.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),this._textBlinkStateManager.isEnabled&&!this._textBlinkStateManager.isBlinkOn&&n.isBlink()&&(this._cellColorResolver.result.fg|=1073741824),E!==0&&(this._model.lineLengths[l]=Q+1),!(this._model.cells[P]===E&&this._model.cells[P+1]===this._cellColorResolver.result.bg&&this._model.cells[P+2]===this._cellColorResolver.result.fg&&this._model.cells[P+3]===this._cellColorResolver.result.ext)&&(X=!0,I.length>1&&(E|=pC),this._model.cells[P]=E,this._model.cells[P+1]=this._cellColorResolver.result.bg,this._model.cells[P+2]=this._cellColorResolver.result.fg,this._model.cells[P+3]=this._cellColorResolver.result.ext,R=n.getWidth(),this._glyphRenderer.value.updateCell(Q,l,E,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,I,R,a),g)){for(n=this._workCell,Q++;Q<=A;Q++)$=(l*r.cols+Q)*4,this._nullModelCell(Q,l,$,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext);Q--}}this._setRowBlinkState(l,Pe)}X&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model),this._updateTextBlinkState()}_nullModelCell(e,t,r,n,a,l){this._glyphRenderer.value.updateCell(e,t,0,n,a,l,"",0,0),this._model.cells[r]=0,this._model.cells[r+1]=n,this._model.cells[r+2]=a,this._model.cells[r+3]=l}_resetBlinkingRowState(){this._rowHasBlinkingCells=new Array(this._terminal.rows).fill(!1),this._rowHasBlinkingCellsCount=0}_setRowBlinkState(e,t){this._rowHasBlinkingCells[e]!==t&&(this._rowHasBlinkingCells[e]=t,this._rowHasBlinkingCellsCount+=t?1:-1)}_updateTextBlinkState(){this._textBlinkStateManager.setNeedsBlinkInViewport(this._rowHasBlinkingCellsCount>0)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1,sync:!0}))}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},SC=class extends a0{constructor(t,r,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=r,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function e2(e,t,r=0){return Math.max(Math.min(e,t),r)}var CC=class extends Mc{constructor(e){if(d3&&LS()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw new Error("WebGL2 is only supported on Safari 16 and above")}super(),this._onChangeTextureAtlas=this._register(new ko),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new ko),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new ko),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new ko),this.onContextLoss=this._onContextLoss.event,this._customGlyphs=e?.customGlyphs??!0,this._preserveDrawingBuffer=e?.preserveDrawingBuffer}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let r=t.coreService,n=t.optionsService,a=t,l=a._renderService,c=a._characterJoinerService,h=a._charSizeService,p=a._coreBrowserService,g=a._decorationService,x=a._logService,y=a._themeService;this._renderer=this._register(new TC(e,c,h,p,r,g,x,n,y,this._customGlyphs,this._preserveDrawingBuffer)),this._register(Ac.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Ac.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Ac.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Ac.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),l.setRenderer(this._renderer),this._register(qs(()=>{if(this._terminal._core._store._isDisposed)return;let A=this._terminal._core._renderService;A.setRenderer(this._terminal._core._createRenderer()),A.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};var _C=class{constructor(t,r,n,a={}){this._terminal=t,this._regex=r,this._handler=n,this._options=a}provideLinks(t,r){let n=kC.computeLink(t,this._regex,this._terminal,this._handler);r(this._addCallbacks(n))}_addCallbacks(t){return t.map(r=>(r.leave=this._options.leave,r.hover=(n,a)=>{if(this._options.hover){let{range:l}=r;this._options.hover(n,a,l)}},r))}};function LC(e){try{let t=new URL(e),r=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var kC=class yh{static computeLink(t,r,n,a){let l=r.flags.includes("g")?r.flags:`${r.flags}g`,c=new RegExp(r.source,l),[h,p]=yh._getWindowedLineStrings(t-1,n),g=h.join(""),x,y=[];for(;x=c.exec(g);){let A=x[0];if(!LC(A))continue;let[v,L]=yh._mapStrIdx(n,p,0,x.index),[I,E]=yh._mapStrIdx(n,v,L,A.length);if(v===-1||L===-1||I===-1||E===-1)continue;let R={start:{x:L+1,y:v+1},end:{x:E,y:I+1}};y.push({range:R,text:A,activate:a})}return y}static _getWindowedLineStrings(t,r){let n,a=t,l=t,c,h,p=[];if(n=r.buffer.active.getLine(t)){let g=n.translateToString(!0);if(n.isWrapped&&g[0]!==" "){for(c=0;(n=r.buffer.active.getLine(--a))&&c<2048&&(h=n.translateToString(!0),c+=h.length,p.push(h),!(!n.isWrapped||h.indexOf(" ")!==-1)););p.reverse()}for(p.push(g),c=0;(n=r.buffer.active.getLine(++l))&&n.isWrapped&&c<2048&&(h=n.translateToString(!0),c+=h.length,p.push(h),h.indexOf(" ")===-1););}return[p,a]}static _mapStrIdx(t,r,n,a){let l=t.buffer.active,c=l.getNullCell(),h=n;for(;a;){let p=l.getLine(r);if(!p)return[-1,-1];for(let g=h;g<p.length;++g){p.getCell(g,c);let x=c.getChars();if(c.getWidth()&&(a-=x.length||1,g===p.length-1&&x==="")){let y=l.getLine(r+1);y&&y.isWrapped&&(y.getCell(0,c),c.getWidth()===2&&(a+=1))}if(a<0)return[r,g]}r++,h=0}return[r,h]}},IC=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function EC(e,t){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var NC=class{constructor(t=EC,r={}){this._handler=t,this._options=r}activate(t){this._terminal=t;let r=this._options,n=r.urlRegex??IC;this._linkProvider=this._terminal.registerLinkProvider(new _C(this._terminal,n,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function t2(e){return{dispose:e}}var RC=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},MC=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return t2(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let l=t2(()=>{let c=this._listeners.indexOf(a);c!==-1&&this._listeners.splice(c,1)});return n&&(Array.isArray(n)?n.push(l):n.add(l)),l},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:r,thisArgs:n}=this._listeners[0];r.call(n,t);return}default:{let r=this._listeners.slice();for(let{fn:n,thisArgs:a}of r)n.call(a,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},DC;(e=>{function t(l,c){return l(h=>c.fire(h))}e.forward=t;function r(l,c){return(h,p,g)=>l(x=>h.call(p,c(x)),void 0,g)}e.map=r;function n(...l){return(c,h,p)=>{let g=new RC;for(let x of l)g.add(x(y=>c.call(h,y)));return p&&(Array.isArray(p)?p.push(g):p.add(g)),g}}e.any=n;function a(l,c,h){return c(h),l(p=>c(p))}e.runAndSubscribe=a})(DC||={});var r2=class vh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new MC,this.onChange=this._onChange.event}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,n=!1){return(t&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t,this._active||(this.activeVersion=t.version)}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,n=0,a=t.length;for(let l=0;l<a;++l){let c=t.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=a)return r+this.wcwidth(c);let g=t.charCodeAt(l);56320<=g&&g<=57343?c=(c-55296)*1024+g-56320+65536:r+=this.wcwidth(g)}let h=this.charProperties(c,n),p=vh.extractWidth(h);vh.extractShouldJoin(h)&&(p-=vh.extractWidth(n)),r+=p,n=h}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},rp=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],jC=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],np=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],BC=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]],bl;function n2(e,t){let r=0,n=t.length-1,a;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(a=r+n>>1,e>t[a][1])r=a+1;else if(e<t[a][0])n=a-1;else return!0;return!1}var QC=class{constructor(){if(this.version="11",!bl){bl=new Uint8Array(65536),bl.fill(1),bl[0]=0,bl.fill(0,1,32),bl.fill(0,127,160);for(let e=0;e<rp.length;++e)bl.fill(0,rp[e][0],rp[e][1]+1);for(let e=0;e<np.length;++e)bl.fill(2,np[e][0],np[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?bl[e]:n2(e,jC)?0:n2(e,BC)?2:1}charProperties(e,t){let r=this.wcwidth(e),n=r===0&&t!==0;if(n){let a=r2.extractWidth(t);a===0?n=!1:a>r&&(r=a)}return r2.createPropertyValue(0,r,n)}},PC=class{activate(e){e.unicode.register(new QC)}dispose(){}};function Nc(e){return{dispose:e}}function wh(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function OC(...e){return Nc(()=>wh(e))}var _3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(t){return this._isDisposed?t.dispose():this._disposables.add(t),t}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let t of this._disposables)t.dispose();this._disposables.clear()}}clear(){for(let t of this._disposables)t.dispose();this._disposables.clear()}},ud=class{constructor(){this._store=new _3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};ud.None=Object.freeze({dispose(){}});var zh=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},xm=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return Nc(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=Nc(()=>{let l=this._listeners.indexOf(n);l!==-1&&this._listeners.splice(l,1)});return r&&(Array.isArray(r)?r.push(a):r.add(a)),a},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:r}=this._listeners[0];t.call(r,e);return}default:{let t=this._listeners.slice();for(let{fn:r,thisArgs:n}of t)r.call(n,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},FC;(e=>{function t(l,c){return l(h=>c.fire(h))}e.forward=t;function r(l,c){return(h,p,g)=>l(x=>h.call(p,c(x)),void 0,g)}e.map=r;function n(...l){return(c,h,p)=>{let g=new _3;for(let x of l)g.add(x(y=>c.call(h,y)));return p&&(Array.isArray(p)?p.push(g):p.add(g)),g}}e.any=n;function a(l,c,h){return c(h),l(p=>c(p))}e.runAndSubscribe=a})(FC||={});function L3(e,t=0,r){let n=setTimeout(()=>{e()},t);return Nc(()=>{clearTimeout(n)})}var $C=class extends ud{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new zh),this._linesCacheDisposables=this._register(new zh),this._lastAccessTimestamp=0,this._register(Nc(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=OC(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._lastAccessTimestamp=Date.now(),this._linesCacheTimeout.value||this._scheduleLinesCacheTimeout(15e3)}_destroyLinesCache(){this._linesCache=void 0,this._lastAccessTimestamp=0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}_scheduleLinesCacheTimeout(e){this._linesCacheTimeout.value=L3(()=>{if(!this._linesCache)return;let t=Date.now()-this._lastAccessTimestamp;if(t>=15e3){this._destroyLinesCache();return}this._scheduleLinesCacheTimeout(15e3-t)},e)}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let r=[],n=[0],a=this._terminal.buffer.active.getLine(e);for(;a;){let l=this._terminal.buffer.active.getLine(e+1),c=l?l.isWrapped:!1,h=a.translateToString(!c&&t);if(c&&l){let p=a.getCell(a.length-1);p&&p.getCode()===0&&p.getWidth()===1&&l.getCell(0)?.getWidth()===2&&(h=h.slice(0,-1))}if(r.push(h),c)n.push(n[n.length-1]+h.length);else break;e++,a=l}return[r.join(""),n]}},UC=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return this._lastSearchOptions?t?this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord:!1:!0}shouldUpdateHighlighting(t,r){return r?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(r):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},zC=class{constructor(t,r){this._terminal=t,this._lineCache=r}find(t,r,n,a){if(!t||t.length===0){this._terminal.clearSelection();return}if(n>=this._terminal.cols)throw new Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let l={startRow:r,startCol:n},c=this._findInLine(t,l,a);if(!c)for(let h=r+1;h<this._terminal.buffer.active.baseY+this._terminal.rows&&(l.startRow=h,l.startCol=0,c=this._findInLine(t,l,a),!c);h++);return c}findNextWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=0,c=0;a&&(n===t?(l=a.end.x,c=a.end.y):(l=a.start.x,c=a.start.y)),this._lineCache.initLinesCache();let h={startRow:c,startCol:l},p=this._findInLine(t,h,r);if(!p)for(let g=c+1;g<this._terminal.buffer.active.baseY+this._terminal.rows&&(h.startRow=g,h.startCol=0,p=this._findInLine(t,h,r),!p);g++);if(!p&&c!==0)for(let g=0;g<c&&(h.startRow=g,h.startCol=0,p=this._findInLine(t,h,r),!p);g++);return!p&&a&&(h.startRow=a.start.y,h.startCol=0,p=this._findInLine(t,h,r)),p}findPreviousWithSelection(t,r,n){if(!t||t.length===0){this._terminal.clearSelection();return}let a=this._terminal.getSelectionPosition();this._terminal.clearSelection();let l=this._terminal.buffer.active.baseY+this._terminal.rows-1,c=this._terminal.cols,h=!0;this._lineCache.initLinesCache();let p={startRow:l,startCol:c},g;if(a&&(p.startRow=l=a.start.y,p.startCol=a.start.x,n!==t&&(g=this._findInLine(t,p,r,!1),g||(p.startRow=l=a.end.y,p.startCol=a.end.x))),g??=this._findInLine(t,p,r,h),!g){p.startCol=Math.max(p.startCol,this._terminal.cols);for(let x=l-1;x>=0&&(p.startRow=x,g=this._findInLine(t,p,r,h),!g);x--);}if(!g&&l!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let x=this._terminal.buffer.active.baseY+this._terminal.rows-1;x>=l&&(p.startRow=x,g=this._findInLine(t,p,r,h),!g);x--);return g}_isWholeWord(t,r,n){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t-1]))&&(t+n.length===r.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(r[t+n.length]))}_findInLine(t,r,n={},a=!1){let l=r.startRow,c=r.startCol;if(this._terminal.buffer.active.getLine(l)?.isWrapped){if(a){r.startCol+=this._terminal.cols;return}return r.startRow--,r.startCol+=this._terminal.cols,this._findInLine(t,r,n)}let h=this._lineCache.getLineFromCache(l);h||(h=this._lineCache.translateBufferLineToStringWithWrap(l,!0),this._lineCache.setLineInCache(l,h));let[p,g]=h,x=this._bufferColsToStringOffset(l,c),y=t,A=p;n.regex||(y=n.caseSensitive?t:t.toLowerCase(),A=n.caseSensitive?p:p.toLowerCase());let v=-1;if(n.regex){let L=RegExp(y,n.caseSensitive?"g":"gi"),I;if(a)for(;I=L.exec(A.slice(0,x));)v=L.lastIndex-I[0].length,t=I[0],L.lastIndex-=t.length-1;else I=L.exec(A.slice(x)),I&&I[0].length>0&&(v=x+(L.lastIndex-I[0].length),t=I[0])}else a?x-y.length>=0&&(v=A.lastIndexOf(y,x-y.length)):v=A.indexOf(y,x);if(v>=0){if(n.wholeWord&&!this._isWholeWord(v,A,t))return;let L=0;for(;L<g.length-1&&v>=g[L+1];)L++;let I=L;for(;I<g.length-1&&v+t.length>=g[I+1];)I++;let E=v-g[L],R=v+t.length-g[I],P=this._stringLengthToBufferSize(l+L,E),Q=this._stringLengthToBufferSize(l+I,R)-P+this._terminal.cols*(I-L);return{term:t,col:P,row:l+L,size:Q}}}_stringLengthToBufferSize(t,r){let n=this._terminal.buffer.active.getLine(t);if(!n)return 0;for(let a=0;a<r;a++){let l=n.getCell(a);if(!l)break;let c=l.getChars();c.length>1&&(r-=c.length-1);let h=n.getCell(a+1);h&&h.getWidth()===0&&r++}return r}_bufferColsToStringOffset(t,r){let n=t,a=0,l=this._terminal.buffer.active.getLine(n);for(;r>0&&l;){for(let c=0;c<r&&c<this._terminal.cols;c++){let h=l.getCell(c);if(!h)break;h.getWidth()&&(a+=h.getCode()===0?1:h.getChars().length)}if(n++,l=this._terminal.buffer.active.getLine(n),l&&!l.isWrapped)break;r-=this._terminal.cols}return a}},HC=class extends ud{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Nc(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,r){this.clearHighlightDecorations();for(let n of t){let a=this._createResultDecorations(n,r,!1);if(a)for(let l of a)this._storeDecoration(l,n)}}createActiveDecoration(t,r){let n=this._createResultDecorations(t,r,!0);if(n)return{decorations:n,match:t,dispose(){wh(n)}}}clearHighlightDecorations(){wh(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,r){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:r,dispose(){t.dispose()}})}_applyStyles(t,r,n){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),r&&(t.style.outline=`1px solid ${r}`)),n&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,r,n){let a=[],l=t.col,c=t.size,h=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;c>0;){let g=Math.min(this._terminal.cols-l,c);a.push([h,l,g]),l=0,c-=g,h++}let p=[];for(let g of a){let x=this._terminal.registerMarker(g[0]),y=this._terminal.registerDecoration({marker:x,x:g[1],width:g[2],layer:n?"top":"bottom",backgroundColor:n?r.activeMatchBackground:r.matchBackground,overviewRulerOptions:this._highlightedLines.has(x.line)?void 0:{color:n?r.activeMatchColorOverviewRuler:r.matchOverviewRuler,position:"center"}});if(y){let A=[];A.push(x),A.push(y.onRender(v=>this._applyStyles(v,n?r.activeMatchBorder:r.matchBorder,!1))),A.push(y.onDispose(()=>wh(A))),p.push(y)}}return p.length===0?void 0:p}},WC=class extends ud{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new xm)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,r){this._searchResults=t.slice(0,r)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let r=0;r<this._searchResults.length;r++){let n=this._searchResults[r];if(n.row===t.row&&n.col===t.col&&n.size===t.size)return r}return-1}fireResultsChanged(t){if(!t)return;let r=-1;this._selectedDecoration&&(r=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:r,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},GC=class extends ud{constructor(t){super(),this._highlightTimeout=this._register(new zh),this._lineCache=this._register(new zh),this._state=new UC,this._resultTracker=this._register(new WC),this._onAfterSearch=this._register(new xm),this.onAfterSearch=this._onAfterSearch.event,this._onBeforeSearch=this._register(new xm),this.onBeforeSearch=this._onBeforeSearch.event,this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new $C(t),this._engine=new zC(t,this._lineCache.value),this._decorationManager=new HC(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Nc(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=L3(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findNextAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_highlightAllMatches(t,r){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],a,l=this._engine.find(t,0,0,r);for(;l&&(a?.row!==l.row||a?.col!==l.col)&&!(n.length>=this._highlightLimit);){a=l,n.push(a);let c=this._terminal.cols,h=a.col+a.size,p=a.row;h>=c&&(p+=Math.floor(h/c),h=h%c),l=this._engine.find(t,p,h,r)}this._resultTracker.updateResults(n,this._highlightLimit),r.decorations&&this._decorationManager.createHighlightDecorations(n,r.decorations)}_findNextAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findNextWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}findPrevious(t,r,n){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._onBeforeSearch.fire(),this._state.lastSearchOptions=r,this._state.shouldUpdateHighlighting(t,r)&&this._highlightAllMatches(t,r);let a=this._findPreviousAndSelect(t,r,n);return this._fireResults(r),this._state.cachedSearchTerm=t,this._onAfterSearch.fire(),a}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,r,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let a=this._engine.findPreviousWithSelection(t,r,this._state.cachedSearchTerm);return this._selectResult(a,r?.decorations,n?.noScroll)}_selectResult(t,r,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),r){let a=this._decorationManager.createActiveDecoration(t,r);a&&(this._resultTracker.selectedDecoration=a)}if(!n&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let a=t.row-this._terminal.buffer.active.viewportY;a-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(a)}return!0}};var ai=0,oi=0,li=0,Ls=0,Qi;(e=>{function t(a,l,c,h){return h!==void 0?`#${dc(a)}${dc(l)}${dc(c)}${dc(h)}`:`#${dc(a)}${dc(l)}${dc(c)}`}e.toCss=t;function r(a,l,c,h=255){return(a<<24|l<<16|c<<8|h)>>>0}e.toRgba=r;function n(a,l,c,h){return{css:e.toCss(a,l,c,h),rgba:e.toRgba(a,l,c,h)}}e.toColor=n})(Qi||={});var VC;(e=>{function t(p,g){if(Ls=(g.rgba&255)/255,Ls===1)return{css:g.css,rgba:g.rgba};let x=g.rgba>>24&255,y=g.rgba>>16&255,A=g.rgba>>8&255,v=p.rgba>>24&255,L=p.rgba>>16&255,I=p.rgba>>8&255;ai=v+Math.round((x-v)*Ls),oi=L+Math.round((y-L)*Ls),li=I+Math.round((A-I)*Ls);let E=Qi.toCss(ai,oi,li),R=Qi.toRgba(ai,oi,li);return{css:E,rgba:R}}e.blend=t;function r(p){return(p.rgba&255)===255}e.isOpaque=r;function n(p,g,x){let y=Ah.ensureContrastRatio(p.rgba,g.rgba,x);if(y)return Qi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let g=(p.rgba|255)>>>0;return[ai,oi,li]=Ah.toChannels(g),{css:Qi.toCss(ai,oi,li),rgba:g}}e.opaque=a;function l(p,g){return Ls=Math.round(g*255),[ai,oi,li]=Ah.toChannels(p.rgba),{css:Qi.toCss(ai,oi,li,Ls),rgba:Qi.toRgba(ai,oi,li,Ls)}}e.opacity=l;function c(p,g){return Ls=p.rgba&255,l(p,Ls*g/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(VC||={});var Ci;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return ai=parseInt(a.slice(1,2).repeat(2),16),oi=parseInt(a.slice(2,3).repeat(2),16),li=parseInt(a.slice(3,4).repeat(2),16),Qi.toColor(ai,oi,li);case 5:return ai=parseInt(a.slice(1,2).repeat(2),16),oi=parseInt(a.slice(2,3).repeat(2),16),li=parseInt(a.slice(3,4).repeat(2),16),Ls=parseInt(a.slice(4,5).repeat(2),16),Qi.toColor(ai,oi,li,Ls);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let l=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(l)return ai=parseInt(l[1],10),oi=parseInt(l[2],10),li=parseInt(l[3],10),Ls=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),Qi.toColor(ai,oi,li,Ls);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ai,oi,li,Ls]=t.getImageData(0,0,1,1).data,Ls!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Qi.toRgba(ai,oi,li,Ls),css:a}}e.toColor=n})(Ci||={});var Xi;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,l){let c=n/255,h=a/255,p=l/255,g=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return g*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(Xi||={});var Ah;(e=>{function t(c,h){if(Ls=(h&255)/255,Ls===1)return h;let p=h>>24&255,g=h>>16&255,x=h>>8&255,y=c>>24&255,A=c>>16&255,v=c>>8&255;return ai=y+Math.round((p-y)*Ls),oi=A+Math.round((g-A)*Ls),li=v+Math.round((x-v)*Ls),Qi.toRgba(ai,oi,li)}e.blend=t;function r(c,h,p){let g=Xi.relativeLuminance(c>>8),x=Xi.relativeLuminance(h>>8);if(yl(g,x)<p){if(x<g){let v=n(c,h,p),L=yl(g,Xi.relativeLuminance(v>>8));if(L<p){let I=a(c,h,p),E=yl(g,Xi.relativeLuminance(I>>8));return L>E?v:I}return v}let y=a(c,h,p),A=yl(g,Xi.relativeLuminance(y>>8));if(A<p){let v=n(c,h,p),L=yl(g,Xi.relativeLuminance(v>>8));return A>L?y:v}return y}}e.ensureContrastRatio=r;function n(c,h,p){let g=c>>24&255,x=c>>16&255,y=c>>8&255,A=h>>24&255,v=h>>16&255,L=h>>8&255,I=yl(Xi.relativeLuminance2(A,v,L),Xi.relativeLuminance2(g,x,y));for(;I<p&&(A>0||v>0||L>0);)A-=Math.max(0,Math.ceil(A*.1)),v-=Math.max(0,Math.ceil(v*.1)),L-=Math.max(0,Math.ceil(L*.1)),I=yl(Xi.relativeLuminance2(A,v,L),Xi.relativeLuminance2(g,x,y));return(A<<24|v<<16|L<<8|255)>>>0}e.reduceLuminance=n;function a(c,h,p){let g=c>>24&255,x=c>>16&255,y=c>>8&255,A=h>>24&255,v=h>>16&255,L=h>>8&255,I=yl(Xi.relativeLuminance2(A,v,L),Xi.relativeLuminance2(g,x,y));for(;I<p&&(A<255||v<255||L<255);)A=Math.min(255,A+Math.ceil((255-A)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),L=Math.min(255,L+Math.ceil((255-L)*.1)),I=yl(Xi.relativeLuminance2(A,v,L),Xi.relativeLuminance2(g,x,y));return(A<<24|v<<16|L<<8|255)>>>0}e.increaseLuminance=a;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(Ah||={});function dc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function yl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var qC=Object.freeze((()=>{let e=[Ci.toColor("#2e3436"),Ci.toColor("#cc0000"),Ci.toColor("#4e9a06"),Ci.toColor("#c4a000"),Ci.toColor("#3465a4"),Ci.toColor("#75507b"),Ci.toColor("#06989a"),Ci.toColor("#d3d7cf"),Ci.toColor("#555753"),Ci.toColor("#ef2929"),Ci.toColor("#8ae234"),Ci.toColor("#fce94f"),Ci.toColor("#729fcf"),Ci.toColor("#ad7fa8"),Ci.toColor("#34e2e2"),Ci.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=t[r/36%6|0],a=t[r/6%6|0],l=t[r%6];e.push({css:Qi.toCss(n,a,l),rgba:Qi.toRgba(n,a,l)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:Qi.toCss(n,n,n),rgba:Qi.toRgba(n,n,n)})}return e})());function s2(e,t,r){return Math.max(t,Math.min(e,r))}function YC(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var k3=class{constructor(e){this._buffer=e}serialize(e,t){let r=this._buffer.getNullCell(),n=this._buffer.getNullCell(),a=r,l=e.start.y,c=e.end.y,h=e.start.x,p=e.end.x;this._beforeSerialize(c-l,l,c);for(let g=l;g<=c;g++){let x=this._buffer.getLine(g);if(x){let y=g===e.start.y?h:0,A=g===e.end.y?p:x.length;for(let v=y;v<A;v++){let L=x.getCell(v,a===r?n:r);if(!L){console.warn(`Can't get cell at row=${g}, col=${v}`);continue}this._nextCell(L,a,g,v),a=L}}this._rowEnd(g,g===c)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,r,n){}_rowEnd(e,t){}_beforeSerialize(e,t,r){}_afterSerialize(){}_serializeString(e){return""}};function c1(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function el(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function I3(e,t){if(!e.isUnderline()&&!t.isUnderline())return!0;if(e.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let r=e.isUnderlineColorDefault(),n=t.isUnderlineColorDefault();return r&&n?!0:r!==n?!1:e.getUnderlineColor()===t.getUnderlineColor()&&e.getUnderlineColorMode()===t.getUnderlineColorMode()}function u1(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&I3(e,t)&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}function E3(e,t){let r=e;return typeof r.attributesEquals=="function"?r.attributesEquals(t):c1(e,t)&&el(e,t)&&u1(e,t)}var ZC=class extends k3{constructor(t,r){super(t),this._terminal=r,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,r,n){this._allRows=new Array(t),this._lastContentCursorRow=r,this._lastCursorRow=r,this._firstRow=r}_rowEnd(t,r){this._nullCellCount>0&&!el(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n="";if(!r){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let a=this._buffer.getLine(t),l=this._buffer.getLine(t+1);if(!l.isWrapped)n=`\r
61
+ `,this._lastCursorRow=t+1,this._lastCursorCol=0;else{n="";let c=a.getCell(a.length-1,this._thisRowLastChar),h=a.getCell(a.length-2,this._thisRowLastSecondChar),p=l.getCell(0,this._nextRowFirstChar),g=p.getWidth()>1,x=!1;(p.getChars()&&g?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&el(c,p)&&(x=!0),g&&(h.getChars()||h.getWidth()===0)&&el(c,p)&&el(h,p)&&(x=!0)),x||(n="-".repeat(this._nullCellCount+1),n+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(n+="\x1B[A",n+=`\x1B[${a.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${a.length-this._nullCellCount}D`,n+="\x1B[B"),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow="",this._nullCellCount=0}_diffStyle(t,r){let n=[];if(E3(t,r))return n;let a=!c1(t,r),l=!el(t,r),c=!u1(t,r);if(a||l||c)if(t.isAttributeDefault())r.isAttributeDefault()||n.push(0);else{if(a){let h=t.getFgColor();t.isFgRGB()?n.push(38,2,h>>>16&255,h>>>8&255,h&255):t.isFgPalette()?h>=16?n.push(38,5,h):n.push(h&8?90+(h&7):30+(h&7)):n.push(39)}if(l){let h=t.getBgColor();t.isBgRGB()?n.push(48,2,h>>>16&255,h>>>8&255,h&255):t.isBgPalette()?h>=16?n.push(48,5,h):n.push(h&8?100+(h&7):40+(h&7)):n.push(49)}if(c){if(t.isInverse()!==r.isInverse()&&n.push(t.isInverse()?7:27),t.isBold()!==r.isBold()&&n.push(t.isBold()?1:22),I3(t,r))t.isUnderline()!==r.isUnderline()&&n.push(t.isUnderline()?4:24);else{let h=t.getUnderlineStyle();if(h===0)n.push(24);else if(h===1&&t.isUnderlineColorDefault())n.push(4);else if(n.push("4:"+h),!t.isUnderlineColorDefault()){let p=t.getUnderlineColor();t.isUnderlineColorRGB()?n.push("58:2::"+(p>>>16&255)+":"+(p>>>8&255)+":"+(p&255)):n.push("58:5:"+p)}}t.isOverline()!==r.isOverline()&&n.push(t.isOverline()?53:55),t.isBlink()!==r.isBlink()&&n.push(t.isBlink()?5:25),t.isInvisible()!==r.isInvisible()&&n.push(t.isInvisible()?8:28),t.isItalic()!==r.isItalic()&&n.push(t.isItalic()?3:23),t.isDim()!==r.isDim()&&n.push(t.isDim()?2:22),t.isStrikethrough()!==r.isStrikethrough()&&n.push(t.isStrikethrough()?9:29)}}return n}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let l=t.getChars()==="",c=this._diffStyle(t,this._cursorStyle);if(l?!el(this._cursorStyle,t):c.length>0){this._nullCellCount>0&&(el(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=a,this._currentRow+=`\x1B[${c.join(";")}m`;let h=this._buffer.getLine(n);h!==void 0&&(h.getCell(a,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=a)}l?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(el(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=a+t.getWidth())}_serializeString(t){let r=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(r=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n="";for(let c=0;c<r;c++)n+=this._allRows[c],c+1<r&&(n+=this._allRowSeparators[c]);if(!t){let c=this._buffer.baseY+this._buffer.cursorY,h=this._buffer.cursorX,p=c!==this._lastCursorRow||h!==this._lastCursorCol,g=x=>{x>0?n+=`\x1B[${x}C`:x<0&&(n+=`\x1B[${-x}D`)};p&&((x=>{x>0?n+=`\x1B[${x}B`:x<0&&(n+=`\x1B[${-x}A`)})(c-this._lastCursorRow),g(h-this._lastCursorCol))}let a=this._terminal._core._inputHandler._curAttrData,l=this._diffStyle(a,this._cursorStyle);return l.length>0&&(n+=`\x1B[${l.join(";")}m`),n}},KC=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,r,n){let a=r.length,l=n===void 0?a:s2(n+t.rows,0,a);return this._serializeBufferByRange(t,r,{start:a-l,end:a-1},!1)}_serializeBufferByRange(t,r,n,a){return new ZC(r,t).serialize({start:{x:0,y:typeof n.start=="number"?n.start:n.start.line},end:{x:t.cols,y:typeof n.end=="number"?n.end:n.end.line}},a)}_serializeBufferAsHTML(t,r){let n=t.buffer.active,a=new XC(n,t,r),l=r.onlySelection??!1,c=r.range;if(c)return a.serialize({start:{x:c.startCol,y:(c.startLine,c.startLine)},end:{x:t.cols,y:(c.endLine,c.endLine)}});if(!l){let p=n.length,g=r.scrollback,x=g===void 0?p:s2(g+t.rows,0,p);return a.serialize({start:{x:0,y:p-x},end:{x:t.cols,y:p-1}})}let h=this._terminal?.getSelectionPosition();return h!==void 0?a.serialize({start:{x:h.start.x,y:h.start.y},end:{x:h.end.x,y:h.end.y}}):""}_serializeScrollRegion(t){let r=t._core.buffer,n=r.scrollTop,a=r.scrollBottom;return n!==0||a!==t.rows-1?`\x1B[${n+1};${a+1}r`:""}_serializeModes(t){let r="",n=t.modes;if(n.applicationCursorKeysMode&&(r+="\x1B[?1h"),n.applicationKeypadMode&&(r+="\x1B[?66h"),n.bracketedPasteMode&&(r+="\x1B[?2004h"),n.insertMode&&(r+="\x1B[4h"),n.originMode&&(r+="\x1B[?6h"),n.reverseWraparoundMode&&(r+="\x1B[?45h"),n.sendFocusMode&&(r+="\x1B[?1004h"),n.wraparoundMode===!1&&(r+="\x1B[?7l"),n.mouseTrackingMode!=="none")switch(n.mouseTrackingMode){case"x10":r+="\x1B[?9h";break;case"vt200":r+="\x1B[?1000h";break;case"drag":r+="\x1B[?1002h";break;case"any":r+="\x1B[?1003h";break}return n.showCursor||(r+="\x1B[?25l"),r}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let r=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);if(!t?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let n=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);r+=`\x1B[?1049h\x1B[H${n}`}return t?.excludeModes||(r+=this._serializeModes(this._terminal),r+=this._serializeScrollRegion(this._terminal)),r}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t??{})}dispose(){}},XC=class extends k3{constructor(t,r,n){super(t),this._terminal=r,this._options=n,this._currentRow="",this._htmlContent="",r._core._themeService?this._ansiColors=r._core._themeService.colors.ansi:this._ansiColors=qC}_beforeSerialize(t,r,n){this._htmlContent+="<html><body><!--StartFragment--><pre>";let a="#000000",l="#ffffff";(this._options.includeGlobalBackground??!1)&&(a=this._terminal.options.theme?.foreground??"#ffffff",l=this._terminal.options.theme?.background??"#000000");let c=[];c.push("color: "+a+";"),c.push("background-color: "+l+";"),c.push("font-family: "+this._terminal.options.fontFamily+";"),c.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+c.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(t,r){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,r){let n=r?t.getFgColor():t.getBgColor();if(r?t.isFgRGB():t.isBgRGB())return"#"+[n>>16&255,n>>8&255,n&255].map(a=>a.toString(16).padStart(2,"0")).join("");if(r?t.isFgPalette():t.isBgPalette())return this._ansiColors[n].css}_getUnderlineColor(t){if(t.isUnderlineColorDefault())return;let r=t.getUnderlineColor();return t.isUnderlineColorRGB()?"#"+[r>>16&255,r>>8&255,r&255].map(n=>n.toString(16).padStart(2,"0")).join(""):this._ansiColors[r].css}_getUnderlineStyle(t){switch(t.getUnderlineStyle()){case 1:return"underline";case 2:return"underline double";case 3:return"underline wavy";case 4:return"underline dotted";case 5:return"underline dashed";default:return"underline"}}_diffStyle(t,r){let n=[];if(E3(t,r))return;let a=!c1(t,r),l=!el(t,r),c=!u1(t,r);if(a||l||c){let h=this._getHexColor(t,!0);h&&n.push("color: "+h+";");let p=this._getHexColor(t,!1);p&&n.push("background-color: "+p+";"),t.isInverse()&&n.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&n.push("font-weight: bold;");let g=[];if(t.isUnderline()&&g.push(this._getUnderlineStyle(t)),t.isOverline()&&g.push("overline"),t.isStrikethrough()&&g.push("line-through"),t.isBlink()&&g.push("blink"),g.length>0&&n.push("text-decoration: "+g.join(" ")+";"),t.isUnderline()){let x=this._getUnderlineColor(t);x&&n.push("text-decoration-color: "+x+";")}return t.isInvisible()&&n.push("visibility: hidden;"),t.isItalic()&&n.push("font-style: italic;"),t.isDim()&&n.push("opacity: 0.5;"),n}}_nextCell(t,r,n,a){if(t.getWidth()===0)return;let l=t.getChars()==="",c=this._diffStyle(t,r);c&&(this._currentRow+=c.length===0?"</span><span>":"</span><span style='"+c.join(" ")+"'>"),l?this._currentRow+=" ":this._currentRow+=YC(t.getChars())}_serializeString(){return this._htmlContent}};var JC=class{constructor(e=new e_,t=new N3){this._base64=e,this._provider=t}activate(e){this._terminal=e,this._disposable=e.parser.registerOscHandler(52,t=>this._setOrReportClipboard(t))}dispose(){return this._disposable?.dispose()}_readText(e,t){let r=this._base64.encodeText(t);this._terminal?.input(`\x1B]52;${e};${r}\x07`,!1)}_setOrReportClipboard(e){let t=e.split(";");if(t.length<2)return!0;let r=t[0],n=t[1];if(n==="?"){let c=this._provider.readText(r);return c instanceof Promise?c.then(h=>(this._readText(r,h),!0)):(this._readText(r,c),!0)}let a="";try{a=this._base64.decodeText(n)}catch{}let l=this._provider.writeText(r,a);return l instanceof Promise?l.then(()=>!0):!0}},N3=class{readText(e){return navigator.clipboard.readText()}writeText(e,t){return navigator.clipboard.writeText(t)}},e_=class{encodeText(t){let r=new TextEncoder().encode(t);if(r.toBase64!==void 0)return r.toBase64();let n="";for(let a=0;a<r.length;a++)n+=String.fromCharCode(r[a]);return btoa(n)}decodeText(t){if(Uint8Array.fromBase64!==void 0){try{return new TextDecoder().decode(Uint8Array.fromBase64(t))}catch{}return""}try{let r=atob(t),n=new Uint8Array(r.length);for(let a=0;a<r.length;++a)n[a]=r.charCodeAt(a);return new TextDecoder().decode(n)}catch{}return""}};var t_=Object.create,R3=Object.defineProperty,r_=Object.getOwnPropertyDescriptor,n_=Object.getOwnPropertyNames,s_=Object.getPrototypeOf,i_=Object.prototype.hasOwnProperty,C0=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},a_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of n_(t))!i_.call(e,a)&&a!==r&&R3(e,a,{get:()=>t[a],enumerable:!(n=r_(t,a))||n.enumerable});return e},_0=(e,t,r)=>(r=e!=null?t_(s_(e)):{},a_(!e||!e.__esModule?R3(r,"default",{value:e,enumerable:!0}):r,e)),d1=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn("BE platform detected. This version of node-sixel works only on LE properly.");function t(v){return v&255}e.red=t;function r(v){return v>>>8&255}e.green=r;function n(v){return v>>>16&255}e.blue=n;function a(v){return v>>>24&255}e.alpha=a;function l(v,L,I,E=255){return((E&255)<<24|(I&255)<<16|(L&255)<<8|v&255)>>>0}e.toRGBA8888=l;function c(v){return[v&255,v>>8&255,v>>16&255,v>>>24]}e.fromRGBA8888=c;function h(v,L){let I=t(v),E=r(v),R=n(v),P=Number.MAX_SAFE_INTEGER,Q=-1;for(let $=0;$<L.length;++$){let W=I-L[$][0],B=E-L[$][1],q=R-L[$][2],ne=W*W+B*B+q*q;if(!ne)return $;ne<P&&(P=ne,Q=$)}return Q}e.nearestColorIndex=h;function p(v,L,I){return Math.max(v,Math.min(I,L))}function g(v,L,I){return I<0&&(I+=1),I>1&&(I-=1),I*6<1?L+(v-L)*6*I:I*2<1?v:I*3<2?L+(v-L)*(4-I*6):L}function x(v,L,I){if(!I){let P=Math.round(L*255);return l(P,P,P)}let E=L<.5?L*(1+I):L+I-L*I,R=2*L-E;return l(p(0,255,Math.round(g(E,R,v+1/3)*255)),p(0,255,Math.round(g(E,R,v)*255)),p(0,255,Math.round(g(E,R,v-1/3)*255)))}function y(v,L,I){return(4278190080|Math.round(I/100*255)<<16|Math.round(L/100*255)<<8|Math.round(v/100*255))>>>0}e.normalizeRGB=y;function A(v,L,I){return x((v+240%360)/360,L/100,I/100)}e.normalizeHLS=A,e.PALETTE_VT340_COLOR=new Uint32Array([y(0,0,0),y(20,20,80),y(80,13,13),y(20,80,20),y(80,20,80),y(20,80,80),y(80,80,20),y(53,53,53),y(26,26,26),y(33,33,60),y(60,26,26),y(33,60,33),y(60,33,60),y(33,60,60),y(60,60,33),y(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46),y(0,0,0),y(13,13,13),y(26,26,26),y(40,40,40),y(6,6,6),y(20,20,20),y(33,33,33),y(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let v=[l(0,0,0),l(205,0,0),l(0,205,0),l(205,205,0),l(0,0,238),l(205,0,205),l(0,250,205),l(229,229,229),l(127,127,127),l(255,0,0),l(0,255,0),l(255,255,0),l(92,92,255),l(255,0,255),l(0,255,255),l(255,255,255)],L=[0,95,135,175,215,255];for(let I=0;I<6;++I)for(let E=0;E<6;++E)for(let R=0;R<6;++R)v.push(l(L[I],L[E],L[R]));for(let I=8;I<=238;I+=10)v.push(l(I,I,I));return new Uint32Array(v)})(),e.DEFAULT_BACKGROUND=l(0,0,0,255),e.DEFAULT_FOREGROUND=l(255,255,255,255)}),M3=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InWasm=r;var t=n=>{if(Uint8Array.fromBase64)return Uint8Array.fromBase64(n);if(typeof Buffer<"u")return Buffer.from(n,"base64");let a=atob(n),l=new Uint8Array(a.length);for(let c=0;c<l.length;++c)l[c]=a.charCodeAt(c);return l};function r(n){if(n.d){let{t:a,s:l,d:c}=n,h,p,g=WebAssembly;return a===0?l?x=>new g.Instance(p||(p=new g.Module(h||(h=t(c)))),x):x=>p?g.instantiate(p,x):g.instantiate(h||(h=t(c)),x).then(y=>(p=y.module)&&y.instance):a===1?l?()=>p||(p=new g.Module(h||(h=t(c)))):()=>p?Promise.resolve(p):g.compile(h||(h=t(c))).then(x=>p=x):l?()=>h||(h=t(c)):()=>Promise.resolve(h||(h=t(c)))}if(typeof _wasmCtx>"u")throw new Error('must run "inwasm"');_wasmCtx.add(n)}}),D3=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=M3(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqLBgKZBAEKf0GIKCgCAEGgKGohAUGEKCgCACIDQaAoaiEAQYAoKAIAQQFrQXxxIgRBoChqIQUgBEEQayADSgRAIARBkChqIQMDQCABIABBA2otAABBAnQoAoAgIABBAmotAABBAnQoAoAYIABBAWotAABBAnQoAoAQIAAtAABBAnQoAoAIcnJyIgY2AgAgAUEDaiAAQQdqLQAAQQJ0KAKAICAAQQZqLQAAQQJ0KAKAGCAAQQVqLQAAQQJ0KAKAECAAQQRqLQAAQQJ0KAKACHJyciIHNgIAIAFBBmogAEELai0AAEECdCgCgCAgAEEKai0AAEECdCgCgBggAEEJai0AAEECdCgCgBAgAEEIai0AAEECdCgCgAhycnIiCDYCACABQQlqIABBD2otAABBAnQoAoAgIABBDmotAABBAnQoAoAYIABBDWotAABBAnQoAoAQIABBDGotAABBAnQoAoAIcnJyIgk2AgAgAiAGciAHciAIciAJciECIAFBDGohASAAQRBqIgAgA0kNAAsLIAAgBUkEQANAIAEgAEEDai0AAEECdCgCgCAgAEECai0AAEECdCgCgBggAEEBai0AAEECdCgCgBAgAC0AAEECdCgCgAhycnIiAzYCACACIANyIQIgAUEDaiEBIABBBGoiACAFSQ0ACwtBfyEAIAJB////B00Ef0GEKCAENgIAQYgoIAFBoChrNgIAQQAFQX8LC+0BAQR/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQX8hAxAADQFBgCgoAgAhAUGEKCgCACEAC0F/IQMgASAAayIBQQJIDQAgAC0AoShBAnQoAoAQIAAtAKAoQQJ0KAKACHIhAgJ/IAFBBEYEQEEDQQQgAC0AoyhBPUYbIAAtAKIoQT1GayEBC0EBIAFBA0kNABogAC0AoihBAnQoAoAYIAJyIQJBAiABQQRHDQAaIAAtAKMoQQJ0KAKAICACciECQQMLIQEgAkH///8HSw0AQQAhA0GIKCgCACIAIAI2AKAoQYgoIAAgAWo2AgALIAML"}),n=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map(h=>h.charCodeAt(0))),a=new Uint32Array(1024);a.fill(4278190080);for(let h=0;h<n.length;++h)a[n[h]]=h<<2;for(let h=0;h<n.length;++h)a[256+n[h]]=h>>4|(h<<4&255)<<8;for(let h=0;h<n.length;++h)a[512+n[h]]=h>>2<<8|(h<<6&255)<<16;for(let h=0;h<n.length;++h)a[768+n[h]]=h<<16;var l=new Uint8Array(0),c=class{constructor(h,p,g){if(this._inst=null,this._ended=!0,this._bytes=0,this.keepSize=h??1048576,this.maxBytes=p??4294901760,this._bytes=g??32768,this._bytes>this.maxBytes||this.maxBytes>4294901760)throw new Error("invalid byte settings")}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):l}release(){this._inst&&(this._bytes>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(h,p){if(this.maxBytes=h??this.maxBytes,this._bytes=p??Math.min(this._bytes,this.maxBytes),this._bytes>this.maxBytes||this.maxBytes>4294901760)throw Error("invalid byte settings");let g=this._m32,x=this._bytes+5152;this._inst?this._mem.buffer.byteLength<x&&(this._mem.grow(Math.ceil((x-this._mem.buffer.byteLength)/65536)),g=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(x/65536)}),this._inst=r({env:{memory:this._mem}}),g=new Uint32Array(this._mem.buffer,0),g.set(a,256),this._d=new Uint8Array(this._mem.buffer,5152)),g[1280]=0,g[1281]=0,g[1282]=0,this._m32=g,this._ended=!1}_realloc(h){let p=this._m32[1280]+h;if(this._bytes<p){if(p>this.maxBytes)return-3;let g=this._bytes;for(;(g*=2)<p;);if(g=Math.min(g,this.maxBytes),g<p)return-3;if(g+5152>this._mem.buffer.byteLength){let x=Math.ceil((g+5152-this._mem.buffer.byteLength)/65536);this._mem.grow(x),this._m32=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)}this._bytes=g}return 0}put(h){if(!this._inst||this._ended)return-2;if(this._realloc(h.length))return-3;let p=this._m32;return this._d.set(h,p[1280]),p[1280]+=h.length,p[1280]-p[1281]>=131072?this._inst.exports.dec():0}end(){return this._ended=!0,this._inst?this._inst.exports.end():-2}get loadedBytes(){return this._inst?this._m32[1280]:0}get freeBytes(){return this._inst?this.maxBytes-this._m32[1280]:0}};e.default=c}),o_=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=M3(),r=(0,t.InWasm)({s:1,t:0,d:"AGFzbQEAAAABCgJgAABgA39/fwACDwEDZW52Bm1lbW9yeQIAAQMDAgABBwcBA2RlYwABCAEACu4EAgwAQQBBAEGAAvwLAAveBAEJf0EAQQBBgAL8CwAgAUEXTgRAIAAgAWpBCGshCkGACCEBIAJBAnRBgAhqIQsgAEEOaiEDQf8BIQZBACECA0AgA0EBaiEHIAMtAAAiCEE/cSEAAkACQCAIQcABcSIJRQRAIABBAnQiAC0AAyEGIAAtAAIhBCAALQABIQUgAC0AACECIAchAwwBCwJAIAhB/QFLDQAgCUHAAUcNACAFQQVsIAJBA2xqIARBB2xqIAZBC2xqQT9xQQJ0IgMgBDoAAiADIAU6AAEgAyACOgAAIANBA2ogBjoAAANAIAEgAjoAACABQQNqIAY6AAAgAUECaiAEOgAAIAFBAWogBToAACABQQRqIQEgAEUEQCAHIQMMBAsgAEEBayEAIAEgC0kNAAsgByEDDAILAn8CQAJAAkAgCEH+AWsOAgABAgsgAy0AAyEEIAMtAAIhBSADLQABIQIgA0EEagwCCyADKAIBIgJBGHYhBiACQRB2IQQgAkEIdiEFIANBBWoMAQsgCUGAAUcEQCAHIAlBwABHDQEaIAQgCEEDcWpBAmshBCACIABBBHZqQQJrIQIgBSAIQQJ2QQNxakECayEFIAcMAQsgBCAAQShrIgkgAy0AASIHQQ9xamohBCACIAdBBHYgCWpqIQIgACAFakEgayEFIANBAmoLIQMgBUEFbCACQQNsaiAEQQdsaiAGQQtsakE/cUECdCIAIAQ6AAIgACAFOgABIAAgAjoAACAAQQNqIAY6AAALIAEgBjoAAyABIAQ6AAIgASAFOgABIAEgAjoAACABQQRqIQELIAMgCkkNAAsLCw=="}),n=class{constructor(a){this.keepSize=a,this.width=0,this.height=0}decode(a){this.width=a[4]<<24|a[5]<<16|a[6]<<8|a[7],this.height=a[8]<<24|a[9]<<16|a[10]<<8|a[11];let l=this.width*this.height,c=l*4,h=a.length,p=Math.max(c,h)+(Math.min(c,h)>>1)+4096;this._inst?this._mem.buffer.byteLength<p&&(this._mem.grow(Math.ceil((p-this._mem.buffer.byteLength)/65536)),this._d=null):(this._mem=new WebAssembly.Memory({initial:Math.ceil(p/65536)}),this._inst=r({env:{memory:this._mem}})),this._d||(this._d=new Uint8Array(this._mem.buffer));let g=this._mem.buffer.byteLength-h&-256;return this._d.set(a,g),this._inst.exports.dec(g,h,l),this._d.subarray(1024,1024+c)}release(){this._inst&&this._mem.buffer.byteLength>this.keepSize&&(this._inst=this._d=this._mem=null)}};e.default=n}),l_=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:"AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF"}}),c_=C0(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=d1(),r=l_();function n(v){if(typeof Buffer<"u")return Buffer.from(v,"base64");let L=atob(v),I=new Uint8Array(L.length);for(let E=0;E<I.length;++E)I[E]=L.charCodeAt(E);return I}var a=n(r.LIMITS.BYTES),l,c=new Uint32Array,h=class{constructor(){this.bandHandler=v=>1,this.modeHandler=v=>1}handle_band(v){return this.bandHandler(v)}mode_parsed(v){return this.modeHandler(v)}},p={memoryLimit:2048*65536,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:r.LIMITS.PALETTE_SIZE,truncate:!0};function g(v){let L=new h,I={env:{handle_band:L.handle_band.bind(L),mode_parsed:L.mode_parsed.bind(L)}};return WebAssembly.instantiate(l||a,I).then(E=>(l=l||E.module,new x(v,E.instance||E,L)))}e.DecoderAsync=g;var x=class{constructor(v,L,I){if(this._PIXEL_OFFSET=r.LIMITS.MAX_WIDTH+4,this._canvas=c,this._bandWidths=[],this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},p,v),this._opts.paletteLimit>r.LIMITS.PALETTE_SIZE)throw new Error(`DecoderOptions.paletteLimit must not exceed ${r.LIMITS.PALETTE_SIZE}`);if(L)I.bandHandler=this._handle_band.bind(this),I.modeHandler=this._initCanvas.bind(this);else{let E=l||(l=new WebAssembly.Module(a));L=new WebAssembly.Instance(E,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=L,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),r.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),r.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(v){if(v===2){let L=this.width*this.height;if(L>this._canvas.length){if(this._opts.memoryLimit&&L*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(L)}this._maxWidth=this._width}else if(v===1)if(this._level===2){let L=Math.min(this._rasterWidth,r.LIMITS.MAX_WIDTH)*this._rasterHeight;if(L>this._canvas.length){if(this._opts.memoryLimit&&L*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");this._canvas=new Uint32Array(L)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(v,L){let I=v+L;if(I>this._canvas.length){if(this._opts.memoryLimit&&I*4>this._opts.memoryLimit)throw this.release(),new Error("image exceeds memory limit");let E=new Uint32Array(Math.ceil(I/65536)*65536);E.set(this._canvas),this._canvas=E}}_handle_band(v){let L=this._PIXEL_OFFSET,I=this._lastOffset;if(this._mode===2){let E=this.height-this._currentHeight,R=0;for(;R<6&&E>0;)this._canvas.set(this._pSrc.subarray(L*R,L*R+v),I+v*R),R++,E--;this._lastOffset+=v*R,this._currentHeight+=R}else if(this._mode===1){this._realloc(I,v*6),this._maxWidth=Math.max(this._maxWidth,v),this._minWidth=Math.min(this._minWidth,v);for(let E=0;E<6;++E)this._canvas.set(this._pSrc.subarray(L*E,L*E+v),I+v*E);this._bandWidths.push(v),this._lastOffset+=v*6,this._currentHeight+=6}return 0}get width(){return this._mode!==1?this._width:Math.max(this._maxWidth,this._wasm.current_width())}get height(){return this._mode!==1?this._height:this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(v=this._opts.fillColor,L=this._opts.palette,I=this._opts.paletteLimit,E=this._opts.truncate){this._wasm.init(this._opts.sixelColor,v,I,E?1:0),L&&this._palette.set(L.subarray(0,r.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(v,L=0,I=v.length){let E=L;for(;E<I;){let R=Math.min(I-E,r.LIMITS.CHUNK_SIZE);this._chunk.set(v.subarray(E,E+=R)),this._wasm.decode(0,R)}}decodeString(v,L=0,I=v.length){let E=L;for(;E<I;){let R=Math.min(I-E,r.LIMITS.CHUNK_SIZE);for(let P=0,Q=E;P<R;++P,++Q)this._chunk[P]=v.charCodeAt(Q);E+=R,this._wasm.decode(0,R)}}get data32(){if(this._mode===0||!this.width||!this.height)return c;let v=this._wasm.current_width();if(this._mode===2){let L=this.height-this._currentHeight;if(L>0){let I=this._PIXEL_OFFSET,E=this._lastOffset,R=0;for(;R<6&&L>0;)this._canvas.set(this._pSrc.subarray(I*R,I*R+v),E+v*R),R++,L--;L&&this._canvas.fill(this._fillColor,E+v*R)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let R=!1;if(v)if(v!==this._minWidth)R=!0;else{let P=this._PIXEL_OFFSET,Q=this._lastOffset;this._realloc(Q,v*6);for(let $=0;$<6;++$)this._canvas.set(this._pSrc.subarray(P*$,P*$+v),Q+v*$)}if(!R)return this._canvas.subarray(0,this.width*this.height)}let L=new Uint32Array(this.width*this.height);L.fill(this._fillColor);let I=0,E=0;for(let R=0;R<this._bandWidths.length;++R){let P=this._bandWidths[R];for(let Q=0;Q<6;++Q)L.set(this._canvas.subarray(E,E+=P),I),I+=this.width}if(v){let R=this._PIXEL_OFFSET,P=this._wasm.current_height();for(let Q=0;Q<P;++Q)L.set(this._pSrc.subarray(R*Q,R*Q+v),I+this.width*Q)}return L}return c}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=c,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=r.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=x;function y(v,L){let I=new x(L);return I.init(),typeof v=="string"?I.decodeString(v):I.decode(v),{width:I.width,height:I.height,data32:I.data32,data8:I.data8}}e.decode=y;async function A(v,L){let I=await g(L);return I.init(),typeof v=="string"?I.decodeString(v):I.decode(v),{width:I.width,height:I.height,data32:I.data32,data8:I.data8}}e.decodeAsync=A});function bm(e){return{dispose:e}}var j3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},B3=class{constructor(){this._store=new j3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};B3.None=Object.freeze({dispose(){}});var u_=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},d_=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(e,t,r)=>{if(this._disposed)return bm(()=>{});let n={fn:e,thisArgs:t};this._listeners.push(n);let a=bm(()=>{let l=this._listeners.indexOf(n);l!==-1&&this._listeners.splice(l,1)});return r&&(Array.isArray(r)?r.push(a):r.add(a)),a},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:r}=this._listeners[0];t.call(r,e);return}default:{let t=this._listeners.slice();for(let{fn:r,thisArgs:n}of t)r.call(n,e)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},h_;(e=>{function t(l,c){return l(h=>c.fire(h))}e.forward=t;function r(l,c){return(h,p,g)=>l(x=>h.call(p,c(x)),void 0,g)}e.map=r;function n(...l){return(c,h,p)=>{let g=new j3;for(let x of l)g.add(x(y=>c.call(h,y)));return p&&(Array.isArray(p)?p.push(g):p.add(g)),g}}e.any=n;function a(l,c,h){return c(h),l(p=>c(p))}e.runAndSubscribe=a})(h_||={});var i2=_0(d1()),b0=class Hl extends B3{constructor(t){super(),this._terminal=t,this._layers=new Map,this._optionsRefresh=this._register(new u_),this._oldOpen=this._terminal._core.open,this._terminal._core.open=r=>{this._oldOpen?.call(this._terminal._core,r),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange(r=>{r==="fontSize"&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))}),this._register(bm(()=>{this.removeLayerFromDom(),this.removeLayerFromDom("bottom"),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this._layers.clear(),this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0}))}get canvas(){return this._layers.get("top")?.canvas}static createCanvas(t,r,n){let a=(t??document).createElement("canvas");return a.width=r|0,a.height=n|0,a}static createImageData(t,r,n,a){if(typeof ImageData!="function"){let l=t.createImageData(r,n);return a&&l.data.set(new Uint8ClampedArray(a,0,r*n*4)),l}return a?new ImageData(new Uint8ClampedArray(a,0,r*n*4),r,n):new ImageData(r,n)}static createImageBitmap(t){return typeof createImageBitmap!="function"?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&this.cellSize.height!==-1&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._terminal.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,r,n){let a=t*(this.dimensions?.css.cell.height||0),l=this.dimensions?.css.canvas.width||0,c=(r+1-t)*(this.dimensions?.css.cell.height||0);(!n||n==="top")&&this._layers.get("top")?.clearRect(0,a,l,c),(!n||n==="bottom")&&this._layers.get("bottom")?.clearRect(0,a,l,c)}clearAll(t){if(!t||t==="top"){let r=this._layers.get("top");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}if(!t||t==="bottom"){let r=this._layers.get("bottom");r?.clearRect(0,0,r.canvas.width,r.canvas.height)}}draw(t,r,n,a,l=1){let c=this._layers.get(t.layer);if(!c)return;let{width:h,height:p}=this.cellSize;if(h===-1||p===-1)return;this._rescaleImage(t,h,p);let g=t.actual,x=Math.ceil(g.width/h),y=r%x*h,A=Math.floor(r/x)*p,v=n*h,L=a*p,I=l*h+y>g.width?g.width-y:l*h,E=A+p>g.height?g.height-A:p;c.drawImage(g,Math.floor(y),Math.floor(A),Math.ceil(I),Math.ceil(E),Math.floor(v),Math.floor(L),Math.ceil(I),Math.ceil(E))}extractTile(t,r){let{width:n,height:a}=this.cellSize;if(n===-1||a===-1)return;this._rescaleImage(t,n,a);let l=t.actual,c=Math.ceil(l.width/n),h=r%c*n,p=Math.floor(r/c)*a,g=n+h>l.width?l.width-h:n,x=p+a>l.height?l.height-p:a,y=Hl.createCanvas(this.document,g,x),A=y.getContext("2d");if(A)return A.drawImage(l,Math.floor(h),Math.floor(p),Math.floor(g),Math.floor(x),0,0,Math.floor(g),Math.floor(x)),y}drawPlaceholder(t,r,n=1){let a=this._layers.get("top");if(a){let{width:l,height:c}=this.cellSize;if(l===-1||c===-1||(this._placeholder?c>=this._placeholder.height&&this._createPlaceHolder(c+1):this._createPlaceHolder(Math.max(c+1,24)),!this._placeholder))return;a.drawImage(this._placeholderBitmap??this._placeholder,t*l,r*c%2?0:1,l*n,c,t*l,r*c,l*n,c)}}rescaleCanvas(){let t=this.dimensions?.css.canvas.width||0,r=this.dimensions?.css.canvas.height||0;for(let n of this._layers.values())(n.canvas.width!==t||n.canvas.height!==r)&&(n.canvas.width=t,n.canvas.height=r)}_rescaleImage(t,r,n){if(r===t.actualCellSize.width&&n===t.actualCellSize.height)return;let{width:a,height:l}=t.origCellSize;if(r===a&&n===l){t.actual=t.orig,t.actualCellSize.width=a,t.actualCellSize.height=l;return}let c=Hl.createCanvas(this.document,Math.ceil(t.orig.width*r/a),Math.ceil(t.orig.height*n/l)),h=c.getContext("2d");h&&(h.drawImage(t.orig,0,0,c.width,c.height),t.actual=c,t.actualCellSize.width=r,t.actualCellSize.height=n)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{for(let r of[...this._layers.keys()])this.removeLayerFromDom(r);this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(t="top"){if(!this.document||!this._terminal._core.screenElement){console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement");return}if(this._layers.has(t))return;let r=Hl.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0);r.classList.add(`xterm-image-layer-${t}`);let n=this._terminal._core.screenElement;n.style.isolation="isolate",t==="bottom"?(r.style.zIndex="-1",n.insertBefore(r,n.firstChild)):(r.style.zIndex="0",n.appendChild(r));let a=r.getContext("2d",{alpha:!0});if(!a){r.remove();return}this._layers.set(t,a),this.clearAll(t)}removeLayerFromDom(t="top"){let r=this._layers.get(t);r&&(r.canvas.remove(),this._layers.delete(t))}hasLayer(t){return this._layers.has(t)}_createPlaceHolder(t=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let r=32,n=Hl.createCanvas(this.document,r,t),a=n.getContext("2d",{alpha:!1});if(!a)return;let l=Hl.createImageData(a,r,t),c=new Uint32Array(l.data.buffer),h=(0,i2.toRGBA8888)(0,0,0),p=(0,i2.toRGBA8888)(255,255,255);c.fill(h);for(let y=0;y<t;++y){let A=y%2,v=y*r;for(let L=0;L<r;L+=2)c[v+L+A]=p}a.putImageData(l,0,0);let g=screen.width+r-1&-32||4096;this._placeholder=Hl.createCanvas(this.document,g,t);let x=this._placeholder.getContext("2d",{alpha:!1});if(!x){this._placeholder=void 0;return}for(let y=0;y<g;y+=r)x.drawImage(n,y,0);Hl.createImageBitmap(this._placeholder).then(y=>this._placeholderBitmap=y)}get document(){return this._terminal._core._coreBrowserService?.window.document}},_l={width:7,height:14},ym=class Q3{constructor(t=0,r=0,n=-1,a=-1){this.imageId=n,this.tileId=a,this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new Q3(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0&&this.imageId===-1}},Fd=new ym,f_=class{constructor(e,t,r){this._terminal=e,this._renderer=t,this._opts=r,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(n){n instanceof Error&&console.error(n.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let e of this._images.values())e.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return this._pixelLimit*4/1e6}setLimit(e){if(e<.5||e>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=e/4*1e6>>>0,this._evictOldest(0)}getUsage(){return this._getStoredPixels()*4/1e6}_getStoredPixels(){let e=0;for(let t of this._images.values())t.orig&&(e+=t.orig.width*t.orig.height,t.actual&&t.actual!==t.orig&&(e+=t.actual.width*t.actual.height));return e}_delImg(e){let t=this._images.get(e);t&&(this._images.delete(e),window.ImageBitmap&&t.orig instanceof ImageBitmap&&t.orig.close(),this.onImageDeleted?.(e))}wipeAlternate(){let e=[];for(let[t,r]of this._images.entries())r.bufferType==="alternate"&&(r.marker?.dispose(),e.push(t));for(let t of e)this._delImg(t);this._needsFullClear=!0,this._fullyCleared=!1}deleteImage(e){let t=this._images.get(e);t&&(t.marker?.dispose(),this._delImg(e))}addImage(e,t){this._evictOldest(e.width*e.height);let r=this._renderer.cellSize;(r.width===-1||r.height===-1)&&(r=_l);let n=Math.ceil(e.width/r.width),a=Math.ceil(e.height/r.height),l=++this._lastId,c=this._terminal._core.buffer,h=this._terminal.cols,p=this._terminal.rows,g=c.x,x=c.y,y=g,A=0;t.scrolling||(c.x=0,c.y=0,y=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(c.y);for(let E=0;E<a;++E){let R=c.lines.get(c.y+c.ybase);for(let P=0;P<n&&!(y+P>=h);++P)this._writeToCell(R,y+P,l,E*n+P),A++;if(t.scrolling)E<a-1&&this._terminal._core._inputHandler.lineFeed();else if(++c.y>=p)break;c.x=y}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(c.y),t.scrolling?t.cursorPos==="iip"?c.x=Math.min(y+n,h):c.x=y:(c.x=g,c.y=x);let v=[];for(let[E,R]of this._images.entries())R.tileCount<1&&(R.marker?.dispose(),v.push(E));for(let E of v)this._delImg(E);let L=this._terminal.registerMarker(0);L?.onDispose(()=>{this._images.get(l)&&this._delImg(l)}),this._terminal.buffer.active.type==="alternate"&&this._evictOnAlternate();let I={orig:e,origCellSize:r,actual:e,actualCellSize:{...r},marker:L||void 0,tileCount:A,bufferType:this._terminal.buffer.active.type,layer:t.layer,zIndex:t.zIndex};return this._images.set(l,I),this.onImageAdded?.(),l}render(e){let t=!1,r=!1;for(let g of this._images.values())if(g.layer==="bottom"?r=!0:t=!0,t&&r)break;if(t&&!this._renderer.hasLayer("top")&&(this._renderer.insertLayerToDom("top"),!this._renderer.hasLayer("top")))return;if(r&&!this._renderer.hasLayer("bottom")&&this._renderer.insertLayerToDom("bottom"),this._renderer.rescaleCanvas(),!this._images.size){this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),this._renderer.hasLayer("top")&&this._renderer.removeLayerFromDom("top"),this._renderer.hasLayer("bottom")&&this._renderer.removeLayerFromDom("bottom");return}!t&&this._renderer.hasLayer("top")&&(this._renderer.clearAll("top"),this._renderer.removeLayerFromDom("top")),!r&&this._renderer.hasLayer("bottom")&&(this._renderer.clearAll("bottom"),this._renderer.removeLayerFromDom("bottom")),this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:n,end:a}=e,l=this._terminal._core.buffer,c=this._terminal._core.cols;this._renderer.clearLines(n,a);let h=[],p=[];for(let g=n;g<=a;++g){let x=l.lines.get(g+l.ydisp);if(!x)return;for(let y=0;y<c;++y){let A;if(x.getBg(y)&268435456)A=x._extendedAttrs[y]??Fd;else{let I=x._extendedAttrs[y];if(!I||I.imageId===void 0||I.imageId===-1)continue;A=I}let v=A.imageId;if(v===void 0||v===-1)continue;let L=this._images.get(v);if(A.tileId!==-1){let I=A.tileId,E=y,R=1;for(;++y<c;){let P=x._extendedAttrs[y];if(!P||P.imageId!==v||P.tileId!==I+R)break;R++}y--,L?L.actual&&h.push({imgSpec:L,tileId:I,col:E,row:g,count:R}):this._opts.showPlaceholder&&p.push({col:E,row:g,count:R}),this._fullyCleared=!1}}}h.sort((g,x)=>g.imgSpec.zIndex-x.imgSpec.zIndex);for(let g of p)this._renderer.drawPlaceholder(g.col,g.row,g.count);for(let g of h)this._renderer.draw(g.imgSpec,g.tileId,g.col,g.row,g.count)}viewportResize(e){if(!this._images.size){this._viewportMetrics=e;return}if(this._viewportMetrics.cols>=e.cols){this._viewportMetrics=e;return}let t=this._terminal._core.buffer,r=t.lines.length,n=this._viewportMetrics.cols-1;for(let a=0;a<r;++a){let l=t.lines.get(a);if(l.getBg(n)&268435456){let c=l._extendedAttrs[n]??Fd,h=c.imageId;if(h===void 0||h===-1)continue;let p=this._images.get(h);if(!p)continue;let g=Math.ceil((p.actual?.width||0)/p.actualCellSize.width);if(c.tileId%g+1>=g)continue;let x=!1;for(let v=n+1;v>e.cols;++v)if(l._data[v*3+0]&4194303){x=!0;break}if(x)continue;let y=Math.min(e.cols,g-c.tileId%g+n),A=c.tileId;for(let v=n+1;v<y;++v)this._writeToCell(l,v,h,++A),p.tileCount++}}this._viewportMetrics=e}getImageAtBufferCell(e,t){let r=this._terminal._core.buffer.lines.get(t);if(r&&r.getBg(e)&268435456){let n=r._extendedAttrs[e]??Fd;if(n.imageId&&n.imageId!==-1){let a=this._images.get(n.imageId)?.orig;if(window.ImageBitmap&&a instanceof ImageBitmap){let l=b0.createCanvas(window.document,a.width,a.height);return l.getContext("2d")?.drawImage(a,0,0,a.width,a.height),l}return a}}}extractTileAtBufferCell(e,t){let r=this._terminal._core.buffer.lines.get(t);if(r&&r.getBg(e)&268435456){let n=r._extendedAttrs[e]??Fd;if(n.imageId&&n.imageId!==-1&&n.tileId!==-1){let a=this._images.get(n.imageId);if(a)return this._renderer.extractTile(a,n.tileId)}}}_evictOldest(e){let t=this._getStoredPixels(),r=t;for(;this._pixelLimit<r+e&&this._images.size;){let n=this._images.get(++this._lowestId);n&&n.orig&&(r-=n.orig.width*n.orig.height,n.actual&&n.orig!==n.actual&&(r-=n.actual.width*n.actual.height),n.marker?.dispose(),this._delImg(this._lowestId))}return t-r}_writeToCell(e,t,r,n){if(e._data[t*3+2]&268435456){let a=e._extendedAttrs[t];if(a){if(a.imageId!==void 0){let l=this._images.get(a.imageId);l&&l.tileCount--,a.imageId=r,a.tileId=n;return}e._extendedAttrs[t]=new ym(a.ext,a.urlId,r,n);return}}e._data[t*3+2]|=268435456,e._extendedAttrs[t]=new ym(0,0,r,n)}_evictOnAlternate(){for(let r of this._images.values())r.bufferType==="alternate"&&(r.tileCount=0);let e=this._terminal._core.buffer;for(let r=0;r<this._terminal.rows;++r){let n=e.lines.get(r);if(n){for(let a=0;a<this._terminal.cols;++a)if(n._data[a*3+2]&268435456){let l=n._extendedAttrs[a]?.imageId;if(l){let c=this._images.get(l);c&&c.tileCount++}}}}let t=[];for(let[r,n]of this._images.entries())n.bufferType==="alternate"&&!n.tileCount&&(n.marker?.dispose(),t.push(r));for(let r of t)this._delImg(r)}},p_=_0(D3()),m_=_0(o_());function Hh(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}function sp(e){let t=0;for(let r=0;r<e.length;++r){if(e[r]<48||e[r]>57)throw new Error("illegal char");t=t*10+e[r]-48}return t}function a2(e){let t=Hh(e);if(!t.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return t}function g_(e){if(typeof Buffer<"u")return Buffer.from(Hh(e),"base64").toString();let t=atob(Hh(e)),r=new Uint8Array(t.length);for(let n=0;n<r.length;++n)r[n]=t.charCodeAt(n);return new TextDecoder().decode(r)}var o2={inline:sp,size:sp,name:g_,width:a2,height:a2,preserveAspectRatio:sp},l2=[70,105,108,101],c2=[77,117,108,116,105,112,97,114,116,70,105,108,101],ip=[70,105,108,101,80,97,114,116],ap=[70,105,108,101,69,110,100],op=[82,101,112,111,114,116,67,101,108,108,83,105,122,101],lp=1024,x_=class{constructor(){this.state=0,this._buffer=new Uint32Array(lp),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}end(){if(this.state===0){if(this._position===ap.length){for(let t=0;t<ap.length;++t)if(this._buffer[t]!==ap[t])return this._a();return this.fields.type=4,this.state=4,0}if(this._position===op.length){for(let t=0;t<op.length;++t)if(this._buffer[t]!==op[t])return this._a();return this.fields.type=5,this.state=4,0}return this._a()}return this.state===4?0:this.state===3&&this.fields.type===2?this._storeValue(this._position)?(this.state=4,0):this._a():this._a()}parse(t,r,n){let a=this.state,l=this._position,c=this._buffer;if(a===1||a===4||a===0&&l>14)return-1;for(let h=r;h<n;++h){let p=t[h];switch(p){case 59:if(!this._storeValue(l))return this._a();a=2,l=0;break;case 61:if(a===0){if(c[0]===70){let g=0;for(;g<l2.length;++g)if(c[g]!==l2[g])return this._a();if(this.fields.type=1,l===ip.length){for(;g<ip.length;++g)if(c[g]!==ip[g])return this._a();return this.fields.type=3,this.state=4,h+1}}else if(c[0]===77){for(let g=0;g<c2.length;++g)if(c[g]!==c2[g])return this._a();this.fields.type=2}else return this._a();a=2,l=0}else if(a===2){if(!this._storeKey(l))return this._a();a=3,l=0}else if(a===3){if(l>=lp)return this._a();c[l++]=p}break;case 58:return a===3&&!this._storeValue(l)?this._a():(this.state=4,h+1);default:if(l>=lp)return this._a();c[l++]=p}}return this.state=a,this._position=l,-2}_a(){return this.fields.type=0,this.state=1,-1}_storeKey(t){let r=Hh(this._buffer.subarray(0,t));return r?(this._key=r,this.fields[r]=null,!0):!1}_storeValue(t){if(this._key){try{let r=this._buffer.slice(0,t);this.fields[this._key]=o2[this._key]?o2[this._key](r):r}catch{return!1}return!0}return!1}},Wh={mime:"unsupported",width:0,height:0};function b_(e){if(e.length<24)return Wh;let t=new Uint32Array(e.buffer,e.byteOffset,6);if(t[0]===1196314761&&t[1]===169478669&&t[3]===1380206665)return{mime:"image/png",width:e[16]<<24|e[17]<<16|e[18]<<8|e[19],height:e[20]<<24|e[21]<<16|e[22]<<8|e[23]};if(e[0]===255&&e[1]===216&&e[2]===255){let[r,n]=y_(e);return{mime:"image/jpeg",width:r,height:n}}return t[0]===944130375&&(e[4]===55||e[4]===57)&&e[5]===97?{mime:"image/gif",width:e[7]<<8|e[6],height:e[9]<<8|e[8]}:t[0]===1718185841?{mime:"image/qoi",width:e[4]<<24|e[5]<<16|e[6]<<8|e[7],height:e[8]<<24|e[9]<<16|e[10]<<8|e[11]}:Wh}function y_(e){let t=e.length,r=4,n=e[r]<<8|e[r+1];for(;;){if(r+=n,r>=t)return[0,0];if(e[r]!==255)return[0,0];if(e[r+1]===192||e[r+1]===194)return r+8<t?[e[r+7]<<8|e[r+8],e[r+5]<<8|e[r+6]]:[0,0];r+=2,n=e[r]<<8|e[r+1]}}var cp={type:0,name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},v_=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._storage=r,this._coreTerminal=n,this._aborted=!1,this._hp=new x_,this._header=cp,this._metrics=Wh,this._isMultipart=!1,this._abortMulti=!1;let a=Math.ceil(this._opts.iipSizeLimit*4/3),l=Math.min(1048576,a);this._dec=new p_.default(4194304,a,l),this._qoiDec=new m_.default(4194304)}reset(){this._hp.reset(),this._dec.release(),this._qoiDec.release()}start(){this._aborted=!1,this._metrics=Wh,this._hp.reset()}put(e,t,r){if(!this._aborted)if(this._hp.state===4)this._dec.put(e.subarray(t,r))!==0&&(this._dec.release(),this._aborted=!0);else{let n=this._hp.parse(e,t,r);if(n===-1){this._aborted=!0;return}if(n>0){if(this._hp.fields.type===1){if(this._isMultipart&&(this._isMultipart=!1,this._abortMulti=!1,this._dec.release()),this._header=Object.assign({},cp,this._hp.fields),!this._header.inline){this._aborted=!0;return}this._dec.init()}else if(this._abortMulti){this._aborted=!0;return}this._dec.put(e.subarray(n,r))!==0&&(this._dec.release(),this._aborted=!0,this._isMultipart&&(this._abortMulti=!0))}}}end(e){if(this._aborted||this._hp.state!==4&&this._hp.end())return!0;let t=this._hp.fields.type;if(t===3)return!0;if(t===5){let c=_l.width,h=_l.height;this._renderer.dimensions&&(c=this._renderer.dimensions.css.canvas.width/this._coreTerminal.cols,h=this._renderer.dimensions.css.canvas.height/this._coreTerminal.rows);let p=this._coreTerminal._core._coreBrowserService?.dpr??1,g=`\x1B]1337;ReportCellSize=${h.toFixed(3)};${c.toFixed(3)};${p.toFixed(3)}\x1B\\`;return this._coreTerminal.input(g,!1),!0}if(t===2)return this._header=Object.assign({},cp,this._hp.fields),this._isMultipart=!0,this._abortMulti=!1,this._dec.release(),this._dec.init(),!0;if(t===4&&(!this._isMultipart||(this._isMultipart=!1,this._abortMulti||this._header.type!==2)))return!0;let r=0,n=0,a;if((a=e)&&(a=!this._dec.end())&&(this._metrics=b_(this._dec.data8),(a=this._metrics.mime!=="unsupported")&&(r=this._metrics.width,n=this._metrics.height,(a=r&&n&&r*n<this._opts.pixelLimit)&&([r,n]=this._resize(r,n).map(Math.floor),a=r&&n&&r*n<this._opts.pixelLimit))),!a)return this._dec.release(),!0;let l;if(this._metrics.mime==="image/qoi"){let c=this._qoiDec.decode(this._dec.data8);if(l=new ImageData(new Uint8ClampedArray(c.buffer,c.byteOffset,c.byteLength),this._qoiDec.width,this._qoiDec.height),this._qoiDec.release(),r===this._qoiDec.width&&n===this._qoiDec.height){this._dec.release();let h=b0.createCanvas(void 0,this._qoiDec.width,this._qoiDec.height);return h.getContext("2d")?.putImageData(l,0,0),this._storage.addImage(h),!0}}else l=new Blob([this._dec.data8],{type:this._metrics.mime});return this._dec.release(),createImageBitmap(l,{resizeWidth:r,resizeHeight:n}).then(c=>(this._storage.addImage(c),!0))}_resize(e,t){let r=this._renderer.dimensions?.css.cell.width||_l.width,n=this._renderer.dimensions?.css.cell.height||_l.height,a=this._renderer.dimensions?.css.canvas.width||r*this._coreTerminal.cols,l=this._renderer.dimensions?.css.canvas.height||n*this._coreTerminal.rows,c=this._dim(this._header.width,a,r),h=this._dim(this._header.height,l,n);if(!c&&!h){let p=a/e,g=(l-n)/t,x=Math.min(p,g);return x<1?[e*x,t*x]:[e,t]}return c?this._header.preserveAspectRatio||!c||!h?[c,t*c/e]:[c,h]:[e*h/t,h]}_dim(e,t,r){return e==="auto"?0:e.endsWith("%")?parseInt(e.slice(0,-1),10)*t/100:e.endsWith("px")?parseInt(e.slice(0,-2),10):parseInt(e,10)*r}},w_=_0(D3());function u2(e){let t={},r=e.split(",");for(let n of r){let a=n.indexOf("=");if(a===-1)continue;let l=n.substring(0,a),c=n.substring(a+1);if(l==="a"){t.action=c;continue}if(l==="o"){t.compression=c;continue}if(l==="t"){t.transmission=c;continue}if(l==="d"){t.deleteSelector=c;continue}let h=parseInt(c,10);switch(l){case"f":t.format=h;break;case"i":t.id=h;break;case"I":t.imageNumber=h;break;case"s":t.width=h;break;case"v":t.height=h;break;case"x":t.x=h;break;case"y":t.y=h;break;case"w":t.sourceWidth=h;break;case"h":t.sourceHeight=h;break;case"X":t.xOffset=h;break;case"Y":t.yOffset=h;break;case"c":t.columns=h;break;case"r":t.rows=h;break;case"m":t.more=h;break;case"q":t.quiet=h;break;case"C":t.cursorMovement=h;break;case"z":t.zIndex=h;break;case"p":t.placementId=h;break}}return t}var d2=0,A_=class{constructor(e,t,r,n){this._opts=e,this._renderer=t,this._kittyStorage=r,this._coreTerminal=n,this._aborted=!1,this._decodeError=!1,this._activeDecoder=null,this._inControlData=!0,this._controlData=new Uint32Array(512),this._controlLength=0,this._encodedSizeLimit=0,this._totalEncodedSize=0,this._parsedCommand=null,this._pendingTransmissions=new Map,this._maxEncodedBytes=Math.ceil(this._opts.kittySizeLimit*4/3),this._initialEncodedBytes=Math.min(4194304,this._maxEncodedBytes)}reset(){this._cleanupAllPending(),this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),this._kittyStorage.reset()}dispose(){this.reset()}_removePendingEntry(e){this._pendingTransmissions.delete(e),this._lastPendingKey===e&&(this._lastPendingKey=void 0)}_cleanupAllPending(){for(let e of this._pendingTransmissions.values())e.decoder.release();this._pendingTransmissions.clear(),this._lastPendingKey=void 0}start(){this._aborted=!1,this._decodeError=!1,this._inControlData=!0,this._controlLength=0,this._parsedCommand=null,this._encodedSizeLimit=this._maxEncodedBytes,this._totalEncodedSize=0,this._activeDecoder=null}put(e,t,r){if(!this._aborted)if(!this._inControlData)this._streamPayload(e,t,r);else{let n=r;for(let l=t;l<r;l++)if(e[l]===59){this._inControlData=!1,n=l;break}let a=n-t;if(this._controlLength+a>512){this._aborted=!0;return}if(this._controlData.set(e.subarray(t,n),this._controlLength),this._controlLength+=a,!this._inControlData){if(this._parsedCommand=u2(this._parseControlDataString()),this._parsedCommand.id!==void 0&&this._parsedCommand.imageNumber!==void 0){this._sendResponse(this._parsedCommand.id,"EINVAL:cannot specify both i and I keys",this._parsedCommand.quiet??0),this._aborted=!0;return}if(this._parsedCommand.action==="d")return;let l=n+1;l<r&&this._streamPayload(e,l,r)}}}_streamPayload(e,t,r){if(this._aborted)return;let n=this._parsedCommand?.id??this._lastPendingKey??0,a=this._pendingTransmissions.get(n),l=a?.totalEncodedSize??0;if(this._totalEncodedSize+=r-t,l+this._totalEncodedSize>this._encodedSizeLimit){let c=this._activeDecoder??a?.decoder;c&&c.release(),this._activeDecoder=null,a&&this._removePendingEntry(n),this._aborted=!0;return}this._decodeError||(a?.decoder&&!this._activeDecoder&&(this._activeDecoder=a.decoder),this._activeDecoder||(this._activeDecoder=new w_.default(4194304,this._maxEncodedBytes,this._initialEncodedBytes),this._activeDecoder.init()),this._activeDecoder.put(e.subarray(t,r))!==d2&&(this._activeDecoder.release(),this._activeDecoder=null,this._decodeError=!0,a&&this._removePendingEntry(n)))}end(e){if(this._aborted||!e)return this._activeDecoder&&(this._activeDecoder.release(),this._activeDecoder=null),!0;if(this._inControlData)return this._handleNoPayloadCommand();let t=this._parsedCommand;if(t.action==="d")return this._handleDelete(t);let r=t.id??this._lastPendingKey??0,n=t.more===1,a=this._pendingTransmissions.get(r);if(n)return this._activeDecoder&&(a?(a.totalEncodedSize+=this._totalEncodedSize,a.decodeError=a.decodeError||this._decodeError):this._pendingTransmissions.set(r,{cmd:{...t},decoder:this._activeDecoder,totalEncodedSize:this._totalEncodedSize,decodeError:this._decodeError}),this._lastPendingKey=r,this._activeDecoder=null),!0;a&&(this._lastPendingKey=void 0);let l=this._decodeError,c=t,h=this._activeDecoder;a&&(c=a.cmd,h=a.decoder,l=l||a.decodeError,this._pendingTransmissions.delete(r));let p=new Uint8Array(0);h&&(h.end()!==d2&&(l=!0),p=h.data8),this._activeDecoder=null;let g=this._handleCommandWithBytesAndCmd(c,p,l);return h&&h.release(),g}_parseControlDataString(){let e="";for(let t=0;t<this._controlLength;t++)e+=String.fromCodePoint(this._controlData[t]);return e}_handleNoPayloadCommand(){let e=u2(this._parseControlDataString());if(e.id!==void 0&&e.imageNumber!==void 0)return this._sendResponse(e.id,"EINVAL:cannot specify both i and I keys",e.quiet??0),!0;switch(e.action??"t"){case"d":return this._handleDelete(e);case"q":return this._sendResponse(e.id??0,"OK",e.quiet??0),!0;case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handleCommandWithBytesAndCmd(e,t,r){switch(e.action??"t"){case"t":{let n=this._handleTransmit(e,t,r);return(e.transmission??"d")==="d"&&e.id!==void 0&&(r?this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0):t.length>0&&this._sendResponse(e.id,"OK",e.quiet??0)),n}case"T":return this._handleTransmitDisplay(e,t,r);case"q":return this._handleQuery(e,t,r);case"p":return this._handlePlacement(e);default:return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported action",e.quiet??0),!0}}_handlePlacement(e){if(e.id===void 0)return!0;let t=e.id,r=this._kittyStorage.getImage(t);return r?this._displayImage(r,e).then(n=>(this._sendResponse(t,n?"OK":"EINVAL:image rendering failed",e.quiet??0,e.placementId),!0)):(this._sendResponse(t,"ENOENT:image not found",e.quiet??0,e.placementId),!0)}_handleTransmit(e,t,r){return(e.transmission??"d")!=="d"?(e.id!==void 0&&this._sendResponse(e.id,"EINVAL:unsupported transmission medium",e.quiet??0),!0):(r||t.length===0||this._kittyStorage.storeImage(e.id,{data:new Blob([t]),width:e.width??0,height:e.height??0,format:e.format??32,compression:e.compression??""}),!0)}_handleTransmitDisplay(e,t,r){if(r)return e.id!==void 0&&this._sendResponse(e.id,"EINVAL:invalid base64 data",e.quiet??0),!0;this._handleTransmit(e,t,r);let n=e.id??this._kittyStorage.lastImageId,a=this._kittyStorage.getImage(n);if(a){let l=this._displayImage(a,e);return e.id!==void 0?l.then(c=>(this._sendResponse(n,c?"OK":"EINVAL:image rendering failed",e.quiet??0),!0)):l.then(()=>!0)}return!0}_handleQuery(e,t,r){let n=e.id??0,a=e.quiet??0;if((e.transmission??"d")!=="d")return this._sendResponse(n,"EINVAL:unsupported transmission medium",a),!0;if(r)return this._sendResponse(n,"EINVAL:invalid base64 data",a),!0;if(t.length===0)return this._sendResponse(n,"OK",a),!0;let l=e.format??32;if(l===100)this._sendResponse(n,"OK",a);else{let c=e.width??0,h=e.height??0;if(!c||!h)return this._sendResponse(n,"EINVAL:width and height required for raw pixel data",a),!0;let p=l===32?4:3,g=c*h*p;if(t.length<g)return this._sendResponse(n,"EINVAL:insufficient pixel data",a),!0;this._sendResponse(n,"OK",a)}return!0}_handleDelete(e){switch(e.deleteSelector??"a"){case"a":case"A":this._cleanupAllPending(),this._kittyStorage.deleteAll();break;case"i":case"I":if(e.id!==void 0){let t=this._pendingTransmissions.get(e.id);t&&t.decoder.release(),this._removePendingEntry(e.id),this._kittyStorage.deleteById(e.id)}break}return!0}_sendResponse(e,t,r,n){let a=t==="OK";if(a&&r>=1||!a&&r>=2)return;let l=n?`,p=${n}`:"",c=`\x1B_Gi=${e}${l};${t}\x1B\\`;this._coreTerminal._core.coreService.triggerDataEvent(c)}_displayImage(e,t){return this._decodeAndDisplay(e,t).then(()=>!0).catch(()=>!1)}async _decodeAndDisplay(e,t){let r=await this._createBitmap(e);try{let n=Math.max(0,t.x??0),a=Math.max(0,t.y??0),l=t.sourceWidth||r.width-n,c=t.sourceHeight||r.height-a,h=Math.max(0,r.width-n),p=Math.max(0,r.height-a),g=Math.max(0,Math.min(l,h)),x=Math.max(0,Math.min(c,p));if(g===0||x===0)throw new Error("invalid source rectangle");if(n!==0||a!==0||g!==r.width||x!==r.height){let Be=await createImageBitmap(r,n,a,g,x);r.close(),r=Be}let y=this._renderer.dimensions?.css.cell.width||_l.width,A=this._renderer.dimensions?.css.cell.height||_l.height,v,L;t.columns!==void 0&&t.rows!==void 0?(v=t.columns,L=t.rows):t.columns!==void 0?(v=t.columns,L=Math.max(1,Math.ceil(r.height/r.width*(v*y)/A))):t.rows!==void 0?(L=t.rows,v=Math.max(1,Math.ceil(r.width/r.height*(L*A)/y))):(v=Math.ceil(r.width/y),L=Math.ceil(r.height/A));let I=r.width,E=r.height;if((t.columns!==void 0||t.rows!==void 0)&&(I=Math.round(v*y),E=Math.round(L*A)),I*E>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");let R=this._coreTerminal._core.buffer,P=R.x,Q=R.y,$=R.ybase,W=t.zIndex!==void 0&&t.zIndex<0?"bottom":"top";if(I!==r.width||E!==r.height){let Be=await createImageBitmap(r,{resizeWidth:I,resizeHeight:E});r.close(),r=Be}let B=Math.min(Math.max(0,t.xOffset??0),y-1),q=Math.min(Math.max(0,t.yOffset??0),A-1);if(B!==0||q!==0){let Be=t.columns!==void 0?Math.round(v*y):r.width+B,fe=t.rows!==void 0?Math.round(L*A):r.height+q,X=b0.createCanvas(window.document,Be,fe),Qe=X.getContext("2d");if(!Qe)throw new Error("Failed to create offset canvas context");Qe.drawImage(r,B,q);let Pe=await createImageBitmap(X);if(X.width=X.height=0,r.close(),r=Pe,I=r.width,E=r.height,I*E>this._opts.pixelLimit)throw new Error("image exceeds pixel limit");t.columns===void 0&&(v=Math.ceil(r.width/y)),t.rows===void 0&&(L=Math.ceil(r.height/A))}let ne=t.zIndex??0;if(this._kittyStorage.addImage(e.id,r,!0,W,ne),r=void 0,t.cursorMovement===1){let Be=R.ybase-$;R.x=P,R.y=Math.max(Q-Be,0)}else R.x=Math.min(P+v,this._coreTerminal.cols)}catch(n){throw r?.close(),n}}async _createBitmap(e){let t=new Uint8Array(await e.data.arrayBuffer());if(e.compression==="z"&&(t=await this._decompressZlib(t)),e.format===100){let I=new Blob([t],{type:"image/png"});if(!window.createImageBitmap){let E=URL.createObjectURL(I),R=new Image;return new Promise((P,Q)=>{R.addEventListener("load",()=>{URL.revokeObjectURL(E);let $=b0.createCanvas(window.document,R.width,R.height);$.getContext("2d")?.drawImage(R,0,0),createImageBitmap($).then(P).catch(Q)}),R.addEventListener("error",()=>{URL.revokeObjectURL(E),Q(new Error("Failed to load image"))}),R.src=E})}return createImageBitmap(I)}let r=e.width,n=e.height;if(!r||!n)throw new Error("Width and height required for raw pixel data");let a=e.format===32?4:3,l=r*n*a;if(t.length<l)throw new Error("Insufficient pixel data");let c=r*n;if(e.format===32)return createImageBitmap(new ImageData(new Uint8ClampedArray(t.buffer,t.byteOffset,c*4),r,n));let h=new Uint8ClampedArray(c*4),p=new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),g=new Uint32Array(h.buffer),x=c&-4,y=0,A=0;for(let I=0;I<x;I+=4){let E=p[y++],R=p[y++],P=p[y++];g[A++]=4278190080|E,g[A++]=4278190080|E>>>24|R<<8,g[A++]=4278190080|R>>>16|P<<16,g[A++]=4278190080|P>>>8}let v=x*3,L=x*4;for(let I=x;I<c;I++)h[L]=t[v],h[L+1]=t[v+1],h[L+2]=t[v+2],h[L+3]=255,v+=3,L+=4;return createImageBitmap(new ImageData(h,r,n))}async _decompressZlib(e){try{return await this._decompress(e,"deflate")}catch{return await this._decompress(e,"deflate-raw")}}async _decompress(e,t){let r=new DecompressionStream(t),n=r.writable.getWriter();n.write(e),n.close();let a=[],l=r.readable.getReader();for(;;){let{done:g,value:x}=await l.read();if(g)break;a.push(x)}let c=a.reduce((g,x)=>g+x.length,0),h=new Uint8Array(c),p=0;for(let g of a)h.set(g,p),p+=g.length;return h}get images(){return this._kittyStorage.images}get _kittyIdToStorageId(){return this._kittyStorage.kittyIdToStorageId}get pendingTransmissions(){return this._pendingTransmissions}},P3=class vm{constructor(t){this._storage=t,this._nextImageId=1,this._images=new Map,this._kittyIdToStorageId=new Map,this._storageIdToKittyId=new Map,this._handleStorageImageDeleted=r=>{let n=this._storageIdToKittyId.get(r);n!==void 0&&(this._kittyIdToStorageId.delete(n),this._storageIdToKittyId.delete(r),this._images.delete(n))},this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"},this._previousOnImageDeleted=this._storage.onImageDeleted,this._wrappedOnImageDeleted=r=>{this._previousOnImageDeleted?.(r),this._handleStorageImageDeleted(r)},this._storage.onImageDeleted=this._wrappedOnImageDeleted}reset(){this._nextImageId=1,this._images.clear(),this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}dispose(){this.reset(),this._storage.onImageDeleted===this._wrappedOnImageDeleted&&(this._storage.onImageDeleted=this._previousOnImageDeleted)}storeImage(t,r){let n=t??this._nextImageId++,a=this._kittyIdToStorageId.get(n);return a!==void 0&&(this._storage.deleteImage(a),this._kittyIdToStorageId.delete(n),this._storageIdToKittyId.delete(a)),!this._images.has(n)&&this._images.size>=vm._maxStoredImages&&this._evictUndisplayedImages(),this._images.set(n,{...r,id:n}),n}addImage(t,r,n,a,l){let c=this._kittyIdToStorageId.get(t);c!==void 0&&this._storageIdToKittyId.delete(c),this._addImageOpts.scrolling=n,this._addImageOpts.layer=a,this._addImageOpts.zIndex=l;let h=this._storage.addImage(r,this._addImageOpts);this._kittyIdToStorageId.set(t,h),this._storageIdToKittyId.set(h,t)}getImage(t){return this._images.get(t)}deleteById(t){this._images.delete(t);let r=this._kittyIdToStorageId.get(t);r!==void 0&&(this._storage.deleteImage(r),this._kittyIdToStorageId.delete(t),this._storageIdToKittyId.delete(r))}deleteAll(){this._images.clear();for(let t of this._kittyIdToStorageId.values())this._storage.deleteImage(t);this._kittyIdToStorageId.clear(),this._storageIdToKittyId.clear()}get images(){return this._images}get kittyIdToStorageId(){return this._kittyIdToStorageId}get lastImageId(){return this._nextImageId-1}_evictUndisplayedImages(){for(let[t]of this._images){if(this._images.size<=vm._maxStoredImages/2)break;this._kittyIdToStorageId.has(t)||this._images.delete(t)}}};P3._maxStoredImages=256;var T_=P3,Yu=_0(d1()),S_=_0(c_()),C_=4194304,wm=Yu.PALETTE_ANSI_256;wm.set(Yu.PALETTE_VT340_COLOR);var __=class{constructor(e,t,r){this._opts=e,this._storage=t,this._coreTerminal=r,this._size=0,this._aborted=!1,(0,S_.DecoderAsync)({memoryLimit:this._opts.pixelLimit*4,palette:wm,paletteLimit:this._opts.sixelPaletteLimit}).then(n=>this._dec=n)}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,wm,this._opts.sixelPaletteLimit))}hook(e){if(this._size=0,this._aborted=!1,this._dec){let t=e.params[1]===1?0:L_(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(t,null,this._opts.sixelPaletteLimit)}}put(e,t,r){if(!(this._aborted||!this._dec)){if(this._size+=r-t,this._size>this._opts.sixelSizeLimit){console.warn("SIXEL: too much data, aborting"),this._aborted=!0,this._dec.release();return}try{this._dec.decode(e,t,r)}catch(n){console.warn(`SIXEL: error while decoding image - ${n}`),this._aborted=!0,this._dec.release()}}}unhook(e){if(this._aborted||!e||!this._dec)return!0;let t=this._dec.width,r=this._dec.height;if(!t||!r)return r&&this._storage.advanceCursor(r),!0;let n=b0.createCanvas(void 0,t,r);return n.getContext("2d")?.putImageData(new ImageData(this._dec.data8,t,r),0,0),this._dec.memoryUsage>C_&&this._dec.release(),this._storage.addImage(n),!0}};function L_(e,t){let r=0;if(!t)return r;if(e.isInverse())if(e.isFgDefault())r=$d(t.foreground.rgba);else if(e.isFgRGB()){let n=e.constructor.toColorRGB(e.getFgColor());r=(0,Yu.toRGBA8888)(...n)}else r=$d(t.ansi[e.getFgColor()].rgba);else if(e.isBgDefault())r=$d(t.background.rgba);else if(e.isBgRGB()){let n=e.constructor.toColorRGB(e.getBgColor());r=(0,Yu.toRGBA8888)(...n)}else r=$d(t.ansi[e.getBgColor()].rgba);return r}function $d(e){return Yu.BIG_ENDIAN?e:(e&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255}var k_=class{constructor(e,t,r,n){this._storage=e,this._opts=t,this._renderer=r,this._terminal=n,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"vt340"}}addImage(e){this._addImageOpts.scrolling=this._opts.sixelScrolling,this._storage.addImage(e,this._addImageOpts)}advanceCursor(e){if(this._opts.sixelScrolling){let t=this._renderer.cellSize;(t.width===-1||t.height===-1)&&(t=_l);let r=Math.ceil(e/t.height);for(let n=1;n<r;++n)this._terminal._core._inputHandler.lineFeed()}}},I_=class{constructor(e){this._storage=e,this._addImageOpts={scrolling:!0,layer:"top",zIndex:0,cursorPos:"iip"}}addImage(e){this._storage.addImage(e,this._addImageOpts)}},h2={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:4096,sixelSizeLimit:33554432,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:33554432,kittySupport:!0,kittySizeLimit:33554432},f2=4096,E_=class{constructor(t){this._disposables=[],this._handlers=new Map,this._onImageAdded=new d_,this.onImageAdded=this._onImageAdded.event,this._opts=Object.assign({},h2,t),this._defaultOpts=Object.assign({},h2,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear(),this._onImageAdded.dispose()}_disposeLater(...t){for(let r of t)this._disposables.push(r)}activate(t){if(this._terminal=t,this._renderer=new b0(t),this._storage=new f_(t,this._renderer,this._opts),this._storage.onImageAdded=()=>this._onImageAdded.fire(),this._opts.enableSizeReports){let r=t.options.windowOptions??{};r.getWinSizePixels=!0,r.getCellSizePixels=!0,r.getWinSizeChars=!0,t.options.windowOptions=r}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},r=>this._decset(r)),t.parser.registerCsiHandler({prefix:"?",final:"l"},r=>this._decrst(r)),t.parser.registerCsiHandler({final:"c"},r=>this._da1(r)),t.parser.registerCsiHandler({prefix:"?",final:"S"},r=>this._xtermGraphicsAttributes(r)),t.onRender(r=>this._storage?.render(r)),t.parser.registerCsiHandler({intermediates:"!",final:"p"},()=>this.reset()),t.parser.registerEscHandler({final:"c"},()=>this.reset()),t._core._inputHandler.onRequestReset(()=>this.reset()),t.buffer.onBufferChange(()=>this._storage?.wipeAlternate()),t.onResize(r=>this._storage?.viewportResize(r))),this._opts.sixelSupport){let r=new k_(this._storage,this._opts,this._renderer,t),n=new __(this._opts,r,t);this._handlers.set("sixel",n),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},n))}if(this._opts.iipSupport){let r=new I_(this._storage),n=new v_(this._opts,this._renderer,r,t);this._handlers.set("iip",n),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,n))}if(this._opts.kittySupport){let r=new T_(this._storage),n=new A_(this._opts,this._renderer,r,t);this._handlers.set("kitty",n),this._disposeLater(r,n,t._core._inputHandler._parser.registerApcHandler({final:"G"},n))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,r){return this._storage?.getImageAtBufferCell(t,r)}extractTileAtBufferCell(t,r){return this._storage?.extractTileAtBufferCell(t,r)}_report(t){this._terminal?._core.input(t,!1)}_decset(t){for(let r=0;r<t.length;++r)t[r]===80&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let r=0;r<t.length;++r)t[r]===80&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return t[0]?!0:this._opts.sixelSupport?(this._report("\x1B[?62;4;9;22c"),!0):!1}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(t[0]===1)switch(t[1]){case 1:return this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let r of this._handlers.values())r.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=f2?(this._opts.sixelPaletteLimit=t[2],this._report(`\x1B[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`\x1B[?${t[0]};2S`),!0;case 4:return this._report(`\x1B[?${t[0]};0;${f2}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}if(t[0]===2)switch(t[1]){case 1:let r=this._renderer?.dimensions?.css.canvas.width,n=this._renderer?.dimensions?.css.canvas.height;if(!r||!n){let l=_l;r=(this._terminal?.cols||80)*l.width,n=(this._terminal?.rows||24)*l.height}if(r*n<this._opts.pixelLimit)this._report(`\x1B[?${t[0]};0;${r.toFixed(0)};${n.toFixed(0)}S`);else{let l=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`\x1B[?${t[0]};0;${l};${l}S`)}return!0;case 4:let a=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`\x1B[?${t[0]};0;${a};${a}S`),!0;default:return this._report(`\x1B[?${t[0]};2S`),!0}return this._report(`\x1B[?${t[0]};1S`),!0}};const zc=new Map;function n0(e){return{name:e,get hasSubscribers(){return(zc.get(e)?.size??0)>0},publish(t){const r=zc.get(e);if(r)for(const n of r)n(t,e)},subscribe(t){const r=zc.get(e)??new Set;r.add(t),zc.set(e,r)},unsubscribe(t){const r=zc.get(e);if(!r)return!1;const n=r.delete(t);return r.size===0&&zc.delete(e),n}}}function N_(e){const t={start:`${e}:start`,end:`${e}:end`,asyncStart:`${e}:asyncStart`,asyncEnd:`${e}:asyncEnd`,error:`${e}:error`},r={start:n0(t.start),end:n0(t.end),asyncStart:n0(t.asyncStart),asyncEnd:n0(t.asyncEnd),error:n0(t.error),traceSync(n,a,l,...c){r.start.publish(a);try{const h=n.apply(l,c);return r.end.publish(a),h}catch(h){throw r.error.publish(h),h}},async tracePromise(n,a,l,...c){r.asyncStart.publish(a);try{const h=await n.apply(l,c);return r.asyncEnd.publish(a),h}catch(h){throw r.error.publish(h),h}},traceCallback(n,a,l,c,...h){r.start.publish(l);try{const p=n.apply(c,h);return r.end.publish(l),p}catch(p){throw r.error.publish(p),p}}};return r}var R_=Object.create,h1=Object.defineProperty,M_=Object.getOwnPropertyDescriptor,D_=Object.getOwnPropertyNames,j_=Object.getPrototypeOf,B_=Object.prototype.hasOwnProperty,O3=e=>{throw TypeError(e)},Q_=(e,t,r)=>t in e?h1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P_=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},O_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of D_(t))!B_.call(e,a)&&a!==r&&h1(e,a,{get:()=>t[a],enumerable:!(n=M_(t,a))||n.enumerable});return e},F_=(e,t,r)=>(r=e!=null?R_(j_(e)):{},O_(!e||!e.__esModule?h1(r,"default",{value:e,enumerable:!0}):r,e)),Gs=(e,t,r)=>Q_(e,typeof t!="symbol"?t+"":t,r),f1=(e,t,r)=>t.has(e)||O3("Cannot "+r),ie=(e,t,r)=>(f1(e,t,"read from private field"),r?r.call(e):t.get(e)),bn=(e,t,r)=>t.has(e)?O3("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Rr=(e,t,r,n)=>(f1(e,t,"write to private field"),t.set(e,r),r),Xt=(e,t,r)=>(f1(e,t,"access private method"),r),up=(e,t,r,n)=>({set _(a){Rr(e,t,a)},get _(){return ie(e,t,n)}}),$_=P_((e,t)=>{var r=(()=>{var n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,h=(i,o)=>{for(var u in o)n(i,u,{get:o[u],enumerable:!0})},p=(i,o,u,d)=>{if(o&&typeof o=="object"||typeof o=="function")for(let f of l(o))!c.call(i,f)&&f!==u&&n(i,f,{get:()=>o[f],enumerable:!(d=a(o,f))||d.enumerable});return i},g=i=>p(n({},"__esModule",{value:!0}),i),x={};h(x,{BoundingBox:()=>se,Font:()=>hg,Glyph:()=>Ot,Path:()=>Fe,_parse:()=>at,load:()=>J7,loadSync:()=>e8,parse:()=>X7});var y=0,A=-3;function v(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function L(i,o){this.source=i,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=o,this.destLen=0,this.ltree=new v,this.dtree=new v}var I=new v,E=new v,R=new Uint8Array(30),P=new Uint16Array(30),Q=new Uint8Array(30),$=new Uint16Array(30),W=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),B=new v,q=new Uint8Array(320);function ne(i,o,u,d){var f,m;for(f=0;f<u;++f)i[f]=0;for(f=0;f<30-u;++f)i[f+u]=f/u|0;for(m=d,f=0;f<30;++f)o[f]=m,m+=1<<i[f]}function Be(i,o){var u;for(u=0;u<7;++u)i.table[u]=0;for(i.table[7]=24,i.table[8]=152,i.table[9]=112,u=0;u<24;++u)i.trans[u]=256+u;for(u=0;u<144;++u)i.trans[24+u]=u;for(u=0;u<8;++u)i.trans[168+u]=280+u;for(u=0;u<112;++u)i.trans[176+u]=144+u;for(u=0;u<5;++u)o.table[u]=0;for(o.table[5]=32,u=0;u<32;++u)o.trans[u]=u}var fe=new Uint16Array(16);function X(i,o,u,d){var f,m;for(f=0;f<16;++f)i.table[f]=0;for(f=0;f<d;++f)i.table[o[u+f]]++;for(i.table[0]=0,m=0,f=0;f<16;++f)fe[f]=m,m+=i.table[f];for(f=0;f<d;++f)o[u+f]&&(i.trans[fe[o[u+f]]++]=f)}function Qe(i){i.bitcount--||(i.tag=i.source[i.sourceIndex++],i.bitcount=7);var o=i.tag&1;return i.tag>>>=1,o}function Pe(i,o,u){if(!o)return u;for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var d=i.tag&65535>>>16-o;return i.tag>>>=o,i.bitcount-=o,d+u}function ue(i,o){for(;i.bitcount<24;)i.tag|=i.source[i.sourceIndex++]<<i.bitcount,i.bitcount+=8;var u=0,d=0,f=0,m=i.tag;do d=2*d+(m&1),m>>>=1,++f,u+=o.table[f],d-=o.table[f];while(d>=0);return i.tag=m,i.bitcount-=f,o.trans[u+d]}function Ce(i,o,u){var d,f,m,w,T,_;for(d=Pe(i,5,257),f=Pe(i,5,1),m=Pe(i,4,4),w=0;w<19;++w)q[w]=0;for(w=0;w<m;++w){var M=Pe(i,3,0);q[W[w]]=M}for(X(B,q,0,19),T=0;T<d+f;){var N=ue(i,B);switch(N){case 16:var J=q[T-1];for(_=Pe(i,2,3);_;--_)q[T++]=J;break;case 17:for(_=Pe(i,3,3);_;--_)q[T++]=0;break;case 18:for(_=Pe(i,7,11);_;--_)q[T++]=0;break;default:q[T++]=N;break}}X(o,q,0,d),X(u,q,d,f)}function tt(i,o,u){for(;;){var d=ue(i,o);if(d===256)return y;if(d<256)i.dest[i.destLen++]=d;else{var f,m,w,T;for(d-=257,f=Pe(i,R[d],P[d]),m=ue(i,u),w=i.destLen-Pe(i,Q[m],$[m]),T=w;T<w+f;++T)i.dest[i.destLen++]=i.dest[T]}}}function we(i){for(var o,u,d;i.bitcount>8;)i.sourceIndex--,i.bitcount-=8;if(o=i.source[i.sourceIndex+1],o=256*o+i.source[i.sourceIndex],u=i.source[i.sourceIndex+3],u=256*u+i.source[i.sourceIndex+2],o!==(~u&65535))return A;for(i.sourceIndex+=4,d=o;d;--d)i.dest[i.destLen++]=i.source[i.sourceIndex++];return i.bitcount=0,y}function ce(i,o){var u=new L(i,o),d,f,m;do{switch(d=Qe(u),f=Pe(u,2,0),f){case 0:m=we(u);break;case 1:m=tt(u,I,E);break;case 2:Ce(u,u.ltree,u.dtree),m=tt(u,u.ltree,u.dtree);break;default:m=A}if(m!==y)throw new Error("Data error")}while(!d);return u.destLen<u.dest.length?typeof u.dest.slice=="function"?u.dest.slice(0,u.destLen):u.dest.subarray(0,u.destLen):u.dest}Be(I,E),ne(R,P,4,3),ne(Q,$,2,1),R[28]=0,P[28]=258;function $e(i,o,u,d,f){return Math.pow(1-f,3)*i+3*Math.pow(1-f,2)*f*o+3*(1-f)*Math.pow(f,2)*u+Math.pow(f,3)*d}function ke(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}ke.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},ke.prototype.addPoint=function(i,o){typeof i=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=i,this.x2=i),i<this.x1&&(this.x1=i),i>this.x2&&(this.x2=i)),typeof o=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=o,this.y2=o),o<this.y1&&(this.y1=o),o>this.y2&&(this.y2=o))},ke.prototype.addX=function(i){this.addPoint(i,null)},ke.prototype.addY=function(i){this.addPoint(null,i)},ke.prototype.addBezier=function(i,o,u,d,f,m,w,T){let _=[i,o],M=[u,d],N=[f,m],J=[w,T];this.addPoint(i,o),this.addPoint(w,T);for(let K=0;K<=1;K++){let ve=6*_[K]-12*M[K]+6*N[K],pe=-3*_[K]+9*M[K]-9*N[K]+3*J[K],Se=3*M[K]-3*_[K];if(pe===0){if(ve===0)continue;let Dr=-Se/ve;0<Dr&&Dr<1&&(K===0&&this.addX($e(_[K],M[K],N[K],J[K],Dr)),K===1&&this.addY($e(_[K],M[K],N[K],J[K],Dr)));continue}let ht=Math.pow(ve,2)-4*Se*pe;if(ht<0)continue;let Tr=(-ve+Math.sqrt(ht))/(2*pe);0<Tr&&Tr<1&&(K===0&&this.addX($e(_[K],M[K],N[K],J[K],Tr)),K===1&&this.addY($e(_[K],M[K],N[K],J[K],Tr)));let pr=(-ve-Math.sqrt(ht))/(2*pe);0<pr&&pr<1&&(K===0&&this.addX($e(_[K],M[K],N[K],J[K],pr)),K===1&&this.addY($e(_[K],M[K],N[K],J[K],pr)))}},ke.prototype.addQuad=function(i,o,u,d,f,m){let w=i+.6666666666666666*(u-i),T=o+2/3*(d-o),_=w+1/3*(f-i),M=T+1/3*(m-o);this.addBezier(i,o,w,T,_,M,f,m)};var se=ke;function je(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var de={};function Oe(i,o){let u=Math.floor(i),d=i-u;if(de[o]||(de[o]={}),de[o][d]!==void 0){let m=de[o][d];return u+m}let f=+(Math.round(d+"e+"+o)+"e-"+o);return de[o][d]=f,u+f}function Ee(i){let o=[[]],u=0,d=0;for(let f=0;f<i.length;f+=1){let m=o[o.length-1],w=i[f],T=m[0],_=m[1],M=m[m.length-1],N=i[f+1];m.push(w),w.type==="M"?(u=w.x,d=w.y):w.type==="L"&&(!N||N.type==="Z")?Math.abs(w.x-u)>1||Math.abs(w.y-d)>1||m.pop():w.type==="L"&&M&&M.x===w.x&&M.y===w.y?m.pop():w.type==="Z"&&(T&&_&&M&&T.type==="M"&&_.type==="L"&&M.type==="L"&&M.x===T.x&&M.y===T.y&&(m.shift(),m[0].type="M"),f+1<i.length&&o.push([]))}return i=[].concat.apply([],o),i}function _e(i){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},i)}function re(i){return parseInt(i)===i&&(i={decimalPlaces:i,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},i)}je.prototype.fromSVG=function(i,o={}){typeof SVGPathElement<"u"&&i instanceof SVGPathElement&&(i=i.getAttribute("d")),o=_e(o),this.commands=[];let u="0123456789",d="MmLlQqCcZzHhVv",f="SsTtAa",m="-+",w={},T=[""],_=!1;function M(pe){return pe.filter(Se=>Se.length).map(Se=>{let ht=parseFloat(Se);return(o.decimalPlaces||o.decimalPlaces===0)&&(ht=Oe(ht,o.decimalPlaces)),ht})}function N(pe){if(!this.commands.length)return pe;let Se=this.commands[this.commands.length-1];for(let ht=0;ht<pe.length;ht++)pe[ht]+=Se[ht&1?"y":"x"];return pe}function J(){if(w.type===void 0)return;let pe=w.type.toUpperCase(),Se=pe!=="Z"&&w.type.toUpperCase()!==w.type,ht=M(T);if(T=[""],!ht.length&&pe!=="Z")return;Se&&pe!=="H"&&pe!=="V"&&(ht=N.apply(this,[ht]));let Tr=this.commands.length&&this.commands[this.commands.length-1].x||0,pr=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(pe){case"M":this.moveTo(...ht);break;case"L":this.lineTo(...ht);break;case"V":for(let Dr=0;Dr<ht.length;Dr++){let sn=0;Se&&(sn=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(Tr,ht[Dr]+sn)}break;case"H":for(let Dr=0;Dr<ht.length;Dr++){let sn=0;Se&&(sn=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(ht[Dr]+sn,pr)}break;case"C":this.bezierCurveTo(...ht);break;case"Q":this.quadraticCurveTo(...ht);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let Dr in this.commands[this.commands.length-1])this.commands[this.commands.length-1][Dr]===void 0&&(this.commands[this.commands.length-1][Dr]=0)}for(let pe=0;pe<i.length;pe++){let Se=i.charAt(pe),ht=T[T.length-1];if(u.indexOf(Se)>-1)T[T.length-1]+=Se;else if(m.indexOf(Se)>-1)if(!w.type&&!this.commands.length&&(w.type="L"),Se==="-")!w.type||ht.indexOf("-")>0?_=!0:ht.length?T.push("-"):T[T.length-1]=Se;else if(!w.type||ht.length>0)_=!0;else continue;else if(d.indexOf(Se)>-1)w.type?(J.apply(this),w={type:Se}):w.type=Se;else{if(f.indexOf(Se)>-1)throw new Error("Unsupported path command: "+Se+". Currently supported commands are "+d.split("").join(", ")+".");` ,
62
+ \r\f\v`.indexOf(Se)>-1?T.push(""):Se==="."?!w.type||ht.indexOf(Se)>-1?_=!0:T[T.length-1]+=Se:_=!0}if(_)throw new Error("Unexpected character: "+Se+" at offset "+pe)}J.apply(this),o.optimize&&(this.commands=Ee(this.commands));let K=o.flipY,ve=o.flipYBase;if(K===!0&&o.flipYBase===void 0){let pe=this.getBoundingBox();ve=pe.y1+pe.y2}for(let pe in this.commands){let Se=this.commands[pe];for(let ht in Se)["x","x1","x2"].includes(ht)?this.commands[pe][ht]=o.x+Se[ht]*o.scale:["y","y1","y2"].includes(ht)&&(this.commands[pe][ht]=o.y+(K?ve-Se[ht]:Se[ht])*o.scale)}return this},je.fromSVG=function(i,o){return new je().fromSVG(i,o)},je.prototype.moveTo=function(i,o){this.commands.push({type:"M",x:i,y:o})},je.prototype.lineTo=function(i,o){this.commands.push({type:"L",x:i,y:o})},je.prototype.curveTo=je.prototype.bezierCurveTo=function(i,o,u,d,f,m){this.commands.push({type:"C",x1:i,y1:o,x2:u,y2:d,x:f,y:m})},je.prototype.quadTo=je.prototype.quadraticCurveTo=function(i,o,u,d){this.commands.push({type:"Q",x1:i,y1:o,x:u,y:d})},je.prototype.close=je.prototype.closePath=function(){this.commands.push({type:"Z"})},je.prototype.extend=function(i){if(i.commands)i=i.commands;else if(i instanceof se){let o=i;this.moveTo(o.x1,o.y1),this.lineTo(o.x2,o.y1),this.lineTo(o.x2,o.y2),this.lineTo(o.x1,o.y2),this.close();return}Array.prototype.push.apply(this.commands,i)},je.prototype.getBoundingBox=function(){let i=new se,o=0,u=0,d=0,f=0;for(let m=0;m<this.commands.length;m++){let w=this.commands[m];switch(w.type){case"M":i.addPoint(w.x,w.y),o=d=w.x,u=f=w.y;break;case"L":i.addPoint(w.x,w.y),d=w.x,f=w.y;break;case"Q":i.addQuad(d,f,w.x1,w.y1,w.x,w.y),d=w.x,f=w.y;break;case"C":i.addBezier(d,f,w.x1,w.y1,w.x2,w.y2,w.x,w.y),d=w.x,f=w.y;break;case"Z":d=o,f=u;break;default:throw new Error("Unexpected path command "+w.type)}}return i.isEmpty()&&i.addPoint(0,0),i},je.prototype.draw=function(i){let o=this._layers;if(o&&o.length){for(let d=0;d<o.length;d++)this.draw.call(o[d],i);return}let u=this._image;if(u){i.drawImage(u.image,u.x,u.y,u.width,u.height);return}i.beginPath();for(let d=0;d<this.commands.length;d+=1){let f=this.commands[d];f.type==="M"?i.moveTo(f.x,f.y):f.type==="L"?i.lineTo(f.x,f.y):f.type==="C"?i.bezierCurveTo(f.x1,f.y1,f.x2,f.y2,f.x,f.y):f.type==="Q"?i.quadraticCurveTo(f.x1,f.y1,f.x,f.y):f.type==="Z"&&this.stroke&&this.strokeWidth&&i.closePath()}this.fill&&(i.fillStyle=this.fill,i.fill()),this.stroke&&(i.strokeStyle=this.stroke,i.lineWidth=this.strokeWidth,i.stroke())},je.prototype.toPathData=function(i){i=re(i);function o(T){let _=Oe(T,i.decimalPlaces);return Math.round(T)===_?""+_:_.toFixed(i.decimalPlaces)}function u(){let T="";for(let _=0;_<arguments.length;_+=1){let M=arguments[_];M>=0&&_>0&&(T+=" "),T+=o(M)}return T}let d=this.commands;i.optimize&&(d=JSON.parse(JSON.stringify(this.commands)),d=Ee(d));let f=i.flipY,m=i.flipYBase;if(f===!0&&m===void 0){let T=new je;T.extend(d);let _=T.getBoundingBox();m=_.y1+_.y2}let w="";for(let T=0;T<d.length;T+=1){let _=d[T];_.type==="M"?w+="M"+u(_.x,f?m-_.y:_.y):_.type==="L"?w+="L"+u(_.x,f?m-_.y:_.y):_.type==="C"?w+="C"+u(_.x1,f?m-_.y1:_.y1,_.x2,f?m-_.y2:_.y2,_.x,f?m-_.y:_.y):_.type==="Q"?w+="Q"+u(_.x1,f?m-_.y1:_.y1,_.x,f?m-_.y:_.y):_.type==="Z"&&(w+="Z")}return w},je.prototype.toSVG=function(i,o){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),o||(o=this.toPathData(i));let u='<path d="';return u+=o,u+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u+=' fill="none"':u+=' fill="'+this.fill+'"'),this.stroke&&(u+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),u+="/>",u},je.prototype.toDOMElement=function(i,o){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),o||(o=this.toPathData(i));let u=document.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",o),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?u.setAttribute("fill","none"):u.setAttribute("fill",this.fill)),this.stroke&&(u.setAttribute("stroke",this.stroke),u.setAttribute("stroke-width",this.strokeWidth)),u};var Fe=je;function wt(i){throw new Error(i)}function Xe(i,o){i||wt(o)}var ee={fail:wt,argument:Xe,assert:Xe},Ue=32768,Le=2147483648,te=-32768,ye=32767+1/65536,ot={},le={},xe={};function Ne(i){return function(){return i}}le.BYTE=function(i){return ee.argument(i>=0&&i<=255,"Byte value should be between 0 and 255."),[i]},xe.BYTE=Ne(1),le.CHAR=function(i){return[i.charCodeAt(0)]},xe.CHAR=Ne(1),le.CHARARRAY=function(i){(i===null||typeof i>"u")&&(i="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let o=[];for(let u=0;u<i.length;u+=1)o[u]=i.charCodeAt(u);return o},xe.CHARARRAY=function(i){return typeof i>"u"?0:i.length},le.USHORT=function(i){return[i>>8&255,i&255]},xe.USHORT=Ne(2),le.SHORT=function(i){return i>=Ue&&(i=-(2*Ue-i)),[i>>8&255,i&255]},xe.SHORT=Ne(2),le.UINT24=function(i){return[i>>16&255,i>>8&255,i&255]},xe.UINT24=Ne(3),le.ULONG=function(i){return[i>>24&255,i>>16&255,i>>8&255,i&255]},xe.ULONG=Ne(4),le.LONG=function(i){return i>=Le&&(i=-(2*Le-i)),[i>>24&255,i>>16&255,i>>8&255,i&255]},xe.LONG=Ne(4),le.FLOAT=function(i){if(i>ye||i<te)throw new Error(`Value ${i} is outside the range of representable values in 16.16 format`);let o=Math.round(i*65536)<<0;return le.ULONG(o)},xe.FLOAT=xe.ULONG,le.FIXED=le.ULONG,xe.FIXED=xe.ULONG,le.FWORD=le.SHORT,xe.FWORD=xe.SHORT,le.UFWORD=le.USHORT,xe.UFWORD=xe.USHORT,le.F2DOT14=function(i){return le.USHORT(i*16384)},xe.F2DOT14=xe.USHORT,le.LONGDATETIME=function(i){return[0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255]},xe.LONGDATETIME=Ne(8),le.TAG=function(i){return ee.argument(i.length===4,"Tag should be exactly 4 ASCII characters."),[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]},xe.TAG=Ne(4),le.Card8=le.BYTE,xe.Card8=xe.BYTE,le.Card16=le.USHORT,xe.Card16=xe.USHORT,le.OffSize=le.BYTE,xe.OffSize=xe.BYTE,le.SID=le.USHORT,xe.SID=xe.USHORT,le.NUMBER=function(i){return i>=-107&&i<=107?[i+139]:i>=108&&i<=1131?(i=i-108,[(i>>8)+247,i&255]):i>=-1131&&i<=-108?(i=-i-108,[(i>>8)+251,i&255]):i>=-32768&&i<=32767?le.NUMBER16(i):le.NUMBER32(i)},xe.NUMBER=function(i){return le.NUMBER(i).length},le.NUMBER16=function(i){return[28,i>>8&255,i&255]},xe.NUMBER16=Ne(3),le.NUMBER32=function(i){return[29,i>>24&255,i>>16&255,i>>8&255,i&255]},xe.NUMBER32=Ne(5),le.REAL=function(i){let o=i.toString(),u=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(o);if(u){let m=parseFloat("1e"+((u[2]?+u[2]:0)+u[1].length));o=(Math.round(i*m)/m).toString()}let d="";for(let m=0,w=o.length;m<w;m+=1){let T=o[m];T==="e"?d+=o[++m]==="-"?"c":"b":T==="."?d+="a":T==="-"?d+="e":d+=T}d+=d.length&1?"f":"ff";let f=[30];for(let m=0,w=d.length;m<w;m+=2)f.push(parseInt(d.substr(m,2),16));return f},xe.REAL=function(i){return le.REAL(i).length},le.NAME=le.CHARARRAY,xe.NAME=xe.CHARARRAY,le.STRING=le.CHARARRAY,xe.STRING=xe.CHARARRAY,ot.UTF8=function(i,o,u){let d=[],f=u;for(let m=0;m<f;m++,o+=1)d[m]=i.getUint8(o);return String.fromCharCode.apply(null,d)},ot.UTF16=function(i,o,u){let d=[],f=u/2;for(let m=0;m<f;m++,o+=2)d[m]=i.getUint16(o);return String.fromCharCode.apply(null,d)},le.UTF16=function(i){let o=[];for(let u=0;u<i.length;u+=1){let d=i.charCodeAt(u);o[o.length]=d>>8&255,o[o.length]=d&255}return o},xe.UTF16=function(i){return i.length*2};var yt={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};ot.MACSTRING=function(i,o,u,d){let f=yt[d];if(f===void 0)return;let m="";for(let w=0;w<u;w++){let T=i.getUint8(o+w);T<=127?m+=String.fromCharCode(T):m+=f[T&127]}return m};var gt=typeof WeakMap=="function"&&new WeakMap,At,Ft=function(i){if(!At){At={};for(let f in yt)At[f]=new String(f)}let o=At[i];if(o===void 0)return;if(gt){let f=gt.get(o);if(f!==void 0)return f}let u=yt[i];if(u===void 0)return;let d={};for(let f=0;f<u.length;f++)d[u.charCodeAt(f)]=f+128;return gt&&gt.set(o,d),d};le.MACSTRING=function(i,o){let u=Ft(o);if(u===void 0)return;let d=[];for(let f=0;f<i.length;f++){let m=i.charCodeAt(f);if(m>=128&&(m=u[m],m===void 0))return;d[f]=m}return d},xe.MACSTRING=function(i,o){let u=le.MACSTRING(i,o);return u!==void 0?u.length:0};function Z(i){return i>=-128&&i<=127}function Ge(i,o,u){let d=0,f=i.length;for(;o<f&&d<64&&i[o]===0;)++o,++d;return u.push(128|d-1),o}function pt(i,o,u){let d=0,f=i.length,m=o;for(;m<f&&d<64;){let w=i[m];if(!Z(w)||w===0&&m+1<f&&i[m+1]===0)break;++m,++d}u.push(d-1);for(let w=o;w<m;++w)u.push(i[w]+256&255);return m}function Pt(i,o,u){let d=0,f=i.length,m=o;for(;m<f&&d<64;){let w=i[m];if(w===0||Z(w)&&m+1<f&&Z(i[m+1]))break;++m,++d}u.push(64|d-1);for(let w=o;w<m;++w){let T=i[w];u.push(T+65536>>8&255,T+256&255)}return m}le.VARDELTAS=function(i){let o=0,u=[];for(;o<i.length;){let d=i[o];d===0?o=Ge(i,o,u):d>=-128&&d<=127?o=pt(i,o,u):o=Pt(i,o,u)}return u},le.INDEX=function(i){let o=1,u=[o],d=[];for(let T=0;T<i.length;T+=1){let _=le.OBJECT(i[T]);Array.prototype.push.apply(d,_),o+=_.length,u.push(o)}if(d.length===0)return[0,0];let f=[],m=1+Math.floor(Math.log(o)/Math.log(2))/8|0,w=[void 0,le.BYTE,le.USHORT,le.UINT24,le.ULONG][m];for(let T=0;T<u.length;T+=1){let _=w(u[T]);Array.prototype.push.apply(f,_)}return Array.prototype.concat(le.Card16(i.length),le.OffSize(m),f,d)},xe.INDEX=function(i){return le.INDEX(i).length},le.DICT=function(i){let o=[],u=Object.keys(i),d=u.length;for(let f=0;f<d;f+=1){let m=parseInt(u[f],0),w=i[m],T=le.OPERAND(w.value,w.type),_=le.OPERATOR(m);for(let M=0;M<T.length;M++)o.push(T[M]);for(let M=0;M<_.length;M++)o.push(_[M])}return o},xe.DICT=function(i){return le.DICT(i).length},le.OPERATOR=function(i){return i<1200?[i]:[12,i-1200]},le.OPERAND=function(i,o){let u=[];if(Array.isArray(o))for(let d=0;d<o.length;d+=1){ee.argument(i.length===o.length,"Not enough arguments given for type"+o);let f=le.OPERAND(i[d],o[d]);for(let m=0;m<f.length;m++)u.push(f[m])}else if(o==="SID"){let d=le.NUMBER(i);for(let f=0;f<d.length;f++)u.push(d[f])}else if(o==="offset"){let d=le.NUMBER32(i);for(let f=0;f<d.length;f++)u.push(d[f])}else if(o==="number"){let d=le.NUMBER(i);for(let f=0;f<d.length;f++)u.push(d[f])}else if(o==="real"){let d=le.REAL(i);for(let f=0;f<d.length;f++)u.push(d[f])}else throw new Error("Unknown operand type "+o);return u},le.OP=le.BYTE,xe.OP=xe.BYTE;var hr=typeof WeakMap=="function"&&new WeakMap;le.CHARSTRING=function(i){if(hr){let d=hr.get(i);if(d!==void 0)return d}let o=[],u=i.length;for(let d=0;d<u;d+=1){let f=i[d],m=le[f.type](f.value);for(let w=0;w<m.length;w++)o.push(m[w])}return hr&&hr.set(i,o),o},xe.CHARSTRING=function(i){return le.CHARSTRING(i).length},le.OBJECT=function(i){let o=le[i.type];return ee.argument(o!==void 0,"No encoding function for type "+i.type),o(i.value)},xe.OBJECT=function(i){let o=xe[i.type];return ee.argument(o!==void 0,"No sizeOf function for type "+i.type),o(i.value)},le.TABLE=function(i){let o=[],u=(i.fields||[]).length,d=[],f=[];for(let m=0;m<u;m+=1){let w=i.fields[m],T=le[w.type];ee.argument(T!==void 0,"No encoding function for field type "+w.type+" ("+w.name+")");let _=i[w.name];_===void 0&&(_=w.value);let M=T(_);if(w.type==="TABLE")_.fields!==null&&(f.push(o.length),d.push(M)),o.push(0,0);else for(let N=0;N<M.length;N++)o.push(M[N])}for(let m=0;m<d.length;m+=1){let w=f[m],T=o.length;ee.argument(T<65536,"Table "+i.tableName+" too big."),o[w]=T>>8,o[w+1]=T&255;for(let _=0;_<d[m].length;_++)o.push(d[m][_])}return o},xe.TABLE=function(i){let o=0,u=(i.fields||[]).length;for(let d=0;d<u;d+=1){let f=i.fields[d],m=xe[f.type];ee.argument(m!==void 0,"No sizeOf function for field type "+f.type+" ("+f.name+")");let w=i[f.name];w===void 0&&(w=f.value),o+=m(w),f.type==="TABLE"&&(o+=2)}return o},le.RECORD=le.TABLE,xe.RECORD=xe.TABLE,le.LITERAL=function(i){return i},xe.LITERAL=function(i){return i.length};function Zt(i,o,u){if(o&&o.length)for(let d=0;d<o.length;d+=1){let f=o[d];this[f.name]=f.value}if(this.tableName=i,this.fields=o,u){let d=Object.keys(u);for(let f=0;f<d.length;f+=1){let m=d[f],w=u[m];this[m]!==void 0&&(this[m]=w)}}}Zt.prototype.encode=function(){return le.TABLE(this)},Zt.prototype.sizeOf=function(){return xe.TABLE(this)};function _r(i,o,u){u===void 0&&(u=o.length);let d=new Array(o.length+1);d[0]={name:i+"Count",type:"USHORT",value:u};for(let f=0;f<o.length;f++)d[f+1]={name:i+f,type:"USHORT",value:o[f]};return d}function ae(i,o,u){let d=o.length,f=new Array(d+1);f[0]={name:i+"Count",type:"USHORT",value:d};for(let m=0;m<d;m++)f[m+1]={name:i+m,type:"TABLE",value:u(o[m],m)};return f}function ze(i,o,u){let d=o.length,f=[];f[0]={name:i+"Count",type:"USHORT",value:d};for(let m=0;m<d;m++)f=f.concat(u(o[m],m));return f}function Je(i){i.format===1?Zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(_r("glyph",i.glyphs))):i.format===2?Zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(ze("rangeRecord",i.ranges,function(o,u){return[{name:"startGlyphID"+u,type:"USHORT",value:o.start},{name:"endGlyphID"+u,type:"USHORT",value:o.end},{name:"startCoverageIndex"+u,type:"USHORT",value:o.index}]}))):ee.assert(!1,"Coverage format must be 1 or 2.")}Je.prototype=Object.create(Zt.prototype),Je.prototype.constructor=Je;function Rt(i){Zt.call(this,"scriptListTable",ze("scriptRecord",i,function(o,u){let d=o.script,f=d.defaultLangSys;return ee.assert(!!f,"Unable to write GSUB: script "+o.tag+" has no default language system."),[{name:"scriptTag"+u,type:"TAG",value:o.tag},{name:"script"+u,type:"TABLE",value:new Zt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Zt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:f.reqFeatureIndex}].concat(_r("featureIndex",f.featureIndexes)))}].concat(ze("langSys",d.langSysRecords,function(m,w){let T=m.langSys;return[{name:"langSysTag"+w,type:"TAG",value:m.tag},{name:"langSys"+w,type:"TABLE",value:new Zt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:T.reqFeatureIndex}].concat(_r("featureIndex",T.featureIndexes)))}]})))}]}))}Rt.prototype=Object.create(Zt.prototype),Rt.prototype.constructor=Rt;function Mt(i){Zt.call(this,"featureListTable",ze("featureRecord",i,function(o,u){let d=o.feature;return[{name:"featureTag"+u,type:"TAG",value:o.tag},{name:"feature"+u,type:"TABLE",value:new Zt("featureTable",[{name:"featureParams",type:"USHORT",value:d.featureParams}].concat(_r("lookupListIndex",d.lookupListIndexes)))}]}))}Mt.prototype=Object.create(Zt.prototype),Mt.prototype.constructor=Mt;function ir(i,o){Zt.call(this,"lookupListTable",ae("lookup",i,function(u){let d=o[u.lookupType];return ee.assert(!!d,"Unable to write GSUB lookup type "+u.lookupType+" tables."),new Zt("lookupTable",[{name:"lookupType",type:"USHORT",value:u.lookupType},{name:"lookupFlag",type:"USHORT",value:u.lookupFlag}].concat(ae("subtable",u.subtables,d)))}))}ir.prototype=Object.create(Zt.prototype),ir.prototype.constructor=ir;function Ut(i){i.format===1?Zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:i.startGlyph}].concat(_r("glyph",i.classes))):i.format===2?Zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(ze("rangeRecord",i.ranges,function(o,u){return[{name:"startGlyphID"+u,type:"USHORT",value:o.start},{name:"endGlyphID"+u,type:"USHORT",value:o.end},{name:"class"+u,type:"USHORT",value:o.classId}]}))):ee.assert(!1,"Class format must be 1 or 2.")}Ut.prototype=Object.create(Zt.prototype),Ut.prototype.constructor=Ut;var We={Table:Zt,Record:Zt,Coverage:Je,ClassDef:Ut,ScriptList:Rt,FeatureList:Mt,LookupList:ir,ushortList:_r,tableList:ae,recordList:ze};function br(i,o){return i.getUint8(o)}function Ze(i,o){return i.getUint16(o,!1)}function Dt(i,o){return i.getInt16(o,!1)}function nt(i,o){return(i.getUint16(o)<<8)+i.getUint8(o+2)}function _t(i,o){return i.getUint32(o,!1)}function Qr(i,o){return i.getInt32(o,!1)}function yr(i,o){let u=i.getInt16(o,!1),d=i.getUint16(o+2,!1);return u+d/65535}function Nt(i,o){let u="";for(let d=o;d<o+4;d+=1)u+=String.fromCharCode(i.getInt8(d));return u}function Nn(i,o,u){let d=0;for(let f=0;f<u;f+=1)d<<=8,d+=i.getUint8(o+f);return d}function Zr(i,o,u){let d=[];for(let f=o;f<u;f+=1)d.push(i.getUint8(f));return d}function lt(i){let o="";for(let u=0;u<i.length;u+=1)o+=String.fromCharCode(i[u]);return o}var gr={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},Pr={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function be(i,o){this.data=i,this.offset=o,this.relativeOffset=0}be.prototype.parseByte=function(){let i=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},be.prototype.parseChar=function(){let i=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,i},be.prototype.parseCard8=be.prototype.parseByte,be.prototype.parseUShort=function(){let i=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},be.prototype.parseCard16=be.prototype.parseUShort,be.prototype.parseSID=be.prototype.parseUShort,be.prototype.parseOffset16=be.prototype.parseUShort,be.prototype.parseShort=function(){let i=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,i},be.prototype.parseF2Dot14=function(){let i=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,i},be.prototype.parseUInt24=function(){let i=nt(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,i},be.prototype.parseULong=function(){let i=_t(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},be.prototype.parseLong=function(){let i=Qr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},be.prototype.parseOffset32=be.prototype.parseULong,be.prototype.parseFixed=function(){let i=yr(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,i},be.prototype.parseString=function(i){let o=this.data,u=this.offset+this.relativeOffset,d="";this.relativeOffset+=i;for(let f=0;f<i;f++)d+=String.fromCharCode(o.getUint8(u+f));return d},be.prototype.parseTag=function(){return this.parseString(4)},be.prototype.parseLongDateTime=function(){let i=_t(this.data,this.offset+this.relativeOffset+4);return i-=2082844800,this.relativeOffset+=8,i},be.prototype.parseVersion=function(i){let o=Ze(this.data,this.offset+this.relativeOffset),u=Ze(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,i===void 0&&(i=4096),o+u/i/10},be.prototype.skip=function(i,o){o===void 0&&(o=1),this.relativeOffset+=gr[i]*o},be.prototype.parseULongList=function(i){i===void 0&&(i=this.parseULong());let o=new Array(i),u=this.data,d=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getUint32(d),d+=4;return this.relativeOffset+=i*4,o},be.prototype.parseOffset16List=be.prototype.parseUShortList=function(i){i===void 0&&(i=this.parseUShort());let o=new Array(i),u=this.data,d=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getUint16(d),d+=2;return this.relativeOffset+=i*2,o},be.prototype.parseShortList=function(i){let o=new Array(i),u=this.data,d=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getInt16(d),d+=2;return this.relativeOffset+=i*2,o},be.prototype.parseByteList=function(i){let o=new Array(i),u=this.data,d=this.offset+this.relativeOffset;for(let f=0;f<i;f++)o[f]=u.getUint8(d++);return this.relativeOffset+=i,o},be.prototype.parseList=function(i,o){o||(o=i,i=this.parseUShort());let u=new Array(i);for(let d=0;d<i;d++)u[d]=o.call(this);return u},be.prototype.parseList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i);for(let d=0;d<i;d++)u[d]=o.call(this);return u},be.prototype.parseRecordList=function(i,o){o||(o=i,i=this.parseUShort());let u=new Array(i),d=Object.keys(o);for(let f=0;f<i;f++){let m={};for(let w=0;w<d.length;w++){let T=d[w],_=o[T];m[T]=_.call(this)}u[f]=m}return u},be.prototype.parseRecordList32=function(i,o){o||(o=i,i=this.parseULong());let u=new Array(i),d=Object.keys(o);for(let f=0;f<i;f++){let m={};for(let w=0;w<d.length;w++){let T=d[w],_=o[T];m[T]=_.call(this)}u[f]=m}return u},be.prototype.parseTupleRecords=function(i,o){let u=[];for(let d=0;d<i;d++){let f=[];for(let m=0;m<o;m++)f.push(this.parseF2Dot14());u.push(f)}return u},be.prototype.parseStruct=function(i){if(typeof i=="function")return i.call(this);{let o=Object.keys(i),u={};for(let d=0;d<o.length;d++){let f=o[d],m=i[f];u[f]=m.call(this)}return u}},be.prototype.parseValueRecord=function(i){if(i===void 0&&(i=this.parseUShort()),i===0)return;let o={};return i&1&&(o.xPlacement=this.parseShort()),i&2&&(o.yPlacement=this.parseShort()),i&4&&(o.xAdvance=this.parseShort()),i&8&&(o.yAdvance=this.parseShort()),i&16&&(o.xPlaDevice=void 0,this.parseShort()),i&32&&(o.yPlaDevice=void 0,this.parseShort()),i&64&&(o.xAdvDevice=void 0,this.parseShort()),i&128&&(o.yAdvDevice=void 0,this.parseShort()),o},be.prototype.parseValueRecordList=function(){let i=this.parseUShort(),o=this.parseUShort(),u=new Array(o);for(let d=0;d<o;d++)u[d]=this.parseValueRecord(i);return u},be.prototype.parsePointer=function(i){let o=this.parseOffset16();if(o>0)return new be(this.data,this.offset+o).parseStruct(i)},be.prototype.parsePointer32=function(i){let o=this.parseOffset32();if(o>0)return new be(this.data,this.offset+o).parseStruct(i)},be.prototype.parseListOfLists=function(i){let o=this.parseOffset16List(),u=o.length,d=this.relativeOffset,f=new Array(u);for(let m=0;m<u;m++){let w=o[m];if(w===0){f[m]=void 0;continue}if(this.relativeOffset=w,i){let T=this.parseOffset16List(),_=new Array(T.length);for(let M=0;M<T.length;M++)this.relativeOffset=w+T[M],_[M]=i.call(this);f[m]=_}else f[m]=this.parseUShortList()}return this.relativeOffset=d,f},be.prototype.parseCoverage=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort(),u=this.parseUShort();if(o===1)return{format:1,glyphs:this.parseUShortList(u)};if(o===2){let d=new Array(u);for(let f=0;f<u;f++)d[f]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:d}}throw new Error("0x"+i.toString(16)+": Coverage format must be 1 or 2.")},be.prototype.parseClassDef=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();return o===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:o===2?{format:2,ranges:this.parseRecordList({start:be.uShort,end:be.uShort,classId:be.uShort})}:(console.warn(`0x${i.toString(16)}: This font file uses an invalid ClassDef format of ${o}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:o})},be.list=function(i,o){return function(){return this.parseList(i,o)}},be.list32=function(i,o){return function(){return this.parseList32(i,o)}},be.recordList=function(i,o){return function(){return this.parseRecordList(i,o)}},be.recordList32=function(i,o){return function(){return this.parseRecordList32(i,o)}},be.pointer=function(i){return function(){return this.parsePointer(i)}},be.pointer32=function(i){return function(){return this.parsePointer32(i)}},be.tag=be.prototype.parseTag,be.byte=be.prototype.parseByte,be.uShort=be.offset16=be.prototype.parseUShort,be.uShortList=be.prototype.parseUShortList,be.uInt24=be.prototype.parseUInt24,be.uLong=be.offset32=be.prototype.parseULong,be.uLongList=be.prototype.parseULongList,be.fixed=be.prototype.parseFixed,be.f2Dot14=be.prototype.parseF2Dot14,be.struct=be.prototype.parseStruct,be.coverage=be.prototype.parseCoverage,be.classDef=be.prototype.parseClassDef;var Er={reserved:be.uShort,reqFeatureIndex:be.uShort,featureIndexes:be.uShortList};be.prototype.parseScriptList=function(){return this.parsePointer(be.recordList({tag:be.tag,script:be.pointer({defaultLangSys:be.pointer(Er),langSysRecords:be.recordList({tag:be.tag,langSys:be.pointer(Er)})})}))||[]},be.prototype.parseFeatureList=function(){return this.parsePointer(be.recordList({tag:be.tag,feature:be.pointer({featureParams:be.offset16,lookupListIndexes:be.uShortList})}))||[]},be.prototype.parseLookupList=function(i){return this.parsePointer(be.list(be.pointer(function(){let o=this.parseUShort();ee.argument(1<=o&&o<=9,"GPOS/GSUB lookup type "+o+" unknown.");let u=this.parseUShort(),d=u&16;return{lookupType:o,lookupFlag:u,subtables:this.parseList(be.pointer(i[o])),markFilteringSet:d?this.parseUShort():void 0}})))||[]},be.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let i=this.parseUShort(),o=this.parseUShort();return ee.argument(i===1&&o<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:be.offset32,featureTableSubstitutionOffset:be.offset32})})||[]},be.prototype.parseVariationStore=function(){let i=this.relativeOffset,o=this.parseUShort(),u={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=i+o+2,u},be.prototype.parseItemVariationStore=function(){let i=this.relativeOffset,o={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},u=this.parseOffset32(),d=this.parseUShort(),f=this.parseULongList(d);this.relativeOffset=i+u,o.variationRegions=this.parseVariationRegionList();for(let m=0;m<d;m++){let w=f[m];this.relativeOffset=i+w,o.itemVariationSubtables.push(this.parseItemVariationSubtable())}return o},be.prototype.parseVariationRegionList=function(){let i=this.parseUShort(),o=this.parseUShort();return this.parseRecordList(o,{regionAxes:be.recordList(i,{startCoord:be.f2Dot14,peakCoord:be.f2Dot14,endCoord:be.f2Dot14})})},be.prototype.parseItemVariationSubtable=function(){let i=this.parseUShort(),o=this.parseUShort(),u=this.parseUShortList(),d=u.length;return{regionIndexes:u,deltaSets:i&&d?this.parseDeltaSets(i,o,d):[]}},be.prototype.parseDeltaSetIndexMap=function(){let i=this.parseByte(),o=this.parseByte(),u=[],d=0;switch(i){case 0:d=this.parseUShort();break;case 1:d=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${i}`)}if(!d)return{format:i,entryFormat:o};let f=(o&Pr.INNER_INDEX_BIT_COUNT_MASK)+1,m=((o&Pr.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let w=0;w<d;w++){let T;if(m===1)T=this.parseByte();else if(m===2)T=this.parseUShort();else if(m===3)T=this.parseUInt24();else if(m===4)T=this.parseULong();else throw new Error(`Invalid entry size of ${m}`);let _=T>>f,M=T&(1<<f)-1;u.push({outerIndex:_,innerIndex:M})}return{format:i,entryFormat:o,map:u}},be.prototype.parseDeltaSets=function(i,o,u){let d=Array.from({length:i},()=>[]),f=o&Pr.LONG_WORDS,m=o&Pr.WORD_DELTA_COUNT_MASK;if(m>u)throw Error("wordCount must be less than or equal to regionIndexCount");let w=(f?this.parseLong:this.parseShort).bind(this),T=(f?this.parseShort:this.parseChar).bind(this);for(let _=0;_<i;_++)for(let M=0;M<u;M++)M<m?d[_].push(w()):d[_].push(T());return d},be.prototype.parseTupleVariationStoreList=function(i,o,u){let d=this.parseUShort(),f=this.parseUShort()&1,m=this.parseOffset32(),w=(f?this.parseULong:this.parseUShort).bind(this),T={},_=w();f||(_*=2);let M;for(let N=0;N<d;N++){M=w(),f||(M*=2);let J=M-_;T[N]=J?this.parseTupleVariationStore(m+_,i,o,u,N):void 0,_=M}return T},be.prototype.parseTupleVariationStore=function(i,o,u,d,f){let m=this.relativeOffset;this.relativeOffset=i,u==="cvar"&&(this.relativeOffset+=4);let w=this.parseUShort(),T=!!(w&Pr.SHARED_POINT_NUMBERS),_=w&Pr.COUNT_MASK,M=this.parseOffset16(),N=[],J=[];for(let pe=0;pe<_;pe++){let Se=this.parseTupleVariationHeader(o,u);N.push(Se)}this.relativeOffset!==i+M&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${i+M}, actually ${this.relativeOffset}`),this.relativeOffset=i+M),T&&(J=this.parsePackedPointNumbers());let K=this.relativeOffset;for(let pe=0;pe<_;pe++){let Se=N[pe];Se.privatePoints=[],this.relativeOffset=K,u==="cvar"&&!Se.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),Se.flags.privatePointNumbers&&(Se.privatePoints=this.parsePackedPointNumbers()),delete Se.flags;let ht=this.offset,Tr=this.relativeOffset,pr=Dr=>{let sn,Pn,Zn=()=>{let Kn=0;if(u==="gvar"){if(Kn=Se.privatePoints.length||J.length,!Kn){let Ps=d.get(f);Ps.path,Kn=Ps.points.length,Kn+=4}}else u==="cvar"&&(Kn=d.length);this.offset=ht,this.relativeOffset=Tr,sn=this.parsePackedDeltas(Kn),u==="gvar"&&(Pn=this.parsePackedDeltas(Kn))};return{configurable:!0,get:function(){return sn===void 0&&Zn(),Dr==="deltasY"?Pn:sn},set:function(Kn){sn===void 0&&Zn(),Dr==="deltasY"?Pn=Kn:sn=Kn}}};Object.defineProperty(Se,"deltas",pr.call(this,"deltas")),u==="gvar"&&Object.defineProperty(Se,"deltasY",pr.call(this,"deltasY")),K+=Se.variationDataSize,delete Se.variationDataSize}this.relativeOffset=m;let ve={headers:N};return ve.sharedPoints=J,ve},be.prototype.parseTupleVariationHeader=function(i,o){let u=this.parseUShort(),d=this.parseUShort(),f=!!(d&Pr.EMBEDDED_PEAK_TUPLE),m=!!(d&Pr.INTERMEDIATE_REGION),w=!!(d&Pr.PRIVATE_POINT_NUMBERS),T=f?void 0:d&Pr.TUPLE_INDEX_MASK,_=f?this.parseTupleRecords(1,i)[0]:void 0,M=m?this.parseTupleRecords(1,i)[0]:void 0,N=m?this.parseTupleRecords(1,i)[0]:void 0,J={variationDataSize:u,peakTuple:_,intermediateStartTuple:M,intermediateEndTuple:N,flags:{embeddedPeakTuple:f,intermediateRegion:m,privatePointNumbers:w}};return o==="gvar"&&(J.sharedTupleRecordsIndex=T),J},be.prototype.parsePackedPointNumbers=function(){let i=this.parseByte(),o=[],u=i;if(i>=128){let f=this.parseByte();u=(i&Pr.POINT_RUN_COUNT_MASK)<<8|f}let d=0;for(;o.length<u;){let f=this.parseByte(),m=!!(f&Pr.POINTS_ARE_WORDS),w=(f&Pr.POINT_RUN_COUNT_MASK)+1;for(let T=0;T<w&&o.length<u;T++){let _;m?_=this.parseUShort():_=this.parseByte(),d=d+_,o.push(d)}}return o},be.prototype.parsePackedDeltas=function(i){let o=[];for(;o.length<i;){let u=this.parseByte(),d=!!(u&Pr.DELTAS_ARE_ZERO),f=!!(u&Pr.DELTAS_ARE_WORDS),m=(u&Pr.DELTA_RUN_COUNT_MASK)+1;for(let w=0;w<m&&o.length<i;w++)d?o.push(0):f?o.push(this.parseShort()):o.push(this.parseChar())}return o};var at={getByte:br,getCard8:br,getUShort:Ze,getCard16:Ze,getShort:Dt,getUInt24:nt,getULong:_t,getFixed:yr,getTag:Nt,getOffset:Nn,getBytes:Zr,bytesToString:lt,Parser:be},en=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Te={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Lt={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Y={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function st(i,o,u){switch(i){case 0:if(o===65535)return"und";if(u)return u[o];break;case 1:return Te[o];case 3:return Y[o]}}var xt="utf-16",Gt={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Gr={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Fr(i,o,u){switch(i){case 0:return xt;case 1:return Gr[u]||Gt[o];case 3:if(o===1||o===10)return xt;break}}var ur={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function tn(i){return ur[i]}function on(i,o,u){let d={},f=new at.Parser(i,o),m=f.parseUShort(),w=f.parseUShort(),T=f.offset+f.parseUShort();for(let _=0;_<w;_++){let M=f.parseUShort(),N=f.parseUShort(),J=f.parseUShort(),K=f.parseUShort(),ve=en[K]||K,pe=f.parseUShort(),Se=f.parseUShort(),ht=st(M,J,u),Tr=Fr(M,N,J),pr=tn(M);if(Tr!==void 0&&ht!==void 0&&pr!==void 0){let Dr;if(Tr===xt?Dr=ot.UTF16(i,T+Se,pe):Dr=ot.MACSTRING(i,T+Se,pe,Tr),Dr){let sn=d[pr];sn===void 0&&(sn=d[pr]={});let Pn=sn[ve];Pn===void 0&&(Pn=sn[ve]={}),Pn[ht]=Dr}}}return m===1&&f.parseUShort(),d}function Xr(i){let o={};for(let u in i)o[i[u]]=parseInt(u);return o}function Wr(i,o,u,d,f,m){return new We.Record("NameRecord",[{name:"platformID",type:"USHORT",value:i},{name:"encodingID",type:"USHORT",value:o},{name:"languageID",type:"USHORT",value:u},{name:"nameID",type:"USHORT",value:d},{name:"length",type:"USHORT",value:f},{name:"offset",type:"USHORT",value:m}])}function $r(i,o){let u=i.length,d=o.length-u+1;e:for(let f=0;f<d;f++)for(;f<d;f++){for(let m=0;m<u;m++)if(o[f+m]!==i[m])continue e;return f}return-1}function Ur(i,o){let u=$r(i,o);if(u<0){u=o.length;let d=0,f=i.length;for(;d<f;++d)o.push(i[d])}return u}function Cn(i,o){let u=Xr(ur),d=Xr(Te),f=Xr(Y),m=[],w=[];for(let _ in i){let M,N=[],J={},K=Xr(en),ve=u[_];for(let pe in i[_]){let Se=K[pe];if(Se===void 0&&(Se=pe),M=parseInt(Se),isNaN(M))throw new Error('Name table entry "'+pe+'" does not exist, see nameTableNames for complete list.');J[M]=i[_][pe],N.push(M)}for(let pe=0;pe<N.length;pe++){M=N[pe];let Se=J[M];for(let ht in Se){let Tr=Se[ht];if(ve===1||ve===0){let pr=d[ht],Dr=Lt[pr],sn=Fr(ve,Dr,pr),Pn=le.MACSTRING(Tr,sn);if(ve===0&&(pr=o.indexOf(ht),pr<0&&(pr=o.length,o.push(ht)),Dr=4,Pn=le.UTF16(Tr)),Pn!==void 0){let Zn=Ur(Pn,w);m.push(Wr(ve,Dr,pr,M,Pn.length,Zn))}}if(ve===3){let pr=f[ht];if(pr!==void 0){let Dr=le.UTF16(Tr),sn=Ur(Dr,w);m.push(Wr(3,1,pr,M,Dr.length,sn))}}}}}m.sort(function(_,M){return _.platformID-M.platformID||_.encodingID-M.encodingID||_.languageID-M.languageID||_.nameID-M.nameID});let T=new We.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:m.length},{name:"stringOffset",type:"USHORT",value:6+m.length*12}]);for(let _=0;_<m.length;_++)T.fields.push({name:"record_"+_,type:"RECORD",value:m[_]});return T.fields.push({name:"strings",type:"LITERAL",value:w}),T}function Rn(i,o,u=[]){if(o<256&&o in en){if(u.length&&!u.includes(parseInt(o)))return;o=en[o]}for(let d in i)for(let f in i[d])if(f===o||parseInt(f)===o)return i[d][f]}var hn={parse:on,make:Cn,getNameByID:Rn};function Vr(i,o,u,d){i.length=o.parseUShort(),i.language=o.parseUShort()-1;let f=o.parseByteList(i.length),m=Object.assign({},f),w=Fr(u,d,i.language),T=yt[w];for(let _=0;_<T.length;_++)m[T.charCodeAt(_)]=f[128+_];i.glyphIndexMap=m}function ys(i,o,u){o.parseUShort(),i.length=o.parseULong(),i.language=o.parseULong();let d;i.groupCount=d=o.parseULong(),i.glyphIndexMap={};for(let f=0;f<d;f+=1){let m=o.parseULong(),w=o.parseULong(),T=o.parseULong();for(let _=m;_<=w;_+=1)i.glyphIndexMap[_]=T,u===12&&T++}}function cn(i,o,u,d,f){i.length=o.parseUShort(),i.language=o.parseUShort();let m;i.segCount=m=o.parseUShort()>>1,o.skip("uShort",3),i.glyphIndexMap={};let w=new at.Parser(u,d+f+14),T=new at.Parser(u,d+f+16+m*2),_=new at.Parser(u,d+f+16+m*4),M=new at.Parser(u,d+f+16+m*6),N=d+f+16+m*8;for(let J=0;J<m-1;J+=1){let K,ve=w.parseUShort(),pe=T.parseUShort(),Se=_.parseShort(),ht=M.parseUShort();for(let Tr=pe;Tr<=ve;Tr+=1)ht!==0?(N=M.offset+M.relativeOffset-2,N+=ht,N+=(Tr-pe)*2,K=at.getUShort(u,N),K!==0&&(K=K+Se&65535)):K=Tr+Se&65535,i.glyphIndexMap[Tr]=K}}function Vt(i,o){let u={};o.skip("uLong");let d=o.parseULong();for(let f=0;f<d;f+=1){let m=o.parseUInt24(),w={varSelector:m},T=o.parseOffset32(),_=o.parseOffset32(),M=o.relativeOffset;T&&(o.relativeOffset=T,w.defaultUVS=o.parseStruct({ranges:function(){return o.parseRecordList32({startUnicodeValue:o.parseUInt24,additionalCount:o.parseByte})}})),_&&(o.relativeOffset=_,w.nonDefaultUVS=o.parseStruct({uvsMappings:function(){let N={},J=o.parseRecordList32({unicodeValue:o.parseUInt24,glyphID:o.parseUShort});for(let K=0;K<J.length;K+=1)N[J[K].unicodeValue]=J[K];return N}})),u[m]=w,o.relativeOffset=M}i.varSelectorList=u}function hs(i,o){let u={};u.version=at.getUShort(i,o),ee.argument(u.version===0,"cmap table version should be 0."),u.numTables=at.getUShort(i,o+2);let d=null,f=-1,m=-1,w=null,T=null,_=[0,1,2,3,4,6],M=[0,1,10];for(let J=u.numTables-1;J>=0;J-=1)if(w=at.getUShort(i,o+4+J*8),T=at.getUShort(i,o+4+J*8+2),w===3&&M.includes(T)||w===0&&_.includes(T)||w===1&&T===0){if(m>0)continue;if(m=at.getULong(i,o+4+J*8+4),d)break}else if(w===0&&T===5){if(f=at.getULong(i,o+4+J*8+4),d=new at.Parser(i,o+f),d.parseUShort()!==14)f=-1,d=null;else if(m>0)break}if(m===-1)throw new Error("No valid cmap sub-tables found.");let N=new at.Parser(i,o+m);if(u.format=N.parseUShort(),u.format===0)Vr(u,N,w,T);else if(u.format===12||u.format===13)ys(u,N,u.format);else if(u.format===4)cn(u,N,i,o,m);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+u.format+", platformId "+w+", encodingId "+T+").");return d&&Vt(u,d),u}function Sn(i,o,u){i.segments.push({end:o,start:o,delta:-(o-u),offset:0,glyphIndex:u})}function rs(i){i.segments.push({end:65535,start:65535,delta:1,offset:0})}function qr(i){if(i.length===0)return i;let o=[i[0]];for(let u=1;u<i.length;u++){let d=o[o.length-1],f=i[u];d.end+1===f.start&&d.delta===f.delta&&f.end!==65535?d.end=f.end:o.push(f)}return o}function _n(i){let o=!0,u;for(u=i.length-1;u>0;u-=1)if(i.get(u).unicode>65535){o=!1;break}let d=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:o?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:o?12:20}];o||d.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),d.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let f=new We.Table("cmap",d);for(f.segments=[],u=0;u<i.length;u+=1){let ve=i.get(u);for(let pe=0;pe<ve.unicodes.length;pe+=1)Sn(f,ve.unicodes[pe],u)}f.segments.sort(function(ve,pe){return ve.start-pe.start}),f.segments=qr(f.segments),rs(f);let m=f.segments.length,w=0,T=[],_=[],M=[],N=[],J=[],K=[];for(u=0;u<m;u+=1){let ve=f.segments[u];ve.end<=65535&&ve.start<=65535?(T.push({name:"end_"+u,type:"USHORT",value:ve.end}),_.push({name:"start_"+u,type:"USHORT",value:ve.start}),M.push({name:"idDelta_"+u,type:"SHORT",value:ve.delta}),N.push({name:"idRangeOffset_"+u,type:"USHORT",value:ve.offset}),ve.glyphId!==void 0&&J.push({name:"glyph_"+u,type:"USHORT",value:ve.glyphId})):w+=1,!o&&ve.glyphIndex!==void 0&&(K.push({name:"cmap12Start_"+u,type:"ULONG",value:ve.start}),K.push({name:"cmap12End_"+u,type:"ULONG",value:ve.end}),K.push({name:"cmap12Glyph_"+u,type:"ULONG",value:ve.glyphIndex}))}f.segCountX2=(m-w)*2,f.searchRange=Math.pow(2,Math.floor(Math.log(m-w)/Math.log(2)))*2,f.entrySelector=Math.log(f.searchRange/2)/Math.log(2),f.rangeShift=f.segCountX2-f.searchRange;for(let ve=0;ve<T.length;ve++)f.fields.push(T[ve]);f.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let ve=0;ve<_.length;ve++)f.fields.push(_[ve]);for(let ve=0;ve<M.length;ve++)f.fields.push(M[ve]);for(let ve=0;ve<N.length;ve++)f.fields.push(N[ve]);for(let ve=0;ve<J.length;ve++)f.fields.push(J[ve]);if(f.cmap4Length=14+T.length*2+2+_.length*2+M.length*2+N.length*2+J.length*2,!o){let ve=16+K.length*4;f.cmap12Offset=20+f.cmap4Length,f.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:ve},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:K.length/3});for(let pe=0;pe<K.length;pe++)f.fields.push(K[pe])}return f}var un={parse:hs,make:_n},Bn=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Nr=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],zr=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],wn=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],V=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],et=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],kt=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Bt(i){this.font=i}Bt.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.font.glyphs;if(u)for(let d=0;d<u.length;d+=1){let f=u.get(d);for(let m=0;m<f.unicodes.length;m+=1)if(f.unicodes[m]===o)return d}return null};function zt(i){this.cmap=i}zt.prototype.charToGlyphIndex=function(i){return this.cmap.glyphIndexMap[i.codePointAt(0)]||0};function gn(i,o){this.encoding=i,this.charset=o}gn.prototype.charToGlyphIndex=function(i){let o=i.codePointAt(0),u=this.encoding[o];return this.charset.indexOf(u)};function lr(i){switch(i.version){case 1:this.names=kt.slice();break;case 2:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)i.glyphNameIndex[o]<kt.length?this.names[o]=kt[i.glyphNameIndex[o]]:this.names[o]=i.names[i.glyphNameIndex[o]-kt.length];break;case 2.5:this.names=new Array(i.numberOfGlyphs);for(let o=0;o<i.numberOfGlyphs;o++)this.names[o]=kt[o+i.glyphNameIndex[o]];break;case 3:this.names=[];break;default:this.names=[];break}}lr.prototype.nameToGlyphIndex=function(i){return this.names.indexOf(i)},lr.prototype.glyphIndexToName=function(i){return this.names[i]};function yn(i){let o,u=i.tables.cmap.glyphIndexMap,d=Object.keys(u);for(let f=0;f<d.length;f+=1){let m=d[f],w=u[m];o=i.glyphs.get(w),o.addUnicode(parseInt(m))}for(let f=0;f<i.glyphs.length;f+=1)o=i.glyphs.get(f),i.cffEncoding?o.name=i.cffEncoding.charset[f]:i.glyphNames.names&&(o.name=i.glyphNames.glyphIndexToName(f))}function ar(i){i._IndexToUnicodeMap={};let o=i.tables.cmap.glyphIndexMap,u=Object.keys(o);for(let d=0;d<u.length;d+=1){let f=u[d],m=o[f];i._IndexToUnicodeMap[m]===void 0?i._IndexToUnicodeMap[m]={unicodes:[parseInt(f)]}:i._IndexToUnicodeMap[m].unicodes.push(parseInt(f))}}function Ln(i,o){o.lowMemory?ar(i):yn(i)}function rn(i,o,u,d,f){i.beginPath(),i.moveTo(o,u),i.lineTo(d,f),i.stroke()}var $n={line:rn};function ns(i,o){let u=new be(i,o),d=u.parseShort();d!==0&&console.warn("Only CPALv0 is currently fully supported.");let f=u.parseShort(),m=u.parseShort(),w=u.parseShort(),T=u.parseOffset32(),_=u.parseUShortList(m);u.relativeOffset=T;let M=u.parseULongList(w);return u.relativeOffset=T,{version:d,numPaletteEntries:f,colorRecords:M,colorRecordIndices:_}}function vs({version:i=0,numPaletteEntries:o=0,colorRecords:u=[],colorRecordIndices:d=[0]}){return ee.argument(i===0,"Only CPALv0 are supported."),ee.argument(u.length,"No colorRecords given."),ee.argument(d.length,"No colorRecordIndices given."),d.length>1&&ee.argument(o,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new We.Table("CPAL",[{name:"version",type:"USHORT",value:i},{name:"numPaletteEntries",type:"USHORT",value:o||u.length},{name:"numPalettes",type:"USHORT",value:d.length},{name:"numColorRecords",type:"USHORT",value:u.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*d.length},...d.map((f,m)=>({name:"colorRecordIndices_"+m,type:"USHORT",value:f})),...u.map((f,m)=>({name:"colorRecords_"+m,type:"ULONG",value:f}))])}function fs(i){var o=(i&4278190080)>>24,u=(i&16711680)>>16,d=(i&65280)>>8,f=i&255;return o=o+256&255,u=u+256&255,d=d+256&255,f=(f+256&255)/255,{b:o,g:u,r:d,a:f}}function Gn(i,o,u=0,d="hexa"){if(o==65535)return"currentColor";let f=i&&i.tables&&i.tables.cpal;if(!f)return"currentColor";if(u>f.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${f.colorRecordIndices.length}, index: ${o})`);if(o>f.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${f.numPaletteEntries}, index: ${o})`);let m=f.colorRecordIndices[u]+o;if(m>f.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${f.colorRecords.length}, lookupIndex: ${m})`);let w=fs(f.colorRecords[m]);return d==="bgra"?w:Ye(w,d)}function fn(i){return("0"+parseInt(i).toString(16)).slice(-2)}function Un(i){let o=i.r/255,u=i.g/255,d=i.b/255,f=Math.max(o,u,d),m=Math.min(o,u,d),w,T,_=(f+m)/2;if(f===m)w=T=0;else{let M=f-m;switch(T=_>.5?M/(2-f-m):M/(f+m),f){case o:w=(u-d)/M+(u<d?6:0);break;case u:w=(d-o)/M+2;break;case d:w=(o-u)/M+4;break}w/=6}return{h:w*360,s:T*100,l:_*100}}function xr(i){let{h:o,s:u,l:d,a:f}=i;o=o%360,u/=100,d/=100;let m=(1-Math.abs(2*d-1))*u,w=m*(1-Math.abs(o/60%2-1)),T=d-m/2,_=0,M=0,N=0;return 0<=o&&o<60?(_=m,M=w,N=0):60<=o&&o<120?(_=w,M=m,N=0):120<=o&&o<180?(_=0,M=m,N=w):180<=o&&o<240?(_=0,M=w,N=m):240<=o&&o<300?(_=w,M=0,N=m):300<=o&&o<=360&&(_=m,M=0,N=w),{r:Math.round((_+T)*255),g:Math.round((M+T)*255),b:Math.round((N+T)*255),a:f}}function z(i){return parseInt(`0x${fn(i.b)}${fn(i.g)}${fn(i.r)}${fn(i.a*255)}`,16)}function ge(i,o="hexa"){let u=o=="raw"||o=="cpal",d=Number.isInteger(i),f=!0;if(d&&u||i==="currentColor")return i;if(typeof i=="object"){if(o=="bgra")return i;if(u)return z(i)}else if(!d&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(i.trim())){switch(i=i.trim().substring(1),i.length){case 3:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:1};break;case 4:i={r:parseInt(i[0].repeat(2),16),g:parseInt(i[1].repeat(2),16),b:parseInt(i[2].repeat(2),16),a:parseInt(i[3].repeat(2),16)/255};break;case 6:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:1};break;case 8:i={r:parseInt(i[0]+i[1],16),g:parseInt(i[2]+i[3],16),b:parseInt(i[4]+i[5],16),a:parseInt(i[6]+i[7],16)/255};break}if(o=="bgra")return i}else if(typeof document<"u"&&/^[a-z]+$/i.test(i)){let m=document.createElement("canvas").getContext("2d");m.fillStyle=i;let w=Ye(m.fillStyle,"hexa");w==="#000000ff"&&i.toLowerCase()!=="black"?f=!1:i=w}else{i=i.trim();let m=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(m.test(i)){let w=i.match(m).filter(T=>typeof T<"u");i={r:Math.round(parseFloat(w[1])/(w[2]?.39215686274509803:1)),g:Math.round(parseFloat(w[3])/(w[4]?.39215686274509803:1)),b:Math.round(parseFloat(w[5])/(w[6]?.39215686274509803:1)),a:w[7]?parseFloat(w[7])/(w[8]?100:1):1}}else{let w=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(w.test(i)){let T=i.match(w).filter(_=>typeof _<"u");i=xr({h:parseFloat(T[1])*(T[2]==="turn"?360:1),s:parseFloat(T[3]),l:parseFloat(T[4]),a:T[5]?parseFloat(T[5])/(T[6]?100:1):1})}else f=!1}}if(!f)throw new Error(`Invalid color format: ${i}`);return Ye(i,o)}function Ye(i,o="hexa"){if(i==="currentColor")return i;if(Number.isInteger(i)){if(o=="raw"||o=="cpal")return i;i=fs(i)}else typeof i!="object"&&(i=ge(i,"bgra"));let u=["hsl","hsla"].includes(o)?Un(i):null;switch(o){case"rgba":return`rgba(${i.r}, ${i.g}, ${i.b}, ${parseFloat(i.a.toFixed(3))})`;case"rgb":return`rgb(${i.r}, ${i.g}, ${i.b})`;case"hex":case"hex6":case"hex-6":return`#${fn(i.r)}${fn(i.g)}${fn(i.b)}`;case"hexa":case"hex8":case"hex-8":return`#${fn(i.r)}${fn(i.g)}${fn(i.b)}${fn(i.a*255)}`;case"hsl":return`hsl(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%)`;case"hsla":return`hsla(${u.h.toFixed(2)}, ${u.s.toFixed(2)}%, ${u.l.toFixed(2)}%, ${parseFloat(i.a.toFixed(3))})`;case"bgra":return i;case"raw":case"cpal":return z(i);default:throw new Error("Unknown color format: "+o)}}var ct={parse:ns,make:vs,getPaletteColor:Gn,parseColor:ge,formatColor:Ye};function it(i,o){let u=o||new Fe;return{configurable:!0,get:function(){return typeof u=="function"&&(u=u()),u},set:function(d){u=d}}}function bt(i){this.bindConstructorValues(i)}bt.prototype.bindConstructorValues=function(i){if(this.index=i.index||0,i.name===".notdef"?i.unicode=void 0:i.name===".null"&&(i.unicode=0),i.unicode===0&&i.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=i.name||null,this.unicode=i.unicode,this.unicodes=i.unicodes||(i.unicode!==void 0?[i.unicode]:[]),"xMin"in i&&(this.xMin=i.xMin),"yMin"in i&&(this.yMin=i.yMin),"xMax"in i&&(this.xMax=i.xMax),"yMax"in i&&(this.yMax=i.yMax),"advanceWidth"in i&&(this.advanceWidth=i.advanceWidth),"leftSideBearing"in i&&(this.leftSideBearing=i.leftSideBearing),"points"in i&&(this.points=i.points),Object.defineProperty(this,"path",it(this,i.path))},bt.prototype.addUnicode=function(i){this.unicodes.length===0&&(this.unicode=i),this.unicodes.push(i)},bt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},bt.prototype.getPath=function(i,o,u,d,f){i=i!==void 0?i:0,o=o!==void 0?o:0,u=u!==void 0?u:72,d=Object.assign({},f&&f.defaultRenderOptions,d);let m,w,T=d.xScale,_=d.yScale,M=1/(this.path.unitsPerEm||1e3)*u,N=this;f&&f.variation&&(N=f.variation.getTransform(this,d.variation),m=N.path.commands),d.hinting&&f&&f.hinting&&(w=N.path&&f.hinting.exec(N,u,d)),w?(m=f.hinting.getCommands(w),i=Math.round(i),o=Math.round(o),T=_=1):(m=N.path.commands,T===void 0&&(T=M),_===void 0&&(_=M));let J=new Fe;if(d.drawSVG){let K=this.getSvgImage(f);if(K){let ve=new Fe;return ve._image={image:K.image,x:i+K.leftSideBearing*M,y:o-K.baseline*M,width:K.image.width*M,height:K.image.height*M},J._layers=[ve],J}}if(d.drawLayers){let K=this.getLayers(f);if(K&&K.length){J._layers=[];for(let ve=0;ve<K.length;ve+=1){let pe=K[ve],Se=Gn(f,pe.paletteIndex,d.usePalette);Se==="currentColor"?Se=d.fill||"black":Se=Ye(Se,d.colorFormat||"rgba"),d=Object.assign({},d,{fill:Se}),J._layers.push(this.getPath.call(pe.glyph,i,o,u,d,f))}return J}}J.fill=d.fill||this.path.fill,J.stroke=this.path.stroke,J.strokeWidth=this.path.strokeWidth*M;for(let K=0;K<m.length;K+=1){let ve=m[K];ve.type==="M"?J.moveTo(i+ve.x*T,o+-ve.y*_):ve.type==="L"?J.lineTo(i+ve.x*T,o+-ve.y*_):ve.type==="Q"?J.quadraticCurveTo(i+ve.x1*T,o+-ve.y1*_,i+ve.x*T,o+-ve.y*_):ve.type==="C"?J.curveTo(i+ve.x1*T,o+-ve.y1*_,i+ve.x2*T,o+-ve.y2*_,i+ve.x*T,o+-ve.y*_):ve.type==="Z"&&J.stroke&&J.strokeWidth&&J.closePath()}return J},bt.prototype.getLayers=function(i){if(!i)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return i.layers.get(this.index)},bt.prototype.getSvgImage=function(i){if(!i)throw new Error("The font object is required to read the svg table in order to get the image.");return i.svgImages.get(this.index)},bt.prototype.getContours=function(i=null){if(this.points===void 0&&!i)return[];let o=[],u=[],d=i||this.points;for(let f=0;f<d.length;f+=1){let m=d[f];u.push(m),m.lastPointOfContour&&(o.push(u),u=[])}return ee.argument(u.length===0,"There are still points left in the current contour."),o},bt.prototype.getMetrics=function(){let i=this.path.commands,o=[],u=[];for(let f=0;f<i.length;f+=1){let m=i[f];m.type!=="Z"&&(o.push(m.x),u.push(m.y)),(m.type==="Q"||m.type==="C")&&(o.push(m.x1),u.push(m.y1)),m.type==="C"&&(o.push(m.x2),u.push(m.y2))}let d={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,o),yMax:Math.max.apply(null,u),leftSideBearing:this.leftSideBearing};return isFinite(d.xMin)||(d.xMin=0),isFinite(d.xMax)||(d.xMax=this.advanceWidth),isFinite(d.yMin)||(d.yMin=0),isFinite(d.yMax)||(d.yMax=0),d.rightSideBearing=this.advanceWidth-d.leftSideBearing-(d.xMax-d.xMin),d},bt.prototype.draw=function(i,o,u,d,f,m){f=Object.assign({},m&&m.defaultRenderOptions,f),this.getPath(o,u,d,f,m).draw(i)},bt.prototype.drawPoints=function(i,o,u,d,f,m){if(f=Object.assign({},m&&m.defaultRenderOptions,f),f.drawLayers){let J=this.getLayers(m);if(J&&J.length){for(let K=0;K<J.length;K+=1)J[K].glyph.index!==this.index&&this.drawPoints.call(J[K].glyph,i,o,u,d);return}}function w(J,K,ve,pe){i.beginPath();for(let Se=0;Se<J.length;Se+=1)i.moveTo(K+J[Se].x*pe,ve+J[Se].y*pe),i.arc(K+J[Se].x*pe,ve+J[Se].y*pe,2,0,Math.PI*2,!1);i.fill()}o=o!==void 0?o:0,u=u!==void 0?u:0,d=d!==void 0?d:24;let T=1/this.path.unitsPerEm*d,_=[],M=[],N=this.path.commands;m&&m.variation&&(N=m.variation.getTransform(this,f.variation).path.commands);for(let J=0;J<N.length;J+=1){let K=N[J];K.x!==void 0&&_.push({x:K.x,y:-K.y}),K.x1!==void 0&&M.push({x:K.x1,y:-K.y1}),K.x2!==void 0&&M.push({x:K.x2,y:-K.y2})}i.fillStyle="blue",w(_,o,u,T),i.fillStyle="red",w(M,o,u,T)},bt.prototype.drawMetrics=function(i,o,u,d){let f;o=o!==void 0?o:0,u=u!==void 0?u:0,d=d!==void 0?d:24,f=1/this.path.unitsPerEm*d,i.lineWidth=1,i.strokeStyle="black",$n.line(i,o,-1e4,o,1e4),$n.line(i,-1e4,u,1e4,u);let m=this.xMin||0,w=this.yMin||0,T=this.xMax||0,_=this.yMax||0,M=this.advanceWidth||0;i.strokeStyle="blue",$n.line(i,o+m*f,-1e4,o+m*f,1e4),$n.line(i,o+T*f,-1e4,o+T*f,1e4),$n.line(i,-1e4,u+-w*f,1e4,u+-w*f),$n.line(i,-1e4,u+-_*f,1e4,u+-_*f),i.strokeStyle="green",$n.line(i,o+M*f,-1e4,o+M*f,1e4)},bt.prototype.toPathData=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this;o&&o.variation&&(u=o.variation.getTransform(this,i.variation));let d=u.points&&i.pointsTransform?i.pointsTransform(u.points):u.path;return i.pathTransform&&(d=i.pathTransform(d)),d.toPathData(i)},bt.prototype.fromSVG=function(i,o={}){return this.path.fromSVG(i,o)},bt.prototype.toSVG=function(i,o){let u=this.toPathData.apply(this,[i,o]);return this.path.toSVG(i,u)},bt.prototype.toDOMElement=function(i,o){i=Object.assign({},{variation:o&&o.defaultRenderOptions.variation},i);let u=this.path;return o&&o.variation&&(u=o.variation.getTransform(this,i.variation).path),u.toDOMElement(i)};var Ot=bt;function qt(i,o,u){Object.defineProperty(i,o,{get:function(){return typeof i[u]>"u"&&i.path,i[u]},set:function(d){i[u]=d},enumerable:!0,configurable:!0})}function dt(i,o){if(this.font=i,this.glyphs={},Array.isArray(o))for(let u=0;u<o.length;u++){let d=o[u];d.path.unitsPerEm=i.unitsPerEm,this.glyphs[u]=d}this.length=o&&o.length||0}typeof Symbol<"u"&&Symbol.iterator&&(dt.prototype[Symbol.iterator]=function(){let i=-1;return{next:(function(){i++;let o=i>=this.length-1;return{value:this.get(i),done:o}}).bind(this)}}),dt.prototype.get=function(i){if(this.font._push&&this.glyphs[i]===void 0){this.font._push(i),typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());let o=this.glyphs[i],u=this.font._IndexToUnicodeMap[i];if(u)for(let d=0;d<u.unicodes.length;d++)o.addUnicode(u.unicodes[d]);this.font.cffEncoding?o.name=this.font.cffEncoding.charset[i]:this.font.glyphNames.names&&(o.name=this.font.glyphNames.glyphIndexToName(i)),this.glyphs[i].advanceWidth=this.font._hmtxTableData[i].advanceWidth,this.glyphs[i].leftSideBearing=this.font._hmtxTableData[i].leftSideBearing}else typeof this.glyphs[i]=="function"&&(this.glyphs[i]=this.glyphs[i]());return this.glyphs[i]},dt.prototype.push=function(i,o){this.glyphs[i]=o,this.length++};function nr(i,o){return new Ot({index:o,font:i})}function Lr(i,o,u,d,f,m){return function(){let w=new Ot({index:o,font:i});return w.path=function(){u(w,d,f);let T=m(i.glyphs,w);return T.unitsPerEm=i.unitsPerEm,T},qt(w,"numberOfContours","_numberOfContours"),qt(w,"xMin","_xMin"),qt(w,"xMax","_xMax"),qt(w,"yMin","_yMin"),qt(w,"yMax","_yMax"),qt(w,"points","_points"),w}}function vr(i,o,u,d,f){return function(){let m=new Ot({index:o,font:i});return m.path=function(){let w=u(i,m,d,f);return w.unitsPerEm=i.unitsPerEm,w},m}}var $t={GlyphSet:dt,glyphLoader:nr,ttfGlyphLoader:Lr,cffGlyphLoader:vr};function rt(i,o){if(i===o)return!0;if(Array.isArray(i)&&Array.isArray(o)){if(i.length!==o.length)return!1;for(let u=0;u<i.length;u+=1)if(!rt(i[u],o[u]))return!1;return!0}else return!1}var jt=10;function U(i){let o;return i.length<1240?o=107:i.length<33900?o=1131:o=32768,o}function G(i,o,u,d){let f=[],m=[],w=d>1?at.getULong(i,o):at.getCard16(i,o),T=d>1?4:2,_,M;if(w!==0){let N=at.getByte(i,o+T);_=o+(w+1)*N+T;let J=o+T+1;for(let K=0;K<w+1;K+=1)f.push(at.getOffset(i,J,N)),J+=N;M=_+f[w]}else M=o+T;for(let N=0;N<f.length-1;N+=1){let J=at.getBytes(i,_+f[N],_+f[N+1]);u&&(J=u(J,i,o,d)),m.push(J)}return{objects:m,startOffset:o,endOffset:M}}function he(i,o,u){let d=[],f=u>1?at.getULong(i,o):at.getCard16(i,o),m=u>1?4:2,w,T;if(f!==0){let _=at.getByte(i,o+m);w=o+(f+1)*_+m;let M=o+m+1;for(let N=0;N<f+1;N+=1)d.push(at.getOffset(i,M,_)),M+=_;T=w+d[f]}else T=o+m;return{offsets:d,startOffset:o,endOffset:T}}function Me(i,o,u,d,f,m){let w=m>1?at.getULong(u,d):at.getCard16(u,d),T=m>1?4:2,_=0;if(w!==0){let N=at.getByte(u,d+T);_=d+(w+1)*N+T}let M=at.getBytes(u,_+o[i],_+o[i+1]);return f&&(M=f(M)),M}function Qt(i){let o="",u=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let d=i.parseByte(),f=d>>4,m=d&15;if(f===15||(o+=u[f],m===15))break;o+=u[m]}return parseFloat(o)}function It(i,o){let u,d,f,m;if(o===28)return u=i.parseByte(),d=i.parseByte(),u<<8|d;if(o===29)return u=i.parseByte(),d=i.parseByte(),f=i.parseByte(),m=i.parseByte(),u<<24|d<<16|f<<8|m;if(o===30)return Qt(i);if(o>=32&&o<=246)return o-139;if(o>=247&&o<=250)return u=i.parseByte(),(o-247)*256+u+108;if(o>=251&&o<=254)return u=i.parseByte(),-(o-251)*256-u-108;throw new Error("Invalid b0 "+o)}function tr(i){let o={};for(let u=0;u<i.length;u+=1){let d=i[u][0],f=i[u][1],m;if(f.length===1?m=f[0]:m=f,Object.prototype.hasOwnProperty.call(o,d)&&!isNaN(o[d]))throw new Error("Object "+o+" already has key "+d);o[d]=m}return o}function fr(i,o,u,d){o=o!==void 0?o:0;let f=new at.Parser(i,o),m=[],w=[];u=u!==void 0?u:i.byteLength;let T=d<2?22:28;for(;f.relativeOffset<u;){let _=f.parseByte();if(_<T){if(_===12&&(_=1200+f.parseByte()),d>1&&_===23){gs(w);continue}m.push([_,w]),w=[]}else w.push(It(f,_,d))}return tr(m)}function jr(i,o){return o<=390?o=Bn[o]:i?o=i[o-391]:o=void 0,o}function kn(i,o,u){let d={},f;for(let m=0;m<o.length;m+=1){let w=o[m];if(Array.isArray(w.type)){let T=[];T.length=w.type.length;for(let _=0;_<w.type.length;_++)f=i[w.op]!==void 0?i[w.op][_]:void 0,f===void 0&&(f=w.value!==void 0&&w.value[_]!==void 0?w.value[_]:null),w.type[_]==="SID"&&(f=jr(u,f)),T[_]=f;d[w.name]=T}else f=i[w.op],f===void 0&&(f=w.value!==void 0?w.value:null),w.type==="SID"&&(f=jr(u,f)),d[w.name]=f}return d}function O(i,o){let u={};if(u.formatMajor=at.getCard8(i,o),u.formatMinor=at.getCard8(i,o+1),u.formatMajor>2)throw new Error(`Unsupported CFF table version ${u.formatMajor}.${u.formatMinor}`);return u.size=at.getCard8(i,o+2),u.formatMajor<2?(u.offsetSize=at.getCard8(i,o+3),u.startOffset=o,u.endOffset=o+4):(u.topDictLength=at.getCard16(i,o+3),u.endOffset=o+8),u}var Ae=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Re=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],mt=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],Ct=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],or=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Jt(i,o,u,d){let f=fr(i,o,i.byteLength,d);return kn(f,d>1?Re:Ae,u)}function Ht(i,o,u,d,f){let m=fr(i,o,u,f);return kn(m,f>1?Ct:mt,d)}function Or(i,o,u){let d=fr(i,o,void 0,u);return kn(d,or)}function Mn(i,o,u){let d=[];for(let f=0;f<u.length;f++){let m=new DataView(new Uint8Array(u[f]).buffer),w=Or(m,0,2),T=w.private[0],_=w.private[1];if(T!==0&&_!==0){let M=Ht(i,_+o,T,[],2);if(M.subrs){let N=_+M.subrs,J=G(i,N+o,void 0,2);w._subrs=J.objects,w._subrsBias=U(w._subrs)}w._privateDict=M}d.push(w)}return d}function ws(i,o,u,d,f){let m=[];for(let w=0;w<u.length;w+=1){let T=new DataView(new Uint8Array(u[w]).buffer),_=Jt(T,0,d,f);_._subrs=[],_._subrsBias=0,_._defaultWidthX=0,_._nominalWidthX=0;let M=f<2?_.private[0]:0,N=f<2?_.private[1]:0;if(M!==0&&N!==0){let J=Ht(i,N+o,M,d,f);if(_._defaultWidthX=J.defaultWidthX,_._nominalWidthX=J.nominalWidthX,J.subrs!==0){let K=N+J.subrs,ve=G(i,K+o,void 0,f);_._subrs=ve.objects,_._subrsBias=U(_._subrs)}_._privateDict=J}m.push(_)}return m}function Pi(i,o,u,d,f){let m,w,T=new at.Parser(i,o);u-=1;let _=[".notdef"],M=T.parseCard8();if(M===0)for(let N=0;N<u;N+=1)m=T.parseSID(),f?_.push(m):_.push(jr(d,m)||m);else if(M===1)for(;_.length<=u;){m=T.parseSID(),w=T.parseCard8();for(let N=0;N<=w;N+=1)f?_.push("cid"+("00000"+m).slice(-5)):_.push(jr(d,m)||m),m+=1}else if(M===2)for(;_.length<=u;){m=T.parseSID(),w=T.parseCard16();for(let N=0;N<=w;N+=1)f?_.push("cid"+("00000"+m).slice(-5)):_.push(jr(d,m)||m),m+=1}else throw new Error("Unknown charset format "+M);return _}function Oi(i,o){let u,d={},f=new at.Parser(i,o),m=f.parseCard8();if(m===0){let w=f.parseCard8();for(let T=0;T<w;T+=1)u=f.parseCard8(),d[u]=T}else if(m===1){let w=f.parseCard8();u=1;for(let T=0;T<w;T+=1){let _=f.parseCard8(),M=f.parseCard8();for(let N=_;N<=_+M;N+=1)d[N]=u,u+=1}}else throw new Error("Unknown encoding format "+m);return d}function gs(i){let o=i.pop();for(;i.length>o;)i.pop()}function Ks(i,o){let u=i.tables.cff&&i.tables.cff.topDict&&i.tables.cff.topDict.paintType||0;return u===2&&(o.fill=null,o.stroke="black",o.strokeWidth=i.tables.cff.topDict.strokeWidth||0),u}function hi(i,o,u,d,f){let m,w,T,_,M=new Fe,N=[],J=0,K=!1,ve=!1,pe=0,Se=0,ht,Tr,pr,Dr,sn=0,Pn=[],Zn,Kn=0,Ps=i.tables.cff2||i.tables.cff;if(pr=Ps.topDict._defaultWidthX,Dr=Ps.topDict._nominalWidthX,f=f||i.variation&&i.variation.get(),o.getBlendPath||(o.getBlendPath=function(cr){return hi(i,o,u,d,cr)}),i.isCIDFont||d>1){let cr=Ps.topDict._fdSelect?Ps.topDict._fdSelect[o.index]:0,dr=Ps.topDict._fdArray[cr];ht=dr._subrs,Tr=dr._subrsBias,d>1?(Pn=Ps.topDict._vstore.itemVariationStore,sn=dr._privateDict.vsindex):(pr=dr._defaultWidthX,Dr=dr._nominalWidthX)}else ht=Ps.topDict._subrs,Tr=Ps.topDict._subrsBias;let Ao=Ks(i,M),an=pr;function Ca(cr,dr){ve&&Ao!==2&&M.closePath(),M.moveTo(cr,dr),ve=!0}function Wi(){let cr;cr=(N.length&1)!==0,cr&&!K&&(an=N.shift()+Dr),J+=N.length>>1,N.length=0,K=!0}function Sr(cr){let dr,ji,Pl,Nd,ac,To,Gi,Wa,Bi,_a,Vi,qi,Rs=0;for(;Rs<cr.length;){let Va=cr[Rs];switch(Rs+=1,Va){case 1:Wi();break;case 3:Wi();break;case 4:N.length>1&&!K&&(an=N.shift()+Dr,K=!0),Se+=N.pop(),Ca(pe,Se);break;case 5:for(;N.length>0;)pe+=N.shift(),Se+=N.shift(),M.lineTo(pe,Se);break;case 6:for(;N.length>0&&(pe+=N.shift(),M.lineTo(pe,Se),N.length!==0);)Se+=N.shift(),M.lineTo(pe,Se);break;case 7:for(;N.length>0&&(Se+=N.shift(),M.lineTo(pe,Se),N.length!==0);)pe+=N.shift(),M.lineTo(pe,Se);break;case 8:for(;N.length>0;)m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_+N.shift(),M.curveTo(m,w,T,_,pe,Se);break;case 10:if(ac=N.pop()+Tr,To=ht[ac],To){if(Kn>=jt){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Kn++,Sr(To),Kn--}break;case 11:if(d>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Va=cr[Rs],Rs+=1,Va){case 35:m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),Gi=T+N.shift(),Wa=_+N.shift(),Bi=Gi+N.shift(),_a=Wa+N.shift(),Vi=Bi+N.shift(),qi=_a+N.shift(),pe=Vi+N.shift(),Se=qi+N.shift(),N.shift(),M.curveTo(m,w,T,_,Gi,Wa),M.curveTo(Bi,_a,Vi,qi,pe,Se);break;case 34:m=pe+N.shift(),w=Se,T=m+N.shift(),_=w+N.shift(),Gi=T+N.shift(),Wa=_,Bi=Gi+N.shift(),_a=_,Vi=Bi+N.shift(),qi=Se,pe=Vi+N.shift(),M.curveTo(m,w,T,_,Gi,Wa),M.curveTo(Bi,_a,Vi,qi,pe,Se);break;case 36:m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),Gi=T+N.shift(),Wa=_,Bi=Gi+N.shift(),_a=_,Vi=Bi+N.shift(),qi=_a+N.shift(),pe=Vi+N.shift(),M.curveTo(m,w,T,_,Gi,Wa),M.curveTo(Bi,_a,Vi,qi,pe,Se);break;case 37:m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),Gi=T+N.shift(),Wa=_+N.shift(),Bi=Gi+N.shift(),_a=Wa+N.shift(),Vi=Bi+N.shift(),qi=_a+N.shift(),Math.abs(Vi-pe)>Math.abs(qi-Se)?pe=Vi+N.shift():Se=qi+N.shift(),M.curveTo(m,w,T,_,Gi,Wa),M.curveTo(Bi,_a,Vi,qi,pe,Se);break;default:console.log("Glyph "+o.index+": unknown operator 1200"+Va),N.length=0}break;case 14:if(d>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(N.length>=4){let oc=V[N.pop()],$c=V[N.pop()],Rd=N.pop(),Md=N.pop();if(oc&&$c){o.isComposite=!0,o.components=[];let mg=i.cffEncoding.charset.indexOf(oc),gg=i.cffEncoding.charset.indexOf($c);o.components.push({glyphIndex:gg,dx:0,dy:0}),o.components.push({glyphIndex:mg,dx:Md,dy:Rd}),M.extend(i.glyphs.get(gg).path);let t8=i.glyphs.get(mg),zf=JSON.parse(JSON.stringify(t8.path.commands));for(let Hf=0;Hf<zf.length;Hf+=1){let $o=zf[Hf];$o.type!=="Z"&&($o.x+=Md,$o.y+=Rd),($o.type==="Q"||$o.type==="C")&&($o.x1+=Md,$o.y1+=Rd),$o.type==="C"&&($o.x2+=Md,$o.y2+=Rd)}M.extend(zf)}}else N.length>0&&!K&&(an=N.shift()+Dr,K=!0);ve&&Ao!==2&&(M.closePath(),ve=!1);break;case 15:if(d<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}sn=N.pop();break;case 16:if(d<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Zn||(Zn=i.variation&&f&&i.variation.process.getBlendVector(Pn,sn,f));var es=N.pop(),aa=Zn?Zn.length:Pn.itemVariationSubtables[sn].regionIndexes.length,Ga=es*aa,So=N.length-Ga,pl=So-es;if(Zn)for(let oc=0;oc<es;oc++){var pg=N[pl+oc];for(let $c=0;$c<aa;$c++)pg+=Zn[$c]*N[So++];N[pl+oc]=pg}for(;Ga--;)N.pop();break;case 18:Wi();break;case 19:case 20:Wi(),Rs+=J+7>>3;break;case 21:N.length>2&&!K&&(an=N.shift()+Dr,K=!0),Se+=N.pop(),pe+=N.pop(),Ca(pe,Se);break;case 22:N.length>1&&!K&&(an=N.shift()+Dr,K=!0),pe+=N.pop(),Ca(pe,Se);break;case 23:Wi();break;case 24:for(;N.length>2;)m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_+N.shift(),M.curveTo(m,w,T,_,pe,Se);pe+=N.shift(),Se+=N.shift(),M.lineTo(pe,Se);break;case 25:for(;N.length>6;)pe+=N.shift(),Se+=N.shift(),M.lineTo(pe,Se);m=pe+N.shift(),w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_+N.shift(),M.curveTo(m,w,T,_,pe,Se);break;case 26:for(N.length&1&&(pe+=N.shift());N.length>0;)m=pe,w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T,Se=_+N.shift(),M.curveTo(m,w,T,_,pe,Se);break;case 27:for(N.length&1&&(Se+=N.shift());N.length>0;)m=pe+N.shift(),w=Se,T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_,M.curveTo(m,w,T,_,pe,Se);break;case 28:dr=cr[Rs],ji=cr[Rs+1],N.push((dr<<24|ji<<16)>>16),Rs+=2;break;case 29:if(ac=N.pop()+i.gsubrsBias,To=i.gsubrs[ac],To){if(Kn>=jt){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Kn++,Sr(To),Kn--}break;case 30:for(;N.length>0&&(m=pe,w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_+(N.length===1?N.shift():0),M.curveTo(m,w,T,_,pe,Se),N.length!==0);)m=pe+N.shift(),w=Se,T=m+N.shift(),_=w+N.shift(),Se=_+N.shift(),pe=T+(N.length===1?N.shift():0),M.curveTo(m,w,T,_,pe,Se);break;case 31:for(;N.length>0&&(m=pe+N.shift(),w=Se,T=m+N.shift(),_=w+N.shift(),Se=_+N.shift(),pe=T+(N.length===1?N.shift():0),M.curveTo(m,w,T,_,pe,Se),N.length!==0);)m=pe,w=Se+N.shift(),T=m+N.shift(),_=w+N.shift(),pe=T+N.shift(),Se=_+(N.length===1?N.shift():0),M.curveTo(m,w,T,_,pe,Se);break;default:Va<32?console.log("Glyph "+o.index+": unknown operator "+Va):Va<247?N.push(Va-139):Va<251?(dr=cr[Rs],Rs+=1,N.push((Va-247)*256+dr+108)):Va<255?(dr=cr[Rs],Rs+=1,N.push(-(Va-251)*256-dr-108)):(dr=cr[Rs],ji=cr[Rs+1],Pl=cr[Rs+2],Nd=cr[Rs+3],Rs+=4,N.push((dr<<24|ji<<16|Pl<<8|Nd)/65536))}}}return Sr(u),i.variation&&f&&(M.commands=M.commands.map(cr=>{let dr=Object.keys(cr);for(let ji=0;ji<dr.length;ji++){let Pl=dr[ji];Pl!=="type"&&(cr[Pl]=Math.round(cr[Pl]))}return cr})),K&&(o.advanceWidth=an),M}function Is(i,o,u,d,f){let m=[],w,T=new at.Parser(i,o),_=T.parseCard8();if(_===0)for(let M=0;M<u;M++){if(w=T.parseCard8(),w>=d)throw new Error("CFF table CID Font FDSelect has bad FD index value "+w+" (FD count "+d+")");m.push(w)}else if(_===3||f>1&&_===4){let M=_===4?T.parseULong():T.parseCard16(),N=_===4?T.parseULong():T.parseCard16();if(N!==0)throw new Error(`CFF Table CID Font FDSelect format ${_} range has bad initial GID ${N}`);let J;for(let K=0;K<M;K++){if(w=_===4?T.parseUShort():T.parseCard8(),J=_===4?T.parseULong():T.parseCard16(),w>=d)throw new Error("CFF table CID Font FDSelect has bad FD index value "+w+" (FD count "+d+")");if(J>u)throw new Error(`CFF Table CID Font FDSelect format ${f} range has bad GID ${J}`);for(;N<J;N++)m.push(w);N=J}if(J!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+J)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+_);return m}function As(i,o,u,d){let f,m=O(i,o);m.formatMajor===2?f=u.tables.cff2={}:f=u.tables.cff={};let w=m.formatMajor>1?null:G(i,m.endOffset,at.bytesToString),T=m.formatMajor>1?null:G(i,w.endOffset),_=m.formatMajor>1?null:G(i,T.endOffset,at.bytesToString),M=G(i,m.formatMajor>1?o+m.size+m.topDictLength:_.endOffset,void 0,m.formatMajor);u.gsubrs=M.objects,u.gsubrsBias=U(u.gsubrs);let N;if(m.formatMajor>1){let K=o+m.size,ve=at.getBytes(i,K,K+m.topDictLength);N=ws(i,0,[ve],void 0,m.formatMajor)[0]}else{let K=ws(i,o,T.objects,_.objects,m.formatMajor);if(K.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+K.length);N=K[0]}if(f.topDict=N,N._privateDict&&(u.defaultWidthX=N._privateDict.defaultWidthX,u.nominalWidthX=N._privateDict.nominalWidthX),m.formatMajor<2&&N.ros[0]!==void 0&&N.ros[1]!==void 0&&(u.isCIDFont=!0),m.formatMajor>1){let K=N.fdArray,ve=N.fdSelect;if(!K)throw new Error("This is a CFF2 font, but FDArray information is missing");let pe=G(i,o+K,null,m.formatMajor),Se=Mn(i,o,pe.objects);N._fdArray=Se,ve&&(N._fdSelect=Is(i,o+ve,u.numGlyphs,Se.length,m.formatMajor))}else if(u.isCIDFont){let K=N.fdArray,ve=N.fdSelect;if(K===0||ve===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");K+=o;let pe=G(i,K),Se=ws(i,o,pe.objects,_.objects,m.formatMajor);N._fdArray=Se,ve+=o,N._fdSelect=Is(i,ve,u.numGlyphs,Se.length,m.formatMajor)}if(m.formatMajor<2){let K=o+N.private[1],ve=Ht(i,K,N.private[0],_.objects,m.formatMajor);if(u.defaultWidthX=ve.defaultWidthX,u.nominalWidthX=ve.nominalWidthX,ve.subrs!==0){let pe=K+ve.subrs,Se=G(i,pe);u.subrs=Se.objects,u.subrsBias=U(u.subrs)}else u.subrs=[],u.subrsBias=0}let J;if(d.lowMemory?(J=he(i,o+N.charStrings,m.formatMajor),u.nGlyphs=J.offsets.length-(m.formatMajor>1?1:0)):(J=G(i,o+N.charStrings,null,m.formatMajor),u.nGlyphs=J.objects.length),m.formatMajor>1&&u.tables.maxp&&u.nGlyphs!==u.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${u.nGlyphs}) must correspond to the glyph count in the maxp table (${u.tables.maxp.numGlyphs})`),m.formatMajor<2){let K=[],ve=[];N.charset===0?K=Nr:N.charset===1?K=zr:N.charset===2?K=wn:K=Pi(i,o+N.charset,u.nGlyphs,_.objects,u.isCIDFont),N.encoding===0?ve=V:N.encoding===1?ve=et:ve=Oi(i,o+N.encoding),u.cffEncoding=new gn(ve,K),u.encoding=u.encoding||u.cffEncoding}if(u.glyphs=new $t.GlyphSet(u),d.lowMemory)u._push=function(K){let ve=Me(K,J.offsets,i,o+N.charStrings,void 0,m.formatMajor);u.glyphs.push(K,$t.cffGlyphLoader(u,K,hi,ve,m.formatMajor))};else for(let K=0;K<u.nGlyphs;K+=1){let ve=J.objects[K];u.glyphs.push(K,$t.cffGlyphLoader(u,K,hi,ve,m.formatMajor))}if(N.vstore){let K=new at.Parser(i,o+N.vstore);N._vstore=K.parseVariationStore()}}function zn(i,o){let u,d=Bn.indexOf(i);return d>=0&&(u=d),d=o.indexOf(i),d>=0?u=d+Bn.length:(u=Bn.length+o.length,o.push(i)),u}function na(){return new We.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Ra(i){let o=new We.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);o.names=[];for(let u=0;u<i.length;u+=1)o.names.push({name:"name_"+u,type:"NAME",value:i[u]});return o}function Xs(i,o,u){let d={};for(let f=0;f<i.length;f+=1){let m=i[f],w=o[m.name];w!==void 0&&!rt(w,m.value)&&(m.type==="SID"&&(w=zn(w,u)),d[m.op]={name:m.name,type:m.type,value:w})}return d}function uo(i,o,u){let d=new We.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return d.dict=Xs(u>1?Re:Ae,i,o),d}function Es(i){let o=new We.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return o.topDicts=[{name:"topDict_0",type:"TABLE",value:i}],o}function Vn(i){let o=new We.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);o.strings=[];for(let u=0;u<i.length;u+=1)o.strings.push({name:"string_"+u,type:"STRING",value:i[u]});return o}function Ms(){return new We.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function ho(i,o){let u=new We.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let d=0;d<i.length;d+=1){let f=i[d],m=zn(f,o);u.fields.push({name:"glyph_"+d,type:"SID",value:m})}return u}function pa(i,o){let u=[],d=i.path;o<2&&u.push({name:"width",type:"NUMBER",value:i.advanceWidth});let f=0,m=0;for(let w=0;w<d.commands.length;w+=1){let T,_,M=d.commands[w];if(M.type==="Q"){let N=.3333333333333333,J=2/3;M={type:"C",x:M.x,y:M.y,x1:Math.round(N*f+J*M.x1),y1:Math.round(N*m+J*M.y1),x2:Math.round(N*M.x+J*M.x1),y2:Math.round(N*M.y+J*M.y1)}}if(M.type==="M")T=Math.round(M.x-f),_=Math.round(M.y-m),u.push({name:"dx",type:"NUMBER",value:T}),u.push({name:"dy",type:"NUMBER",value:_}),u.push({name:"rmoveto",type:"OP",value:21}),f=Math.round(M.x),m=Math.round(M.y);else if(M.type==="L")T=Math.round(M.x-f),_=Math.round(M.y-m),u.push({name:"dx",type:"NUMBER",value:T}),u.push({name:"dy",type:"NUMBER",value:_}),u.push({name:"rlineto",type:"OP",value:5}),f=Math.round(M.x),m=Math.round(M.y);else if(M.type==="C"){let N=Math.round(M.x1-f),J=Math.round(M.y1-m),K=Math.round(M.x2-M.x1),ve=Math.round(M.y2-M.y1);T=Math.round(M.x-M.x2),_=Math.round(M.y-M.y2),u.push({name:"dx1",type:"NUMBER",value:N}),u.push({name:"dy1",type:"NUMBER",value:J}),u.push({name:"dx2",type:"NUMBER",value:K}),u.push({name:"dy2",type:"NUMBER",value:ve}),u.push({name:"dx",type:"NUMBER",value:T}),u.push({name:"dy",type:"NUMBER",value:_}),u.push({name:"rrcurveto",type:"OP",value:8}),f=Math.round(M.x),m=Math.round(M.y)}}return o<2&&u.push({name:"endchar",type:"OP",value:14}),u}function Fi(i,o){let u=new We.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let d=0;d<i.length;d+=1){let f=i.get(d),m=pa(f,o);u.charStrings.push({name:f.name,type:"CHARSTRING",value:m})}return u}function ma(i,o,u){let d=new We.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return d.dict=Xs(u>1?Ct:mt,i,o),d}function Ma(i,o){let u=new We.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),d=1/o.unitsPerEm,f={version:o.version,fullName:o.fullName,familyName:o.familyName,weight:o.weightName,fontBBox:o.fontBBox||[0,0,0,0],fontMatrix:[d,0,0,d,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},m=o&&o.topDict||{};m.paintType&&(f.paintType=m.paintType,f.strokeWidth=m.strokeWidth||0);let w={},T=[],_;for(let K=1;K<i.length;K+=1)_=i.get(K),T.push(_.name);let M=[];u.header=na(),u.nameIndex=Ra([o.postScriptName]);let N=uo(f,M);u.topDictIndex=Es(N),u.globalSubrIndex=Ms(),u.charsets=ho(T,M),u.charStringsIndex=Fi(i,1),u.privateDict=ma(w,M),u.stringIndex=Vn(M);let J=u.header.sizeOf()+u.nameIndex.sizeOf()+u.topDictIndex.sizeOf()+u.stringIndex.sizeOf()+u.globalSubrIndex.sizeOf();return f.charset=J,f.encoding=0,f.charStrings=f.charset+u.charsets.sizeOf(),f.private[1]=f.charStrings+u.charStringsIndex.sizeOf(),N=uo(f,M),u.topDictIndex=Es(N),u}var $i={parse:As,make:Ma};function fo(i,o){let u={},d=new at.Parser(i,o);return u.version=d.parseVersion(),u.fontRevision=Math.round(d.parseFixed()*1e3)/1e3,u.checkSumAdjustment=d.parseULong(),u.magicNumber=d.parseULong(),ee.argument(u.magicNumber===1594834165,"Font header has wrong magic number."),u.flags=d.parseUShort(),u.unitsPerEm=d.parseUShort(),u.created=d.parseLongDateTime(),u.modified=d.parseLongDateTime(),u.xMin=d.parseShort(),u.yMin=d.parseShort(),u.xMax=d.parseShort(),u.yMax=d.parseShort(),u.macStyle=d.parseUShort(),u.lowestRecPPEM=d.parseUShort(),u.fontDirectionHint=d.parseShort(),u.indexToLocFormat=d.parseShort(),u.glyphDataFormat=d.parseShort(),u}function fi(i){let o=Math.round(new Date().getTime()/1e3)+2082844800,u=o,d=i.macStyle||0;return i.createdTimestamp&&(u=i.createdTimestamp+2082844800),new We.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:u},{name:"modified",type:"LONGDATETIME",value:o},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:d},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],i)}var Ds={parse:fo,make:fi};function pn(i,o){let u={},d=new at.Parser(i,o);return u.version=d.parseVersion(),u.ascender=d.parseShort(),u.descender=d.parseShort(),u.lineGap=d.parseShort(),u.advanceWidthMax=d.parseUShort(),u.minLeftSideBearing=d.parseShort(),u.minRightSideBearing=d.parseShort(),u.xMaxExtent=d.parseShort(),u.caretSlopeRise=d.parseShort(),u.caretSlopeRun=d.parseShort(),u.caretOffset=d.parseShort(),d.relativeOffset+=8,u.metricDataFormat=d.parseShort(),u.numberOfHMetrics=d.parseUShort(),u}function Da(i){return new We.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],i)}var ss={parse:pn,make:Da};function ga(i,o,u,d,f){let m,w,T=new at.Parser(i,o);for(let _=0;_<d;_+=1){_<u&&(m=T.parseUShort(),w=T.parseShort());let M=f.get(_);M.advanceWidth=m,M.leftSideBearing=w}}function Ns(i,o,u,d,f){i._hmtxTableData={};let m,w,T=new at.Parser(o,u);for(let _=0;_<f;_+=1)_<d&&(m=T.parseUShort(),w=T.parseShort()),i._hmtxTableData[_]={advanceWidth:m,leftSideBearing:w}}function cl(i,o,u,d,f,m,w){w.lowMemory?Ns(i,o,u,d,f):ga(o,u,d,f,m)}function pi(i){let o=new We.Table("hmtx",[]);for(let u=0;u<i.length;u+=1){let d=i.get(u),f=d.advanceWidth||0,m=d.leftSideBearing||0;o.fields.push({name:"advanceWidth_"+u,type:"USHORT",value:f}),o.fields.push({name:"leftSideBearing_"+u,type:"SHORT",value:m})}return o}var ja={parse:cl,make:pi};function po(i){let o=new We.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:i.length}]),u="",d=12+i.length*4;for(let f=0;f<i.length;++f){let m=u.indexOf(i[f]);m<0&&(m=u.length,u+=i[f]),o.fields.push({name:"offset "+f,type:"USHORT",value:d+m}),o.fields.push({name:"length "+f,type:"USHORT",value:i[f].length})}return o.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),o}function Il(i,o){let u=new at.Parser(i,o),d=u.parseULong();ee.argument(d===1,"Unsupported ltag table version."),u.skip("uLong",1);let f=u.parseULong(),m=[];for(let w=0;w<f;w++){let T="",_=o+u.parseUShort(),M=u.parseUShort();for(let N=_;N<_+M;++N)T+=String.fromCharCode(i.getInt8(N));m.push(T)}return m}var ul={make:po,parse:Il};function No(i,o){let u={},d=new at.Parser(i,o);return u.version=d.parseVersion(),u.numGlyphs=d.parseUShort(),u.version===1&&(u.maxPoints=d.parseUShort(),u.maxContours=d.parseUShort(),u.maxCompositePoints=d.parseUShort(),u.maxCompositeContours=d.parseUShort(),u.maxZones=d.parseUShort(),u.maxTwilightPoints=d.parseUShort(),u.maxStorage=d.parseUShort(),u.maxFunctionDefs=d.parseUShort(),u.maxInstructionDefs=d.parseUShort(),u.maxStackElements=d.parseUShort(),u.maxSizeOfInstructions=d.parseUShort(),u.maxComponentElements=d.parseUShort(),u.maxComponentDepth=d.parseUShort()),u}function Js(i){return new We.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:i}])}var Ro={parse:No,make:Js},mo=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function go(i){for(let o=0;o<mo.length;o+=1){let u=mo[o];if(i>=u.begin&&i<u.end)return o}return-1}function mi(i,o){let u={},d=new at.Parser(i,o);u.version=d.parseUShort(),u.xAvgCharWidth=d.parseShort(),u.usWeightClass=d.parseUShort(),u.usWidthClass=d.parseUShort(),u.fsType=d.parseUShort(),u.ySubscriptXSize=d.parseShort(),u.ySubscriptYSize=d.parseShort(),u.ySubscriptXOffset=d.parseShort(),u.ySubscriptYOffset=d.parseShort(),u.ySuperscriptXSize=d.parseShort(),u.ySuperscriptYSize=d.parseShort(),u.ySuperscriptXOffset=d.parseShort(),u.ySuperscriptYOffset=d.parseShort(),u.yStrikeoutSize=d.parseShort(),u.yStrikeoutPosition=d.parseShort(),u.sFamilyClass=d.parseShort(),u.panose=[];for(let f=0;f<10;f++)u.panose[f]=d.parseByte();return u.ulUnicodeRange1=d.parseULong(),u.ulUnicodeRange2=d.parseULong(),u.ulUnicodeRange3=d.parseULong(),u.ulUnicodeRange4=d.parseULong(),u.achVendID=String.fromCharCode(d.parseByte(),d.parseByte(),d.parseByte(),d.parseByte()),u.fsSelection=d.parseUShort(),u.usFirstCharIndex=d.parseUShort(),u.usLastCharIndex=d.parseUShort(),u.sTypoAscender=d.parseShort(),u.sTypoDescender=d.parseShort(),u.sTypoLineGap=d.parseShort(),u.usWinAscent=d.parseUShort(),u.usWinDescent=d.parseUShort(),u.version>=1&&(u.ulCodePageRange1=d.parseULong(),u.ulCodePageRange2=d.parseULong()),u.version>=2&&(u.sxHeight=d.parseShort(),u.sCapHeight=d.parseShort(),u.usDefaultChar=d.parseUShort(),u.usBreakChar=d.parseUShort(),u.usMaxContent=d.parseUShort()),u}function ps(i){return new We.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],i)}var Ei={parse:mi,make:ps,unicodeRanges:mo,getUnicodeRange:go};function xo(i,o){let u={},d=new at.Parser(i,o);switch(u.version=d.parseVersion(),u.italicAngle=d.parseFixed(),u.underlinePosition=d.parseShort(),u.underlineThickness=d.parseShort(),u.isFixedPitch=d.parseULong(),u.minMemType42=d.parseULong(),u.maxMemType42=d.parseULong(),u.minMemType1=d.parseULong(),u.maxMemType1=d.parseULong(),u.version){case 1:u.names=kt.slice();break;case 2:u.numberOfGlyphs=d.parseUShort(),u.glyphNameIndex=new Array(u.numberOfGlyphs);for(let f=0;f<u.numberOfGlyphs;f++)u.glyphNameIndex[f]=d.parseUShort();u.names=[];for(let f=0;f<u.numberOfGlyphs;f++)if(u.glyphNameIndex[f]>=kt.length){let m=d.parseChar();u.names.push(d.parseString(m))}break;case 2.5:u.numberOfGlyphs=d.parseUShort(),u.offset=new Array(u.numberOfGlyphs);for(let f=0;f<u.numberOfGlyphs;f++)u.offset[f]=d.parseChar();break}return u}function dl(i){let{italicAngle:o=Math.round((i.italicAngle||0)*65536),underlinePosition:u=0,underlineThickness:d=0,isFixedPitch:f=0,minMemType42:m=0,maxMemType42:w=0,minMemType1:T=0,maxMemType1:_=0}=i.tables.post||{};return new We.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:o},{name:"underlinePosition",type:"FWORD",value:u},{name:"underlineThickness",type:"FWORD",value:d},{name:"isFixedPitch",type:"ULONG",value:f},{name:"minMemType42",type:"ULONG",value:m},{name:"maxMemType42",type:"ULONG",value:w},{name:"minMemType1",type:"ULONG",value:T},{name:"maxMemType1",type:"ULONG",value:_}])}var Mo={parse:xo,make:dl},js=new Array(9);js[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(be.coverage),deltaGlyphId:this.parseShort()};if(o===2)return{substFormat:2,coverage:this.parsePointer(be.coverage),substitute:this.parseOffset16List()};ee.assert(!1,"0x"+i.toString(16)+": lookup type 1 format must be 1 or 2.")},js[2]=function(){let i=this.parseUShort();return ee.argument(i===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(be.coverage),sequences:this.parseListOfLists()}},js[3]=function(){let i=this.parseUShort();return ee.argument(i===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(be.coverage),alternateSets:this.parseListOfLists()}},js[4]=function(){let i=this.parseUShort();return ee.argument(i===1,"GSUB ligature table identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(be.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var ei={sequenceIndex:be.uShort,lookupListIndex:be.uShort};js[5]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:o,coverage:this.parsePointer(be.coverage),ruleSets:this.parseListOfLists(function(){let u=this.parseUShort(),d=this.parseUShort();return{input:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(d,ei)}})};if(o===2)return{substFormat:o,coverage:this.parsePointer(be.coverage),classDef:this.parsePointer(be.classDef),classSets:this.parseListOfLists(function(){let u=this.parseUShort(),d=this.parseUShort();return{classes:this.parseUShortList(u-1),lookupRecords:this.parseRecordList(d,ei)}})};if(o===3){let u=this.parseUShort(),d=this.parseUShort();return{substFormat:o,coverages:this.parseList(u,be.pointer(be.coverage)),lookupRecords:this.parseRecordList(d,ei)}}ee.assert(!1,"0x"+i.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},js[6]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{substFormat:1,coverage:this.parsePointer(be.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(ei)}})};if(o===2)return{substFormat:2,coverage:this.parsePointer(be.coverage),backtrackClassDef:this.parsePointer(be.classDef),inputClassDef:this.parsePointer(be.classDef),lookaheadClassDef:this.parsePointer(be.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(ei)}})};if(o===3)return{substFormat:3,backtrackCoverage:this.parseList(be.pointer(be.coverage)),inputCoverage:this.parseList(be.pointer(be.coverage)),lookaheadCoverage:this.parseList(be.pointer(be.coverage)),lookupRecords:this.parseRecordList(ei)};ee.assert(!1,"0x"+i.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},js[7]=function(){let i=this.parseUShort();ee.argument(i===1,"GSUB Extension Substitution subtable identifier-format must be 1");let o=this.parseUShort(),u=new be(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:o,extension:js[o].call(u)}},js[8]=function(){let i=this.parseUShort();return ee.argument(i===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:i,coverage:this.parsePointer(be.coverage),backtrackCoverage:this.parseList(be.pointer(be.coverage)),lookaheadCoverage:this.parseList(be.pointer(be.coverage)),substitutes:this.parseUShortList()}};function El(i,o){o=o||0;let u=new be(i,o),d=u.parseVersion(1);return ee.argument(d===1||d===1.1,"Unsupported GSUB table version."),d===1?{version:d,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(js)}:{version:d,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(js),variations:u.parseFeatureVariationsList()}}var Xn=new Array(9);Xn[1]=function(i){if(i.substFormat===1)return new We.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)},{name:"deltaGlyphID",type:"SHORT",value:i.deltaGlyphId}]);if(i.substFormat===2)return new We.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.ushortList("substitute",i.substitute)));ee.fail("Lookup type 1 substFormat must be 1 or 2.")},Xn[2]=function(i){return ee.assert(i.substFormat===1,"Lookup type 2 substFormat must be 1."),new We.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.tableList("seqSet",i.sequences,function(o){return new We.Table("sequenceSetTable",We.ushortList("sequence",o))})))},Xn[3]=function(i){return ee.assert(i.substFormat===1,"Lookup type 3 substFormat must be 1."),new We.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.tableList("altSet",i.alternateSets,function(o){return new We.Table("alternateSetTable",We.ushortList("alternate",o))})))},Xn[4]=function(i){return ee.assert(i.substFormat===1,"Lookup type 4 substFormat must be 1."),new We.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.tableList("ligSet",i.ligatureSets,function(o){return new We.Table("ligatureSetTable",We.tableList("ligature",o,function(u){return new We.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:u.ligGlyph}].concat(We.ushortList("component",u.components,u.components.length+1)))}))})))},Xn[5]=function(i){if(i.substFormat===1)return new We.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.tableList("sequenceRuleSet",i.ruleSets,function(o){return o?new We.Table("sequenceRuleSetTable",We.tableList("sequenceRule",o,function(u){let d=We.ushortList("seqLookup",[],u.lookupRecords.length).concat(We.ushortList("inputSequence",u.input,u.input.length+1));[d[0],d[1]]=[d[1],d[0]];for(let f=0;f<u.lookupRecords.length;f++){let m=u.lookupRecords[f];d=d.concat({name:"sequenceIndex"+f,type:"USHORT",value:m.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:m.lookupListIndex})}return new We.Table("sequenceRuleTable",d)})):new We.Table("NULL",null)})));if(i.substFormat===2)return new We.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)},{name:"classDef",type:"TABLE",value:new We.ClassDef(i.classDef)}].concat(We.tableList("classSeqRuleSet",i.classSets,function(o){return o?new We.Table("classSeqRuleSetTable",We.tableList("classSeqRule",o,function(u){let d=We.ushortList("classes",u.classes,u.classes.length+1).concat(We.ushortList("seqLookupCount",[],u.lookupRecords.length));for(let f=0;f<u.lookupRecords.length;f++){let m=u.lookupRecords[f];d=d.concat({name:"sequenceIndex"+f,type:"USHORT",value:m.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:m.lookupListIndex})}return new We.Table("classSeqRuleTable",d)})):new We.Table("NULL",null)})));if(i.substFormat===3){let o=[{name:"substFormat",type:"USHORT",value:i.substFormat}];o.push({name:"inputGlyphCount",type:"USHORT",value:i.coverages.length}),o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.coverages.length;u++){let d=i.coverages[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new We.Coverage(d)})}for(let u=0;u<i.lookupRecords.length;u++){let d=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:d.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:d.lookupListIndex})}return new We.Table("contextualSubstitutionTable",o)}ee.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},Xn[6]=function(i){if(i.substFormat===1)return new We.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:i.substFormat},{name:"coverage",type:"TABLE",value:new We.Coverage(i.coverage)}].concat(We.tableList("chainRuleSet",i.chainRuleSets,function(o){return new We.Table("chainRuleSetTable",We.tableList("chainRule",o,function(u){let d=We.ushortList("backtrackGlyph",u.backtrack,u.backtrack.length).concat(We.ushortList("inputGlyph",u.input,u.input.length+1)).concat(We.ushortList("lookaheadGlyph",u.lookahead,u.lookahead.length)).concat(We.ushortList("substitution",[],u.lookupRecords.length));for(let f=0;f<u.lookupRecords.length;f++){let m=u.lookupRecords[f];d=d.concat({name:"sequenceIndex"+f,type:"USHORT",value:m.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:m.lookupListIndex})}return new We.Table("chainRuleTable",d)}))})));if(i.substFormat===2)ee.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(i.substFormat===3){let o=[{name:"substFormat",type:"USHORT",value:i.substFormat}];o.push({name:"backtrackGlyphCount",type:"USHORT",value:i.backtrackCoverage.length});for(let u=0;u<i.backtrackCoverage.length;u++){let d=i.backtrackCoverage[u];o.push({name:"backtrackCoverage"+u,type:"TABLE",value:new We.Coverage(d)})}o.push({name:"inputGlyphCount",type:"USHORT",value:i.inputCoverage.length});for(let u=0;u<i.inputCoverage.length;u++){let d=i.inputCoverage[u];o.push({name:"inputCoverage"+u,type:"TABLE",value:new We.Coverage(d)})}o.push({name:"lookaheadGlyphCount",type:"USHORT",value:i.lookaheadCoverage.length});for(let u=0;u<i.lookaheadCoverage.length;u++){let d=i.lookaheadCoverage[u];o.push({name:"lookaheadCoverage"+u,type:"TABLE",value:new We.Coverage(d)})}o.push({name:"substitutionCount",type:"USHORT",value:i.lookupRecords.length});for(let u=0;u<i.lookupRecords.length;u++){let d=i.lookupRecords[u];o=o.concat({name:"sequenceIndex"+u,type:"USHORT",value:d.sequenceIndex}).concat({name:"lookupListIndex"+u,type:"USHORT",value:d.lookupListIndex})}return new We.Table("chainContextTable",o)}ee.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function gi(i){return new We.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new We.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new We.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new We.LookupList(i.lookups,Xn)}])}var qn={parse:El,make:gi};function xa(i,o){let u=new at.Parser(i,o),d=u.parseULong();ee.argument(d===1,"Unsupported META table version."),u.parseULong(),u.parseULong();let f=u.parseULong(),m={};for(let w=0;w<f;w++){let T=u.parseTag(),_=u.parseULong(),M=u.parseULong();if(T==="appl"||T==="bild")continue;let N=ot.UTF8(i,o+_,M);m[T]=N}return m}function Ui(i){let o=Object.keys(i).length,u="",d=16+o*12,f=new We.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:d},{name:"numTags",type:"ULONG",value:o}]);for(let m in i){let w=u.length;u+=i[m],f.fields.push({name:"tag "+m,type:"TAG",value:m}),f.fields.push({name:"offset "+m,type:"ULONG",value:d+w}),f.fields.push({name:"length "+m,type:"ULONG",value:i[m].length})}return f.fields.push({name:"stringPool",type:"CHARARRAY",value:u}),f}var Do={parse:xa,make:Ui};function Bs(i,o){let u=new be(i,o),d=u.parseUShort();d!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let f=u.parseUShort(),m=u.parseOffset32(),w=u.parseOffset32(),T=u.parseUShort();u.relativeOffset=m;let _=u.parseRecordList(f,{glyphID:be.uShort,firstLayerIndex:be.uShort,numLayers:be.uShort});u.relativeOffset=w;let M=u.parseRecordList(T,{glyphID:be.uShort,paletteIndex:be.uShort});return{version:d,baseGlyphRecords:_,layerRecords:M}}function Us({version:i=0,baseGlyphRecords:o=[],layerRecords:u=[]}){ee.argument(i===0,"Only COLRv0 supported.");let d=14,f=d+o.length*6;return new We.Table("COLR",[{name:"version",type:"USHORT",value:i},{name:"numBaseGlyphRecords",type:"USHORT",value:o.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:d},{name:"layerRecordsOffset",type:"ULONG",value:f},{name:"numLayerRecords",type:"USHORT",value:u.length},...o.map((m,w)=>[{name:"glyphID_"+w,type:"USHORT",value:m.glyphID},{name:"firstLayerIndex_"+w,type:"USHORT",value:m.firstLayerIndex},{name:"numLayers_"+w,type:"USHORT",value:m.numLayers}]).flat(),...u.map((m,w)=>[{name:"LayerGlyphID_"+w,type:"USHORT",value:m.glyphID},{name:"paletteIndex_"+w,type:"USHORT",value:m.paletteIndex}]).flat()])}var zi={parse:Bs,make:Us};function dn(i,o){return[{name:"tag_"+i,type:"TAG",value:o.tag},{name:"minValue_"+i,type:"FIXED",value:o.minValue<<16},{name:"defaultValue_"+i,type:"FIXED",value:o.defaultValue<<16},{name:"maxValue_"+i,type:"FIXED",value:o.maxValue<<16},{name:"flags_"+i,type:"USHORT",value:0},{name:"nameID_"+i,type:"USHORT",value:o.axisNameID}]}function Ni(i,o,u){let d={},f=new at.Parser(i,o);d.tag=f.parseTag(),d.minValue=f.parseFixed(),d.defaultValue=f.parseFixed(),d.maxValue=f.parseFixed(),f.skip("uShort",1);let m=f.parseUShort();return d.axisNameID=m,d.name=Rn(u,m),d}function xi(i,o,u,d={}){let f=[{name:"nameID_"+i,type:"USHORT",value:o.subfamilyNameID},{name:"flags_"+i,type:"USHORT",value:0}];for(let m=0;m<u.length;++m){let w=u[m].tag;f.push({name:"axis_"+i+" "+w,type:"FIXED",value:o.coordinates[w]<<16})}return d&&d.postScriptNameID&&f.push({name:"postScriptNameID_",type:"USHORT",value:o.postScriptNameID!==void 0?o.postScriptNameID:65535}),f}function ba(i,o,u,d,f){let m={},w=new at.Parser(i,o),T=w.parseUShort();m.subfamilyNameID=T,m.name=Rn(d,T,[2,17]),w.skip("uShort",1),m.coordinates={};for(let M=0;M<u.length;++M)m.coordinates[u[M].tag]=w.parseFixed();if(w.relativeOffset===f)return m.postScriptNameID=void 0,m.postScriptName=void 0,m;let _=w.parseUShort();return m.postScriptNameID=_==65535?void 0:_,m.postScriptName=m.postScriptNameID!==void 0?Rn(d,_,[6]):"",m}function sa(i,o){let u=new We.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:i.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:i.instances.length},{name:"instanceSize",type:"USHORT",value:4+i.axes.length*4}]);u.offsetToData=u.sizeOf();for(let f=0;f<i.axes.length;f++)u.fields=u.fields.concat(dn(f,i.axes[f],o));let d={};for(let f=0;f<i.instances.length;f++)if(i.instances[f].postScriptNameID!==void 0){u.instanceSize+=2,d.postScriptNameID=!0;break}for(let f=0;f<i.instances.length;f++)u.fields=u.fields.concat(xi(f,i.instances[f],i.axes,d));return u}function ya(i,o,u){let d=new at.Parser(i,o),f=d.parseULong();ee.argument(f===65536,"Unsupported fvar table version.");let m=d.parseOffset16();d.skip("uShort",1);let w=d.parseUShort(),T=d.parseUShort(),_=d.parseUShort(),M=d.parseUShort(),N=[];for(let ve=0;ve<w;ve++)N.push(Ni(i,o+m+ve*T,u));let J=[],K=o+m+w*T;for(let ve=0;ve<_;ve++)J.push(ba(i,K+ve*M,N,u,M));return{axes:N,instances:J}}var bi={make:sa,parse:ya},va={tag:be.tag,nameID:be.uShort,ordering:be.uShort},Qs=new Array(5);Qs[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},Qs[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},Qs[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},Qs[4]=function(){let i=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(i,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Ri(){let i=this.parseUShort(),o=Qs[i],u={format:i};return o===void 0?(console.warn(`Unknown axis value table format ${i}`),u):Object.assign(u,this.parseStruct(o.bind(this)))}function Ba(i,o,u){o||(o=0);let d=new at.Parser(i,o),f=d.parseUShort(),m=d.parseUShort();f!==1&&console.warn(`Unsupported STAT table version ${f}.${m}`);let w=[f,m],T=d.parseUShort(),_=d.parseUShort(),M=d.parseOffset32(),N=d.parseUShort(),J=d.parseOffset32(),K=f>1||m>0?d.parseUShort():void 0;u!==void 0&&ee.argument(_>=u.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),N>0&&ee.argument(_>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let ve=[];for(let ht=0;ht<_;ht++)d.offset=o+M,d.relativeOffset=ht*T,ve.push(d.parseStruct(va));d.offset=o,d.relativeOffset=J;let pe=d.parseUShortList(N),Se=[];for(let ht=0;ht<N;ht++)d.offset=o+J,d.relativeOffset=pe[ht],Se.push(Ri.apply(d));return{version:w,axes:ve,values:Se,elidedFallbackNameID:K}}var zs=new Array(5);zs[1]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:1},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`value${i}`,type:"FLOAT",value:o.value}]},zs[2]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:2},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`nominalValue${i}`,type:"FLOAT",value:o.nominalValue},{name:`rangeMinValue${i}`,type:"FLOAT",value:o.rangeMinValue},{name:`rangeMaxValue${i}`,type:"FLOAT",value:o.rangeMaxValue}]},zs[3]=function(i,o){return[{name:`format${i}`,type:"USHORT",value:3},{name:`axisIndex${i}`,type:"USHORT",value:o.axisIndex},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID},{name:`value${i}`,type:"FLOAT",value:o.value},{name:`linkedValue${i}`,type:"FLOAT",value:o.linkedValue}]},zs[4]=function(i,o){let u=[{name:`format${i}`,type:"USHORT",value:4},{name:`axisCount${i}`,type:"USHORT",value:o.axisValues.length},{name:`flags${i}`,type:"USHORT",value:o.flags},{name:`valueNameID${i}`,type:"USHORT",value:o.valueNameID}];for(let d=0;d<o.axisValues.length;d++)u=u.concat([{name:`format${i}axisIndex${d}`,type:"USHORT",value:o.axisValues[d].axisIndex},{name:`format${i}value${d}`,type:"FLOAT",value:o.axisValues[d].value}]);return u};function Yn(i,o){return new We.Record("axisRecord_"+i,[{name:"axisTag_"+i,type:"TAG",value:o.tag},{name:"axisNameID_"+i,type:"USHORT",value:o.nameID},{name:"axisOrdering_"+i,type:"USHORT",value:o.ordering}])}function Mi(i,o){let u=o.format,d=zs[u];ee.argument(d!==void 0,`Unknown axis value table format ${u}`);let f=d(i,o);return new We.Table("axisValueTable_"+i,f)}function jo(i){let o=new We.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:i.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:i.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:i.elidedFallbackNameID}]);o.designAxesOffset=o.offsetToAxisValueOffsets=o.sizeOf();for(let m=0;m<i.axes.length;m++){let w=Yn(m,i.axes[m]);o.offsetToAxisValueOffsets+=w.sizeOf(),o.fields=o.fields.concat(w.fields)}let u=[],d=[],f=i.values.length*2;for(let m=0;m<i.values.length;m++){let w=Mi(m,i.values[m]);u.push({name:"offset_"+m,type:"USHORT",value:f}),f+=w.sizeOf(),d=d.concat(w.fields)}return o.fields=o.fields.concat(u),o.fields=o.fields.concat(d),o}var wa={make:jo,parse:Ba};function Bo(i,o){return new We.Record("axisValueMap_"+i,[{name:"fromCoordinate_"+i,type:"F2DOT14",value:o.fromCoordinate},{name:"toCoordinate_"+i,type:"F2DOT14",value:o.toCoordinate}])}function Qo(i,o){let u=new We.Record("segmentMap_"+i,[{name:"positionMapCount_"+i,type:"USHORT",value:o.axisValueMaps.length}]),d=[];for(let f=0;f<o.axisValueMaps.length;f++){let m=Bo(`${i}_${f}`,o.axisValueMaps[f]);d=d.concat(m.fields)}return u.fields=u.fields.concat(d),u}function Qa(i,o){ee.argument(i.axisSegmentMaps.length===o.axes.length,"avar axis count must correspond to fvar axis count");let u=new We.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:i.axisSegmentMaps.length}]);for(let d=0;d<i.axisSegmentMaps.length;d++){let f=Qo(d,i.axisSegmentMaps[d]);u.fields=u.fields.concat(f.fields)}return u}function bo(i,o,u){o||(o=0);let d=new be(i,o),f=d.parseUShort(),m=d.parseUShort();f!==1&&console.warn(`Unsupported avar table version ${f}.${m}`),d.skip("uShort",1);let w=d.parseUShort();ee.argument(w===u.axes.length,"avar axis count must correspond to fvar axis count");let T=[];for(let _=0;_<w;_++){let M=[],N=d.parseUShort();for(let J=0;J<N;J++){let K=d.parseF2Dot14(),ve=d.parseF2Dot14();M.push({fromCoordinate:K,toCoordinate:ve})}T.push({axisValueMaps:M})}return{version:[f,m],axisSegmentMaps:T}}var Pa={make:Qa,parse:bo};function oe(i,o,u,d){let f=new at.Parser(i,o),m=f.parseTupleVariationStore(f.relativeOffset,u.axes.length,"cvar",d),w=f.parseUShort(),T=f.parseUShort();return w!==1&&console.warn(`Unsupported cvar table version ${w}.${T}`),{version:[w,T],...m}}function Ve(){console.warn("Writing of cvar tables is not yet supported.")}var Tt={make:Ve,parse:oe};function Et(i,o,u,d){let f=new at.Parser(i,o),m=f.parseUShort(),w=f.parseUShort();m!==1&&console.warn(`Unsupported gvar table version ${m}.${w}`);let T=f.parseUShort();T!==u.axes.length&&console.warn(`axisCount ${T} in gvar table does not match the number of axes ${u.axes.length} in the fvar table!`);let _=f.parseUShort(),M=f.parsePointer32(function(){return this.parseTupleRecords(_,T)}),N=f.parseTupleVariationStoreList(T,"gvar",d);return{version:[m,w],sharedTuples:M,glyphVariations:N}}function qe(){console.warn("Writing of gvar tables is not yet supported.")}var vt={make:qe,parse:Et};function wr(i,o){let u={},d=new at.Parser(i,o);u.version=d.parseUShort(),ee.argument(u.version<=1,"Unsupported gasp table version."),u.numRanges=d.parseUShort(),u.gaspRanges=[];for(let f=0;f<u.numRanges;f++)u.gaspRanges[f]={rangeMaxPPEM:d.parseUShort(),rangeGaspBehavior:d.parseUShort()};return u}function Yr(i){let o=new We.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:i.numRanges}]);for(let u in i.gaspRanges)o.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:i.gaspRanges[u].rangeMaxPPEM}),o.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:i.gaspRanges[u].rangeGaspBehavior});return o}var k={parse:wr,make:Yr};function D(i,o){let u=new Map,d=i.buffer,f=new be(i,o);if(f.parseUShort()!==0)return u;f.relativeOffset=f.parseOffset32();let m=i.byteOffset+o+f.relativeOffset,w=f.parseUShort(),T=new Map;for(let _=0;_<w;_++){let M=f.parseUShort(),N=f.parseUShort(),J=m+f.parseOffset32(),K=f.parseULong(),ve=T.get(J);ve===void 0&&(ve=new Uint8Array(d,J,K),T.set(J,ve));for(let pe=M;pe<=N;pe++)u.set(pe,ve)}return u}function F(i){let o=Array.from(i.keys()).sort(),u=[],d=[],f=new Map,m=0,w={endGlyphID:null};for(let K=0,ve=o.length;K<ve;K++){let pe=o[K],Se=i.get(pe),ht=f.get(Se);ht===void 0&&(ht=m,d.push(Se),f.set(Se,ht),m+=Se.byteLength),pe-1===w.endGlyphID&&ht===w.svgDocOffset?w.endGlyphID=pe:(w={startGlyphID:pe,endGlyphID:pe,svgDocOffset:ht,svgDocLength:Se.byteLength},u.push(w))}let T=u.length,_=d.length,M=2+T*12,N=new Array(4+T*4+_),J=0;N[J++]={name:"version",type:"USHORT",value:0},N[J++]={name:"svgDocumentListOffset",type:"ULONG",value:10},N[J++]={name:"reserved",type:"ULONG",value:0},N[J++]={name:"numEntries",type:"USHORT",value:T};for(let K=0;K<T;K++){let ve="documentRecord_"+K,{startGlyphID:pe,endGlyphID:Se,svgDocOffset:ht,svgDocLength:Tr}=u[K];N[J++]={name:ve+"_startGlyphID",type:"USHORT",value:pe},N[J++]={name:ve+"_endGlyphID",type:"USHORT",value:Se},N[J++]={name:ve+"_svgDocOffset",type:"ULONG",value:M+ht},N[J++]={name:ve+"_svgDocLength",type:"ULONG",value:Tr}}for(let K=0;K<_;K++)N[J++]={name:"svgDoc_"+K,type:"LITERAL",value:d[K]};return new We.Table("SVG ",N)}var H={make:F,parse:D};function He(i){return Math.log(i)/Math.log(2)|0}function Ie(i){for(;i.length%4!==0;)i.push(0);let o=0;for(let u=0;u<i.length;u+=4)o+=(i[u]<<24)+(i[u+1]<<16)+(i[u+2]<<8)+i[u+3];return o%=Math.pow(2,32),o}function ft(i,o,u,d){return new We.Record("Table Record",[{name:"tag",type:"TAG",value:i!==void 0?i:""},{name:"checkSum",type:"ULONG",value:o!==void 0?o:0},{name:"offset",type:"ULONG",value:u!==void 0?u:0},{name:"length",type:"ULONG",value:d!==void 0?d:0}])}function ut(i){let o=new We.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);o.tables=i,o.numTables=i.length;let u=Math.pow(2,He(o.numTables));o.searchRange=16*u,o.entrySelector=He(u),o.rangeShift=o.numTables*16-o.searchRange;let d=[],f=[],m=o.sizeOf()+ft().sizeOf()*o.numTables;for(;m%4!==0;)m+=1,f.push({name:"padding",type:"BYTE",value:0});for(let w=0;w<i.length;w+=1){let T=i[w];ee.argument(T.tableName.length===4,"Table name"+T.tableName+" is invalid.");let _=T.sizeOf(),M=ft(T.tableName,Ie(T.encode()),m,_);for(d.push({name:M.tag+" Table Record",type:"RECORD",value:M}),f.push({name:T.tableName+" table",type:"RECORD",value:T}),m+=_,ee.argument(!isNaN(m),"Something went wrong calculating the offset.");m%4!==0;)m+=1,f.push({name:"padding",type:"BYTE",value:0})}return d.sort(function(w,T){return w.value.tag>T.value.tag?1:-1}),o.fields=o.fields.concat(d),o.fields=o.fields.concat(f),o}function Yt(i,o,u){for(let d=0;d<o.length;d+=1){let f=i.charToGlyphIndex(o[d]);if(f>0)return i.glyphs.get(f).getMetrics()}return u}function Ar(i){let o=0;for(let u=0;u<i.length;u+=1)o+=i[u];return o/i.length}function ln(i){let o=[],u=[],d=[],f=[],m=[],w=[],T=[],_,M=0,N=0,J=0,K=0,ve=0;for(let es=0;es<i.glyphs.length;es+=1){let aa=i.glyphs.get(es),Ga=aa.unicode|0;if(isNaN(aa.advanceWidth))throw new Error("Glyph "+aa.name+" ("+es+"): advanceWidth is not a number.");(_>Ga||_===void 0)&&Ga>0&&(_=Ga),M<Ga&&(M=Ga);let So=Ei.getUnicodeRange(Ga);if(So<32)N|=1<<So;else if(So<64)J|=1<<So-32;else if(So<96)K|=1<<So-64;else if(So<123)ve|=1<<So-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(aa.name===".notdef")continue;let pl=aa.getMetrics();o.push(pl.xMin),u.push(pl.yMin),d.push(pl.xMax),f.push(pl.yMax),w.push(pl.leftSideBearing),T.push(pl.rightSideBearing),m.push(aa.advanceWidth)}let pe={xMin:Math.min.apply(null,o),yMin:Math.min.apply(null,u),xMax:Math.max.apply(null,d),yMax:Math.max.apply(null,f),advanceWidthMax:Math.max.apply(null,m),advanceWidthAvg:Ar(m),minLeftSideBearing:Math.min.apply(null,w),maxLeftSideBearing:Math.max.apply(null,w),minRightSideBearing:Math.min.apply(null,T)};pe.ascender=i.ascender,pe.descender=i.descender;let Se=0;i.weightClass>=600&&(Se|=i.macStyleValues.BOLD),i.italicAngle<0&&(Se|=i.macStyleValues.ITALIC);let ht=Ds.make({flags:3,unitsPerEm:i.unitsPerEm,xMin:pe.xMin,yMin:pe.yMin,xMax:pe.xMax,yMax:pe.yMax,lowestRecPPEM:3,macStyle:Se,createdTimestamp:i.createdTimestamp}),Tr=ss.make({ascender:pe.ascender,descender:pe.descender,advanceWidthMax:pe.advanceWidthMax,minLeftSideBearing:pe.minLeftSideBearing,minRightSideBearing:pe.minRightSideBearing,xMaxExtent:pe.maxLeftSideBearing+(pe.xMax-pe.xMin),numberOfHMetrics:i.glyphs.length}),pr=Ro.make(i.glyphs.length),Dr=Ei.make(Object.assign({xAvgCharWidth:Math.round(pe.advanceWidthAvg),usFirstCharIndex:_,usLastCharIndex:M,ulUnicodeRange1:N,ulUnicodeRange2:J,ulUnicodeRange3:K,ulUnicodeRange4:ve,sTypoAscender:pe.ascender,sTypoDescender:pe.descender,sTypoLineGap:0,usWinAscent:pe.yMax,usWinDescent:Math.abs(pe.yMin),ulCodePageRange1:1,sxHeight:Yt(i,"xyvw",{yMax:Math.round(pe.ascender/2)}).yMax,sCapHeight:Yt(i,"HIKLEFJMNTZBDPRAGOQSUVWXY",pe).yMax,usDefaultChar:i.hasChar(" ")?32:0,usBreakChar:i.hasChar(" ")?32:0},i.tables.os2)),sn=ja.make(i.glyphs),Pn=un.make(i.glyphs),Zn=i.getEnglishName("fontFamily"),Kn=i.getEnglishName("fontSubfamily"),Ps=Zn+" "+Kn,Ao=i.getEnglishName("postScriptName");Ao||(Ao=Zn.replace(/\s/g,"")+"-"+Kn);let an={};for(let es in i.names)an[es]=i.names[es];an.unicode=an.unicode||{},an.macintosh=an.macintosh||{},an.windows=an.windows||{};let Ca=i.names.unicode||{},Wi=i.names.macintosh||{},Sr=i.names.windows||{};for(let es in an){if(an[es]=an[es]||{},!an[es].uniqueID){let aa=i.getEnglishName("manufacturer")||"";an[es].uniqueID={en:`${aa}: ${Ps}`}}an[es].postScriptName||(an[es].postScriptName={en:Ao})}an.unicode.preferredFamily||(an.unicode.preferredFamily=Ca.fontFamily||Wi.fontFamily||Sr.fontFamily),an.macintosh.preferredFamily||(an.macintosh.preferredFamily=Wi.fontFamily||Ca.fontFamily||Sr.fontFamily),an.windows.preferredFamily||(an.windows.preferredFamily=Sr.fontFamily||Ca.fontFamily||Wi.fontFamily),an.unicode.preferredSubfamily||(an.unicode.preferredSubfamily=Ca.fontSubfamily||Wi.fontSubfamily||Sr.fontSubfamily),an.macintosh.preferredSubfamily||(an.macintosh.preferredSubfamily=Wi.fontSubfamily||Ca.fontSubfamily||Sr.fontSubfamily),an.windows.preferredSubfamily||(an.windows.preferredSubfamily=Sr.fontSubfamily||Ca.fontSubfamily||Wi.fontSubfamily);let cr=[],dr=hn.make(an,cr),ji=cr.length>0?ul.make(cr):void 0,Pl=Mo.make(i),Nd=$i.make(i.glyphs,{version:i.getEnglishName("version"),fullName:Ps,familyName:Zn,weightName:Kn,postScriptName:Ao,unitsPerEm:i.unitsPerEm,fontBBox:[0,pe.yMin,pe.ascender,pe.advanceWidthMax],topDict:i.tables.cff&&i.tables.cff.topDict||{}}),ac=i.metas&&Object.keys(i.metas).length>0?Do.make(i.metas):void 0,To=[ht,Tr,pr,Dr,dr,Pn,Pl,Nd,sn];ji&&To.push(ji);let Gi={gsub:qn,cpal:ct,colr:zi,stat:wa,avar:Pa,cvar:Tt,fvar:bi,gvar:vt,gasp:k,svg:H},Wa={avar:[i.tables.fvar],fvar:[i.names]};for(let es in Gi){let aa=i.tables[es];if(aa){let Ga=Gi[es].make.call(i,aa,...Wa[es]||[]);Ga&&To.push(Ga)}}ac&&To.push(ac);let Bi=ut(To),_a=Bi.encode(),Vi=Ie(_a),qi=Bi.fields,Rs=!1;for(let es=0;es<qi.length;es+=1)if(qi[es].name==="head table"){qi[es].value.checkSumAdjustment=2981146554-Vi,Rs=!0;break}if(!Rs)throw new Error("Could not find head table with checkSum to adjust.");return Bi}var Qn={make:ut,fontToTable:ln,computeCheckSum:Ie};function In(i,o){let u=0,d=i.length-1;for(;u<=d;){let f=u+d>>>1,m=i[f].tag;if(m===o)return f;m<o?u=f+1:d=f-1}return-u-1}function is(i,o){let u=0,d=i.length-1;for(;u<=d;){let f=u+d>>>1,m=i[f];if(m===o)return f;m<o?u=f+1:d=f-1}return-u-1}function Br(i,o){let u,d=0,f=i.length-1;for(;d<=f;){let m=d+f>>>1;u=i[m];let w=u.start;if(w===o)return u;w<o?d=m+1:f=m-1}if(d>0)return u=i[d-1],o>u.end?0:u}function xn(i,o){this.font=i,this.tableName=o}xn.prototype={searchTag:In,binSearch:is,getTable:function(i){let o=this.font.tables[this.tableName];return!o&&i&&(o=this.font.tables[this.tableName]=this.createDefaultTable()),o},getScriptNames:function(){let i=this.getTable();return i?i.scripts.map(function(o){return o.tag}):[]},getDefaultScriptName:function(){let i=this.getTable();if(!i)return;let o=!1;for(let u=0;u<i.scripts.length;u++){let d=i.scripts[u].tag;if(d==="DFLT")return d;d==="latn"&&(o=!0)}if(o)return"latn"},getScriptTable:function(i,o){let u=this.getTable(o);if(u){i=i||"DFLT";let d=u.scripts,f=In(u.scripts,i);if(f>=0)return d[f].script;if(o){let m={tag:i,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return d.splice(-1-f,0,m),m.script}}},getLangSysTable:function(i,o,u){let d=this.getScriptTable(i,u);if(d){if(!o||o==="dflt"||o==="DFLT")return d.defaultLangSys;let f=In(d.langSysRecords,o);if(f>=0)return d.langSysRecords[f].langSys;if(u){let m={tag:o,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return d.langSysRecords.splice(-1-f,0,m),m.langSys}}},getFeatureTable:function(i,o,u,d){let f=this.getLangSysTable(i,o,d);if(f){let m,w=f.featureIndexes,T=this.font.tables[this.tableName].features;for(let _=0;_<w.length;_++)if(m=T[w[_]],m.tag===u)return m.feature;if(d){let _=T.length;return ee.assert(_===0||u>=T[_-1].tag,"Features must be added in alphabetical order."),m={tag:u,feature:{params:0,lookupListIndexes:[]}},T.push(m),w.push(_),m.feature}}},getLookupTables:function(i,o,u,d,f){let m=this.getFeatureTable(i,o,u,f),w=[];if(m){let T,_=m.lookupListIndexes,M=this.font.tables[this.tableName].lookups;for(let N=0;N<_.length;N++)T=M[_[N]],T.lookupType===d&&w.push(T);if(w.length===0&&f){T={lookupType:d,lookupFlag:0,subtables:[],markFilteringSet:void 0};let N=M.length;return M.push(T),_.push(N),[T]}}return w},getGlyphClass:function(i,o){switch(i.format){case 1:return i.startGlyph<=o&&o<i.startGlyph+i.classes.length?i.classes[o-i.startGlyph]:0;case 2:{let u=Br(i.ranges,o);return u?u.classId:0}}},getCoverageIndex:function(i,o){switch(i.format){case 1:{let u=is(i.glyphs,o);return u>=0?u:-1}case 2:{let u=Br(i.ranges,o);return u?u.index+o-u.start:-1}}},expandCoverage:function(i){if(i.format===1)return i.glyphs;{let o=[],u=i.ranges;for(let d=0;d<u.length;d++){let f=u[d],m=f.start,w=f.end;for(let T=m;T<=w;T++)o.push(T)}return o}}};var ls=xn;function as(i){ls.call(this,i,"gpos")}as.prototype=ls.prototype,as.prototype.init=function(){let i=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(i)},as.prototype.getKerningValue=function(i,o,u){for(let d=0;d<i.length;d++){let f=i[d].subtables;for(let m=0;m<f.length;m++){let w=f[m],T=this.getCoverageIndex(w.coverage,o);if(!(T<0))switch(w.posFormat){case 1:{let _=w.pairSets[T];for(let M=0;M<_.length;M++){let N=_[M];if(N.secondGlyph===u)return N.value1&&N.value1.xAdvance||0}break}case 2:{let _=this.getGlyphClass(w.classDef1,o),M=this.getGlyphClass(w.classDef2,u),N=w.classRecords[_][M];return N.value1&&N.value1.xAdvance||0}}}}return 0},as.prototype.getKerningTables=function(i,o){if(this.font.tables.gpos)return this.getLookupTables(i,o,"kern",2)};var E0=as;function Jn(i,o){let u=i.length;if(u!==o.length)return!1;for(let d=0;d<u;d++)if(i[d]!==o[d])return!1;return!0}function Oa(i,o,u){let d=0,f=i.length-1,m=null;for(;d<=f;){let w=Math.floor((d+f)/2),T=i[w],_=T[o];if(_<u)d=w+1;else if(_>u)f=w-1;else{m=T;break}}return m}function yo(i,o,u){let d=0,f=i.length-1;for(;d<=f;){let m=Math.floor((d+f)/2),w=i[m];if(w[o]<u)d=m+1;else if(w[o]>u)f=m-1;else return m}return-1}function Hs(i,o,u){let d=0,f=i.length,m=(w,T)=>w[o]-T[o];for(;d<f;){let w=d+f>>>1;m(i[w],u)<0?d=w+1:f=w}return i.splice(d,0,u),d}function tc(i){return i[0]===31&&i[1]===139&&i[2]===8}function Nl(i){let o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=10,d=i.byteLength-8,f=o.getInt8(3);if(f&4&&(u+=2+o.getUint16(u,!0)),f&8)for(;u<d&&i[u++]!==0;);if(f&16)for(;u<d&&i[u++]!==0;);if(f&2&&(u+=2),u>=d)throw new Error("Can't find compressed blocks");let m=o.getUint32(o.byteLength-4,!0);return ce(i.subarray(u,d),new Uint8Array(m))}function rc(i){return{x:i.x,y:i.y,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour}}function Fa(i){return{glyphIndex:i.glyphIndex,xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:i.dx,dy:i.dy}}function cs(i){ls.call(this,i,"gsub")}function Po(i,o,u){let d=i.subtables;for(let f=0;f<d.length;f++){let m=d[f];if(m.substFormat===o)return m}if(u)return d.push(u),u}cs.prototype=ls.prototype,cs.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},cs.prototype.getSingle=function(i,o,u){let d=[],f=this.getLookupTables(o,u,i,1);for(let m=0;m<f.length;m++){let w=f[m].subtables;for(let T=0;T<w.length;T++){let _=w[T],M=this.expandCoverage(_.coverage),N;if(_.substFormat===1){let J=_.deltaGlyphId;for(N=0;N<M.length;N++){let K=M[N];d.push({sub:K,by:K+J})}}else{let J=_.substitute;for(N=0;N<M.length;N++)d.push({sub:M[N],by:J[N]})}}}return d},cs.prototype.getMultiple=function(i,o,u){let d=[],f=this.getLookupTables(o,u,i,2);for(let m=0;m<f.length;m++){let w=f[m].subtables;for(let T=0;T<w.length;T++){let _=w[T],M=this.expandCoverage(_.coverage),N;for(N=0;N<M.length;N++){let J=M[N],K=_.sequences[N];d.push({sub:J,by:K})}}}return d},cs.prototype.getAlternates=function(i,o,u){let d=[],f=this.getLookupTables(o,u,i,3);for(let m=0;m<f.length;m++){let w=f[m].subtables;for(let T=0;T<w.length;T++){let _=w[T],M=this.expandCoverage(_.coverage),N=_.alternateSets;for(let J=0;J<M.length;J++)d.push({sub:M[J],by:N[J]})}}return d},cs.prototype.getLigatures=function(i,o,u){let d=[],f=this.getLookupTables(o,u,i,4);for(let m=0;m<f.length;m++){let w=f[m].subtables;for(let T=0;T<w.length;T++){let _=w[T],M=this.expandCoverage(_.coverage),N=_.ligatureSets;for(let J=0;J<M.length;J++){let K=M[J],ve=N[J];for(let pe=0;pe<ve.length;pe++){let Se=ve[pe];d.push({sub:[K].concat(Se.components),by:Se.ligGlyph})}}}}return d},cs.prototype.addSingle=function(i,o,u,d){let f=this.getLookupTables(u,d,i,1,!0)[0],m=Po(f,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});ee.assert(m.coverage.format===1,"Single: unable to modify coverage table format "+m.coverage.format);let w=o.sub,T=this.binSearch(m.coverage.glyphs,w);T<0&&(T=-1-T,m.coverage.glyphs.splice(T,0,w),m.substitute.splice(T,0,0)),m.substitute[T]=o.by},cs.prototype.addMultiple=function(i,o,u,d){ee.assert(o.by instanceof Array&&o.by.length>1,'Multiple: "by" must be an array of two or more ids');let f=this.getLookupTables(u,d,i,2,!0)[0],m=Po(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ee.assert(m.coverage.format===1,"Multiple: unable to modify coverage table format "+m.coverage.format);let w=o.sub,T=this.binSearch(m.coverage.glyphs,w);T<0&&(T=-1-T,m.coverage.glyphs.splice(T,0,w),m.sequences.splice(T,0,0)),m.sequences[T]=o.by},cs.prototype.addAlternate=function(i,o,u,d){let f=this.getLookupTables(u,d,i,3,!0)[0],m=Po(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ee.assert(m.coverage.format===1,"Alternate: unable to modify coverage table format "+m.coverage.format);let w=o.sub,T=this.binSearch(m.coverage.glyphs,w);T<0&&(T=-1-T,m.coverage.glyphs.splice(T,0,w),m.alternateSets.splice(T,0,0)),m.alternateSets[T]=o.by},cs.prototype.addLigature=function(i,o,u,d){let f=this.getLookupTables(u,d,i,4,!0)[0],m=f.subtables[0];m||(m={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},f.subtables[0]=m),ee.assert(m.coverage.format===1,"Ligature: unable to modify coverage table format "+m.coverage.format);let w=o.sub[0],T=o.sub.slice(1),_={ligGlyph:o.by,components:T},M=this.binSearch(m.coverage.glyphs,w);if(M>=0){let N=m.ligatureSets[M];for(let J=0;J<N.length;J++)if(Jn(N[J].components,T))return;N.push(_)}else M=-1-M,m.coverage.glyphs.splice(M,0,w),m.ligatureSets.splice(M,0,[_])},cs.prototype.getFeature=function(i,o,u){if(/ss\d\d/.test(i))return this.getSingle(i,o,u);switch(i){case"aalt":case"salt":return this.getSingle(i,o,u).concat(this.getAlternates(i,o,u));case"dlig":case"liga":case"rlig":return this.getLigatures(i,o,u);case"ccmp":return this.getMultiple(i,o,u).concat(this.getLigatures(i,o,u));case"stch":return this.getMultiple(i,o,u)}},cs.prototype.add=function(i,o,u,d){if(/ss\d\d/.test(i))return this.addSingle(i,o,u,d);switch(i){case"aalt":case"salt":return typeof o.by=="number"?this.addSingle(i,o,u,d):this.addAlternate(i,o,u,d);case"dlig":case"liga":case"rlig":return this.addLigature(i,o,u,d);case"ccmp":return o.by instanceof Array?this.addMultiple(i,o,u,d):this.addLigature(i,o,u,d)}};var Bc=cs,md=class{constructor(i){this.defaultValue=255,this.font=i}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(i){let o=[],u=this.cpal();if(!u)return o;for(let d=0;d<u.colorRecordIndices.length;d++){let f=u.colorRecordIndices[d],m=[];for(let w=f;w<f+u.numPaletteEntries;w++)m.push(Ye(u.colorRecords[w],i||"hexa"));o.push(m)}return o}toCPALcolor(i){return Array.isArray(i)?i.map(o=>ge(o,"raw")):ge(i,"raw")}fillPalette(i,o=[],u=this.cpal().numPaletteEntries){return i=Number.isInteger(i)?this.get(i,"raw"):i,Object.assign(Array(u).fill(this.defaultValue),this.toCPALcolor(i).concat(this.toCPALcolor(o)))}extend(i){if(this.ensureCPAL(Array(i).fill(this.defaultValue)))return;let o=this.cpal(),u=o.numPaletteEntries+i,d=this.getAll().map(f=>this.fillPalette(f,[],u));o.numPaletteEntries=u,o.colorRecords=this.toCPALcolor(d.flat()),this.updateIndices()}get(i,o="hexa"){return this.getAll(o)[i]||null}getColor(i,o=0,u="hexa"){return Gn(this.font,i,o,u)}setColor(i,o,u=0){i=parseInt(i),u=parseInt(u);let d=this.getAll("raw"),f=d[u];if(!f)throw Error(`paletteIndex ${u} out of range`);let m=this.cpal(),w=m.numPaletteEntries;Array.isArray(o)||(o=[o]),o.length+i>w&&(this.extend(o.length+i-w),d=this.getAll("raw"),f=d[u]);for(let T=0;T<o.length;T++)f[T+i]=this.toCPALcolor(o[T]);m.colorRecords=d.flat(),this.updateIndices()}add(i){if(this.ensureCPAL(i))return;let o=this.cpal(),u=o.numPaletteEntries;i&&i.length?(i=this.toCPALcolor(i),i.length>u?this.extend(i.length-u):i.length<u&&(i=this.fillPalette(i)),o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...i)):(o.colorRecordIndices.push(o.colorRecords.length),o.colorRecords.push(...Array(u).fill(this.defaultValue)))}delete(i){let o=this.getAll("raw");delete o[i];let u=this.cpal();u.colorRecordIndices.pop(),u.colorRecords=o.flat()}deleteColor(i,o){if(i===o)throw Error("replacementIndex cannot be the same as colorIndex");let u=this.cpal(),d=this.getAll("raw"),f=[];if(o>u.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${u.numPaletteEntries-1}, replacementIndex: ${o})`);for(let T=0;T<d.length;T++){let _=d[T].filter((M,N)=>N!==i);f.push(_)}let m=this.font.tables.colr;if(m){let T=m.layerRecords;for(let _=0;_<T.length;_++){let M=T[_].paletteIndex;if(M>i)T[_].paletteIndex-=1;else if(M===i){let N=0;for(let J=0;J<d.length;J++)if(o>i&&o<=i+d[J].length){N++;break}T[_].paletteIndex=o-N}}this.font.tables.colr={...m,layerRecords:T}}let w=f.flat();for(let T=0;T<d.length;T++)u.colorRecordIndices[T]-=T;u.numPaletteEntries=Math.max(0,u.numPaletteEntries-1),u.colorRecords=this.toCPALcolor(w)}ensureCPAL(i){return this.cpal()?!1:(!i||!i.length?i=[this.defaultValue]:i=this.toCPALcolor(i),this.font.tables.cpal={version:0,numPaletteEntries:i.length,colorRecords:i,colorRecordIndices:[0]},!0)}updateIndices(){let i=this.cpal(),o=Math.ceil(i.colorRecords.length/i.numPaletteEntries);i.colorRecordIndices=[];for(let u=0;u<o;u++)i.colorRecordIndices.push(u*i.numPaletteEntries)}},Ef=class{constructor(i){this.font=i}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(i){let o=this.font,u=[],d=o.tables.colr,f=o.tables.cpal;if(!d||!f)return u;let m=Oa(d.baseGlyphRecords,"glyphID",i);if(!m)return u;let w=m.firstLayerIndex,T=m.numLayers;for(let _=0;_<T;_++){let M=d.layerRecords[w+_];u.push({glyph:o.glyphs.get(M.glyphID),paletteIndex:M.paletteIndex})}return u}add(i,o,u){let d=this.get(i);o=Array.isArray(o)?o:[o],u===void 0||u===1/0||u>d.length?u=d.length:u<0&&(u=d.length+1+u%(d.length+1),u>=d.length+1&&(u-=d.length+1));let f=[];for(let m=0;m<u;m++){let w=Number.isInteger(d[m].glyph)?d[m].glyph:d[m].glyph.index;f.push({glyphID:w,paletteIndex:d[m].paletteIndex})}for(let m of o){let w=Number.isInteger(m.glyph)?m.glyph:m.glyph.index;f.push({glyphID:w,paletteIndex:m.paletteIndex})}for(let m=u;m<d.length;m++){let w=Number.isInteger(d[m].glyph)?d[m].glyph:d[m].glyph.index;f.push({glyphID:w,paletteIndex:d[m].paletteIndex})}this.updateColrTable(i,f)}setPaletteIndex(i,o,u){let d=this.get(i);d[o]?(d=d.map((f,m)=>({glyphID:f.glyph.index,paletteIndex:m===o?u:f.paletteIndex})),this.updateColrTable(i,d)):console.error("Invalid layer index")}remove(i,o,u=o){let d=this.get(i);d=d.map(f=>({glyphID:f.glyph.index,paletteIndex:f.paletteIndex})),d.splice(o,u-o+1),this.updateColrTable(i,d)}updateColrTable(i,o){this.ensureCOLR();let u=this.font.tables.colr,d=yo(u.baseGlyphRecords,"glyphID",i);if(d===-1){let _={glyphID:i,firstLayerIndex:u.layerRecords.length,numLayers:0};d=Hs(u.baseGlyphRecords,"glyphID",_)}let f=u.baseGlyphRecords[d],m=f.numLayers,w=o.length,T=w-m;if(T>0){let _=o.slice(m).map(M=>({glyphID:M.glyphID,paletteIndex:M.paletteIndex}));u.layerRecords.splice(f.firstLayerIndex+m,0,..._)}else T<0&&u.layerRecords.splice(f.firstLayerIndex+w,-T);for(let _=0;_<Math.min(m,w);_++)u.layerRecords[f.firstLayerIndex+_]={glyphID:o[_].glyphID,paletteIndex:o[_].paletteIndex};if(f.numLayers=w,T!==0)for(let _=0;_<u.baseGlyphRecords.length;_++){let M=u.baseGlyphRecords[_];_===d||M.firstLayerIndex<f.firstLayerIndex||(u.baseGlyphRecords[_].firstLayerIndex+=T)}}},Nf=class{constructor(i){this.font=i,this.cache=new WeakMap}get(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.image}getAsync(i){let o=this.getOrCreateSvgImageCacheEntry(i);return o&&o.promise}getOrCreateSvgImageCacheEntry(i){let o=this.font.tables.svg;if(o===void 0)return;let u=o.get(i);if(u===void 0)return;let d=this.cache.get(u);d===void 0&&(d=Rf(u),this.cache.set(u,d));let f=d.images.get(i);return f===void 0&&(f=vo(this.font,d.template,i),f.promise.then(m=>{if(f.image=m,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(i)}catch(w){console.error("font.onGlyphUpdated",i,w)}}),d.images.set(i,f)),f}};function Rf(i){return{template:hl(i).then(gd),images:new Map}}function vo(i,o,u){return{promise:o.then(d=>{let f;typeof d=="string"?f=d:(d[4]=u,f=d.join(""));let m=xd(f,i.unitsPerEm);return m.image.decode().then(()=>m)}),image:void 0}}var hl=typeof DecompressionStream=="function"?nc:Mf;function Mf(i){try{return Promise.resolve(new TextDecoder().decode(tc(i)?Nl(i):i))}catch(o){return Promise.reject(o)}}function nc(i){if(tc(i))return new Response(new Response(i).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(i))}catch(o){return Promise.reject(o)}}function gd(i){let o=i.indexOf("<svg"),u=i.indexOf(">",o+4)+1;if(/ id=['"]glyph\d+['"]/.test(i.substring(o,u)))return i;let d=i.lastIndexOf("</svg>");return[i.substring(0,u),"<defs>",i.substring(u,d),'</defs><use href="#glyph',"",'"/>',i.substring(d)]}function xd(i,o){let u=new DOMParser().parseFromString(i,"image/svg+xml").documentElement,d=u.viewBox.baseVal,f=u.width.baseVal,m=u.height.baseVal,w=1,T=1;d.width>0&&d.height>0&&(f.unitType===1?(w=f.valueInSpecifiedUnits/d.width,T=m.unitType===1?m.valueInSpecifiedUnits/d.height:w):m.unitType===1?(T=m.valueInSpecifiedUnits/d.height,w=T):o&&(w=o/d.width,T=o/d.height));let _=document.createElement("div");_.style.position="fixed",_.style.visibility="hidden",_.appendChild(u),document.body.appendChild(_);let M=u.getBBox();document.body.removeChild(_);let N=(M.x-d.x)*w,J=(d.y-M.y)*T,K=M.width*w,ve=M.height*T;u.setAttribute("viewBox",[M.x,M.y,M.width,M.height].join(" ")),w!==1&&u.setAttribute("width",K),T!==1&&u.setAttribute("height",ve);let pe=new Image(K,ve);return pe.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(u.outerHTML),{leftSideBearing:N,baseline:J,image:pe}}var Qc=new WeakMap;function N0(i,o,u,d,f){let m;return(o&d)>0?(m=i.parseByte(),(o&f)===0&&(m=-m),m=u+m):(o&f)>0?m=u:m=u+i.parseShort(),m}function R0(i,o,u){let d=new at.Parser(o,u);i._numberOfContours=d.parseShort(),i._xMin=d.parseShort(),i._yMin=d.parseShort(),i._xMax=d.parseShort(),i._yMax=d.parseShort();let f,m;if(i._numberOfContours>0){let w=i.endPointIndices=[];for(let _=0;_<i._numberOfContours;_+=1)w.push(d.parseUShort());i.instructionLength=d.parseUShort(),i.instructions=[];for(let _=0;_<i.instructionLength;_+=1)i.instructions.push(d.parseByte());let T=w[w.length-1]+1;f=[];for(let _=0;_<T;_+=1)if(m=d.parseByte(),f.push(m),(m&8)>0){let M=d.parseByte();for(let N=0;N<M;N+=1)f.push(m),_+=1}if(ee.argument(f.length===T,"Bad flags."),w.length>0){let _=[],M;if(T>0){for(let K=0;K<T;K+=1)m=f[K],M={},M.onCurve=!!(m&1),M.lastPointOfContour=w.indexOf(K)>=0,_.push(M);let N=0;for(let K=0;K<T;K+=1)m=f[K],M=_[K],M.x=N0(d,m,N,2,16),N=M.x;let J=0;for(let K=0;K<T;K+=1)m=f[K],M=_[K],M.y=N0(d,m,J,4,32),J=M.y}i.points=_}else i.points=[]}else if(i._numberOfContours===0)i.points=[];else{i.isComposite=!0,i.points=[],i.components=[];let w=!0;for(;w;){f=d.parseUShort();let T={glyphIndex:d.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(f&1)>0?(f&2)>0?(T.dx=d.parseShort(),T.dy=d.parseShort()):T.matchedPoints=[d.parseUShort(),d.parseUShort()]:(f&2)>0?(T.dx=d.parseChar(),T.dy=d.parseChar()):T.matchedPoints=[d.parseByte(),d.parseByte()],(f&8)>0?T.xScale=T.yScale=d.parseF2Dot14():(f&64)>0?(T.xScale=d.parseF2Dot14(),T.yScale=d.parseF2Dot14()):(f&128)>0&&(T.xScale=d.parseF2Dot14(),T.scale01=d.parseF2Dot14(),T.scale10=d.parseF2Dot14(),T.yScale=d.parseF2Dot14()),i.components.push(T),w=!!(f&32)}if(f&256){i.instructionLength=d.parseUShort(),i.instructions=[];for(let T=0;T<i.instructionLength;T+=1)i.instructions.push(d.parseByte())}}}function Oo(i,o){let u=[];for(let d=0;d<i.length;d+=1){let f=i[d],m={x:o.xScale*f.x+o.scale10*f.y+o.dx,y:o.scale01*f.x+o.yScale*f.y+o.dy,onCurve:f.onCurve,lastPointOfContour:f.lastPointOfContour};u.push(m)}return u}function $a(i){let o=[],u=[];for(let d=0;d<i.length;d+=1){let f=i[d];u.push(f),f.lastPointOfContour&&(o.push(u),u=[])}return ee.argument(u.length===0,"There are still points left in the current contour."),o}function sc(i){let o=new Fe;if(!i)return o;let u=$a(i);for(let d=0;d<u.length;++d){let f=u[d],m=f[f.length-1],w=f[0];if(m.onCurve)o.moveTo(m.x,m.y);else if(w.onCurve)o.moveTo(w.x,w.y);else{let T={x:(m.x+w.x)*.5,y:(m.y+w.y)*.5};o.moveTo(T.x,T.y)}for(let T=0;T<f.length;++T)if(m=w,w=f[(T+1)%f.length],m.onCurve)o.lineTo(m.x,m.y);else{let _=w;w.onCurve||(_={x:(m.x+w.x)*.5,y:(m.y+w.y)*.5}),o.quadraticCurveTo(m.x,m.y,_.x,_.y)}o.closePath()}return o}function bd(i,o){if(o.isComposite){Qc.has(i)||Qc.set(i,new Set);let u=Qc.get(i);u.add(o.index);try{for(let d=0;d<o.components.length;d+=1){let f=o.components[d];if(u.has(f.glyphIndex))continue;let m=i.get(f.glyphIndex);if(m.getPath(),m.points){let w;if(f.matchedPoints===void 0)w=Oo(m.points,f);else{if(f.matchedPoints[0]>o.points.length-1||f.matchedPoints[1]>m.points.length-1)throw Error("Matched points out of range in "+o.name);let T=o.points[f.matchedPoints[0]],_=m.points[f.matchedPoints[1]],M={xScale:f.xScale,scale01:f.scale01,scale10:f.scale10,yScale:f.yScale,dx:0,dy:0};_=Oo([_],M)[0],M.dx=T.x-_.x,M.dy=T.y-_.y,w=Oo(m.points,M)}o.points=o.points.concat(w)}}}finally{u.delete(o.index)}}return sc(o.points)}function yd(i,o,u,d){let f=new $t.GlyphSet(d);for(let m=0;m<u.length-1;m+=1){let w=u[m],T=u[m+1];w!==T?f.push(m,$t.ttfGlyphLoader(d,m,R0,i,o+w,bd)):f.push(m,$t.glyphLoader(d,m))}return f}function M0(i,o,u,d){let f=new $t.GlyphSet(d);return d._push=function(m){let w=u[m],T=u[m+1];w!==T?f.push(m,$t.ttfGlyphLoader(d,m,R0,i,o+w,bd)):f.push(m,$t.glyphLoader(d,m))},f}function D0(i,o,u,d,f){return f.lowMemory?M0(i,o,u,d):yd(i,o,u,d)}var vd={getPath:sc,parse:D0},wd=class{constructor(i){this.font=i}normalizeCoordTags(i){for(let o in i)if(o.length<4){let u=o.padEnd(4," ");i[u]===void 0&&(i[u]=i[o]),delete i[o]}}getNormalizedCoords(i){i||(i=this.font.variation.get());let o=[];this.normalizeCoordTags(i);for(let u=0;u<this.fvar().axes.length;u++){let d=this.fvar().axes[u],f=i[d.tag];f===void 0&&(f=d.defaultValue),f<d.defaultValue?o.push((f-d.defaultValue+Number.EPSILON)/(d.defaultValue-d.minValue+Number.EPSILON)):o.push((f-d.defaultValue+Number.EPSILON)/(d.maxValue-d.defaultValue+Number.EPSILON))}if(this.avar())for(let u=0;u<this.avar().axisSegmentMaps.length;u++){let d=this.avar().axisSegmentMaps[u];for(let f=0;f<d.axisValueMaps.length;f++){let m=d.axisValueMaps[f];if(f>=1&&o[u]<m.fromCoordinate){let w=d.axisValueMaps[f-1];o[u]=((o[u]-w.fromCoordinate)*(m.toCoordinate-w.toCoordinate)+Number.EPSILON)/(m.fromCoordinate-w.fromCoordinate+Number.EPSILON)+w.toCoordinate;break}}}return o}interpolatePoints(i,o,u){if(i.length===0)return;let d=0;for(;d<i.length;){let f=d,m=d,w=i[m];for(;!w.lastPointOfContour;)w=i[++m];for(;d<=m&&!u[d];)d++;if(d>m)continue;let T=d,_=d;for(d++;d<=m;)u[d]&&(this.deltaInterpolate(_+1,d-1,_,d,o,i),_=d),d++;_===T?this.deltaShift(f,m,_,o,i):(this.deltaInterpolate(_+1,m,_,T,o,i),T>0&&this.deltaInterpolate(f,T-1,_,T,o,i)),d=m+1}}deltaInterpolate(i,o,u,d,f,m){if(i>o)return;let w=["x","y"];for(let _=0;_<w.length;_++){let M=w[_];if(f[u][M]>f[d][M]){var T=u;u=d,d=T}let N=f[u][M],J=f[d][M],K=m[u][M],ve=m[d][M];if(N!==J||K===ve){let pe=N===J?0:(ve-K)/(J-N);for(let Se=i;Se<=o;Se++){let ht=f[Se][M];ht<=N?ht+=K-N:ht>=J?ht+=ve-J:ht=K+(ht-N)*pe,m[Se][M]=ht}}}}deltaShift(i,o,u,d,f){let m=f[u].x-d[u].x,w=f[u].y-d[u].y;if(!(m===0&&w===0))for(let T=i;T<=o;T++)T!==u&&(f[T].x+=m,f[T].y+=w)}transformComponents(i,o,u,d,f,m){let w=0;for(let T=0;T<i.components.length;T++){let _=i.components[T],M=this.font.glyphs.get(_.glyphIndex),N=Fa(_),J=d.indexOf(T);J>-1&&(N.dx+=Math.round(f.deltas[J]*m),N.dy+=Math.round(f.deltasY[J]*m));let K=Oo(this.getTransform(M,u).points,N);o.splice(w,K.length,...K),w+=M.points.length}}applyTupleVariationStore(i,o,u,d="gvar",f={}){u||(u=this.font.variation.get());let m=this.getNormalizedCoords(u),{headers:w,sharedPoints:T}=i,_=this.fvar().axes.length,M;d==="gvar"?M=o.map(rc):d==="cvar"&&(M=[...o]);for(let N=0;N<w.length;N++){let J=w[N],K=1;for(let pe=0;pe<_;pe++){let Se=[0];switch(d){case"gvar":Se=J.peakTuple?J.peakTuple:this.gvar().sharedTuples[J.sharedTupleRecordsIndex];break;case"cvar":Se=J.peakTuple;break}if(Se[pe]!==0){if(m[pe]===0){K=0;break}if(J.intermediateStartTuple)if(m[pe]<J.intermediateStartTuple[pe]||m[pe]>J.intermediateEndTuple[pe]){K=0;break}else m[pe]<Se[pe]?K=K*(m[pe]-J.intermediateStartTuple[pe]+Number.EPSILON)/(Se[pe]-J.intermediateStartTuple[pe]+Number.EPSILON):K=K*(J.intermediateEndTuple[pe]-m[pe]+Number.EPSILON)/(J.intermediateEndTuple[pe]-Se[pe]+Number.EPSILON);else{if(m[pe]<Math.min(0,Se[pe])||m[pe]>Math.max(0,Se[pe])){K=0;break}K=(K*m[pe]+Number.EPSILON)/(Se[pe]+Number.EPSILON)}}}if(K===0)continue;let ve=J.privatePoints.length?J.privatePoints:T;if(d==="gvar"&&f.glyph&&f.glyph.isComposite)this.transformComponents(f.glyph,M,u,ve,J,K);else if(ve.length===0)for(let pe=0;pe<M.length;pe++){let Se=M[pe];d==="gvar"?M[pe]={x:Math.round(Se.x+J.deltas[pe]*K),y:Math.round(Se.y+J.deltasY[pe]*K),onCurve:Se.onCurve,lastPointOfContour:Se.lastPointOfContour}:d==="cvar"&&(M[pe]=Math.round(Se+J.deltas[pe]*K))}else{let pe;d==="gvar"?pe=M.map(rc):d==="cvar"&&(pe=M);let Se=Array(o.length).fill(!1);for(let ht=0;ht<ve.length;ht++){let Tr=ve[ht];if(Tr<o.length){let pr=pe[Tr];d==="gvar"?(Se[Tr]=!0,pr.x+=J.deltas[ht]*K,pr.y+=J.deltasY[ht]*K):d==="cvar"&&(M[Tr]=Math.round(pr+J.deltas[ht]*K))}}if(d==="gvar"){this.interpolatePoints(pe,M,Se);for(let ht=0;ht<o.length;ht++){let Tr=pe[ht].x-M[ht].x,pr=pe[ht].y-M[ht].y;M[ht].x=Math.round(M[ht].x+Tr),M[ht].y=Math.round(M[ht].y+pr)}}}}return M}getTransform(i,o){Number.isInteger(i)&&(i=this.font.glyphs.get(i));let u=i.getBlendPath,d=!!(i.points&&i.points.length),f=i;if(u||d){if(o||(o=this.font.variation.get()),d){let m=this.gvar()&&this.gvar().glyphVariations[i.index];if(m){let w=i.points,T=this.applyTupleVariationStore(m,w,o,"gvar",{glyph:i});f=new Ot(Object.assign({},i,{points:T,path:sc(T)}))}}else if(u){let m=i.getBlendPath(o);f=new Ot(Object.assign({},i,{path:m}))}}return this.font.tables.hvar&&(i._advanceWidth=typeof i._advanceWidth<"u"?i._advanceWidth:i.advanceWidth,i.advanceWidth=f.advanceWidth=Math.round(i._advanceWidth+this.getVariableAdjustment(f.index,"hvar","advanceWidth",o)),i._leftSideBearing=typeof i._leftSideBearing<"u"?i._leftSideBearing:i.leftSideBearing,i.leftSideBearing=f.leftSideBearing=Math.round(i._leftSideBearing+this.getVariableAdjustment(f.index,"hvar","lsb",o))),f}getCvarTransform(i){let o=this.font.tables.cvt,u=this.cvar();return!o||!o.length||!u||!u.headers.length?o:this.applyTupleVariationStore(u,o,i,"cvar")}getVariableAdjustment(i,o,u,d){d=d||this.font.variation.get();let f,m,w=this.font.tables[o];if(!w)throw Error(`trying to get variation adjustment from non-existent table "${w}"`);if(!w.itemVariationStore)throw Error(`trying to get variation adjustment from table "${w}" which does not have an itemVariationStore`);let T=w[u]&&w[u].map.length;if(T){let _=i;_>=T&&(_=T-1),{outerIndex:f,innerIndex:m}=w[u].map[_]}else f=0,m=i;return this.getDelta(w.itemVariationStore,f,m,d)}getDelta(i,o,u,d){if(o>=i.itemVariationSubtables.length)return 0;let f=i.itemVariationSubtables[o];if(u>=f.deltaSets.length)return 0;let m=f.deltaSets[u],w=this.getBlendVector(i,o,d),T=0;for(let _=0;_<f.regionIndexes.length;_++)T+=m[_]*w[_];return T}getBlendVector(i,o,u){u||(u=this.font.variation.get());let d=i.itemVariationSubtables[o],f=this.getNormalizedCoords(u),m=[];for(let w=0;w<d.regionIndexes.length;w++){let T=1,_=d.regionIndexes[w],M=i.variationRegions[_].regionAxes;for(let N=0;N<M.length;N++){let J=M[N],K;J.startCoord>J.peakCoord||J.peakCoord>J.endCoord||J.startCoord<0&&J.endCoord>0&&J.peakCoord!==0||J.peakCoord===0?K=1:f[N]<J.startCoord||f[N]>J.endCoord?K=0:f[N]===J.peakCoord?K=1:f[N]<J.peakCoord?K=(f[N]-J.startCoord+Number.EPSILON)/(J.peakCoord-J.startCoord+Number.EPSILON):K=(J.endCoord-f[N]+Number.EPSILON)/(J.endCoord-J.peakCoord+Number.EPSILON),T*=K}m[w]=T}return m}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},j0=class{constructor(i){this.font=i,this.process=new wd(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let i=this.getDefaultInstanceIndex();i>-1?this.set(i):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((i,o)=>(i[o.tag]=o.defaultValue,i),{})}getDefaultInstanceIndex(){let i=this.getDefaultCoordinates(),o=this.getInstanceIndex(i);return o<0&&(o=this.fvar().instances.findIndex(u=>u.name&&u.name.en==="Regular")),o}getInstanceIndex(i){return this.fvar().instances.findIndex(o=>Object.keys(i).every(u=>o.coordinates[u]===i[u]))}getInstance(i){return this.fvar().instances&&this.fvar().instances[i]}set(i){let o;if(Number.isInteger(i)){let u=this.getInstance(i);if(!u)throw Error(`Invalid instance index ${i}`);o={...u.coordinates}}else o=i,this.process.normalizeCoordTags(o);o=Object.assign({},this.font.defaultRenderOptions.variation,o),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:o})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},B0=1e6,yi=64,Fo=1e4,Pc,Aa,fl,Ts;function Ad(i){this.font=i,this.getCommands=function(o){return vd.getPath(o).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Td(i){return i}function Sd(i){return Math.sign(i)*Math.round(Math.abs(i))}function Cd(i){return Math.sign(i)*Math.round(Math.abs(i*2))/2}function _d(i){return Math.sign(i)*(Math.round(Math.abs(i)+.5)-.5)}function C(i){return Math.sign(i)*Math.ceil(Math.abs(i))}function j(i){return Math.sign(i)*Math.floor(Math.abs(i))}var me=function(i){let o=this.srPeriod,u=this.srPhase,d=this.srThreshold,f=1;return i<0&&(i=-i,f=-1),i+=d-u,i=Math.trunc(i/o)*o,i+=u,i<0?u*f:i*f},Ke={x:1,y:0,axis:"x",distance:function(i,o,u,d){return(u?i.xo:i.x)-(d?o.xo:o.x)},interpolate:function(i,o,u,d){let f,m,w,T,_,M,N;if(!d||d===this){if(f=i.xo-o.xo,m=i.xo-u.xo,_=o.x-o.xo,M=u.x-u.xo,w=Math.abs(f),T=Math.abs(m),N=w+T,N===0){i.x=i.xo+(_+M)/2;return}i.x=i.xo+(_*T+M*w)/N;return}if(f=d.distance(i,o,!0,!0),m=d.distance(i,u,!0,!0),_=d.distance(o,o,!1,!0),M=d.distance(u,u,!1,!0),w=Math.abs(f),T=Math.abs(m),N=w+T,N===0){Ke.setRelative(i,i,(_+M)/2,d,!0);return}Ke.setRelative(i,i,(_*T+M*w)/N,d,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(i,o,u,d,f){if(!d||d===this){i.x=(f?o.xo:o.x)+u;return}let m=f?o.xo:o.x,w=f?o.yo:o.y,T=m+u*d.x,_=w+u*d.y;i.x=T+(i.y-_)/d.normalSlope},slope:0,touch:function(i){i.xTouched=!0},touched:function(i){return i.xTouched},untouch:function(i){i.xTouched=!1}},St={x:0,y:1,axis:"y",distance:function(i,o,u,d){return(u?i.yo:i.y)-(d?o.yo:o.y)},interpolate:function(i,o,u,d){let f,m,w,T,_,M,N;if(!d||d===this){if(f=i.yo-o.yo,m=i.yo-u.yo,_=o.y-o.yo,M=u.y-u.yo,w=Math.abs(f),T=Math.abs(m),N=w+T,N===0){i.y=i.yo+(_+M)/2;return}i.y=i.yo+(_*T+M*w)/N;return}if(f=d.distance(i,o,!0,!0),m=d.distance(i,u,!0,!0),_=d.distance(o,o,!1,!0),M=d.distance(u,u,!1,!0),w=Math.abs(f),T=Math.abs(m),N=w+T,N===0){St.setRelative(i,i,(_+M)/2,d,!0);return}St.setRelative(i,i,(_*T+M*w)/N,d,!0)},normalSlope:0,setRelative:function(i,o,u,d,f){if(!d||d===this){i.y=(f?o.yo:o.y)+u;return}let m=f?o.xo:o.x,w=f?o.yo:o.y,T=m+u*d.x,_=w+u*d.y;i.y=_+d.normalSlope*(i.x-T)},slope:Number.POSITIVE_INFINITY,touch:function(i){i.yTouched=!0},touched:function(i){return i.yTouched},untouch:function(i){i.yTouched=!1}};Object.freeze(Ke),Object.freeze(St);function rr(i,o){this.x=i,this.y=o,this.axis=void 0,this.slope=o/i,this.normalSlope=-i/o,Object.freeze(this)}rr.prototype.distance=function(i,o,u,d){return this.x*Ke.distance(i,o,u,d)+this.y*St.distance(i,o,u,d)},rr.prototype.interpolate=function(i,o,u,d){let f,m,w,T,_,M,N;if(w=d.distance(i,o,!0,!0),T=d.distance(i,u,!0,!0),f=d.distance(o,o,!1,!0),m=d.distance(u,u,!1,!0),_=Math.abs(w),M=Math.abs(T),N=_+M,N===0){this.setRelative(i,i,(f+m)/2,d,!0);return}this.setRelative(i,i,(f*M+m*_)/N,d,!0)},rr.prototype.setRelative=function(i,o,u,d,f){d=d||this;let m=f?o.xo:o.x,w=f?o.yo:o.y,T=m+u*d.x,_=w+u*d.y,M=d.normalSlope,N=this.slope,J=i.x,K=i.y;i.x=(N*J-M*T+_-K)/(N-M),i.y=N*(i.x-J)+K},rr.prototype.touch=function(i){i.xTouched=!0,i.yTouched=!0};function Ir(i,o){let u=Math.sqrt(i*i+o*o);return i/=u,o/=u,i===1&&o===0?Ke:i===0&&o===1?St:new rr(i,o)}function nn(i,o,u,d){this.x=this.xo=Math.round(i*64)/64,this.y=this.yo=Math.round(o*64)/64,this.lastPointOfContour=u,this.onCurve=d,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}nn.prototype.nextTouched=function(i){let o=this.nextPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.nextPointOnContour;return o},nn.prototype.prevTouched=function(i){let o=this.prevPointOnContour;for(;!i.touched(o)&&o!==this;)o=o.prevPointOnContour;return o};var An=Object.freeze(new nn(0,0)),Dn={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function xs(i,o){switch(this.env=i,this.stack=[],this.prog=o,i){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Ke,this.round=Sd}}Ad.prototype.exec=function(i,o){if(typeof o!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let u=this.font,d=this._prepState;if(!d||d.ppem!==o){let f=this._fpgmState;if(!f){xs.prototype=Dn,f=this._fpgmState=new xs("fpgm",u.tables.fpgm),f.funcs=[],f.font=u,f.instructionCount=0,f.callDepth=0;try{Aa(f)}catch(w){console.log("Hinting error in FPGM:"+w),this._errorState=3;return}}xs.prototype=f,d=this._prepState=new xs("prep",u.tables.prep),d.ppem=o,d.instructionCount=0,d.callDepth=0;let m=u.variation&&u.variation.process.getCvarTransform()||u.tables.cvt;if(m){let w=d.cvt=new Array(m.length),T=o/u.unitsPerEm;for(let _=0;_<m.length;_++)w[_]=m[_]*T}else d.cvt=[];try{Aa(d)}catch(w){this._errorState<2&&console.log("Hinting error in PREP:"+w),this._errorState=2}}if(!(this._errorState>1))try{return fl(i,d)}catch(f){this._errorState<1&&(console.log("Hinting error:"+f),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},fl=function(i,o){let u=o.ppem/o.font.unitsPerEm,d=u,f=i.components,m,w,T;if(xs.prototype=o,!f)T=new xs("glyf",i.instructions),T.instructionCount=0,T.callDepth=0,Ts(i,T,u,d),w=T.gZone;else{let _=o.font;w=[],m=[];for(let M=0;M<f.length;M++){let N=f[M],J=_.glyphs.get(N.glyphIndex);T=new xs("glyf",J.instructions),T.instructionCount=0,T.callDepth=0,Ts(J,T,u,d);let K=Math.round(N.dx*u),ve=Math.round(N.dy*d),pe=T.gZone,Se=T.contours;for(let Tr=0;Tr<pe.length;Tr++){let pr=pe[Tr];pr.xTouched=pr.yTouched=!1,pr.xo=pr.x=pr.x+K,pr.yo=pr.y=pr.y+ve}let ht=w.length;w.push.apply(w,pe);for(let Tr=0;Tr<Se.length;Tr++)m.push(Se[Tr]+ht)}i.instructions&&!T.inhibitGridFit&&(T=new xs("glyf",i.instructions),T.gZone=T.z0=T.z1=T.z2=w,T.contours=m,w.push(new nn(0,0),new nn(Math.round(i.advanceWidth*u),0)),Aa(T),w.length-=2)}return w},Ts=function(i,o,u,d){let f=i.points||[],m=f.length,w=o.gZone=o.z0=o.z1=o.z2=[],T=o.contours=[],_;for(let J=0;J<m;J++)_=f[J],w[J]=new nn(_.x*u,_.y*d,_.lastPointOfContour,_.onCurve);let M,N;for(let J=0;J<m;J++)_=w[J],M||(M=_,T.push(J)),_.lastPointOfContour?(_.nextPointOnContour=M,M.prevPointOnContour=_,M=void 0):(N=w[J+1],_.nextPointOnContour=N,N.prevPointOnContour=_);o.inhibitGridFit||(w.push(new nn(0,0),new nn(Math.round(i.advanceWidth*u),0)),Aa(o),w.length-=2)},Aa=function(i){let o=i.prog;if(!o)return;let u=o.length,d;for(i.ip=0;i.ip<u;i.ip++){if(++i.instructionCount>B0)throw new Error("Hinting instructions exceeded maximum of "+B0);if(d=Pc[o[i.ip]],!d)throw new Error("unknown instruction: 0x"+Number(o[i.ip]).toString(16));d(i)}};function mn(i){let o=i.tZone=new Array(i.gZone.length);for(let u=0;u<o.length;u++)o[u]=new nn(0,0)}function Di(i,o){let u=i.prog,d=i.ip,f=1,m;do if(m=u[++d],m===88)f++;else if(m===89)f--;else if(m===64)d+=u[d+1]+1;else if(m===65)d+=2*u[d+1]+1;else if(m>=176&&m<=183)d+=m-176+1;else if(m>=184&&m<=191)d+=(m-184+1)*2;else if(o&&f===1&&m===27)break;while(f>0);i.ip=d}function Ua(i,o){o.fv=o.pv=o.dpv=i}function za(i,o){o.pv=o.dpv=i}function ia(i,o){o.fv=i}function vi(i,o){let u=o.stack,d=u.pop(),f=u.pop(),m=o.z2[d],w=o.z1[f],T,_;i?(T=m.y-w.y,_=w.x-m.x):(T=w.x-m.x,_=w.y-m.y),o.pv=o.dpv=Ir(T,_)}function Ta(i,o){let u=o.stack,d=u.pop(),f=u.pop(),m=o.z2[d],w=o.z1[f],T,_;i?(T=m.y-w.y,_=w.x-m.x):(T=w.x-m.x,_=w.y-m.y),o.fv=Ir(T,_)}function Df(i){let o=i.stack,u=o.pop(),d=o.pop();i.pv=i.dpv=Ir(d,u)}function Q0(i){let o=i.stack,u=o.pop(),d=o.pop();i.fv=Ir(d,u)}function r6(i){let o=i.stack,u=i.pv;o.push(u.x*16384),o.push(u.y*16384)}function n6(i){let o=i.stack,u=i.fv;o.push(u.x*16384),o.push(u.y*16384)}function s6(i){i.fv=i.pv}function i6(i){let o=i.stack,u=o.pop(),d=o.pop(),f=o.pop(),m=o.pop(),w=o.pop(),T=i.z0,_=i.z1,M=T[u],N=T[d],J=_[f],K=_[m],ve=i.z2[w],pe=M.x,Se=M.y,ht=N.x,Tr=N.y,pr=J.x,Dr=J.y,sn=K.x,Pn=K.y,Zn=(pe-ht)*(Dr-Pn)-(Se-Tr)*(pr-sn),Kn=pe*Tr-Se*ht,Ps=pr*Pn-Dr*sn;ve.x=(Kn*(pr-sn)-Ps*(pe-ht))/Zn,ve.y=(Kn*(Dr-Pn)-Ps*(Se-Tr))/Zn}function a6(i){i.rp0=i.stack.pop()}function o6(i){i.rp1=i.stack.pop()}function l6(i){i.rp2=i.stack.pop()}function c6(i){let o=i.stack.pop();switch(i.zp0=o,o){case 0:i.tZone||mn(i),i.z0=i.tZone;break;case 1:i.z0=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function u6(i){let o=i.stack.pop();switch(i.zp1=o,o){case 0:i.tZone||mn(i),i.z1=i.tZone;break;case 1:i.z1=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function d6(i){let o=i.stack.pop();switch(i.zp2=o,o){case 0:i.tZone||mn(i),i.z2=i.tZone;break;case 1:i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function h6(i){let o=i.stack.pop();switch(i.zp0=i.zp1=i.zp2=o,o){case 0:i.tZone||mn(i),i.z0=i.z1=i.z2=i.tZone;break;case 1:i.z0=i.z1=i.z2=i.gZone;break;default:throw new Error("Invalid zone pointer")}}function f6(i){i.loop=i.stack.pop(),i.loop>Fo&&(i.loop=Fo)}function p6(i){i.round=Sd}function m6(i){i.round=_d}function g6(i){let o=i.stack.pop();i.minDis=o/64}function x6(i){Di(i,!1)}function b6(i){let o=i.stack.pop();i.ip+=o-1}function y6(i){let o=i.stack.pop();i.cvCutIn=o/64}function v6(i){let o=i.stack;o.push(o[o.length-1])}function jf(i){i.stack.pop()}function w6(i){i.stack.length=0}function A6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(u),o.push(d)}function T6(i){let o=i.stack;o.push(o.length)}function S6(i){let o=i.stack,u=o.pop(),d=o.pop();if(d>Fo&&(d=Fo),++i.callDepth>yi)throw new Error("Hinting call depth exceeded maximum of "+yi);let f=i.ip,m=i.prog;i.prog=i.funcs[u];for(let w=0;w<d;w++)Aa(i);i.ip=f,i.prog=m,i.callDepth--}function C6(i){let o=i.stack.pop();if(++i.callDepth>yi)throw new Error("Hinting call depth exceeded maximum of "+yi);let u=i.ip,d=i.prog;i.prog=i.funcs[o],Aa(i),i.ip=u,i.prog=d,i.callDepth--}function _6(i){let o=i.stack,u=o.pop();o.push(o[o.length-u])}function L6(i){let o=i.stack,u=o.pop();o.push(o.splice(o.length-u,1)[0])}function k6(i){if(i.env!=="fpgm")throw new Error("FDEF not allowed here");let o=i.stack,u=i.prog,d=i.ip,f=o.pop(),m=d;for(;u[++d]!==45;);i.ip=d,i.funcs[f]=u.slice(m+1,d)}function q1(i,o){let u=o.stack.pop(),d=o.z0[u],f=o.fv,m=o.pv,w=m.distance(d,An);i&&(w=o.round(w)),f.setRelative(d,An,w,m),f.touch(d),o.rp0=o.rp1=u}function Y1(i,o){let u=o.z2,d=u.length-2,f,m,w;for(let T=0;T<d;T++)f=u[T],!i.touched(f)&&(m=f.prevTouched(i),m!==f&&(w=f.nextTouched(i),m===w&&i.setRelative(f,f,i.distance(m,m,!1,!0),i,!0),i.interpolate(f,m,w,i)))}function Z1(i,o){let u=o.stack,d=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[d],m=o.fv,w=o.pv,T=o.loop,_=o.z2;for(;T--;){let M=u.pop(),N=_[M],J=w.distance(f,f,!1,!0);m.setRelative(N,N,J,w),m.touch(N)}o.loop=1}function K1(i,o){let u=o.stack,d=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[d],m=o.fv,w=o.pv,T=u.pop(),_=o.z2[o.contours[T]],M=_,N=w.distance(f,f,!1,!0);do M!==f&&m.setRelative(M,M,N,w),M=M.nextPointOnContour;while(M!==_)}function X1(i,o){let u=o.stack,d=i?o.rp1:o.rp2,f=(i?o.z0:o.z1)[d],m=o.fv,w=o.pv,T=u.pop(),_;switch(T){case 0:_=o.tZone;break;case 1:_=o.gZone;break;default:throw new Error("Invalid zone")}let M,N=w.distance(f,f,!1,!0),J=_.length-2;for(let K=0;K<J;K++)M=_[K],m.setRelative(M,M,N,w)}function I6(i){let o=i.stack,u=i.loop,d=i.fv,f=o.pop()/64,m=i.z2;for(;u--;){let w=o.pop(),T=m[w];d.setRelative(T,T,f),d.touch(T)}i.loop=1}function E6(i){let o=i.stack,u=i.rp1,d=i.rp2,f=i.loop,m=i.z0[u],w=i.z1[d],T=i.fv,_=i.dpv,M=i.z2;for(;f--;){let N=o.pop(),J=M[N];T.interpolate(J,m,w,_),T.touch(J)}i.loop=1}function J1(i,o){let u=o.stack,d=u.pop()/64,f=u.pop(),m=o.z1[f],w=o.z0[o.rp0],T=o.fv,_=o.pv;T.setRelative(m,w,d,_),T.touch(m),o.rp1=o.rp0,o.rp2=f,i&&(o.rp0=f)}function N6(i){let o=i.stack,u=i.rp0,d=i.z0[u],f=i.loop,m=i.fv,w=i.pv,T=i.z1;for(;f--;){let _=o.pop(),M=T[_];m.setRelative(M,d,0,w),m.touch(M)}i.loop=1}function R6(i){i.round=Cd}function eg(i,o){let u=o.stack,d=u.pop(),f=u.pop(),m=o.z0[f],w=o.fv,T=o.pv,_=o.cvt[d],M=T.distance(m,An);i&&(Math.abs(M-_)<o.cvCutIn&&(M=_),M=o.round(M)),w.setRelative(m,An,M,T),o.zp0===0&&(m.xo=m.x,m.yo=m.y),w.touch(m),o.rp0=o.rp1=f}function M6(i){let o=i.prog,u=i.ip,d=i.stack,f=o[++u];for(let m=0;m<f;m++)d.push(o[++u]);i.ip=u}function D6(i){let o=i.ip,u=i.prog,d=i.stack,f=u[++o];for(let m=0;m<f;m++){let w=u[++o]<<8|u[++o];w&32768&&(w=-((w^65535)+1)),d.push(w)}i.ip=o}function j6(i){let o=i.stack,u=i.store;u||(u=i.store=[]);let d=o.pop(),f=o.pop();u[f]=d}function B6(i){let o=i.stack,u=i.store,d=o.pop(),f=u&&u[d]||0;o.push(f)}function Q6(i){let o=i.stack,u=o.pop(),d=o.pop();i.cvt[d]=u/64}function P6(i){let o=i.stack,u=o.pop();o.push(i.cvt[u]*64)}function tg(i,o){let u=o.stack,d=u.pop(),f=o.z2[d];u.push(o.dpv.distance(f,An,i,!1)*64)}function rg(i,o){let u=o.stack,d=u.pop(),f=u.pop(),m=o.z1[d],w=o.z0[f],T=o.dpv.distance(w,m,i,i);o.stack.push(Math.round(T*64))}function O6(i){i.stack.push(i.ppem)}function F6(i){i.autoFlip=!0}function $6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d<u?1:0)}function U6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d<=u?1:0)}function z6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d>u?1:0)}function H6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d>=u?1:0)}function W6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(u===d?1:0)}function G6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(u!==d?1:0)}function V6(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?1:0)}function q6(i){let o=i.stack,u=o.pop();o.push(Math.trunc(u)&1?0:1)}function Y6(i){let o=i.stack.pop(),u;o||Di(i,!0)}function Z6(i){}function K6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(u&&d?1:0)}function X6(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(u||d?1:0)}function J6(i){let o=i.stack,u=o.pop();o.push(u?0:1)}function Bf(i,o){let u=o.stack,d=u.pop(),f=o.fv,m=o.pv,w=o.ppem,T=o.deltaBase+(i-1)*16,_=o.deltaShift,M=o.z0;for(let N=0;N<d;N++){let J=u.pop(),K=u.pop();if(T+((K&240)>>4)!==w)continue;let ve=(K&15)-8;ve>=0&&ve++;let pe=M[J];f.setRelative(pe,pe,ve*_,m)}}function e4(i){let o=i.stack.pop();i.deltaBase=o}function t4(i){let o=i.stack.pop();i.deltaShift=Math.pow(.5,o)}function r4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d+u)}function n4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d-u)}function s4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d*64/u)}function i4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(d*u/64)}function a4(i){let o=i.stack,u=o.pop();o.push(Math.abs(u))}function o4(i){let o=i.stack,u=o.pop();o.push(-u)}function l4(i){let o=i.stack,u=o.pop();o.push(Math.floor(u/64)*64)}function c4(i){let o=i.stack,u=o.pop();o.push(Math.ceil(u/64)*64)}function Ld(i,o){let u=o.stack,d=u.pop();u.push(o.round(d/64)*64)}function u4(i){let o=i.stack,u=o.pop(),d=o.pop();i.cvt[d]=u*i.ppem/i.font.unitsPerEm}function Qf(i,o){let u=o.stack,d=u.pop(),f=o.ppem,m=o.deltaBase+(i-1)*16,w=o.deltaShift;for(let T=0;T<d;T++){let _=u.pop(),M=u.pop();if(m+((M&240)>>4)!==f)continue;let N=(M&15)-8;N>=0&&N++;let J=N*w;o.cvt[_]+=J}}function d4(i){let o=i.stack.pop();i.round=me;let u;switch(o&192){case 0:u=.5;break;case 64:u=1;break;case 128:u=2;break;default:throw new Error("invalid SROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid SROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function h4(i){let o=i.stack.pop();i.round=me;let u;switch(o&192){case 0:u=Math.sqrt(2)/2;break;case 64:u=Math.sqrt(2);break;case 128:u=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(i.srPeriod=u,o&48){case 0:i.srPhase=0;break;case 16:i.srPhase=.25*u;break;case 32:i.srPhase=.5*u;break;case 48:i.srPhase=.75*u;break;default:throw new Error("invalid S45ROUND value")}o&=15,o===0?i.srThreshold=0:i.srThreshold=(o/8-.5)*u}function f4(i){i.round=Td}function p4(i){i.round=C}function m4(i){i.round=j}function g4(i){let o=i.stack.pop()}function ng(i,o){let u=o.stack,d=u.pop(),f=u.pop(),m=o.z2[d],w=o.z1[f],T,_;i?(T=m.y-w.y,_=w.x-m.x):(T=w.x-m.x,_=w.y-m.y),o.dpv=Ir(T,_)}function x4(i){let o=i.stack,u=o.pop(),d=0;u&1&&(d=35),u&32&&(d|=4096),o.push(d)}function b4(i){let o=i.stack,u=o.pop(),d=o.pop(),f=o.pop();o.push(d),o.push(u),o.push(f)}function y4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(Math.max(d,u))}function v4(i){let o=i.stack,u=o.pop(),d=o.pop();o.push(Math.min(d,u))}function w4(i){let o=i.stack.pop()}function A4(i){let o=i.stack.pop(),u=i.stack.pop();switch(o){case 1:i.inhibitGridFit=!!u;return;case 2:i.ignoreCvt=!!u;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Rl(i,o){let u=o.stack,d=o.prog,f=o.ip;for(let m=0;m<i;m++)u.push(d[++f]);o.ip=f}function Ml(i,o){let u=o.ip,d=o.prog,f=o.stack;for(let m=0;m<i;m++){let w=d[++u]<<8|d[++u];w&32768&&(w=-((w^65535)+1)),f.push(w)}o.ip=u}function mr(i,o,u,d,f,m){let w=m.stack,T=i&&w.pop(),_=w.pop(),M=m.rp0,N=m.z0[M],J=m.z1[_],K=m.minDis,ve=m.fv,pe=m.dpv,Se,ht,Tr,pr;ht=Se=pe.distance(J,N,!0,!0),Tr=ht>=0?1:-1,ht=Math.abs(ht),i&&(pr=m.cvt[T],d&&Math.abs(ht-pr)<m.cvCutIn&&(ht=pr)),u&&ht<K&&(ht=K),d&&(ht=m.round(ht)),ve.setRelative(J,N,Tr*ht,pe),ve.touch(J),m.rp1=m.rp0,m.rp2=_,o&&(m.rp0=_)}Pc=[Ua.bind(void 0,St),Ua.bind(void 0,Ke),za.bind(void 0,St),za.bind(void 0,Ke),ia.bind(void 0,St),ia.bind(void 0,Ke),vi.bind(void 0,0),vi.bind(void 0,1),Ta.bind(void 0,0),Ta.bind(void 0,1),Df,Q0,r6,n6,s6,i6,a6,o6,l6,c6,u6,d6,h6,f6,p6,m6,g6,x6,b6,y6,void 0,void 0,v6,jf,w6,A6,T6,_6,L6,void 0,void 0,void 0,S6,C6,k6,void 0,q1.bind(void 0,0),q1.bind(void 0,1),Y1.bind(void 0,St),Y1.bind(void 0,Ke),Z1.bind(void 0,0),Z1.bind(void 0,1),K1.bind(void 0,0),K1.bind(void 0,1),X1.bind(void 0,0),X1.bind(void 0,1),I6,E6,J1.bind(void 0,0),J1.bind(void 0,1),N6,R6,eg.bind(void 0,0),eg.bind(void 0,1),M6,D6,j6,B6,Q6,P6,tg.bind(void 0,0),tg.bind(void 0,1),void 0,rg.bind(void 0,0),rg.bind(void 0,1),O6,void 0,F6,void 0,void 0,$6,U6,z6,H6,W6,G6,V6,q6,Y6,Z6,K6,X6,J6,Bf.bind(void 0,1),e4,t4,r4,n4,s4,i4,a4,o4,l4,c4,Ld.bind(void 0,0),Ld.bind(void 0,1),Ld.bind(void 0,2),Ld.bind(void 0,3),void 0,void 0,void 0,void 0,u4,Bf.bind(void 0,2),Bf.bind(void 0,3),Qf.bind(void 0,1),Qf.bind(void 0,2),Qf.bind(void 0,3),d4,h4,void 0,void 0,f4,void 0,p4,m4,jf,jf,void 0,void 0,void 0,void 0,void 0,g4,ng.bind(void 0,0),ng.bind(void 0,1),x4,void 0,b4,y4,v4,w4,A4,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,Rl.bind(void 0,1),Rl.bind(void 0,2),Rl.bind(void 0,3),Rl.bind(void 0,4),Rl.bind(void 0,5),Rl.bind(void 0,6),Rl.bind(void 0,7),Rl.bind(void 0,8),Ml.bind(void 0,1),Ml.bind(void 0,2),Ml.bind(void 0,3),Ml.bind(void 0,4),Ml.bind(void 0,5),Ml.bind(void 0,6),Ml.bind(void 0,7),Ml.bind(void 0,8),mr.bind(void 0,0,0,0,0,0),mr.bind(void 0,0,0,0,0,1),mr.bind(void 0,0,0,0,0,2),mr.bind(void 0,0,0,0,0,3),mr.bind(void 0,0,0,0,1,0),mr.bind(void 0,0,0,0,1,1),mr.bind(void 0,0,0,0,1,2),mr.bind(void 0,0,0,0,1,3),mr.bind(void 0,0,0,1,0,0),mr.bind(void 0,0,0,1,0,1),mr.bind(void 0,0,0,1,0,2),mr.bind(void 0,0,0,1,0,3),mr.bind(void 0,0,0,1,1,0),mr.bind(void 0,0,0,1,1,1),mr.bind(void 0,0,0,1,1,2),mr.bind(void 0,0,0,1,1,3),mr.bind(void 0,0,1,0,0,0),mr.bind(void 0,0,1,0,0,1),mr.bind(void 0,0,1,0,0,2),mr.bind(void 0,0,1,0,0,3),mr.bind(void 0,0,1,0,1,0),mr.bind(void 0,0,1,0,1,1),mr.bind(void 0,0,1,0,1,2),mr.bind(void 0,0,1,0,1,3),mr.bind(void 0,0,1,1,0,0),mr.bind(void 0,0,1,1,0,1),mr.bind(void 0,0,1,1,0,2),mr.bind(void 0,0,1,1,0,3),mr.bind(void 0,0,1,1,1,0),mr.bind(void 0,0,1,1,1,1),mr.bind(void 0,0,1,1,1,2),mr.bind(void 0,0,1,1,1,3),mr.bind(void 0,1,0,0,0,0),mr.bind(void 0,1,0,0,0,1),mr.bind(void 0,1,0,0,0,2),mr.bind(void 0,1,0,0,0,3),mr.bind(void 0,1,0,0,1,0),mr.bind(void 0,1,0,0,1,1),mr.bind(void 0,1,0,0,1,2),mr.bind(void 0,1,0,0,1,3),mr.bind(void 0,1,0,1,0,0),mr.bind(void 0,1,0,1,0,1),mr.bind(void 0,1,0,1,0,2),mr.bind(void 0,1,0,1,0,3),mr.bind(void 0,1,0,1,1,0),mr.bind(void 0,1,0,1,1,1),mr.bind(void 0,1,0,1,1,2),mr.bind(void 0,1,0,1,1,3),mr.bind(void 0,1,1,0,0,0),mr.bind(void 0,1,1,0,0,1),mr.bind(void 0,1,1,0,0,2),mr.bind(void 0,1,1,0,0,3),mr.bind(void 0,1,1,0,1,0),mr.bind(void 0,1,1,0,1,1),mr.bind(void 0,1,1,0,1,2),mr.bind(void 0,1,1,0,1,3),mr.bind(void 0,1,1,1,0,0),mr.bind(void 0,1,1,1,0,1),mr.bind(void 0,1,1,1,0,2),mr.bind(void 0,1,1,1,0,3),mr.bind(void 0,1,1,1,1,0),mr.bind(void 0,1,1,1,1,1),mr.bind(void 0,1,1,1,1,2),mr.bind(void 0,1,1,1,1,3)];var T4=Ad;function Oc(i){this.char=i,this.state={},this.activeState=null}function Pf(i,o,u){this.contextName=u,this.startIndex=i,this.endOffset=o}function S4(i,o,u){this.contextName=i,this.openRange=null,this.ranges=[],this.checkStart=o,this.checkEnd=u}function Hi(i,o){this.context=i,this.index=o,this.length=i.length,this.current=i[o],this.backtrack=i.slice(0,o),this.lookahead=i.slice(o+1)}function kd(i){this.eventId=i,this.subscribers=[]}function C4(i){let o=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let d=0;d<o.length;d++){let f=o[d];Object.defineProperty(this.events,f,{value:new kd(f)})}if(i)for(let d=0;d<o.length;d++){let f=o[d],m=i[f];typeof m=="function"&&this.events[f].subscribe(m)}let u=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let d=0;d<u.length;d++){let f=u[d];this.events[f].subscribe(this.updateContextsRanges)}}function Ss(i){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],C4.call(this,i)}Oc.prototype.setState=function(i,o){return this.state[i]=o,this.activeState={key:i,value:this.state[i]},this.activeState},Oc.prototype.getState=function(i){return this.state[i]||null},Ss.prototype.inboundIndex=function(i){return i>=0&&i<this.tokens.length},Ss.prototype.composeRUD=function(i){let o=i.map(d=>this[d[0]].apply(this,d.slice(1).concat(!0))),u=d=>typeof d=="object"&&Object.prototype.hasOwnProperty.call(d,"FAIL");if(o.every(u))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:o.filter(u)};this.dispatch("composeRUD",[o.filter(d=>!u(d))])},Ss.prototype.replaceRange=function(i,o,u,d){o=o!==null?o:this.tokens.length;let f=u.every(m=>m instanceof Oc);if(!isNaN(i)&&this.inboundIndex(i)&&f){let m=this.tokens.splice.apply(this.tokens,[i,o].concat(u));return d||this.dispatch("replaceToken",[i,o,u]),[m,u]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Ss.prototype.replaceToken=function(i,o,u){if(!isNaN(i)&&this.inboundIndex(i)&&o instanceof Oc){let d=this.tokens.splice(i,1,o);return u||this.dispatch("replaceToken",[i,o]),[d[0],o]}else return{FAIL:"replaceToken: invalid token or index."}},Ss.prototype.removeRange=function(i,o,u){o=isNaN(o)?this.tokens.length:o;let d=this.tokens.splice(i,o);return u||this.dispatch("removeRange",[d,i,o]),d},Ss.prototype.removeToken=function(i,o){if(!isNaN(i)&&this.inboundIndex(i)){let u=this.tokens.splice(i,1);return o||this.dispatch("removeToken",[u,i]),u}else return{FAIL:"removeToken: invalid token index."}},Ss.prototype.insertToken=function(i,o,u){return i.every(d=>d instanceof Oc)?(this.tokens.splice.apply(this.tokens,[o,0].concat(i)),u||this.dispatch("insertToken",[i,o]),i):{FAIL:"insertToken: invalid token(s)."}},Ss.prototype.registerModifier=function(i,o,u){this.events.newToken.subscribe(function(d,f){let m=[d,f],w=o===null||o.apply(this,m)===!0,T=[d,f];if(w){let _=u.apply(this,T);d.setState(i,_)}}),this.registeredModifiers.push(i)},kd.prototype.subscribe=function(i){return typeof i=="function"?this.subscribers.push(i)-1:{FAIL:`invalid '${this.eventId}' event handler`}},kd.prototype.unsubscribe=function(i){this.subscribers.splice(i,1)},Hi.prototype.setCurrentIndex=function(i){this.index=i,this.current=this.context[i],this.backtrack=this.context.slice(0,i),this.lookahead=this.context.slice(i+1)},Hi.prototype.get=function(i){switch(!0){case i===0:return this.current;case(i<0&&Math.abs(i)<=this.backtrack.length):return this.backtrack.slice(i)[0];case(i>0&&i<=this.lookahead.length):return this.lookahead[i-1];default:return null}},Ss.prototype.rangeToText=function(i){if(i instanceof Pf)return this.getRangeTokens(i).map(o=>o.char).join("")},Ss.prototype.getText=function(){return this.tokens.map(i=>i.char).join("")},Ss.prototype.getContext=function(i){return this.registeredContexts[i]||null},Ss.prototype.on=function(i,o){let u=this.events[i];return u?u.subscribe(o):null},Ss.prototype.dispatch=function(i,o){let u=this.events[i];if(u instanceof kd)for(let d=0;d<u.subscribers.length;d++)u.subscribers[d].apply(this,o||[])},Ss.prototype.registerContextChecker=function(i,o,u){if(this.getContext(i))return{FAIL:`context name '${i}' is already registered.`};if(typeof o!="function")return{FAIL:"missing context start check."};if(typeof u!="function")return{FAIL:"missing context end check."};let d=new S4(i,o,u);return this.registeredContexts[i]=d,this.contextCheckers.push(d),d},Ss.prototype.getRangeTokens=function(i){let o=i.startIndex+i.endOffset;return[].concat(this.tokens.slice(i.startIndex,o))},Ss.prototype.getContextRanges=function(i){let o=this.getContext(i);return o?o.ranges:{FAIL:`context checker '${i}' is not registered.`}},Ss.prototype.resetContextsRanges=function(){let i=this.registeredContexts;for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let u=i[o];u.ranges=[]}},Ss.prototype.updateContextsRanges=function(){this.resetContextsRanges();let i=this.tokens.map(o=>o.char);for(let o=0;o<i.length;o++){let u=new Hi(i,o);this.runContextCheck(u)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Ss.prototype.setEndOffset=function(i,o){let u=this.getContext(o).openRange.startIndex,d=new Pf(u,i,o),f=this.getContext(o).ranges;return d.rangeId=`${o}.${f.length}`,f.push(d),this.getContext(o).openRange=null,d},Ss.prototype.runContextCheck=function(i){let o=i.index;for(let u=0;u<this.contextCheckers.length;u++){let d=this.contextCheckers[u],f=d.contextName,m=this.getContext(f).openRange;if(!m&&d.checkStart(i)&&(m=new Pf(o,null,f),this.getContext(f).openRange=m,this.dispatch("contextStart",[f,o])),m&&d.checkEnd(i)){let w=o-m.startIndex+1,T=this.setEndOffset(w,f);this.dispatch("contextEnd",[f,T])}}},Ss.prototype.tokenize=function(i){this.tokens=[],this.resetContextsRanges();let o=Array.from(i);this.dispatch("start");for(let u=0;u<o.length;u++){let d=o[u],f=new Hi(o,u);this.dispatch("next",[f]),this.runContextCheck(f);let m=new Oc(d);this.tokens.push(m),this.dispatch("newToken",[m,f])}return this.dispatch("end",[this.tokens]),this.tokens};var _4=Ss;function Dl(i){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(i)}function sg(i){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(i)}function jl(i){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(i)}function Id(i){return/[\u0E00-\u0E7F]/.test(i)}function Ed(i){return/[A-z]/.test(i)}function L4(i){return/\s/.test(i)}function Sa(i){this.font=i,this.features={}}function Bl(i){this.id=i.id,this.tag=i.tag,this.substitution=i.substitution}function Ql(i,o){if(!i)return-1;switch(o.format){case 1:return o.glyphs.indexOf(i);case 2:{let u=o.ranges;for(let d=0;d<u.length;d++){let f=u[d];if(i>=f.start&&i<=f.end){let m=i-f.start;return f.index+m}}break}default:return-1}return-1}function k4(i,o){return Ql(i,o.coverage)===-1?null:i+o.deltaGlyphId}function I4(i,o){let u=Ql(i,o.coverage);return u===-1?null:o.substitute[u]}function Of(i,o){let u=[];for(let d=0;d<i.length;d++){let f=i[d],m=o.current;m=Array.isArray(m)?m[0]:m;let w=Ql(m,f);w!==-1&&u.push(w)}return u.length!==i.length?-1:u}function E4(i,o){let u=o.inputCoverage.length+o.lookaheadCoverage.length+o.backtrackCoverage.length;if(i.context.length<u)return[];let d=Of(o.inputCoverage,i);if(d===-1)return[];let f=o.inputCoverage.length-1;if(i.lookahead.length<o.lookaheadCoverage.length)return[];let m=i.lookahead.slice(f);for(;m.length&&jl(m[0].char);)m.shift();let w=new Hi(m,0),T=Of(o.lookaheadCoverage,w),_=[].concat(i.backtrack);for(_.reverse();_.length&&jl(_[0].char);)_.shift();if(_.length<o.backtrackCoverage.length)return[];let M=new Hi(_,0),N=Of(o.backtrackCoverage,M),J=d.length===o.inputCoverage.length&&T.length===o.lookaheadCoverage.length&&N.length===o.backtrackCoverage.length,K=[];if(J)for(let ve=0;ve<o.lookupRecords.length;ve++){let pe=o.lookupRecords[ve],Se=pe.lookupListIndex,ht=this.getLookupByIndex(Se);for(let Tr=0;Tr<ht.subtables.length;Tr++){let pr=ht.subtables[Tr],Dr,sn=this.getSubstitutionType(ht,pr);if(sn==="71"?(sn=this.getSubstitutionType(pr,pr.extension),Dr=this.getLookupMethod(pr,pr.extension),pr=pr.extension):Dr=this.getLookupMethod(ht,pr),sn==="12"){let Pn=i.get(pe.sequenceIndex),Zn=Dr(Pn);Zn&&K.push(Zn)}else if(sn==="21"){let Pn=i.get(pe.sequenceIndex),Zn=Dr(Pn);Zn&&K.push(Zn)}else throw new Error(`Substitution type ${sn} is not supported in chaining substitution`)}}return K}function N4(i,o){let u=i.current,d=Ql(u,o.coverage);if(d===-1)return null;let f,m=o.ligatureSets[d];for(let w=0;w<m.length;w++){f=m[w];for(let T=0;T<f.components.length;T++){let _=i.lookahead[T],M=f.components[T];if(_!==M)break;if(T===f.components.length-1)return f}}return null}function R4(i,o){let u=i.current;if(Ql(u,o.coverage)===-1)return null;for(let d of o.ruleSets)for(let f of d){let m=!0;for(let w=0;w<f.input.length;w++)if(i.lookahead[w]!==f.input[w]){m=!1;break}if(m){let w=[];w.push(u);for(let _=0;_<f.input.length;_++)w.push(f.input[_]);let T=(_,M)=>{let{lookupListIndex:N,sequenceIndex:J}=M,{subtables:K}=this.getLookupByIndex(N);for(let ve of K)Ql(_[J],ve.coverage)!==-1&&(_[J]=ve.deltaGlyphId)};for(let _=0;_<f.lookupRecords.length;_++){let M=f.lookupRecords[_];T(w,M)}return w}}return null}function M4(i,o){if(i.context.length<o.coverages.length)return[];for(let d=0;d<o.coverages.length;d++){let f=i.get(d);if(f=Array.isArray(f)?f[0]:f,Ql(f,o.coverages[d])===-1)return[]}let u=[];for(let d=0;d<o.lookupRecords.length;d++){let f=o.lookupRecords[d],m=f.lookupListIndex,w=this.getLookupByIndex(m);for(let T=0;T<w.subtables.length;T++){let _=w.subtables[T],M,N=this.getSubstitutionType(w,_);if(N==="71"?(N=this.getSubstitutionType(_,_.extension),M=this.getLookupMethod(_,_.extension),_=_.extension):M=this.getLookupMethod(w,_),N==="12"){let J=i.get(f.sequenceIndex),K=M(J);K&&u.push(K)}else if(N==="21"){let J=i.get(f.sequenceIndex),K=M(J);K&&u.push(K)}}}return u}function D4(i,o){let u=Ql(i,o.coverage);return u===-1?null:o.sequences[u]}Sa.prototype.getDefaultScriptFeaturesIndexes=function(){let i=this.font.tables.gsub.scripts;for(let o=0;o<i.length;o++){let u=i[o];if(u.tag==="DFLT")return u.script.defaultLangSys.featureIndexes}return[]},Sa.prototype.getScriptFeaturesIndexes=function(i){if(!this.font.tables.gsub)return[];if(!i)return this.getDefaultScriptFeaturesIndexes();let o=this.font.tables.gsub.scripts;for(let u=0;u<o.length;u++){let d=o[u];if(d.tag===i&&d.script.defaultLangSys)return d.script.defaultLangSys.featureIndexes;{let f=d.langSysRecords;if(f)for(let m=0;m<f.length;m++){let w=f[m];if(w.tag===i)return w.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Sa.prototype.mapTagsToFeatures=function(i,o){let u={};for(let d=0;d<i.length;d++){let f=i[d].tag,m=i[d].feature;u[f]=m}this.features[o].tags=u},Sa.prototype.getScriptFeatures=function(i){let o=this.features[i];if(Object.prototype.hasOwnProperty.call(this.features,i))return o;let u=this.getScriptFeaturesIndexes(i);if(!u)return null;let d=this.font.tables.gsub;return o=u.map(f=>d.features[f]),this.features[i]=o,this.mapTagsToFeatures(o,i),o},Sa.prototype.getSubstitutionType=function(i,o){let u=i.lookupType.toString(),d=o.substFormat.toString();return u+d},Sa.prototype.getLookupMethod=function(i,o){let u=this.getSubstitutionType(i,o);switch(u){case"11":return d=>k4.apply(this,[d,o]);case"12":return d=>I4.apply(this,[d,o]);case"63":return d=>E4.apply(this,[d,o]);case"41":return d=>N4.apply(this,[d,o]);case"21":return d=>D4.apply(this,[d,o]);case"51":return d=>R4.apply(this,[d,o]);case"53":return d=>M4.apply(this,[d,o]);default:throw new Error(`substitutionType : ${u} lookupType: ${i.lookupType} - substFormat: ${o.substFormat} is not yet supported`)}},Sa.prototype.lookupFeature=function(i){let o=i.contextParams,u=o.index,d=this.getFeature({tag:i.tag,script:i.script});if(!d)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${i.tag}' for script '${i.script}'.`);let f=this.getFeatureLookups(d),m=[].concat(o.context);for(let w=0;w<f.length;w++){let T=f[w],_=this.getLookupSubtables(T);for(let M=0;M<_.length;M++){let N=_[M],J=this.getSubstitutionType(T,N),K;J==="71"?(J=this.getSubstitutionType(N,N.extension),K=this.getLookupMethod(N,N.extension),N=N.extension):K=this.getLookupMethod(T,N);let ve;switch(J){case"11":ve=K(o.current),ve&&m.splice(u,1,new Bl({id:11,tag:i.tag,substitution:ve}));break;case"12":ve=K(o.current),ve&&m.splice(u,1,new Bl({id:12,tag:i.tag,substitution:ve}));break;case"63":ve=K(o),Array.isArray(ve)&&ve.length&&m.splice(u,1,new Bl({id:63,tag:i.tag,substitution:ve}));break;case"41":ve=K(o),ve&&m.splice(u,1,new Bl({id:41,tag:i.tag,substitution:ve}));break;case"21":ve=K(o.current),ve&&m.splice(u,1,new Bl({id:21,tag:i.tag,substitution:ve}));break;case"51":case"53":ve=K(o),Array.isArray(ve)&&ve.length&&m.splice(u,1,new Bl({id:parseInt(J),tag:i.tag,substitution:ve}));break}o=new Hi(m,u),!(Array.isArray(ve)&&!ve.length)&&(ve=null)}}return m.length?m:null},Sa.prototype.supports=function(i){if(!i.script)return!1;this.getScriptFeatures(i.script);let o=Object.prototype.hasOwnProperty.call(this.features,i.script);if(!i.tag)return o;let u=this.features[i.script].some(d=>d.tag===i.tag);return o&&u},Sa.prototype.getLookupSubtables=function(i){return i.subtables||null},Sa.prototype.getLookupByIndex=function(i){return this.font.tables.gsub.lookups[i]||null},Sa.prototype.getFeatureLookups=function(i){return i.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Sa.prototype.getFeature=function(i){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,i.script)||this.getScriptFeatures(i.script);let o=this.features[i.script];return o?o.tags[i.tag]?this.features[i.script].tags[i.tag]:null:{FAIL:`No feature for script ${i.script}`}};var j4=Sa;function B4(i){let o=i.current,u=i.get(-1);return u===null&&Dl(o)||!Dl(u)&&Dl(o)}function Q4(i){let o=i.get(1);return o===null||!Dl(o)}var P4={startCheck:B4,endCheck:Q4};function O4(i){let o=i.current,u=i.get(-1);return(Dl(o)||jl(o))&&!Dl(u)}function F4(i){let o=i.get(1);switch(!0){case o===null:return!0;case(!Dl(o)&&!jl(o)):{let u=L4(o);if(!u)return!0;if(u){let d=!1;if(d=i.lookahead.some(f=>Dl(f)||jl(f)),!d)return!0}break}default:return!1}}var $4={startCheck:O4,endCheck:F4};function U4(i,o,u){o[u].setState(i.tag,i.substitution)}function z4(i,o,u){o[u].setState(i.tag,i.substitution)}function Ff(i,o,u){for(let d=0;d<i.substitution.length;d++){let f=i.substitution[d],m=o[u+d];if(Array.isArray(f)){f.length?m.setState(i.tag,f[0]):m.setState("deleted",!0);continue}m.setState(i.tag,f)}}function H4(i,o,u){let d=o[u];d.setState(i.tag,i.substitution.ligGlyph);let f=i.substitution.components.length;for(let m=0;m<f;m++)d=o[u+m+1],d.setState("deleted",!0)}var ig={11:U4,12:z4,63:Ff,41:H4,51:Ff,53:Ff};function W4(i,o,u){i instanceof Bl&&ig[i.id]&&ig[i.id](i,o,u)}var ic=W4;function G4(i){let o=[].concat(i.backtrack);for(let u=o.length-1;u>=0;u--){let d=o[u],f=sg(d),m=jl(d);if(!f&&!m)return!0;if(f)return!1}return!1}function V4(i){if(sg(i.current))return!1;for(let o=0;o<i.lookahead.length;o++){let u=i.lookahead[o];if(!jl(u))return!0}return!1}function q4(i){let o="arab",u=this.featuresTags[o],d=this.tokenizer.getRangeTokens(i);if(d.length===1)return;let f=new Hi(d.map(w=>w.getState("glyphIndex")),0),m=new Hi(d.map(w=>w.char),0);for(let w=0;w<d.length;w++){let T=d[w];if(jl(T.char))continue;f.setCurrentIndex(w),m.setCurrentIndex(w);let _=0;G4(m)&&(_|=1),V4(m)&&(_|=2);let M;switch(_){case 1:M="fina";break;case 2:M="init";break;case 3:M="medi";break}if(u.indexOf(M)===-1)continue;let N=this.query.lookupFeature({tag:M,script:o,contextParams:f});if(N instanceof Error){console.info(N.message);continue}for(let J=0;J<N.length;J++){let K=N[J];K instanceof Bl&&(ic(K,d,J),f.context[J]=K.substitution)}}}var Y4=q4;function ag(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function Z4(i){let o="arab",u=this.tokenizer.getRangeTokens(i),d=ag(u);for(let f=0;f<d.context.length;f++){d.setCurrentIndex(f);let m=this.query.lookupFeature({tag:"rlig",script:o,contextParams:d});if(m.length){for(let w=0;w<m.length;w++){let T=m[w];ic(T,u,f)}d=ag(u)}}}var K4=Z4;function X4(i){return i.index===0&&i.context.length>1}function J4(i){return i.index===i.context.length-1}var e7={startCheck:X4,endCheck:J4};function og(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function t7(i){let o="delf",u="ccmp",d=this.tokenizer.getRangeTokens(i),f=og(d);for(let m=0;m<f.context.length;m++){if(!this.query.getFeature({tag:u,script:o,contextParams:f}))continue;f.setCurrentIndex(m);let w=this.query.lookupFeature({tag:u,script:o,contextParams:f});if(w.length){for(let T=0;T<w.length;T++){let _=w[T];ic(_,d,m)}f=og(d)}}}var r7=t7;function n7(i){let o=i.current,u=i.get(-1);return u===null&&Ed(o)||!Ed(u)&&Ed(o)}function s7(i){let o=i.get(1);return o===null||!Ed(o)}var i7={startCheck:n7,endCheck:s7};function lg(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function a7(i){let o="latn",u=this.tokenizer.getRangeTokens(i),d=lg(u);for(let f=0;f<d.context.length;f++){d.setCurrentIndex(f);let m=this.query.lookupFeature({tag:"liga",script:o,contextParams:d});if(m.length){for(let w=0;w<m.length;w++){let T=m[w];ic(T,u,f)}d=lg(u)}}}var o7=a7;function l7(i){let o=i.current,u=i.get(-1);return u===null&&Id(o)||!Id(u)&&Id(o)}function c7(i){let o=i.get(1);return o===null||!Id(o)}var u7={startCheck:l7,endCheck:c7};function cg(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function d7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),d=cg(u,0);for(let f=0;f<d.context.length;f++){d.setCurrentIndex(f);let m=this.query.lookupFeature({tag:"ccmp",script:o,contextParams:d});if(m.length){for(let w=0;w<m.length;w++){let T=m[w];ic(T,u,f)}d=cg(u,f)}}}var h7=d7;function ug(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function f7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),d=ug(u,0);for(let f=0;f<d.context.length;f++){d.setCurrentIndex(f);let m=this.query.lookupFeature({tag:"liga",script:o,contextParams:d});if(m.length){for(let w=0;w<m.length;w++){let T=m[w];ic(T,u,f)}d=ug(u,f)}}}var p7=f7;function dg(i,o){let u=i.map(d=>d.activeState.value);return new Hi(u,o||0)}function m7(i){let o="thai",u=this.tokenizer.getRangeTokens(i),d=dg(u,0);for(let f=0;f<d.context.length;f++){d.setCurrentIndex(f);let m=this.query.lookupFeature({tag:"rlig",script:o,contextParams:d});if(m.length){for(let w=0;w<m.length;w++){let T=m[w];ic(T,u,f)}d=dg(u,f)}}}var g7=m7;function $f(i){if(i===null)return!1;let o=i.codePointAt(0);return o>=6155&&o<=6157||o>=65024&&o<=65039||o>=917760&&o<=917999}function x7(i){let o=i.current,u=i.get(1);return u===null&&$f(o)||$f(u)}function b7(i){let o=i.get(1);return o===null||!$f(o)}var y7={startCheck:x7,endCheck:b7};function v7(i){let o=this.query.font,u=this.tokenizer.getRangeTokens(i);if(u[1].setState("deleted",!0),o.tables.cmap&&o.tables.cmap.varSelectorList){let d=u[0].char.codePointAt(0),f=u[1].char.codePointAt(0),m=o.tables.cmap.varSelectorList[f];if(m!==void 0&&m.nonDefaultUVS){let w=m.nonDefaultUVS.uvsMappings;if(w[d]){let T=w[d].glyphID;o.glyphs.glyphs[T]!==void 0&&u[0].setState("glyphIndex",T)}}}}var w7=v7;function Ha(i){this.baseDir=i||"ltr",this.tokenizer=new _4,this.featuresTags={}}Ha.prototype.setText=function(i){this.text=i},Ha.prototype.contextChecks={ccmpReplacementCheck:e7,latinWordCheck:i7,arabicWordCheck:P4,arabicSentenceCheck:$4,thaiWordCheck:u7,unicodeVariationSequenceCheck:y7};function Fc(i){let o=this.contextChecks[`${i}Check`];return this.tokenizer.registerContextChecker(i,o.startCheck,o.endCheck)}function A7(){return Fc.call(this,"ccmpReplacement"),Fc.call(this,"latinWord"),Fc.call(this,"arabicWord"),Fc.call(this,"arabicSentence"),Fc.call(this,"thaiWord"),Fc.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function T7(){let i=this.tokenizer.getContextRanges("arabicSentence");for(let o=0;o<i.length;o++){let u=i[o],d=this.tokenizer.getRangeTokens(u);this.tokenizer.replaceRange(u.startIndex,u.endOffset,d.reverse())}}Ha.prototype.registerFeatures=function(i,o){let u=o.filter(d=>this.query.supports({script:i,tag:d}));Object.prototype.hasOwnProperty.call(this.featuresTags,i)?this.featuresTags[i]=this.featuresTags[i].concat(u):this.featuresTags[i]=u},Ha.prototype.applyFeatures=function(i,o){if(!i)throw new Error("No valid font was provided to apply features");this.query||(this.query=new j4(i));for(let u=0;u<o.length;u++){let d=o[u];this.query.supports({script:d.script})&&this.registerFeatures(d.script,d.tags)}},Ha.prototype.registerModifier=function(i,o,u){this.tokenizer.registerModifier(i,o,u)};function P0(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function S7(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;P0.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];Y4.call(this,u)}}function C7(){P0.call(this);let i=this.tokenizer.getContextRanges("ccmpReplacement");for(let o=0;o<i.length;o++){let u=i[o];r7.call(this,u)}}function _7(){if(!this.hasFeatureEnabled("arab","rlig"))return;P0.call(this);let i=this.tokenizer.getContextRanges("arabicWord");for(let o=0;o<i.length;o++){let u=i[o];K4.call(this,u)}}function L7(){if(!this.hasFeatureEnabled("latn","liga"))return;P0.call(this);let i=this.tokenizer.getContextRanges("latinWord");for(let o=0;o<i.length;o++){let u=i[o];o7.call(this,u)}}function k7(){let i=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let o=0;o<i.length;o++){let u=i[o];w7.call(this,u)}}function I7(){P0.call(this);let i=this.tokenizer.getContextRanges("thaiWord");for(let o=0;o<i.length;o++){let u=i[o];this.hasFeatureEnabled("thai","liga")&&p7.call(this,u),this.hasFeatureEnabled("thai","rlig")&&g7.call(this,u),this.hasFeatureEnabled("thai","ccmp")&&h7.call(this,u)}}Ha.prototype.checkContextReady=function(i){return!!this.tokenizer.getContext(i)},Ha.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&C7.call(this),this.checkContextReady("arabicWord")&&(S7.call(this),_7.call(this)),this.checkContextReady("latinWord")&&L7.call(this),this.checkContextReady("arabicSentence")&&T7.call(this),this.checkContextReady("thaiWord")&&I7.call(this),this.checkContextReady("unicodeVariationSequence")&&k7.call(this)},Ha.prototype.hasFeatureEnabled=function(i,o){return(this.featuresTags[i]||[]).indexOf(o)!==-1},Ha.prototype.processText=function(i){(!this.text||this.text!==i)&&(this.setText(i),A7.call(this),this.applyFeaturesToContexts())},Ha.prototype.getBidiText=function(i){return this.processText(i),this.tokenizer.getText()},Ha.prototype.getTextGlyphs=function(i){this.processText(i);let o=[];for(let u=0;u<this.tokenizer.tokens.length;u++){let d=this.tokenizer.tokens[u];if(d.state.deleted)continue;let f=d.activeState.value;o.push(Array.isArray(f)?f[0]:f)}return o};var E7=Ha;function Uf(i){return{fontFamily:{en:i.familyName||" "},fontSubfamily:{en:i.styleName||" "},fullName:{en:i.fullName||i.familyName+" "+i.styleName},postScriptName:{en:i.postScriptName||(i.familyName+i.styleName).replace(/\s/g,"")},designer:{en:i.designer||" "},designerURL:{en:i.designerURL||" "},manufacturer:{en:i.manufacturer||" "},manufacturerURL:{en:i.manufacturerURL||" "},license:{en:i.license||" "},licenseURL:{en:i.licenseURL||" "},version:{en:i.version||"Version 0.1"},description:{en:i.description||" "},copyright:{en:i.copyright||" "},trademark:{en:i.trademark||" "}}}function Hn(i){if(i=i||{},i.tables=i.tables||{},!i.empty){if(!i.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!i.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!i.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!i.ascender)throw new Error("When creating a new Font object, ascender is required.");if(i.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=Uf(i),this.names.macintosh=Uf(i),this.names.windows=Uf(i),this.unitsPerEm=i.unitsPerEm||1e3,this.ascender=i.ascender,this.descender=i.descender,this.createdTimestamp=i.createdTimestamp,this.italicAngle=i.italicAngle||0,this.weightClass=i.weightClass||0;let o=0;i.fsSelection?o=i.fsSelection:(this.italicAngle<0?o|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(o|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(o|=this.fsSelectionValues.BOLD),o===0&&(o=this.fsSelectionValues.REGULAR)),(!i.panose||!Array.isArray(i.panose))&&(i.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(i.tables,{os2:Object.assign({usWeightClass:i.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:i.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:i.panose[0]||0,bSerifStyle:i.panose[1]||0,bWeight:i.panose[2]||0,bProportion:i.panose[3]||0,bContrast:i.panose[4]||0,bStrokeVariation:i.panose[5]||0,bArmStyle:i.panose[6]||0,bLetterform:i.panose[7]||0,bMidline:i.panose[8]||0,bXHeight:i.panose[9]||0,fsSelection:o},i.tables.os2)})}this.supported=!0,this.glyphs=new $t.GlyphSet(this,i.glyphs||[]),this.encoding=new Bt(this),this.position=new E0(this),this.substitution=new Bc(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(o,u,d)=>(o[u]=d,o.fvar&&(o.gvar||o.cff2)&&!this.variation&&(this.variation=new j0(this)),!0)}),this.palettes=new md(this),this.layers=new Ef(this),this.svgImages=new Nf(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new T4(this):null}})}Hn.prototype.hasChar=function(i){return this.encoding.charToGlyphIndex(i)>0},Hn.prototype.charToGlyphIndex=function(i){return this.encoding.charToGlyphIndex(i)},Hn.prototype.charToGlyph=function(i){let o=this.charToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Hn.prototype.updateFeatures=function(i){return this.defaultRenderOptions.features.map(o=>o.script==="latn"?{script:"latn",tags:o.tags.filter(u=>i[u])}:o)},Hn.prototype.stringToGlyphIndexes=function(i,o){let u=new E7,d=m=>this.charToGlyphIndex(m.char);u.registerModifier("glyphIndex",null,d);let f=o?this.updateFeatures(o.features):this.defaultRenderOptions.features;return u.applyFeatures(this,f),u.getTextGlyphs(i)},Hn.prototype.stringToGlyphs=function(i,o){let u=this.stringToGlyphIndexes(i,o),d=u.length,f=new Array(d),m=this.glyphs.get(0);for(let w=0;w<d;w+=1)f[w]=this.glyphs.get(u[w])||m;return f},Hn.prototype.nameToGlyphIndex=function(i){return this.glyphNames.nameToGlyphIndex(i)},Hn.prototype.nameToGlyph=function(i){let o=this.nameToGlyphIndex(i),u=this.glyphs.get(o);return u||(u=this.glyphs.get(0)),u},Hn.prototype.glyphIndexToName=function(i){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(i):""},Hn.prototype.getKerningValue=function(i,o){i=i.index||i,o=o.index||o;let u=this.position.defaultKerningTables;return u?this.position.getKerningValue(u,i,o):this.kerningPairs[i+","+o]||0},Hn.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Hn.prototype.forEachGlyph=function(i,o,u,d,f,m){o=o!==void 0?o:0,u=u!==void 0?u:0,d=d!==void 0?d:72,f=Object.assign({},this.defaultRenderOptions,f);let w=1/this.unitsPerEm*d,T=this.stringToGlyphs(i,f),_;if(f.kerning){let M=f.script||this.position.getDefaultScriptName();_=this.position.getKerningTables(M,f.language)}for(let M=0;M<T.length;M+=1){let N=T[M];if(m.call(this,N,o,u,d,f),N.advanceWidth&&(o+=N.advanceWidth*w),f.kerning&&M<T.length-1){let J=_?this.position.getKerningValue(_,N.index,T[M+1].index):this.getKerningValue(N,T[M+1]);o+=J*w}f.letterSpacing?o+=f.letterSpacing*d:f.tracking&&(o+=f.tracking/1e3*d)}return o},Hn.prototype.getPath=function(i,o,u,d,f){f=Object.assign({},this.defaultRenderOptions,f);let m=new Fe;if(m._layers=[],Ks(this,m,d),m.stroke){let w=1/(m.unitsPerEm||1e3)*d;m.strokeWidth*=w}return this.forEachGlyph(i,o,u,d,f,(w,T,_,M)=>{let N=w.getPath(T,_,M,f,this);if(f.drawSVG||f.drawLayers){let J=N._layers;if(J&&J.length){for(let K=0;K<J.length;K++){let ve=J[K];m._layers.push(ve)}return}}m.extend(N)}),m},Hn.prototype.getPaths=function(i,o,u,d,f){f=Object.assign({},this.defaultRenderOptions,f);let m=[];return this.forEachGlyph(i,o,u,d,f,function(w,T,_,M){let N=w.getPath(T,_,M,f,this);m.push(N)}),m},Hn.prototype.getAdvanceWidth=function(i,o,u){return u=Object.assign({},this.defaultRenderOptions,u),this.forEachGlyph(i,0,0,o,u,function(){})},Hn.prototype.draw=function(i,o,u,d,f,m){this.getPath(o,u,d,f,m).draw(i)},Hn.prototype.drawPoints=function(i,o,u,d,f,m){m=Object.assign({},this.defaultRenderOptions,m),this.forEachGlyph(o,u,d,f,m,function(w,T,_,M){w.drawPoints(i,T,_,M,m,this)})},Hn.prototype.drawMetrics=function(i,o,u,d,f,m){m=Object.assign({},this.defaultRenderOptions,m),this.forEachGlyph(o,u,d,f,m,function(w,T,_,M){w.drawMetrics(i,T,_,M)})},Hn.prototype.getEnglishName=function(i){let o=(this.names.unicode||this.names.macintosh||this.names.windows)[i];if(o)return o.en},Hn.prototype.validate=function(){let i=[],o=this;function u(f,m){f||(console.warn(`[opentype.js] ${m}`),i.push(m))}function d(f){let m=o.getEnglishName(f);u(m&&m.trim().length>0,"No English "+f+" specified.")}if(d("fontFamily"),d("weightName"),d("manufacturer"),d("copyright"),d("version"),u(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let f=this.tables.colr.baseGlyphRecords,m=-1;for(let w=0;w<f.length;w++){let T=f[w].glyphID;if(u(m<f[w].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${T} comes after ${m}`),m>f[w].glyphID)break;m=T}}return i},Hn.prototype.toTables=function(){return Qn.fontToTable(this)},Hn.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Hn.prototype.toArrayBuffer=function(){let i=this.toTables().encode(),o=new ArrayBuffer(i.length),u=new Uint8Array(o);for(let d=0;d<i.length;d++)u[d]=i[d];return o},Hn.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Hn.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Hn.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Hn.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Hn.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var hg=Hn;function N7(i,o){let u=new at.Parser(i,o),d=u.parseUShort(),f=u.parseUShort();d!==1&&console.warn(`Unsupported hvar table version ${d}.${f}`);let m=[d,f],w=u.parsePointer32(function(){return this.parseItemVariationStore()}),T=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),_=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),M=u.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:m,itemVariationStore:w,advanceWidth:T,lsb:_,rsb:M}}function R7(){console.warn("Writing of hvar tables is not yet supported.")}var M7={make:R7,parse:N7},D7=function(){return{coverage:this.parsePointer(be.coverage),attachPoints:this.parseList(be.pointer(be.uShortList))}},j7=function(){var i=this.parseUShort();if(ee.argument(i===1||i===2||i===3,"Unsupported CaretValue table version."),i===1)return{coordinate:this.parseShort()};if(i===2)return{pointindex:this.parseShort()};if(i===3)return{coordinate:this.parseShort()}},B7=function(){return this.parseList(be.pointer(j7))},Q7=function(){return{coverage:this.parsePointer(be.coverage),ligGlyphs:this.parseList(be.pointer(B7))}},P7=function(){return this.parseUShort(),this.parseList(be.pointer(be.coverage))};function O7(i,o){o=o||0;let u=new be(i,o),d=u.parseVersion(1);ee.argument(d===1||d===1.2||d===1.3,"Unsupported GDEF table version.");var f={version:d,classDef:u.parsePointer(be.classDef),attachList:u.parsePointer(D7),ligCaretList:u.parsePointer(Q7),markAttachClassDef:u.parsePointer(be.classDef)};return d>=1.2&&(f.markGlyphSets=u.parsePointer(P7)),f}var F7={parse:O7},wo=new Array(10);wo[1]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();if(o===1)return{posFormat:1,coverage:this.parsePointer(be.coverage),value:this.parseValueRecord()};if(o===2)return{posFormat:2,coverage:this.parsePointer(be.coverage),values:this.parseValueRecordList()};ee.assert(!1,"0x"+i.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},wo[2]=function(){let i=this.offset+this.relativeOffset,o=this.parseUShort();ee.assert(o===1||o===2,"0x"+i.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let u=this.parsePointer(be.coverage),d=this.parseUShort(),f=this.parseUShort();if(o===1)return{posFormat:o,coverage:u,valueFormat1:d,valueFormat2:f,pairSets:this.parseList(be.pointer(be.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(d),value2:this.parseValueRecord(f)}})))};if(o===2){let m=this.parsePointer(be.classDef),w=this.parsePointer(be.classDef),T=this.parseUShort(),_=this.parseUShort();return{posFormat:o,coverage:u,valueFormat1:d,valueFormat2:f,classDef1:m,classDef2:w,class1Count:T,class2Count:_,classRecords:this.parseList(T,be.list(_,function(){return{value1:this.parseValueRecord(d),value2:this.parseValueRecord(f)}}))}}},wo[3]=function(){return{error:"GPOS Lookup 3 not supported"}},wo[4]=function(){return{error:"GPOS Lookup 4 not supported"}},wo[5]=function(){return{error:"GPOS Lookup 5 not supported"}},wo[6]=function(){return{error:"GPOS Lookup 6 not supported"}},wo[7]=function(){return{error:"GPOS Lookup 7 not supported"}},wo[8]=function(){return{error:"GPOS Lookup 8 not supported"}},wo[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function $7(i,o){o=o||0;let u=new be(i,o),d=u.parseVersion(1);return ee.argument(d===1||d===1.1,"Unsupported GPOS table version "+d),d===1?{version:d,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(wo)}:{version:d,scripts:u.parseScriptList(),features:u.parseFeatureList(),lookups:u.parseLookupList(wo),variations:u.parseFeatureVariationsList()}}var U7=new Array(10);function z7(i){return new We.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new We.ScriptList(i.scripts)},{name:"features",type:"TABLE",value:new We.FeatureList(i.features)},{name:"lookups",type:"TABLE",value:new We.LookupList(i.lookups,U7)}])}var H7={parse:$7,make:z7};function W7(i){let o={};i.skip("uShort");let u=i.parseUShort();ee.argument(u===0,"Unsupported kern sub-table version."),i.skip("uShort",2);let d=i.parseUShort();i.skip("uShort",3);for(let f=0;f<d;f+=1){let m=i.parseUShort(),w=i.parseUShort(),T=i.parseShort();o[m+","+w]=T}return o}function G7(i){let o={};i.skip("uShort"),i.parseULong()>1&&console.warn("Only the first kern subtable is supported."),i.skip("uLong");let u=i.parseUShort()&255;if(i.skip("uShort"),u===0){let d=i.parseUShort();i.skip("uShort",3);for(let f=0;f<d;f+=1){let m=i.parseUShort(),w=i.parseUShort(),T=i.parseShort();o[m+","+w]=T}}return o}function V7(i,o){let u=new at.Parser(i,o),d=u.parseUShort();if(d===0)return W7(u);if(d===1)return G7(u);throw new Error("Unsupported kern table version ("+d+").")}var q7={parse:V7};function Y7(i,o,u,d){let f=new at.Parser(i,o),m=d?f.parseUShort:f.parseULong,w=[];for(let T=0;T<u+1;T+=1){let _=m.call(f);d&&(_*=2),w.push(_)}return w}var Z7={parse:Y7};function fg(i,o){let u=[],d=12;for(let f=0;f<o;f+=1){let m=at.getTag(i,d),w=at.getULong(i,d+4),T=at.getULong(i,d+8),_=at.getULong(i,d+12);u.push({tag:m,checksum:w,offset:T,length:_,compression:!1}),d+=16}return u}function K7(i,o){let u=[],d=44;for(let f=0;f<o;f+=1){let m=at.getTag(i,d),w=at.getULong(i,d+4),T=at.getULong(i,d+8),_=at.getULong(i,d+12),M;T<_?M="WOFF":M=!1,u.push({tag:m,offset:w,compression:M,compressedLength:T,length:_}),d+=20}return u}function jn(i,o){if(o.compression==="WOFF"){let u=new Uint8Array(i.buffer,o.offset+2,o.compressedLength-2),d=new Uint8Array(o.length);if(ce(u,d),d.byteLength!==o.length)throw new Error("Decompression error: "+o.tag+" decompressed length doesn't match recorded length");return{data:new DataView(d.buffer,0),offset:0}}else return{data:i,offset:o.offset}}function X7(i,o={}){let u,d,f=new hg({empty:!0});i.constructor!==ArrayBuffer&&(i=new Uint8Array(i).buffer);let m=new DataView(i,0),w,T=[],_=at.getTag(m,0);if(_==="\0\0\0"||_==="true"||_==="typ1")f.outlinesFormat="truetype",w=at.getUShort(m,4),T=fg(m,w);else if(_==="OTTO")f.outlinesFormat="cff",w=at.getUShort(m,4),T=fg(m,w);else if(_==="wOFF"){let Sr=at.getTag(m,4);if(Sr==="\0\0\0")f.outlinesFormat="truetype";else if(Sr==="OTTO")f.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+_);w=at.getUShort(m,12),T=K7(m,w)}else if(_==="wOF2"){let Sr="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+Sr)}else throw new Error("Unsupported OpenType signature "+_);let M,N,J,K,ve,pe,Se,ht,Tr,pr,Dr,sn,Pn,Zn,Kn,Ps,Ao,an;for(let Sr=0;Sr<w;Sr+=1){let cr=T[Sr],dr;switch(cr.tag){case"avar":Se=cr;break;case"cmap":dr=jn(m,cr),f.tables.cmap=un.parse(dr.data,dr.offset),f.encoding=new zt(f.tables.cmap);break;case"cvt ":dr=jn(m,cr),an=new at.Parser(dr.data,dr.offset),f.tables.cvt=an.parseShortList(cr.length/2);break;case"fvar":J=cr;break;case"STAT":K=cr;break;case"gvar":ve=cr;break;case"cvar":pe=cr;break;case"fpgm":dr=jn(m,cr),an=new at.Parser(dr.data,dr.offset),f.tables.fpgm=an.parseByteList(cr.length);break;case"head":dr=jn(m,cr),f.tables.head=Ds.parse(dr.data,dr.offset),f.unitsPerEm=f.tables.head.unitsPerEm,u=f.tables.head.indexToLocFormat;break;case"hhea":dr=jn(m,cr),f.tables.hhea=ss.parse(dr.data,dr.offset),f.ascender=f.tables.hhea.ascender,f.descender=f.tables.hhea.descender,f.numberOfHMetrics=f.tables.hhea.numberOfHMetrics;break;case"HVAR":Pn=cr;break;case"hmtx":sn=cr;break;case"ltag":dr=jn(m,cr),d=ul.parse(dr.data,dr.offset);break;case"COLR":dr=jn(m,cr),f.tables.colr=zi.parse(dr.data,dr.offset);break;case"CPAL":dr=jn(m,cr),f.tables.cpal=ct.parse(dr.data,dr.offset);break;case"maxp":dr=jn(m,cr),f.tables.maxp=Ro.parse(dr.data,dr.offset),f.numGlyphs=f.tables.maxp.numGlyphs;break;case"name":Ps=cr;break;case"OS/2":dr=jn(m,cr),f.tables.os2=Ei.parse(dr.data,dr.offset);break;case"post":dr=jn(m,cr),f.tables.post=Mo.parse(dr.data,dr.offset),f.glyphNames=new lr(f.tables.post);break;case"prep":dr=jn(m,cr),an=new at.Parser(dr.data,dr.offset),f.tables.prep=an.parseByteList(cr.length);break;case"glyf":ht=cr;break;case"loca":Kn=cr;break;case"CFF ":M=cr;break;case"CFF2":N=cr;break;case"kern":Zn=cr;break;case"GDEF":Tr=cr;break;case"GPOS":pr=cr;break;case"GSUB":Dr=cr;break;case"meta":Ao=cr;break;case"gasp":try{dr=jn(m,cr),f.tables.gasp=k.parse(dr.data,dr.offset)}catch(ji){console.warn("Failed to parse gasp table, skipping."),console.warn(ji)}break;case"SVG ":dr=jn(m,cr),f.tables.svg=H.parse(dr.data,dr.offset);break;default:break}}let Ca=jn(m,Ps);if(f.tables.name=hn.parse(Ca.data,Ca.offset,d),f.names=f.tables.name,ht&&Kn){let Sr=u===0,cr=jn(m,Kn),dr=Z7.parse(cr.data,cr.offset,f.numGlyphs,Sr),ji=jn(m,ht);f.glyphs=vd.parse(ji.data,ji.offset,dr,f,o)}else if(M){let Sr=jn(m,M);$i.parse(Sr.data,Sr.offset,f,o)}else if(N){let Sr=jn(m,N);$i.parse(Sr.data,Sr.offset,f,o)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let Wi=jn(m,sn);if(ja.parse(f,Wi.data,Wi.offset,f.numberOfHMetrics,f.numGlyphs,f.glyphs,o),Ln(f,o),Zn){let Sr=jn(m,Zn);f.kerningPairs=q7.parse(Sr.data,Sr.offset)}else f.kerningPairs={};if(Tr){let Sr=jn(m,Tr);f.tables.gdef=F7.parse(Sr.data,Sr.offset)}if(pr){let Sr=jn(m,pr);f.tables.gpos=H7.parse(Sr.data,Sr.offset),f.position.init()}if(Dr){let Sr=jn(m,Dr);f.tables.gsub=qn.parse(Sr.data,Sr.offset)}if(J){let Sr=jn(m,J);f.tables.fvar=bi.parse(Sr.data,Sr.offset,f.names)}if(K){let Sr=jn(m,K);f.tables.stat=wa.parse(Sr.data,Sr.offset,f.tables.fvar)}if(ve){J||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),ht||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let Sr=jn(m,ve);f.tables.gvar=vt.parse(Sr.data,Sr.offset,f.tables.fvar,f.glyphs)}if(pe){J||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),f.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),ht||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let Sr=jn(m,pe);f.tables.cvar=Tt.parse(Sr.data,Sr.offset,f.tables.fvar,f.tables.cvt||[])}if(Se){J||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let Sr=jn(m,Se);f.tables.avar=Pa.parse(Sr.data,Sr.offset,f.tables.fvar)}if(Pn){J||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),sn||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let Sr=jn(m,Pn);f.tables.hvar=M7.parse(Sr.data,Sr.offset,f.tables.fvar)}if(Ao){let Sr=jn(m,Ao);f.tables.meta=Do.parse(Sr.data,Sr.offset),f.metas=f.tables.meta}return f.palettes=new md(f),f}function J7(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function e8(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return g(x)})();(function(n,a){typeof define=="function"&&define.amd?define(a):typeof t=="object"&&t.exports?t.exports=a():n.opentype=a()})(typeof self<"u"?self:e,()=>({...r,default:r}))}),U_=F_($_()),_i=n0("lru-cache:metrics"),Cu=N_("lru-cache"),z_=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,dp=()=>_i.hasSubscribers||Cu.hasSubscribers,F3=new Set,p2=typeof process=="object"&&process?process:{},H_=(e,t,r,n)=>{typeof p2.emitWarning=="function"?p2.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},W_=e=>!F3.has(e),Wl=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),$3=e=>Wl(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Th:null:null,Th=class extends Array{constructor(e){super(e),this.fill(0)}},hc,V0,G_=(hc=class{constructor(e,t){if(Gs(this,"heap"),Gs(this,"length"),!ie(hc,V0))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){let t=$3(e);if(!t)return[];Rr(hc,V0,!0);let r=new hc(e,t);return Rr(hc,V0,!1),r}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},V0=new WeakMap,bn(hc,V0,!1),hc),m2,g2,Co,qa,Ho,Hc,Wo,q0,Y0,Go,ri,Ya,Ws,ms,Kr,la,Za,Yi,Ai,Vo,Ti,qo,Yo,Ka,Xa,Zo,Z0,ca,Wc,Kt,hp,Gc,Ol,Ud,Ja,x2,Vc,K0,zd,Fl,$l,fp,qc,Hd,b2,y2,Wd,os,pp,v2,w2,X0,mp,J0,Ul,gp,xp,V_=(xp=class{constructor(e){bn(this,Kt),bn(this,Co),bn(this,qa),bn(this,Ho),bn(this,Hc),bn(this,Wo),bn(this,q0),bn(this,Y0),bn(this,Go),Gs(this,"ttl"),Gs(this,"ttlResolution"),Gs(this,"ttlAutopurge"),Gs(this,"updateAgeOnGet"),Gs(this,"updateAgeOnHas"),Gs(this,"allowStale"),Gs(this,"noDisposeOnSet"),Gs(this,"noUpdateTTL"),Gs(this,"maxEntrySize"),Gs(this,"sizeCalculation"),Gs(this,"noDeleteOnFetchRejection"),Gs(this,"noDeleteOnStaleGet"),Gs(this,"allowStaleOnFetchAbort"),Gs(this,"allowStaleOnFetchRejection"),Gs(this,"ignoreFetchAbort"),Gs(this,"backgroundFetchSize"),bn(this,ri),bn(this,Ya),bn(this,Ws),bn(this,ms),bn(this,Kr),bn(this,la),bn(this,Za),bn(this,Yi),bn(this,Ai),bn(this,Vo),bn(this,Ti),bn(this,qo),bn(this,Yo),bn(this,Ka),bn(this,Xa),bn(this,Zo),bn(this,Z0),bn(this,ca),bn(this,Wc),bn(this,Gc,()=>{}),bn(this,Ol,()=>{}),bn(this,Ud,()=>{}),bn(this,Ja,()=>!1),bn(this,Vc,fe=>{}),bn(this,K0,(fe,X,Qe)=>{}),bn(this,zd,(fe,X,Qe,Pe)=>{if(Qe||Pe)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),Gs(this,m2,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:a,updateAgeOnGet:l,updateAgeOnHas:c,allowStale:h,dispose:p,onInsert:g,disposeAfter:x,noDisposeOnSet:y,noUpdateTTL:A,maxSize:v=0,maxEntrySize:L=0,sizeCalculation:I,fetchMethod:E,memoMethod:R,noDeleteOnFetchRejection:P,noDeleteOnStaleGet:Q,allowStaleOnFetchRejection:$,allowStaleOnFetchAbort:W,ignoreFetchAbort:B,backgroundFetchSize:q=1,perf:ne}=e;if(this.backgroundFetchSize=q,ne!==void 0&&typeof ne?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(Rr(this,Go,ne??z_),t!==0&&!Wl(t))throw new TypeError("max option must be a nonnegative integer");let Be=t?$3(t):Array;if(!Be)throw new Error("invalid max value: "+t);if(Rr(this,Co,t),Rr(this,qa,v),this.maxEntrySize=L||ie(this,qa),this.sizeCalculation=I,this.sizeCalculation){if(!ie(this,qa)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(Rr(this,Y0,R),E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(Rr(this,q0,E),Rr(this,Z0,!!E),Rr(this,Ws,new Map),Rr(this,ms,Array.from({length:t}).fill(void 0)),Rr(this,Kr,Array.from({length:t}).fill(void 0)),Rr(this,la,new Be(t)),Rr(this,Za,new Be(t)),Rr(this,Yi,0),Rr(this,Ai,0),Rr(this,Vo,G_.create(t)),Rr(this,ri,0),Rr(this,Ya,0),typeof p=="function"&&Rr(this,Ho,p),typeof g=="function"&&Rr(this,Hc,g),typeof x=="function"?(Rr(this,Wo,x),Rr(this,Ti,[])):(Rr(this,Wo,void 0),Rr(this,Ti,void 0)),Rr(this,Zo,!!ie(this,Ho)),Rr(this,Wc,!!ie(this,Hc)),Rr(this,ca,!!ie(this,Wo)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!P,this.allowStaleOnFetchRejection=!!$,this.allowStaleOnFetchAbort=!!W,this.ignoreFetchAbort=!!B,this.maxEntrySize!==0){if(ie(this,qa)!==0&&!Wl(ie(this,qa)))throw new TypeError("maxSize must be a positive integer if specified");if(!Wl(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Xt(this,Kt,x2).call(this)}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!Q,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!c,this.ttlResolution=Wl(n)||n===0?n:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!Wl(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Xt(this,Kt,hp).call(this)}if(ie(this,Co)===0&&this.ttl===0&&ie(this,qa)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ie(this,Co)&&!ie(this,qa)){let fe="LRU_CACHE_UNBOUNDED";W_(fe)&&(F3.add(fe),H_("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",fe,xp))}}get perf(){return ie(this,Go)}static unsafeExposeInternals(e){return{starts:ie(e,Yo),ttls:ie(e,Ka),autopurgeTimers:ie(e,Xa),sizes:ie(e,qo),keyMap:ie(e,Ws),keyList:ie(e,ms),valList:ie(e,Kr),next:ie(e,la),prev:ie(e,Za),get head(){return ie(e,Yi)},get tail(){return ie(e,Ai)},free:ie(e,Vo),isBackgroundFetch:t=>{var r;return Xt(r=e,Kt,os).call(r,t)},backgroundFetch:(t,r,n,a)=>{var l;return Xt(l=e,Kt,Wd).call(l,t,r,n,a)},moveToTail:t=>{var r;return Xt(r=e,Kt,J0).call(r,t)},indexes:t=>{var r;return Xt(r=e,Kt,Fl).call(r,t)},rindexes:t=>{var r;return Xt(r=e,Kt,$l).call(r,t)},isStale:t=>{var r;return ie(r=e,Ja).call(r,t)}}}get max(){return ie(this,Co)}get maxSize(){return ie(this,qa)}get calculatedSize(){return ie(this,Ya)}get size(){return ie(this,ri)}get fetchMethod(){return ie(this,q0)}get memoMethod(){return ie(this,Y0)}get dispose(){return ie(this,Ho)}get onInsert(){return ie(this,Hc)}get disposeAfter(){return ie(this,Wo)}getRemainingTTL(e){return ie(this,Ws).has(e)?1/0:0}*entries(){for(let e of Xt(this,Kt,Fl).call(this))ie(this,Kr)[e]!==void 0&&ie(this,ms)[e]!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield[ie(this,ms)[e],ie(this,Kr)[e]])}*rentries(){for(let e of Xt(this,Kt,$l).call(this))ie(this,Kr)[e]!==void 0&&ie(this,ms)[e]!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield[ie(this,ms)[e],ie(this,Kr)[e]])}*keys(){for(let e of Xt(this,Kt,Fl).call(this)){let t=ie(this,ms)[e];t!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield t)}}*rkeys(){for(let e of Xt(this,Kt,$l).call(this)){let t=ie(this,ms)[e];t!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield t)}}*values(){for(let e of Xt(this,Kt,Fl).call(this))ie(this,Kr)[e]!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}*rvalues(){for(let e of Xt(this,Kt,$l).call(this))ie(this,Kr)[e]!==void 0&&!Xt(this,Kt,os).call(this,ie(this,Kr)[e])&&(yield ie(this,Kr)[e])}[(g2=Symbol.iterator,m2=Symbol.toStringTag,g2)](){return this.entries()}find(e,t={}){for(let r of Xt(this,Kt,Fl).call(this)){let n=ie(this,Kr)[r],a=Xt(this,Kt,os).call(this,n)?n.__staleWhileFetching:n;if(a!==void 0&&e(a,ie(this,ms)[r],this))return Xt(this,Kt,X0).call(this,ie(this,ms)[r],t)}}forEach(e,t=this){for(let r of Xt(this,Kt,Fl).call(this)){let n=ie(this,Kr)[r],a=Xt(this,Kt,os).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,ms)[r],this)}}rforEach(e,t=this){for(let r of Xt(this,Kt,$l).call(this)){let n=ie(this,Kr)[r],a=Xt(this,Kt,os).call(this,n)?n.__staleWhileFetching:n;a!==void 0&&e.call(t,a,ie(this,ms)[r],this)}}purgeStale(){let e=!1;for(let t of Xt(this,Kt,$l).call(this,{allowStale:!0}))ie(this,Ja).call(this,t)&&(Xt(this,Kt,Ul).call(this,ie(this,ms)[t],"expire"),e=!0);return e}info(e){let t=ie(this,Ws).get(e);if(t===void 0)return;let r=ie(this,Kr)[t],n=Xt(this,Kt,os).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let a={value:n};if(ie(this,Ka)&&ie(this,Yo)){let l=ie(this,Ka)[t],c=ie(this,Yo)[t];if(l&&c){let h=l-(ie(this,Go).now()-c);a.ttl=h,a.start=Date.now()}}return ie(this,qo)&&(a.size=ie(this,qo)[t]),a}dump(){let e=[];for(let t of Xt(this,Kt,Fl).call(this,{allowStale:!0})){let r=ie(this,ms)[t],n=ie(this,Kr)[t],a=Xt(this,Kt,os).call(this,n)?n.__staleWhileFetching:n;if(a===void 0||r===void 0)continue;let l={value:a};if(ie(this,Ka)&&ie(this,Yo)){l.ttl=ie(this,Ka)[t];let c=ie(this,Go).now()-ie(this,Yo)[t];l.start=Math.floor(Date.now()-c)}ie(this,qo)&&(l.size=ie(this,qo)[t]),e.unshift([r,l])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let n=Date.now()-r.start;r.start=ie(this,Go).now()-n}Xt(this,Kt,qc).call(this,t,r.value,r)}}set(e,t,r={}){let{status:n=_i.hasSubscribers?{}:void 0}=r;r.status=n,n&&(n.op="set",n.key=e,t!==void 0&&(n.value=t),n.cache=this);let a=Xt(this,Kt,qc).call(this,e,t,r);return n&&_i.hasSubscribers&&_i.publish(n),a}pop(){var e;try{for(;ie(this,ri);){let t=ie(this,Kr)[ie(this,Yi)];if(Xt(this,Kt,Hd).call(this,!0),Xt(this,Kt,os).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(ie(this,ca)&&ie(this,Ti)){let t=ie(this,Ti),r;for(;r=t?.shift();)(e=ie(this,Wo))==null||e.call(this,...r)}}}has(e,t={}){let{status:r=_i.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="has",r.key=e,r.cache=this);let n=Xt(this,Kt,b2).call(this,e,t);return _i.hasSubscribers&&_i.publish(r),n}peek(e,t={}){let{status:r=dp()?{}:void 0}=t;r&&(r.op="peek",r.key=e,r.cache=this),t.status=r;let n=Xt(this,Kt,y2).call(this,e,t);return _i.hasSubscribers&&_i.publish(r),n}fetch(e,t={}){let r=Cu.hasSubscribers,{status:n=dp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Xt(this,Kt,pp).call(this,e,t);return n&&r&&(n.trace=!0,Cu.tracePromise(()=>a,n).catch(()=>{})),a}forceFetch(e,t={}){let r=Cu.hasSubscribers,{status:n=dp()?{}:void 0}=t;t.status=n,n&&t.context&&(n.context=t.context);let a=Xt(this,Kt,v2).call(this,e,t);return n&&r&&(n.trace=!0,Cu.tracePromise(()=>a,n).catch(()=>{})),a}memo(e,t={}){let{status:r=_i.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="memo",r.key=e,t.context&&(r.context=t.context),r.cache=this);let n=Xt(this,Kt,w2).call(this,e,t);return r&&(r.value=n),_i.hasSubscribers&&_i.publish(r),n}get(e,t={}){let{status:r=_i.hasSubscribers?{}:void 0}=t;t.status=r,r&&(r.op="get",r.key=e,r.cache=this);let n=Xt(this,Kt,X0).call(this,e,t);return r&&(n!==void 0&&(r.value=n),_i.hasSubscribers&&_i.publish(r)),n}delete(e){return Xt(this,Kt,Ul).call(this,e,"delete")}clear(){return Xt(this,Kt,gp).call(this,"delete")}},Co=new WeakMap,qa=new WeakMap,Ho=new WeakMap,Hc=new WeakMap,Wo=new WeakMap,q0=new WeakMap,Y0=new WeakMap,Go=new WeakMap,ri=new WeakMap,Ya=new WeakMap,Ws=new WeakMap,ms=new WeakMap,Kr=new WeakMap,la=new WeakMap,Za=new WeakMap,Yi=new WeakMap,Ai=new WeakMap,Vo=new WeakMap,Ti=new WeakMap,qo=new WeakMap,Yo=new WeakMap,Ka=new WeakMap,Xa=new WeakMap,Zo=new WeakMap,Z0=new WeakMap,ca=new WeakMap,Wc=new WeakMap,Kt=new WeakSet,hp=function(){let e=new Th(ie(this,Co)),t=new Th(ie(this,Co));Rr(this,Ka,e),Rr(this,Yo,t);let r=this.ttlAutopurge?Array.from({length:ie(this,Co)}):void 0;Rr(this,Xa,r),Rr(this,Ud,(c,h,p=ie(this,Go).now())=>{t[c]=h!==0?p:0,e[c]=h,n(c,h)}),Rr(this,Gc,c=>{t[c]=e[c]!==0?ie(this,Go).now():0,n(c,e[c])});let n=this.ttlAutopurge?(c,h)=>{if(r?.[c]&&(clearTimeout(r[c]),r[c]=void 0),h&&h!==0&&r){let p=setTimeout(()=>{ie(this,Ja).call(this,c)&&Xt(this,Kt,Ul).call(this,ie(this,ms)[c],"expire")},h+1);p.unref&&p.unref(),r[c]=p}}:()=>{};Rr(this,Ol,(c,h)=>{if(e[h]){let p=e[h],g=t[h];if(!p||!g)return;c.ttl=p,c.start=g,c.now=a||l();let x=c.now-g;c.remainingTTL=p-x}});let a=0,l=()=>{let c=ie(this,Go).now();if(this.ttlResolution>0){a=c;let h=setTimeout(()=>a=0,this.ttlResolution);h.unref&&h.unref()}return c};this.getRemainingTTL=c=>{let h=ie(this,Ws).get(c);if(h===void 0)return 0;let p=e[h],g=t[h];if(!p||!g)return 1/0;let x=(a||l())-g;return p-x},Rr(this,Ja,c=>{let h=t[c],p=e[c];return!!p&&!!h&&(a||l())-h>p})},Gc=new WeakMap,Ol=new WeakMap,Ud=new WeakMap,Ja=new WeakMap,x2=function(){let e=new Th(ie(this,Co));Rr(this,Ya,0),Rr(this,qo,e),Rr(this,Vc,t=>{Rr(this,Ya,ie(this,Ya)-e[t]),e[t]=0}),Rr(this,zd,(t,r,n,a)=>{if(!Wl(n)){if(Xt(this,Kt,os).call(this,r))return this.backgroundFetchSize;if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(n=a(r,t),!Wl(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return n}),Rr(this,K0,(t,r,n)=>{if(e[t]=r,ie(this,qa)){let a=ie(this,qa)-e[t];for(;ie(this,Ya)>a;)Xt(this,Kt,Hd).call(this,!0)}Rr(this,Ya,ie(this,Ya)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=ie(this,Ya))})},Vc=new WeakMap,K0=new WeakMap,zd=new WeakMap,Fl=function*({allowStale:e=this.allowStale}={}){if(ie(this,ri))for(let t=ie(this,Ai);Xt(this,Kt,fp).call(this,t)&&((e||!ie(this,Ja).call(this,t))&&(yield t),t!==ie(this,Yi));)t=ie(this,Za)[t]},$l=function*({allowStale:e=this.allowStale}={}){if(ie(this,ri))for(let t=ie(this,Yi);Xt(this,Kt,fp).call(this,t)&&((e||!ie(this,Ja).call(this,t))&&(yield t),t!==ie(this,Ai));)t=ie(this,la)[t]},fp=function(e){return e!==void 0&&ie(this,Ws).get(ie(this,ms)[e])===e},qc=function(e,t,r,n){var a,l,c,h;let{ttl:p=this.ttl,start:g,noDisposeOnSet:x=this.noDisposeOnSet,sizeCalculation:y=this.sizeCalculation,status:A}=r,v=Xt(this,Kt,os).call(this,t);if(t===void 0)return A&&(A.set="deleted"),this.delete(e),this;let{noUpdateTTL:L=this.noUpdateTTL}=r;A&&!v&&(A.value=t);let I=ie(this,zd).call(this,e,t,r.size||0,y,A);if(this.maxEntrySize&&I>this.maxEntrySize)return Xt(this,Kt,Ul).call(this,e,"set"),A&&(A.set="miss",A.maxEntrySizeExceeded=!0),this;let E=ie(this,ri)===0?void 0:ie(this,Ws).get(e);if(E===void 0)E=ie(this,ri)===0?ie(this,Ai):ie(this,Vo).length!==0?ie(this,Vo).pop():ie(this,ri)===ie(this,Co)?Xt(this,Kt,Hd).call(this,!1):ie(this,ri),ie(this,ms)[E]=e,ie(this,Kr)[E]=t,ie(this,Ws).set(e,E),ie(this,la)[ie(this,Ai)]=E,ie(this,Za)[E]=ie(this,Ai),Rr(this,Ai,E),up(this,ri)._++,ie(this,K0).call(this,E,I,A),A&&(A.set="add"),L=!1,ie(this,Wc)&&!v&&((a=ie(this,Hc))==null||a.call(this,t,e,"add"));else{Xt(this,Kt,J0).call(this,E);let R=ie(this,Kr)[E];if(t!==R){if(!x)if(Xt(this,Kt,os).call(this,R)){R!==n&&R.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:P}=R;P!==void 0&&P!==t&&(ie(this,Zo)&&((l=ie(this,Ho))==null||l.call(this,P,e,"set")),ie(this,ca)&&ie(this,Ti)?.push([P,e,"set"]))}else ie(this,Zo)&&((c=ie(this,Ho))==null||c.call(this,R,e,"set")),ie(this,ca)&&ie(this,Ti)?.push([R,e,"set"]);if(ie(this,Vc).call(this,E),ie(this,K0).call(this,E,I,A),ie(this,Kr)[E]=t,!v){let P=R&&Xt(this,Kt,os).call(this,R)?R.__staleWhileFetching:R,Q=P===void 0?"add":t!==P?"replace":"update";A&&(A.set=Q,P!==void 0&&(A.oldValue=P)),ie(this,Wc)&&this.onInsert?.(t,e,Q)}}else v||(A&&(A.set="update"),ie(this,Wc)&&this.onInsert?.(t,e,"update"))}if(p!==0&&!ie(this,Ka)&&Xt(this,Kt,hp).call(this),ie(this,Ka)&&(L||ie(this,Ud).call(this,E,p,g),A&&ie(this,Ol).call(this,A,E)),!x&&ie(this,ca)&&ie(this,Ti)){let R=ie(this,Ti),P;for(;P=R?.shift();)(h=ie(this,Wo))==null||h.call(this,...P)}return this},Hd=function(e){var t;let r=ie(this,Yi),n=ie(this,ms)[r],a=ie(this,Kr)[r],l=Xt(this,Kt,os).call(this,a);l&&a.__abortController.abort(new Error("evicted"));let c=l?a.__staleWhileFetching:a;return(ie(this,Zo)||ie(this,ca))&&c!==void 0&&(ie(this,Zo)&&((t=ie(this,Ho))==null||t.call(this,c,n,"evict")),ie(this,ca)&&ie(this,Ti)?.push([c,n,"evict"])),ie(this,Vc).call(this,r),ie(this,Xa)?.[r]&&(clearTimeout(ie(this,Xa)[r]),ie(this,Xa)[r]=void 0),e&&(ie(this,ms)[r]=void 0,ie(this,Kr)[r]=void 0,ie(this,Vo).push(r)),ie(this,ri)===1?(Rr(this,Yi,Rr(this,Ai,0)),ie(this,Vo).length=0):Rr(this,Yi,ie(this,la)[r]),ie(this,Ws).delete(n),up(this,ri)._--,r},b2=function(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=ie(this,Ws).get(e);if(a!==void 0){let l=ie(this,Kr)[a];if(Xt(this,Kt,os).call(this,l)&&l.__staleWhileFetching===void 0)return!1;if(ie(this,Ja).call(this,a))n&&(n.has="stale",ie(this,Ol).call(this,n,a));else return r&&ie(this,Gc).call(this,a),n&&(n.has="hit",ie(this,Ol).call(this,n,a)),!0}else n&&(n.has="miss");return!1},y2=function(e,t){let{status:r,allowStale:n=this.allowStale}=t,a=ie(this,Ws).get(e);if(a===void 0||!n&&ie(this,Ja).call(this,a)){r&&(r.peek=a===void 0?"miss":"stale");return}let l=ie(this,Kr)[a],c=Xt(this,Kt,os).call(this,l)?l.__staleWhileFetching:l;return r&&(c!==void 0?(r.peek="hit",r.value=c):r.peek="miss"),c},Wd=function(e,t,r,n){let a=t===void 0?void 0:ie(this,Kr)[t];if(Xt(this,Kt,os).call(this,a))return a;let l=new AbortController,{signal:c}=r;c?.addEventListener("abort",()=>l.abort(c.reason),{signal:l.signal});let h={signal:l.signal,options:r,context:n},p=(L,I=!1)=>{let{aborted:E}=l.signal,R=r.ignoreFetchAbort&&L!==void 0,P=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&L!==void 0);if(r.status&&(E&&!I?(r.status.fetchAborted=!0,r.status.fetchError=l.signal.reason,R&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),E&&!R&&!I)return x(l.signal.reason,P);let Q=A,$=ie(this,Kr)[t];return($===A||$===void 0&&R&&I)&&(L===void 0?Q.__staleWhileFetching!==void 0?ie(this,Kr)[t]=Q.__staleWhileFetching:Xt(this,Kt,Ul).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),Xt(this,Kt,qc).call(this,e,L,h.options,Q))),L},g=L=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=L),x(L,!1)),x=(L,I)=>{let{aborted:E}=l.signal,R=E&&r.allowStaleOnFetchAbort,P=R||r.allowStaleOnFetchRejection,Q=P||r.noDeleteOnFetchRejection,$=A;if(ie(this,Kr)[t]===A&&(!Q||!I&&$.__staleWhileFetching===void 0?Xt(this,Kt,Ul).call(this,e,"fetch"):R||(ie(this,Kr)[t]=$.__staleWhileFetching)),P)return r.status&&$.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),$.__staleWhileFetching;if($.__returned===$)throw L},y=(L,I)=>{var E;let R=(E=ie(this,q0))==null?void 0:E.call(this,e,a,h);l.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(L(void 0),r.allowStaleOnFetchAbort&&(L=P=>p(P,!0)))}),R&&R instanceof Promise?R.then(P=>L(P===void 0?void 0:P),I):R!==void 0&&L(R)};r.status&&(r.status.fetchDispatched=!0);let A=new Promise(y).then(p,g),v=Object.assign(A,{__abortController:l,__staleWhileFetching:a,__returned:void 0});return t===void 0?(Xt(this,Kt,qc).call(this,e,v,{...h.options,status:void 0}),t=ie(this,Ws).get(e)):ie(this,Kr)[t]=v,v},os=function(e){if(!ie(this,Z0))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},pp=async function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:l=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:h=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:x=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:L,forceRefresh:I=!1,status:E,signal:R}=t;if(E&&(E.op="fetch",E.key=e,I&&(E.forceRefresh=!0),E.cache=this),!ie(this,Z0))return E&&(E.fetch="get"),Xt(this,Kt,X0).call(this,e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:E});let P={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:l,noDisposeOnSet:c,size:h,sizeCalculation:p,noUpdateTTL:g,noDeleteOnFetchRejection:x,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:v,ignoreFetchAbort:A,status:E,signal:R},Q=ie(this,Ws).get(e);if(Q===void 0){E&&(E.fetch="miss");let $=Xt(this,Kt,Wd).call(this,e,Q,P,L);return $.__returned=$}else{let $=ie(this,Kr)[Q];if(Xt(this,Kt,os).call(this,$)){let ne=r&&$.__staleWhileFetching!==void 0;return E&&(E.fetch="inflight",ne&&(E.returnedStale=!0)),ne?$.__staleWhileFetching:$.__returned=$}let W=ie(this,Ja).call(this,Q);if(!I&&!W)return E&&(E.fetch="hit"),Xt(this,Kt,J0).call(this,Q),n&&ie(this,Gc).call(this,Q),E&&ie(this,Ol).call(this,E,Q),$;let B=Xt(this,Kt,Wd).call(this,e,Q,P,L),q=B.__staleWhileFetching!==void 0&&r;return E&&(E.fetch=W?"stale":"refresh",q&&W&&(E.returnedStale=!0)),q?B.__staleWhileFetching:B.__returned=B}},v2=async function(e,t={}){let r=await Xt(this,Kt,pp).call(this,e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r},w2=function(e,t={}){let r=ie(this,Y0);if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,status:a,forceRefresh:l,...c}=t;a&&l&&(a.forceRefresh=!0);let h=Xt(this,Kt,X0).call(this,e,c),p=l||h===void 0;if(a&&(a.memo=p?"miss":"hit",p||(a.value=h)),!p)return h;let g=r(e,h,{options:c,context:n});return a&&(a.value=g),Xt(this,Kt,qc).call(this,e,g,c),g},X0=function(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:l}=t,c=ie(this,Ws).get(e);if(c===void 0){l&&(l.get="miss");return}let h=ie(this,Kr)[c],p=Xt(this,Kt,os).call(this,h);return l&&ie(this,Ol).call(this,l,c),ie(this,Ja).call(this,c)?p?(l&&(l.get="stale-fetching"),r&&h.__staleWhileFetching!==void 0?(l&&(l.returnedStale=!0),h.__staleWhileFetching):void 0):(a||Xt(this,Kt,Ul).call(this,e,"expire"),l&&(l.get="stale"),r?(l&&(l.returnedStale=!0),h):void 0):(l&&(l.get=p?"fetching":"hit"),Xt(this,Kt,J0).call(this,c),n&&ie(this,Gc).call(this,c),p?h.__staleWhileFetching:h)},mp=function(e,t){ie(this,Za)[t]=e,ie(this,la)[e]=t},J0=function(e){e!==ie(this,Ai)&&(e===ie(this,Yi)?Rr(this,Yi,ie(this,la)[e]):Xt(this,Kt,mp).call(this,ie(this,Za)[e],ie(this,la)[e]),Xt(this,Kt,mp).call(this,ie(this,Ai),e),Rr(this,Ai,e))},Ul=function(e,t){var r,n;_i.hasSubscribers&&_i.publish({op:"delete",delete:t,key:e,cache:this});let a=!1;if(ie(this,ri)!==0){let l=ie(this,Ws).get(e);if(l!==void 0)if(ie(this,Xa)?.[l]&&(clearTimeout(ie(this,Xa)?.[l]),ie(this,Xa)[l]=void 0),a=!0,ie(this,ri)===1)Xt(this,Kt,gp).call(this,t);else{ie(this,Vc).call(this,l);let c=ie(this,Kr)[l];if(Xt(this,Kt,os).call(this,c)?c.__abortController.abort(new Error("deleted")):(ie(this,Zo)||ie(this,ca))&&(ie(this,Zo)&&((r=ie(this,Ho))==null||r.call(this,c,e,t)),ie(this,ca)&&ie(this,Ti)?.push([c,e,t])),ie(this,Ws).delete(e),ie(this,ms)[l]=void 0,ie(this,Kr)[l]=void 0,l===ie(this,Ai))Rr(this,Ai,ie(this,Za)[l]);else if(l===ie(this,Yi))Rr(this,Yi,ie(this,la)[l]);else{let h=ie(this,Za)[l];ie(this,la)[h]=ie(this,la)[l];let p=ie(this,la)[l];ie(this,Za)[p]=ie(this,Za)[l]}up(this,ri)._--,ie(this,Vo).push(l)}}if(ie(this,ca)&&ie(this,Ti)?.length){let l=ie(this,Ti),c;for(;c=l?.shift();)(n=ie(this,Wo))==null||n.call(this,...c)}return a},gp=function(e){var t,r;for(let n of Xt(this,Kt,$l).call(this,{allowStale:!0})){let a=ie(this,Kr)[n];if(Xt(this,Kt,os).call(this,a))a.__abortController.abort(new Error("deleted"));else{let l=ie(this,ms)[n];ie(this,Zo)&&((t=ie(this,Ho))==null||t.call(this,a,l,e)),ie(this,ca)&&ie(this,Ti)?.push([a,l,e])}}if(ie(this,Ws).clear(),ie(this,Kr).fill(void 0),ie(this,ms).fill(void 0),ie(this,Ka)&&ie(this,Yo)){ie(this,Ka).fill(0),ie(this,Yo).fill(0);for(let n of ie(this,Xa)??[])n!==void 0&&clearTimeout(n);ie(this,Xa)?.fill(void 0)}if(ie(this,qo)&&ie(this,qo).fill(0),Rr(this,Yi,0),Rr(this,Ai,0),ie(this,Vo).length=0,Rr(this,Ya,0),Rr(this,ri,0),ie(this,ca)&&ie(this,Ti)){let n=ie(this,Ti),a;for(;a=n?.shift();)(r=ie(this,Wo))==null||r.call(this,...a)}},xp);function U3(e){let t={individual:{},range:[]},r=new WeakMap;for(let n of e)Am(t,n,r);return t}function Am(e,t,r){for(let[n,a]of Object.entries(t.individual))if(e.individual[n])Yc(e.individual[n],a,r);else{let l=!1;for(let[c,{range:h,entry:p}]of e.range.entries()){let g=bp(Number(n),h);if(g.both!==null){l=!0,e.individual[n]=a,Yc(e.individual[n],Li(p),r),e.range.splice(c,1);for(let x of g.second)Array.isArray(x)?e.range.push({range:x,entry:Li(p)}):e.individual[x]=Li(p)}}l||(e.individual[n]=a)}for(let{range:n,entry:a}of t.range){let l=[n];for(let c=0;c<e.range.length;c++){let{range:h,entry:p}=e.range[c];for(let[g,x]of l.entries())if(Array.isArray(x)){let y=q_(x,h);if(y.both===null)continue;e.range.splice(c,1),c--;let A=Li(p);Array.isArray(y.both)?e.range.push({range:y.both,entry:A}):e.individual[y.both]=A,Yc(A,Li(a),r);for(let v of y.second)Array.isArray(v)?e.range.push({range:v,entry:Li(p)}):e.individual[v]=Li(p);l=y.first}else{let y=bp(x,h);if(y.both===null)continue;e.individual[x]=Li(a),Yc(e.individual[x],Li(p),r),e.range.splice(c,1),c--;for(let A of y.second)Array.isArray(A)?e.range.push({range:A,entry:Li(p)}):e.individual[A]=Li(p);l.splice(g,1,...y.first);break}}for(let c of Object.keys(e.individual))for(let[h,p]of l.entries())if(Array.isArray(p)){let g=bp(Number(c),p);if(g.both===null)continue;Yc(e.individual[c],Li(a),r),l.splice(h,1,...g.second);break}else if(Number(c)===p){Yc(e.individual[c],Li(a),r);break}for(let c of l)Array.isArray(c)?e.range.push({range:c,entry:Li(a)}):e.individual[c]=Li(a)}}function Yc(e,t,r){let n=r.get(e);n?.has(t)||(n||(n=new Set,r.set(e,n)),n.add(t),t.lookup&&(!e.lookup||e.lookup.index>t.lookup.index||e.lookup.index===t.lookup.index&&e.lookup.subIndex>t.lookup.subIndex)&&(e.lookup=t.lookup),t.forward&&(e.forward?Am(e.forward,t.forward,r):e.forward=t.forward),t.reverse&&(e.reverse?Am(e.reverse,t.reverse,r):e.reverse=t.reverse))}function q_(e,t){let r={first:[],second:[],both:null};if(e[0]<t[1]&&t[0]<e[1]){let n=Math.max(e[0],t[0]),a=Math.min(e[1],t[1]);r.both=vc(n,a)}if(e[0]<t[0]){let n=e[0],a=Math.min(t[0],e[1]);r.first.push(vc(n,a))}else if(t[0]<e[0]){let n=t[0],a=Math.min(t[1],e[0]);r.second.push(vc(n,a))}if(e[1]>t[1]){let n=Math.max(e[0],t[1]),a=e[1];r.first.push(vc(n,a))}else if(t[1]>e[1]){let n=Math.max(e[1],t[0]),a=t[1];r.second.push(vc(n,a))}return r}function bp(e,t){if(e<t[0]||e>t[1])return{first:[e],second:[t],both:null};let r={first:[],second:[],both:e};return t[0]<e&&r.second.push(vc(t[0],e)),t[1]>e&&r.second.push(vc(e+1,t[1])),r}function vc(e,t){return t-e===1?e:[e,t]}function Li(e,t=new Map){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=A2(e.forward,t)),e.reverse&&(r.reverse=A2(e.reverse,t)),e.lookup&&(r.lookup={contextRange:e.lookup.contextRange.slice(),index:e.lookup.index,length:e.lookup.length,subIndex:e.lookup.subIndex,substitutions:e.lookup.substitutions.slice()}),r}function A2(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=Li(a,t);return{individual:r,range:e.range.map(({range:n,entry:a})=>({range:n.slice(),entry:Li(a,t)}))}}function Tm(e,t,r,n){let a=t[n],l=e[a];if(!l)return;let c=l.lookup;if(l.reverse){let p=Y_(l.reverse,t,r);(!c&&p||p&&c&&(c.index>p.index||c.index===p.index&&c.subIndex>p.subIndex))&&(c=p)}if(++n>=t.length||!l.forward)return c;let h=Tm(l.forward,t,r,n);return(!c&&h||h&&c&&(c.index>h.index||c.index===h.index&&c.subIndex>h.subIndex))&&(c=h),c}function Y_(e,t,r){let n=e[t[--r]],a=n&&n.lookup;for(;n&&((!a&&n.lookup||n.lookup&&a&&a.index>n.lookup.index)&&(a=n.lookup),!(--r<0||!n.reverse));)n=n.reverse[t[r]];return a}function T2(e,t,r){let n=!1;for(let a=0;a<e.length;a++){let l=e[a];if(n){if(r<=l[0])return e[a-1][1]=r,e;if(r<=l[1])return e[a-1][1]=Math.max(r,l[1]),e.splice(a,1),e;e.splice(a,1),a--}else{if(r<=l[0])return e.splice(a,0,[t,r]),e;if(r<=l[1])return l[0]=Math.min(t,l[0]),e;if(t<l[1])l[0]=Math.min(t,l[0]),n=!0;else continue}}return n?e[e.length-1][1]=r:e.push([t,r]),e}function Z_(e,t){switch(e.format){case 1:let r=e.glyphs.indexOf(t);return r!==-1?r:null;case 2:let n=e.ranges.find(a=>a.start<=t&&a.end>=t);return n?n.index:null}}function Ll(e){switch(e.format){case 1:return e.glyphs.map((r,n)=>({glyphId:r,index:n}));case 2:let t=[];for(let[r,n]of e.ranges.entries())n.end===n.start?t.push({glyphId:n.start,index:r}):t.push({glyphId:[n.start,n.end+1],index:r});return t}}function K_(e,t){let r=t[0],n=Sm(e,r),a=t[0]+1,l=new Map;for(;a<t[1];)Sm(e,a)!==n&&(a-r<=1?l.set(r,n):l.set([r,a],n)),a++;return a-r<=1?l.set(r,n):l.set([r,a],n),l}function Sm(e,t){let r=Z_(e.coverage,t);if(r===null)return null;switch(e.substFormat){case 1:return(t+e.deltaGlyphId)%2**16;case 2:return e.substitute[r]??null}}function p1(e,t,r,n,a){let l=[];for(let c of r){c.entry.forward={individual:{},range:[]};for(let h of e)l.push(...gf(c.entry.forward,n,a,t,h).map(({entry:p,substitution:g})=>({entry:p,substitutions:[...c.substitutions,g]})))}return l}function pf(e,t){let r=[],n=new Set;for(let a of t){if(n.has(a.entry))continue;n.add(a.entry),a.entry.forward??={individual:{},range:[]};let l={};for(let c of e)Array.isArray(c)?a.entry.forward.range.push({entry:l,range:c}):a.entry.forward.individual[c]=l;r.push({entry:l,substitutions:a.substitutions})}return r}function mf(e,t){let r=[],n=new Set;for(let a of t){if(n.has(a.entry))continue;n.add(a.entry),a.entry.reverse??={individual:{},range:[]};let l={};for(let c of e)Array.isArray(c)?a.entry.reverse.range.push({entry:l,range:c}):a.entry.reverse.individual[c]=l;r.push({entry:l,substitutions:a.substitutions})}return r}function gf(e,t,r,n,a){let l=[];if(!Array.isArray(a))e.individual[a]={},l.push({entry:e.individual[a],substitution:J_(t,r,n,a)});else{let c=X_(t,r,n,a);for(let[h,p]of c){let g={};Array.isArray(h)?e.range.push({range:h,entry:g}):e.individual[h]={},l.push({entry:g,substitution:p})}}return l}function X_(e,t,r,n){for(let a of e.filter(l=>l.sequenceIndex===r))for(let l of t[a.lookupListIndex].subtables){let c=K_(l,n);if(!Array.from(c.values()).every(h=>h!==null))return c}return new Map([[n,null]])}function J_(e,t,r,n){for(let a of e.filter(l=>l.sequenceIndex===r))for(let l of t[a.lookupListIndex].subtables){let c=Sm(l,n);if(c!==null)return c}return null}function eL(e,t,r){let n={individual:{},range:[]},a=Ll(e.coverage);for(let{glyphId:l,index:c}of a){let h=e.chainRuleSets[c];if(h)for(let[p,g]of h.entries()){let x=gf(n,g.lookupRecords,t,0,l).map(({entry:y,substitution:A})=>({entry:y,substitutions:[A]}));for(let[y,A]of g.input.entries())x=p1([A],y+1,x,g.lookupRecords,t);for(let y of g.lookahead)x=pf([y],x);for(let y of g.backtrack)x=mf([y],x);for(let{entry:y,substitutions:A}of x)y.lookup={substitutions:A,length:g.input.length+1,index:r,subIndex:p,contextRange:[-1*g.backtrack.length,1+g.input.length+g.lookahead.length]}}}return n}function tL(e,t){return e.format===2?Array.isArray(t)?rL(e,t):new Map([[t,Cm(e,t)]]):new Map([[t,null]])}function rL(e,t){let r=t[0],n=Cm(e,r),a=t[0]+1,l=new Map;for(;a<t[1];)Cm(e,a)!==n&&(a-r<=1?l.set(r,n):l.set([r,a],n)),a++;return a-r<=1?l.set(r,n):l.set([r,a],n),l}function Cm(e,t){for(let r of e.ranges)if(r.start<=t&&r.end>=t)return r.classId;return null}function yp(e,t){switch(e.format){case 2:let r=[];for(let n of e.ranges)n.classId===t&&(n.end===n.start?r.push(n.start):r.push([n.start,n.end+1]));return r;default:return[]}}function nL(e,t,r){let n=[],a=Ll(e.coverage);for(let{glyphId:l}of a){let c=tL(e.inputClassDef,l);for(let[h,p]of c.entries()){if(p===null)continue;let g=e.chainClassSet[p];if(g)for(let[x,y]of g.entries()){let A={individual:{},range:[]},v=gf(A,y.lookupRecords,t,0,h).map(({entry:L,substitution:I})=>({entry:L,substitutions:[I]}));for(let[L,I]of y.input.entries())v=p1(yp(e.inputClassDef,I),L+1,v,y.lookupRecords,t);for(let L of y.lookahead)v=pf(yp(e.lookaheadClassDef,L),v);for(let L of y.backtrack)v=mf(yp(e.backtrackClassDef,L),v);for(let{entry:L,substitutions:I}of v)L.lookup={substitutions:I,index:r,subIndex:x,length:y.input.length+1,contextRange:[-1*y.backtrack.length,1+y.input.length+y.lookahead.length]};n.push(A)}}}return U3(n)}function sL(e,t,r){let n={individual:{},range:[]},a=Ll(e.inputCoverage[0]);for(let{glyphId:l}of a){let c=gf(n,e.lookupRecords,t,0,l).map(({entry:h,substitution:p})=>({entry:h,substitutions:[p]}));for(let[h,p]of e.inputCoverage.slice(1).entries())c=p1(Ll(p).map(g=>g.glyphId),h+1,c,e.lookupRecords,t);for(let h of e.lookaheadCoverage)c=pf(Ll(h).map(p=>p.glyphId),c);for(let h of e.backtrackCoverage)c=mf(Ll(h).map(p=>p.glyphId),c);for(let{entry:h,substitutions:p}of c)h.lookup={substitutions:p,index:r,subIndex:0,length:e.inputCoverage.length,contextRange:[-1*e.backtrackCoverage.length,e.inputCoverage.length+e.lookaheadCoverage.length]}}return n}function iL(e,t){let r={individual:{},range:[]},n=Ll(e.coverage);for(let{glyphId:a,index:l}of n){let c={};Array.isArray(a)?r.range.push({entry:c,range:a}):r.individual[a]=c;let h=[{entry:c,substitutions:[e.substitutes[l]]}];for(let p of e.lookaheadCoverage)h=pf(Ll(p).map(g=>g.glyphId),h);for(let p of e.backtrackCoverage)h=mf(Ll(p).map(g=>g.glyphId),h);for(let{entry:p,substitutions:g}of h)p.lookup={substitutions:g,index:t,subIndex:0,length:1,contextRange:[-1*e.backtrackCoverage.length,1+e.lookaheadCoverage.length]}}return r}function _m(e,t=new Map){let r={};for(let[n,a]of Object.entries(e.individual))r[n]=S2(a,t);for(let{range:n,entry:a}of e.range){let l=S2(a,t);for(let c=n[0];c<n[1];c++)r[c]=l}return r}function S2(e,t){if(t.has(e))return t.get(e);let r={};return t.set(e,r),e.forward&&(r.forward=_m(e.forward,t)),e.reverse&&(r.reverse=_m(e.reverse,t)),e.lookup&&(r.lookup=e.lookup),r}var aL=class{constructor(e,t){this._lookupTrees=[],this._glyphLookups={},this._font=e,t.cacheSize>0&&(this._cache=new V_({maxSize:t.cacheSize,sizeCalculation:((l,c)=>c.length)}));let r=(this._font.tables.gsub&&this._font.tables.gsub.features.filter(l=>l.tag==="calt")||[]).reduce((l,c)=>[...l,...c.feature.lookupListIndexes],[]),n=this._font.tables.gsub&&this._font.tables.gsub.lookups||[],a=n.filter((l,c)=>r.some(h=>h===c));for(let[l,c]of a.entries()){let h=[];switch(c.lookupType){case 6:for(let[g,x]of c.subtables.entries())switch(x.substFormat){case 1:h.push(eL(x,n,g));break;case 2:h.push(nL(x,n,g));break;case 3:h.push(sL(x,n,g));break}break;case 8:for(let[g,x]of c.subtables.entries())h.push(iL(x,g));break}let p=_m(U3(h));this._lookupTrees.push({tree:p,processForward:c.lookupType!==8});for(let g of Object.keys(p))this._glyphLookups[g]||(this._glyphLookups[g]=[]),this._glyphLookups[g].push(l)}}findLigatures(e){let t=this._cache&&this._cache.get(e);if(t&&!Array.isArray(t))return t;let r=[];for(let l of e)r.push(this._font.charToGlyphIndex(l));if(this._lookupTrees.length===0)return{inputGlyphs:r,outputGlyphs:r,contextRanges:[]};let n=this._findInternal(r.slice()),a={inputGlyphs:r,outputGlyphs:n.sequence,contextRanges:n.ranges};return this._cache&&this._cache.set(e,a),a}findLigatureRanges(e){if(this._lookupTrees.length===0)return[];let t=this._cache&&this._cache.get(e);if(t)return Array.isArray(t)?t:t.contextRanges;let r=[];for(let a of e)r.push(this._font.charToGlyphIndex(a));let n=this._findInternal(r);return this._cache&&this._cache.set(e,n.ranges),n.ranges}_findInternal(e){let t=[],r=this._getNextLookup(e,0);for(;r.index!==null;){let n=this._lookupTrees[r.index];if(n.processForward){let a=r.last;for(let l=r.first;l<a;l++){let c=Tm(n.tree,e,l,l);if(c){for(let h=0;h<c.substitutions.length;h++){let p=c.substitutions[h];p!==null&&(e[l+h]=p)}T2(t,c.contextRange[0]+l,c.contextRange[1]+l),l+c.length>=a&&(a=l+c.length+1),l+=c.length-1}}}else for(let a=r.last-1;a>=r.first;a--){let l=Tm(n.tree,e,a,a);if(l){for(let c=0;c<l.substitutions.length;c++){let h=l.substitutions[c];h!==null&&(e[a+c]=h)}T2(t,l.contextRange[0]+a,l.contextRange[1]+a),a-=l.length-1}}r=this._getNextLookup(e,r.index+1)}return{sequence:e,ranges:t}}_getNextLookup(e,t){let r={index:null,first:1/0,last:-1};for(let n=0;n<e.length;n++){let a=this._glyphLookups[e[n]];if(a)for(let l=0;l<a.length;l++){let c=a[l];if(c>=t){(r.index===null||c<=r.index)&&(r.index=c,r.first>n&&(r.first=n),r.last=n+1);break}}}return r}};function oL(e,t){let r=U_.parse(e);return new aL(r,{cacheSize:0,...t})}function lL(e){if(typeof e!="string")throw new Error("Font family must be a string");let t={input:e,offset:0},r=[],n="";for(;t.offset<t.input.length;){let a=t.input[t.offset++];switch(a){case"'":case'"':n+=cL(t,a);break;case",":r.push(n),n="";break;default:/\s/.test(a)||(t.offset--,n+=uL(t),r.push(n),n="")}}return r}function cL(e,t){let r="",n=!1;for(;e.offset<e.input.length;){let a=e.input[e.offset++];if(n)/[\dA-Fa-f]/.test(a)?(e.offset--,r+=z3(e)):a!==`
63
+ `&&(r+=a),n=!1;else switch(a){case t:return r;case"\\":n=!0;break;default:r+=a}}throw new Error("Unterminated string")}function uL(e){let t="",r=!1;for(;e.offset<e.input.length;){let n=e.input[e.offset++];if(r)/[\dA-Fa-f]/.test(n)?(e.offset--,t+=z3(e)):t+=n,r=!1;else switch(n){case"\\":r=!0;break;case",":return t;default:/\s/.test(n)?t.endsWith(" ")||(t+=" "):t+=n}}return t}function z3(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return vp(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,vp(t);t+=r}return vp(t)}function vp(e){return String.fromCodePoint(parseInt(e,16))}var eu;async function dL(e,t){if(!eu){if(typeof navigator<"u"&&"fonts"in navigator){try{let a=await navigator.permissions.request?.({name:"local-fonts"});if(a&&a.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(a){if(a instanceof Error&&a.name!=="TypeError")throw a}let n={};try{let a=await navigator.fonts.query();for(let l of a)n.hasOwnProperty(l.family)||(n[l.family]=[]),n[l.family].push(l);eu=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let n={};try{let a=await window.queryLocalFonts();for(let l of a)n.hasOwnProperty(l.family)||(n[l.family]=[]),n[l.family].push(l);eu=Promise.resolve(n)}catch(a){a instanceof Error&&console.error(a.name,a.message)}}eu??=Promise.resolve({})}let r=await eu;for(let n of lL(e)){if(hL.includes(n))return;if(r.hasOwnProperty(n)&&r[n].length>0){let a=r[n][0];if("blob"in a){let l=await(await a.blob()).arrayBuffer();return oL(l,{cacheSize:t})}return}}}var hL=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],fL=1e5;function pL(e,t=[]){let r,n,a=0,l;return e.registerCharacterJoiner(c=>{let h=e.options.fontFamily;if(h&&(a===0||r!==h)){n=void 0,a=1,r=h;let p=r;dL(p,fL).then(g=>{p===e.options.fontFamily&&(a=2,n=g,g&&e.refresh(0,e.rows-1))}).catch(g=>{p===e.options.fontFamily&&(a=3,e.options.logLevel==="debug"&&console.debug(l,new Error("Failure while loading font")),n=void 0,l=g)})}return n&&a===2?n.findLigatureRanges(c).map(p=>[p[0],p[1]]):mL(c,t)})}function mL(e,t){let r=[];for(let n=0;n<e.length;n++)for(let a=0;a<t.length;a++)if(e.startsWith(t[a],n)){r.push([n,n+t[a].length]),n+=t[a].length-1;break}return r}var gL=class{constructor(e){this._fallbackLigatures=(e?.fallbackLigatures??["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"]).sort((t,r)=>r.length-t.length),this._fontFeatureSettings=e?.fontFeatureSettings}activate(e){if(!e.element)throw new Error("Cannot activate LigaturesAddon before open is called");this._terminal=e,this._characterJoinerId=pL(e,this._fallbackLigatures),e.element.style.fontFeatureSettings=this._fontFeatureSettings??'"calt" on'}dispose(){this._characterJoinerId!==void 0&&(this._terminal?.deregisterCharacterJoiner(this._characterJoinerId),this._characterJoinerId=void 0),this._terminal?.element&&(this._terminal.element.style.fontFeatureSettings="")}};function C2(e){let t=0;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<48||57<n)return-1;t=t*10+n-48}return t}var xL=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,t=>{if(!t.startsWith("4;"))return!1;let r=t.split(";");if(r.length>3)return!0;r.length===2&&r.push("");let n=C2(r[1]),a=C2(r[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(a<0)return!0;this.progress={state:n,value:a};break;case 2:case 4:if(a<0)return!0;this.progress={state:n,value:a||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn("progress state out of bounds, not applied");return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function H3(e,t){const r=Math.max(e.left,t.left),n=Math.max(e.top,t.top),a=Math.min(e.right,t.right),l=Math.min(e.bottom,t.bottom);return a>r&&l>n?{left:r,top:n,right:a,bottom:l}:null}function _2(e,t){const r=H3(e,t);return r?(r.right-r.left)*(r.bottom-r.top):0}function Lc(e){const t=e.element;if(!t||!e.cols||!e.rows)return null;const n=(t.querySelector?.(".xterm-screen")??null??t).getBoundingClientRect();if(!n.width||!n.height)return null;const a=e.dimensions?.css?.cell?.height,l=n.width/e.cols,c=a&&a>0?a:n.height/e.rows;return{originLeft:n.left,originTop:n.top,cellW:l,cellH:c}}function Sh(e,t){const r=Lc(e);if(!r)return null;const n=t.row-e.buffer.active.viewportY;if(n<0||n>=e.rows)return null;const a=Math.max(0,Math.min(e.cols-1,t.col));return{x:r.originLeft+(a+.5)*r.cellW,y:r.originTop+n*r.cellH}}function bL(e,t){const r=Math.max(0,e.buffer.active.baseY+e.rows-1);return{col:Math.max(0,Math.min(e.cols-1,t.col)),row:Math.max(0,Math.min(r,t.row))}}function Gh(e,t,r){const n=e.row*r+e.col,a=t.row*r+t.col;return n<=a?{start:e,end:t}:{start:t,end:e}}function yL(e,t,r){const n=Lc(e);if(!n)return null;const{start:a,end:l}=Gh(t,r,e.cols),c=e.buffer.active.viewportY,h=c+e.rows-1;if(l.row<c||a.row>h)return null;const p=Math.max(a.row,c),g=Math.min(l.row,h),x=n.originTop+(p-c)*n.cellH,y=n.originTop+(g-c+1)*n.cellH;return a.row===l.row?{left:n.originLeft+a.col*n.cellW,top:x,right:n.originLeft+(l.col+1)*n.cellW,bottom:y}:{left:n.originLeft,top:x,right:n.originLeft+e.cols*n.cellW,bottom:y}}function vL(e){const t=Math.max(e.viewport.left,e.terminal.left),r=Math.max(e.viewport.top,e.terminal.top),n=Math.min(e.viewport.right,e.terminal.right),a=Math.min(e.viewport.bottom,e.terminal.bottom),l=t+e.margin,c=r+e.margin,h=Math.max(l,n-e.width-e.margin),p=Math.max(c,a-e.height-e.margin),g=ne=>Math.max(l,Math.min(ne,h)),x=ne=>Math.max(c,Math.min(ne,p)),y=e.selection?H3(e.selection,{left:t,top:r,right:n,bottom:a}):null;if(!y){const ne=g(e.clientX-e.width/2),Be=e.clientY-e.height-e.fingerGap,fe=e.clientY+e.fingerGap,X=x(Be>=c?Be:fe);return{left:Math.round(ne),top:Math.round(X)}}const A=(y.left+y.right)/2,v=(y.top+y.bottom)/2,L=e.preference?.alignX??A,I=e.selectionGap??e.fingerGap,E=y.top-e.height-I,R=y.bottom+I,P=e.preference?.vertical==="below"?R:E,Q=e.preference?.vertical==="below"?E:R,$=[{left:l,top:c},{left:h,top:c},{left:l,top:p},{left:h,top:p}];e.preference&&$.sort((ne,Be)=>{const fe=X=>{const Qe=X.left+e.width/2,Pe=X.top+e.height/2;return Math.hypot(Qe-e.preference.focusX,Pe-e.preference.focusY)};return fe(Be)-fe(ne)});const W=[{left:L-e.width/2,top:P},{left:A-e.width/2,top:P},{left:L-e.width/2,top:Q},{left:A-e.width/2,top:Q},{left:y.left-e.width-e.fingerGap,top:v-e.height/2},{left:y.right+e.fingerGap,top:v-e.height/2},...$].map(ne=>({left:g(ne.left),top:x(ne.top)}));let B=W[0],q=Number.POSITIVE_INFINITY;return W.forEach((ne,Be)=>{const fe={left:ne.left,top:ne.top,right:ne.left+e.width,bottom:ne.top+e.height},X=(e.avoid??[]).reduce((Pe,ue)=>Pe+_2(fe,ue),0),Qe=(X>0?1e6:0)+X*100+_2(fe,y)*10+Be*.01;Qe<q&&(B=ne,q=Qe)}),{left:Math.round(B.left),top:Math.round(B.top)}}function wL(e){const t=e.willChange.split(",").map(n=>n.trim()),r=(n,a)=>!!(n&&n!==a);return r(e.transform,"none")||r(e.perspective,"none")||r(e.filter,"none")||r(e.backdropFilter,"none")||r(e.containerType,"normal")||e.contain.includes("layout")||e.contain.includes("paint")||e.contain.includes("strict")||e.contain.includes("content")||t.includes("transform")||t.includes("perspective")||t.includes("filter")}function AL(e){let t=e.parentElement;for(;t;){if(wL(window.getComputedStyle(t)))return t;t=t.parentElement}return null}function TL(e,t,r,n){const a=e.getBoundingClientRect();let l=0,c=0;if(t){const h=t.getBoundingClientRect();l=h.left+t.clientLeft,c=h.top+t.clientTop}return{x:a.left-l+r,y:a.top-c+n}}function SL(e,t){const r=e.replace(/\r?\n/g,"\r");return`\x1B[200~${(t&&r.endsWith("\r")?r.slice(0,-1):r).replace(/\x1b/g,"␛")}\x1B[201~${t?"\r":""}`}function CL(e,t,r){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let a=0;const l=e.length-n,c=t.length-n;for(;a<l&&a<c&&e[e.length-1-a]===t[t.length-1-a];)a+=1;const h=t.slice(n,t.length-a);return h&&(r==="insertFromPaste"||r==="insertFromPasteAsQuotation"||/[\r\n]/.test(h))?h:null}const L2=2,_L=new Set(["mount","init-fit","resize","dpr-change","session-key-change","session-reset","tmux-layout"]);function LL(e){const t=e.reason.replace(/^refresh:/,""),r=_L.has(t),n=Math.abs(e.proposedCols-e.currentCols),a=Math.abs(e.proposedRows-e.currentRows);return{accept:r?n>0||a>0:n>=L2||a>=L2,isRealResize:r,colsDelta:n,rowsDelta:a}}function kL(e){return e.before.cols!==e.after.cols||e.before.rows!==e.after.rows||e.lastServerSize===null||e.reconcileServerSize===!0&&(e.lastServerSize.cols!==e.after.cols||e.lastServerSize.rows!==e.after.rows)}function IL(e,t){return!e||t}function EL(e,t,r){return e!=="alternate"&&r>=t}function NL(e,t){return e?"none":t?"single":"settled"}function RL(e,t,r){return!r&&(e||t)}function ML(e){let t,r,n=!1,a=0;const l=e.parser.registerCsiHandler({prefix:"?",final:"l"},h=>(t&&h.some(p=>p===2026)&&(n=!0),!1)),c=h=>{const p=t;if(!p)return;const g=r;if(t=void 0,r=void 0,n=!1,p(),h){const x=e._core?._renderService?._renderer?.value;g&&x?.handleResize(...g),x?.renderRows(0,e.rows-1),e.refresh(0,e.rows-1)}};return{begin(){if(a++,n=!1,t)return;const h=e._core?._renderService?._renderer?.value;if(!h||typeof h.handleResize!="function"||typeof h.renderRows!="function"||typeof h.clear!="function")return;const p=h.handleResize,g=h.renderRows,x=h.clear;h.handleResize=(y,A)=>{r=[y,A]},h.renderRows=()=>{},h.clear=()=>{},t=()=>{h.handleResize=p,h.renderRows=g,h.clear=x}},get generation(){return a},written(h){h===a&&n&&!e.modes.synchronizedOutputMode&&c(!0)},cancel(){c(!0)},dispose(){c(!1),l.dispose()}}}function wp(){return{confirmed:null,pending:null,nextSeq:1}}function k2(e,t){return e?.cols===t.cols&&e.rows===t.rows}function m1(e,t,r){const n={...t,seq:e.nextSeq,attempt:r};return{state:{...e,pending:n,nextSeq:e.nextSeq+1},request:n}}function DL(e,t){return k2(e.pending,t)||!e.pending&&k2(e.confirmed,t)?{state:e,request:null}:m1(e,t,0)}function jL(e,t){return m1(e,t,0)}function BL(e,t){const r=e.pending;if(!r||t.seq!==r.seq)return{state:e,accepted:!1};const n=t.ok&&Number.isFinite(t.cols)&&Number.isFinite(t.rows)&&(t.cols??0)>0&&(t.rows??0)>0?{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}:null;return{state:{...e,confirmed:n,pending:null},accepted:!0}}function I2(e,t,r=1){const n=e.pending;return!n||n.seq!==t?{state:e,request:null,exhausted:!1}:n.attempt>=r?{state:{...e,confirmed:null,pending:null},request:null,exhausted:!0}:{...m1(e,n,n.attempt+1),exhausted:!1}}function QL(e,t){return!Number.isFinite(t.cols)||!Number.isFinite(t.rows)||t.cols<=0||t.rows<=0?e:{...e,confirmed:{cols:Math.floor(t.cols),rows:Math.floor(t.rows)}}}function PL(e){return{...e,pending:null}}const OL=150;function E2(e=0){return{lastPushAt:e}}function FL(e,t,r=OL){return t-e.lastPushAt>=r?(e.lastPushAt=t,{action:"send"}):{action:"hold",readyAt:e.lastPushAt+r}}function $L(e){return{lastPushAt:e}}const Lm="termdock-settings",UL=6,zL=100,HL='"calt" on',WL=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function GL(){if(typeof window>"u")return 13;const e=window.matchMedia("(max-width: 767px)").matches,t=window.matchMedia("(pointer: coarse)").matches;return e||t?10:13}function g1(){return{fontFamily:"var(--font-mono)",fontSize:GL(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function Gd(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function N2(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function d0(e){const t=g1(),r=e&&typeof e=="object"?e:{},n=r.rendererMode??r.renderer;return{fontFamily:typeof r.fontFamily=="string"&&r.fontFamily.trim()?r.fontFamily.trim():t.fontFamily,fontSize:Gd(r.fontSize,UL,zL,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:N2(r.fontWeight,t.fontWeight),fontWeightBold:N2(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(Gd(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:Gd(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:Gd(r.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function Vd(e){return e.pointerType==="touch"||e.pointerType==="pen"}class VL{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[r,n]of this.active)n===t&&(this.active.delete(r),this.pointerStates.delete(r));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,r){return this.active.get(t)===r}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,r,n){this.changeListeners.size!==0&&this.changeListeners.forEach(a=>{try{a({type:t,pointerId:r,handler:n})}catch{}})}log(t,r,n=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const a=performance.now().toFixed(0);console.debug(`[GestureManager ${a}] ${t} ${r} ${n}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,r)=>r.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!Vd(t))return;const r={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,r);let n=!1;for(const a of this.sortedHandlers()){if(!this.handlerMatchesContainer(a,t)){this.log("skip-container",a.name);continue}a.onPointerDown(t,r)&&!n&&(this.active.set(t.pointerId,a.name),n=!0,this.log("claim",a.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,a.name))}n&&t.preventDefault()};handlePointerMove=t=>{if(!Vd(t)||!this.pointerStates.has(t.pointerId))return;let r=!1;for(const n of this.sortedHandlers()){if(!this.handlerMatchesContainer(n,t))continue;const a=this.active.get(t.pointerId)===n.name,l=n.onPointerMove(t,a);if(l==="claim"&&!r){const c=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,n.name),r=!0,t.preventDefault(),c&&c!==n.name&&this.log("handoff",`${c}->${n.name}`,`pid=${t.pointerId}`),this.log("claim",n.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,n.name)}if(l==="release"&&a&&!r){const c=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",n.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,c??null)}}};handlePointerUp=t=>{if(!Vd(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerUp(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlePointerCancel=t=>{if(!Vd(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerCancel(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlerMatchesContainer(t,r){return t.container?t.container.contains(r.target):!0}}const W3=new VL,qL=90,YL=80,ZL=70,KL=(e,t)=>{const{scrollMultiplier:r=1.2,maxScrollBoost:n=.8,boostDenominator:a=50,velocityAlpha:l=.15,maxVelocity:c=15,minVelocity:h=.3,decelerationRate:p=.998,enableKinetic:g=!0,shouldCaptureTouch:x,canStartScrollGesture:y,onScroll:A,onScrollWithCoords:v,onTap:L,onClickWithCoords:I,onClaimChange:E,tapThreshold:R=10,gestureName:P="normal-scroll"}=t,Q=1.06,$=S.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),W=S.useRef(0),B=S.useRef(0),q=S.useRef(0),ne=S.useRef(null),Be=S.useRef(0),fe=S.useRef(!1),X=S.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),Qe=S.useCallback(()=>{ne.current=null,W.current!==0&&(v&&B.current>0&&q.current>0?v(W.current,B.current,q.current):A&&A(W.current),W.current=0,B.current=0,q.current=0)},[A,v]),Pe=S.useCallback(()=>{ne.current===null&&typeof window<"u"&&(ne.current=window.requestAnimationFrame(Qe))},[Qe]),ue=S.useCallback((_e,re,Fe)=>{W.current+=_e,re!==void 0&&Fe!==void 0&&(B.current=re,q.current=Fe),Pe()},[Pe]),Ce=S.useCallback(_e=>{if(!_e||!A)return!1;const re=A(_e);return re?Be.current=0:Be.current++,re},[A]),tt=S.useCallback(_e=>{fe.current!==_e&&(fe.current=_e,E?.(_e))},[E]),we=S.useCallback(()=>{const _e=$.current;_e.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(_e.rafId),_e.rafId=null,ne.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(ne.current),ne.current=null,W.current=0},[]),ce=S.useRef(L);ce.current=L;const $e=S.useRef(I);$e.current=I;const ke=S.useRef(x);ke.current=x;const se=S.useCallback(()=>{const _e=e.current;if(!_e||!("PointerEvent"in window))return()=>{};const re=$.current,Fe={name:P,priority:ZL,get container(){return e.current??void 0},onPointerDown:(ee,Ue)=>(ee.pointerType!=="touch"||(re.pointerId=ee.pointerId,re.startX=Ue.startX,re.startY=Ue.startY,re.didMove=!1,re.gestureAxis=null,re.lastY=ee.clientY,re.lastTime=X(),re.velocity=0,we()),!1),onPointerMove:(ee,Ue)=>{if(ee.pointerType!=="touch"||re.pointerId!==ee.pointerId||!re.lastY||!re.lastTime)return"neutral";const Le=ee.clientX,te=ee.clientY,ye=X(),ot=ye-re.lastTime,le=te-re.lastY;if(re.startX!==null&&re.startY!==null){const Ne=Le-re.startX,yt=te-re.startY;if(!re.didMove&&Math.hypot(Ne,yt)>=R&&(re.didMove=!0),re.gestureAxis===null&&re.didMove){const gt=Math.abs(Ne),At=Math.abs(yt);gt>At*Q?re.gestureAxis="x":At>gt*Q&&(re.gestureAxis="y")}if(re.gestureAxis==="x")return re.isCurrentlyScrolling=!1,tt(!1),re.lastY=te,re.lastTime=ye,Ue?"release":"neutral";if(re.gestureAxis===null)return re.lastY=te,re.lastTime=ye,"neutral"}if(re.gestureAxis==="y"&&!Ue&&!(y?.()??!0))return re.lastY=te,re.lastTime=ye,tt(!1),"neutral";const xe=le/Math.max(ot,1);if(re.velocity=re.velocity*(1-l)+xe*l,re.velocity=Math.max(-c,Math.min(c,re.velocity)),Math.abs(le)>1){if(!Ue)return tt(!0),re.lastY=te,re.lastTime=ye,"claim";re.isCurrentlyScrolling=!0;const Ne=r+Math.min(n,Math.abs(le)/a),yt=-le*Ne;ue(yt,Le,te),tt(!0)}return re.lastY=te,re.lastTime=ye,Ue?"claim":"neutral"},onPointerUp:ee=>{if(ee.pointerType!=="touch"||re.pointerId!==ee.pointerId)return;const Ue=re.isCurrentlyScrolling;re.isCurrentlyScrolling=!1,tt(!1);const Le=re.rafId!==null||ne.current!==null;!re.didMove&&!Le&&re.startX!==null&&re.startY!==null&&ce.current?.(re.startX,re.startY),!re.didMove&&!Le&&re.startX!==null&&re.startY!==null&&$e.current?.(re.startX,re.startY),re.pointerId=null,re.startX=null,re.startY=null;const te=re.gestureAxis==="x";if(re.gestureAxis=null,g&&Ue&&!te&&Math.abs(re.velocity)>h&&re.didMove){const ye=()=>{const ot=X(),le=ot-(re.lastTime||ot);if(re.lastTime=ot,re.velocity*=Math.pow(p,le),Math.abs(re.velocity)<h){re.velocity=0,we();return}if(!Ce(-re.velocity*le)&&Be.current>2){re.velocity=0,we();return}re.rafId=requestAnimationFrame(ye)};re.rafId=requestAnimationFrame(ye)}},onPointerCancel:ee=>{ee.pointerType!=="touch"||re.pointerId!==ee.pointerId||(re.isCurrentlyScrolling=!1,tt(!1),re.pointerId=null,re.startX=null,re.startY=null,re.gestureAxis=null,we())}},wt=W3.register(Fe),Xe=_e.style.touchAction;return _e.style.touchAction="none",()=>{tt(!1),wt(),_e.style.touchAction=Xe,we()}},[e,P,r,n,a,l,c,h,p,X,we,Ce,ue,R,g,tt,y]),je=S.useCallback(()=>{const _e=e.current;if(!_e)return()=>{};const re=$.current,Fe=Ue=>{Ue.touches.length===1&&((x?.()??!0)&&Ue.cancelable&&Ue.preventDefault(),re.isCurrentlyScrolling=!1,re.gestureAxis=null,re.lastY=Ue.touches[0].clientY,re.startX=Ue.touches[0].clientX,re.startY=Ue.touches[0].clientY,re.didMove=!1,re.velocity=0,we())},wt=Ue=>{if(Ue.touches.length!==1)return;const Le=Ue.touches[0].clientX,te=Ue.touches[0].clientY;if(re.startX!==null&&re.startY!==null){const ot=Le-re.startX,le=te-re.startY;if(!re.didMove&&Math.hypot(ot,le)>=R&&(re.didMove=!0),re.gestureAxis===null&&re.didMove){const xe=Math.abs(ot),Ne=Math.abs(le);xe>Ne*Q?re.gestureAxis="x":Ne>xe*Q&&(re.gestureAxis="y")}if(re.gestureAxis==="x"){re.isCurrentlyScrolling=!1,re.lastY=te;return}if(re.gestureAxis===null){(x?.()??!1)&&Ue.cancelable&&Ue.preventDefault(),re.lastY=te;return}}if(Ue.preventDefault(),!re.lastY){re.lastY=te;return}const ye=te-re.lastY;if(Math.abs(ye)>1){re.isCurrentlyScrolling=!0;const ot=r+Math.min(n,Math.abs(ye)/a),le=-ye*ot;ue(le,Le,te)}re.lastY=te},Xe=Ue=>{if(!Ue.changedTouches?.[0])return;const te=re.isCurrentlyScrolling;re.isCurrentlyScrolling=!1;const ye=re.rafId!==null||ne.current!==null;!re.didMove&&!ye&&L&&re.startX!==null&&re.startY!==null&&L(re.startX,re.startY),!re.didMove&&!ye&&I&&re.startX!==null&&re.startY!==null&&I(re.startX,re.startY),re.startX=null,re.startY=null;const ot=re.gestureAxis==="x";if(re.gestureAxis=null,g&&te&&!ot&&re.didMove&&Math.abs(re.velocity)>h){const le=()=>{if(re.velocity*=Math.pow(p,16),Math.abs(re.velocity)<h){re.velocity=0,we();return}if(!Ce(-re.velocity*16)&&Be.current>2){re.velocity=0,we();return}re.rafId=requestAnimationFrame(le)};re.rafId=requestAnimationFrame(le)}};_e.addEventListener("touchstart",Fe,{passive:!1}),_e.addEventListener("touchmove",wt,{passive:!1}),_e.addEventListener("touchend",Xe,{passive:!1}),_e.addEventListener("touchcancel",Xe,{passive:!1});const ee=_e.style.touchAction;return _e.style.touchAction="none",()=>{_e.removeEventListener("touchstart",Fe),_e.removeEventListener("touchmove",wt),_e.removeEventListener("touchend",Xe),_e.removeEventListener("touchcancel",Xe),_e.style.touchAction=ee,we()}},[e,r,n,a,h,p,we,Ce,ue,L,I,R,x,g]),de=S.useCallback(()=>{we();const _e=typeof window<"u"&&"PointerEvent"in window,re=_e?se():()=>{},Fe=_e?()=>{}:je();return()=>{re(),Fe(),we()}},[se,je,we]),Oe=S.useCallback(()=>$.current.isCurrentlyScrolling||$.current.rafId!==null||ne.current!==null,[]),Ee=S.useCallback(()=>{we();const _e=$.current;_e.isCurrentlyScrolling=!1,_e.velocity=0,_e.lastY=null,_e.lastTime=null,_e.startX=null,_e.startY=null,_e.pointerId=null,_e.didMove=!1,_e.gestureAxis=null},[we]);return{setupTouchScroll:de,isScrolling:Oe,stopAllScroll:Ee}};function R2(e){const{name:t,priority:r}=e,n=b.useRef(e.onPointerDown),a=b.useRef(e.onPointerMove),l=b.useRef(e.onPointerUp),c=b.useRef(e.onPointerCancel),h=b.useRef(e.container);n.current=e.onPointerDown,a.current=e.onPointerMove,l.current=e.onPointerUp,c.current=e.onPointerCancel,h.current=e.container,b.useEffect(()=>{const p={name:t,priority:r,get container(){const x=h.current;return typeof x=="function"?x():x},onPointerDown(x,y){return n.current?.(x,y)??!1},onPointerMove(x,y){return a.current?.(x,y)??"neutral"},onPointerUp(x){l.current?.(x)},onPointerCancel(x){c.current?.(x)}};return W3.register(p)},[t,r])}var $s;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})($s||($s={}));$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;$s.Light,$s.Medium,$s.Heavy,$s.Success,$s.Warning,$s.Error;const XL=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",JL=()=>typeof document<"u"&&!!document.body,ek=()=>{if(JL())try{const e=document.createElement("label");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;";const t=document.createElement("input");t.type="checkbox",t.setAttribute("switch",""),e.appendChild(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch{}},M2=e=>Array.isArray(e)?[...e]:[e],tk=e=>{if(XL()){try{const a=M2(e),l=a.length===1?a[0]:a;navigator.vibrate(l)}catch{}return}const t=M2(e),r=Array.from({length:Math.ceil(t.length/2)},(a,l)=>[t[l*2]??0,t[l*2+1]??0]);let n=0;for(const[a,l]of r)a>0&&setTimeout(ek,n),n+=a+l},no=e=>tk(e);function G3({message:e}){const{t}=Hr();return s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-4",children:s.jsx(Fu,{dots:!0,label:e??t("terminal.loading"),className:"max-w-full rounded-full bg-surface-2 px-4 py-2 text-center shadow-sm"})})}function rk(){const{t:e}=Hr();return s.jsx(G3,{message:e("terminal.initializing")})}const nk=({message:e,onRetry:t})=>{const{t:r}=Hr();return s.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:s.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":r("terminal.error"),children:[s.jsx("title",{children:r("terminal.error")}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})]})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"font-medium text-foreground",children:r("terminal.failedToLoad")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e||r("terminal.unknownError")})]}),t&&s.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:r("common.retry")})]})})};function Ch(e){return Array.from(e)}function D2(e,t,r){return Math.max(t,Math.min(r,e))}function sk(e,t,r,n){const a=Ch(e),l=Ch(t);let c=D2(r,0,a.length);const h=D2(n,0,l.length);let p=0;for(;p<a.length&&p<l.length&&a[p]===l[p];)p++;let g=0;for(;g<a.length-p&&g<l.length-p&&a[a.length-1-g]===l[l.length-1-g];)g++;const x=a.length-p-g,y=l.slice(p,l.length-g).join(""),A=[];if(x>0||y){const v=p+x;c>v?A.push({left:c-v}):c<v&&A.push({right:v-c}),c=v,x>0&&(A.push({backspace:x}),c=p),y&&(A.push({insert:y}),c+=Ch(y).length)}return c>h?A.push({left:c-h}):c<h&&A.push({right:h-c}),c=h,{ops:A,cursor:c}}function j2(e){const t=e.value,r=e.selectionStart??t.length;return Ch(t.slice(0,r)).length}const Vh=16,ik=10,B2=1.5,ak=1.8,Q2=240,ok=125,lk=92;function ck(e,t,r){const n=Math.hypot(e,t),a=Math.abs(e),l=Math.abs(t),c=()=>a>=l*B2?e>0?"right":"left":l>=a*B2?t>0?"down":"up":"";if(r==="")return n>Vh?c():"";if(n<ik)return"";if(n<=Vh)return r;const h=c();if(h===""||h===r)return r;if(r==="left"&&h==="right"||r==="right"&&h==="left"||r==="up"&&h==="down"||r==="down"&&h==="up")return h;const g=r==="left"||r==="right";return(g?l:a)>=(g?a:l)*ak?h:r}function uk(e){const t=lk-Vh,r=Math.min(Math.max((e-Vh)/t,0),1);return Q2-r*(Q2-ok)}const dk="termdock-open-terminal-directory",km=/(?:\\[ \t]|[^\s`"'<>|()[\]{}=,:;!?:,;!?。、“”‘’])+/gu,hk=new RegExp(`^( *)(${km.source})`,"u"),fk=/[,;:!?]+$/u,pk=/^[a-z][a-z\d+.-]*:\/\//iu;function mk(e){return!e||e==="/"||pk.test(e)||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.endsWith("/")||/^[^/:]+\/[^/:]+\/(?:[^/:]+\/?)+$/u.test(e)}function V3(e){const t=[];km.lastIndex=0;let r;for(;(r=km.exec(e))!==null;){const a=r[0].replace(fk,"");if(!mk(a))continue;const l=e.slice(r.index+a.length).match(/^:(\d+)(?::\d+)?(?=$|[\s:,,;;。!!??)\]}`])/u),c=l?Number(l[1]):void 0,h=c!==void 0&&Number.isSafeInteger(c)&&c>0;t.push({text:a,...h?{line:c}:{},startIndex:r.index,endIndex:r.index+a.length+(h?l[0].length:0)})}return t}function Ap(e){const t=[];for(const r of e.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return`/${t.join("/")}`}function gk(e){return e.match(/^\/(?:home|Users)\/[^/]+/u)?.[0]??null}function xk(e,t){const r=e.replace(/\\([ \t])/gu,"$1").replace(/\/+$/u,"")||"/";if(r.startsWith("/"))return Ap(r);if(r==="~"||r.startsWith("~/")){const n=t?gk(t):null;return n?Ap(`${n}/${r.slice(2)}`):null}return t?.startsWith("/")?Ap(`${t}/${r}`):null}function qd(e,t){const r=e.buffer.active.getLine(t-1),n=e.buffer.active.getLine(t);if(!r||!n||n.isWrapped)return null;const a=r.translateToString(!0).trimEnd(),l=n.translateToString(!0),c=V3(a).at(-1),h=l.match(hk);if(!c||c.endIndex!==a.length||!c.text.endsWith("/")||!h||/^[~./]/u.test(h[2]))return null;const p=h[2];if(!p.includes("/")&&!/^[^/:]+\.[\p{L}\p{N}_-]+$/u.test(p))return null;let g=r.length-1;for(;g>=0&&!(r.getCell(g)?.getChars()||"").trim();)g-=1;const x=h[1].length;let y=0;for(let I=x;I<n.length;I+=1){const E=n.getCell(I);if(E?.getWidth()!==0){if(!E||/[\s/:]/u.test(E.getChars()||" "))break;y+=E.getWidth()}}if(r.length-g-1>=Math.max(8,x+2,y))return null;const v=r.getCell(g),L=n.getCell(x);return!v||!L||v.isFgDefault()||L.isFgDefault()||v.getFgColorMode()!==L.getFgColorMode()||v.getFgColor()!==L.getFgColor()?null:x}function bk(e,t){const r=e.buffer.active;let n=t-1;if(!r.getLine(n))return null;for(;n>0&&(r.getLine(n)?.isWrapped||qd(e,n)!==null);)n-=1;let a=t-1;for(;a+1<r.length&&(r.getLine(a+1)?.isWrapped||qd(e,a+1)!==null);)a+=1;let l="";const c=[],h=[];for(let g=n;g<=a&&l.length<=2048;g+=1){const x=r.getLine(g);if(!x)break;const y=g>n?qd(e,g)??0:0;let A=x.length;if(g<a&&qd(e,g+1)!==null)for(;A>0&&!(x.getCell(A-1)?.getChars()||"").trim();)A-=1;for(let v=y;v<A;v+=1){const L=x.getCell(v);if(!L||L.getWidth()===0)continue;const I=L.getChars()||" ";l+=I;for(let E=0;E<I.length;E+=1)c.push({x:v+1,y:g+1}),h.push({x:v+Math.max(1,L.getWidth()),y:g+1})}}const p=l.trimEnd().length;return{text:l.slice(0,p),startPositions:c.slice(0,p),endPositions:h.slice(0,p)}}function yk(e,t){return{provideLinks(r,n){const a=bk(e,r);if(!a){n(void 0);return}const l=V3(a.text).map(c=>({text:c.text,range:{start:a.startPositions[c.startIndex]??{x:c.startIndex+1,y:r},end:a.endPositions[c.endIndex-1]??{x:c.endIndex,y:r}},activate:()=>c.line===void 0?t(c.text):t(c.text,c.line)}));n(l.length>0?l:void 0)}}}function P2(e,t){if(!e||e.lines.length===0||!Number.isFinite(t)||t<=0)return 0;const r=Math.floor(t),n=Number.isFinite(e.lines.maxLength)&&e.lines.maxLength>0?Math.floor(e.lines.maxLength):null;let a=0;if(n!==null){const p=Math.max(0,n-r);e.ybase>p&&(e.ybase=p,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,p)),a++)}let l=Math.max(0,Math.floor(e.ybase)+r),c=n===null?l:Math.min(l,n),h=Math.max(0,c-e.lines.length);if(h>r){const p=Math.max(0,e.lines.length-r);e.ybase>p&&(e.ybase=p,Number.isFinite(e.ydisp)&&(e.ydisp=Math.min(e.ydisp,p)),a++),l=Math.max(0,Math.floor(e.ybase)+r),c=n===null?l:Math.min(l,n),h=Math.max(0,c-e.lines.length)}for(let p=0;p<h;p++){const g=e.lines.length;if(e.lines.push(e.getBlankLine(void 0)),e.lines.length<=g)break;a++}return a}function O2(e,t=e.rows){const n=e._core?._bufferService?.buffers;return n?P2(n.normal,t)+P2(n.alt,t):0}function Yd(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function vk(e,t,r){const n=Yd(e.fontBoundingBoxAscent)+Yd(e.fontBoundingBoxDescent),a=Yd(e.actualBoundingBoxAscent)+Yd(e.actualBoundingBoxDescent);return Math.max(1,Math.floor(Math.ceil(n||a||t)*r))}const fc=8,Zd=36,F2=10,wk=1.08,Ak=1.16,Kd=6,Tk=.94,Sk=.08,Ck=.12,_k=88,Lk=36,kk=10,Ik=14,Ek=52;function tu(e){return e?e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,""):""}const Nk=80,Rk=8;function Xd(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function Mk(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function Dk(e){try{const t=atob(e),r=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder("utf-8").decode(r)}catch{return null}}function jk(e){const t="\x1B]52;";let r=0,n="";for(;r<e.length;){const a=e.indexOf(t,r);if(a===-1)return n+=e.slice(r),{cleaned:n,remainder:""};n+=e.slice(r,a);let l=-1,c=1;for(let g=a+t.length;g<e.length;g+=1){const x=e.charCodeAt(g);if(x===7){l=g,c=1;break}if(x===27&&g+1<e.length&&e[g+1]==="\\"){l=g,c=2;break}}if(l===-1)return{cleaned:n,remainder:e.slice(a)};const h=e.slice(a+t.length,l),p=h.indexOf(";");if(p>=0){const g=h.slice(p+1);if(g&&g!=="?"){const x=Dk(g);x!==null&&navigator.clipboard?.writeText(x).catch(()=>{})}}r=l+c}return{cleaned:n,remainder:""}}function Bk(e){if(typeof window>"u")return null;const t=[e,...Array.from(e.querySelectorAll("*"))];let r=null;for(const n of t){const l=window.getComputedStyle(n).overflowY;if(!(l!=="auto"&&l!=="scroll")){if(n.scrollHeight-n.clientHeight>2)return n;r||(r=n)}}return r}const Qk=new Set(["visibility","bfcache","online"]),Pk=5e5,Ok=1e5,ru=260,nu=140,$2=80;function Fk(e){return!e}let Zc=null;const $k=[{font:'400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'400 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'700 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'400 13px "Termdock Star Symbol"',text:"✦✧"},{font:'400 13px "Noto Sans Symbols 2"',text:"⏺⏸⏹✓✗"}],Uk=()=>{if(Zc)return Zc;if(typeof document>"u"||!("fonts"in document))return Zc=Promise.resolve(),Zc;const e=document.fonts;return Zc=Promise.allSettled($k.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),Zc},U2=e=>{if((!e||e.includes("var("))&&typeof window<"u"){const t=getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim();if(t)return t}return e};function z2(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function pc(e,t,r){const n=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(n||t*r))}function zk(e){return{background:e.background,foreground:e.foreground,cursor:e.cursor||e.foreground,cursorAccent:e.cursorAccent||e.background,selectionBackground:e.selectionBackground||"rgba(0, 0, 0, 0.3)",selectionForeground:e.selectionForeground||e.foreground,black:e.black||"#6F6E69",red:e.red||"#AF3029",green:e.green||"#66800B",yellow:e.yellow||"#AD8301",blue:e.blue||"#205EA6",magenta:e.magenta||"#A02F6F",cyan:e.cyan||"#24837B",white:e.white||"#CECDC3",brightBlack:e.brightBlack||"#6F6E69",brightRed:e.brightRed||"#D14D41",brightGreen:e.brightGreen||"#879A39",brightYellow:e.brightYellow||"#D0A215",brightBlue:e.brightBlue||"#4385BE",brightMagenta:e.brightMagenta||"#CE5D97",brightCyan:e.brightCyan||"#3AA99F",brightWhite:e.brightWhite||"#FFFCF0"}}const H2=new Map;function Hk(e,t,r,n,a){if(typeof window>"u"||typeof document>"u")return null;const l=e.getBoundingClientRect();if(l.width<24||l.height<24)return null;const c=window.devicePixelRatio||1,h=`${r}::${n}::${a}::${c}::${t}`;let p=H2.get(h);if(!p)try{const A=document.createElement("canvas").getContext("2d");if(!A)return null;A.font=`${r}px ${t}`;const v=A.measureText("M"),I=(Math.floor(v.width*c)+Math.round(n))/c,E=vk(v,r,a);I>=1&&E>=1&&(p={cellWidth:I,cellHeight:E},H2.set(h,p))}catch{return null}if(!p)return null;const g=Math.max(2,Math.floor(l.width/p.cellWidth)),x=Math.max(2,Math.floor(l.height/p.cellHeight));return!Number.isFinite(g)||!Number.isFinite(x)?null:{cols:g,rows:x}}async function W2(e){if(!e)return!1;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return t.remove(),r}catch{return!1}}}function Wk(e){const t=e.buffer.active,r=t.viewportY,n=Math.min(t.length,r+e.rows),a=[];for(let l=r;l<n;l+=1){const c=t.getLine(l);c&&a.push(c.translateToString(!0))}return a.join(`
64
+ `).replace(/\s+$/g,"")}function su(e,t,r){const n=Lc(e);if(!n)return null;const a=Math.max(0,Math.min(e.cols-1,Math.floor((t-n.originLeft)/n.cellW))),l=Math.max(0,Math.min(e.rows-1,Math.floor((r-n.originTop)/n.cellH)));return{col:a,row:e.buffer.active.viewportY+l}}function Tp(e,t,r){const n=t.row*e.cols+t.col,a=r.row*e.cols+r.col;if(n===a)return e.clearSelection(),!1;const l=Math.min(n,a),c=Math.max(n,a)+1,h=l%e.cols,p=Math.floor(l/e.cols);return e.select(h,p,c-l),!0}function G2(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function Gk(e,t,r,n,a=!0){if(typeof window>"u")return{left:0,top:0};const l=window.visualViewport,c=l?.offsetLeft??0,h=l?.offsetTop??0,p=l?.width??window.innerWidth,g=l?.height??window.innerHeight,x=G2("--safe-top-inset"),y=G2("--safe-bottom-inset"),A=n?yL(n.terminal,n.anchor,n.focus):null,v=[];let L;if(a&&v.push({left:e-32,top:t-32,right:e+32,bottom:t+32}),n){const E=Lc(n.terminal),{start:R,end:P}=Gh(n.anchor,n.focus,n.terminal.cols),Q=Sh(n.terminal,R),$=Sh(n.terminal,P);if(Q&&v.push({left:Q.x-24,top:Q.y-48,right:Q.x+24,bottom:Q.y+4}),$&&E){const W=$.y+E.cellH;v.push({left:$.x-24,top:W-4,right:$.x+24,bottom:W+48})}if(A){const W=n.anchor.row*n.terminal.cols+n.anchor.col,B=n.focus.row*n.terminal.cols+n.focus.col,q=W<=B,ne=A.right-A.left,fe=n.anchor.row===n.focus.row?q?A.left+ne*.25:A.right-ne*.25:(A.left+A.right)/2,X=Sh(n.terminal,n.focus),Qe=X&&E?X.y+E.cellH/2:t;L={vertical:n.focus.row<n.anchor.row?"below":"above",alignX:fe,focusX:X?.x??e,focusY:Qe}}}const I=vL({clientX:e,clientY:t,viewport:{left:c,top:h+x,right:c+p,bottom:h+g-y},terminal:r,width:_k,height:Lk,margin:kk,fingerGap:Ik,selection:A,avoid:v,preference:L,selectionGap:Ek});return{left:I.left-r.left,top:I.top-r.top}}const q3=S.forwardRef(({sessionKey:e,sessionId:t,isLayoutVisible:r=!0,chunks:n,onInput:a,onResize:l,onFlowControl:c,onTmuxScroll:h,tmuxScrollSensitivity:p=.55,onDoubleTap:g,onInputFocusChange:x,onMobileLongPressCopyResult:y,onMobilePasteResult:A,onReadyChange:v,onSizeSynchronizedChange:L,onWritesSettled:I,onWriteProgress:E,onCursorPositionChange:R,onDirectoryLinkActivate:P,terminalSettings:Q,theme:$,className:W,enableTouchScroll:B,mobileLongPressMode:q="arrows",autoFocus:ne=!0,cursorVisible:Be=!0,suppressSmoothScroll:fe=!1},X)=>{const{t:Qe}=Hr(),Pe=S.useRef(null),ue=S.useRef(null),Ce=S.useRef(null),tt=S.useRef(null),we=S.useRef(null),ce=S.useRef(fe);ce.current=fe;const $e=S.useRef(null),ke=S.useRef(a),se=S.useRef(l),je=S.useRef(x),de=S.useRef(c),Oe=S.useRef(v);Oe.current=v;const Ee=S.useRef(L);Ee.current=L;const _e=S.useRef(I);_e.current=I;const re=S.useRef(E);re.current=E;const Fe=S.useRef(R);Fe.current=R;const wt=S.useRef(P);wt.current=P;const Xe=S.useRef(Q.rendererMode),ee=S.useRef(""),Ue=S.useRef(0),Le=S.useRef(!1),te=S.useRef(null),ye=S.useRef(0),ot=S.useRef(0),le=S.useRef(!1),xe=S.useRef(null),Ne=S.useRef(null),yt=S.useRef(null),gt=S.useRef(!1),At=S.useRef(null),Ft=S.useRef(()=>{}),Z=S.useRef(null),Ge=S.useRef(null),pt=S.useRef(void 0),Pt=S.useRef(null),hr=S.useRef(!1),Zt=S.useRef(0),_r=S.useRef(""),ae=S.useRef(null),ze=S.useRef(null),Je=S.useRef(!1),Rt=S.useRef(typeof window<"u"?window.devicePixelRatio:1),Mt=S.useRef(!1),ir=S.useRef(!1),Ut=S.useRef(null),We=S.useRef(""),br=S.useRef(0),Ze=S.useRef(null),Dt=S.useRef(null),nt=S.useRef(null),_t=S.useRef(0),Qr=S.useRef(0),yr=S.useRef(0),Nt=S.useRef(null),Nn=S.useRef(0),Zr=S.useRef(0),lt=S.useRef(!1),gr=S.useRef(0),[,Pr]=S.useReducer(k=>k+1,0),[be,Er]=S.useReducer(k=>k+1,0),[at,en]=S.useState("loading"),[Te,Lt]=S.useState(null),[Y,st]=S.useState(null);S.useEffect(()=>{const k=D=>{(D.target instanceof Element?D.target.closest("[data-termdock-terminal-dropzone]"):null)?.dataset.termdockTerminalDropzone===e&&st(String(D.detail))};return window.addEventListener("termdock:file-drop-error",k),()=>window.removeEventListener("termdock:file-drop-error",k)},[e]);const xt=S.useMemo(()=>p0("terminal"),[]),[Gt,Gr]=S.useState(!0),[Fr,ur]=S.useState(!1);S.useEffect(()=>{if(!Gt&&at!=="loading"){ur(!1);return}const k=window.setTimeout(()=>ur(!0),160);return()=>window.clearTimeout(k)},[Gt,at]);const[tn,on]=S.useState(!1),[Xr,Wr]=S.useState({visible:!1,activeDir:""}),[$r,Ur]=S.useState(null),Cn=S.useRef(null),Rn=S.useRef(!1),hn=S.useRef({active:!1,anchor:null,focus:null,dragging:null}),[Vr,ys]=S.useState(null),[cn,Vt]=S.useState({x:0,y:0,cellW:8,cellH:17,cursorX:0}),hs=S.useRef(cn);hs.current=cn;const Sn=S.useRef(null),[rs,qr]=S.useState({active:!1,text:""}),_n=S.useRef(null),un=S.useRef(null);ke.current=a,se.current=l,je.current=x,de.current=c,Xe.current=Q.rendererMode;const Bn=S.useRef(ne);Bn.current=ne;const Nr=S.useRef(Be);Nr.current=Be;const zr=S.useRef(B);zr.current=B;const wn=S.useRef(r);wn.current=r;const et=Fk(!!h),{rendererMode:kt,fontFamily:Bt,fontSize:zt,fontWeight:gn,fontWeightBold:lr,letterSpacing:yn,lineHeight:ar,minimumContrastRatio:Ln,drawBoldTextInBrightColors:rn,unicodeVersion:$n,customGlyphs:ns,rescaleOverlappingGlyphs:vs,fontLigatures:fs,enableImages:Gn,smoothScrolling:fn}=Q,Un=kt==="webgl",xr=S.useCallback(()=>{Cn.current!==null&&(clearTimeout(Cn.current),Cn.current=null),Ur(null)},[]),z=S.useCallback((k,D)=>{Cn.current!==null&&(clearTimeout(Cn.current),Cn.current=null),Rn.current=!1,Ur(k),!D?.persistent&&(Cn.current=setTimeout(()=>{Cn.current=null,Ur(null)},3e3))},[]);S.useEffect(()=>{if(!$r)return;const k=()=>{hn.current.active||xr()},D=()=>xr();return window.addEventListener("scroll",k,!0),window.addEventListener("resize",D),document.addEventListener("visibilitychange",D),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",D),document.removeEventListener("visibilitychange",D)}},[xr,$r]),S.useEffect(()=>()=>{Cn.current!==null&&(clearTimeout(Cn.current),Cn.current=null)},[]);const ge=S.useCallback(()=>{const k=Ce.current,D=Pe.current,F=hn.current;if(!k||!D||!F.active||!F.anchor||!F.focus){ys(null);return}const H=D.getBoundingClientRect(),He=Lc(k)?.cellH??16,{start:Ie,end:ft}=Gh(F.anchor,F.focus,k.cols),ut=F.dragging==="start"?F.focus:F.dragging==="end"?F.anchor:Ie,Yt=F.dragging==="end"?F.focus:F.dragging==="start"?F.anchor:ft,Ar=(ln,Qn)=>{const In=Sh(k,ln);return In?{left:In.x-H.left,top:Qn?In.y-H.top:In.y+He-H.top}:null};ys({start:Ar(ut,!0),end:Ar(Yt,!1)})},[]),Ye=S.useCallback(k=>{const D=Ce.current,F=Pe.current,H=hn.current;if(!D||!F||!H.active||!H.anchor||!H.focus)return;if(H.dragging){xr();return}const He=F.getBoundingClientRect(),Ie={x:(He.left+He.right)/2,y:(He.top+He.bottom)/2};z(Gk(k?.x??Ie.x,k?.y??Ie.y,He,{terminal:D,anchor:H.anchor,focus:H.focus},k!==void 0),{persistent:!0})},[xr,z]),ct=S.useCallback(()=>{const k=hn.current;k.active=!1,k.anchor=null,k.focus=null,k.dragging=null,ys(null),xr()},[xr]);S.useEffect(()=>{if(!Vr)return;const k=Ce.current;if(!k)return;const D=k.onScroll(()=>{ge(),Ye()}),F=k.onResize(()=>ct());return()=>{D.dispose(),F.dispose()}},[Vr,ge,Ye,ct]),S.useEffect(()=>{B||je.current?.(!1)},[B]);const it=S.useCallback((k,D,F)=>{const H=(F.element?.offsetWidth||0)/F.cols||8,He=(F.element?.offsetHeight||0)/F.rows||16,Ie=Math.max(1,Math.min(F.cols,Math.floor(k/H)+1)),ft=Math.max(1,Math.min(F.rows,Math.floor(D/He)+1));return{x:Ie,y:ft}},[]),bt=S.useCallback((k,D,F)=>{const H=Ce.current;if(!H)return!1;const He=k>0?-1:1;if(H.modes?.mouseTrackingMode!=="none"){let Ie,ft;if(D!==void 0&&F!==void 0){const Ar=it(D,F,H);Ie=Ar.x,ft=Ar.y}else Ie=H.buffer.active.cursorX+1,ft=H.buffer.active.cursorY+1;const Yt=`\x1B[<${He>0?64:65};${Ie};${ft}M`;return ke.current(Yt),!0}if(H.buffer.active.type==="alternate"){const Ie=He>0?"\x1B[A":"\x1B[B";return ke.current(Ie),!0}return null},[it]),Ot=S.useCallback(k=>{const D=Ce.current;if(!D)return!1;const F=pc(Ce.current,zt,ar),H=Zt.current+k,He=Math.trunc(H/F);return Zt.current=H-He*F,He!==0?(D.scrollLines(He),!0):!1},[zt,ar]),qt=S.useCallback(k=>{if(!Ce.current)return!1;const H=pc(Ce.current,zt,ar)/Math.max(.1,p),He=Zt.current+k;let Ie=Math.trunc(He/H);if(Zt.current=He-Ie*H,Ie===0&&Math.abs(He)>=H/3&&(Ie=He>0?1:-1,Zt.current=0),Ie===0)return!1;const ft=Ie>0?"down":"up",ut=Math.max(1,Math.min(Math.abs(Ie),10));return h(ft,ut),!0},[zt,ar,h,p]),dt=S.useRef(bt);dt.current=bt;const nr=S.useRef(Ot);nr.current=Ot;const Lr=S.useRef(qt);Lr.current=qt;const vr=S.useRef(h);vr.current=h;const $t=S.useRef({pointerId:null,tmuxActiveAtDown:!1});S.useEffect(()=>{if(!B)return;const k=Pe.current;if(!k)return;const D=H=>{H.pointerType==="touch"&&($t.current.pointerId=H.pointerId,$t.current.tmuxActiveAtDown=!!vr.current)},F=H=>{H.pointerType==="touch"&&$t.current.pointerId===H.pointerId&&($t.current.pointerId=null,$t.current.tmuxActiveAtDown=!1)};return k.addEventListener("pointerdown",D,{capture:!0,passive:!0}),k.addEventListener("pointerup",F,{capture:!0,passive:!0}),k.addEventListener("pointercancel",F,{capture:!0,passive:!0}),()=>{k.removeEventListener("pointerdown",D,!0),k.removeEventListener("pointerup",F,!0),k.removeEventListener("pointercancel",F,!0)}},[B]);const rt=S.useCallback(()=>{if(lt.current)return!1;const k=$t.current;return k.pointerId!==null?!k.tmuxActiveAtDown:!vr.current},[]),jt=S.useCallback((k,D,F)=>{const H=dt.current(k,D,F);return H!==null?H:vr.current?Lr.current(k):nr.current(k)},[]),U=S.useCallback((k,D)=>{if(performance.now()<=Zr.current){Zr.current=0;return}const F=Ce.current;if(F&&F.modes?.mouseTrackingMode!=="none"){const H=it(k,D,F),He=H.x,Ie=H.y,ft=`\x1B[<0;${He};${Ie}M`,ut=`\x1B[<0;${He};${Ie}m`;ke.current(ft),ke.current(ut)}},[it]),G=S.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),he=S.useCallback((k=700)=>{Nt.current=null,Nn.current=G()+k},[G]),Me=S.useCallback(()=>zr.current&&G()<=Nn.current,[G]),Qt=S.useCallback(()=>{const k=Ge.current;return!k||typeof document>"u"?!1:document.activeElement===k},[]),It=S.useCallback(()=>{if(typeof window>"u")return!1;const k=ut=>{if(typeof document>"u")return 0;const Yt=Number.parseFloat(document.documentElement.style.getPropertyValue(ut)||"0");return Number.isFinite(Yt)?Yt:0},D=k("--kb-height");if(D>0)return D>=$2;const F=window.visualViewport;if(!F)return!1;const H=k("--app-base-vh")||window.innerHeight,He=k("--safe-bottom-inset"),Ie=F.height+F.offsetTop;return Math.max(0,Math.round(H-Ie-He))>=$2},[]),tr=S.useCallback(()=>{Ze.current!==null&&(clearTimeout(Ze.current),Ze.current=null),Dt.current=null},[]),fr=S.useCallback(k=>{const D=Ce.current;let F="";for(const H of k)H.left&&(F+=(D?Xd(D,"D"):"\x1B[D").repeat(H.left)),H.right&&(F+=(D?Xd(D,"C"):"\x1B[C").repeat(H.right)),H.backspace&&(F+="".repeat(H.backspace)),H.insert&&(F+=H.insert);return F},[]),jr=S.useCallback(k=>{const D=k.value,F=tu(D),H=We.current;if(!(zr.current&&!F.includes("\r")&&!H.includes("\r"))){if(F===H)return;let Ar=0;for(;Ar<H.length&&Ar<F.length&&H[Ar]===F[Ar];)Ar++;const ln=H.length-Ar;ln>0&&ke.current("".repeat(ln));const Qn=F.slice(Ar);if(Qn){try{Ce.current?.clearSelection()}catch{}ke.current(Qn)}We.current=F,br.current=Array.from(F).length;return}const Ie=j2(k),{ops:ft,cursor:ut}=sk(H,F,br.current,Ie),Yt=fr(ft);if(Yt){if(ft.some(Ar=>Ar.insert))try{Ce.current?.clearSelection()}catch{}ke.current(Yt)}We.current=F,br.current=ut},[fr]),kn=S.useCallback((k,D)=>{const F=k.value,H=tu(F),He=We.current;if(H===He){tr();return}let Ie=0;for(;Ie<He.length&&Ie<H.length&&He[Ie]===H[Ie];)Ie++;const ft=He.length-Ie;if(B&&!D?.immediate&&ft>=Rk){Dt.current=k,Ze.current!==null&&clearTimeout(Ze.current),Ze.current=setTimeout(()=>{Ze.current=null;const Yt=Dt.current;Dt.current=null,Yt&&jr(Yt)},Nk);return}tr(),jr(k)},[tr,B,jr]),O=S.useCallback(k=>{kn(k,{immediate:!0}),ke.current("\r"),k.value="",We.current="",br.current=0},[kn]),Ae=S.useCallback((k,D,F)=>{if(!k)return;tr();const H=D??Ge.current;H&&(H.value=""),We.current="",br.current=0;try{Ce.current?.clearSelection()}catch{}if(ct(),F?.paste&&/[\r\n]/.test(k)){const He=F.submitAfterPaste??k.endsWith("\r"),Ie=SL(k,He);return ke.current(Ie,{skipModifierTransform:!0,consumeModifier:F?.consumeModifier,targeted:F?.targeted})}return ke.current(k,{skipModifierTransform:!0,consumeModifier:F?.consumeModifier,targeted:F?.targeted})},[tr]),Re=S.useCallback((k,D)=>{const F=tu(k);return F?(st(null),Wf(F)||(Ae(F,D,{paste:!0,submitAfterPaste:!1}),xr()),!0):!1},[xr,Ae]);S.useEffect(()=>s8(k=>{if(k.sessionKey!==e||k.paths.length===0)return;const D=k.paths.map(bc).join(" ");Ae(`${D} `);try{Ge.current?.focus({preventScroll:!0})}catch{}}),[Ae,e]);const mt=S.useCallback(async(k,D)=>{st(null);try{const F=await i3(k);return Wf(`${bc(F)} `)||(Ae(`${bc(F)} `,D),xr()),!0}catch(F){return st(F instanceof Error?F.message:"Image upload failed"),!1}},[xr,Ae]),Ct=S.useCallback(async(k,D)=>{st(null);try{const F=await l3(k);if(!F.length)return!1;const H=`${F.map(bc).join(" ")} `;return Wf(H)||(Ae(H,D),xr()),!0}catch(F){return st(F instanceof Error?F.message:"File upload failed"),!1}},[xr,Ae]),or=S.useCallback(async(k,D)=>{st(null);try{const F=Ou()?.targetPeerId;let H;if(ao()?.readClipboardFiles){try{const{files:ft,paths:ut}=await o3();if(ut.length)return Re(`${ut.map(bc).join(" ")} `,k);if(ft.length)return Ct(ft,k)}catch(ft){if(ft instanceof Mu)throw ft;H=ft}if(Ou()?.targetPeerId!==F)throw new Error("目标服务已切换,请重新粘贴")}if(D?.files.length){const ft=D.files[0];return D.files.length===1&&ft.type.startsWith("image/")?mt(ft,k):Ct(D.files,k)}if(D?.text)return Re(D.text,k);if(!ao()?.readClipboardImage){if(typeof navigator.clipboard?.read=="function"){const ft=await navigator.clipboard.read(),ut=await a3({read:async()=>ft});if(ut.length)return Ct(ut,k);const Yt=await Uh({read:async()=>ft});if(Yt)return mt(Yt,k);for(const Ar of ft){if(!Ar.types.includes("text/plain"))continue;const ln=await(await Ar.getType("text/plain")).text();return Re(ln,k)}return st("剪贴板未提供可读取的文字、图片或视频;视频可通过文件按钮选择上传。"),!1}return navigator.clipboard?.readText?Re(await navigator.clipboard.readText(),k):!1}const He=await Uh(navigator.clipboard);if(He)return mt(He,k);if(!navigator.clipboard?.readText){if(H)throw H;return!1}const Ie=await navigator.clipboard.readText();if(!Ie&&H)throw H;return Re(Ie,k)}catch(F){return st(F instanceof Error?F.message:"Clipboard read failed"),!1}},[Ct,mt,Re]),Jt=S.useCallback(k=>{if(Sn.current&&!k?.repositionFrozen)return null;const D=Ce.current;if(!D||!D.element)return null;const F=Lc(D),He=D.element.querySelector(".xterm-screen")??D.element,Ie=He.getBoundingClientRect(),ft=F?.cellW??(Ie.width>0&&D.cols>0?Ie.width/D.cols:8),ut=F?.cellH??(Ie.height>0&&D.rows>0?Ie.height/D.rows:17),Yt=Ge.current;let Ar=pt.current;Yt&&(Ar===void 0||Ar!==null&&(!Ar.isConnected||!Ar.contains(Yt)))&&(Ar=AL(Yt),pt.current=Ar);const ln=D.buffer.active,Qn=ln.cursorX*ft,In=ln.cursorY*ut,is=TL(He,Ar??null,Qn,In),Br=Math.round(is.x),xn=Math.round(is.y),ls={x:Br,y:xn,cellW:ft,cellH:ut,cursorX:ln.cursorX};return hs.current=ls,Sn.current&&k?.repositionFrozen&&(Sn.current={...ls}),Vt(as=>Math.abs(as.x-Br)<.5&&Math.abs(as.y-xn)<.5&&Math.abs(as.cellW-ft)<.5&&Math.abs(as.cellH-ut)<.5&&as.cursorX===ln.cursorX?as:ls),ls},[]),Ht=S.useRef(Jt);Ht.current=Jt,S.useEffect(()=>{if(!B)return;let k=null,D=null;const F=()=>{k!==null&&window.cancelAnimationFrame(k),D!==null&&window.cancelAnimationFrame(D),k=window.requestAnimationFrame(()=>{k=null,D=window.requestAnimationFrame(()=>{D=null,Ht.current({repositionFrozen:!0})})})};return window.visualViewport?.addEventListener("resize",F),window.visualViewport?.addEventListener("scroll",F),document.addEventListener("termdock:viewport-keyboard-change",F),()=>{k!==null&&window.cancelAnimationFrame(k),D!==null&&window.cancelAnimationFrame(D),window.visualViewport?.removeEventListener("resize",F),window.visualViewport?.removeEventListener("scroll",F),document.removeEventListener("termdock:viewport-keyboard-change",F)}},[B]);const Or=S.useCallback(k=>{let D=0;for(const F of k){const H=F.codePointAt(0)??0,He=H>=4352&&H<=4447||H>=11904&&H<=12350||H>=12353&&H<=13311||H>=13312&&H<=19903||H>=19968&&H<=40959||H>=40960&&H<=42191||H>=44032&&H<=55203||H>=63744&&H<=64255||H>=65072&&H<=65103||H>=65280&&H<=65376||H>=65504&&H<=65510||H>=127744&&H<=129791;D+=He?2:1}return D},[]),Mn=S.useCallback(k=>{const D=Ce.current,{cellW:F,cellH:H}=cn;if(!D||!k)return{width:Math.max(1,Math.round(F)),height:Math.max(1,Math.round(H)),whiteSpace:"pre"};const Ie=Sn.current?.cursorX??D.buffer.active.cursorX,ft=Math.max(1,D.cols),ut=Math.max(1,Or(k)),Yt=Math.max(1,ft-Ie);if(ut<=Yt)return{width:Math.max(1,Math.round(ut*F)),height:Math.max(1,Math.round(H)),whiteSpace:"pre"};const Ar=ut-Yt,Qn=1+Math.ceil(Ar/ft);return{width:Math.max(1,Math.round(Yt*F)),height:Math.max(1,Math.round(Qn*H)),whiteSpace:"pre-wrap"}},[cn,Or]),ws=S.useCallback(()=>{pt.current=void 0;const k=Ht.current();Sn.current={...k??hs.current}},[]),Pi=S.useCallback(()=>{Sn.current=null},[]),Oi=S.useCallback(k=>{if(!Mt.current&&Sn.current===null)return!1;if(Mt.current=!1,Sn.current=null,tr(),Ut.current!==null&&(clearTimeout(Ut.current),Ut.current=null),ir.current=!1,k){k.value=We.current;try{k.setSelectionRange(k.value.length,k.value.length)}catch{}}return qr(D=>D.active||D.text?{active:!1,text:""}:D),!0},[tr]),gs=S.useCallback((k,D)=>{const F=Ge.current;if(F)try{F.removeAttribute("readonly");const He=typeof document<"u"&&document.activeElement===F&&!It(),Ie=G(),ft=Ie-gr.current;gr.current=Ie,He&&ft>600?(F.blur(),F.removeAttribute("readonly"),F.focus(),gr.current=G()):F.focus()}catch{}},[It,G]),Ks=S.useCallback(k=>{Qr.current=G()+k},[G]),hi=S.useCallback(()=>B?G()<=Qr.current:!1,[B,G]),Is=S.useCallback(k=>{Ks(k),yr.current=G()},[Ks,G]),As=S.useCallback(()=>{B&&Ge.current?.removeAttribute("readonly")},[B]),zn=S.useCallback(k=>k instanceof HTMLElement&&(k.closest('[data-terminal-copy-popover="true"]')!==null||k.closest('[data-mobile-copy-button="true"]')!==null||k.closest("[data-selection-handle]")!==null),[]),na=S.useCallback(k=>{if(As(),Is(ru),!B||k.pointerType!=="touch"){Nt.current=null;return}const D=k.target;if(zn(D)){he();return}$r&&!(D instanceof HTMLElement&&D.closest('[data-terminal-copy-popover="true"]'))&&xr(),Nt.current={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,moved:!1}},[xr,B,Is,zn,$r,As,he]),Ra=S.useCallback(k=>{Is(ru);const D=Nt.current;!D||D.pointerId!==k.pointerId||Math.hypot(k.clientX-D.startX,k.clientY-D.startY)>12&&(D.moved=!0)},[Is]),Xs=S.useCallback(k=>{Is(nu);const D=Nt.current;Nt.current=null,!(!B||k.pointerType!=="touch")&&(!D||D.pointerId!==k.pointerId||D.moved||Me()||gs(k.clientX,k.clientY))},[B,Is,gs,Me]),uo=S.useCallback(()=>{Nt.current=null,Is(nu)},[Is]),Es=S.useMemo(()=>({enableKinetic:!0}),[]),Vn=S.useRef(()=>!1),Ms=S.useRef(gs);Ms.current=gs;const ho=S.useCallback((k,D)=>{Me()||Ms.current(k,D)},[Me]),pa=S.useRef(g);pa.current=g;const Fi=S.useRef(y);Fi.current=y;const ma=S.useRef(A);ma.current=A;const Ma=S.useCallback(()=>{if(Rn.current)return;Rn.current=!0,he();const k=Ce.current,D=k?.hasSelection()?k.getSelection():"";try{k?.clearSelection()}catch{}ki.flushSync(()=>{ct()}),(async()=>{const F=await W2(D);Fi.current?.(F)})()},[ct,he]),$i=S.useCallback(k=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:k}}))},[]),{setupTouchScroll:fo,stopAllScroll:fi}=KL(Pe,{...Es,shouldCaptureTouch:Vn.current,canStartScrollGesture:rt,onScroll:jt,onScrollWithCoords:jt,onClickWithCoords:U,onTap:ho,onClaimChange:$i,tapThreshold:12,gestureName:`normal-scroll:${e}`});S.useEffect(()=>{if(!B)return;Ge.current?.setAttribute("readonly","");const k=fo();return()=>{k()}},[B,fo]),S.useEffect(()=>{if(!B)return;let k=It();const D=()=>{const F=It();if(k&&!F){const H=Ge.current;H&&typeof document<"u"&&document.activeElement===H&&(H.setAttribute("readonly",""),H.blur())}k=F};return window.visualViewport?.addEventListener("resize",D),window.visualViewport?.addEventListener("scroll",D),document.addEventListener("termdock:viewport-keyboard-change",D),()=>{window.visualViewport?.removeEventListener("resize",D),window.visualViewport?.removeEventListener("scroll",D),document.removeEventListener("termdock:viewport-keyboard-change",D)}},[B,It]),S.useEffect(()=>{if(!B)return;const k=Pe.current;if(!k)return;const D=H=>{const Ie=H.sourceCapabilities?.firesTouchEvents===!0,ft=G()-yr.current<=1200;return!Ie&&!ft?!1:k.contains(H.target)},F=H=>{D(H)&&(H.cancelable&&H.preventDefault(),H.stopImmediatePropagation(),H.stopPropagation())};return k.addEventListener("mousedown",F,{capture:!0,passive:!1}),k.addEventListener("mouseup",F,{capture:!0,passive:!1}),k.addEventListener("click",F,{capture:!0,passive:!1}),document.addEventListener("mouseup",F,{capture:!0,passive:!1}),()=>{k.removeEventListener("mousedown",F,!0),k.removeEventListener("mouseup",F,!0),k.removeEventListener("click",F,!0),document.removeEventListener("mouseup",F,!0)}},[B,G]);const Ds=S.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),pn=S.useCallback(()=>{const k=Ds.current;k.rafId!==null&&(cancelAnimationFrame(k.rafId),k.rafId=null)},[]),Da=S.useCallback((k,D,F)=>{const H=Ce.current;if(!H||!H.element||!H.cols||!H.rows)return null;const He=Ds.current,Ie=H.element.getBoundingClientRect(),ft=D??He.lastX??Ie.left+Ie.width/2,ut=F??He.lastY??Ie.top+Ie.height/2,Yt=ft-Ie.left,Ar=ut-Ie.top,ln=H.element.offsetWidth/H.cols||8,Qn=H.element.offsetHeight/H.rows||16,In=Math.max(1,Math.min(H.cols,Math.floor(Yt/ln)+1)),is=Math.max(1,Math.min(H.rows,Math.floor(Ar/Qn)+1));return`\x1B[<${k==="up"?64:65};${In};${is}M`},[]),ss=S.useCallback((k,D,F,H)=>{if(D<=0)return;const He=Da(k,F,H);He&&ke.current(D===1?He:He.repeat(D))},[Da]),ga=S.useRef(ss);ga.current=ss;const Ns=S.useRef(()=>{}),cl=S.useCallback(()=>{const D=pc(Ce.current,zt,ar)/Math.max(.1,p),F=1+Ds.current.instantSpeed*.1;return D/Math.min(6,F)},[zt,ar,p]),pi=S.useCallback(()=>{const k=Ds.current;k.rafId=null;const D=cl();let F=0,H=0;for(;F+H<Kd&&k.remainder>=D;)k.remainder-=D,H++;for(;F+H<Kd&&k.remainder<=-D;)k.remainder+=D,F++;if(H>0&&ss("down",H),F>0&&ss("up",F),F+H>0)k.rafId=requestAnimationFrame(pi);else if(k.pointerId!==null&&Math.abs(k.remainder)>=D/3){const Ie=k.remainder>0?"down":"up";k.remainder=0,ss(Ie,1),k.rafId=requestAnimationFrame(pi)}},[cl,ss]),ja=S.useCallback(()=>{const k=Ds.current;k.rafId===null&&typeof requestAnimationFrame<"u"&&(k.rafId=requestAnimationFrame(pi))},[pi]),po=S.useCallback(k=>{if(k.pointerType!=="touch")return!1;pn();const D=Ds.current;return D.pointerId=k.pointerId,D.lastX=k.clientX,D.lastY=k.clientY,D.startX=k.clientX,D.startY=k.clientY,D.gestureAxis=null,D.remainder=0,D.velocity=0,D.instantSpeed=0,D.didScroll=!1,!1},[pn]),Il=S.useCallback((k,D)=>{if(lt.current)return D?"release":"neutral";if(performance.now()<=Zr.current)return"neutral";const F=Ds.current;if(k.pointerType!=="touch"||k.pointerId!==F.pointerId||F.lastY==null)return"neutral";if(F.gestureAxis===null&&F.startX!==null&&F.startY!==null){const Ie=Math.abs(k.clientX-F.startX),ft=Math.abs(k.clientY-F.startY);if(Ie>F2||ft>F2){if(Ie>ft*wk)return F.gestureAxis="x","release";ft>Ie*Ak&&(F.gestureAxis="y")}}if(F.gestureAxis==="x")return F.lastX=k.clientX,F.lastY=k.clientY,"release";if(F.gestureAxis===null)return F.lastX=k.clientX,F.lastY=k.clientY,"neutral";const H=k.clientY-F.lastY;F.lastX=k.clientX,F.lastY=k.clientY;const He=-H;if(F.remainder+=He,F.instantSpeed=Math.abs(He),F.velocity=F.velocity*.45+He*.55,D){const ft=pc(Ce.current,zt,ar)/Math.max(.1,p);Math.abs(F.remainder)>=ft/3&&(F.didScroll=!0,ja())}return"claim"},[zt,ar,p,ja]),ul=S.useCallback(k=>{const D=Ds.current;if(k.pointerType!=="touch"||k.pointerId!==D.pointerId)return;if(pn(),D.pointerId=null,D.lastX=null,D.lastY=null,D.startX=null,D.startY=null,D.instantSpeed=0,D.gestureAxis==="x"){D.gestureAxis=null;return}D.gestureAxis=null;const H=pc(Ce.current,zt,ar)/Math.max(.1,p);if(D.didScroll&&Math.abs(D.velocity)>H*Sk){const He=()=>{D.velocity*=Tk,D.remainder+=D.velocity;const Ie=1+Math.abs(D.velocity)*.1,ft=H/Math.min(6,Ie);if(Math.abs(D.velocity)<H*Ck){if(Math.abs(D.remainder)>=ft/3){const Ar=D.remainder>0?"down":"up";ss(Ar,1),D.remainder=0}D.velocity=0,D.rafId=null;return}let ut=0,Yt=0;for(;ut+Yt<Kd&&D.remainder>=ft;)D.remainder-=ft,Yt++;for(;ut+Yt<Kd&&D.remainder<=-ft;)D.remainder+=ft,ut++;Yt>0&&ss("down",Yt),ut>0&&ss("up",ut),D.rafId=requestAnimationFrame(He)};D.rafId=requestAnimationFrame(He)}else Math.abs(D.remainder)>=H/3&&ja();D.didScroll&&k.stopImmediatePropagation()},[pn,ss,ja,p,zt,ar]),No=S.useCallback(k=>{const D=Ds.current;k.pointerType!=="touch"||k.pointerId!==D.pointerId||(pn(),D.pointerId=null,D.lastX=null,D.lastY=null,D.startX=null,D.startY=null,D.gestureAxis=null,D.remainder=0,D.velocity=0,D.didScroll=!1)},[pn]);R2({name:`tmux-scroll:${e}`,priority:YL,container:()=>Pe.current,onPointerDown:B&&h?po:void 0,onPointerMove:B&&h?Il:void 0,onPointerUp:B&&h?ul:void 0,onPointerCancel:B&&h?No:void 0});const Js=S.useRef({pointerId:null,originX:0,originY:0,holdTimer:null,mode:"idle",longPressMode:"arrows",copyStart:null,copyDidSelect:!1,edgeScrollTimer:null,edgeScrollDir:0,edgeScrollLines:0,edgeClientX:0,edgeClientY:0,gestureLocked:!1,joystickDir:"",joystickRepeatTimer:null,repeatIntervalMs:260,lastHapticTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,tapStartX:0,tapStartY:0,tapDidMove:!1}),Ro=S.useRef(null);Ro.current=Pe.current;const mo=Ro,go=ke,mi=S.useRef(q);mi.current=q;const ps=S.useCallback(k=>{const D=Js.current;D.gestureLocked!==k&&(D.gestureLocked=k,$i(k))},[$i]),Ei=S.useCallback(()=>{const k=Js.current;k.edgeScrollTimer!==null&&(clearInterval(k.edgeScrollTimer),k.edgeScrollTimer=null),k.edgeScrollDir=0},[]),xo=S.useCallback(k=>{const D=Ce.current,F=Js.current;if(D){if(F.mode==="copy"&&F.copyStart){F.copyDidSelect=Tp(D,F.copyStart,k)||F.copyDidSelect;return}if(F.mode==="adjust"){const H=hn.current;if(!H.active||!H.anchor)return;H.focus=bL(D,k),Tp(D,H.anchor,H.focus),ge()}}},[ge]),dl=S.useCallback((k,D)=>{const F=Ce.current,H=Js.current;if(!F)return;const He=Lc(F);if(!He)return;const Ie=He.originTop,ft=He.originTop+F.rows*He.cellH,ut=Math.max(28,He.cellH*1.5),Yt=D-Ie,Ar=ft-D;let ln=0,Qn=0;if(Yt<ut?(ln=-1,Qn=Math.min(1,(ut-Yt)/ut)):Ar<ut&&(ln=1,Qn=Math.min(1,(ut-Ar)/ut)),H.edgeClientX=k,H.edgeClientY=D,ln===0){Ei();return}H.edgeScrollDir=ln,H.edgeScrollLines=1+Math.round(Qn*5),H.edgeScrollTimer===null&&(H.edgeScrollTimer=setInterval(()=>{const In=Ce.current,is=Js.current;if(!In||is.edgeScrollDir===0)return;if(is.mode!=="copy"&&is.mode!=="adjust"){Ei();return}In.scrollLines(is.edgeScrollDir*is.edgeScrollLines);const Br=su(In,is.edgeClientX,is.edgeClientY-Zd);Br&&xo(Br)},60))},[xo,Ei]),Mo=S.useCallback(k=>{if(k.pointerType!=="touch")return!1;const D=mo.current;if(!D)return!1;const F=k.target;if(!(F instanceof HTMLElement)||!D.contains(F)||F.closest('[data-mobile-keyboard="true"]'))return!1;const H=Js.current;H.longPressMode=mi.current;const He=hn.current;if(He.active&&H.pointerId===null){const Ie=F.closest("[data-selection-handle]");if(Ie instanceof HTMLElement){const ft=Ce.current,ut=Ie.dataset.selectionHandle==="start"?"start":"end";if(ft&&He.anchor&&He.focus){const Yt=Gh(He.anchor,He.focus,ft.cols);return He.anchor=ut==="start"?Yt.end:Yt.start,He.focus=ut==="start"?Yt.start:Yt.end,He.dragging=ut,xr(),H.pointerId=k.pointerId,H.tapStartX=k.clientX,H.tapStartY=k.clientY,H.tapDidMove=!1,H.mode="adjust",lt.current=!0,he(1800),Ge.current?.setAttribute("readonly",""),fi(),pn(),no(fc),ps(!0),!0}}if(!F.closest("[data-terminal-copy-popover]")){ct();try{Ce.current?.clearSelection()}catch{}}}if(H.pointerId!==null)return!0;if(lt.current=!1,pa.current){const Ie=performance.now(),ft=k.clientX,ut=k.clientY;if(H.lastTapTime!==0&&Ie-H.lastTapTime<=300&&Math.hypot(ft-H.lastTapX,ut-H.lastTapY)<=25)return no(fc),Zr.current=performance.now()+500,pa.current?.(),on(!0),un.current&&clearTimeout(un.current),un.current=setTimeout(()=>on(!1),400),H.lastTapTime=0,!0}return H.holdTimer!==null&&(clearTimeout(H.holdTimer),H.holdTimer=null),H.joystickRepeatTimer!==null&&(clearTimeout(H.joystickRepeatTimer),H.joystickRepeatTimer=null),H.joystickDir="",H.copyStart=null,H.copyDidSelect=!1,H.pointerId=k.pointerId,H.originX=k.clientX,H.originY=k.clientY,H.tapStartX=k.clientX,H.tapStartY=k.clientY,H.tapDidMove=!1,H.mode="holding",H.longPressMode==="copy"&&ps(!0),H.holdTimer=setTimeout(()=>{if(H.holdTimer=null,H.mode==="holding"){if(H.longPressMode==="copy"){const Ie=Ce.current,ft=Ie?su(Ie,H.tapStartX,H.tapStartY):null;if(!Ie||!ft){H.mode="idle";return}H.mode="copy",lt.current=!0,he(1800),Ge.current?.setAttribute("readonly",""),H.copyStart=ft,H.copyDidSelect=!1,fi(),pn(),Ie.clearSelection(),no(fc),ps(!0);return}H.mode="arrow",lt.current=!0,he(1e3),fi(),pn(),no(fc),ps(!0),requestAnimationFrame(()=>{Wr({visible:!0,activeDir:""})})}},350),!0},[ps,xr,ct]),js=S.useCallback((k,D)=>{if(k.pointerType!=="touch")return"neutral";const F=Js.current;if(F.mode==="arrow"&&k.pointerId!==F.pointerId||F.mode==="copy"&&k.pointerId!==F.pointerId||F.mode!=="arrow"&&F.mode!=="copy"&&k.pointerId!==F.pointerId)return"neutral";const H=k.clientX-F.tapStartX,He=k.clientY-F.tapStartY;if(Math.hypot(H,He)>10&&(F.tapDidMove=!0),F.mode==="holding"){if(!D)return F.holdTimer!==null&&(clearTimeout(F.holdTimer),F.holdTimer=null),ps(!1),lt.current=!1,F.mode="idle","neutral";const Ie=k.clientX-F.originX,ft=k.clientY-F.originY;return F.longPressMode==="copy"&&Math.hypot(Ie,ft)>20?(F.holdTimer!==null&&(clearTimeout(F.holdTimer),F.holdTimer=null),ps(!1),lt.current=!1,F.mode="idle","release"):Math.hypot(Ie,ft)>20?(F.holdTimer!==null&&(clearTimeout(F.holdTimer),F.holdTimer=null),ps(!1),F.mode="idle","release"):"claim"}if(F.mode==="adjust"){if(!D)return"claim";fi();const Ie=Ce.current,ft=hn.current;if(!Ie||!ft.active||!ft.anchor||!ft.focus)return"claim";const ut=su(Ie,k.clientX,k.clientY-Zd);return ut&&(xo(ut),dl(k.clientX,k.clientY)),"claim"}if(F.mode==="copy"){if(!D)return"claim";fi();const Ie=Ce.current;if(!Ie||!F.copyStart)return"claim";const ft=su(Ie,k.clientX,k.clientY-Zd);return ft&&(xo(ft),dl(k.clientX,k.clientY)),"claim"}if(F.mode==="arrow"){if(!D)return"claim";const Ie={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},ft=k.clientX-F.tapStartX,ut=k.clientY-F.tapStartY,Yt=ck(ft,ut,F.joystickDir);if(Yt&&Yt!==F.joystickDir&&(F.originX=k.clientX,F.originY=k.clientY),Yt){const Ar=k.clientX-F.originX,ln=k.clientY-F.originY,Qn=Math.hypot(Ar,ln);if(F.repeatIntervalMs=uk(Qn),Yt!==F.joystickDir){F.joystickRepeatTimer!==null&&clearTimeout(F.joystickRepeatTimer);const In=F.joystickDir==="";F.joystickDir=Yt,go.current(Ie[Yt]);const is=performance.now();is-F.lastHapticTime>120&&(no(fc),F.lastHapticTime=is);const Br=In?400:300;F.joystickRepeatTimer=setTimeout(function xn(){if(F.joystickDir!==Yt)return;go.current(Ie[Yt]);const ls=performance.now();ls-F.lastHapticTime>120&&(no(fc),F.lastHapticTime=ls),F.joystickRepeatTimer=setTimeout(xn,F.repeatIntervalMs)},Br)}Wr({visible:!0,activeDir:Yt})}else F.joystickRepeatTimer!==null&&(clearTimeout(F.joystickRepeatTimer),F.joystickRepeatTimer=null),F.joystickDir="",Wr({visible:!0,activeDir:""});return"claim"}return"neutral"},[ps,xo,dl]),ei=S.useCallback(k=>{if(k.pointerType!=="touch"||k.pointerId!==Js.current.pointerId)return;const D=Js.current;if(D.mode==="copy"){fi(),pn(),Ei(),ps(!1);const H=Ce.current;let He=null;if(H&&D.copyStart&&(He=su(H,k.clientX,k.clientY-Zd),He&&(D.copyDidSelect=Tp(H,D.copyStart,He)||D.copyDidSelect)),H&&D.copyDidSelect&&H.hasSelection()&&D.copyStart){const Ie=hn.current;Ie.active=!0,Ie.anchor=D.copyStart,Ie.focus=He??D.copyStart,Ie.dragging=null,ge(),Ye({x:k.clientX,y:k.clientY}),he(1800),no(fc)}else Fi.current?.(!1);D.holdTimer!==null&&(clearTimeout(D.holdTimer),D.holdTimer=null),D.copyStart=null,D.copyDidSelect=!1,D.pointerId=null,D.mode="idle",lt.current=!1;return}if(D.mode==="adjust"){fi(),pn(),Ei(),ps(!1),hn.current.dragging=null,ge(),Ye({x:k.clientX,y:k.clientY}),he(1800),D.pointerId=null,D.mode="idle",lt.current=!1;return}if(D.mode==="arrow"){fi(),pn(),ps(!1),Wr({visible:!1,activeDir:""}),D.holdTimer!==null&&(clearTimeout(D.holdTimer),D.holdTimer=null),D.joystickRepeatTimer!==null&&(clearTimeout(D.joystickRepeatTimer),D.joystickRepeatTimer=null),D.joystickDir="",D.pointerId=null,D.mode="idle",lt.current=!1;return}const F=mo.current;if(F&&!D.tapDidMove){const H=k.target;H instanceof HTMLElement&&F.contains(H)&&!H.closest('[data-mobile-keyboard="true"]')&&(D.lastTapTime=performance.now(),D.lastTapX=k.clientX,D.lastTapY=k.clientY)}else D.tapDidMove&&(D.lastTapTime=0);D.holdTimer!==null&&(clearTimeout(D.holdTimer),D.holdTimer=null),D.joystickRepeatTimer!==null&&(clearTimeout(D.joystickRepeatTimer),D.joystickRepeatTimer=null),D.joystickDir="",ps(!1),lt.current=!1,D.copyStart=null,D.copyDidSelect=!1,D.pointerId=null,D.mode="idle"},[ps,fi,he,Ei,ge,Ye]),El=S.useCallback(()=>{const k=Js.current;ps(!1),Ei(),k.mode==="arrow"&&Wr({visible:!1,activeDir:""}),k.mode==="adjust"&&(hn.current.dragging=null,ge(),Ye()),k.holdTimer!==null&&(clearTimeout(k.holdTimer),k.holdTimer=null),k.joystickRepeatTimer!==null&&(clearTimeout(k.joystickRepeatTimer),k.joystickRepeatTimer=null),k.joystickDir="",lt.current=!1,k.copyStart=null,k.copyDidSelect=!1,k.pointerId=null,k.tapDidMove=!1,k.mode="idle"},[ps,Ei,ge,Ye]);R2({name:`long-press:${e}`,priority:qL,container:()=>Pe.current,onPointerDown:B?Mo:void 0,onPointerMove:B?js:void 0,onPointerUp:B?ei:void 0,onPointerCancel:B?El:void 0});const Xn=S.useCallback((k={})=>{ot.current+=1,ee.current="",Ne.current=null,Ue.current=0,gt.current=!1,At.current=null,Le.current&&(Le.current=!1,k.notifyFlowResume===!0&&de.current?.(!1)),te.current=null,le.current=!1,xe.current=null,_r.current=""},[]),gi=S.useCallback((k="unknown")=>{const D=$e.current,F=Ce.current,H=Pe.current;if(!D||!F||!H||!F.element||!F.cols||!F.rows)return;const He=H.getBoundingClientRect();if(He.width<24||He.height<24){xt("skip fit: container too small",{reason:k,width:Math.round(He.width),height:Math.round(He.height)});return}try{const Ie={cols:F.cols,rows:F.rows},ft=F.buffer.active,ut=EL(ft.type,ft.baseY,ft.viewportY),Yt=D.proposeDimensions();if(!Yt||Yt.cols<=0||Yt.rows<=0)return;const Ar=O2(F,Ie.rows),ln=LL({reason:k,currentCols:Ie.cols,currentRows:Ie.rows,proposedCols:Yt.cols,proposedRows:Yt.rows});let Qn=0;if(ln.accept){bi.current&&vr.current&&(Ie.cols!==Yt.cols||Ie.rows!==Yt.rows)&&we.current?.begin();const is=F.options.smoothScrollDuration;try{F.options.smoothScrollDuration=0,F.resize(Yt.cols,Yt.rows),Qn=O2(F,Yt.rows),ut&&F.scrollToBottom()}finally{F.options.smoothScrollDuration=is}Zt.current=0}(Ar>0||Qn>0)&&(F.refresh(0,Math.max(0,F.rows-1)),xt("xterm buffer invariant repaired",{reason:k,before:Ar,after:Qn,cols:F.cols,rows:F.rows}));const In={cols:F.cols,rows:F.rows};xt("fit",{reason:k,backend:"xterm",width:Math.round(He.width),height:Math.round(He.height),before:Ie,proposed:Yt,next:In,hysteresis:ln,changed:Ie.cols!==In.cols||Ie.rows!==In.rows})}catch{we.current?.cancel()}},[xt]),qn=S.useCallback(k=>{const D=Ce.current;if(D)try{D.refresh(0,Math.max(0,D.rows-1)),xt("terminal refreshed (sync)",{reason:k,cols:D.cols,rows:D.rows,hasWebgl:!!ae.current})}catch(F){xt("terminal refresh (sync) failed",{reason:k,error:F})}},[xt]),xa=S.useCallback(k=>{const D=ze.current;if(D){try{D.dispose()}catch{}ze.current=null}const F=ae.current;if(!F)return!1;we.current?.cancel();try{F.dispose()}catch{}return ae.current=null,xt("renderer disposed",{type:"webgl",reason:k}),!0},[xt]),Ui=S.useCallback((k,D)=>{if(ae.current)return!0;try{const F=new CC({customGlyphs:ns});return ze.current=F.onContextLoss(()=>{xt("webgl context loss",{reason:"onContextLoss"}),Je.current=!0,typeof window<"u"&&window.setTimeout(()=>{Et("webgl-context-loss",{forceRendererRecreate:!0})},0)}),we.current?.cancel(),k.loadAddon(F),ae.current=F,Je.current=!1,xt("renderer",{type:"webgl",reason:D,mobile:B,mode:Xe.current}),qn(`webgl-enabled:${D}`),gi(`webgl-enabled:${D}`),ya.current=!0,!0}catch(F){return xt("webgl load failed, fallback to dom renderer",{reason:D,error:F,mobile:B,mode:Xe.current}),!1}},[xt,ns,B,gi,qn]),Do=200,Bs=S.useRef(0),Us=S.useRef(new Map),zi=S.useRef(new Map),dn=S.useRef(wp()),Ni=S.useRef(null),xi=S.useRef(null),ba=S.useRef(-1),sa=S.useRef(new Map),ya=S.useRef(!1),bi=S.useRef(!1),va=S.useRef(E2()),Qs=S.useRef(null),Ri=S.useRef(null),Ba=S.useCallback(()=>{Qs.current!==null&&(clearTimeout(Qs.current),Qs.current=null),Ri.current=null},[]),zs=S.useCallback(()=>{const k=Us.current;k.forEach(D=>cancelAnimationFrame(D)),k.clear(),zi.current.clear()},[]),Yn=S.useCallback(()=>{Ni.current!==null&&(window.clearTimeout(Ni.current),Ni.current=null)},[]),Mi=S.useRef(()=>{}),jo=S.useCallback(k=>{Yn(),Ee.current?.(!1),se.current(k.cols,k.rows,k.seq),Ni.current=window.setTimeout(()=>{Ni.current=null;const D=I2(dn.current,k.seq);dn.current=D.state,D.request&&bi.current?(xt("resize ack timeout; retrying",{seq:k.seq,retrySeq:D.request.seq,cols:D.request.cols,rows:D.request.rows}),Mi.current(D.request)):D.exhausted&&(we.current?.cancel(),xt("resize ack timeout; leaving size unconfirmed",{seq:k.seq,cols:k.cols,rows:k.rows}))},1200)},[Yn,xt]);Mi.current=jo;const wa=S.useCallback((k,D)=>{if(!bi.current)return;const F=DL(dn.current,{cols:k,rows:D});dn.current=F.state,F.request&&jo(F.request)},[jo]),Bo=S.useCallback((k,D)=>{const F=FL(va.current,Date.now());if(F.action==="send"){Ri.current=null,wa(k,D);return}Ri.current={cols:k,rows:D},Qs.current===null&&(Qs.current=setTimeout(()=>{Qs.current=null;const H=Ri.current;Ri.current=null,H&&(va.current=$L(Date.now()),wa(H.cols,H.rows))},Math.max(0,F.readyAt-Date.now())))},[wa]),Qo=1500,Qa=400,bo=S.useRef(0),Pa=S.useRef(0),oe=S.useCallback((k,D,F)=>{if(!Number.isFinite(k)||!Number.isFinite(D)||k<=0||D<=0)return;const H=Math.floor(k),He=Math.floor(D);dn.current=QL(dn.current,{cols:H,rows:He}),bo.current=Date.now(),xt("pty-size broadcast received",{cols:H,rows:He,source:F??"unknown"})},[xt]),Ve=S.useCallback(k=>{const D=Ce.current;if(!D||!D.cols||!D.rows||!bi.current||typeof document<"u"&&(document.visibilityState!=="visible"||!Tu()))return;const F=Date.now();if(F-bo.current<Qo||F-Pa.current<Qa)return;const H=D.cols,He=D.rows,Ie=dn.current.confirmed;Ie&&Ie.cols===H&&Ie.rows===He||(Pa.current=F,xt("ensureSizeMatches push",{reason:k,cols:H,rows:He,lastServerSize:Ie}),wa(H,He))},[xt,wa]),Tt=S.useCallback((k,D)=>{const F=Ce.current,H=$e.current;if(!F||!H)return;if(!ya.current){xt("refresh skipped: renderer not ready",{reason:k});return}if(D.dedupeKey!==void 0){if(sa.current.get(k)===D.dedupeKey){xt("refresh deduped",{reason:k,dedupeKey:D.dedupeKey});return}sa.current.set(k,D.dedupeKey)}xt("refresh",{reason:k,options:D});const He=D.forceRendererRecreate===!0||Je.current||Un&&!!ae.current&&Qk.has(k)&&/Android/i.test(navigator.userAgent);let Ie=!1;He&&(Je.current=!1,Un?(xa(`refresh:${k}`),Ui(F,`refresh:${k}`)||qn(`refresh:${k}:webgl-fallback`),Ie=!0):(qn(`refresh:${k}`),Ie=!0)),RL(D.forceRedraw===!0,k==="dpr-change",Ie)?qn(`refresh:${k}`):Ie||xt("terminal redraw skipped: fit/write already repaints",{reason:k});const ft={cols:F.cols,rows:F.rows};gi(`refresh:${k}`);const ut={cols:F.cols,rows:F.rows};if(D.skipResizePush||kL({before:ft,after:ut,lastServerSize:dn.current.confirmed,reconcileServerSize:D.reconcileServerSize})&&Bo(ut.cols,ut.rows),!D.skipScrollToBottom&&k!=="resize"&&k!=="dpr-change"){const Ar=requestAnimationFrame(()=>{const In=Ce.current;if(In&&In.buffer.active.type!=="alternate")try{In.scrollToBottom()}catch{}}),ln=Us.current,Qn=ln.get(k);Qn!==void 0&&cancelAnimationFrame(Qn),ln.set(k,Ar)}},[xt,Un,xa,Ui,qn,gi,Bo]),Et=S.useCallback((k,D={})=>{if(Ce.current,k==="session-key-change"&&(dn.current=wp(),Yn(),Ba(),va.current=E2(),sa.current.clear(),zs()),!D.force&&(k==="visibility"||k==="bfcache"||k==="online")){const H=Date.now();if(H-Bs.current<Do){xt("refresh throttled",{reason:k});return}Bs.current=H}if(zi.current.set(k,D),Us.current.has(k))return;const F=requestAnimationFrame(()=>{const H=zi.current.get(k)??{};Us.current.delete(k),zi.current.delete(k),Tt(k,H)});Us.current.set(k,F)},[xt,zs,Yn,Ba,Tt]),qe=S.useCallback(k=>{const D=Us.current.get(k);if(D===void 0)return;const F=zi.current.get(k)??{};cancelAnimationFrame(D),Us.current.delete(k),zi.current.delete(k),Tt(k,F)},[Tt]);Ns.current=()=>qe("resize"),S.useEffect(()=>()=>{zs(),Pt.current!==null&&(window.clearTimeout(Pt.current),Pt.current=null)},[e,zs]),S.useEffect(()=>{dn.current=wp(),Yn(),sa.current.clear()},[e,Yn]);const vt=S.useCallback(()=>{if(le.current)return;const k=Ce.current;if(!k){Xn();return}if(!ee.current)return;const D=ee.current,F=D.length,H=Ne.current,He=gt.current;ee.current="",Ne.current=null,gt.current=!1,le.current=!0;let Ie=null;He&&(Ie=At.current??{depth:0},At.current=Ie,Ie.depth+=1);const ft=we.current,ut=ft?.generation;k.write(D,()=>{if(Ie&&(Ie.depth-=1),ut!==void 0&&ft?.written(ut),le.current=!1,Ue.current-=F,Ue.current<0&&(Ue.current=0),H!==null&&re.current?.(H),Le.current&&Ue.current<Ok&&(Le.current=!1,de.current?.(!1)),ee.current){vt();return}const Yt=++ot.current,Ar=()=>{if(Yt!==ot.current||le.current||ee.current)return;const ln=k.buffer.active;_e.current?.({x:ln.cursorX,y:ln.cursorY,rows:k.rows,lastProcessedChunkId:xe.current})};typeof window>"u"?Ar():window.requestAnimationFrame(()=>{window.requestAnimationFrame(Ar)})})},[Xn]);Ft.current=vt;const wr=S.useCallback(()=>{if(te.current!==null)return;const k=++ye.current;te.current=k,queueMicrotask(()=>{te.current===k&&(te.current=null,vt())})},[vt]),Yr=S.useCallback((k,D,F=!1)=>{if(!k)return;ot.current+=1,ee.current+=k,Ne.current=D,gt.current=gt.current||F,Ue.current+=k.length;const H=yt.current;(H===null||D>H)&&(yt.current=D),!Le.current&&Ue.current>=Pk&&(Le.current=!0,de.current?.(!0)),wr()},[wr]);return S.useEffect(()=>{let k=!1,D=null,F=null,H=[];const He=Pe.current;return He?(He.tabIndex=B?-1:0,(async()=>{if(Oe.current?.(!1),en("loading"),Lt(null),Gr(!0),await Uk(),!k)try{const ft=Hk(He,U2(Bt),zt,yn,ar),ut=new _9({...ft?{cols:ft.cols,rows:ft.rows}:{},allowProposedApi:!0,fontFamily:U2(Bt),fontSize:zt,fontWeight:z2(gn),fontWeightBold:z2(lr),theme:zk($),logLevel:"off",cursorBlink:!Un,cursorStyle:"block",cursorInactiveStyle:Nr.current?"bar":"none",scrollback:h?2e3:5e3,scrollbar:{showScrollbar:!1},allowTransparency:WT(kt,Gn),convertEol:et,drawBoldTextInBrightColors:rn,rescaleOverlappingGlyphs:vs,minimumContrastRatio:Ln,letterSpacing:yn,lineHeight:ar,smoothScrollDuration:fn&&!ce.current?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),Yt=new L9;ut.loadAddon(Yt),ut.loadAddon(new NC),ut.registerLinkProvider(yk(ut,(Br,xn)=>{wt.current?.(Br,xn)}));const Ar=new PC;ut.loadAddon(Ar),ut.unicode.activeVersion=$n,ut.loadAddon(new GC({highlightLimit:1e3}));const ln=new KC;ut.loadAddon(ln),tt.current=ln,ut.loadAddon(new xL);try{ut.loadAddon(new JC(void 0,new N3))}catch(Br){xt("clipboard addon skipped",{error:Br})}D=ut,Ce.current=ut,$e.current=Yt,Rt.current=typeof window<"u"?window.devicePixelRatio:1,ut.open(He),we.current=ML(ut),fs&&ut.loadAddon(new gL({fontFeatureSettings:HL,fallbackLigatures:WL}));try{const Br=ut._core;Br?.coreService&&(Br.coreService.isCursorInitialized=!0),ut.refresh(0,ut.rows-1)}catch{}Un?(Ui(ut,"init"),ya.current=!0):(xt("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:B,mode:kt}),ya.current=!0),Gr(!1),Er();const Qn=Br=>{if(Br.ctrlKey||Br.metaKey){Br.preventDefault();const xn=Br.deltaY>0?-1:1;gh(t,zt+xn)}};if(nt.current=Qn,He.addEventListener("wheel",Qn,{passive:!1}),!B){let Br=0,xn=null,ls=null,as=null;const E0=()=>{as=null,Ns.current();const Jn=pc(Ce.current,zt,ar),Oa=_t.current+Br;Br=0;const yo=Math.trunc(Oa/Jn);if(_t.current=Oa-yo*Jn,yo!==0){const Hs=yo>0?"down":"up",tc=Ce.current,Nl=Math.max(3,Math.floor((tc?.rows??24)/2)),rc=Math.abs(yo);rc>Nl&&(_t.current=0),ga.current(Hs,Math.min(rc,Nl),xn??void 0,ls??void 0)}};ut.attachCustomWheelEventHandler(Jn=>{if(Jn.ctrlKey||Jn.metaKey||Jn.shiftKey)return!0;if(Jn.deltaY===0)return!1;if(!Ce.current||!vr.current)return!0;const yo=pc(Ce.current,zt,ar);let Hs=Jn.deltaY;return Jn.deltaMode===1?Hs=Jn.deltaY*yo:Jn.deltaMode===2&&(Hs=Jn.deltaY*(He.clientHeight||yo*20)),Br+=Hs,xn=Jn.clientX,ls=Jn.clientY,as===null&&(as=requestAnimationFrame(E0)),Jn.preventDefault(),!1})}const In=Bk(He);if(In?(In.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),ue.current=In,Pr()):ue.current=null,Et("mount",{skipResizePush:!0,skipScrollToBottom:!0}),Bn.current&&(B?ut.focus():Ge.current?.focus({preventScroll:!0})),B||Ht.current(),H.push(ut.onRender(()=>{const Br=ut.buffer.active;Fe.current?.({x:Br.cursorX,y:Br.cursorY,rows:ut.rows}),B||Ht.current()})),!B){try{const Br=ut.textarea;if(Br){Br.tabIndex=-1,Br.setAttribute("aria-hidden","true"),Br.setAttribute("readonly",""),Br.value="";const xn=()=>{Ge.current?.focus({preventScroll:!0})};Br.addEventListener("focus",xn),H.push({dispose:()=>Br.removeEventListener("focus",xn)})}}catch{}try{H.push(ut.onCursorMove(()=>Ht.current())),H.push(ut.onResize(()=>Ht.current()))}catch{}}H.push(ut.onData(Br=>{const xn=At.current;xn!==null&&xn.depth>0||ke.current(Br)}));const is=Br=>{const xn=typeof window<"u"?window.devicePixelRatio:1,ls=Math.abs(xn-Rt.current)>.001;return ls&&(Rt.current=xn,xt("device pixel ratio changed",{value:xn,source:Br})),ls};if(F=new ResizeObserver(Br=>{if(!IL(!!zr.current,wn.current)){xt("resize observer skipped: hidden mobile session");return}pt.current=void 0;const xn=Br[0];xn&&xt("resize observer",{width:Math.round(xn.contentRect.width),height:Math.round(xn.contentRect.height)});const ls=is("resize-observer");Et(ls?"dpr-change":"resize")}),F.observe(He),typeof window<"u"){const Br=()=>{is("window-resize")&&Et("dpr-change")};window.addEventListener("resize",Br),H.push({dispose:()=>window.removeEventListener("resize",Br)});const xn=window.visualViewport;if(xn){const ls=()=>{is("visual-viewport-resize")&&Et("dpr-change")};xn.addEventListener("resize",ls),H.push({dispose:()=>xn.removeEventListener("resize",ls)})}}gi("init-fit"),en("ready"),Oe.current?.(!0)}catch(ft){console.error("Failed to initialize terminal:",ft),Gr(!1),en("error"),Lt(ft instanceof Error?ft.message:"Failed to load terminal")}})(),()=>{Oe.current?.(!1),k=!0,je.current?.(!1),Z.current?.(),Z.current=null,Mt.current=!1,Ut.current!==null&&(clearTimeout(Ut.current),Ut.current=null),ir.current=!1,Sn.current=null,tr(),qr({active:!1,text:""});for(const ft of H)ft.dispose();F?.disconnect(),nt.current&&(He.removeEventListener("wheel",nt.current),nt.current=null),we.current?.dispose(),we.current=null,xa("component-unmount"),D?.dispose(),Ce.current=null,$e.current=null,ue.current=null,Xn({notifyFlowResume:!0}),Yn(),Ba()}):void 0},[gi,Bt,zt,gn,lr,yn,ar,Ln,rn,$n,ns,vs,fs,Gn,fn,$,Xn,tr,B,Ui,xa,xt,Yn,Ba]),S.useEffect(()=>{const k=Ce.current;k&&(k.options.smoothScrollDuration=fn&&!fe?125:0)},[fn,fe,be]),S.useEffect(()=>{const k=Ce.current;k&&(k.options.cursorInactiveStyle=Be?"bar":"none",Be||k.blur())},[Be,be]),S.useEffect(()=>{const k=Ce.current;if(k){if(Un){if(k.options.cursorBlink=!1,Ui(k,"renderer-mode-change")&&Gn&&!hr.current)try{k.loadAddon(new E_({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),hr.current=!0}catch(F){xt("image addon skipped",{error:F})}return}k.options.cursorBlink=!0,xa("renderer-mode-change")&&(qn("renderer-mode-change:webgl-disabled"),gi("renderer-mode-change:webgl-disabled"))}},[Un,Gn,Ui,xa,qn,gi,xt]),S.useEffect(()=>{const k=Ce.current;k&&(xe.current!==null&&k.reset(),Xn(),We.current="",br.current=0,Ge.current&&(Ge.current.value=""),Et("session-reset",{skipScrollToBottom:!0}),Bn.current&&(zr.current?k.focus():Ge.current?.focus({preventScroll:!0})))},[e,be,Et,Xn]),S.useEffect(()=>{if(!B||typeof document>"u")return;let k=null;const D=()=>{k=null;const H=Ge.current;if(!H||document.activeElement!==H||Mt.current)return;const He=We.current,Ie=tu(H.value);if(Ie!==He||Ie.includes("\r")||!It())return;const ft=Math.min(j2(H),Array.from(Ie).length),ut=ft-br.current;if(ut===0)return;const Yt=Ce.current,Ar=ut<0?(Yt?Xd(Yt,"D"):"\x1B[D").repeat(-ut):(Yt?Xd(Yt,"C"):"\x1B[C").repeat(ut);ke.current(Ar),br.current=ft},F=()=>{k===null&&(k=requestAnimationFrame(D))};return document.addEventListener("selectionchange",F),()=>{document.removeEventListener("selectionchange",F),k!==null&&cancelAnimationFrame(k)}},[B,It]),S.useEffect(()=>{if(!B)return;const k=fo();return Z.current=k,()=>{k(),Z.current=null}},[B,fo]),S.useEffect(()=>{const k=Ce.current;if(k)try{k.options.scrollback=h?0:1e3}catch{}},[h,be]),S.useEffect(()=>{const k=Ce.current;if(!k)return;if(n.length===0){xe.current!==null&&(k.reset(),Xn(),Et("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const D=xe.current;let F,H=!1;if(D===null)F=n;else{const He=n.findIndex(Ie=>Ie.id===D);He>=0?F=n.slice(He+1):(F=n,H=!0)}if(F.length>0){const He=F.map(ln=>ln.data).join(""),Ie=_r.current+He,{cleaned:ft,remainder:ut}=jk(Ie);_r.current=ut;const Yt=yt.current,Ar=Yt!==null&&(F[0].id<=Yt||H);ft?Yr(ft,F[F.length-1].id,Ar):re.current?.(F[F.length-1].id)}xe.current=n[n.length-1].id},[n,be,Yr,Et,Xn]),S.useImperativeHandle(X,()=>({serializeSnapshot:()=>Ce.current?tt.current?.serialize({scrollback:100})??null:null,focus:()=>{if(zr.current){gs();return}Ge.current?.focus({preventScroll:!0})},blur:()=>{const k=Ge.current;Oi(k),k&&typeof document<"u"&&document.activeElement===k&&k.blur(),zr.current&&k?.setAttribute("readonly",""),je.current?.(!1)},clear:()=>{const k=Ce.current;k&&(k.reset(),Xn(),Et("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},prepareScreenReplacement:()=>{Xn({notifyFlowResume:!0})},copySelectionOrViewport:async()=>{const k=Ce.current;if(!k)return!1;const D=k.hasSelection()?k.getSelection():Wk(k),F=await W2(D);return F&&k.hasSelection()&&xr(),F},pasteClipboardText:async()=>{he();const k=await or(Ge.current);return ma.current?.(k),k},sendSequence:(k,D)=>Ae(k,null,D),getDimensions:()=>{const k=Ce.current;return!k||!k.cols||!k.rows?null:{cols:k.cols,rows:k.rows}},requestRefresh:Et,setSessionReady:k=>{bi.current=k,k||(we.current?.cancel(),Yn(),dn.current=PL(dn.current),xi.current=null,ba.current=-1,Ee.current?.(!1))},acknowledgeResize:k=>{if(!k.ok&&typeof k.seq=="number"){const Ie=I2(dn.current,k.seq);if(!Ie.request&&!Ie.exhausted)return;Yn(),dn.current=Ie.state,Ie.request&&bi.current?Mi.current(Ie.request):Ie.exhausted&&we.current?.cancel();return}const D=BL(dn.current,k);if(!D.accepted)return;Yn(),dn.current=D.state,xt("resize acknowledged",{seq:k.seq,ok:k.ok,cols:k.cols,rows:k.rows,screenSyncPending:k.screenSyncPending===!0,screenSyncGeneration:k.screenSyncGeneration});const F=Ce.current,H=D.state.confirmed;if(!!!(F&&H&&F.cols===H.cols&&F.rows===H.rows)){Ee.current?.(!1);return}if(k.screenSyncPending&&typeof k.screenSyncGeneration=="number"){xi.current=k.screenSyncGeneration;const Ie=ba.current>=k.screenSyncGeneration;Ee.current?.(Ie),Ie&&(xi.current=null);return}xi.current=null,Ee.current?.(!0)},notifyScreenSynchronized:k=>{if(!Number.isFinite(k))return;ba.current=Math.max(ba.current,k);const D=xi.current;if(D===null||k<D)return;xi.current=null;const F=Ce.current,H=dn.current.confirmed;Ee.current?.(!!(F&&H&&F.cols===H.cols&&F.rows===H.rows))},notifyServerSize:oe,ensureSizeMatches:Ve,requestPtyRedraw:()=>{const k=Ce.current;if(!k||!bi.current||dn.current.pending||xi.current!==null)return;const D=jL(dn.current,{cols:k.cols,rows:k.rows});dn.current=D.state,Mi.current(D.request)}}),[B,Oi,gs,Xn,or,Ae,Et,Yn,xt,wa,oe,Ve]),s.jsxs("div",{ref:Pe,"data-termdock-terminal-dropzone":e,className:`relative h-full w-full terminal-viewport-container ${W||""}`,style:{backgroundColor:$.background,touchAction:Xr.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:na,onPointerMoveCapture:Ra,onPointerUpCapture:Xs,onPointerCancelCapture:uo,onTouchStartCapture:k=>{if(zn(k.target)){he(),Is(ru);return}As(),Is(ru)},onTouchMoveCapture:()=>Is(ru),onTouchEndCapture:()=>Is(nu),onTouchCancelCapture:()=>Is(nu),onMouseDown:k=>{B||k.button===0&&(Pt.current!==null&&(window.clearTimeout(Pt.current),Pt.current=null),requestAnimationFrame(()=>{try{Ge.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:k=>{B||k.button===0&&(Pt.current!==null&&window.clearTimeout(Pt.current),Pt.current=window.setTimeout(()=>{Pt.current=null;try{Ge.current?.focus({preventScroll:!0})}catch{}},0))},children:[Y&&s.jsx("button",{type:"button",role:"alert",onClick:()=>st(null),className:"absolute bottom-2 left-2 right-2 z-20 rounded-md border border-border bg-surface-2 px-3 py-2 text-left text-sm text-foreground",children:Y}),$r&&s.jsxs("button",{type:"button","data-terminal-copy-popover":"true",className:"absolute z-30 inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:$r.left,top:$r.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:k=>{he(),k.stopPropagation()},onPointerUp:k=>{k.preventDefault(),k.stopPropagation(),Ma()},onTouchStart:k=>{he(),k.stopPropagation()},onTouchEnd:k=>{k.preventDefault(),k.stopPropagation(),Ma()},onClick:k=>{k.preventDefault(),k.stopPropagation(),Ma()},children:[s.jsx(i8,{size:14,strokeWidth:2.4}),s.jsx("span",{children:Qe("common.copy")})]}),Vr?.start&&s.jsx("div",{"data-selection-handle":"start",className:"absolute z-30 h-11 w-11 select-none",style:{left:Vr.start.left,top:Vr.start.top,transform:"translate(-50%, -100%)",touchAction:"none"},onPointerDown:k=>k.stopPropagation(),children:s.jsxs("div",{className:"pointer-events-none absolute bottom-0 left-1/2 flex -translate-x-1/2 flex-col items-center",children:[s.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"}),s.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"})]})}),Vr?.end&&s.jsx("div",{"data-selection-handle":"end",className:"absolute z-30 h-11 w-11 select-none",style:{left:Vr.end.left,top:Vr.end.top,transform:"translate(-50%, 0)",touchAction:"none"},onPointerDown:k=>k.stopPropagation(),children:s.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 flex -translate-x-1/2 flex-col items-center",children:[s.jsx("div",{className:"h-3 w-0.5 bg-[var(--accent)]"}),s.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-[var(--accent)] shadow-[0_1px_4px_rgb(0_0_0_/_0.4)]"})]})}),Fr&&Gt&&s.jsx(rk,{}),Fr&&at==="loading"&&!Gt&&s.jsx(G3,{}),at==="error"&&s.jsx(nk,{message:Te||void 0,onRetry:()=>{window.location.reload()}}),at==="ready"&&s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:Ge,"aria-label":Qe("terminal.input"),"data-terminal-input-anchor":"true",inputMode:"text",enterKeyHint:"enter",autoCapitalize:"off",autoComplete:"nope",autoCorrect:"off",spellCheck:!1,tabIndex:-1,style:{position:"absolute",opacity:0,zIndex:20,background:"transparent",color:"transparent",caretColor:"transparent",resize:"none",overflow:"hidden",border:"none",padding:0,margin:0,outline:"none",...B?{inset:0,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",pointerEvents:"auto",fontSize:"16px"}:(()=>{const k=cn.x,D=cn.y,F={position:"fixed",left:k,top:D,pointerEvents:"none",touchAction:"auto",fontSize:`${zt}px`,fontFamily:Bt,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(cn.cellW)),height:Math.max(1,Math.round(cn.cellH))};if(!rs.active)return F;const H=Mn(rs.text);return{...F,opacity:1,color:"transparent",WebkitTextFillColor:"transparent",background:"transparent",transition:"none",caretColor:"transparent",textDecorationColor:"transparent",wordBreak:"break-all",zIndex:20,width:H.width,height:H.height,whiteSpace:H.whiteSpace}})()},onContextMenu:k=>{k.preventDefault()},onFocus:()=>{xt("input anchor focus"),pt.current=void 0,Ht.current(),Et("focus",{skipResizePush:!0,skipScrollToBottom:!0}),je.current?.(!0)},onBlur:k=>{B||Oi(k.currentTarget);const D=hi(),F=typeof document<"u"?document.activeElement:null;if(xt("input anchor blur",{guarded:D,activeTag:F?.tagName??null,activeClass:F?.className??null}),!D){B&&Ge.current?.setAttribute("readonly",""),je.current?.(!1);return}if(typeof window>"u"){je.current?.(!1);return}window.setTimeout(()=>{Qt()||It()||(B&&Ge.current?.setAttribute("readonly",""),je.current?.(!1))},nu)},onBeforeInput:k=>{if(Mt.current)return;const D=k.nativeEvent;if(D instanceof InputEvent){if(D.inputType==="insertFromPaste"||D.inputType==="insertFromPasteAsQuotation"){const F=D.dataTransfer?.getData("text/plain")||D.data;if(F){k.preventDefault();const H=Re(F,k.currentTarget);B&&ma.current?.(H)}return}if(D.inputType==="insertLineBreak"){if(ir.current){ir.current=!1,Ut.current!==null&&(clearTimeout(Ut.current),Ut.current=null),k.preventDefault();return}k.preventDefault(),O(k.currentTarget);return}if(D.inputType==="deleteContentBackward"||D.inputType==="deleteContentForward"||D.inputType==="deleteByCut"){if(!k.currentTarget.value){k.preventDefault(),ke.current("");return}if(D.inputType==="deleteContentBackward"&&k.currentTarget.selectionStart===0&&k.currentTarget.selectionEnd===0){k.preventDefault(),ke.current("");return}return}}},onInput:k=>{if(Mt.current)return;const D=k.nativeEvent,F=CL(We.current,tu(k.currentTarget.value),D.inputType);if(F){const H=Re(F,k.currentTarget);B&&ma.current?.(H);return}kn(k.currentTarget)},onPaste:k=>{const D=k.clipboardData.files.length?Array.from(k.clipboardData.files):Array.from(k.clipboardData.items).filter(Ie=>Ie.kind==="file").map(Ie=>Ie.getAsFile()).filter(Ie=>Ie!==null),F=k.clipboardData.getData("text/plain");if(window.termdockDesktop?.readClipboardFiles){k.preventDefault(),or(k.currentTarget,{files:D,text:F});return}if(D.length&&(D.length>1||!D[0].type.startsWith("image/"))){k.preventDefault(),Ct(D,k.currentTarget);return}const H=D[0];if(H){k.preventDefault(),mt(H,k.currentTarget);return}if(!F){(window.termdockDesktop||typeof navigator.clipboard?.read=="function")&&(k.preventDefault(),or(k.currentTarget));return}k.preventDefault();const He=Re(F,k.currentTarget);B&&ma.current?.(He)},onKeyDown:k=>{const D=Mk(k);if(!D&&!Mt.current){if(k.getModifierState("AltGraph"))return;const F=Ce.current,H=k.metaKey,He=k.ctrlKey,Ie=k.altKey,ft=k.shiftKey,ut=k.key;if(H&&!He&&!Ie&&!ft&&ut==="Enter"){k.preventDefault(),O(k.currentTarget);return}if((H||He)&&!Ie&&!ft&&(ut==="v"||ut==="V"))return;if(H&&!He&&!Ie&&!ft&&(ut==="c"||ut==="C")){k.preventDefault();const Ar=F?.hasSelection()?F.getSelection():"";Ar&&navigator.clipboard?.writeText(Ar).catch(()=>{});return}if((H||He)&&!Ie&&!ft&&(ut==="k"||ut==="K")){k.preventDefault(),F&&(F.reset(),Xn(),Et("clear",{skipResizePush:!0,skipScrollToBottom:!0})),k.currentTarget.value="",We.current="",br.current=0;return}if(H&&!He&&!Ie&&!ft&&ut==="Backspace"){k.preventDefault(),Ae("",k.currentTarget);return}if(H&&!He&&!Ie&&!ft&&ut==="Delete"){k.preventDefault(),Ae("\v",k.currentTarget);return}if(H&&!He&&!Ie&&!ft&&ut==="ArrowLeft"){k.preventDefault(),Ae("",k.currentTarget);return}if(H&&!He&&!Ie&&!ft&&ut==="ArrowRight"){k.preventDefault(),Ae("",k.currentTarget);return}if(H)return;if(Ie&&!He&&!H&&!ft&&ut==="Backspace"){k.preventDefault(),Ae("\x1B",k.currentTarget);return}if(Ie&&!He&&!H&&!ft&&ut==="Delete"){k.preventDefault(),Ae("\x1Bd",k.currentTarget);return}if(Ie&&!He&&!H&&!ft&&ut==="ArrowLeft"){k.preventDefault(),Ae("\x1Bb",k.currentTarget);return}if(Ie&&!He&&!H&&!ft&&ut==="ArrowRight"){k.preventDefault(),Ae("\x1Bf",k.currentTarget);return}const Yt=wS(k,F?.modes?.applicationCursorKeysMode===!0);if(Yt!==null){k.preventDefault(),Ae(Yt,k.currentTarget);return}}if(k.key==="Enter"||k.key==="Go"||k.key==="done"||k.key==="send"){if(D||Mt.current){k.preventDefault();return}if(ir.current){ir.current=!1,Ut.current!==null&&(clearTimeout(Ut.current),Ut.current=null),k.preventDefault();return}k.preventDefault(),O(k.currentTarget);return}if(k.key==="Backspace"){if(D||Mt.current)return;if(!k.currentTarget.value){k.preventDefault(),ke.current("");return}if(k.currentTarget.selectionStart===0&&k.currentTarget.selectionEnd===0){k.preventDefault(),ke.current("");return}}},onCompositionStart:()=>{Mt.current=!0,ws(),qr({active:!0,text:""})},onCompositionUpdate:k=>{Mt.current=!0;const D=k.data??k.currentTarget.value;qr(F=>F.active&&F.text===D?F:{active:!0,text:D})},onCompositionEnd:k=>{Mt.current=!1,ir.current=!0,Ut.current!==null&&clearTimeout(Ut.current),Ut.current=setTimeout(()=>{ir.current=!1,Ut.current=null},50),qr({active:!1,text:""}),kn(k.currentTarget),Pi()}}),rs.active&&(()=>{const k=Mn(rs.text);return s.jsx("div",{"aria-hidden":"true","data-terminal-ime-composition":"true",style:{position:"fixed",left:cn.x,top:cn.y,zIndex:21,pointerEvents:"none",overflow:"hidden",boxSizing:"content-box",width:k.width,height:k.height,margin:0,padding:0,color:$.foreground,background:$.background,boxShadow:`-1px 0 0 1px ${$.background}`,fontSize:`${zt}px`,fontFamily:Bt,lineHeight:"1",textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:$.foreground,wordBreak:"break-all",whiteSpace:k.whiteSpace,transition:"none"},children:rs.text})})(),s.jsx("div",{"aria-hidden":!0,className:`absolute left-1/2 -translate-x-1/2 top-6 z-30 pointer-events-none
65
+ rounded-full bg-[var(--surface-elevated)] px-4 py-1.5 text-sm font-semibold text-foreground
66
+ shadow-lg transition-all duration-150 ease-out`,style:{opacity:tn?1:0,transform:tn?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),s.jsx("div",{ref:_n,"aria-hidden":!0,className:"absolute left-1/2 top-6 z-30 pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:Xr.visible?1:0,transform:Xr.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:Xr.visible&&(()=>{const{activeDir:k}=Xr,D=F=>k===F;return s.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${D("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${D("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),s.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${D("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),s.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${D("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});q3.displayName="TerminalViewport";const Vk=q3,qk=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},Yk=()=>({async createSession(e){return h8(e)},connect(e,t,r){const n=d8(e,t.onEvent,t.onError,{...qk(r),getDimensions:r?.getDimensions});return{close:()=>n()}},async sendInput(e,t){await _b(e,t)},async resize(e){await u8(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await Cb(e)},async restartSession(e,t){return c8(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await l8(e)},async tmuxAction(e,t){return o8(e,t)},async listTmuxSessions(){return lm()},async getTmuxStatus(){return om()},async checkHealth(e){return a8(e)}}),Zk="\x1B",Kk=/\x1b\[[IO]/g,Xk=/\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM]/y,Jk=/\x1b\[[0-9]+;[0-9]+;[0-9]+M/y;function V2(e,t,r){return e.lastIndex=r,e.exec(t)?e.lastIndex:-1}function eI(e){const t=e.replace(Kk,"");if(t.length===0)return e.length>0;let r=0;for(;r<t.length;){let n=V2(Xk,t,r);if(n<0&&(n=V2(Jk,t,r)),n<0&&t.startsWith("\x1B[M",r)&&t.length>=r+6&&(n=r+6),n<0)return!1;r=n}return!0}function tI(e){return e===Zk}function Im(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const _u=15;function rI(){return Y3.map(e=>e.id)}const Y3=[{id:"default",label:"Base",programs:[],includeAlt:!0,rowLayout:[3,3,3],actions:[],showOnDesktop:!1},{id:"opencode",label:"Code",programs:["opencode"],includeAlt:!1,rowLayout:[6],actions:[{id:"opencode-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo||\r"},{id:"opencode-new",label:"/new",sequence:"/new",doubleTapSequence:"/new||\r"},{id:"opencode-models",label:"/models",sequence:"/models",doubleTapSequence:"/models||\r"},{id:"opencode-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact||\r"}],showOnDesktop:!0},{id:"claude",label:"Claude",programs:["claude","claude-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"claude-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"claude-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"claude-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"}],showOnDesktop:!0},{id:"kimi",label:"Kimi",programs:["kimi","kimi-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"kimi-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"kimi-new",label:"/new",sequence:"/new",doubleTapSequence:"/new\r"},{id:"kimi-sessions",label:"/sessions",sequence:"/sessions",doubleTapSequence:"/sessions\r"},{id:"kimi-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"kimi-goal",label:"/goal",sequence:"/goal",doubleTapSequence:"/goal\r"}],showOnDesktop:!0},{id:"codex",label:"Codex",programs:["codex"],includeAlt:!1,rowLayout:[6],actions:[{id:"codex-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"codex-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"codex-model",label:"/model",sequence:"/model",doubleTapSequence:"/model\r"},{id:"codex-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"codex-resume",label:"/resume",sequence:"/resume",doubleTapSequence:"/resume\r"}],showOnDesktop:!0},{id:"coco",label:"Coco",programs:["coco"],includeAlt:!1,rowLayout:[6],actions:[{id:"coco-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"coco-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"coco-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"coco-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0},{id:"traex",label:"TraeX",programs:["traex","traecli"],includeAlt:!1,rowLayout:[6],actions:[{id:"traex-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"traex-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"traex-compact",label:"/compact",sequence:"/||compact ",doubleTapSequence:"/||compact ||\r"},{id:"traex-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"traex-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0}];function Zu(){return Y3.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function x1(e){const t=Array.isArray(e)?e.map(r=>Math.min(20,Math.max(2,Math.floor(r)))).filter(r=>Number.isFinite(r)):[];return t.length>0?t:[3,3]}function Z3(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const b1=/^\/(.+)\/([gimsuy]*)$/;function q2(e){return b1.test(e.trim())}function qh(e){const t=e.trim().match(b1);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function K3(e){if(typeof e!="string")return null;const t=e.trim();return t?b1.test(t)?qh(t)?t:null:t.toLowerCase():null}function Y2(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16))).replace(/\\r/g,"\r").replace(/\\n/g,`
67
+ `).replace(/\\t/g," ")}const Z2="||",nI=120;function sI(e){return e.includes(Z2)?e.split(Z2).filter(t=>t.length>0):[e]}function o0(e){const t=new Set,r=e.map((a,l)=>{const c=typeof a.id=="string"&&a.id.trim().length>0?a.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):`preset-${l+1}`,h=t.has(c)?`${c}-${l+1}`:c;return t.add(h),{id:h,label:typeof a.label=="string"&&a.label.trim().length>0?a.label.trim():"Preset",programs:Array.isArray(a.programs)?a.programs.map(p=>K3(p)).filter(p=>!!p):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:x1(a.rowLayout),showOnDesktop:typeof a.showOnDesktop=="boolean"?!!a.showOnDesktop:!1,actions:Array.isArray(a.actions)?a.actions.map((p,g)=>{const x={id:typeof p.id=="string"&&p.id.trim().length>0?p.id:`${h}-action-${g+1}`,label:typeof p.label=="string"?p.label:`Key ${g+1}`,sequence:typeof p.sequence=="string"?p.sequence:""};return typeof p.doubleTapSequence=="string"&&(x.doubleTapSequence=p.doubleTapSequence),x}):[]}}).filter(a=>a.id!=="auto"),n=Zu()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function iI(e,t){const r=Z3(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const l=qh(a);if(l){if(l.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function K2(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??Zu()[0]}function aI(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function oI(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function X3(e,t){const r=x1(t),n=[];let a=0,l=0;for(;a<e.length;){const c=r[Math.min(l,r.length-1)]??3;n.push({columns:c,items:e.slice(a,a+c)}),a+=c,l+=1}return n}const J3=28,ey=({mode:e,presetLabel:t,title:r,ariaLabel:n,disabled:a,onPointerDown:l,buttonRef:c})=>s.jsx("button",{ref:c,type:"button",onPointerDown:l,tabIndex:-1,disabled:a,className:"h-7 w-7 rounded-full bg-surface-2 shadow-sm text-[11px] font-medium active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",title:r,"aria-label":n??r,children:e==="auto"?s.jsx(zT,{size:14}):(t.charAt(0)||"?").toUpperCase()}),lI={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},iu=8;function cI(e,t){return lI[e]??null}const uI=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:a,disabled:l,defaultShowExtended:c=!1,presetLabel:h,presetModeLabel:p,presetMode:g,presetOptions:x,includeAlt:y,presetRowLayout:A,extraActions:v,onKeyPress:L,onTextPress:I,onPastePress:E,onFilePress:R,onFileLongPress:P,fileUploadState:Q="idle",fileUploadProgress:$=0,longPressMode:W="arrows",copyFeedback:B="idle",onLongPressModeToggle:q,onModifierToggle:ne,onPresetSelect:Be,onExpandedChange:fe})=>{const{t:X}=Hr(),[Qe,Pe]=S.useState(c),[ue,Ce]=S.useState(!1),tt=S.useRef(null),we=r==="desktop-actions",ce=we||Qe,[$e,ke]=S.useState(!1),[se,je]=S.useState(null),de=l||!e||!t,Oe=l||!e,Ee=S.useRef(null),_e=S.useRef(null),re=S.useRef(null),Fe=S.useRef(null),wt=S.useRef(null),Xe=S.useRef(B),ee=S.useRef(null),Ue=S.useRef(0),Le=S.useRef(null),te=S.useRef(!1),ye=S.useCallback(Ze=>{if(de)return;const Dt=Ze.target;if(!(Dt instanceof Element))return;const nt=Dt.closest("button"),_t=nt?.hasAttribute("data-mobile-native-action")===!0;nt&&!_t?(Ze.preventDefault(),no(iu)):nt&&no(iu)},[de]),ot=S.useCallback(Ze=>{Ze.preventDefault()},[]),le=S.useCallback(Ze=>{const Dt=Ze.target;de||Dt instanceof HTMLElement&&Dt.closest("button")&&Dt.blur()},[de]);S.useEffect(()=>{Pe(c)},[c]),S.useEffect(()=>{we||fe?.(Qe)},[we,fe,Qe]),S.useEffect(()=>{de&&(ee.current!==null&&(window.clearTimeout(ee.current.timer),ee.current=null),ke(!1),je(null))},[de]),S.useEffect(()=>{e||(ke(!1),je(null))},[e]),S.useEffect(()=>{if(!$e)return;const Ze=()=>{const Dt=Ee.current?.getBoundingClientRect();Dt&&je({left:Math.max(8,Dt.left),top:Math.max(8,Dt.top-8)})};return Ze(),window.addEventListener("resize",Ze),window.addEventListener("scroll",Ze,!0),()=>{window.removeEventListener("resize",Ze),window.removeEventListener("scroll",Ze,!0)}},[$e]),S.useEffect(()=>{const Ze=Xe.current;if(Xe.current=B,B==="idle"||B===Ze)return;if(wt.current!==null&&window.clearTimeout(wt.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(B==="copied"){_e.current?.animate?.([{transform:"scale(1)"},{transform:"scale(1.16)",offset:.28},{transform:"scale(0.96)",offset:.62},{transform:"scale(1)"}],{duration:720,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});const nt=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];re.current?.animate?.(nt,{duration:760,easing:"ease-out"}),Fe.current?.animate?.(nt,{duration:760,delay:130,easing:"ease-out"})}else _e.current?.animate?.([{transform:"translateX(0)"},{transform:"translateX(-2px)"},{transform:"translateX(2px)"},{transform:"translateX(0)"}],{duration:280,easing:"ease-out"});no(iu),B==="copied"&&(wt.current=window.setTimeout(()=>{no(iu),wt.current=null},90),W==="copy"&&q?.())},[B,W,q]),S.useEffect(()=>()=>{wt.current!==null&&window.clearTimeout(wt.current)},[]);const xe=S.useCallback((Ze,Dt)=>{de||(Ze.preventDefault(),L(Dt))},[L,de]),Ne=S.useCallback((Ze,Dt)=>{de||(Ze.preventDefault(),ne(Dt))},[ne,de]),yt=S.useCallback(Ze=>{de||(Ze.preventDefault(),Pe(Dt=>{const nt=!Dt;return nt&&(Ce(!0),tt.current!==null&&window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>{Ce(!1),tt.current=null},350)),nt}))},[de]),gt=S.useCallback(()=>{const Ze=typeof performance<"u"?performance.now():Date.now();Ze-Ue.current<350||(Ue.current=Ze,E?.())},[E]),At=S.useCallback(Ze=>{de||(Ze.stopPropagation(),Ze.pointerType!=="touch"&&(Ze.preventDefault(),gt()))},[de,gt]),Ft=S.useCallback(Ze=>{de||(Ze.preventDefault(),Ze.stopPropagation(),gt())},[de,gt]),Z=S.useCallback(Ze=>{de||Q==="uploading"||!R||(Ze.preventDefault(),Ze.stopPropagation(),te.current||R(),te.current=!1)},[Q,R,de]),Ge=S.useCallback(()=>{Le.current!==null&&window.clearTimeout(Le.current),Le.current=null},[]),pt=S.useCallback(Ze=>{Ze.stopPropagation(),!(de||Q==="uploading"||!P)&&(te.current=!1,Le.current=window.setTimeout(()=>{Le.current=null,te.current=!0,no(iu),P()},500))},[Q,P,de]);S.useEffect(()=>()=>Ge(),[Ge]);const Pt=S.useCallback(Ze=>{de||Ze.stopPropagation()},[de]),hr=250,Zt=S.useCallback(()=>{ee.current!==null&&(window.clearTimeout(ee.current.timer),ee.current=null)},[]);S.useEffect(()=>()=>{Zt(),tt.current!==null&&(window.clearTimeout(tt.current),tt.current=null)},[Zt]);const _r=S.useCallback((Ze,Dt)=>{if(de)return;if(Ze.preventDefault(),!Dt.doubleTapSequence){I(Dt.sequence);return}const nt=ee.current;if(nt!==null&&nt.actionId===Dt.id){window.clearTimeout(nt.timer),ee.current=null,I(Dt.doubleTapSequence);return}Zt();const _t=window.setTimeout(()=>{ee.current=null,I(Dt.sequence)},hr);ee.current={actionId:Dt.id,timer:_t}},[Zt,I,de]),ae=S.useCallback(Ze=>{de||(Ze.preventDefault(),Ze.stopPropagation(),q?.())},[q,de]),ze=S.useCallback(Ze=>{de||Ze.stopPropagation()},[de]),Je=S.useCallback(Ze=>{if(de)return;Ze.preventDefault();const Dt=Ze.currentTarget.getBoundingClientRect();je({left:Math.max(8,Dt.left),top:Math.max(8,Dt.top-8)}),ke(nt=>!nt)},[de]),Rt=S.useCallback((Ze,Dt)=>{de||(Ze.preventDefault(),ke(!1),je(null),Be(Dt))},[Be,de]),Mt=v.length>0,ir=S.useMemo(()=>{const Ze=[{id:"preset",kind:"preset"}];if(!we&&y&&Ze.push({id:"alt",kind:"alt"}),Mt){const Dt=v.map(nt=>({id:nt.id,kind:"text",action:nt}));return Ze.concat(Dt)}return we?Ze.concat([{id:"esc",kind:"key",keyName:"esc"},{id:"ctrl-c",kind:"key",keyName:"ctrl-c"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"},{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"}]):Ze.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,Mt,y,we]),Ut=S.useMemo(()=>X3(ir,we&&!Mt?[6]:A),[ir,Mt,we,A]),We=`${we?"space-y-1":"mt-1 space-y-1"}${ue?" pointer-events-none":""}`,br=$e&&se?ki.createPortal(s.jsx("div",{className:"fixed z-popover min-w-28 -translate-y-full rounded-2xl bg-surface-elevated p-1.5 shadow-xl border border-border/15",style:{left:se.left,top:se.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(Ze=>s.jsx("button",{type:"button",onPointerDown:Dt=>Rt(Dt,Ze.id),tabIndex:-1,disabled:Oe,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${Ze.id===g?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:Ze.label},Ze.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[br,s.jsx("div",{"data-mobile-keyboard":"true",className:`z-chrome select-none overflow-hidden app-chrome-bg transition-all duration-150 ease-out px-1 py-0 ${e?we?"max-h-24":"max-h-40":"max-h-0"} ${e?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"} ${t?"":"[&_button]:pointer-events-none"}`,onMouseDownCapture:ye,onPointerDownCapture:ye,onContextMenuCapture:ot,onFocusCapture:le,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!we&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:Ze=>xe(Ze,"esc"),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"Esc"}),s.jsx("button",{type:"button",onPointerDown:Ze=>Ne(Ze,"ctrl"),tabIndex:-1,disabled:Oe,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="ctrl"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="ctrl"?"Ctrl*":"Ctrl"})}),s.jsx("button",{type:"button",onPointerDown:Ze=>xe(Ze,"ctrl-c"),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-C"}),s.jsx("button",{type:"button",onPointerDown:Ze=>xe(Ze,"ctrl-u"),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-U"}),s.jsxs("button",{type:"button",onPointerDown:pt,onPointerUp:Ge,onPointerCancel:Ge,onClick:Z,tabIndex:-1,disabled:Oe||!R||Q==="uploading",title:Q==="uploading"?`${X("rightSidebar.uploading")} ${Math.round($)}%`:X(Q==="inserted"?"rightSidebar.inserted":Q==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":X("rightSidebar.insertLocalFile"),className:`relative h-7 w-full overflow-hidden rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${Q==="inserted"?"bg-primary/15 text-primary":Q==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[Q==="uploading"&&s.jsx("span",{"aria-hidden":"true","data-file-upload-progress":"true",className:"absolute inset-y-0 left-0 bg-primary/25 transition-[width] duration-150 ease-out",style:{width:`${Math.max(0,Math.min(100,$))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:Q==="uploading"?s.jsx(En,{size:15,className:"animate-spin"}):Q==="inserted"?s.jsx(ci,{size:15}):Q==="failed"?s.jsx(Wn,{size:15}):s.jsx(gA,{size:15})}),Q!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:Q==="uploading"?`${X("rightSidebar.uploading")} ${Math.round($)}%`:X(Q==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),s.jsx("button",{type:"button",onPointerDown:()=>I("/"),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"/"}),s.jsx("button",{type:"button",onPointerDown:Ze=>xe(Ze,"enter"),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(uA,{size:16})}),s.jsxs("button",{ref:_e,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:ze,onTouchStart:ze,onClick:ae,tabIndex:-1,disabled:Oe,title:X(B==="copied"?"terminal.copied":B==="failed"?"terminal.copyFailed":W==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":X(W==="copy"?"terminal.switchLongPressToArrows":"terminal.switchLongPressToCopy"),className:`relative isolate h-7 w-full overflow-visible rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-colors keyboard-button-active disabled:opacity-50 flex items-center justify-center ${B==="copied"?"bg-primary/15 text-primary":B==="failed"?"bg-destructive/15 text-destructive":W==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:re,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:Fe,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/40 opacity-0"}),s.jsxs("span",{className:"relative z-10 h-4 w-4","aria-hidden":"true",children:[s.jsx(ci,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${B==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),s.jsx(Wn,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${B==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(zb,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${B==="idle"&&W==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(zA,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${B==="idle"&&W==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),B!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:B==="copied"?`${X("terminal.copied")} · ${X("terminal.longPressSendsArrows")}`:`${X("terminal.copyFailed")} · ${X("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:At,onPointerUp:Pt,onTouchStart:Pt,onTouchEnd:Pt,onClick:Ft,tabIndex:-1,disabled:Oe,title:X("terminal.paste"),"aria-label":X("terminal.paste"),className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(tA,{size:15})}),s.jsx("button",{type:"button",onPointerDown:yt,tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:Qe?s.jsx(f8,{size:16}):s.jsx(ol,{size:16})})]}),ce&&s.jsx("div",{className:We,children:Ut.map((Ze,Dt)=>{const nt=Ze.items[0]?.kind==="preset",_t=Math.max(2,Ze.columns),Qr=nt?`${J3}px repeat(${Math.max(1,_t-1)}, minmax(0, 1fr))`:`repeat(${_t}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:Qr},children:Ze.items.map(yr=>yr.kind==="preset"?s.jsx(ey,{buttonRef:yr.id==="preset"?Ee:void 0,mode:g,presetLabel:h,title:p,disabled:Oe,onPointerDown:Je},yr.id):yr.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:Nt=>Ne(Nt,"alt"),tabIndex:-1,disabled:Oe,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="alt"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="alt"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="alt"?"Alt*":"Alt"})},yr.id):yr.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:Nt=>_r(Nt,yr.action),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm px-1 text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 relative",children:[yr.action.label,yr.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},yr.id):s.jsx("button",{type:"button",onPointerDown:Nt=>xe(Nt,yr.keyName),tabIndex:-1,disabled:Oe,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:yr.keyName==="esc"?"Esc":yr.keyName==="ctrl-c"?"Ctrl-C":yr.keyName==="ctrl-d"?"Ctrl-D":yr.keyName==="home"?"Home":"End"},yr.id))},`row-${Dt}`)})})]})})]})},dI=({isMobile:e,isInputFocused:t,isIOS:r,isConnecting:n,connectionError:a,terminalSessionId:l})=>{if(typeof window>"u")return null;const c=window.visualViewport?Math.max(0,Math.round(window.innerHeight-window.visualViewport.height-window.visualViewport.offsetTop)):0;return s.jsxs("div",{className:"px-3 py-2 bg-surface text-foreground text-xs border-b border-border/15",children:[s.jsx("div",{className:"font-bold mb-2",children:"Debug Info"}),s.jsxs("div",{className:"grid grid-cols-2 gap-1 font-mono",children:[s.jsxs("div",{children:["isMobile: ",s.jsx("span",{className:e?"text-accent":"text-destructive",children:String(e)})]}),s.jsxs("div",{children:["touchPoints: ",navigator.maxTouchPoints]}),s.jsxs("div",{children:["innerWidth: ",window.innerWidth]}),s.jsxs("div",{children:["innerHeight: ",window.innerHeight]}),s.jsxs("div",{children:["viewportH:"," ",window.visualViewport?Math.round(window.visualViewport.height):"N/A"]}),s.jsxs("div",{children:["inputFocused: ",String(t)]}),s.jsxs("div",{children:["keyboard~: ",c,"px"]}),s.jsxs("div",{children:["connecting:"," ",s.jsx("span",{className:n?"text-muted-foreground":"text-accent",children:String(n)})]}),s.jsxs("div",{children:["sessionId:"," ",s.jsx("span",{className:l?"text-accent":"text-destructive",children:l?"✓":"✗"})]}),s.jsxs("div",{children:["error:"," ",s.jsx("span",{className:a?"text-destructive":"text-accent",children:a?"Yes":"No"})]}),s.jsxs("div",{children:["isIOS:"," ",s.jsx("span",{className:r?"text-muted-foreground":"text-accent",children:String(r)})]})]}),s.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:s.jsx("div",{children:"Tip: Tap the status bar 3 times to toggle debug panel"})})]})},hI=/^Reconnecting/i,fI=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:l}=Hr(),c=!!e&&hI.test(e),h=!!(n&&!e||c),[p,g]=S.useState(!1);return S.useEffect(()=>{if(!h){g(!1);return}const x=setTimeout(()=>g(!0),1500);return()=>clearTimeout(x)},[h]),h?p?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:s.jsx(Fu,{dots:!0,label:l("connection.reconnecting"),className:"rounded-full bg-surface-2 px-3 py-1 text-[11px]"})}):null:e?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2",children:s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-destructive/70",children:[s.jsx("span",{children:e}),t&&s.jsx("button",{type:"button",onClick:a,disabled:r,className:"text-[11px] text-destructive/90 hover:text-destructive underline underline-offset-2 transition-colors disabled:opacity-40",children:l("common.retry")})]})}):null};let Lu=[],Sp=!1;function ha(e,t,r={}){typeof window>"u"||(Lu.push(JSON.stringify({level:e,message:t,data:{ts:Date.now(),...r}})),pI())}async function pI(){if(!Sp){Sp=!0;try{for(;Lu.length>0;){const e=Lu[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),Lu.shift()}catch{Lu=[];break}}}finally{Sp=!1}}}const mI=120,gI=80,xI=400;function X2(){if(typeof window>"u"||document.visibilityState!=="visible"||!p8())return 0;const e=Number.parseFloat(document.documentElement.style.getPropertyValue("--kb-height")||"0");if(Number.isFinite(e)&&e>0)return Math.round(e);const t=Ko().visualViewport;if(!t)return 0;const r=Number.parseFloat(document.documentElement.style.getPropertyValue("--app-base-vh")||"0")||window.innerHeight,n=Number.parseFloat(document.documentElement.style.getPropertyValue("--safe-bottom-inset")||"0")||0,a=t.height+t.offsetTop;return Math.max(0,Math.round(r-a-n))}function ty(e){const{enabled:t,openThresholdPx:r=mI,closeThresholdPx:n=gI,settleDelayMs:a=xI}=e,l=S.useMemo(()=>p0("keyboard"),[]),c=S.useRef(!1),h=S.useRef(null),p=S.useRef(0),[g,x]=S.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return S.useEffect(()=>{if(typeof window>"u"||!t){c.current=!1,h.current!==null&&(clearTimeout(h.current),h.current=null),x(B=>!B.isOpen&&!B.isSettled&&B.keyboardHeight===0?B:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let y=null;const A=()=>{y=null;const B=X2();let q=c.current;if(B>=r?q=!0:B<=n&&(q=!1),c.current=q,q){const ne=Math.abs(B-p.current);p.current=B,ne>10&&(h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,x(Be=>Be.isSettled?Be:{...Be,isSettled:!0})},a))}else h.current!==null&&(clearTimeout(h.current),h.current=null);x(ne=>{const Be=q?ne.isSettled:!1;return ne.isOpen===q&&ne.keyboardHeight===B&&ne.isSettled===Be?ne:(l("sync",{keyboardHeight:B,isOpen:q,isSettled:Be,visualViewport:Ko().visualViewport?{width:Math.round(Ko().visualViewport.width),height:Math.round(Ko().visualViewport.height),offsetTop:Math.round(Ko().visualViewport.offsetTop)}:null}),{isOpen:q,isSettled:Be,keyboardHeight:B})})},v=(B="event")=>{(B.includes("visibilitychange")||B.includes("pageshow"))&&l("schedule",{source:B}),y===null&&(y=window.requestAnimationFrame(A))};v("mount");const L=()=>v("resize"),I=()=>v("orientationchange"),E=()=>v("visualViewport.resize"),R=()=>v("visualViewport.scroll"),P=()=>v("viewport-keyboard-change");window.addEventListener("resize",L),window.addEventListener("orientationchange",I),Ko().visualViewport?.addEventListener("resize",E),Ko().visualViewport?.addEventListener("scroll",R),document.addEventListener("termdock:viewport-keyboard-change",P);const Q=B=>{l("resume",{source:B,keyboardHeight:X2(),hidden:document.hidden}),v(`${B}:now`),window.setTimeout(()=>v(`${B}:50ms`),50),window.setTimeout(()=>v(`${B}:200ms`),200)},$=()=>{document.hidden||Q("visibilitychange")},W=()=>Q("pageshow");return document.addEventListener("visibilitychange",$),window.addEventListener("pageshow",W),()=>{window.removeEventListener("resize",L),window.removeEventListener("orientationchange",I),Ko().visualViewport?.removeEventListener("resize",E),Ko().visualViewport?.removeEventListener("scroll",R),document.removeEventListener("termdock:viewport-keyboard-change",P),document.removeEventListener("visibilitychange",$),window.removeEventListener("pageshow",W),y!==null&&window.cancelAnimationFrame(y),h.current!==null&&(clearTimeout(h.current),h.current=null)}},[l,t,r,n,a]),g}const _h=300,bI=120,yI=2e3,vI=250,wI=6e4;function AI(e){const t=new Set(e.slides.flat()),r=new Set([...e.visibleSessionIds].filter(c=>t.has(c)));e.foregroundSessionId&&t.has(e.foregroundSessionId)&&r.add(e.foregroundSessionId);const n=e.slides.findIndex(c=>c.some(h=>r.has(h)));if(n<0)return r;const a=e.slides[n-1]??[],l=e.slides[n+1]??[];for(let c=0;c<Math.max(a.length,l.length)&&r.size<3;c+=1)for(const h of[a[c],l[c]])h&&r.size<3&&r.add(h);return r}function Cp(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function Jd(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function TI(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function SI(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function CI(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function _I(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function LI(e){return!e.initialConnectionPending}function kI(e){return!e}function II(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function EI(e,t){return[...e].every(r=>t.has(r))}function NI(e,t){return e===null||t-e>=vI}function RI(e){return!1}function MI(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,wI-(e.now-e.reconnectStartedAt))}function DI(e,t){const r=new Map;let n=0;for(const a of e)if(!r.has(a)){if(t.has(a)){r.set(a,0);continue}r.set(a,_h+n*bI),n+=1}return r}const jI="Session not found on server",Lh="Terminal session not found",BI="STALE_SESSION_RESTORE_REJECTED";function J2(e){return Em(e)?!1:e?.message===jI||e?.status===404&&e.message===Lh}function Em(e){return e?.code===BI}function QI(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function ry(e,t){return QI(e,t).replace(/ /g,"\\ ")}function ny(e,t){return`${ry(e,t)} `}function ex(e,t){return ry(e,t)}function n$(e,t,r){if(!r)return ex(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${ex(e,t)}:${n}`}const PI="/tmp";async function sy(e,t,r){const a=(await t(PI,[e])).files[0];if(!a?.path)throw new Error("Upload did not return a file path");return r(a.path),a}const s$=sy,iy=[640,960,1280,1600,2048,2560,3072,4096],ay=[240,360,480,540,720,1080,1440,2160],Du={min:.1,max:1,step:.01},ju={min:25e4,max:2e7,step:25e4},y1="termdock:mobile-media-compression-v1",Kc={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function oy(){try{const e=JSON.parse(localStorage.getItem(y1)||"null");return!e||typeof e!="object"?Kc:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:iy.includes(e.imageMaxDimension)?e.imageMaxDimension:Kc.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=Du.min&&e.imageQuality<=Du.max?e.imageQuality:Kc.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:ay.includes(e.videoMaxHeight)?e.videoMaxHeight:Kc.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=ju.min&&e.videoBitrate<=ju.max?e.videoBitrate:Kc.videoBitrate}}catch{return Kc}}const v1=Jl((e,t)=>({preferences:oy(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(y1,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===y1||e.key===null)&&v1.setState({preferences:oy(),saveFailed:!1})});function eh(e){if(e<1024)return`${e} B`;const t=["B","KB","MB","GB","TB"],r=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${Number((e/1024**r).toFixed(1))} ${t[r]}`}function OI({result:e,message:t,onClose:r}){const{locale:n}=Hr(),a=n==="zh",l=b.useRef(null),[c,h]=b.useState(null),[p,g]=b.useState(!1);return b.useEffect(()=>{const x=URL.createObjectURL(e.file);return h(x),g(!1),()=>URL.revokeObjectURL(x)},[e.file]),b.useEffect(()=>{const x=l.current;return x?.showModal(),()=>x?.close()},[]),s.jsx("dialog",{ref:l,"aria-label":a?"上传结果预览":"Uploaded media preview",onCancel:x=>{x.preventDefault(),r()},onClick:x=>{x.target===x.currentTarget&&r()},onKeyDown:x=>x.stopPropagation(),onKeyUp:x=>x.stopPropagation(),className:"fixed inset-0 z-modal-panel m-0 h-[100dvh] max-h-none w-screen max-w-none bg-transparent p-3 text-foreground backdrop:bg-[var(--app-backdrop)] open:flex open:items-center open:justify-center",children:s.jsxs("section",{className:"flex max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-1.5rem)] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-start gap-3 border-b border-border/15 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-sm font-semibold",children:a?"上传结果预览":"Uploaded media preview"}),s.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:t}),s.jsx("p",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:e.file.name})]}),s.jsx("button",{type:"button",autoFocus:!0,onClick:r,"aria-label":a?"关闭预览":"Close preview",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:s.jsx(Wn,{size:18})})]}),s.jsx("div",{className:"min-h-0 overflow-auto p-2",children:p?s.jsx("p",{role:"alert",className:"p-4 text-sm text-muted-foreground",children:a?"文件已上传,但当前浏览器无法预览此格式。":"File uploaded, but this browser cannot preview this format."}):c&&(e.kind==="image"?s.jsx("img",{src:c,alt:e.file.name,onError:()=>g(!0),className:"mx-auto block max-h-[65dvh] max-w-full object-contain"}):s.jsx("video",{src:c,controls:!0,playsInline:!0,preload:"metadata",onError:()=>g(!0),className:"mx-auto block max-h-[65dvh] w-full"}))})]})})}function FI({result:e,onDismiss:t}){const{locale:r}=Hr(),n=r==="zh",a=v1(E=>E.preferences.showResultToast),l=a?e:null,[c,h]=b.useState(null);b.useEffect(()=>{if(!e)return;if(!a){t();return}const E=window.setTimeout(t,2e3);return()=>window.clearTimeout(E)},[e,a,t]);const p=l??c?.result;if(!p)return null;const g=p.originalSize-p.uploadedSize,x=p.originalSize>0?Math.abs(g)/p.originalSize*100:0,y=x<1?"<1%":`${Math.floor(x)}%`,A=p.kind==="image"?n?"图片":"Image":n?"视频":"Video",v=g>0?n?"已压缩上传":"Compressed upload":n?"已处理上传":"Processed upload",L=g>0?n?`省 ${y}`:`${y} saved`:g<0?`+${y}`:n?"体积未变":"Size unchanged",I=p.originalRetained?n?`已尝试压缩 · 保留原图 ${eh(p.uploadedSize)},已上传`:`Compression tried · original ${eh(p.uploadedSize)} uploaded`:`${v} · ${eh(p.originalSize)} → ${eh(p.uploadedSize)} · ${L}`;return s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"pointer-events-none absolute left-1/2 top-1/2 z-30 w-max max-w-[calc(100%-1.5rem)] -translate-x-1/2 -translate-y-1/2 motion-safe:animate-[fade-in_0.15s_ease-out]",children:s.jsxs("button",{type:"button","aria-label":`${A}:${I} · ${n?"点击预览":"Preview"}`,onClick:()=>{h({result:l,message:I}),t()},className:"pointer-events-auto flex max-w-full select-none items-center gap-1.5 rounded-full border border-border/15 bg-surface-elevated px-3 py-2 text-[11px] leading-4 text-foreground shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(ci,{size:13,strokeWidth:2.5,className:"shrink-0 text-primary","aria-hidden":"true"}),s.jsx("span",{className:"truncate tabular-nums",children:I}),s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n?"预览 ›":"Preview ›"})]})}),c&&ki.createPortal(s.jsx(OI,{result:c.result,message:c.message,onClose:()=>h(null)}),document.body)]})}const $I=320,tx="termdock:mobile-keyboard-expanded",rx="termdock:mobile-keyboard-preset-mode",nx="termdock:mobile-long-press-mode",UI=80;function zI(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function sx(e){const t=(e instanceof Error?e.message:String(e)).slice(0,3e3);return/importing a module script failed|dynamically imported module|loading chunk/i.test(t)?`压缩模块加载失败,可能是页面版本过旧或网络中断。请更新页面后重试,无需清除转码器缓存。
68
+ ${t}`:t}function HI(e){switch(e?.phase){case"loading":return`正在加载转码器… ${e.progress??0}%(优先使用浏览器缓存)`;case"saving":return"加载完成,正在保存到本机…";case"initializing":return e.source==="local"?"已找到本机缓存,正在初始化转码器…":"正在初始化本地转码器…";case"ready":return e.source==="local"?"已从本机缓存加载,转码器已就绪。":e.saved?"转码器已就绪,已保存到本机供下次使用。":"转码器已就绪。";default:return"正在检查本机转码器缓存…"}}function _p(){return typeof window>"u"?!1:(navigator.maxTouchPoints>0||"ontouchstart"in window)&&window.innerWidth<768}const WI={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},GI=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=g1(),colorTheme:a="dark",toolbarPresets:l=[],isActive:c=!0,focusSuspended:h=!1,deferCursorUntilPositioned:p=!1,isLayoutVisible:g=!0,focusRequestToken:x=0,resumeRequestToken:y=0,resumeRequestReason:A="visibility",resumeRequestDelayMs:v=0,forceResumeReconnect:L=!1,initialConnectDelayMs:I=0,initialConnectEnabled:E=!0,resumeRequestEnabled:R=!0,onStreamReadyChange:P,onStreamConnected:Q,onViewportReadyChange:$,onContentReadyChange:W,onKeyboardVisibilityChange:B,suppressKeyboard:q=!1,keyboardPortalTarget:ne=null,sharedMobileKeyboardLayout:Be=!1,suppressPageFlipRefresh:fe=!1,showDebug:X,onStatusChange:Qe})=>{const{t:Pe}=Hr(),[ue]=S.useState(e||r3()),[Ce,tt]=S.useState(()=>(e?cm(e):null)??n.fontSize),we=S.useMemo(()=>Yk(),[]),ce=S.useMemo(()=>p0("session"),[]),$e=S.useMemo(()=>p0("keyboard"),[]),ke=S.useRef(null),se=S.useRef(null);S.useEffect(()=>{cm(ue)===null&&tt(n.fontSize)},[n.fontSize,ue]);const je=S.useMemo(()=>({...n,fontSize:Ce}),[n,Ce]),[de,Oe]=S.useState(_p),[Ee,_e]=S.useState(!1),[re,Fe]=S.useState(!1),[wt,Xe]=S.useState(!1),[ee,Ue]=S.useState(()=>typeof document>"u"?!0:!document.hidden&&Tu()),[Le,te]=S.useState(()=>typeof document>"u"?!0:document.hasFocus()),[ye,ot]=S.useState(!1),[le,xe]=S.useState(!1),[Ne,yt]=S.useState(!1),[gt,At]=S.useState(!1),[Ft,Z]=S.useState(!0),{isOpen:Ge,keyboardHeight:pt}=ty({enabled:de&&c}),[Pt,hr]=S.useState(null),[Zt,_r]=S.useState(null),[ae,ze]=S.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(tx)==="true"),[Je,Rt]=S.useState(()=>{if(typeof window>"u")return"auto";const oe=window.localStorage.getItem(rx);return oe&&oe.length>0?oe:"auto"}),[Mt,ir]=S.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(nx)==="copy"?"copy":"arrows"),[Ut,We]=S.useState("idle"),[br,Ze]=S.useState("idle"),[Dt,nt]=S.useState(0),[_t,Qr]=S.useState(null),[yr,Nt]=S.useState(null),Nn=S.useCallback(()=>Nt(null),[]),{preferences:Zr,update:lt,saveFailed:gr}=v1(),{videoEnabled:Pr,videoMaxHeight:be,videoBitrate:Er,imageEnabled:at,imageMaxDimension:en,imageQuality:Te}=Zr,[Lt,Y]=S.useState(!1),[st,xt]=S.useState(null),[Gt,Gr]=S.useState(null),Fr=Jr(oe=>oe.sessions.get(ue)),{setTerminalSession:ur,setConnecting:tn,appendToBuffer:on,replaceBuffer:Xr,clearTerminalSession:Wr,removeTerminalSession:$r,clearBuffer:Ur,setSessionActiveProgram:Cn,setSessionCwd:Rn,setSessionCopyMode:hn,setSessionAgentStatus:Vr,setSessionShellTitle:ys,setSessionPromptState:cn,clearAgentNeedsReview:Vt}=Jr.getState(),hs=S.useMemo(()=>`wt-${ue.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[ue]),Sn=Fr?.terminalSessionId??null,rs=Fr?.mode??"shell",qr=Fr?.activeProgram??null,_n=S.useMemo(()=>o0(l),[l]),un=rs==="tmux",Bn=Fr?.bufferChunks??[],Nr=Fr?.isConnecting??!1,zr=Sn,wn=S.useCallback(async(oe,Ve)=>{const Tt=xk(oe,Fr?.cwd||Fr?.directory);if(!Tt)return;let Et=Tt,qe="directory";try{Et=(await r1(Tt)).path}catch(vt){if(!(vt instanceof Error)||vt.message!=="Path is not a directory")return;qe="file"}try{const vt=sr.getState();vt.setRightTab("files"),vt.openRight(),window.dispatchEvent(new CustomEvent(dk,{detail:{path:Et,kind:qe,line:Ve}}))}catch{}},[Fr?.cwd,Fr?.directory]),V=t??Fr?.mode??"shell",et=V==="tmux"?r??Fr?.tmuxSessionName??null:null,[kt,Bt]=S.useState(null),zt=S.useRef(!1),[gn,lr]=S.useState(!1),[yn,ar]=S.useState(!1),[Ln,rn]=S.useState(null),[$n,ns]=S.useState(0),[vs,fs]=S.useState(null),Gn=X!==void 0?X:!1,fn=S.useRef(null),Un=S.useRef(null),xr=S.useRef(null),z=S.useRef(null),ge=S.useRef(null),Ye=S.useRef(!1),ct=S.useRef(null),it=S.useRef([]),bt=S.useRef(0),Ot=S.useRef(!1),qt=S.useRef(null),dt=S.useRef(null),nr=S.useRef(-1),Lr=S.useRef(null),vr=S.useRef(0),$t=S.useRef(null),rt=S.useRef(null),jt=S.useRef(0),U=S.useRef(0),G=S.useRef(!1),he=S.useRef(null),Me=S.useRef(null),Qt=S.useRef(!1),It=S.useRef(0),tr=S.useRef(!1),fr=S.useRef(!1),jr=S.useRef(!1),kn=S.useRef(null),O=S.useRef(null),Ae=S.useRef(null),Re=S.useRef(c);Re.current=c;const mt=S.useRef(h);mt.current=h;const Ct=S.useRef(de),or=S.useRef(null),Jt=S.useRef(null),Ht=S.useRef(null),Or=S.useRef(null),Mn=S.useRef(null),ws=S.useRef(null),Pi=S.useRef(null),Oi=S.useCallback(()=>{const oe=++It.current,Ve=()=>{oe===It.current&&xe(!0)};if(typeof window>"u"){Ve();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(Ve))},[]),gs=S.useCallback(oe=>{if(tr.current){if(O.current!==null&&(window.clearTimeout(O.current),O.current=null),oe.x===0&&oe.y>=oe.rows-1){Z(!1);return}O.current=window.setTimeout(()=>{O.current=null,Z(!0)},UI)}},[]),Ks=S.useRef(null);S.useEffect(()=>()=>{Ks.current?.()},[]);const hi=S.useCallback(()=>{Ks.current||(Ks.current=o1(()=>{Ks.current=null;const oe=Jr.getState(),Ve=xr.current,Tt=oe.getTerminalSession(ue);if(!Ve||Tt?.mode!=="shell"||oe.hasPendingBufferWrites(ue))return;const Et=m8(Ve),qe=ge.current?.getDimensions();if(!Et||!qe)return;const vt=ge.current?.serializeSnapshot();vt&&g8({id:Ve,version:1,...Et,...qe,data:vt,savedAt:Date.now()})},2e3))},[ue]),Is=S.useCallback(oe=>{const Ve=Jr.getState(),Tt=Ve.getTerminalSession(ue)?.bufferChunks.at(-1)?.id;if(xr.current&&Tt!==void 0&&Tt<=oe&&!Ve.hasPendingBufferWrites(ue)&&(x8(xr.current),hi()),!G.current||!_I({writtenChunkId:oe,initialTargetChunkId:he.current}))return;const Et=Me.current;Me.current=null,Et!==null&&ge.current?.notifyScreenSynchronized(Et),G.current=!1,he.current=null,Oi()},[Oi,hi,ue]),As=S.useCallback(oe=>{if(!tr.current)return;const Ve=kn.current;Ve&&Ve.x===oe.x&&Ve.y===oe.y&&Ve.rows===oe.rows||(kn.current=oe,O.current!==null&&(window.clearTimeout(O.current),O.current=null),oe.x===0&&oe.y>=oe.rows-1&&Z(!1))},[]);S.useEffect(()=>{if(!p){fr.current=!1;return}fr.current||(fr.current=!0,jr.current=!1,tr.current=!0,kn.current=null,Z(!1),O.current!==null&&(window.clearTimeout(O.current),O.current=null),Ae.current!==null&&window.clearTimeout(Ae.current),Ae.current=window.setTimeout(()=>{Ae.current=null,O.current!==null&&typeof window<"u"&&window.clearTimeout(O.current),O.current=null,tr.current=!1,Z(!0)},15e3))},[p]);const zn=S.useCallback(()=>{Or.current=null;const oe=Ht.current;Ht.current=null,oe&&ys(oe.sessionId,oe.title)},[ys]),na=S.useCallback((oe,Ve)=>{if(Ht.current={sessionId:oe,title:Ve},Or.current===null){if(typeof window>"u"){zn();return}Or.current=window.requestAnimationFrame(zn)}},[zn]),Ra=S.useCallback(()=>{Or.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Or.current),Or.current=null,Ht.current=null},[]),Xs=S.useCallback(async()=>{const oe=V;return(await b8({preferredFrontendSessionId:ue,mode:oe,tmuxSessionName:oe==="tmux"?et||hs:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[V,et,hs,ue]),uo=S.useRef(c);S.useEffect(()=>{if(!c){ge.current?.blur(),uo.current=!1;return}if(uo.current)return;uo.current=!0;const oe=NL(de,fe);if(oe==="single"){ge.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}oe!=="none"&&ge.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[c,de,fe,zr]),S.useEffect(()=>{Ct.current=de},[de]);const Es=S.useCallback(()=>{!Re.current||mt.current||ge.current?.focus()},[]);S.useLayoutEffect(()=>{h&&ge.current?.blur()},[h]),S.useEffect(()=>{if(!c||h||Ft||jr.current)return;jr.current=!0;const oe=window.requestAnimationFrame(()=>{ge.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(oe)},[h,c,Ft]);const Vn=S.useCallback(oe=>{typeof window>"u"||typeof document>"u"||!Re.current||mt.current||Ct.current||document.hidden||!Tu()||(or.current!==null&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{if(or.current=null,!Re.current||mt.current||Ct.current||document.hidden||!Tu())return;const Ve=document.activeElement,Tt=Ve?.getAttribute("data-terminal-input-anchor")==="true";if((Ve instanceof HTMLInputElement||Ve instanceof HTMLTextAreaElement||Ve instanceof HTMLSelectElement||Ve?.isContentEditable===!0)&&!Tt){$e("desktop resume focus skipped: editable active",{reason:oe});return}$e("desktop resume focus",{reason:oe}),ge.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),ge.current?.focus()},50))},[$e]);S.useEffect(()=>()=>{or.current!==null&&typeof window<"u"&&window.clearTimeout(or.current),or.current=null,Jt.current!==null&&typeof window<"u"&&window.clearTimeout(Jt.current),Jt.current=null,Mn.current!==null&&typeof window<"u"&&window.clearTimeout(Mn.current),Mn.current=null,ws.current!==null&&typeof window<"u"&&window.clearTimeout(ws.current),ws.current=null,Ae.current!==null&&typeof window<"u"&&window.clearTimeout(Ae.current),Ae.current=null,O.current!==null&&typeof window<"u"&&window.clearTimeout(O.current),O.current=null},[]),S.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const oe=()=>{Jt.current!==null&&window.clearTimeout(Jt.current),Jt.current=window.setTimeout(()=>{Jt.current=null;const Ve=document.activeElement,Et=!(Ve?.getAttribute("data-terminal-input-anchor")==="true")&&!!(Ve&&(Ve instanceof HTMLInputElement||Ve instanceof HTMLTextAreaElement||Ve instanceof HTMLSelectElement||Ve.isContentEditable));qT({isActive:Re.current&&!mt.current,isMobile:Ct.current,documentVisible:!document.hidden,activeElementIsEditable:Et})&&Es()},0)};return document.addEventListener("pointerup",oe),()=>{document.removeEventListener("pointerup",oe),Jt.current!==null&&(window.clearTimeout(Jt.current),Jt.current=null)}},[Es]);const Ms=S.useCallback(()=>{ss.current=!1,ns(oe=>oe+1)},[]),ho=S.useCallback((oe,Ve,Tt)=>{const Et=xr.current,qe=Date.now();if(Et&&Ve&&y8(Et)){se.current={startedAt:qe,strategy:"reconnect",reason:oe},ha("info","PWA_RESUME terminal-start",{frontendSessionId:ue,backendSessionId:Et,strategy:"reconnect",reason:oe,active:Re.current});return}if(Et&&v8(Et,()=>{const vt=se.current;ha("info","PWA_RESUME terminal-responsive",{frontendSessionId:ue,backendSessionId:Et,durationMs:vt?Date.now()-vt.startedAt:null,strategy:vt?.strategy??"probe",reason:vt?.reason??oe}),se.current=null,Q?.(ue)},{visible:Tt})){se.current={startedAt:qe,strategy:"probe",reason:oe},ha("info","PWA_RESUME terminal-start",{frontendSessionId:ue,backendSessionId:Et,strategy:"probe",reason:oe,active:Re.current}),ce("[Terminal] resume probe sent",{reason:oe,backendSessionId:Et,active:Re.current});return}if(ce("[Terminal] resume probe missing connection, restarting ensureSession",{reason:oe,backendSessionId:Et,active:Re.current}),!LI({initialConnectionPending:Qt.current})){ce("[Terminal] resume probe deferred during initial websocket handshake",{reason:oe,backendSessionId:Et});return}Ms()},[ce,Q,Ms,ue]),pa=S.useCallback((oe,Ve)=>{const Tt=xr.current;Tt&&ct.current!==oe&&(ct.current=oe,xg(Tt,oe,Ve),ce("[Terminal] flow-control state sent",{backendSessionId:Tt,paused:oe,reason:Ve}))},[ce]),Fi=S.useCallback((oe,Ve)=>{const Tt=xr.current;Tt&&$t.current!==oe&&($t.current=oe,bg(Tt,oe,Ve),ce("[Terminal] focus state sent",{backendSessionId:Tt,focused:oe,reason:Ve}))},[ce]),ma=S.useCallback((oe,Ve)=>{const Tt=xr.current;Tt&&rt.current!==oe&&(rt.current=oe,yg(Tt,oe,Ve),ce("[Terminal] viewing state sent",{backendSessionId:Tt,viewing:oe,reason:Ve}))},[ce]),Ma=GT({isActive:c&&!h,viewportFocused:wt,documentVisible:ee,windowFocused:Le,streamReady:ye}),$i=VT({isActive:c,documentVisible:ee,windowFocused:Le,streamReady:ye,isDesktop:ao()!==null}),fo=S.useRef(Ma),fi=S.useRef($i);S.useEffect(()=>{fo.current=Ma,Fi(Ma,"logical-focus-change")},[Ma,Fi,zr]),S.useEffect(()=>{fi.current=$i,ma($i,"logical-viewing-change")},[$i,ma,zr]),oS(zr,ee,ye),S.useEffect(()=>{const oe=Ve=>{const Tt=Ve.detail;!Tt||Tt.sessionId!==ue||tt(Tt.fontSize??n.fontSize)};return window.addEventListener("termfontchange",oe),()=>window.removeEventListener("termfontchange",oe)},[ue,n.fontSize]),S.useEffect(()=>{const oe=()=>{const qe=!document.hidden&&Tu();Ue(qe),qe&&c&&Vn("visibility")},Ve=qe=>{c&&Vn(qe.persisted?"bfcache":"pageshow")},Tt=()=>{te(!0),Vn("window-focus")},Et=()=>te(!1);return document.addEventListener("visibilitychange",oe),window.addEventListener(vg,oe),window.addEventListener("pageshow",Ve),window.addEventListener("focus",Tt),window.addEventListener("blur",Et),()=>{document.removeEventListener("visibilitychange",oe),window.removeEventListener(vg,oe),window.removeEventListener("pageshow",Ve),window.removeEventListener("focus",Tt),window.removeEventListener("blur",Et)}},[c,Vn]),S.useEffect(()=>{if(!y||!R||!ga.current)return;const oe=v,Ve=oe<=0,Tt=ke.current;if(Tt?.token===y&&(Tt.visible||!Ve))return;const Et=()=>{ke.current={token:y,visible:Ve},ge.current?.requestRefresh(A,{skipScrollToBottom:!0}),ho(oe>0?"global-resume-background":"global-resume-visible",oe<=0&&L,Ve)};if(oe<=0){Et();return}const qe=window.setTimeout(Et,oe);return()=>window.clearTimeout(qe)},[y,A,R,v,L,ho]);const Ds=S.useRef(0);S.useEffect(()=>{if(ye){Ds.current=0;return}if(!gn||kt==="Authentication required"||kt===Lh)return;const oe=Ds.current,Ve=Math.min(2e3*Math.pow(2,Math.min(oe,4)),3e4),Tt=setTimeout(()=>{Ds.current+=1,ce("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:Ds.current,backendSessionId:xr.current}),Bt("Reconnecting..."),lr(!1),Ms()},Ve);return()=>clearTimeout(Tt)},[kt,gn,ye,$n,ce,Ms]),S.useEffect(()=>{if(typeof window>"u"){_e(!1);return}const oe=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;_e(oe)},[]),S.useEffect(()=>{(!c||!de)&&Fe(!1),c||Xe(!1)},[c,de]),S.useEffect(()=>{xr.current=zr,nr.current=-1,Me.current=null,$t.current=null,rt.current=null,ct.current=null},[zr]),S.useEffect(()=>{P?.(ue,ye)},[ye,P,ue]),S.useEffect(()=>{W?.(ue,ye&&le&&Ne)},[le,Ne,ye,W,ue]),S.useEffect(()=>{un||(Ot.current=!1,qt.current=null,dt.current&&(clearTimeout(dt.current),dt.current=null))},[un]),S.useEffect(()=>{zr&&ge.current?.requestRefresh("session-key-change",{force:!0})},[zr]),S.useEffect(()=>{const oe=c&&de&&Ge;$e("visibility signal",{sessionId:ue,isActive:c,isMobile:de,isInputFocused:re,isViewportKeyboardOpen:Ge,viewportKeyboardHeight:pt,visible:oe}),B?.(ue,oe)},[B,ue,c,de,Ge,pt,$e]),S.useEffect(()=>{c&&x&&x!==vr.current&&(vr.current=x,Es())},[x,Es,c]),S.useEffect(()=>{z.current=ue},[ue]),S.useEffect(()=>{!de&&(Pt!==null||Zt!==null)&&(hr(null),_r(null),Lr.current=null)},[de,Pt,Zt]),S.useEffect(()=>{!zr&&(Pt!==null||Zt!==null)&&(hr(null),_r(null),Lr.current=null)},[zr,Pt,Zt]),S.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(tx,ae?"true":"false")},[ae]),S.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(rx,Je)},[Je]),S.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(nx,Mt)},[Mt]),S.useEffect(()=>{Oe(_p());const oe=()=>{Oe(_p())};return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[]);const pn=S.useCallback(()=>{jt.current+=1,U.current+=1,zn(),Ra();const oe=fn.current;fn.current=null,Un.current=null,Qt.current=!1,ot(!1),ge.current?.setSessionReady(!1);const Ve=xr.current;Ve&&xg(Ve,!1,"stream-disconnect"),Ye.current=!1,ct.current=null,it.current=[],oe?.()},[Ra,zn]),Da=S.useCallback(async oe=>{if(Un.current===oe){ce(`[startStream] Skipping - already connected to ${oe}`);return}ce(`[startStream] Starting stream for frontendSessionId=${ue} backendSessionId=${oe}`),rn(null),It.current+=1,G.current=!1,he.current=null,xe(!1),yt(!1),pn();const Ve=jt.current+1;jt.current=Ve,Qt.current=!0;const Tt=Jr.getState().getTerminalSession(ue);if(Tt?.mode==="shell"&&!Tt.bufferChunks.length){const qe=await Promise.race([w8(oe),new Promise(vt=>window.setTimeout(()=>vt(null),75))]);if(jt.current!==Ve||z.current!==ue)return;if(qe&&!Jr.getState().getTerminalSession(ue)?.bufferChunks.length){Jr.getState().replaceBuffer(ue,[qe.data]);const vt=ge.current?.getDimensions();vt?.cols===qe.cols&&vt.rows===qe.rows&&A8(oe,qe.seq,qe.epoch)}}const Et=we.connect(oe,{onEvent:qe=>{if(jt.current!==Ve)return;const vt=ue;if(vt)switch(qe.type){case"connected":{U.current+=1,Qt.current=!1;const wr=se.current;wr&&(ha("info","PWA_RESUME terminal-connected",{frontendSessionId:vt,backendSessionId:xr.current,durationMs:Date.now()-wr.startedAt,strategy:wr.strategy,reason:wr.reason}),se.current=null),Q?.(vt),(qe.runtime||qe.ptyBackend)&&ce(`[Terminal] connected frontendSessionId=${vt} backendSessionId=${xr.current} runtime=${qe.runtime??"unknown"} pty=${qe.ptyBackend??"unknown"} cwd=${qe.cwd??"unknown"}`),tn(vt,!1),Bt(null),lr(!1),rn(null),ot(!0),xr.current&&(bg(xr.current,fo.current,"stream-connected"),yg(xr.current,fi.current,"stream-connected")),ge.current?.setSessionReady(!0),ct.current=null,pa(Ye.current,"stream-connected"),qe.tuiProgress!==void 0&&Jr.getState().setSessionTuiProgress(vt,qe.tuiProgress??null),qe.shellTitle!==void 0&&Jr.getState().setSessionShellTitle(vt,qe.shellTitle??null),qe.promptState!==void 0&&qe.promptState!==null&&Jr.getState().setSessionPromptState(vt,qe.promptState);const Yr=Jr.getState().getTerminalSession(vt);if(Yr?.terminalSessionId&&qe.mode&&Jr.getState().setTerminalSession(vt,{sessionId:Yr.terminalSessionId,cols:80,rows:24,mode:qe.mode,tmuxSessionName:qe.tmuxSessionName??null,cwd:qe.cwd??null}),qe.activeProgram!==void 0&&Cn(vt,qe.activeProgram??null,qe.activeProgramSource??null,qe.activeProgramRaw??null),ge.current?.requestRefresh("connected",{force:!0,reconcileServerSize:Re.current}),qe.mode!=="tmux"&&(fs(null),hn(vt,!1)),ce("[Terminal] Connected event received:",{frontendSessionId:vt,backendSessionId:xr.current,storeHasState:!!Yr,storeTerminalId:Yr?.terminalSessionId,hasHistoryInStore:!!Yr?.history?.length,historyLength:Yr?.history?.length??0}),Yr?.history&&Yr.history.length>0){ce(`[Terminal] Restoring ${Yr.history.length} history chunks to frontend session ${vt}`);const F=Yr.history.reduce((He,Ie)=>He+Ie.length,0),H=Math.max(300,Math.min(2e3,Math.ceil(F/200)));bt.current=Date.now()+H,Yr.history.forEach(He=>{on(vt,He,{markActivity:!1})}),Jr.getState().setSessionHistory(vt,[]),ce(`[Terminal] History restoration complete for ${vt}`)}else ce(`[Terminal] No history to restore for ${vt}`);const k=qe.replayChunks,D=!!Yr?.history?.length||!!k?.length;if(D?G.current=!0:Oi(),k&&k.length>0){let F=null;if(qe.replayOutOfWindow)ce(`[Terminal] Replay out-of-window, atomically replacing buffer (${k.length} chunks)`),F=Xr(vt,mS(k));else{ce(`[Terminal] Replay incremental: ${k.length} chunks`);for(const Ie of k)on(vt,Ie)}const H=k.reduce((Ie,ft)=>Ie+ft.length,0),He=Math.max(200,Math.min(1500,Math.ceil(H/200)));bt.current=Math.max(bt.current,Date.now()+He),he.current=F}D&&he.current===null&&(he.current=Jr.getState().flushPendingBufferWrites(vt),he.current===null&&(G.current=!1,Oi()));break}case"reconnecting":{rn(wr=>wr??Date.now()),Bt("Reconnecting..."),lr(!1);break}case"data":{qe.data&&(Ye.current?it.current.push(qe.data):on(vt,qe.data));break}case"tmux-layout":{fs(qe.layout??null),qe.layout&&hn(vt,qe.layout.inCopyMode);break}case"tmux-screen-sync":{const wr=qe.generation??0;if(wr<nr.current)break;nr.current=wr,It.current+=1,G.current=!0,xe(!1),it.current=[],ge.current?.prepareScreenReplacement(),Me.current=wr,he.current=Xr(vt,gS(qe.chunks??[])),he.current===null&&(Me.current=null,ge.current?.notifyScreenSynchronized(wr),G.current=!1,Oi()),typeof qe.cols=="number"&&typeof qe.rows=="number"&&ge.current?.notifyServerSize(qe.cols,qe.rows,"tmux-screen-sync");break}case"active-program":{Cn(vt,qe.activeProgram??null,qe.activeProgramSource??null,qe.activeProgramRaw??null);break}case"cwd":{Rn(vt,qe.cwd??null);break}case"agent-status":{Vr(vt,{agentStatus:qe.agentStatus??null,agentIndicator:qe.agentIndicator??null,agentStatusDetail:qe.agentStatusDetail??null,agent:qe.agent??null,agentMessage:qe.agentMessage??null,agentNativeSessionId:qe.agentNativeSessionId??null,agentResumeRecovered:qe.agentResumeRecovered===!0,agentRich:qe.agentRich===!0,agentActivity:qe.agentActivity??0,agentCwd:qe.agentCwd??null,reviewed:qe.reviewed??null});break}case"git-status":{Jr.getState().setSessionGitStatus(vt,qe.gitStatus??null);break}case"focus-mode":{ce("[Terminal] focus tracking mode",{backendSessionId:xr.current,requested:qe.focusTrackingRequested===!0});break}case"resize-ack":{ge.current?.acknowledgeResize({seq:qe.seq,ok:qe.ok!==!1,cols:qe.cols,rows:qe.rows,screenSyncPending:qe.screenSyncPending,screenSyncGeneration:qe.screenSyncGeneration});break}case"pty-size":{typeof qe.cols=="number"&&typeof qe.rows=="number"&&ge.current?.notifyServerSize(qe.cols,qe.rows,qe.source);break}case"shell-title":{na(vt,qe.title??null);break}case"prompt-state":{cn(vt,qe.state??"idle",qe.exitCode??null);break}case"tui-progress":{Jr.getState().setSessionTuiProgress(vt,qe.tuiProgress??null);break}case"exit":{const wr=typeof qe.exitCode=="number"?qe.exitCode:null,Yr=typeof qe.signal=="number"?qe.signal:null;on(vt,`\r
69
+ [Process exited${wr!==null?` with code ${wr}`:""}${Yr!==null?` (signal ${Yr})`:""}]\r
70
+ `),Wr(vt),tn(vt,!1),Bt("Terminal session ended"),ot(!1),lr(!1),rn(null),fs(null),hn(vt,!1),pn();break}}},onError:(qe,vt)=>{if(jt.current!==Ve)return;const wr=ue;if(!wr)return;Qt.current=!1;const Yr=vt&&qe.message==="Authentication required",k=J2(qe),D=Yr?qe.message:k||vt?"Reconnecting...":qe.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${vt}):`,D),k&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:xr.current,frontendSessionId:wr,isActive:c,isMobile:de,fatal:vt,stack:new Error().stack}),Bt(D),lr(!!vt),vt&&(rn(null),tn(wr,!1),pn(),k&&(ce("[onError] Session lost, auto-recreating"),Bt("Reconnecting..."),lr(!1),Wr(wr),Ur(wr),xr.current=null,ss.current=!1,Ms()))}},{...WI,getDimensions:()=>ge.current?.getDimensions()??null});fn.current=()=>{Et.close(),jt.current===Ve&&(Un.current=null)},Un.current=oe},[on,Ur,Wr,ce,pn,Oi,Q,pa,Ms,na,tn,Cn,Vr,hn,Rn,cn,we,ue]);S.useEffect(()=>{const oe=MI({isActive:c,isStreamReady:ye,reconnectStartedAt:Ln,now:Date.now()});if(oe===null)return;const Ve=window.setTimeout(()=>{ce("[Terminal] visible reconnect watchdog expired",{backendSessionId:xr.current,reconnectStartedAt:Ln}),pn(),tn(ue,!1),Bt("Reconnecting..."),lr(!1),rn(Date.now()),Ms()},oe);return()=>window.clearTimeout(Ve)},[ce,pn,c,ye,Ln,Ms,ue,tn]);const ss=S.useRef(!1),ga=S.useRef(!1),Ns=S.useRef(0);S.useEffect(()=>()=>{Ns.current+=1,ss.current=!1,pn()},[pn]);const cl=S.useRef(V),pi=S.useRef(et);S.useEffect(()=>{const oe=cl.current,Ve=pi.current;cl.current=V,pi.current=et,z.current===ue&&(oe===V&&Ve===et||(ss.current=!1,pn(),ns(Tt=>Tt+1)))},[V,et,pn,ue]),S.useEffect(()=>{if(z.current!==ue&&(ce(`[useEffect] sessionId changed from ${z.current} to ${ue}, allowing reinitialization`),ss.current=!1,ga.current=!1),ss.current&&z.current===ue){ce(`[useEffect] Already initialized for sessionId=${ue}, skipping`);return}if(!gt)return;const oe=async vt=>{if(ce(`[ensureSession] Starting for sessionId=${ue}, runId=${vt}`),!z.current||z.current!==ue){ce(`[ensureSession] SessionId mismatch or stale run (current=${z.current}, target=${ue}), skipping`);return}if(vt!==Ns.current){ce(`[ensureSession] Stale run detected (runId=${vt}, currentRunId=${Ns.current}), skipping`);return}const wr=Jr.getState(),Yr=wr.getTerminalSession(ue),k=Yr?.mode??V;ce("[ensureSession] Current state from store:",{terminalSessionId:Yr?.terminalSessionId,mode:Yr?.mode,tmuxSessionName:Yr?.tmuxSessionName,isConnecting:Yr?.isConnecting});let D=Yr?.terminalSessionId??null,F=!D;if(D&&k!==V?(ce(`[ensureSession] Store mode mismatch for ${D}: current=${k} desired=${V}, will create new session`),F=!0,wr.clearTerminalSession(ue),D=null):D&&V==="tmux"&&et&&Yr?.tmuxSessionName!==et&&(ce(`[ensureSession] Store tmux name mismatch for ${D}: current=${Yr?.tmuxSessionName} desired=${et}, will create new session`),F=!0,wr.clearTerminalSession(ue),D=null),D&&we.checkHealth&&!Re.current){ce(`[ensureSession] Checking health of existing session ${D}`);try{const H=await we.checkHealth(D);if(ce("[ensureSession] Health check result:",H),!H.healthy)ce(`[ensureSession] Session ${D} is NOT healthy (healthy=${H.healthy}), will create new session`),ce("[ensureSession] Health check details:",H),F=!0,H.mode&&Yr?.terminalSessionId&&wr.setTerminalSession(ue,{sessionId:Yr.terminalSessionId,cols:80,rows:24,mode:H.mode,tmuxSessionName:H.tmuxSessionName??null}),wr.clearTerminalSession(ue),ce("[ensureSession] Cleared unhealthy session from store");else{ce(`[ensureSession] Session ${D} is healthy, reusing it, cwd=${H.cwd}, clients=${H.clients}, lastActivity=${Date.now()-(H.lastActivity||0)}ms ago`),H.mode&&Yr?.terminalSessionId&&wr.setTerminalSession(ue,{sessionId:Yr.terminalSessionId,cols:80,rows:24,mode:H.mode,tmuxSessionName:H.tmuxSessionName??null}),ce(`[ensureSession] Setting terminalIdRef to ${D} and starting stream`),xr.current=D,Da(D),ce(`[ensureSession] Successfully reused healthy session ${D}, returning early`);return}}catch(H){ce(`[ensureSession] Failed to check health of session ${D}:`,H),ce("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ce(`[ensureSession] Decision: shouldCreateNewSession=${F}, terminalId=${D}`),F){ce(`[ensureSession] Creating new session, shouldCreateNewSession=${F}, runId=${vt}`),Bt(null),lr(!1),wr.setConnecting(ue,!0);const He=Jr.getState().getTerminalSession(ue),ft=(He?.mode??V)===V&&(V!=="tmux"||!et||He?.tmuxSessionName===et);if(He?.terminalSessionId&&ft)ce(`[ensureSession] Race condition avoided: another instance already created session ${He.terminalSessionId}`),wr.setConnecting(ue,!1),D=He.terminalSessionId,F=!1;else try{const ut=await Xs();if(ce(`[ensureSession] Opened managed backend session ${ut.sessionId}`),vt!==Ns.current){ce(`[ensureSession] Stale run after session creation (runId=${vt}, currentRunId=${Ns.current}), leaving ${ut.sessionId} for sibling`);return}wr.setTerminalSession(ue,ut),ce(`[ensureSession] Updated store with new session ${ut.sessionId}`),D=ut.sessionId}catch(ut){if(vt!==Ns.current){ce("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(ut instanceof Gf&&Em(ut)){ce("[ensureSession] Confirmed missing persisted session:",{sessionId:ue,error:ut.message}),wr.clearTerminalSession(ue),Bt(Lh),lr(!0),wr.setConnecting(ue,!1);return}Bt("Reconnecting..."),lr(!0),wr.setConnecting(ue,!1);return}}if(vt!==Ns.current){ce(`[ensureSession] Stale run before starting stream (runId=${vt}, currentRunId=${Ns.current}), skipping`);return}if(!D){ce(`[ensureSession] No terminalId, terminalId=${D}`);return}ce(`[ensureSession] Starting stream for session ${D}`),xr.current=D,Da(D),ce(`[ensureSession] ensureSession completed for sessionId=${ue}, terminalId=${D}`)};let Ve=null,Tt=null;const Et=()=>{Tt=null,!(ss.current&&z.current===ue)&&(ce(`[useEffect] Running ensureSession for sessionId=${ue}, hasInitialized=${ss.current}`),ss.current=!0,ga.current=!0,Ve=++Ns.current,oe(Ve))};if(!E&&!ga.current){ce(`[useEffect] Holding background connection until the selected session is ready: ${ue}`);return}const qe=ga.current?0:Math.max(0,I);return qe>0?(ce(`[useEffect] Delaying initial connection for sessionId=${ue} by ${qe}ms`),Tt=window.setTimeout(Et,qe)):Et(),()=>{Tt!==null&&window.clearTimeout(Tt),ce(`[useEffect] Cleanup for sessionId=${ue}, runId=${Ve??"pending"}`)}},[ue,$n,Da,pn,we,ce,V,et,hs,I,E,gt]);const ja=S.useCallback(async()=>{if(ue&&!yn){ar(!0),Bt(null),lr(!1),rn(null),pn();try{we.forceKill&&await we.forceKill({sessionId:ue})}catch{}$r(ue),Ur(ue),ge.current?.clear(),await new Promise(oe=>setTimeout(oe,100));try{tn(ue,!0);const oe=await Xs();ur(ue,oe),xr.current=oe.sessionId,Da(oe.sessionId)}catch(oe){Bt(oe instanceof Gf&&Em(oe)?Lh:"Reconnecting..."),lr(!0),tn(ue,!1)}finally{ar(!1)}}},[ue,yn,pn,we,$r,Ur,tn,ur,Da,Xs]),po=S.useCallback((oe,Ve,Tt,Et)=>{if(!(xr.current!==Ve||U.current!==Tt)){if(oe instanceof Gf&&J2(oe)){ce("[Terminal] operation backend missing, recovering",{terminalId:Ve,sessionId:ue}),Bt("Reconnecting..."),lr(!1),pn(),Wr(ue),xr.current=null,tn(ue,!0),Ms();return}Bt(oe instanceof Error?oe.message:Et)}},[Wr,ce,pn,Ms,ue,tn]),Il=S.useCallback((oe,Ve)=>{if(!Re.current&&!Ve?.targeted||!oe)return;const Tt=eI(oe),Et=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(oe);if(un&&Et&&(Ot.current=!0),Date.now()<bt.current)return;let qe=oe,vt=Ve?.consumeModifier??!1;if(!Ve?.skipModifierTransform&&Pt&&oe.length>0){const F=oe[0];if(F.length===1&&/[a-zA-Z]/.test(F)){const H=F.toUpperCase();Pt==="ctrl"?(qe=String.fromCharCode(H.charCodeAt(0)&31),vt=!0):Pt==="alt"&&(qe=`\x1B${oe}`,vt=!0)}vt||(Pt==="alt"&&(qe=`\x1B${oe}`),vt=!0)}const wr=xr.current;if(!wr)return;const Yr=U.current,D=(async()=>{try{if(un&&!Tt&&Ot.current&&we.tmuxAction){Ot.current=!1;try{await we.tmuxAction(wr,{action:"copy-mode",enabled:!1})}catch{}if(xr.current!==wr||U.current!==Yr)return!1;if(tI(qe))return!0}return await we.sendInput(wr,qe),Vt(ue),!0}catch(F){return po(F,wr,Yr,"Failed to send input"),!1}})();return vt&&(Zt||hr(null),Es()),D},[Pt,Vt,Es,po,un,Zt,ue,we]);S.useEffect(()=>{const oe=Ve=>{const Tt=Ve,Et=Tt.detail?.sessionId;if(Et?Et!==ue:!Re.current)return;const qe=Tt.detail?.text;if(!qe)return;const vt=Tt.detail?.nonce;if(zt.current||!ge.current){vt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:vt,ok:!1}}));return}const wr=ge.current?.sendSequence(qe,{paste:Tt.detail?.paste,targeted:!!Et});vt&&Promise.resolve(wr).then(Yr=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:vt,ok:Yr===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:vt,ok:!1}}))}),YT(Ct.current,Tt.detail?.focus!==!1)&&Es()};return window.addEventListener("termdock-insert-reference",oe),()=>window.removeEventListener("termdock-insert-reference",oe)},[Es,ue]);const ul=S.useCallback((oe,Ve,Tt)=>{const Et=xr.current;if(!Et){$e("xterm resize push skipped: no terminalId",{cols:oe,rows:Ve});return}$e("xterm resize push",{cols:oe,rows:Ve}),we.resize({sessionId:Et,cols:oe,rows:Ve,seq:Tt}).catch(qe=>{ge.current?.acknowledgeResize({seq:Tt,ok:!1}),qe&&/session not found/i.test(String(qe.message||qe))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Et,cols:oe,rows:Ve,stack:new Error().stack})})},[we,$e]),No=S.useCallback(async oe=>{const Ve=xr.current;if(!Ve||!we.tmuxAction)return;const Tt=U.current;try{const Et=await we.tmuxAction(Ve,oe);if(xr.current!==Ve||U.current!==Tt)return;Et.layout&&(fs(Et.layout),oe.action==="switch-session"&&(ur(ue,{sessionId:Ve,cols:80,rows:24,mode:"tmux",tmuxSessionName:Et.layout.sessionName}),T8(ue,{tmuxSessionName:Et.layout.sessionName}).catch(qe=>{console.warn("[Terminal] failed to update inventory after tmux switch",qe)})))}catch(Et){po(Et,Ve,Tt,"Failed to execute tmux action")}},[po,ue,ur,we]);S.useEffect(()=>{if(!vs||!zr)return;const Ve=vs.windows.find(Tt=>Tt.id===vs.activeWindowId)?.panes.find(Tt=>Tt.id===vs.activePaneId);Ve&&ge.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${zr}:${vs.sessionId}:${Ve.id}:${Ve.width}x${Ve.height}`})},[vs,zr]);const Js=S.useCallback((oe,Ve=5)=>{const Tt=Math.max(1,Math.min(Math.floor(Ve)||1,40));Ot.current=!0;const Et=qt.current;if(Et&&Et.direction===oe){Et.lines+=Tt;return}Et&&No({action:"scroll",direction:Et.direction,lines:Et.lines}).finally(()=>{Es()}),qt.current={direction:oe,lines:Tt},dt.current&&clearTimeout(dt.current),dt.current=setTimeout(()=>{const qe=qt.current;qe&&(qt.current=null,No({action:"scroll",direction:qe.direction,lines:qe.lines}).finally(()=>{Es()}))},0)},[Es,No]),Ro=S.useCallback(oe=>{const Ve=Date.now(),Tt=Lr.current,Et=Tt!==null&&Tt.modifier===oe&&Ve-Tt.timestamp<=$I;if(Lr.current={modifier:oe,timestamp:Ve},Zt===oe){_r(null),hr(null);return}if(Et){_r(oe),hr(oe);return}Zt!==null&&Zt!==oe&&_r(null),hr(qe=>qe===oe?null:oe)},[Zt]),mo=S.useCallback(oe=>{if(Xe(oe&&Re.current),$e("input focus changed",{focused:oe,isActive:Re.current,isMobile:Ct.current}),!Ct.current||!Re.current){Fe(!1);return}Fe(Ve=>Ve===oe?Ve:oe)},[$e]),go=S.useCallback(oe=>{if(Ye.current=oe,pa(oe,"viewport-watermark"),!oe&&it.current.length>0){const Ve=ue;if(Ve){const Tt=it.current;it.current=[];for(const Et of Tt)on(Ve,Et)}}},[on,pa,ue]),mi=S.useCallback(oe=>{Re.current&&ge.current?.ensureSizeMatches(oe)},[]),ps=S.useRef(null);S.useEffect(()=>{if(!c)return;const oe=ps.current;if(!oe)return;const Ve=()=>mi("pointerdown"),Tt=()=>mi("keydown"),Et=()=>mi("touchstart"),qe=()=>mi("wheel");return oe.addEventListener("pointerdown",Ve),oe.addEventListener("keydown",Tt),oe.addEventListener("touchstart",Et,{passive:!0}),oe.addEventListener("wheel",qe,{passive:!0}),()=>{oe.removeEventListener("pointerdown",Ve),oe.removeEventListener("keydown",Tt),oe.removeEventListener("touchstart",Et),oe.removeEventListener("wheel",qe)}},[c,mi]);const Ei=S.useCallback(oe=>{ge.current=oe},[]),xo=S.useCallback(oe=>{At(oe),$?.(ue,oe)},[$,ue]),dl=S.useCallback(oe=>{const Ve=cI(oe);if(!Ve)return;const Tt=Pt!==null;ge.current?.sendSequence(Ve,{consumeModifier:Tt})},[Pt]),Mo=S.useCallback(oe=>{const Ve=sI(oe);if(Ve.length===0)return;const Tt=Pt!==null;ge.current?.sendSequence(Y2(Ve[0]),{consumeModifier:Tt});for(let Et=1;Et<Ve.length;Et+=1){const qe=Ve[Et];window.setTimeout(()=>{ge.current?.sendSequence(Y2(qe))},nI*Et)}},[Pt]),js=S.useCallback(()=>{ge.current?.pasteClipboardText()},[]),ei=S.useCallback(oe=>{ws.current!==null&&(window.clearTimeout(ws.current),ws.current=null),Ze(oe),(oe==="inserted"||oe==="failed")&&(ws.current=window.setTimeout(()=>{ws.current=null,Ze("idle")},1400))},[]),El=S.useCallback(()=>{ei("idle"),nt(0),Pi.current?.click()},[ei]),Xn=S.useCallback(()=>{Y(!0)},[]),gi=S.useCallback(oe=>{const Ve=oe.currentTarget.files?.[0];if(oe.currentTarget.value="",!Ve)return;Qr(null),Nt(null),nt(0),ei("uploading");const Tt=Pr&&Ve.type.startsWith("video/")?{maxHeight:be,videoBitrate:Er,onProgress:nt}:null,Et=at&&zI(Ve)?{maxDimension:en,quality:Te}:null;let qe=Tt?"视频压缩":Et?"图片压缩":"文件上传";(async()=>{const vt=Tt?await(await Tc(async()=>{const{compressVideoLocally:wr}=await import("./videoCompression-DJaU8exd.js");return{compressVideoLocally:wr}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(Ve,Tt):Et?await(await Tc(async()=>{const{compressImageLocally:wr}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:wr}},[])).compressImageLocally(Ve,Et):Ve;qe="文件上传",await sy(vt,(wr,Yr)=>ad(wr,Yr,void 0,nt),wr=>{if(qe="插入终端",!Re.current||zt.current)throw new Error(`终端暂不可用,文件已上传至 ${wr}`);window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:ny(wr,null),focus:!0}}))}),(Tt||Et)&&Nt({file:vt,kind:Tt?"video":"image",originalSize:Ve.size,uploadedSize:vt.size,originalRetained:vt===Ve})})().then(()=>ei("inserted"),vt=>{const wr=sx(vt);Qr({stage:qe,detail:wr}),Y(!0),ei("failed"),ha("warn","MOBILE_MEDIA_UPLOAD failed",{stage:qe,detail:wr})})},[Er,Pr,be,at,en,Te,ei]);S.useEffect(()=>{if(!Lt||!Pr)return;let oe=!0;return Gr(null),xt({phase:"checking-cache"}),Tc(async()=>{const{prepareLocalVideoCompression:Ve}=await import("./videoCompression-DJaU8exd.js");return{prepareLocalVideoCompression:Ve}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:Ve})=>{if(oe)return Ve(Tt=>{oe&&xt(Tt)})}).catch(Ve=>{oe&&Gr(sx(Ve))}),()=>{oe=!1}},[Lt,Pr]);const qn=Nr||kt!==null;zt.current=qn;const xa=S.useRef(qr);qn||(xa.current=qr);const Ui=qn?xa.current:qr,Do=S.useMemo(()=>iI(Ui,_n),[Ui,_n]),Bs=S.useMemo(()=>K2(_n,Je),[Je,_n]),Us=!de&&Je!=="auto"&&Bs.id!=="default"&&Bs.showOnDesktop!==!0?"auto":Je,zi=Us==="auto"?Do:Us,dn=S.useMemo(()=>K2(_n,zi),[zi,_n]),Ni=S.useMemo(()=>dn.actions.filter(oe=>oe.sequence.trim().length>0).map((oe,Ve)=>({...oe,label:Im(oe,Ve)})),[dn.actions]),xi=S.useMemo(()=>Z3(qr),[qr]),ba=dn.label,sa=S.useMemo(()=>Us!=="auto"?`Manual preset: ${dn.label}`:xi?`Auto preset · ${dn.label} (${xi})`:"Auto preset",[xi,Us,dn.label]),ya=S.useCallback(oe=>{Rt(oe)},[]),bi=S.useCallback(()=>{ir(oe=>oe==="copy"?"arrows":"copy"),We("idle")},[]),va=S.useCallback(()=>{typeof window>"u"||(Mn.current!==null&&window.clearTimeout(Mn.current),Mn.current=window.setTimeout(()=>{Mn.current=null,We("idle")},1200))},[]),Qs=S.useCallback(oe=>{Mn.current!==null&&typeof window<"u"&&(window.clearTimeout(Mn.current),Mn.current=null),We(oe?"copied":"failed"),va()},[va]),Ri=S.useCallback(oe=>{ze(oe)},[]),Ba=S.useMemo(()=>de?aI(_n):oI(_n),[de,_n]),zs=S.useMemo(()=>S8(a),[a]);S.useEffect(()=>{if(!un||!ye||!gt||!zr)return;const oe=xS(zs);oe&&we.sendInput(zr,oe).catch(Ve=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",Ve)})},[un,ye,gt,zr,we,zs]);const Yn=S.useMemo(()=>`terminal::${ue}`,[ue]);S.useEffect(()=>{Qe?.({isConnecting:Nr,isRestarting:yn,hasError:!!kt,sessionId:zr})},[Nr,yn,kt,zr,Qe]);const Mi=!zr||Nr||yn,jo=S.useCallback((oe,Ve)=>{if(Mi)return;const Tt=Math.max(1,Math.min(Math.floor(Ve)||1,40));Js(oe,Tt)},[Js,Mi]);S.useEffect(()=>{if(!c||!de)return;ge.current?.requestRefresh("resize",{skipScrollToBottom:!Ge,force:!0})},[c,de,Ge,pt,ue]),S.useEffect(()=>{if(!c||!de)return;const oe=Ve=>{const Tt=Ve.detail;ge.current?.requestRefresh("resize",{skipScrollToBottom:Tt?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",oe),()=>{document.removeEventListener("termdock:viewport-keyboard-change",oe)}},[c,de,ue]);const wa=!q&&(de||dn.id==="default"||dn.showOnDesktop===!0),Bo=c,Qo=de&&!Be?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Qa=de&&!Be?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,bo=s.jsx(uI,{visible:wa,interactive:Bo,presentation:de?"mobile":"desktop-actions",activeModifier:Pt,lockedModifier:Zt,disabled:Mi,defaultShowExtended:ae,presetLabel:ba,presetModeLabel:sa,presetMode:Us,presetOptions:Ba,includeAlt:dn.includeAlt,presetRowLayout:dn.rowLayout,extraActions:Ni,onKeyPress:dl,onTextPress:Mo,onPastePress:de?js:void 0,onFilePress:de?El:void 0,onFileLongPress:de?Xn:void 0,fileUploadState:br,fileUploadProgress:Dt,longPressMode:Mt,copyFeedback:Ut,onLongPressModeToggle:bi,onModifierToggle:Ro,onPresetSelect:ya,onExpandedChange:Ri}),Pa=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return s.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:Qo,children:[s.jsx("input",{ref:Pi,type:"file",className:"hidden",onChange:gi}),Lt&&ki.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>Y(!1),"aria-label":Pe("common.close")}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"mobile-video-compression-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] z-modal-panel max-h-[calc(100dvh-1.5rem)] overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:left-1/2 sm:right-auto sm:w-[min(28rem,calc(100vw-2rem))] sm:-translate-x-1/2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"mobile-video-compression-title",className:"text-sm font-semibold text-foreground",children:"本地媒体压缩"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"按文件类型选择压缩方式,处理完成后才上传。"})]}),s.jsx("button",{type:"button",className:"min-h-10 rounded-lg bg-surface-2 px-3 text-xs",onClick:()=>Y(!1),children:Pe("common.close")})]}),_t&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[_t.stage,"失败。",_t.stage.endsWith("压缩")?"原文件未上传。":_t.stage==="插入终端"?"文件已上传,路径见详情。":""]}),s.jsxs("details",{className:"mt-2",children:[s.jsx("summary",{className:"cursor-pointer",children:"错误详情"}),s.jsx("p",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:_t.detail})]})]}),gr&&s.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:"本机未能保存设置,重新打开后可能恢复默认值。"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"显示压缩结果提示"}),s.jsx("input",{type:"checkbox",checked:Zr.showResultToast,onChange:oe=>lt({showResultToast:oe.target.checked}),className:"h-4 w-4 accent-primary"})]}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩图片后上传"}),s.jsx("input",{type:"checkbox",checked:at,onChange:oe=>lt({imageEnabled:oe.target.checked}),className:"h-4 w-4 accent-primary"})]}),at&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片最长边",s.jsx("select",{value:en,onChange:oe=>lt({imageMaxDimension:Number(oe.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:iy.map(oe=>s.jsxs("option",{value:oe,children:[oe," px",oe===640?" · 最省流量":oe===2048?" · 推荐":oe===4096?" · 保留更多细节":""]},oe))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片画质:",Math.round(Te*100),"%",s.jsx("input",{type:"range",min:Du.min,max:Du.max,step:Du.step,value:Te,onChange:oe=>lt({imageQuality:Number(oe.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"支持 JPEG、PNG、HEIC 照片;GIF、SVG 等保持原文件。压缩后未变小也会保留原图。"})]}),s.jsx("div",{className:"mt-4 border-t border-border/15 pt-1"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩视频后上传"}),s.jsx("input",{type:"checkbox",checked:Pr,onChange:oe=>lt({videoEnabled:oe.target.checked}),className:"h-4 w-4 accent-primary"})]}),Pr&&s.jsxs("div",{className:"mt-4 space-y-4",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["视频最长边(像素)",s.jsx("select",{value:be,onChange:oe=>lt({videoMaxHeight:Number(oe.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:ay.map(oe=>s.jsxs("option",{value:oe,children:[oe," px",oe===240?" · 最省流量":oe===720?" · 推荐":oe>=1440?" · 手机处理较慢":""]},oe))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",Er/1e6," Mbps",s.jsx("input",{type:"range",min:ju.min,max:ju.max,step:ju.step,value:Er,onChange:oe=>lt({videoBitrate:Number(oe.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"保持比例,不放大原视频。尺寸越小通常处理越快;码率越低体积通常越小,过高可能比原片更大。"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",role:"status","aria-live":"polite",children:Gt?"本地转码器准备失败,请关闭开关后重试。":HI(st)}),st?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),Gt&&s.jsx("p",{className:"text-[11px] text-destructive",children:Gt})]})]})]}),document.body),Gn&&s.jsx(dI,{isMobile:de,isInputFocused:re,isIOS:Ee,isConnecting:Nr,connectionError:kt,terminalSessionId:zr}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:zs.background,...Qa},children:[s.jsx("div",{ref:ps,className:"h-full w-full box-border",children:s.jsx(C8,{fallback:s.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("span",{className:"text-sm text-muted-foreground",children:Pe("terminal.componentFailed")})]})}),children:s.jsx(Vk,{ref:Ei,sessionKey:Yn,sessionId:ue,isLayoutVisible:g,chunks:Bn,onInput:Il,onResize:ul,onFlowControl:go,onTmuxScroll:un?jo:void 0,tmuxScrollSensitivity:.38,onDoubleTap:de?()=>{ge.current?.sendSequence(" ")}:void 0,onInputFocusChange:mo,onMobileLongPressCopyResult:Qs,onReadyChange:xo,onSizeSynchronizedChange:yt,onWritesSettled:gs,onWriteProgress:Is,onCursorPositionChange:As,onDirectoryLinkActivate:wn,terminalSettings:je,theme:zs,enableTouchScroll:de,mobileLongPressMode:Mt,autoFocus:!h&&!de&&!Pa,cursorVisible:!h&&Ft,suppressSmoothScroll:!le||!Ne,className:h||!Ft?"terminal-focus-suspended":void 0},Yn)})}),s.jsx(FI,{result:yr,onDismiss:Nn}),s.jsx(fI,{connectionError:kt,isFatalError:gn,isRestarting:yn,isConnecting:Nr,onHardRestart:ja})]}),ne?q?null:ki.createPortal(bo,ne):bo]})};function VI({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=Hr(),l=Jr(c=>{const h=c.sessions.get(e.id);return Xo(e,h?.activeProgram??null,h?.cwd??null,void 0,h?.shellTitle??null,h?.promptState??null).primary});return s.jsxs("div",{"data-pane-titlebar":"true",className:"swiper-no-swiping flex h-6 min-h-6 shrink-0 items-center border-b border-border app-chrome-bg",children:[s.jsxs("button",{type:"button","data-split-pane-title":e.id,draggable:!1,onDragStart:c=>c.preventDefault(),"aria-pressed":t,title:`${l} · 拖动标题移动,边缘拆分,中央交换`,onClick:r,className:"split-pane-drag-handle flex h-full min-w-0 cursor-grab active:cursor-grabbing flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-[12px] font-medium leading-none text-foreground hover:bg-surface focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:[s.jsx(Eo,{size:11,className:`shrink-0 ${t?"text-primary":"text-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l}),s.jsx(hf,{size:12,"aria-hidden":"true",className:"shrink-0 text-muted-foreground"}),t&&s.jsx("span",{"aria-hidden":"true",className:"h-1 w-1 shrink-0 rounded-full bg-primary"})]}),n&&s.jsx("button",{type:"button",onClick:n,"aria-label":a("tab.explorerTitle"),title:a("tab.explorerTitle"),className:"inline-flex h-full w-7 shrink-0 items-center justify-center text-muted-foreground hover:bg-surface hover:text-foreground focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:s.jsx(qb,{size:14})})]})}const qI="termdock:startup:";function l0(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${qI}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function ix(e,t){e||ki.flushSync(t)}const Nm="horizontal";function h0(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function kh(e,t){if(!Array.isArray(e)||e.length!==t)return h0(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return h0(t);const n=r.reduce((a,l)=>a+l,0);return n<=0?h0(t):r.map(a=>a/n)}function YI(e){const t=Math.max(1,Math.ceil(Math.sqrt(Math.max(1,e))));return{columns:t,rows:Math.max(1,Math.ceil(Math.max(1,e)/t))}}function ZI(e){return e==="horizontal"||e==="vertical"||e==="grid"}function KI(e){if(!Array.isArray(e))return[];const t=new Set,r=new Set,n=[];for(const a of e){if(!a||typeof a!="object")continue;const l=a;if(typeof l.id!="string"||!l.id||r.has(l.id))continue;const c=Array.isArray(l.sessionIds)?l.sessionIds.filter(g=>typeof g=="string"&&!!g&&!t.has(g)):[],h=[...new Set(c)];if(h.length<2)continue;const p=YI(h.length);h.forEach(g=>t.add(g)),r.add(l.id),n.push({id:l.id,...typeof l.name=="string"&&l.name.trim()?{name:l.name.trim().slice(0,80)}:{},sessionIds:h,layout:ZI(l.layout)?l.layout:Nm,ratios:kh(l.ratios,h.length),...l.gridColumnRatios!==void 0?{gridColumnRatios:kh(l.gridColumnRatios,p.columns)}:{},...l.gridRowRatios!==void 0?{gridRowRatios:kh(l.gridRowRatios,p.rows)}:{}})}return n}function XI(e,t){const r=new Set(t);return e.flatMap(n=>{const a=n.sessionIds.filter(l=>r.has(l));return a.length<2?[]:[{...n,sessionIds:a,ratios:a.length===n.sessionIds.length?kh(n.ratios,a.length):h0(a.length)}]})}function Ku(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function Lp(e,t,r){if(!t||!r||t===r)return e;const n=Ku(e,t),a=Ku(e,r);if(n&&n.id===a?.id)return e;const l=[...n?.sessionIds??[t],...a?.sessionIds??[r]],c=[...new Set(l)],h={id:n?.id??`split:${t}`,...n?.name?{name:n.name}:{},sessionIds:c,layout:c.length>2&&(!n||n.layout===Nm)?"grid":n?.layout??Nm,ratios:h0(c.length)},p=new Set([n?.id,a?.id].filter(Boolean)),g=e.filter(y=>!p.has(y.id)),x=n?Math.max(0,e.findIndex(y=>y.id===n.id)):g.length;return g.splice(Math.min(x,g.length),0,h),g}function JI(e,t){const r=Ku(e,t);if(!r||!t)return e;if(r.sessionIds.length<=2)return e.filter(a=>a.id!==r.id);const n=r.sessionIds.filter(a=>a!==t);return e.map(a=>a.id===r.id?{...a,sessionIds:n,ratios:h0(n.length)}:a)}function eE(e,t){const r=Ku(e,t);return r?e.filter(n=>n.id!==r.id):e}function tE(e,t,r){return e.map(n=>{if(n.id!==t)return n;const a=[...new Set(r)],l=new Set(n.sessionIds);return a.length===n.sessionIds.length&&a.every(h=>l.has(h))?{...n,sessionIds:a}:n})}function rE(e,t,r){const n=r.trim().slice(0,80);return e.map(a=>a.id===t?{...a,...n?{name:n}:{name:void 0}}:a)}const Rm=320,ly=1,nE=Rm+120,Mm="termdock:split-workspaces:v2",cy="termdock:split-workspace:v1",sE=.1,iE=.9;function kp(){if(typeof window>"u")return{mobile:!1,landscape:!1};const t=(navigator.maxTouchPoints>0||"ontouchstart"in window)&&Math.min(window.innerWidth,window.innerHeight)<768;return{mobile:t,landscape:t&&window.innerWidth>window.innerHeight}}function aE(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Mm);if(e)return KI(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(cy)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(iE,Math.max(sE,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[r,1-r]}]}}catch{}return[]}function oE(e,t){const r=new Map(e.map(c=>[c.id,c])),n=new Map;t.forEach(c=>c.sessionIds.forEach(h=>n.set(h,c)));const a=new Set,l=[];for(const c of e){const h=n.get(c.id);if(!h){l.push({key:c.id,sessions:[c]});continue}if(a.has(h.id))continue;a.add(h.id);const p=h.sessionIds.flatMap(g=>{const x=r.get(g);return x?[x]:[]});p.length>=2&&l.push({key:h.id,sessions:p,workspace:h})}return l}function ax(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function th(e,t){const r=Yh(e,t);if(r===null)return;const n=e.wrapperEl;ax(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),ax(e),n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}catch{n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}}function Dm(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function Yh(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function lE(e,t){const r=Dm(e),n=Yh(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=ly}function cE(e){const t=[],r=new Map,n=new Map,a=new Map;for(const l of e){const c=r.get(l.id)??[];if(c.push(l.id),r.set(l.id,c),l.sessionId){const h=n.get(l.sessionId)??[];h.push(l.id),n.set(l.sessionId,h)}if(l.mode==="tmux"&&l.tmuxSessionName){const h=a.get(l.tmuxSessionName)??[];h.push(l.id),a.set(l.tmuxSessionName,h)}}for(const[l,c]of r)c.length>1&&t.push({kind:"frontend",key:l,sessionIds:c});for(const[l,c]of n)c.length>1&&t.push({kind:"backend",key:l,sessionIds:c});for(const[l,c]of a)c.length>1&&t.push({kind:"tmux",key:l,sessionIds:c});return t}function uy(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function dy(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function uE(e,t){const r=uy(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function ox(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...dy(n),history:a?.history}})}function lx(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function cx(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function ux(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function dE(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t)if(e.get(r)!==n)return!1;return!0}function hE(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const r=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`wt-${r}${n}`}const fE=({terminalSettings:e=g1(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:l="shell",defaultTmuxSessionName:c="",connectionPrioritySessionId:h=null,connectionPriorityReady:p=!0,desktopRightSidebarEnabled:g=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopPinnedLeftSidebarWidth:A=0,desktopViewportWidth:v=0,onStatusChange:L,onSessionDataUpdate:I,onInitialViewportReady:E,onInitialRecoveryRequired:R})=>{const{t:P}=Hr(),Q=b.useMemo(()=>p0("session"),[]),$=b.useMemo(()=>p0("terminal"),[]),[W,B]=b.useState([]),[q,ne]=b.useState(null),Be=ts(U=>U.activePaneId);b.useEffect(()=>{ts.getState().setActivePane(q)},[q]);const[fe,X]=b.useState(null),[Qe,Pe]=b.useState(!0),[ue,Ce]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[tt,we]=b.useState(()=>new Set),[ce,$e]=b.useState(()=>({token:0,completed:new Set})),[ke,se]=b.useState(0),[je,de]=b.useState(()=>new Set),[Oe,Ee]=b.useState(()=>new Set),_e=b.useRef(new Map),[re,Fe]=b.useState(()=>new Set),wt=b.useRef(!1),Xe=b.useRef(null),ee=b.useRef({}),[Ue,Le]=b.useState(null),[te,ye]=b.useState(()=>aE()),[ot,le]=b.useState(!1),[xe,Ne]=b.useState(null),[yt,gt]=b.useState(null),[At,Ft]=b.useState(null),[Z,Ge]=b.useState(!1),[pt,Pt]=b.useState(()=>kp().mobile),[hr,Zt]=b.useState(()=>kp().landscape),[_r,ae]=b.useState(null),[ze,Je]=b.useState(null),Rt=b.useRef(a),Mt=b.useRef(!1),ir=b.useRef(!1),Ut=b.useRef(null),We=b.useRef(null),br=b.useRef(pt),Ze=b.useRef(null),Dt=b.useRef(0),nt=b.useRef([]),_t=b.useRef(0),Qr=b.useRef(null),yr=b.useRef(!1),Nt=b.useRef(!0),Nn=b.useRef(null),Zr=b.useRef(""),lt=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const U=()=>{const G=kp();br.current=G.mobile,Pt(G.mobile),Zt(G.landscape)};return U(),window.addEventListener("resize",U),()=>window.removeEventListener("resize",U)},[]);const{sessions:gr,inventory:Pr,activeSessionId:be,isLoading:Er,openSession:at,setActiveSession:en,removeSession:Te,renameSession:Lt,resetSessionCustomName:Y,reorderSessions:st,restoreSessions:xt}=_8(),Gt=Pr?.tmuxRecovery??null;b.useEffect(()=>{Gt&&R?.()},[Gt,R]),b.useEffect(()=>{Ft(null),gt(null)},[Gt?.id]);const Gr=b.useCallback(async()=>{gt("restore"),Ft(null);try{const U=await L8();await xt(),U.failed>0&&Ft(P("tab.tmuxRecoveryPartial",{restored:U.restored,failed:U.failed}))}catch{Ft(P("tab.tmuxRecoveryFailed"))}finally{gt(null)}},[xt,P]),Fr=b.useCallback(async()=>{gt("dismiss"),Ft(null);try{await k8(),await xt()}catch{Ft(P("tab.tmuxRecoveryDismissFailed"))}finally{gt(null)}},[xt,P]),ur=sr(U=>U.groupByFolder),tn=Fh(U=>U.collaborationGroups),on=sr(U=>U.leftOpen||U.rightOpen),Xr=sr(U=>U.rightSidebarWidthContextKey),Wr=sr(U=>U.rightSidebarWidth),$r=sr(U=>U.rightPinned),[Ur,Cn]=b.useState(()=>ux(Jr.getState().sessions));b.useEffect(()=>Jr.subscribe(U=>{const G=ux(U.sessions);Cn(he=>dE(he,G)?he:G)}),[]);const{arranged:Rn}=b.useMemo(()=>jh(W,U=>Ur.get(U.id)??null,ur,"",te,tn),[W,Ur,ur,te,tn]),hn=b.useRef(Rn);hn.current=Rn;const Vr=b.useMemo(()=>oE(Rn,te),[Rn,te]),ys=b.useRef(Vr);ys.current=Vr;const cn=b.useMemo(()=>Ku(te,q),[q,te]),Vt=b.useMemo(()=>{const U=Vr.find(G=>G.sessions.some(he=>he.id===q));return new Set(U?.sessions.map(G=>G.id)??[])},[q,Vr]),hs=b.useMemo(()=>{const U=new Map;if(!g||v<=0)return U;for(const G of Vr){const he=G.sessions[0];if(!he)continue;const Me=I8(he.id,Ur.get(he.id)??null,G.workspace?.id??null);if(!(Me===Xr?$r:E8(he.id,Ur.get(he.id)??null,G.workspace?.id??null)))continue;const It=Me===Xr?Wr:N8(he.id,Ur.get(he.id)??null,G.workspace?.id??null),tr=xh(It,v,A);U.set(G.key,tr+Lb)}return U},[Ur,A,g,$r,Xr,Wr,v,Vr]),Sn=b.useMemo(()=>Cp(W.map(U=>({id:U.id,backendSessionId:U.sessionId})),h),[h,W]),rs=b.useMemo(()=>lx(gr,be),[be,gr]),qr=Jd({prioritySessionId:Sn,activeSessionId:fe??q,persistedActiveSessionId:rs,firstSessionId:W[0]?.id??null}),_n=b.useMemo(()=>DI(Vr.flatMap(U=>U.sessions.map(G=>G.id)),Vt),[Vt,Vr]),un=qr!==null&&tt.has(qr),Bn=b.useMemo(()=>{const U=new Set(Vt);return fe&&U.add(fe),!U.size&&qr&&U.add(qr),U},[Vt,fe,qr]),Nr=ce.token===ue.token&&EI(Bn,ce.completed),zr=Nr||ke===ue.token?ue.token:-1;b.useEffect(()=>{if(!ue.token||Nr)return;const U=window.setTimeout(()=>se(ue.token),yI);return()=>window.clearTimeout(U)},[ue.token,Nr]);const wn=b.useCallback((U,G)=>{we(he=>{if(he.has(U)===G)return he;const Qt=new Set(he);return G?Qt.add(U):Qt.delete(U),Qt})},[]),V=b.useCallback(U=>{const G=Dt.current;$e(Me=>{if(Me.token===G&&Me.completed.has(U))return Me;const Qt=new Set(Me.token===G?Me.completed:[]);return Qt.add(U),{token:G,completed:Qt}});const he=Sn??fe??Ze.current;U===he&&l0("foreground-stream-connected")},[fe,Sn]),et=b.useCallback((U,G)=>{de(he=>{if(he.has(U)===G)return he;const Me=new Set(he);return G?Me.add(U):Me.delete(U),Me})},[]),kt=b.useCallback((U,G)=>{Ee(he=>{if(he.has(U)===G)return he;const Me=new Set(he);return G?Me.add(U):Me.delete(U),Me})},[]);b.useEffect(()=>{for(const[U,G]of _e.current){const he=W.find(Me=>Me.id===U);if(!he||he.sessionId!==G.backendSessionId){_e.current.delete(U);continue}!tt.has(U)||!je.has(U)||!Oe.has(U)||(_e.current.delete(U),_b(G.backendSessionId,`${G.command}\r`).catch(Me=>{console.error("[Session] Failed to send startup command:",Me)}))}},[W,tt,je,Oe]);const Bt=qr!==null&&je.has(qr),zt=qr!==null&&Oe.has(qr);b.useEffect(()=>{Bt&&l0("foreground-viewport-ready")},[Bt]),b.useEffect(()=>{zt&&l0("foreground-content-ready")},[zt]),b.useEffect(()=>{if(!E)return;if(!Qe&&W.length===0){E();return}if(!Bt||!un||!zt)return;const U=[...Vt].every(It=>je.has(It)&&tt.has(It)&&Oe.has(It));let G=0,he=0;const Me=()=>{G=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{l0("initial-viewport-presented"),E()})})};U&&Me();const Qt=U?void 0:window.setTimeout(Me,8e3);return()=>{cancelAnimationFrame(G),cancelAnimationFrame(he),clearTimeout(Qt)}},[un,zt,Bt,Qe,E,W.length,Vt,je,tt,Oe]);const gn=b.useMemo(()=>pt?AI({slides:Vr.map(U=>U.sessions.map(G=>G.id)),visibleSessionIds:Vt,foregroundSessionId:qr}):re,[pt,Vr,Vt,qr,re]);b.useEffect(()=>{if(pt||Vt.size===0)return;const U=new Set(Vt),G=Vr.findIndex(he=>he.sessions.some(Me=>Vt.has(Me.id)));for(let he=-2;he<=2;he+=1)he!==0&&Vr[G+he]?.sessions.forEach(Me=>U.add(Me.id));Fe(he=>{let Me=!1;const Qt=new Set(he);for(const It of U)Qt.has(It)||(Qt.add(It),Me=!0);return Me?Qt:he})},[pt,Vt,Vr]);const lr=aS(gn);b.useEffect(()=>{if(!fe)return;if(!W.some(G=>G.id===fe)){X(null);return}if(!je.has(fe)||!tt.has(fe)||!Oe.has(fe))return;const U=window.setTimeout(()=>{X(G=>G===fe?null:G),Rt.current&&!br.current&&Le({sessionId:fe,token:Date.now()})},80);return()=>window.clearTimeout(U)},[Oe,fe,tt,W,je]),b.useEffect(()=>{typeof window>"u"||(te.length>0?(window.localStorage.setItem(Mm,JSON.stringify(te)),window.localStorage.removeItem(cy)):window.localStorage.removeItem(Mm))},[te]),b.useEffect(()=>{Er||Qe||te.length===0||ye(U=>XI(U,W.map(G=>G.id)))},[Er,Qe,W,te.length]),b.useEffect(()=>{if(!xe)return;const U=window.setTimeout(()=>Ne(null),3200);return()=>window.clearTimeout(U)},[xe]),Ze.current=q,Dt.current=ue.token,nt.current=W,Qr.current=be,yr.current=Er,Nt.current=Qe,Rt.current=a;const yn=b.useCallback((U=Xe.current)=>{const G=_t.current,he=typeof window<"u"?window.visualViewport:null,Me=U?Dm(U):null,Qt=U?Yh(U,G):null;return{sessionsLength:nt.current.length,workspaceSlidesLength:ys.current.length,sessionIds:nt.current.map(It=>It.id),activeSessionId:Ze.current,activeSessionIndex:G,persistedActiveId:Qr.current,isLoading:yr.current,isRestoring:Nt.current,activeIndex:U?.activeIndex??null,previousIndex:U?.previousIndex??null,animating:U?.animating??null,allowTouchMove:U?.allowTouchMove??null,width:U?.width??null,translate:Me,targetTranslate:Qt,translateDelta:Me!==null&&Qt!==null?Me-Qt:null,snapGridLength:U?.snapGrid?.length??null,targetSnap:U?.snapGrid?.[G]??null,visualViewport:he?{width:Math.round(he.width),height:Math.round(he.height),offsetTop:Math.round(he.offsetTop)}:null}},[]),ar=b.useCallback((U,G)=>{Q(U,{...yn(),...G})},[Q,yn]);b.useEffect(()=>{Er||Qe||q!==be&&en(q)},[q,Er,Qe,be,en]);const Ln=b.useMemo(()=>{if(Rn.length===0||!q)return 0;const U=Vr.findIndex(G=>G.sessions.some(he=>he.id===q));return U>=0?U:0},[Vr,q]);_t.current=Ln;const rn=b.useCallback(()=>{Ut.current&&(clearTimeout(Ut.current),Ut.current=null)},[]),$n=b.useCallback(U=>{rn(),Ut.current=setTimeout(()=>{Ut.current=null,Mt.current=!1,ar("[swiper:touch-guard-clear]",{reason:U})},nE)},[rn,ar]),ns=b.useCallback((U,G={})=>{const he=Xe.current,Me=_t.current,Qt=ys.current;if(!he||Qt.length===0||Me<0||Me>=Qt.length)return;if(Mt.current){ar("[swiper:sync-skip-touch]",{reason:U});return}if(he.animating){ar("[swiper:sync-skip-animating]",{reason:U});return}const It=Dm(he),tr=Yh(he,Me),fr=It!==null&&tr!==null&&Math.abs(It-tr)<=ly,jr=he.activeIndex===Me;if(ar("[swiper:sync-check]",{reason:U,activeIndexAligned:jr,translateAligned:fr,immediate:G.immediate===!0}),!(jr&&fr)){if(jr){th(he,Me),ar("[swiper:sync-forced-active]",{reason:U,translateAligned:fr,immediate:G.immediate===!0});return}G.immediate?(th(he,Me),he.slideTo(Me,0,!1),th(he,Me)):he.slideTo(Me,Rm,!1),ar("[swiper:sync-applied]",{reason:U,activeIndexAligned:jr,translateAligned:fr,immediate:G.immediate===!0})}},[ar]);b.useEffect(()=>{const U=G=>{const he=G;Xe.current&&(Xe.current.allowTouchMove=!he.detail.locked),ar("[swiper:gesture-lock]",{locked:he.detail.locked})};return document.addEventListener("termdock:gesture-lock",U),()=>document.removeEventListener("termdock:gesture-lock",U)},[ar]),b.useEffect(()=>{if(W.length===0){q!==null&&ne(null);return}if(!q){if(!p)return;ne(Jd({prioritySessionId:Sn,activeSessionId:null,persistedActiveSessionId:rs,firstSessionId:W[0]?.id??null}));return}W.some(G=>G.id===q)||ne(W[0].id)},[W,q,p,Sn,rs]);const vs=b.useCallback((U,G)=>{if(G&&Date.now()<lt.current){ee.current[U]=!1;return}ee.current[U]=G,Je(he=>G?U:he===U?null:he)},[]),fs=b.useCallback(U=>{if(!Mt.current&&U.activeIndex!==_t.current){ar("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:U.activeIndex,expectedActiveIndex:_t.current}),requestAnimationFrame(()=>ns("ignored-layout-slide-change",{immediate:!0}));return}const G=ys.current[U.activeIndex],he=G?.sessions.some(It=>It.id===q)?q:G?.sessions[0]?.id;if(ar("[swiper:slide-change]",{nextSessionId:he??null,instanceActiveIndex:U.activeIndex}),!he||he===q)return;const Me=!!q&&ee.current[q]===!0,Qt=Rt.current&&(!br.current||Me);if(We.current=he,ne(he),Qt){Le({sessionId:he,token:Date.now()});return}Le(null)},[W,q,ar,ns]);b.useLayoutEffect(()=>{if(We.current===q){ar("[swiper:sync-skip-swiper-driven]",{activeSessionId:q}),We.current=null;return}ns("active-session-index",{immediate:!0})},[q,Ln,W.length,ns,ar]),b.useEffect(()=>{const U=Xe.current;if(!U)return;const G=Vr.length>1&&!on&&!ot;U.allowTouchMove!==G&&(U.allowTouchMove=G,ar("[swiper:allow-touch-sync]",{nextAllow:G,sidebarOverlayOpen:on}))},[Vr.length,ar,on,ot]);const Gn=b.useCallback(U=>{const G=Xe.current;if(!G)return;const he=G.el;if(ar("[swiper:layout-before]",{reason:U,scrollLeft:he?.scrollLeft??null}),he&&(he.scrollLeft=0),G.updateSize(),G.updateSlides(),G.updateProgress(),G.updateSlidesClasses(),he&&(he.scrollLeft=0),ar("[swiper:layout-after]",{reason:U,scrollLeft:he?.scrollLeft??null}),Mt.current||G.animating){ar("[swiper:layout-skip-sync-motion]",{reason:U});return}ns(`layout:${U}`,{immediate:!0}),requestAnimationFrame(()=>{const Me=Xe.current;Me&&(Mt.current||Me.animating||th(Me,_t.current))})},[ar,ns]);b.useEffect(()=>()=>rn(),[rn]);const fn=Vr.map(U=>U.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Gn("group-change"))},[ur,fn,Gn]),b.useEffect(()=>{let U=null,G="mount";const he=fr=>{G=fr,U===null&&(U=requestAnimationFrame(()=>{U=null,Gn(`viewport-change:${G}`)}))},Me=()=>he("window-resize"),Qt=()=>he("visual-viewport-resize"),It=()=>he("visual-viewport-scroll"),tr=fr=>{he(`measured:${fr.detail?.source??"unknown"}`)};return window.addEventListener("resize",Me),window.visualViewport?.addEventListener("resize",Qt),window.visualViewport?.addEventListener("scroll",It),document.addEventListener(wg,tr),he("mount"),()=>{window.removeEventListener("resize",Me),window.visualViewport?.removeEventListener("resize",Qt),window.visualViewport?.removeEventListener("scroll",It),document.removeEventListener(wg,tr),U!==null&&cancelAnimationFrame(U)}},[Gn]),b.useEffect(()=>{if(typeof document>"u")return;let U=null,G=null;const he=jr=>{if(jr!=="online"&&document.hidden)return;const kn=performance.now();if(!NI(G,kn))return;G=kn;const O=jr==="bfcache"||jr==="online"?jr:"visibility",Ae=RI();Vf(),ha("info","PWA_RESUME scheduled",{source:jr,forceForegroundReconnect:Ae,activeSessionId:Ze.current}),Ce(Re=>({token:Re.token+1,reason:O,forceForegroundReconnect:Ae})),requestAnimationFrame(()=>Gn(`resume:${jr}:raf`)),U&&clearTimeout(U),U=setTimeout(()=>{U=null,Gn(`resume:${jr}:settled`)},320)},Me=()=>{if(document.hidden){Vf();return}he("visibility")},Qt=()=>{Vf()},It=jr=>{he(jr.persisted?"bfcache":"pageshow")},tr=()=>he("online"),fr=()=>he("focus");return document.addEventListener("visibilitychange",Me),window.addEventListener("pagehide",Qt),window.addEventListener("pageshow",It),window.addEventListener("online",tr),window.addEventListener("focus",fr),()=>{document.removeEventListener("visibilitychange",Me),window.removeEventListener("pagehide",Qt),window.removeEventListener("pageshow",It),window.removeEventListener("online",tr),window.removeEventListener("focus",fr),U&&clearTimeout(U)}},[Gn]),b.useLayoutEffect(()=>{if(!kI(Qe))return;const U=cE(W),G=JSON.stringify(U);U.length>0&&G!==Zr.current?(Zr.current=G,console.warn("[session-invariant] duplicate mapping detected",U)):U.length===0&&Zr.current&&(Zr.current=""),I?.({sessions:W.map(he=>({id:he.id,name:he.name,customName:he.customName,mode:he.mode,tmuxSessionName:he.tmuxSessionName})),activeSessionId:q,splitWorkspaces:te.map(({id:he,name:Me,sessionIds:Qt,layout:It})=>({id:he,...Me?{name:Me}:{},sessionIds:Qt,layout:It}))})},[W,q,te,I,Qe]),b.useEffect(()=>{if(Er||wt.current)return;wt.current=!0;const U=Cp(gr.map(It=>({id:It.sessionId,backendSessionId:It.backendSessionId??null})),h),G=lx(gr,be),he=Jd({prioritySessionId:p?U:null,activeSessionId:null,persistedActiveSessionId:G,firstSessionId:gr[0]?.sessionId??null}),Me=uy(gr.map(dy));if(Q("[Session] Restoring",Me.length,"persisted sessions (one-shot)"),ar("[swiper:restore-start]",{persistedSessionIds:gr.map(It=>It.sessionId),nextActiveSessionId:he}),Me.length>0){const It=Jr.getState();Me.forEach(fr=>{fr.sessionId&&It.setTerminalSession(fr.id,{sessionId:fr.sessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName,history:fr.history})}),gr.forEach(fr=>{fr.agent!==void 0&&It.setSessionAgentIdentity(fr.sessionId,fr.agent),fr.activeProgram!=null&&It.setSessionActiveProgram(fr.sessionId,fr.activeProgram),fr.cwd!=null&&It.setSessionCwd(fr.sessionId,fr.cwd),fr.shellTitle!=null&&It.setSessionShellTitle(fr.sessionId,fr.shellTitle)}),B(Me);const tr=he||Me[0]?.id||null;ne(tr),ar("[swiper:restore-complete]",{restoredSessionIds:Me.map(fr=>fr.id),nextActiveSessionId:tr})}(async()=>(Me.length===0&&await Nn.current?.({createIfEmpty:!0}),Pe(!1),requestAnimationFrame(()=>ns("restore-finished",{immediate:!0}))))()},[Er,gr,be,Q,ar,ns,p,h]),b.useEffect(()=>{if(!p||Qe||W.length===0)return;const U=Cp(W.map(he=>({id:he.id,backendSessionId:he.sessionId})),h),G=Jd({prioritySessionId:U,activeSessionId:Ze.current,persistedActiveSessionId:rs,firstSessionId:W[0]?.id??null});G&&G!==Ze.current&&ne(G)},[p,h,Qe,rs,W]);const Un=b.useRef([]),xr=b.useRef(!1);Ze.current=q,b.useEffect(()=>{if(Qe)return;const U=Un.current,G=gr,he=new Map(U.map(O=>[O.sessionId,O])),Me=Jr.getState();for(const O of G){const Ae=he.get(O.sessionId),Re=Jr.getState().sessions.get(O.sessionId);O.agent!==void 0&&JSON.stringify(O.agent)!==JSON.stringify(Re?.agent)&&(Re?.agent==null||JSON.stringify(O.agent)!==JSON.stringify(Ae?.agent))&&Me.setSessionAgentIdentity(O.sessionId,O.agent),O.activeProgram!=null&&O.activeProgram!==Re?.activeProgram&&(Re?.activeProgram==null||O.activeProgram!==Ae?.activeProgram)&&Me.setSessionActiveProgram(O.sessionId,O.activeProgram),O.cwd!=null&&O.cwd!==Re?.cwd&&(Re?.cwd==null||O.cwd!==Ae?.cwd)&&Me.setSessionCwd(O.sessionId,O.cwd),O.shellTitle!=null&&O.shellTitle!==Re?.shellTitle&&(Re?.shellTitle==null||O.shellTitle!==Ae?.shellTitle)&&Me.setSessionShellTitle(O.sessionId,O.shellTitle)}if(!xr.current){B(O=>ox(O,G)),Un.current=G,xr.current=!0;return}const Qt=new Set(U.map(O=>O.sessionId)),It=new Set(G.map(O=>O.sessionId)),tr=new Map(U.map(O=>[O.sessionId,O.name]));Un.current=G,B(O=>{const Ae=ox(O,G);return(!Ze.current||!Ae.some(Re=>Re.id===Ze.current))&&ne(Ae[0]?.id??null),Ae});const fr=G.filter(O=>!Qt.has(O.sessionId)),jr=[...Qt].filter(O=>!It.has(O)),kn=G.filter(O=>Qt.has(O.sessionId)&&tr.get(O.sessionId)!==O.name);(fr.length>0||jr.length>0||kn.length>0)&&Q("[Session] Synced persisted sessions:",{newSessionIds:fr.map(O=>O.sessionId),removedSessionIds:jr,renamedSessionIds:kn.map(O=>O.sessionId),currentSessionIds:G.map(O=>O.sessionId)});for(const O of G){if(!O.backendSessionId)continue;Jr.getState().setTerminalSession(O.sessionId,{sessionId:O.backendSessionId,cols:80,rows:24,mode:O.mode,tmuxSessionName:O.tmuxSessionName})}},[gr,Qe,Q]);const z=b.useCallback(async U=>{try{const G=sr.getState(),he=q?{rightOpen:G.rightOpen,rightPinned:G.rightPinned,rightSidebarWidth:G.rightSidebarWidth,rightTab:G.rightTab}:null,Me=U?.mode==="tmux"||U?.mode==="shell"?U.mode:l,Qt=(U?.tmuxSessionName||"").trim(),It=c.trim(),tr=Me==="tmux"?Qt||It||hE():null,fr=typeof U?.cwd=="string"?U.cwd:null,jr=q?Jr.getState().sessions.get(q)?.cwd??null:null,kn=typeof fr=="string"&&fr.trim().length>0?fr:typeof jr=="string"&&jr.trim().length>0?jr:void 0,O=await at({preferredFrontendSessionId:U?.preferredFrontendSessionId,requireExisting:U?.requireExisting===!0,mode:Me,tmuxSessionName:tr,cwd:kn,termType:"xterm-256color",createIfEmpty:U?.createIfEmpty===!0}),Ae=O.session,Re=O.terminalSession;!O.reused&&he&&sr.getState().initializeRightSidebarForSession(Ae.sessionId,Re.cwd??kn??null,he);const mt={id:Ae.sessionId,name:Ae.name,customName:Ae.customName===!0,sessionId:Re.sessionId,mode:Re.mode??Ae.mode,tmuxSessionName:Re.tmuxSessionName??Ae.tmuxSessionName},Ct=U?.command?.trim();return Ct&&_e.current.set(mt.id,{backendSessionId:Re.sessionId,command:Ct}),B(Jt=>uE(Jt,mt)),ne(mt.id),Jr.getState().setTerminalSession(mt.id,{sessionId:Re.sessionId,cols:80,rows:24,mode:mt.mode,tmuxSessionName:mt.tmuxSessionName,activeProgram:Re.activeProgram,activeProgramRaw:Re.activeProgramRaw,activeProgramSource:Re.activeProgramSource,cwd:Re.cwd}),Q("[Session] Inventory opened session:",{frontendSessionId:mt.id,backendSessionId:Re.sessionId,reused:O.reused,mode:mt.mode,tmuxSessionName:mt.tmuxSessionName}),mt.id}catch(G){return console.error("[Session] Failed to create new session:",G),null}},[l,c,q,at,Q]);Nn.current=z;const ge=b.useCallback((U,G={})=>{ts.getState().setActivePane(U);const he=Ze.current,Me=!!he&&ee.current[he]===!0;if(ne(U),br.current&&G.preserveMobileKeyboard===!1){lt.current=Date.now()+600,he&&(ee.current[he]=!1),Je(null),Le(null);const Qt=document.activeElement;Qt instanceof HTMLTextAreaElement&&Qt.closest(".terminal-viewport-container")&&Qt.blur();return}Me&&br.current&&Je(U),Rt.current&&(!br.current||Me)&&Le({sessionId:U,token:Date.now()})},[]),Ye=b.useCallback(U=>{ne(U),le(!0),Ne(null)},[]),ct=b.useCallback(U=>{const G=Ze.current;!G||G===U||(ye(he=>Lp(he,G,U)),le(!1),ge(G,{preserveMobileKeyboard:!1}))},[ge]),it=b.useCallback(async()=>{const U=Ze.current;if(!U||Z)return;Ge(!0);const G=Jr.getState().sessions.get(U)?.cwd??void 0,he=await z({cwd:G||void 0,mode:l});if(Ge(!1),!he){Ne(P("common.error"));return}ye(Me=>Lp(Me,U,he)),le(!1),ge(U,{preserveMobileKeyboard:!1})},[ge,l,z,Z,P]),bt=b.useCallback(U=>{ye(G=>eE(G,U)),U&&ge(U,{preserveMobileKeyboard:!1})},[ge]),Ot=b.useCallback(U=>{ye(G=>JI(G,U)),ge(U,{preserveMobileKeyboard:!1})},[ge]),qt=b.useCallback(U=>{if(W.find(he=>he.id===U)){if(ts.getState().setActivePane(U),U===Ze.current)return;if(ne(U),!CI({isMobile:br.current,viewportReady:je.has(U),streamReady:tt.has(U),contentReady:Oe.has(U)})){X(null),Rt.current&&Le({sessionId:U,token:Date.now()}),Q("[Session] Switched to session:",U);return}Fe(Me=>{if(Me.has(U))return Me;const Qt=new Set(Me);return Qt.add(U),Qt}),X(U),Q("[Session] Switched to session:",U)}},[Oe,Q,tt,W,je]),dt=b.useCallback((U,G)=>{G.trim()&&(B(he=>he.map(Me=>Me.id===U?{...Me,name:G.trim(),customName:!0}:Me)),Lt(U,G.trim()))},[Lt]),nr=b.useCallback(U=>{B(G=>G.map(he=>he.id===U?{...he,customName:!1}:he)),Y(U)},[Y]),Lr=b.useCallback(U=>{B(G=>{const he=new Map(G.map(tr=>[tr.id,tr])),Me=U.map(tr=>he.get(tr)).filter(tr=>tr!==void 0),Qt=new Set(U),It=G.filter(tr=>!Qt.has(tr.id));return[...Me,...It]}),st(U),Q("[Session] Reordered sessions:",U),requestAnimationFrame(()=>{Xe.current?.update()})},[st,Q]),vr=b.useCallback(async U=>{const G=typeof U=="string"?U:U.sessionId,he=typeof U=="string"?"auto":U.closeMode??"auto",Me=W.find(It=>It.id===G);if(!Me)return;const Qt=R8(Rn,G,It=>It.id);try{he==="destroy"&&Me.mode==="tmux"&&Me.tmuxSessionName?(await kb(Me.tmuxSessionName),Q("[Session] Destroyed tmux session:",{frontendSessionId:Me.id,tmuxSessionName:Me.tmuxSessionName})):Me.sessionId&&(await Cb(Me.sessionId),Q("[Session] Closed backend terminal:",Me.sessionId))}catch(It){console.error("[Session] Failed to close backend terminal:",It);return}B(It=>{const tr=It.filter(fr=>fr.id!==G);return ne(Qt),tr}),Te(G,Qt),delete ee.current[G],Q("[Session] Closed session:",{sessionId:G,closeMode:he})},[W,Rn,Te,Q]),$t=b.useCallback(U=>{if(!U)return;const G=W.filter(he=>he.sessionId===U);if(G.length!==0){G.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:U,frontendSessionIds:G.map(he=>he.id)}),B(he=>{const Me=he.filter(Qt=>Qt.sessionId!==U);return Me.length!==he.length&&!Me.some(It=>It.id===q)&&ne(Me.length>0?Me[0].id:null),Me});for(const he of G)Te(he.id),delete ee.current[he.id];Q("[Session] Backend gone, dropped local session(s):",G.map(he=>he.id))}},[W,q,Te,Q]);b.useEffect(()=>{const U=Jt=>{z(Jt.detail)},G=Jt=>{qt(Jt.detail)},he=()=>{const Jt=Ze.current;!Jt||br.current||Le({sessionId:Jt,token:Date.now()})},Me=Jt=>{const Ht=Jt;Ht.detail&&Ye(Ht.detail)},Qt=Jt=>{const Ht=Jt.detail;bt(Ht??Ze.current??void 0)},It=Jt=>{const Ht=Jt.detail;Ht&&Ot(Ht)},tr=Jt=>{const Ht=Jt.detail,Or=typeof Ht=="string"?Ht:Ht?.layout,Mn=typeof Ht=="string"?Ze.current:Ht?.sessionId;Or!=="horizontal"&&Or!=="vertical"&&Or!=="grid"||ye(ws=>ws.map(Pi=>Pi.sessionIds.includes(Mn??"")?{...Pi,layout:Or}:Pi))},fr=Jt=>{const Or=Jt.detail?.direction;if(Or!=="prev"&&Or!=="next")return;const Mn=hn.current;if(Mn.length<=1)return;const ws=Ze.current,Pi=ws?Mn.findIndex(Is=>Is.id===ws):-1,Ks=((Pi>=0?Pi:0)+(Or==="next"?1:-1)+Mn.length)%Mn.length,hi=Mn[Ks]?.id;hi&&hi!==ws&&qt(hi)},jr=Jt=>{vr(Jt.detail)},kn=Jt=>{$t(Jt.detail)},O=Jt=>{const Ht=Jt;!Ht.detail?.sessionId||!Ht.detail?.name||dt(Ht.detail.sessionId,Ht.detail.name)},Ae=Jt=>{const Ht=Jt;Ht.detail?.sessionId&&nr(Ht.detail.sessionId)},Re=Jt=>{const Ht=Jt;Ht.detail?.sessionIds&&Lr(Ht.detail.sessionIds)},mt=Jt=>{const Ht=Jt.detail;!Ht?.workspaceId||!Array.isArray(Ht.sessionIds)||ye(Or=>tE(Or,Ht.workspaceId,Ht.sessionIds))},Ct=Jt=>{const Ht=Jt.detail;!Ht?.workspaceId||typeof Ht.name!="string"||ye(Or=>rE(Or,Ht.workspaceId,Ht.name))},or=Jt=>{const Ht=Jt.detail;!Ht?.primaryId||!Ht.secondaryId||Ht.primaryId===Ht.secondaryId||(ye(Or=>Lp(Or,Ht.primaryId,Ht.secondaryId)),ge(Ht.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",U),window.addEventListener("switch-terminal-session",G),window.addEventListener("focus-active-terminal-session",he),window.addEventListener("open-terminal-split-chooser",Me),window.addEventListener("close-terminal-split",Qt),window.addEventListener("remove-terminal-split-pane",It),window.addEventListener("set-terminal-split-direction",tr),window.addEventListener("cycle-terminal-session",fr),window.addEventListener("close-terminal-session",jr),window.addEventListener("close-terminal-session-by-backend",kn),window.addEventListener("rename-terminal-session",O),window.addEventListener("reset-terminal-session-name",Ae),window.addEventListener("reorder-terminal-session",Re),window.addEventListener("reorder-terminal-split-workspace",mt),window.addEventListener("rename-terminal-split-workspace",Ct),window.addEventListener("combine-terminal-split-sessions",or),()=>{window.removeEventListener("new-terminal-session",U),window.removeEventListener("switch-terminal-session",G),window.removeEventListener("focus-active-terminal-session",he),window.removeEventListener("open-terminal-split-chooser",Me),window.removeEventListener("close-terminal-split",Qt),window.removeEventListener("remove-terminal-split-pane",It),window.removeEventListener("set-terminal-split-direction",tr),window.removeEventListener("cycle-terminal-session",fr),window.removeEventListener("close-terminal-session",jr),window.removeEventListener("close-terminal-session-by-backend",kn),window.removeEventListener("rename-terminal-session",O),window.removeEventListener("reset-terminal-session-name",Ae),window.removeEventListener("reorder-terminal-session",Re),window.removeEventListener("reorder-terminal-split-workspace",mt),window.removeEventListener("rename-terminal-split-workspace",Ct),window.removeEventListener("combine-terminal-split-sessions",or)}},[ge,z,qt,Ye,bt,Ot,vr,$t,dt,nr,Lr]),b.useEffect(()=>{if(!cn||pt)return;const U=G=>{if(!(G.ctrlKey||G.metaKey)||!G.shiftKey)return;if(cn.layout==="horizontal"?G.key==="ArrowLeft"||G.key==="ArrowRight":cn.layout==="vertical"?G.key==="ArrowUp"||G.key==="ArrowDown":G.key.startsWith("Arrow")){G.preventDefault(),G.stopPropagation();const Me=cn.sessionIds.indexOf(Ze.current??""),Qt=G.key==="ArrowLeft"||G.key==="ArrowUp"?-1:1,It=(Math.max(0,Me)+Qt+cn.sessionIds.length)%cn.sessionIds.length,tr=cn.sessionIds[It];if(!tr)return;ge(tr);return}G.key==="Backspace"&&(G.preventDefault(),G.stopPropagation(),bt(Ze.current??void 0))};return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[ge,cn,bt,pt]);const rt=U=>{const G=Jr.getState().sessions.get(U.id);return Xo(U,G?.activeProgram??null,G?.cwd??null,void 0,G?.shellTitle??null,G?.promptState??null)},jt=(U,G={})=>{const he=U.id===q&&!Be?.startsWith("@collaboration:"),Me=Vt.has(U.id)&&!G.hidden,Qt=p&&SI({sessionId:U.id,foregroundSessionId:qr,visibleSessionIds:Vt,deferredViewportSessionIds:pt?lr:gn}),It=TI({sessionId:U.id,foregroundSessionId:qr,foregroundReady:un,isVisible:Me})&&p,tr=II({sessionId:U.id,foregroundSessionId:qr,requestToken:ue.token,foregroundCompletedToken:zr,isVisible:Bn.has(U.id)})&&p,fr=Me||U.id===qr||gn.has(U.id)?0:_n.get(U.id)??_h;return s.jsxs("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${G.hidden?"invisible pointer-events-none":""}`,style:G.containerStyle,"aria-hidden":G.hidden||void 0,onPointerDownCapture:()=>{Me&&ix(he,()=>ge(U.id))},onWheelCapture:()=>{ix(he,()=>ge(U.id))},children:[G.showPaneTitle&&s.jsx(VI,{session:U,active:he,onActivate:()=>ge(U.id),onToggleRightSidebar:he?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:Qt&&s.jsx(GI,{sessionId:U.id,mode:U.mode,tmuxSessionName:U.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:he,focusSuspended:fe!==null,deferCursorUntilPositioned:fe===U.id||U.mode==="tmux"&&!Oe.has(U.id),isLayoutVisible:Me,initialConnectEnabled:It&&tr,resumeRequestEnabled:tr,suppressKeyboard:G.suppressKeyboard,keyboardPortalTarget:G.keyboardPortalTarget,sharedMobileKeyboardLayout:G.sharedMobileKeyboardLayout,suppressPageFlipRefresh:G.suppressPageFlipRefresh,focusRequestToken:Ue?.sessionId===U.id?Ue.token:0,resumeRequestToken:ue.token,resumeRequestReason:ue.reason,forceResumeReconnect:ue.forceForegroundReconnect&&Bn.has(U.id),resumeRequestDelayMs:Bn.has(U.id)?0:G.hidden?_h:_n.get(U.id)??_h,initialConnectDelayMs:fr,onStreamReadyChange:wn,onStreamConnected:V,onViewportReadyChange:et,onContentReadyChange:kt,onKeyboardVisibilityChange:vs,showDebug:n,onStatusChange:he?L:void 0})})]},U.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[Gt&&s.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:s.jsx(n1,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:P("tab.tmuxRecoveryTitle",{count:Gt.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:P("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:Gt.sessions.map(U=>U.name).join(" · ")}),At&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:At}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:yt!==null,onClick:()=>{Gr()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[s.jsx(Yb,{size:13,className:yt==="restore"?"animate-spin":""}),P(yt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:yt!==null,onClick:()=>{Fr()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:P("tab.tmuxRecoveryDismiss")})]})]})]})}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(x9,{onSwiper:U=>{Xe.current=U,U.allowTouchMove=Vr.length>1&&!on&&!ot,ar("[swiper:on-swiper]",{allowTouchMove:U.allowTouchMove}),requestAnimationFrame(()=>Gn("on-swiper"))},onSlideChange:fs,onTouchStart:(U,G)=>{const he=cx(G),Me=he==="touch"||he==="pen"||he==="unknown";$("[swipe:touch-start]",{pointerType:he,allowed:Me}),ar("[swiper:touch-start]",{pointerType:he,allowed:Me}),Me&&(rn(),ir.current=!0,Mt.current=!0)},onTouchEnd:(U,G)=>{const he=cx(G),Me=he==="touch"||he==="pen"||he==="unknown";$("[swipe:touch-end]",{pointerType:he,allowed:Me}),ar("[swiper:touch-end]",{pointerType:he,allowed:Me}),Me&&(ir.current=!1,$n("touch-end"))},onTransitionEnd:()=>{const U=Xe.current;if(ir.current){ar("[swiper:transition-end-during-touch]");return}if(Mt.current&&U&&!lE(U,_t.current)){ar("[swiper:transition-end-deferred]");return}rn(),Mt.current=!1,ar("[swiper:transition-end]")},initialSlide:Math.max(0,Ln),speed:Rm,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"terminal-session-swiper h-full",children:Vr.map(U=>{const G=U.workspace,he=!!G&&U.sessions.length>=2,Me=pt?hr?"horizontal":"vertical":G?.layout??"horizontal",Qt=pt&&ze?U.sessions.some(tr=>tr.id===ze):!1,It=U.sessions.some(tr=>tr.id===q)?q:U.sessions[0]?.id;return s.jsx(b9,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":hs.get(U.key)??0,style:{paddingRight:hs.get(U.key)??0,paddingTop:y&&!he?"2.5rem":void 0},children:he?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:pt?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[s.jsx(Dg,{layoutId:U.key,preset:G?.layout??"horizontal",initialTree:tS(U.sessions.map(tr=>tr.id),Me,G?.ratios,G?.gridColumnRatios,G?.gridRowRatios),mobile:pt,focusId:Qt?ze:null,panes:U.sessions.map(tr=>({id:tr.id,content:jt(tr,{showPaneTitle:!pt,suppressKeyboard:pt&&tr.id!==It,keyboardPortalTarget:pt?_r:null,sharedMobileKeyboardLayout:pt,suppressPageFlipRefresh:!0})}))}),pt&&s.jsx("div",{ref:ae,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(Dg,{layoutId:U.key,preset:G?.layout??"horizontal",mobile:pt,panes:[{id:U.sessions[0].id,content:jt(U.sessions[0])}]})})},U.key)})})}),ot&&q&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>le(!1),"aria-label":P("common.close")}),s.jsxs("section",{className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":P("tab.splitTitle"),children:[s.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Cl,{size:17})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:P("tab.splitTitle")}),s.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:P("tab.splitExistingHint")})]}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>le(!1),"aria-label":P("common.close"),children:s.jsx(Wn,{size:16})})]}),s.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[s.jsxs("button",{type:"button",disabled:Z,onClick:()=>{it()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Ys,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:P("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:P("tab.splitNewHint")})]})]}),te.filter(U=>U.id!==cn?.id).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:P("tab.splitExistingGroups")}),te.filter(U=>U.id!==cn?.id).map((U,G)=>{const he=U.sessionIds.flatMap(It=>{const tr=W.find(fr=>fr.id===It);return tr?[tr]:[]});if(he.length<2)return null;const Me=U.name||`${P("tab.splitWorkspace")} ${G+1}`,Qt=he.map(It=>rt(It).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>ct(he[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(Cl,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:Me}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:P("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[P("tab.sessionCount",{count:he.length})," · ",Qt]})]}),s.jsx(ci,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},U.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:P("tab.splitAvailableSessions")}),W.filter(U=>!te.some(G=>G.sessionIds.includes(U.id))&&U.id!==q).length===0&&te.filter(U=>U.id!==cn?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:P("tab.splitNoOtherSessions")}):W.filter(U=>!te.some(G=>G.sessionIds.includes(U.id))&&U.id!==q).map(U=>{const G=Ur.get(U.id)??null,he=rt(U);return s.jsxs("button",{type:"button",onClick:()=>ct(U.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:G?s.jsx(Ec,{size:15}):s.jsx(Cl,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:he.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:G?$u(G)??G:U.name})]}),s.jsx(ci,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},U.id)})]})]})]}),xe&&s.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:xe})]})},pE={sm:"h-4 w-7",md:"h-6 w-10"},mE={sm:"h-3 w-3",md:"h-5 w-5"},gE={sm:"translate-x-3",md:"translate-x-4"};function nl({checked:e,disabled:t=!1,size:r="md",className:n=""}){return s.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${pE[r]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${n}`,children:s.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${mE[r]} ${e?gE[r]:""}`})})}function Ji(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var xE=typeof Symbol=="function"&&Symbol.observable||"@@observable",dx=xE,hx=()=>Math.random().toString(36).substring(7).split("").join("."),bE={INIT:`@@redux/INIT${hx()}`,REPLACE:`@@redux/REPLACE${hx()}`},fx=bE;function yE(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function hy(e,t,r){if(typeof e!="function")throw new Error(Ji(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Ji(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Ji(1));return r(hy)(e,t)}let n=e,a=t,l=new Map,c=l,h=0,p=!1;function g(){c===l&&(c=new Map,l.forEach((E,R)=>{c.set(R,E)}))}function x(){if(p)throw new Error(Ji(3));return a}function y(E){if(typeof E!="function")throw new Error(Ji(4));if(p)throw new Error(Ji(5));let R=!0;g();const P=h++;return c.set(P,E),function(){if(R){if(p)throw new Error(Ji(6));R=!1,g(),c.delete(P),l=null}}}function A(E){if(!yE(E))throw new Error(Ji(7));if(typeof E.type>"u")throw new Error(Ji(8));if(typeof E.type!="string")throw new Error(Ji(17));if(p)throw new Error(Ji(9));try{p=!0,a=n(a,E)}finally{p=!1}return(l=c).forEach(P=>{P()}),E}function v(E){if(typeof E!="function")throw new Error(Ji(10));n=E,A({type:fx.REPLACE})}function L(){const E=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(Ji(11));function P(){const $=R;$.next&&$.next(x())}return P(),{unsubscribe:E(P)}},[dx](){return this}}}return A({type:fx.INIT}),{dispatch:A,subscribe:y,getState:x,replaceReducer:v,[dx]:L}}function px(e,t){return function(...r){return t(e.apply(this,r))}}function mx(e,t){if(typeof e=="function")return px(e,t);if(typeof e!="object"||e===null)throw new Error(Ji(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=px(a,t))}return r}function fy(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function vE(...e){return t=>(r,n)=>{const a=t(r,n);let l=()=>{throw new Error(Ji(15))};const c={getState:a.getState,dispatch:(p,...g)=>l(p,...g)},h=e.map(p=>p(c));return l=fy(...h)(a.dispatch),{...a,dispatch:l}}}var Ip={exports:{}},Ep={};var gx;function wE(){if(gx)return Ep;gx=1;var e=E9();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,l=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Ep.useSyncExternalStoreWithSelector=function(p,g,x,y,A){var v=a(null);if(v.current===null){var L={hasValue:!1,value:null};v.current=L}else L=v.current;v=c(function(){function E(W){if(!R){if(R=!0,P=W,W=y(W),A!==void 0&&L.hasValue){var B=L.value;if(A(B,W))return Q=B}return Q=W}if(B=Q,r(P,W))return B;var q=y(W);return A!==void 0&&A(B,q)?(P=W,B):(P=W,Q=q)}var R=!1,P,Q,$=x===void 0?null:x;return[function(){return E(g())},$===null?void 0:function(){return E($())}]},[g,x,y,A]);var I=n(p,v[0],v[1]);return l(function(){L.hasValue=!0,L.value=I},[I]),h(I),I},Ep}var xx;function AE(){return xx||(xx=1,Ip.exports=wE()),Ip.exports}AE();var TE=b.version.startsWith("19"),SE=Symbol.for(TE?"react.transitional.element":"react.element"),CE=Symbol.for("react.portal"),_E=Symbol.for("react.fragment"),LE=Symbol.for("react.strict_mode"),kE=Symbol.for("react.profiler"),IE=Symbol.for("react.consumer"),EE=Symbol.for("react.context"),py=Symbol.for("react.forward_ref"),NE=Symbol.for("react.suspense"),RE=Symbol.for("react.suspense_list"),w1=Symbol.for("react.memo"),ME=Symbol.for("react.lazy"),DE=py,jE=w1;function BE(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case SE:switch(e=e.type,e){case _E:case kE:case LE:case NE:case RE:return e;default:switch(e=e&&e.$$typeof,e){case EE:case py:case ME:case w1:return e;case IE:return e;default:return t}}case CE:return t}}}function QE(e){return BE(e)===w1}function PE(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:l,areStatePropsEqual:c}){let h=!1,p,g,x,y,A;function v(P,Q){return p=P,g=Q,x=e(p,g),y=t(n,g),A=r(x,y,g),h=!0,A}function L(){return x=e(p,g),t.dependsOnOwnProps&&(y=t(n,g)),A=r(x,y,g),A}function I(){return e.dependsOnOwnProps&&(x=e(p,g)),t.dependsOnOwnProps&&(y=t(n,g)),A=r(x,y,g),A}function E(){const P=e(p,g),Q=!c(P,x);return x=P,Q&&(A=r(x,y,g)),A}function R(P,Q){const $=!l(Q,g),W=!a(P,p,Q,g);return p=P,g=Q,$&&W?L():$?I():W?E():A}return function(Q,$){return h?R(Q,$):v(Q,$)}}function OE(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const l=t(e,a),c=r(e,a),h=n(e,a);return PE(l,c,h,e,a)}function FE(e,t){const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=(...l)=>t(a(...l)))}return r}function jm(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function bx(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function my(e,t){return function(n,{displayName:a}){const l=function(h,p){return l.dependsOnOwnProps?l.mapToProps(h,p):l.mapToProps(h,void 0)};return l.dependsOnOwnProps=!0,l.mapToProps=function(h,p){l.mapToProps=e,l.dependsOnOwnProps=bx(e);let g=l(h,p);return typeof g=="function"&&(l.mapToProps=g,l.dependsOnOwnProps=bx(g),g=l(h,p)),g},l}}function A1(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function $E(e){return e&&typeof e=="object"?jm(t=>FE(e,t)):e?typeof e=="function"?my(e):A1(e,"mapDispatchToProps"):jm(t=>({dispatch:t}))}function UE(e){return e?typeof e=="function"?my(e):A1(e,"mapStateToProps"):jm(()=>({}))}function zE(e,t,r){return{...r,...e,...t}}function HE(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let l=!1,c;return function(p,g,x){const y=e(p,g,x);return l?a(y,c)||(c=y):(l=!0,c=y),c}}}function WE(e){return e?typeof e=="function"?HE(e):A1(e,"mergeProps"):()=>zE}function GE(e){e()}function VE(){let e=null,t=null;return{clear(){e=null,t=null},notify(){GE(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var yx={notify(){},get:()=>[]};function gy(e,t){let r,n=yx,a=0,l=!1;function c(I){x();const E=n.subscribe(I);let R=!1;return()=>{R||(R=!0,E(),y())}}function h(){n.notify()}function p(){L.onStateChange&&L.onStateChange()}function g(){return l}function x(){a++,r||(r=t?t.addNestedSub(p):e.subscribe(p),n=VE())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=yx)}function A(){l||(l=!0,x())}function v(){l&&(l=!1,y())}const L={addNestedSub:c,notifyNestedSubs:h,handleChangeWrapper:p,isSubscribed:g,trySubscribe:A,tryUnsubscribe:v,getListeners:()=>n};return L}var qE=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",YE=qE(),ZE=()=>typeof navigator<"u"&&navigator.product==="ReactNative",KE=ZE(),XE=()=>YE||KE?b.useLayoutEffect:b.useEffect,Zh=XE();function vx(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Np(e,t){if(vx(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(t,r[a])||!vx(e[r[a]],t[r[a]]))return!1;return!0}var JE={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},eN={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},tN={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},xy={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},rN={[DE]:tN,[jE]:xy};function wx(e){return QE(e)?xy:rN[e.$$typeof]||JE}var nN=Object.defineProperty,sN=Object.getOwnPropertyNames,Ax=Object.getOwnPropertySymbols,iN=Object.getOwnPropertyDescriptor,aN=Object.getPrototypeOf,Tx=Object.prototype;function Bm(e,t){if(typeof t!="string"){if(Tx){const l=aN(t);l&&l!==Tx&&Bm(e,l)}let r=sN(t);Ax&&(r=r.concat(Ax(t)));const n=wx(e),a=wx(t);for(let l=0;l<r.length;++l){const c=r[l];if(!eN[c]&&!(a&&a[c])&&!(n&&n[c])){const h=iN(t,c);try{nN(e,c,h)}catch{}}}}return e}var oN=Symbol.for("react-redux-context"),lN=typeof globalThis<"u"?globalThis:{};function cN(){if(!b.createContext)return{};const e=lN[oN]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var by=cN(),uN=[null,null];function dN(e,t,r){Zh(()=>e(...t),r)}function hN(e,t,r,n,a,l){e.current=n,r.current=!1,a.current&&(a.current=null,l())}function fN(e,t,r,n,a,l,c,h,p,g,x){if(!e)return()=>{};let y=!1,A=null;const v=()=>{if(y||!h.current)return;const I=t.getState();let E,R;try{E=n(I,a.current)}catch(P){R=P,A=P}R||(A=null),E===l.current?c.current||g():(l.current=E,p.current=E,c.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,A)throw A}}function pN(e,t){return e===t}function mN(e,t,r,{pure:n,areStatesEqual:a=pN,areOwnPropsEqual:l=Np,areStatePropsEqual:c=Np,areMergedPropsEqual:h=Np,forwardRef:p=!1,context:g=by}={}){const x=g,y=UE(e),A=$E(t),v=WE(r),L=!!e;return E=>{const R=E.displayName||E.name||"Component",P=`Connect(${R})`,Q={shouldHandleStateChanges:L,displayName:P,wrappedComponentName:R,WrappedComponent:E,initMapStateToProps:y,initMapDispatchToProps:A,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:c,areOwnPropsEqual:l,areMergedPropsEqual:h};function $(q){const[ne,Be,fe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ue,...Le}=q;return[q.context,Ue,Le]},[q]),X=b.useMemo(()=>{let Ue=x;return ne?.Consumer,Ue},[ne,x]),Qe=b.useContext(X),Pe=!!q.store&&!!q.store.getState&&!!q.store.dispatch,ue=!!Qe&&!!Qe.store,Ce=Pe?q.store:Qe.store,tt=ue?Qe.getServerState:Ce.getState,we=b.useMemo(()=>OE(Ce.dispatch,Q),[Ce]),[ce,$e]=b.useMemo(()=>{if(!L)return uN;const Ue=gy(Ce,Pe?void 0:Qe.subscription),Le=Ue.notifyNestedSubs.bind(Ue);return[Ue,Le]},[Ce,Pe,Qe]),ke=b.useMemo(()=>Pe?Qe:{...Qe,subscription:ce},[Pe,Qe,ce]),se=b.useRef(void 0),je=b.useRef(fe),de=b.useRef(void 0),Oe=b.useRef(!1),Ee=b.useRef(!1),_e=b.useRef(void 0);Zh(()=>(Ee.current=!0,()=>{Ee.current=!1}),[]);const re=b.useMemo(()=>()=>de.current&&fe===je.current?de.current:we(Ce.getState(),fe),[Ce,fe]),Fe=b.useMemo(()=>Le=>ce?fN(L,Ce,ce,we,je,se,Oe,Ee,de,$e,Le):()=>{},[ce]);dN(hN,[je,se,Oe,fe,de,$e]);let wt;try{wt=b.useSyncExternalStore(Fe,re,tt?()=>we(tt(),fe):re)}catch(Ue){throw _e.current&&(Ue.message+=`
71
+ The error may be correlated with this previous error:
72
+ ${_e.current.stack}
73
+
74
+ `),Ue}Zh(()=>{_e.current=void 0,de.current=void 0,se.current=wt});const Xe=b.useMemo(()=>b.createElement(E,{...wt,ref:Be}),[Be,E,wt]);return b.useMemo(()=>L?b.createElement(X.Provider,{value:ke},Xe):Xe,[X,Xe,ke])}const B=b.memo($);if(B.WrappedComponent=E,B.displayName=$.displayName=P,p){const ne=b.forwardRef(function(fe,X){return b.createElement(B,{...fe,reactReduxForwardedRef:X})});return ne.displayName=P,ne.WrappedComponent=E,Bm(ne,E)}return Bm(B,E)}}var yy=mN;function gN(e){const{children:t,context:r,serverState:n,store:a}=e,l=b.useMemo(()=>{const p=gy(a);return{store:a,subscription:p,getServerState:n?()=>n:void 0}},[a,n]),c=b.useMemo(()=>a.getState(),[a]);Zh(()=>{const{subscription:p}=l;return p.onStateChange=p.notifyNestedSubs,p.trySubscribe(),c!==a.getState()&&p.notifyNestedSubs(),()=>{p.tryUnsubscribe(),p.onStateChange=void 0}},[l,c]);const h=r||by;return b.createElement(h.Provider,{value:l},t)}var xN=gN,bN="Invariant failed";function yN(e,t){throw new Error(bN)}var Io=function(t){var r=t.top,n=t.right,a=t.bottom,l=t.left,c=n-l,h=a-r,p={top:r,right:n,bottom:a,left:l,width:c,height:h,x:l,y:r,center:{x:(n+l)/2,y:(a+r)/2}};return p},T1=function(t,r){return{top:t.top-r.top,left:t.left-r.left,bottom:t.bottom+r.bottom,right:t.right+r.right}},Sx=function(t,r){return{top:t.top+r.top,left:t.left+r.left,bottom:t.bottom-r.bottom,right:t.right-r.right}},vN=function(t,r){return{top:t.top+r.y,left:t.left+r.x,bottom:t.bottom+r.y,right:t.right+r.x}},Rp={top:0,right:0,bottom:0,left:0},S1=function(t){var r=t.borderBox,n=t.margin,a=n===void 0?Rp:n,l=t.border,c=l===void 0?Rp:l,h=t.padding,p=h===void 0?Rp:h,g=Io(T1(r,a)),x=Io(Sx(r,c)),y=Io(Sx(x,p));return{marginBox:g,borderBox:Io(r),paddingBox:x,contentBox:y,margin:a,border:c,padding:p}},eo=function(t){var r=t.slice(0,-2),n=t.slice(-2);if(n!=="px")return 0;var a=Number(r);return isNaN(a)&&yN(),a},wN=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Kh=function(t,r){var n=t.borderBox,a=t.border,l=t.margin,c=t.padding,h=vN(n,r);return S1({borderBox:h,border:a,margin:l,padding:c})},Xh=function(t,r){return r===void 0&&(r=wN()),Kh(t,r)},vy=function(t,r){var n={top:eo(r.marginTop),right:eo(r.marginRight),bottom:eo(r.marginBottom),left:eo(r.marginLeft)},a={top:eo(r.paddingTop),right:eo(r.paddingRight),bottom:eo(r.paddingBottom),left:eo(r.paddingLeft)},l={top:eo(r.borderTopWidth),right:eo(r.borderRightWidth),bottom:eo(r.borderBottomWidth),left:eo(r.borderLeftWidth)};return S1({borderBox:t,margin:n,padding:a,border:l})},wy=function(t){var r=t.getBoundingClientRect(),n=window.getComputedStyle(t);return vy(r,n)},Xu=function(t){var r=[],n=null,a=function(){for(var c=arguments.length,h=new Array(c),p=0;p<c;p++)h[p]=arguments[p];r=h,!n&&(n=requestAnimationFrame(function(){n=null,t.apply(void 0,r)}))};return a.cancel=function(){n&&(cancelAnimationFrame(n),n=null)},a};function Jh(){return Jh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Jh.apply(null,arguments)}function Ay(e,t){}Ay.bind(null,"warn");Ay.bind(null,"error");function ql(){}function AN(e,t){return{...e,...t}}function oo(e,t,r){const n=t.map(a=>{const l=AN(r,a.options);return e.addEventListener(a.eventName,a.fn,l),function(){e.removeEventListener(a.eventName,a.fn,l)}});return function(){n.forEach(l=>{l()})}}const TN="Invariant failed";class ef extends Error{}ef.prototype.toString=function(){return this.message};function Wt(e,t){throw new ef(TN)}class SN extends S.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=ql,this.onWindowError=r=>{const n=this.getCallbacks();n.isDragging()&&n.tryAbort(),r.error instanceof ef&&r.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=r=>{this.callbacks=r}}componentDidMount(){this.unbind=oo(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof ef){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const CN=`
75
+ Press space bar to start a drag.
76
+ When dragging you can use the arrow keys to move the item around and escape to cancel.
77
+ Some screen readers may require you to be in focus mode or to use your pass through key
78
+ `,tf=e=>e+1,_N=e=>`
79
+ You have lifted an item in position ${tf(e.source.index)}
80
+ `,Ty=(e,t)=>{const r=e.droppableId===t.droppableId,n=tf(e.index),a=tf(t.index);return r?`
81
+ You have moved the item from position ${n}
82
+ to position ${a}
83
+ `:`
84
+ You have moved the item from position ${n}
85
+ in list ${e.droppableId}
86
+ to list ${t.droppableId}
87
+ in position ${a}
88
+ `},Sy=(e,t,r)=>t.droppableId===r.droppableId?`
89
+ The item ${e}
90
+ has been combined with ${r.draggableId}`:`
91
+ The item ${e}
92
+ in list ${t.droppableId}
93
+ has been combined with ${r.draggableId}
94
+ in list ${r.droppableId}
95
+ `,LN=e=>{const t=e.destination;if(t)return Ty(e.source,t);const r=e.combine;return r?Sy(e.draggableId,e.source,r):"You are over an area that cannot be dropped on"},Cx=e=>`
96
+ The item has returned to its starting position
97
+ of ${tf(e.index)}
98
+ `,kN=e=>{if(e.reason==="CANCEL")return`
99
+ Movement cancelled.
100
+ ${Cx(e.source)}
101
+ `;const t=e.destination,r=e.combine;return t?`
102
+ You have dropped the item.
103
+ ${Ty(e.source,t)}
104
+ `:r?`
105
+ You have dropped the item.
106
+ ${Sy(e.draggableId,e.source,r)}
107
+ `:`
108
+ The item has been dropped while not over a drop area.
109
+ ${Cx(e.source)}
110
+ `},Ih={dragHandleUsageInstructions:CN,onDragStart:_N,onDragUpdate:LN,onDragEnd:kN};function IN(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function Cy(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!IN(e[r],t[r]))return!1;return!0}function Tn(e,t){const r=b.useState(()=>({inputs:t,result:e()}))[0],n=b.useRef(!0),a=b.useRef(r),c=n.current||!!(t&&a.current.inputs&&Cy(t,a.current.inputs))?a.current:{inputs:t,result:e()};return b.useEffect(()=>{n.current=!1,a.current=c},[c]),c.result}function kr(e,t){return Tn(()=>e,t)}const di={x:0,y:0},Ii=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),ka=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Yl=(e,t)=>e.x===t.x&&e.y===t.y,L0=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Rc=(e,t,r=0)=>e==="x"?{x:t,y:r}:{x:r,y:t},Ju=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),_x=(e,t)=>Math.min(...t.map(r=>Ju(e,r))),_y=e=>t=>({x:e(t.x),y:e(t.y)});var EN=(e,t)=>{const r=Io({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return r.width<=0||r.height<=0?null:r};const dd=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),Lx=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],NN={top:0,right:0,bottom:0,left:0},RN=(e,t)=>t?dd(e,t.scroll.diff.displacement):e,MN=(e,t,r)=>r&&r.increasedBy?{...e,[t.end]:e[t.end]+r.increasedBy[t.line]}:e,DN=(e,t)=>t&&t.shouldClipSubject?EN(t.pageMarginBox,e):Io(e);var y0=({page:e,withPlaceholder:t,axis:r,frame:n})=>{const a=RN(e.marginBox,n),l=MN(a,r,t),c=DN(l,n);return{page:e,withPlaceholder:t,active:c}},C1=(e,t)=>{e.frame||Wt();const r=e.frame,n=ka(t,r.scroll.initial),a=L0(n),l={...r,scroll:{initial:r.scroll.initial,current:t,diff:{value:n,displacement:a},max:r.scroll.max}},c=y0({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:l});return{...e,frame:l,subject:c}};function ui(e,t=Cy){let r=null;function n(...a){if(r&&r.lastThis===this&&t(a,r.lastArgs))return r.lastResult;const l=e.apply(this,a);return r={lastResult:l,lastArgs:a,lastThis:this},l}return n.clear=function(){r=null},n}const Ly=ui(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),ky=ui(e=>e.reduce((t,r)=>(t[r.descriptor.id]=r,t),{})),xf=ui(e=>Object.values(e)),jN=ui(e=>Object.values(e));var k0=ui((e,t)=>jN(t).filter(n=>e===n.descriptor.droppableId).sort((n,a)=>n.descriptor.index-a.descriptor.index));function _1(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function bf(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var yf=ui((e,t)=>t.filter(r=>r.descriptor.id!==e.descriptor.id)),BN=({isMovingForward:e,draggable:t,destination:r,insideDestination:n,previousImpact:a})=>{if(!r.isCombineEnabled||!_1(a))return null;function c(v){const L={type:"COMBINE",combine:{draggableId:v,droppableId:r.descriptor.id}};return{...a,at:L}}const h=a.displaced.all,p=h.length?h[0]:null;if(e)return p?c(p):null;const g=yf(t,n);if(!p){if(!g.length)return null;const v=g[g.length-1];return c(v.descriptor.id)}const x=g.findIndex(v=>v.descriptor.id===p);x===-1&&Wt();const y=x-1;if(y<0)return null;const A=g[y];return c(A.descriptor.id)},I0=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Iy={point:di,value:0},ed={invisible:{},visible:{},all:[]},QN={displaced:ed,displacedBy:Iy,at:null};var co=(e,t)=>r=>e<=r&&r<=t,Ey=e=>{const t=co(e.top,e.bottom),r=co(e.left,e.right);return n=>{if(t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right))return!0;const l=t(n.top)||t(n.bottom),c=r(n.left)||r(n.right);if(l&&c)return!0;const p=n.top<e.top&&n.bottom>e.bottom,g=n.left<e.left&&n.right>e.right;return p&&g?!0:p&&c||g&&l}},PN=e=>{const t=co(e.top,e.bottom),r=co(e.left,e.right);return n=>t(n.top)&&t(n.bottom)&&r(n.left)&&r(n.right)};const L1={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},Ny={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var ON=e=>t=>{const r=co(t.top,t.bottom),n=co(t.left,t.right);return a=>e===L1?r(a.top)&&r(a.bottom):n(a.left)&&n(a.right)};const FN=(e,t)=>{const r=t.frame?t.frame.scroll.diff.displacement:di;return dd(e,r)},$N=(e,t,r)=>t.subject.active?r(t.subject.active)(e):!1,UN=(e,t,r)=>r(t)(e),k1=({target:e,destination:t,viewport:r,withDroppableDisplacement:n,isVisibleThroughFrameFn:a})=>{const l=n?FN(e,t):e;return $N(l,t,a)&&UN(l,r,a)},zN=e=>k1({...e,isVisibleThroughFrameFn:Ey}),Ry=e=>k1({...e,isVisibleThroughFrameFn:PN}),HN=e=>k1({...e,isVisibleThroughFrameFn:ON(e.destination.axis)}),WN=(e,t,r)=>{if(typeof r=="boolean")return r;if(!t)return!0;const{invisible:n,visible:a}=t;if(n[e])return!1;const l=a[e];return l?l.shouldAnimate:!0};function GN(e,t){const r=e.page.marginBox,n={top:t.point.y,right:0,bottom:0,left:t.point.x};return Io(T1(r,n))}function td({afterDragging:e,destination:t,displacedBy:r,viewport:n,forceShouldAnimate:a,last:l}){return e.reduce(function(h,p){const g=GN(p,r),x=p.descriptor.id;if(h.all.push(x),!zN({target:g,destination:t,viewport:n,withDroppableDisplacement:!0}))return h.invisible[p.descriptor.id]=!0,h;const A=WN(x,l,a),v={draggableId:x,shouldAnimate:A};return h.visible[x]=v,h},{all:[],visible:{},invisible:{}})}function VN(e,t){if(!e.length)return 0;const r=e[e.length-1].descriptor.index;return t.inHomeList?r:r+1}function kx({insideDestination:e,inHomeList:t,displacedBy:r,destination:n}){const a=VN(e,{inHomeList:t});return{displaced:ed,displacedBy:r,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function rf({draggable:e,insideDestination:t,destination:r,viewport:n,displacedBy:a,last:l,index:c,forceShouldAnimate:h}){const p=I0(e,r);if(c==null)return kx({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const g=t.find(L=>L.descriptor.index===c);if(!g)return kx({insideDestination:t,inHomeList:p,displacedBy:a,destination:r});const x=yf(e,t),y=t.indexOf(g),A=x.slice(y);return{displaced:td({afterDragging:A,destination:r,displacedBy:a,last:l,viewport:n.frame,forceShouldAnimate:h}),displacedBy:a,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:c}}}}function Xl(e,t){return!!t.effected[e]}var qN=({isMovingForward:e,destination:t,draggables:r,combine:n,afterCritical:a})=>{if(!t.isCombineEnabled)return null;const l=n.draggableId,h=r[l].descriptor.index;return Xl(l,a)?e?h:h-1:e?h+1:h},YN=({isMovingForward:e,isInHomeList:t,insideDestination:r,location:n})=>{if(!r.length)return null;const a=n.index,l=e?a+1:a-1,c=r[0].descriptor.index,h=r[r.length-1].descriptor.index,p=t?h:h+1;return l<c||l>p?null:l},ZN=({isMovingForward:e,isInHomeList:t,draggable:r,draggables:n,destination:a,insideDestination:l,previousImpact:c,viewport:h,afterCritical:p})=>{const g=c.at;if(g||Wt(),g.type==="REORDER"){const y=YN({isMovingForward:e,isInHomeList:t,location:g.destination,insideDestination:l});return y==null?null:rf({draggable:r,insideDestination:l,destination:a,viewport:h,last:c.displaced,displacedBy:c.displacedBy,index:y})}const x=qN({isMovingForward:e,destination:a,displaced:c.displaced,draggables:n,combine:g.combine,afterCritical:p});return x==null?null:rf({draggable:r,insideDestination:l,destination:a,viewport:h,last:c.displaced,displacedBy:c.displacedBy,index:x})},KN=({displaced:e,afterCritical:t,combineWith:r,displacedBy:n})=>{const a=!!(e.visible[r]||e.invisible[r]);return Xl(r,t)?a?di:L0(n.point):a?n.point:di},XN=({afterCritical:e,impact:t,draggables:r})=>{const n=bf(t);n||Wt();const a=n.draggableId,l=r[a].page.borderBox.center,c=KN({displaced:t.displaced,afterCritical:e,combineWith:a,displacedBy:t.displacedBy});return Ii(l,c)};const My=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,JN=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,I1=(e,t,r)=>t[e.crossAxisStart]+r.margin[e.crossAxisStart]+r.borderBox[e.crossAxisSize]/2,Ix=({axis:e,moveRelativeTo:t,isMoving:r})=>Rc(e.line,t.marginBox[e.end]+My(e,r),I1(e,t.marginBox,r)),Ex=({axis:e,moveRelativeTo:t,isMoving:r})=>Rc(e.line,t.marginBox[e.start]-JN(e,r),I1(e,t.marginBox,r)),eR=({axis:e,moveInto:t,isMoving:r})=>Rc(e.line,t.contentBox[e.start]+My(e,r),I1(e,t.contentBox,r));var tR=({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:a})=>{const l=k0(n.descriptor.id,r),c=t.page,h=n.axis;if(!l.length)return eR({axis:h,moveInto:n.page,isMoving:c});const{displaced:p,displacedBy:g}=e,x=p.all[0];if(x){const A=r[x];if(Xl(x,a))return Ex({axis:h,moveRelativeTo:A.page,isMoving:c});const v=Kh(A.page,g.point);return Ex({axis:h,moveRelativeTo:v,isMoving:c})}const y=l[l.length-1];if(y.descriptor.id===t.descriptor.id)return c.borderBox.center;if(Xl(y.descriptor.id,a)){const A=Kh(y.page,L0(a.displacedBy.point));return Ix({axis:h,moveRelativeTo:A,isMoving:c})}return Ix({axis:h,moveRelativeTo:y.page,isMoving:c})},Qm=(e,t)=>{const r=e.frame;return r?Ii(t,r.scroll.diff.displacement):t};const rR=({impact:e,draggable:t,droppable:r,draggables:n,afterCritical:a})=>{const l=t.page.borderBox.center,c=e.at;return!r||!c?l:c.type==="REORDER"?tR({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:a}):XN({impact:e,draggables:n,afterCritical:a})};var vf=e=>{const t=rR(e),r=e.droppable;return r?Qm(r,t):t},Dy=(e,t)=>{const r=ka(t,e.scroll.initial),n=L0(r);return{frame:Io({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:r,displacement:n}}}};function Nx(e,t){return e.map(r=>t[r])}function nR(e,t){for(let r=0;r<t.length;r++){const n=t[r].visible[e];if(n)return n}return null}var sR=({impact:e,viewport:t,destination:r,draggables:n,maxScrollChange:a})=>{const l=Dy(t,Ii(t.scroll.current,a)),c=r.frame?C1(r,Ii(r.frame.scroll.current,a)):r,h=e.displaced,p=td({afterDragging:Nx(h.all,n),destination:r,displacedBy:e.displacedBy,viewport:l.frame,last:h,forceShouldAnimate:!1}),g=td({afterDragging:Nx(h.all,n),destination:c,displacedBy:e.displacedBy,viewport:t.frame,last:h,forceShouldAnimate:!1}),x={},y={},A=[h,p,g];return h.all.forEach(L=>{const I=nR(L,A);if(I){y[L]=I;return}x[L]=!0}),{...e,displaced:{all:h.all,invisible:x,visible:y}}},iR=(e,t)=>Ii(e.scroll.diff.displacement,t),E1=({pageBorderBoxCenter:e,draggable:t,viewport:r})=>{const n=iR(r,e),a=ka(n,t.page.borderBox.center);return Ii(t.client.borderBox.center,a)},jy=({draggable:e,destination:t,newPageBorderBoxCenter:r,viewport:n,withDroppableDisplacement:a,onlyOnMainAxis:l=!1})=>{const c=ka(r,e.page.borderBox.center),p={target:dd(e.page.borderBox,c),destination:t,withDroppableDisplacement:a,viewport:n};return l?HN(p):Ry(p)},aR=({isMovingForward:e,draggable:t,destination:r,draggables:n,previousImpact:a,viewport:l,previousPageBorderBoxCenter:c,previousClientSelection:h,afterCritical:p})=>{if(!r.isEnabled)return null;const g=k0(r.descriptor.id,n),x=I0(t,r),y=BN({isMovingForward:e,draggable:t,destination:r,insideDestination:g,previousImpact:a})||ZN({isMovingForward:e,isInHomeList:x,draggable:t,draggables:n,destination:r,insideDestination:g,previousImpact:a,viewport:l,afterCritical:p});if(!y)return null;const A=vf({impact:y,draggable:t,droppable:r,draggables:n,afterCritical:p});if(jy({draggable:t,destination:r,newPageBorderBoxCenter:A,viewport:l.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:E1({pageBorderBoxCenter:A,draggable:t,viewport:l}),impact:y,scrollJumpRequest:null};const L=ka(A,c),I=sR({impact:y,viewport:l,destination:r,draggables:n,maxScrollChange:L});return{clientSelection:h,impact:I,scrollJumpRequest:L}};const Zi=e=>{const t=e.subject.active;return t||Wt(),t};var oR=({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:n,viewport:a})=>{const l=r.subject.active;if(!l)return null;const c=r.axis,h=co(l[c.start],l[c.end]),p=xf(n).filter(x=>x!==r).filter(x=>x.isEnabled).filter(x=>!!x.subject.active).filter(x=>Ey(a.frame)(Zi(x))).filter(x=>{const y=Zi(x);return e?l[c.crossAxisEnd]<y[c.crossAxisEnd]:y[c.crossAxisStart]<l[c.crossAxisStart]}).filter(x=>{const y=Zi(x),A=co(y[c.start],y[c.end]);return h(y[c.start])||h(y[c.end])||A(l[c.start])||A(l[c.end])}).sort((x,y)=>{const A=Zi(x)[c.crossAxisStart],v=Zi(y)[c.crossAxisStart];return e?A-v:v-A}).filter((x,y,A)=>Zi(x)[c.crossAxisStart]===Zi(A[0])[c.crossAxisStart]);if(!p.length)return null;if(p.length===1)return p[0];const g=p.filter(x=>co(Zi(x)[c.start],Zi(x)[c.end])(t[c.line]));return g.length===1?g[0]:g.length>1?g.sort((x,y)=>Zi(x)[c.start]-Zi(y)[c.start])[0]:p.sort((x,y)=>{const A=_x(t,Lx(Zi(x))),v=_x(t,Lx(Zi(y)));return A!==v?A-v:Zi(x)[c.start]-Zi(y)[c.start]})[0]};const Rx=(e,t)=>{const r=e.page.borderBox.center;return Xl(e.descriptor.id,t)?ka(r,t.displacedBy.point):r},lR=(e,t)=>{const r=e.page.borderBox;return Xl(e.descriptor.id,t)?dd(r,L0(t.displacedBy.point)):r};var cR=({pageBorderBoxCenter:e,viewport:t,destination:r,insideDestination:n,afterCritical:a})=>n.filter(c=>Ry({target:lR(c,a),destination:r,viewport:t.frame,withDroppableDisplacement:!0})).sort((c,h)=>{const p=Ju(e,Qm(r,Rx(c,a))),g=Ju(e,Qm(r,Rx(h,a)));return p<g?-1:g<p?1:c.descriptor.index-h.descriptor.index})[0]||null,hd=ui(function(t,r){const n=r[t.line];return{value:n,point:Rc(t.line,n)}});const uR=(e,t,r)=>{const n=e.axis;if(e.descriptor.mode==="virtual")return Rc(n.line,t[n.line]);const a=e.subject.page.contentBox[n.size],p=k0(e.descriptor.id,r).reduce((g,x)=>g+x.client.marginBox[n.size],0)+t[n.line]-a;return p<=0?null:Rc(n.line,p)},By=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),Qy=(e,t,r)=>{const n=e.frame;I0(t,e)&&Wt(),e.subject.withPlaceholder&&Wt();const a=hd(e.axis,t.displaceBy).point,l=uR(e,a,r),c={placeholderSize:a,increasedBy:l,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!n){const x=y0({page:e.subject.page,withPlaceholder:c,axis:e.axis,frame:e.frame});return{...e,subject:x}}const h=l?Ii(n.scroll.max,l):n.scroll.max,p=By(n,h),g=y0({page:e.subject.page,withPlaceholder:c,axis:e.axis,frame:p});return{...e,subject:g,frame:p}},dR=e=>{const t=e.subject.withPlaceholder;t||Wt();const r=e.frame;if(!r){const c=y0({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:c}}const n=t.oldFrameMaxScroll;n||Wt();const a=By(r,n),l=y0({page:e.subject.page,axis:e.axis,frame:a,withPlaceholder:null});return{...e,subject:l,frame:a}};var hR=({previousPageBorderBoxCenter:e,moveRelativeTo:t,insideDestination:r,draggable:n,draggables:a,destination:l,viewport:c,afterCritical:h})=>{if(!t){if(r.length)return null;const y={displaced:ed,displacedBy:Iy,at:{type:"REORDER",destination:{droppableId:l.descriptor.id,index:0}}},A=vf({impact:y,draggable:n,droppable:l,draggables:a,afterCritical:h}),v=I0(n,l)?l:Qy(l,n,a);return jy({draggable:n,destination:v,newPageBorderBoxCenter:A,viewport:c.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?y:null}const p=e[l.axis.line]<=t.page.borderBox.center[l.axis.line],g=(()=>{const y=t.descriptor.index;return t.descriptor.id===n.descriptor.id||p?y:y+1})(),x=hd(l.axis,n.displaceBy);return rf({draggable:n,insideDestination:r,destination:l,viewport:c,displacedBy:x,last:ed,index:g})},fR=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:r,isOver:n,draggables:a,droppables:l,viewport:c,afterCritical:h})=>{const p=oR({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:l,viewport:c});if(!p)return null;const g=k0(p.descriptor.id,a),x=cR({pageBorderBoxCenter:t,viewport:c,destination:p,insideDestination:g,afterCritical:h}),y=hR({previousPageBorderBoxCenter:t,destination:p,draggable:r,draggables:a,moveRelativeTo:x,insideDestination:g,viewport:c,afterCritical:h});if(!y)return null;const A=vf({impact:y,draggable:r,droppable:p,draggables:a,afterCritical:h});return{clientSelection:E1({pageBorderBoxCenter:A,draggable:r,viewport:c}),impact:y,scrollJumpRequest:null}},Ea=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const pR=(e,t)=>{const r=Ea(e);return r?t[r]:null};var mR=({state:e,type:t})=>{const r=pR(e.impact,e.dimensions.droppables),n=!!r,a=e.dimensions.droppables[e.critical.droppable.id],l=r||a,c=l.axis.direction,h=c==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||c==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(h&&!n)return null;const p=t==="MOVE_DOWN"||t==="MOVE_RIGHT",g=e.dimensions.draggables[e.critical.draggable.id],x=e.current.page.borderBoxCenter,{draggables:y,droppables:A}=e.dimensions;return h?aR({isMovingForward:p,previousPageBorderBoxCenter:x,draggable:g,destination:l,draggables:y,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):fR({isMovingForward:p,previousPageBorderBoxCenter:x,draggable:g,isOver:l,draggables:y,droppables:A,viewport:e.viewport,afterCritical:e.afterCritical})};function xc(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function Py(e){const t=co(e.top,e.bottom),r=co(e.left,e.right);return function(a){return t(a.y)&&r(a.x)}}function gR(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function xR({pageBorderBox:e,draggable:t,candidates:r}){const n=t.page.borderBox.center,a=r.map(l=>{const c=l.axis,h=Rc(l.axis.line,e.center[c.line],l.page.borderBox.center[c.crossAxisLine]);return{id:l.descriptor.id,distance:Ju(n,h)}}).sort((l,c)=>c.distance-l.distance);return a[0]?a[0].id:null}function bR({pageBorderBox:e,draggable:t,droppables:r}){const n=xf(r).filter(a=>{if(!a.isEnabled)return!1;const l=a.subject.active;if(!l||!gR(e,l))return!1;if(Py(l)(e.center))return!0;const c=a.axis,h=l.center[c.crossAxisLine],p=e[c.crossAxisStart],g=e[c.crossAxisEnd],x=co(l[c.crossAxisStart],l[c.crossAxisEnd]),y=x(p),A=x(g);return!y&&!A?!0:y?p<h:g>h});return n.length?n.length===1?n[0].descriptor.id:xR({pageBorderBox:e,draggable:t,candidates:n}):null}const Oy=(e,t)=>Io(dd(e,t));var yR=(e,t)=>{const r=e.frame;return r?Oy(t,r.scroll.diff.value):t};function Fy({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function vR({draggable:e,closest:t,inHomeList:r}){return t?r&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var wR=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:r,insideDestination:n,last:a,viewport:l,afterCritical:c})=>{const h=r.axis,p=hd(r.axis,t.displaceBy),g=p.value,x=e[h.start],y=e[h.end],v=yf(t,n).find(I=>{const E=I.descriptor.id,R=I.page.borderBox.center[h.line],P=Xl(E,c),Q=Fy({displaced:a,id:E});return P?Q?y<=R:x<R-g:Q?y<=R+g:x<R})||null,L=vR({draggable:t,closest:v,inHomeList:I0(t,r)});return rf({draggable:t,insideDestination:n,destination:r,viewport:l,last:a,displacedBy:p,index:L})};const AR=4;var TR=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:r,destination:n,insideDestination:a,afterCritical:l})=>{if(!n.isCombineEnabled)return null;const c=n.axis,h=hd(n.axis,e.displaceBy),p=h.value,g=t[c.start],x=t[c.end],A=yf(e,a).find(L=>{const I=L.descriptor.id,E=L.page.borderBox,P=E[c.size]/AR,Q=Xl(I,l),$=Fy({displaced:r.displaced,id:I});return Q?$?x>E[c.start]+P&&x<E[c.end]-P:g>E[c.start]-p+P&&g<E[c.end]-p-P:$?x>E[c.start]+p+P&&x<E[c.end]+p-P:g>E[c.start]+P&&g<E[c.end]-P});return A?{displacedBy:h,displaced:r.displaced,at:{type:"COMBINE",combine:{draggableId:A.descriptor.id,droppableId:n.descriptor.id}}}:null},$y=({pageOffset:e,draggable:t,draggables:r,droppables:n,previousImpact:a,viewport:l,afterCritical:c})=>{const h=Oy(t.page.borderBox,e),p=bR({pageBorderBox:h,draggable:t,droppables:n});if(!p)return QN;const g=n[p],x=k0(g.descriptor.id,r),y=yR(g,h);return TR({pageBorderBoxWithDroppableScroll:y,draggable:t,previousImpact:a,destination:g,insideDestination:x,afterCritical:c})||wR({pageBorderBoxWithDroppableScroll:y,draggable:t,destination:g,insideDestination:x,last:a.displaced,viewport:l,afterCritical:c})},N1=(e,t)=>({...e,[t.descriptor.id]:t});const SR=({previousImpact:e,impact:t,droppables:r})=>{const n=Ea(e),a=Ea(t);if(!n||n===a)return r;const l=r[n];if(!l.subject.withPlaceholder)return r;const c=dR(l);return N1(r,c)};var CR=({draggable:e,draggables:t,droppables:r,previousImpact:n,impact:a})=>{const l=SR({previousImpact:n,impact:a,droppables:r}),c=Ea(a);if(!c)return l;const h=r[c];if(I0(e,h)||h.subject.withPlaceholder)return l;const p=Qy(h,e,t);return N1(l,p)},Bu=({state:e,clientSelection:t,dimensions:r,viewport:n,impact:a,scrollJumpRequest:l})=>{const c=n||e.viewport,h=r||e.dimensions,p=t||e.current.client.selection,g=ka(p,e.initial.client.selection),x={offset:g,selection:p,borderBoxCenter:Ii(e.initial.client.borderBoxCenter,g)},y={selection:Ii(x.selection,c.scroll.current),borderBoxCenter:Ii(x.borderBoxCenter,c.scroll.current),offset:Ii(x.offset,c.scroll.diff.value)},A={client:x,page:y};if(e.phase==="COLLECTING")return{...e,dimensions:h,viewport:c,current:A};const v=h.draggables[e.critical.draggable.id],L=a||$y({pageOffset:y.offset,draggable:v,draggables:h.draggables,droppables:h.droppables,previousImpact:e.impact,viewport:c,afterCritical:e.afterCritical}),I=CR({draggable:v,impact:L,previousImpact:e.impact,draggables:h.draggables,droppables:h.droppables});return{...e,current:A,dimensions:{draggables:h.draggables,droppables:I},impact:L,viewport:c,scrollJumpRequest:l||null,forceShouldAnimate:l?!1:null}};function _R(e,t){return e.map(r=>t[r])}var Uy=({impact:e,viewport:t,draggables:r,destination:n,forceShouldAnimate:a})=>{const l=e.displaced,c=_R(l.all,r),h=td({afterDragging:c,destination:n,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:a,last:l});return{...e,displaced:h}},zy=({impact:e,draggable:t,droppable:r,draggables:n,viewport:a,afterCritical:l})=>{const c=vf({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:l});return E1({pageBorderBoxCenter:c,draggable:t,viewport:a})},Hy=({state:e,dimensions:t,viewport:r})=>{e.movementMode!=="SNAP"&&Wt();const n=e.impact,a=r||e.viewport,l=t||e.dimensions,{draggables:c,droppables:h}=l,p=c[e.critical.draggable.id],g=Ea(n);g||Wt();const x=h[g],y=Uy({impact:n,viewport:a,destination:x,draggables:c}),A=zy({impact:y,draggable:p,droppable:x,draggables:c,viewport:a,afterCritical:e.afterCritical});return Bu({impact:y,clientSelection:A,state:e,dimensions:l,viewport:a})},LR=e=>({index:e.index,droppableId:e.droppableId}),Wy=({draggable:e,home:t,draggables:r,viewport:n})=>{const a=hd(t.axis,e.displaceBy),l=k0(t.descriptor.id,r),c=l.indexOf(e);c===-1&&Wt();const h=l.slice(c+1),p=h.reduce((A,v)=>(A[v.descriptor.id]=!0,A),{}),g={inVirtualList:t.descriptor.mode==="virtual",displacedBy:a,effected:p};return{impact:{displaced:td({afterDragging:h,destination:t,displacedBy:a,last:null,viewport:n.frame,forceShouldAnimate:!1}),displacedBy:a,at:{type:"REORDER",destination:LR(e.descriptor)}},afterCritical:g}},kR=(e,t)=>({draggables:e.draggables,droppables:N1(e.droppables,t)}),IR=({draggable:e,offset:t,initialWindowScroll:r})=>{const n=Kh(e.client,t),a=Xh(n,r);return{...e,placeholder:{...e.placeholder,client:n},client:n,page:a}},ER=e=>{const t=e.frame;return t||Wt(),t},NR=({additions:e,updatedDroppables:t,viewport:r})=>{const n=r.scroll.diff.value;return e.map(a=>{const l=a.descriptor.droppableId,c=t[l],p=ER(c).scroll.diff.value,g=Ii(n,p);return IR({draggable:a,offset:g,initialWindowScroll:r.scroll.initial})})},RR=({state:e,published:t})=>{const r=t.modified.map(R=>{const P=e.dimensions.droppables[R.droppableId];return C1(P,R.scroll)}),n={...e.dimensions.droppables,...Ly(r)},a=ky(NR({additions:t.additions,updatedDroppables:n,viewport:e.viewport})),l={...e.dimensions.draggables,...a};t.removals.forEach(R=>{delete l[R]});const c={droppables:n,draggables:l},h=Ea(e.impact),p=h?c.droppables[h]:null,g=c.draggables[e.critical.draggable.id],x=c.droppables[e.critical.droppable.id],{impact:y,afterCritical:A}=Wy({draggable:g,home:x,draggables:l,viewport:e.viewport}),v=p&&p.isCombineEnabled?e.impact:y,L=$y({pageOffset:e.current.page.offset,draggable:c.draggables[e.critical.draggable.id],draggables:c.draggables,droppables:c.droppables,previousImpact:v,viewport:e.viewport,afterCritical:A}),I={...e,phase:"DRAGGING",impact:L,onLiftImpact:y,dimensions:c,afterCritical:A,forceShouldAnimate:!1};return e.phase==="COLLECTING"?I:{...I,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const Pm=e=>e.movementMode==="SNAP",Mp=(e,t,r)=>{const n=kR(e.dimensions,t);return!Pm(e)||r?Bu({state:e,dimensions:n}):Hy({state:e,dimensions:n})};function Dp(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const Mx={phase:"IDLE",completed:null,shouldFlush:!1};var MR=(e=Mx,t)=>{if(t.type==="FLUSH")return{...Mx,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&Wt();const{critical:r,clientSelection:n,viewport:a,dimensions:l,movementMode:c}=t.payload,h=l.draggables[r.draggable.id],p=l.droppables[r.droppable.id],g={selection:n,borderBoxCenter:h.client.borderBox.center,offset:di},x={client:g,page:{selection:Ii(g.selection,a.scroll.initial),borderBoxCenter:Ii(g.selection,a.scroll.initial),offset:Ii(g.selection,a.scroll.diff.value)}},y=xf(l.droppables).every(I=>!I.isFixedOnPage),{impact:A,afterCritical:v}=Wy({draggable:h,home:p,draggables:l.draggables,viewport:a});return{phase:"DRAGGING",isDragging:!0,critical:r,movementMode:c,dimensions:l,initial:x,current:x,isWindowScrollAllowed:y,impact:A,afterCritical:v,onLiftImpact:A,viewport:a,scrollJumpRequest:null,forceShouldAnimate:null}}if(t.type==="COLLECTION_STARTING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"?e:(e.phase!=="DRAGGING"&&Wt(),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||Wt(),RR({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;xc(e)||Wt();const{client:r}=t.payload;return Yl(r,e.current.client.selection)?e:Bu({state:e,clientSelection:r,impact:Pm(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return Dp(e);xc(e)||Wt();const{id:r,newScroll:n}=t.payload,a=e.dimensions.droppables[r];if(!a)return e;const l=C1(a,n);return Mp(e,l,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;xc(e)||Wt();const{id:r,isEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Wt(),a.isEnabled===n&&Wt();const l={...a,isEnabled:n};return Mp(e,l,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;xc(e)||Wt();const{id:r,isCombineEnabled:n}=t.payload,a=e.dimensions.droppables[r];a||Wt(),a.isCombineEnabled===n&&Wt();const l={...a,isCombineEnabled:n};return Mp(e,l,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;xc(e)||Wt(),e.isWindowScrollAllowed||Wt();const r=t.payload.newScroll;if(Yl(e.viewport.scroll.current,r))return Dp(e);const n=Dy(e.viewport,r);return Pm(e)?Hy({state:e,viewport:n}):Bu({state:e,viewport:n})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!xc(e))return e;const r=t.payload.maxScroll;if(Yl(r,e.viewport.scroll.max))return e;const n={...e.viewport,scroll:{...e.viewport.scroll,max:r}};return{...e,viewport:n}}if(t.type==="MOVE_UP"||t.type==="MOVE_DOWN"||t.type==="MOVE_LEFT"||t.type==="MOVE_RIGHT"){if(e.phase==="COLLECTING"||e.phase==="DROP_PENDING")return e;e.phase!=="DRAGGING"&&Wt();const r=mR({state:e,type:t.type});return r?Bu({state:e,impact:r.impact,clientSelection:r.clientSelection,scrollJumpRequest:r.scrollJumpRequest}):e}if(t.type==="DROP_PENDING"){const r=t.payload.reason;return e.phase!=="COLLECTING"&&Wt(),{...e,phase:"DROP_PENDING",isWaiting:!0,reason:r}}if(t.type==="DROP_ANIMATE"){const{completed:r,dropDuration:n,newHomeClientOffset:a}=t.payload;return e.phase==="DRAGGING"||e.phase==="DROP_PENDING"||Wt(),{phase:"DROP_ANIMATING",completed:r,dropDuration:n,newHomeClientOffset:a,dimensions:e.dimensions}}if(t.type==="DROP_COMPLETE"){const{completed:r}=t.payload;return{phase:"IDLE",completed:r,shouldFlush:!1}}return e};function Fn(e,t){return e instanceof Object&&"type"in e&&e.type===t}const DR=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),jR=e=>({type:"LIFT",payload:e}),BR=e=>({type:"INITIAL_PUBLISH",payload:e}),QR=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),PR=()=>({type:"COLLECTION_STARTING",payload:null}),OR=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),FR=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),$R=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Gy=e=>({type:"MOVE",payload:e}),UR=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),zR=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),HR=()=>({type:"MOVE_UP",payload:null}),WR=()=>({type:"MOVE_DOWN",payload:null}),GR=()=>({type:"MOVE_RIGHT",payload:null}),VR=()=>({type:"MOVE_LEFT",payload:null}),R1=()=>({type:"FLUSH",payload:null}),qR=e=>({type:"DROP_ANIMATE",payload:e}),M1=e=>({type:"DROP_COMPLETE",payload:e}),Vy=e=>({type:"DROP",payload:e}),YR=e=>({type:"DROP_PENDING",payload:e}),qy=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});var ZR=e=>({getState:t,dispatch:r})=>n=>a=>{if(!Fn(a,"LIFT")){n(a);return}const{id:l,clientSelection:c,movementMode:h}=a.payload,p=t();p.phase==="DROP_ANIMATING"&&r(M1({completed:p.completed})),t().phase!=="IDLE"&&Wt(),r(R1()),r(DR({draggableId:l,movementMode:h}));const x={draggableId:l,scrollOptions:{shouldPublishImmediately:h==="SNAP"}},{critical:y,dimensions:A,viewport:v}=e.startPublishing(x);r(BR({critical:y,dimensions:A,clientSelection:c,movementMode:h,viewport:v}))},KR=e=>()=>t=>r=>{Fn(r,"INITIAL_PUBLISH")&&e.dragging(),Fn(r,"DROP_ANIMATE")&&e.dropping(r.payload.completed.result.reason),(Fn(r,"FLUSH")||Fn(r,"DROP_COMPLETE"))&&e.resting(),t(r)};const D1={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},rd={opacity:{drop:0,combining:.7},scale:{drop:.75}},Yy={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},mc=`${Yy.outOfTheWay}s ${D1.outOfTheWay}`,Qu={fluid:`opacity ${mc}`,snap:`transform ${mc}, opacity ${mc}`,drop:e=>{const t=`${e}s ${D1.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${mc}`,placeholder:`height ${mc}, width ${mc}, margin ${mc}`},Dx=e=>Yl(e,di)?void 0:`translate(${e.x}px, ${e.y}px)`,Om={moveTo:Dx,drop:(e,t)=>{const r=Dx(e);if(r)return t?`${r} scale(${rd.scale.drop})`:r}},{minDropTime:Fm,maxDropTime:Zy}=Yy,XR=Zy-Fm,jx=1500,JR=.6;var eM=({current:e,destination:t,reason:r})=>{const n=Ju(e,t);if(n<=0)return Fm;if(n>=jx)return Zy;const a=n/jx,l=Fm+XR*a,c=r==="CANCEL"?l*JR:l;return Number(c.toFixed(2))},tM=({impact:e,draggable:t,dimensions:r,viewport:n,afterCritical:a})=>{const{draggables:l,droppables:c}=r,h=Ea(e),p=h?c[h]:null,g=c[t.descriptor.droppableId],x=zy({impact:e,draggable:t,draggables:l,afterCritical:a,droppable:p||g,viewport:n});return ka(x,t.client.borderBox.center)},rM=({draggables:e,reason:t,lastImpact:r,home:n,viewport:a,onLiftImpact:l})=>!r.at||t!=="DROP"?{impact:Uy({draggables:e,impact:l,destination:n,viewport:a,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:r.at.type==="REORDER"?{impact:r,didDropInsideDroppable:!0}:{impact:{...r,displaced:ed},didDropInsideDroppable:!0};const nM=({getState:e,dispatch:t})=>r=>n=>{if(!Fn(n,"DROP")){r(n);return}const a=e(),l=n.payload.reason;if(a.phase==="COLLECTING"){t(YR({reason:l}));return}if(a.phase==="IDLE")return;a.phase==="DROP_PENDING"&&a.isWaiting&&Wt(),a.phase==="DRAGGING"||a.phase==="DROP_PENDING"||Wt();const h=a.critical,p=a.dimensions,g=p.draggables[a.critical.draggable.id],{impact:x,didDropInsideDroppable:y}=rM({reason:l,lastImpact:a.impact,afterCritical:a.afterCritical,onLiftImpact:a.onLiftImpact,home:a.dimensions.droppables[a.critical.droppable.id],viewport:a.viewport,draggables:a.dimensions.draggables}),A=y?_1(x):null,v=y?bf(x):null,L={index:h.draggable.index,droppableId:h.droppable.id},I={draggableId:g.descriptor.id,type:g.descriptor.type,source:L,reason:l,mode:a.movementMode,destination:A,combine:v},E=tM({impact:x,draggable:g,dimensions:p,viewport:a.viewport,afterCritical:a.afterCritical}),R={critical:a.critical,afterCritical:a.afterCritical,result:I,impact:x};if(!(!Yl(a.current.client.offset,E)||!!I.combine)){t(M1({completed:R}));return}const Q=eM({current:a.current.client.offset,destination:E,reason:l});t(qR({newHomeClientOffset:E,dropDuration:Q,completed:R}))};var Ky=()=>({x:window.pageXOffset,y:window.pageYOffset});function sM(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function iM({onWindowScroll:e}){function t(){e(Ky())}const r=Xu(t),n=sM(r);let a=ql;function l(){return a!==ql}function c(){l()&&Wt(),a=oo(window,[n])}function h(){l()||Wt(),r.cancel(),a(),a=ql}return{start:c,stop:h,isActive:l}}const aM=e=>Fn(e,"DROP_COMPLETE")||Fn(e,"DROP_ANIMATE")||Fn(e,"FLUSH"),oM=e=>{const t=iM({onWindowScroll:r=>{e.dispatch(UR({newScroll:r}))}});return r=>n=>{!t.isActive()&&Fn(n,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&aM(n)&&t.stop(),r(n)}};var lM=e=>{let t=!1,r=!1;const n=setTimeout(()=>{r=!0}),a=l=>{t||r||(t=!0,e(l),clearTimeout(n))};return a.wasCalled=()=>t,a},cM=()=>{const e=[],t=a=>{const l=e.findIndex(h=>h.timerId===a);l===-1&&Wt();const[c]=e.splice(l,1);c.callback()};return{add:a=>{const l=setTimeout(()=>t(l)),c={timerId:l,callback:a};e.push(c)},flush:()=>{if(!e.length)return;const a=[...e];e.length=0,a.forEach(l=>{clearTimeout(l.timerId),l.callback()})}}};const uM=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,dM=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,hM=(e,t)=>{if(e===t)return!0;const r=e.draggable.id===t.draggable.id&&e.draggable.droppableId===t.draggable.droppableId&&e.draggable.type===t.draggable.type&&e.draggable.index===t.draggable.index,n=e.droppable.id===t.droppable.id&&e.droppable.type===t.droppable.type;return r&&n},au=(e,t)=>{t()},rh=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function jp(e,t,r,n){if(!e){r(n(t));return}const a=lM(r);e(t,{announce:a}),a.wasCalled()||r(n(t))}var fM=(e,t)=>{const r=cM();let n=null;const a=(y,A)=>{n&&Wt(),au("onBeforeCapture",()=>{const v=e().onBeforeCapture;v&&v({draggableId:y,mode:A})})},l=(y,A)=>{n&&Wt(),au("onBeforeDragStart",()=>{const v=e().onBeforeDragStart;v&&v(rh(y,A))})},c=(y,A)=>{n&&Wt();const v=rh(y,A);n={mode:A,lastCritical:y,lastLocation:v.source,lastCombine:null},r.add(()=>{au("onDragStart",()=>jp(e().onDragStart,v,t,Ih.onDragStart))})},h=(y,A)=>{const v=_1(A),L=bf(A);n||Wt();const I=!hM(y,n.lastCritical);I&&(n.lastCritical=y);const E=!uM(n.lastLocation,v);E&&(n.lastLocation=v);const R=!dM(n.lastCombine,L);if(R&&(n.lastCombine=L),!I&&!E&&!R)return;const P={...rh(y,n.mode),combine:L,destination:v};r.add(()=>{au("onDragUpdate",()=>jp(e().onDragUpdate,P,t,Ih.onDragUpdate))})},p=()=>{n||Wt(),r.flush()},g=y=>{n||Wt(),n=null,au("onDragEnd",()=>jp(e().onDragEnd,y,t,Ih.onDragEnd))};return{beforeCapture:a,beforeStart:l,start:c,update:h,flush:p,drop:g,abort:()=>{if(!n)return;const y={...rh(n.lastCritical,n.mode),combine:null,destination:null,reason:"CANCEL"};g(y)}}},pM=(e,t)=>{const r=fM(e,t);return n=>a=>l=>{if(Fn(l,"BEFORE_INITIAL_CAPTURE")){r.beforeCapture(l.payload.draggableId,l.payload.movementMode);return}if(Fn(l,"INITIAL_PUBLISH")){const h=l.payload.critical;r.beforeStart(h,l.payload.movementMode),a(l),r.start(h,l.payload.movementMode);return}if(Fn(l,"DROP_COMPLETE")){const h=l.payload.completed.result;r.flush(),a(l),r.drop(h);return}if(a(l),Fn(l,"FLUSH")){r.abort();return}const c=n.getState();c.phase==="DRAGGING"&&r.update(c.critical,c.impact)}};const mM=e=>t=>r=>{if(!Fn(r,"DROP_ANIMATION_FINISHED")){t(r);return}const n=e.getState();n.phase!=="DROP_ANIMATING"&&Wt(),e.dispatch(M1({completed:n.completed}))},gM=e=>{let t=null,r=null;function n(){r&&(cancelAnimationFrame(r),r=null),t&&(t(),t=null)}return a=>l=>{if((Fn(l,"FLUSH")||Fn(l,"DROP_COMPLETE")||Fn(l,"DROP_ANIMATION_FINISHED"))&&n(),a(l),!Fn(l,"DROP_ANIMATE"))return;const c={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(qy())}};r=requestAnimationFrame(()=>{r=null,t=oo(window,[c])})}};var xM=e=>()=>t=>r=>{(Fn(r,"DROP_COMPLETE")||Fn(r,"FLUSH")||Fn(r,"DROP_ANIMATE"))&&e.stopPublishing(),t(r)},bM=e=>{let t=!1;return()=>r=>n=>{if(Fn(n,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(n.payload.critical.draggable.id),r(n),e.tryRestoreFocusRecorded();return}if(r(n),!!t){if(Fn(n,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(Fn(n,"DROP_COMPLETE")){t=!1;const a=n.payload.completed.result;a.combine&&e.tryShiftRecord(a.draggableId,a.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const yM=e=>Fn(e,"DROP_COMPLETE")||Fn(e,"DROP_ANIMATE")||Fn(e,"FLUSH");var vM=e=>t=>r=>n=>{if(yM(n)){e.stop(),r(n);return}if(Fn(n,"INITIAL_PUBLISH")){r(n);const a=t.getState();a.phase!=="DRAGGING"&&Wt(),e.start(a);return}r(n),e.scroll(t.getState())};const wM=e=>t=>r=>{if(t(r),!Fn(r,"PUBLISH_WHILE_DRAGGING"))return;const n=e.getState();n.phase==="DROP_PENDING"&&(n.isWaiting||e.dispatch(Vy({reason:n.reason})))},AM=fy;var TM=({dimensionMarshal:e,focusMarshal:t,styleMarshal:r,getResponders:n,announce:a,autoScroller:l})=>hy(MR,AM(vE(KR(r),xM(e),ZR(e),nM,mM,gM,wM,vM(l),oM,bM(t),pM(n,a))));const Bp=()=>({additions:{},removals:{},modified:{}});function SM({registry:e,callbacks:t}){let r=Bp(),n=null;const a=()=>{n||(t.collectionStarting(),n=requestAnimationFrame(()=>{n=null;const{additions:p,removals:g,modified:x}=r,y=Object.keys(p).map(L=>e.draggable.getById(L).getDimension(di)).sort((L,I)=>L.descriptor.index-I.descriptor.index),A=Object.keys(x).map(L=>{const E=e.droppable.getById(L).callbacks.getScrollWhileDragging();return{droppableId:L,scroll:E}}),v={additions:y,removals:Object.keys(g),modified:A};r=Bp(),t.publish(v)}))};return{add:p=>{const g=p.descriptor.id;r.additions[g]=p,r.modified[p.descriptor.droppableId]=!0,r.removals[g]&&delete r.removals[g],a()},remove:p=>{const g=p.descriptor;r.removals[g.id]=!0,r.modified[g.droppableId]=!0,r.additions[g.id]&&delete r.additions[g.id],a()},stop:()=>{n&&(cancelAnimationFrame(n),n=null,r=Bp())}}}var Xy=({scrollHeight:e,scrollWidth:t,height:r,width:n})=>{const a=ka({x:t,y:e},{x:n,y:r});return{x:Math.max(0,a.x),y:Math.max(0,a.y)}},Jy=()=>{const e=document.documentElement;return e||Wt(),e},ev=()=>{const e=Jy();return Xy({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},CM=()=>{const e=Ky(),t=ev(),r=e.y,n=e.x,a=Jy(),l=a.clientWidth,c=a.clientHeight,h=n+l,p=r+c;return{frame:Io({top:r,left:n,right:h,bottom:p}),scroll:{initial:e,current:e,max:t,diff:{value:di,displacement:di}}}},_M=({critical:e,scrollOptions:t,registry:r})=>{const n=CM(),a=n.scroll.current,l=e.droppable,c=r.droppable.getAllByType(l.type).map(x=>x.callbacks.getDimensionAndWatchScroll(a,t)),h=r.draggable.getAllByType(e.draggable.type).map(x=>x.getDimension(a));return{dimensions:{draggables:ky(h),droppables:Ly(c)},critical:e,viewport:n}};function Bx(e,t,r){return!(r.descriptor.id===t.id||r.descriptor.type!==t.type||e.droppable.getById(r.descriptor.droppableId).descriptor.mode!=="virtual")}var LM=(e,t)=>{let r=null;const n=SM({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),a=(A,v)=>{e.droppable.exists(A)||Wt(),r&&t.updateDroppableIsEnabled({id:A,isEnabled:v})},l=(A,v)=>{r&&(e.droppable.exists(A)||Wt(),t.updateDroppableIsCombineEnabled({id:A,isCombineEnabled:v}))},c=(A,v)=>{r&&(e.droppable.exists(A)||Wt(),t.updateDroppableScroll({id:A,newScroll:v}))},h=(A,v)=>{r&&e.droppable.getById(A).callbacks.scroll(v)},p=()=>{if(!r)return;n.stop();const A=r.critical.droppable;e.droppable.getAllByType(A.type).forEach(v=>v.callbacks.dragStopped()),r.unsubscribe(),r=null},g=A=>{r||Wt();const v=r.critical.draggable;A.type==="ADDITION"&&Bx(e,v,A.value)&&n.add(A.value),A.type==="REMOVAL"&&Bx(e,v,A.value)&&n.remove(A.value)};return{updateDroppableIsEnabled:a,updateDroppableIsCombineEnabled:l,scrollDroppable:h,updateDroppableScroll:c,startPublishing:A=>{r&&Wt();const v=e.draggable.getById(A.draggableId),L=e.droppable.getById(v.descriptor.droppableId),I={draggable:v.descriptor,droppable:L.descriptor},E=e.subscribe(g);return r={critical:I,unsubscribe:E},_M({critical:I,registry:e,scrollOptions:A.scrollOptions})},stopPublishing:p}},tv=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",kM=e=>{window.scrollBy(e.x,e.y)};const IM=ui(e=>xf(e).filter(t=>!(!t.isEnabled||!t.frame))),EM=(e,t)=>IM(t).find(n=>(n.frame||Wt(),Py(n.frame.pageMarginBox)(e)))||null;var NM=({center:e,destination:t,droppables:r})=>{if(t){const a=r[t];return a.frame?a:null}return EM(e,r)};const nd={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var RM=(e,t,r=()=>nd)=>{const n=r(),a=e[t.size]*n.startFromPercentage,l=e[t.size]*n.maxScrollAtPercentage;return{startScrollingFrom:a,maxScrollValueAt:l}},rv=({startOfRange:e,endOfRange:t,current:r})=>{const n=t-e;return n===0?0:(r-e)/n},j1=1,MM=(e,t,r=()=>nd)=>{const n=r();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return n.maxPixelScroll;if(e===t.startScrollingFrom)return j1;const l=1-rv({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),c=n.maxPixelScroll*n.ease(l);return Math.ceil(c)},DM=(e,t,r)=>{const n=r(),a=n.durationDampening.accelerateAt,l=n.durationDampening.stopDampeningAt,c=t,h=l,g=Date.now()-c;if(g>=l)return e;if(g<a)return j1;const x=rv({startOfRange:a,endOfRange:h,current:g}),y=e*n.ease(x);return Math.ceil(y)},Qx=({distanceToEdge:e,thresholds:t,dragStartTime:r,shouldUseTimeDampening:n,getAutoScrollerOptions:a})=>{const l=MM(e,t,a);return l===0?0:n?Math.max(DM(l,r,a),j1):l},Px=({container:e,distanceToEdges:t,dragStartTime:r,axis:n,shouldUseTimeDampening:a,getAutoScrollerOptions:l})=>{const c=RM(e,n,l);return t[n.end]<t[n.start]?Qx({distanceToEdge:t[n.end],thresholds:c,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:l}):-1*Qx({distanceToEdge:t[n.start],thresholds:c,dragStartTime:r,shouldUseTimeDampening:a,getAutoScrollerOptions:l})},jM=({container:e,subject:t,proposedScroll:r})=>{const n=t.height>e.height,a=t.width>e.width;return!a&&!n?r:a&&n?null:{x:a?0:r.x,y:n?0:r.y}};const BM=_y(e=>e===0?0:e);var nv=({dragStartTime:e,container:t,subject:r,center:n,shouldUseTimeDampening:a,getAutoScrollerOptions:l})=>{const c={top:n.y-t.top,right:t.right-n.x,bottom:t.bottom-n.y,left:n.x-t.left},h=Px({container:t,distanceToEdges:c,dragStartTime:e,axis:L1,shouldUseTimeDampening:a,getAutoScrollerOptions:l}),p=Px({container:t,distanceToEdges:c,dragStartTime:e,axis:Ny,shouldUseTimeDampening:a,getAutoScrollerOptions:l}),g=BM({x:p,y:h});if(Yl(g,di))return null;const x=jM({container:t,subject:r,proposedScroll:g});return x?Yl(x,di)?null:x:null};const QM=_y(e=>e===0?0:e>0?1:-1),B1=(()=>{const e=(t,r)=>t<0?t:t>r?t-r:0;return({current:t,max:r,change:n})=>{const a=Ii(t,n),l={x:e(a.x,r.x),y:e(a.y,r.y)};return Yl(l,di)?null:l}})(),sv=({max:e,current:t,change:r})=>{const n={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},a=QM(r),l=B1({max:n,current:t,change:a});return!l||a.x!==0&&l.x===0||a.y!==0&&l.y===0},Q1=(e,t)=>sv({current:e.scroll.current,max:e.scroll.max,change:t}),PM=(e,t)=>{if(!Q1(e,t))return null;const r=e.scroll.max,n=e.scroll.current;return B1({current:n,max:r,change:t})},P1=(e,t)=>{const r=e.frame;return r?sv({current:r.scroll.current,max:r.scroll.max,change:t}):!1},OM=(e,t)=>{const r=e.frame;return!r||!P1(e,t)?null:B1({current:r.scroll.current,max:r.scroll.max,change:t})};var FM=({viewport:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:l})=>{const c=nv({dragStartTime:n,container:e.frame,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:l});return c&&Q1(e,c)?c:null},$M=({droppable:e,subject:t,center:r,dragStartTime:n,shouldUseTimeDampening:a,getAutoScrollerOptions:l})=>{const c=e.frame;if(!c)return null;const h=nv({dragStartTime:n,container:c.pageMarginBox,subject:t,center:r,shouldUseTimeDampening:a,getAutoScrollerOptions:l});return h&&P1(e,h)?h:null},Ox=({state:e,dragStartTime:t,shouldUseTimeDampening:r,scrollWindow:n,scrollDroppable:a,getAutoScrollerOptions:l})=>{const c=e.current.page.borderBoxCenter,p=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const y=e.viewport,A=FM({dragStartTime:t,viewport:y,subject:p,center:c,shouldUseTimeDampening:r,getAutoScrollerOptions:l});if(A){n(A);return}}const g=NM({center:c,destination:Ea(e.impact),droppables:e.dimensions.droppables});if(!g)return;const x=$M({dragStartTime:t,droppable:g,subject:p,center:c,shouldUseTimeDampening:r,getAutoScrollerOptions:l});x&&a(g.descriptor.id,x)},UM=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:r=()=>nd})=>{const n=Xu(e),a=Xu(t);let l=null;const c=g=>{l||Wt();const{shouldUseTimeDampening:x,dragStartTime:y}=l;Ox({state:g,scrollWindow:n,scrollDroppable:a,dragStartTime:y,shouldUseTimeDampening:x,getAutoScrollerOptions:r})};return{start:g=>{l&&Wt();const x=Date.now();let y=!1;const A=()=>{y=!0};Ox({state:g,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:A,scrollDroppable:A,getAutoScrollerOptions:r}),l={dragStartTime:x,shouldUseTimeDampening:y},y&&c(g)},stop:()=>{l&&(n.cancel(),a.cancel(),l=null)},scroll:c}},zM=({move:e,scrollDroppable:t,scrollWindow:r})=>{const n=(h,p)=>{const g=Ii(h.current.client.selection,p);e({client:g})},a=(h,p)=>{if(!P1(h,p))return p;const g=OM(h,p);if(!g)return t(h.descriptor.id,p),null;const x=ka(p,g);return t(h.descriptor.id,x),ka(p,x)},l=(h,p,g)=>{if(!h||!Q1(p,g))return g;const x=PM(p,g);if(!x)return r(g),null;const y=ka(g,x);return r(y),ka(g,y)};return h=>{const p=h.scrollJumpRequest;if(!p)return;const g=Ea(h.impact);g||Wt();const x=a(h.dimensions.droppables[g],p);if(!x)return;const y=h.viewport,A=l(h.isWindowScrollAllowed,y,x);A&&n(h,A)}},HM=({scrollDroppable:e,scrollWindow:t,move:r,getAutoScrollerOptions:n})=>{const a=UM({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:n}),l=zM({move:r,scrollWindow:t,scrollDroppable:e});return{scroll:p=>{if(!(n().disabled||p.phase!=="DRAGGING")){if(p.movementMode==="FLUID"){a.scroll(p);return}p.scrollJumpRequest&&l(p)}},start:a.start,stop:a.stop}};const v0="data-rfd",w0=(()=>{const e=`${v0}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),$m=(()=>{const e=`${v0}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),WM=(()=>{const e=`${v0}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Fx={contextId:`${v0}-scroll-container-context-id`},GM=e=>t=>`[${t}="${e}"]`,ou=(e,t)=>e.map(r=>{const n=r.styles[t];return n?`${r.selector} { ${n} }`:""}).join(" "),VM="pointer-events: none;";var qM=e=>{const t=GM(e),r=(()=>{const h=`
111
+ cursor: -webkit-grab;
112
+ cursor: grab;
113
+ `;return{selector:t(w0.contextId),styles:{always:`
114
+ -webkit-touch-callout: none;
115
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
116
+ touch-action: manipulation;
117
+ `,resting:h,dragging:VM,dropAnimating:h}}})(),n=(()=>{const h=`
118
+ transition: ${Qu.outOfTheWay};
119
+ `;return{selector:t($m.contextId),styles:{dragging:h,dropAnimating:h,userCancel:h}}})(),a={selector:t(WM.contextId),styles:{always:"overflow-anchor: none;"}},c=[n,r,a,{selector:"body",styles:{dragging:`
120
+ cursor: grabbing;
121
+ cursor: -webkit-grabbing;
122
+ user-select: none;
123
+ -webkit-user-select: none;
124
+ -moz-user-select: none;
125
+ -ms-user-select: none;
126
+ overflow-anchor: none;
127
+ `}}];return{always:ou(c,"always"),resting:ou(c,"resting"),dragging:ou(c,"dragging"),dropAnimating:ou(c,"dropAnimating"),userCancel:ou(c,"userCancel")}};const Na=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,Qp=()=>{const e=document.querySelector("head");return e||Wt(),e},$x=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function YM(e,t){const r=Tn(()=>qM(e),[e]),n=b.useRef(null),a=b.useRef(null),l=kr(ui(y=>{const A=a.current;A||Wt(),A.textContent=y}),[]),c=kr(y=>{const A=n.current;A||Wt(),A.textContent=y},[]);Na(()=>{!n.current&&!a.current||Wt();const y=$x(t),A=$x(t);return n.current=y,a.current=A,y.setAttribute(`${v0}-always`,e),A.setAttribute(`${v0}-dynamic`,e),Qp().appendChild(y),Qp().appendChild(A),c(r.always),l(r.resting),()=>{const v=L=>{const I=L.current;I||Wt(),Qp().removeChild(I),L.current=null};v(n),v(a)}},[t,c,l,r.always,r.resting,e]);const h=kr(()=>l(r.dragging),[l,r.dragging]),p=kr(y=>{if(y==="DROP"){l(r.dropAnimating);return}l(r.userCancel)},[l,r.dropAnimating,r.userCancel]),g=kr(()=>{a.current&&l(r.resting)},[l,r.resting]);return Tn(()=>({dragging:h,dropping:p,resting:g}),[h,p,g])}function iv(e,t){return Array.from(e.querySelectorAll(t))}var av=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function wf(e){return e instanceof av(e).HTMLElement}function ZM(e,t){const r=`[${w0.contextId}="${e}"]`,n=iv(document,r);if(!n.length)return null;const a=n.find(l=>l.getAttribute(w0.draggableId)===t);return!a||!wf(a)?null:a}function KM(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),l=kr(function(A,v){const L={id:A,focus:v};return t.current[A]=L,function(){const E=t.current;E[A]!==L&&delete E[A]}},[]),c=kr(function(A){const v=ZM(e,A);v&&v!==document.activeElement&&v.focus()},[e]),h=kr(function(A,v){r.current===A&&(r.current=v)},[]),p=kr(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const A=r.current;A&&c(A)}))},[c]),g=kr(function(A){r.current=null;const v=document.activeElement;v&&v.getAttribute(w0.draggableId)===A&&(r.current=A)},[]);return Na(()=>(a.current=!0,function(){a.current=!1;const A=n.current;A&&cancelAnimationFrame(A)}),[]),Tn(()=>({register:l,tryRecordFocus:g,tryRestoreFocusRecorded:p,tryShiftRecord:h}),[l,g,p,h])}function XM(){const e={draggables:{},droppables:{}},t=[];function r(y){return t.push(y),function(){const v=t.indexOf(y);v!==-1&&t.splice(v,1)}}function n(y){t.length&&t.forEach(A=>A(y))}function a(y){return e.draggables[y]||null}function l(y){const A=a(y);return A||Wt(),A}const c={register:y=>{e.draggables[y.descriptor.id]=y,n({type:"ADDITION",value:y})},update:(y,A)=>{const v=e.draggables[A.descriptor.id];v&&v.uniqueId===y.uniqueId&&(delete e.draggables[A.descriptor.id],e.draggables[y.descriptor.id]=y)},unregister:y=>{const A=y.descriptor.id,v=a(A);v&&y.uniqueId===v.uniqueId&&(delete e.draggables[A],e.droppables[y.descriptor.droppableId]&&n({type:"REMOVAL",value:y}))},getById:l,findById:a,exists:y=>!!a(y),getAllByType:y=>Object.values(e.draggables).filter(A=>A.descriptor.type===y)};function h(y){return e.droppables[y]||null}function p(y){const A=h(y);return A||Wt(),A}const g={register:y=>{e.droppables[y.descriptor.id]=y},unregister:y=>{const A=h(y.descriptor.id);A&&y.uniqueId===A.uniqueId&&delete e.droppables[y.descriptor.id]},getById:p,findById:h,exists:y=>!!h(y),getAllByType:y=>Object.values(e.droppables).filter(A=>A.descriptor.type===y)};function x(){e.draggables={},e.droppables={},t.length=0}return{draggable:c,droppable:g,subscribe:r,clean:x}}function JM(){const e=Tn(XM,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var O1=S.createContext(null),nf=()=>{const e=document.body;return e||Wt(),e};const eD={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},tD=e=>`rfd-announcement-${e}`;function rD(e){const t=Tn(()=>tD(e),[e]),r=b.useRef(null);return b.useEffect(function(){const l=document.createElement("div");return r.current=l,l.id=t,l.setAttribute("aria-live","assertive"),l.setAttribute("aria-atomic","true"),Jh(l.style,eD),nf().appendChild(l),function(){setTimeout(function(){const p=nf();p.contains(l)&&p.removeChild(l),l===r.current&&(r.current=null)})}},[t]),kr(a=>{const l=r.current;if(l){l.textContent=a;return}},[])}const nD={separator:"::"};function F1(e,t=nD){const r=S.useId();return Tn(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function sD({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function iD({contextId:e,text:t}){const r=F1("hidden-text",{separator:"-"}),n=Tn(()=>sD({contextId:e,uniqueId:r}),[r,e]);return b.useEffect(function(){const l=document.createElement("div");return l.id=n,l.textContent=t,l.style.display="none",nf().appendChild(l),function(){const h=nf();h.contains(l)&&h.removeChild(l)}},[n,t]),n}var Af=S.createContext(null);function ov(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function aD(){let e=null;function t(){return!!e}function r(c){return c===e}function n(c){e&&Wt();const h={abandon:c};return e=h,h}function a(){e||Wt(),e=null}function l(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:l}}function sd(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const oD=9,lD=13,$1=27,lv=32,cD=33,uD=34,dD=35,hD=36,fD=37,pD=38,mD=39,gD=40,xD={[lD]:!0,[oD]:!0};var cv=e=>{xD[e.keyCode]&&e.preventDefault()};const Tf=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),uv=0,Ux=5;function bD(e,t){return Math.abs(t.x-e.x)>=Ux||Math.abs(t.y-e.y)>=Ux}const zx={type:"IDLE"};function yD({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:l,clientX:c,clientY:h}=a;if(l!==uv)return;const p={x:c,y:h},g=r();if(g.type==="DRAGGING"){a.preventDefault(),g.actions.move(p);return}g.type!=="PENDING"&&Wt();const x=g.point;if(!bD(x,p))return;a.preventDefault();const y=g.actions.fluidLift(p);n({type:"DRAGGING",actions:y})}},{eventName:"mouseup",fn:a=>{const l=r();if(l.type!=="DRAGGING"){e();return}a.preventDefault(),l.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:a=>{r().type==="DRAGGING"&&a.preventDefault(),e()}},{eventName:"keydown",fn:a=>{if(r().type==="PENDING"){e();return}if(a.keyCode===$1){a.preventDefault(),e();return}cv(a)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{r().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:a=>{const l=r();if(l.type==="IDLE"&&Wt(),l.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:Tf,fn:e}]}function vD(e){const t=b.useRef(zx),r=b.useRef(ql),n=Tn(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==uv||y.ctrlKey||y.metaKey||y.shiftKey||y.altKey)return;const A=e.findClosestDraggableId(y);if(!A)return;const v=e.tryGetLock(A,c,{sourceEvent:y});if(!v)return;y.preventDefault();const L={x:y.clientX,y:y.clientY};r.current(),g(v,L)}}),[e]),a=Tn(()=>({eventName:"webkitmouseforcewillbegin",fn:x=>{if(x.defaultPrevented)return;const y=e.findClosestDraggableId(x);if(!y)return;const A=e.findOptionsForDraggable(y);A&&(A.shouldRespectForcePress||e.canGetLock(y)&&x.preventDefault())}}),[e]),l=kr(function(){const y={passive:!1,capture:!0};r.current=oo(window,[a,n],y)},[a,n]),c=kr(()=>{t.current.type!=="IDLE"&&(t.current=zx,r.current(),l())},[l]),h=kr(()=>{const x=t.current;c(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[c]),p=kr(function(){const y={capture:!0,passive:!1},A=yD({cancel:h,completed:c,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=oo(window,A,y)},[h,c]),g=kr(function(y,A){t.current.type!=="IDLE"&&Wt(),t.current={type:"PENDING",point:A,actions:y},p()},[p]);Na(function(){return l(),function(){r.current()}},[l])}function wD(){}const AD={[uD]:!0,[cD]:!0,[hD]:!0,[dD]:!0};function TD(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===$1){a.preventDefault(),r();return}if(a.keyCode===lv){a.preventDefault(),n();return}if(a.keyCode===gD){a.preventDefault(),e.moveDown();return}if(a.keyCode===pD){a.preventDefault(),e.moveUp();return}if(a.keyCode===mD){a.preventDefault(),e.moveRight();return}if(a.keyCode===fD){a.preventDefault(),e.moveLeft();return}if(AD[a.keyCode]){a.preventDefault();return}cv(a)}},{eventName:"mousedown",fn:r},{eventName:"mouseup",fn:r},{eventName:"click",fn:r},{eventName:"touchstart",fn:r},{eventName:"resize",fn:r},{eventName:"wheel",fn:r,options:{passive:!0}},{eventName:Tf,fn:r}]}function SD(e){const t=b.useRef(wD),r=Tn(()=>({eventName:"keydown",fn:function(l){if(l.defaultPrevented||l.keyCode!==lv)return;const c=e.findClosestDraggableId(l);if(!c)return;const h=e.tryGetLock(c,x,{sourceEvent:l});if(!h)return;l.preventDefault();let p=!0;const g=h.snapLift();t.current();function x(){p||Wt(),p=!1,t.current(),n()}t.current=oo(window,TD(g,x),{capture:!0,passive:!1})}}),[e]),n=kr(function(){const l={passive:!1,capture:!0};t.current=oo(window,[r],l)},[r]);Na(function(){return n(),function(){t.current()}},[n])}const Pp={type:"IDLE"},CD=120,_D=.15;function LD({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:r=>{r.preventDefault()}},{eventName:"keydown",fn:r=>{if(t().type!=="DRAGGING"){e();return}r.keyCode===$1&&r.preventDefault(),e()}},{eventName:Tf,fn:e}]}function kD({cancel:e,completed:t,getPhase:r}){return[{eventName:"touchmove",options:{capture:!1},fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}a.hasMoved=!0;const{clientX:l,clientY:c}=n.touches[0],h={x:l,y:c};n.preventDefault(),a.actions.move(h)}},{eventName:"touchend",fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}n.preventDefault(),a.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:n=>{if(r().type!=="DRAGGING"){e();return}n.preventDefault(),e()}},{eventName:"touchforcechange",fn:n=>{const a=r();a.type==="IDLE"&&Wt();const l=n.touches[0];if(!l||!(l.force>=_D))return;const h=a.actions.shouldRespectForcePress();if(a.type==="PENDING"){h&&e();return}if(h){if(a.hasMoved){n.preventDefault();return}e();return}n.preventDefault()}},{eventName:Tf,fn:e}]}function ID(e){const t=b.useRef(Pp),r=b.useRef(ql),n=kr(function(){return t.current},[]),a=kr(function(v){t.current=v},[]),l=Tn(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const L=e.findClosestDraggableId(v);if(!L)return;const I=e.tryGetLock(L,h,{sourceEvent:v});if(!I)return;const E=v.touches[0],{clientX:R,clientY:P}=E,Q={x:R,y:P};r.current(),y(I,Q)}}),[e]),c=kr(function(){const v={capture:!0,passive:!1};r.current=oo(window,[l],v)},[l]),h=kr(()=>{const A=t.current;A.type!=="IDLE"&&(A.type==="PENDING"&&clearTimeout(A.longPressTimerId),a(Pp),r.current(),c())},[c,a]),p=kr(()=>{const A=t.current;h(),A.type==="DRAGGING"&&A.actions.cancel({shouldBlockNextClick:!0}),A.type==="PENDING"&&A.actions.abort()},[h]),g=kr(function(){const v={capture:!0,passive:!1},L={cancel:p,completed:h,getPhase:n},I=oo(window,kD(L),v),E=oo(window,LD(L),v);r.current=function(){I(),E()}},[p,n,h]),x=kr(function(){const v=n();v.type!=="PENDING"&&Wt();const L=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:L,hasMoved:!1})},[n,a]),y=kr(function(v,L){n().type!=="IDLE"&&Wt();const I=setTimeout(x,CD);a({type:"PENDING",point:L,actions:v,longPressTimerId:I}),g()},[g,n,a,x]);Na(function(){return c(),function(){r.current();const L=n();L.type==="PENDING"&&(clearTimeout(L.longPressTimerId),a(Pp))}},[n,c,a]),Na(function(){return oo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const ED=["input","button","textarea","select","option","optgroup","video","audio"];function dv(e,t){if(t==null)return!1;if(ED.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:dv(e,t.parentElement)}function ND(e,t){const r=t.target;return wf(r)?dv(e,r):!1}var RD=e=>Io(e.getBoundingClientRect()).center;function MD(e){return e instanceof av(e).Element}const DD=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function hv(e,t){return e==null?null:e[DD](t)?e:hv(e.parentElement,t)}function jD(e,t){return e.closest?e.closest(t):hv(e,t)}function BD(e){return`[${w0.contextId}="${e}"]`}function QD(e,t){const r=t.target;if(!MD(r))return null;const n=BD(e),a=jD(r,n);return!a||!wf(a)?null:a}function PD(e,t){const r=QD(e,t);return r?r.getAttribute(w0.draggableId):null}function OD(e,t){const r=`[${$m.contextId}="${e}"]`,a=iv(document,r).find(l=>l.getAttribute($m.id)===t);return!a||!wf(a)?null:a}function FD(e){e.preventDefault()}function nh({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function fv({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!tv(t.getState(),n))}function $D({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:l,sourceEvent:c}){if(!fv({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const p=n.draggable.getById(a),g=OD(t,p.descriptor.id);if(!g||c&&!p.options.canDragInteractiveElements&&ND(g,c))return null;const x=e.claim(l||ql);let y="PRE_DRAG";function A(){return p.options.shouldRespectForcePress}function v(){return e.isActive(x)}function L(W,B){nh({expected:W,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(B())}const I=L.bind(null,"DRAGGING");function E(W){function B(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(B(),Wt()),r.dispatch(jR(W.liftActionArgs)),y="DRAGGING";function q(ne,Be={shouldBlockNextClick:!1}){if(W.cleanup(),Be.shouldBlockNextClick){const fe=oo(window,[{eventName:"click",fn:FD,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(fe)}B(),r.dispatch(Vy({reason:ne}))}return{isActive:()=>nh({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:A,drop:ne=>q("DROP",ne),cancel:ne=>q("CANCEL",ne),...W.actions}}function R(W){const B=Xu(ne=>{I(()=>Gy({client:ne}))});return{...E({liftActionArgs:{id:a,clientSelection:W,movementMode:"FLUID"},cleanup:()=>B.cancel(),actions:{move:B}}),move:B}}function P(){const W={moveUp:()=>I(HR),moveRight:()=>I(GR),moveDown:()=>I(WR),moveLeft:()=>I(VR)};return E({liftActionArgs:{id:a,clientSelection:RD(g),movementMode:"SNAP"},cleanup:ql,actions:W})}function Q(){nh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>nh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:A,fluidLift:R,snapLift:P,abort:Q}}const UD=[vD,SD,ID];function zD({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const l=[...a?UD:[],...n||[]],c=b.useState(()=>aD())[0],h=kr(function(E,R){sd(E)&&!sd(R)&&c.tryAbandon()},[c]);Na(function(){let E=t.getState();return t.subscribe(()=>{const P=t.getState();h(E,P),E=P})},[c,t,h]),Na(()=>c.tryAbandon,[c.tryAbandon]);const p=kr(I=>fv({lockAPI:c,registry:r,store:t,draggableId:I}),[c,r,t]),g=kr((I,E,R)=>$D({lockAPI:c,registry:r,contextId:e,store:t,draggableId:I,forceSensorStop:E||null,sourceEvent:R&&R.sourceEvent?R.sourceEvent:null}),[e,c,r,t]),x=kr(I=>PD(e,I),[e]),y=kr(I=>{const E=r.draggable.findById(I);return E?E.options:null},[r.draggable]),A=kr(function(){c.isClaimed()&&(c.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(R1()))},[c,t]),v=kr(()=>c.isClaimed(),[c]),L=Tn(()=>({canGetLock:p,tryGetLock:g,findClosestDraggableId:x,findOptionsForDraggable:y,tryReleaseLock:A,isLockClaimed:v}),[p,g,x,y,A,v]);for(let I=0;I<l.length;I++)l[I](L)}const HD=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};ki.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),WD=e=>({...nd,...e.autoScrollerOptions,durationDampening:{...nd.durationDampening,...e.autoScrollerOptions}});function lu(e){return e.current||Wt(),e.current}function GD(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:l}=e,c=b.useRef(null),h=ov(e),p=kr(()=>HD(h.current),[h]),g=kr(()=>WD(h.current),[h]),x=rD(t),y=iD({contextId:t,text:l}),A=YM(t,a),v=kr(fe=>{lu(c).dispatch(fe)},[]),L=Tn(()=>mx({publishWhileDragging:QR,updateDroppableScroll:OR,updateDroppableIsEnabled:FR,updateDroppableIsCombineEnabled:$R,collectionStarting:PR},v),[v]),I=JM(),E=Tn(()=>LM(I,L),[I,L]),R=Tn(()=>HM({scrollWindow:kM,scrollDroppable:E.scrollDroppable,getAutoScrollerOptions:g,...mx({move:Gy},v)}),[E.scrollDroppable,v,g]),P=KM(t),Q=Tn(()=>TM({announce:x,autoScroller:R,dimensionMarshal:E,focusMarshal:P,getResponders:p,styleMarshal:A}),[x,R,E,P,p,A]);c.current=Q;const $=kr(()=>{const fe=lu(c);fe.getState().phase!=="IDLE"&&fe.dispatch(R1())},[]),W=kr(()=>{const fe=lu(c).getState();return fe.phase==="DROP_ANIMATING"?!0:fe.phase==="IDLE"?!1:fe.isDragging},[]),B=Tn(()=>({isDragging:W,tryAbort:$}),[W,$]);r(B);const q=kr(fe=>tv(lu(c).getState(),fe),[]),ne=kr(()=>xc(lu(c).getState()),[]),Be=Tn(()=>({marshal:E,focus:P,contextId:t,canLift:q,isMovementAllowed:ne,dragHandleUsageInstructionsId:y,registry:I}),[t,E,y,P,q,ne,I]);return zD({contextId:t,store:Q,registry:I,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>$,[$]),S.createElement(Af.Provider,{value:Be},S.createElement(xN,{context:O1,store:Q},e.children))}function VD(){return S.useId()}function Pu(e){const t=VD(),r=e.dragHandleUsageInstructions||Ih.dragHandleUsageInstructions;return S.createElement(SN,null,n=>S.createElement(GD,{nonce:e.nonce,contextId:t,setCallbacks:n,dragHandleUsageInstructions:r,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const Hx={dragging:5e3,dropAnimating:4500},qD=(e,t)=>t?Qu.drop(t.duration):e?Qu.snap:Qu.fluid,YD=(e,t)=>{if(e)return t?rd.opacity.drop:rd.opacity.combining},ZD=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function KD(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:l}=e,c=!!a,h=ZD(e),p=!!l,g=p?Om.drop(n,c):Om.moveTo(n);return{position:"fixed",top:r.marginBox.top,left:r.marginBox.left,boxSizing:"border-box",width:r.borderBox.width,height:r.borderBox.height,transition:qD(h,l),transform:g,opacity:YD(c,p),zIndex:p?Hx.dropAnimating:Hx.dragging,pointerEvents:"none"}}function XD(e){return{transform:Om.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function JD(e){return e.type==="DRAGGING"?KD(e):XD(e)}function ej(e,t,r=di){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),l=vy(a,n),c=Xh(l,r),h={client:l,tagName:t.tagName.toLowerCase(),display:n.display},p={x:l.marginBox.width,y:l.marginBox.height};return{descriptor:e,placeholder:h,displaceBy:p,client:l,page:c}}function tj(e){const t=F1("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:l,shouldRespectForcePress:c,isEnabled:h}=e,p=Tn(()=>({canDragInteractiveElements:l,shouldRespectForcePress:c,isEnabled:h}),[l,h,c]),g=kr(v=>{const L=a();return L||Wt(),ej(r,L,v)},[r,a]),x=Tn(()=>({uniqueId:t,descriptor:r,options:p,getDimension:g}),[r,g,p,t]),y=b.useRef(x),A=b.useRef(!0);Na(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),Na(()=>{if(A.current){A.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var U1=S.createContext(null);function sf(e){const t=b.useContext(e);return t||Wt(),t}function rj(e){e.preventDefault()}const nj=e=>{const t=b.useRef(null),r=kr((B=null)=>{t.current=B},[]),n=kr(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:l,registry:c}=sf(Af),{type:h,droppableId:p}=sf(U1),g=Tn(()=>({id:e.draggableId,index:e.index,type:h,droppableId:p}),[e.draggableId,e.index,h,p]),{children:x,draggableId:y,isEnabled:A,shouldRespectForcePress:v,canDragInteractiveElements:L,isClone:I,mapped:E,dropAnimationFinished:R}=e;if(!I){const B=Tn(()=>({descriptor:g,registry:c,getDraggableRef:n,canDragInteractiveElements:L,shouldRespectForcePress:v,isEnabled:A}),[g,c,n,L,v,A]);tj(B)}const P=Tn(()=>A?{tabIndex:0,role:"button","aria-describedby":l,"data-rfd-drag-handle-draggable-id":y,"data-rfd-drag-handle-context-id":a,draggable:!1,onDragStart:rj}:null,[a,l,y,A]),Q=kr(B=>{E.type==="DRAGGING"&&E.dropping&&B.propertyName==="transform"&&ki.flushSync(R)},[R,E]),$=Tn(()=>{const B=JD(E),q=E.type==="DRAGGING"&&E.dropping?Q:void 0;return{innerRef:r,draggableProps:{"data-rfd-draggable-context-id":a,"data-rfd-draggable-id":y,style:B,onTransitionEnd:q},dragHandleProps:P}},[a,P,y,E,Q,r]),W=Tn(()=>({draggableId:g.id,type:g.type,source:{index:g.index,droppableId:g.droppableId}}),[g.droppableId,g.id,g.index,g.type]);return S.createElement(S.Fragment,null,x($,E.snapshot,W))};var pv=(e,t)=>e===t,mv=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const sj=e=>e.combine?e.combine.draggableId:null,ij=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function aj(){const e=ui((a,l)=>({x:a,y:l})),t=ui((a,l,c=null,h=null,p=null)=>({isDragging:!0,isClone:l,isDropAnimating:!!p,dropAnimation:p,mode:a,draggingOver:c,combineWith:h,combineTargetFor:null})),r=ui((a,l,c,h,p=null,g=null,x=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:p,combineWith:g,mode:l,offset:a,dimension:c,forceShouldAnimate:x,snapshot:t(l,h,p,g,null)}}));return(a,l)=>{if(sd(a)){if(a.critical.draggable.id!==l.draggableId)return null;const c=a.current.client.offset,h=a.dimensions.draggables[l.draggableId],p=Ea(a.impact),g=ij(a.impact),x=a.forceShouldAnimate;return r(e(c.x,c.y),a.movementMode,h,l.isClone,p,g,x)}if(a.phase==="DROP_ANIMATING"){const c=a.completed;if(c.result.draggableId!==l.draggableId)return null;const h=l.isClone,p=a.dimensions.draggables[l.draggableId],g=c.result,x=g.mode,y=mv(g),A=sj(g),L={duration:a.dropDuration,curve:D1.drop,moveTo:a.newHomeClientOffset,opacity:A?rd.opacity.drop:null,scale:A?rd.scale.drop:null};return{mapped:{type:"DRAGGING",offset:a.newHomeClientOffset,dimension:p,dropping:L,draggingOver:y,combineWith:A,mode:x,forceShouldAnimate:null,snapshot:t(x,h,y,A,L)}}}return null}}function gv(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const oj={mapped:{type:"SECONDARY",offset:di,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:gv(null)}};function lj(){const e=ui((c,h)=>({x:c,y:h})),t=ui(gv),r=ui((c,h=null,p)=>({mapped:{type:"SECONDARY",offset:c,combineTargetFor:h,shouldAnimateDisplacement:p,snapshot:t(h)}})),n=c=>c?r(di,c,!0):null,a=(c,h,p,g)=>{const x=p.displaced.visible[c],y=!!(g.inVirtualList&&g.effected[c]),A=bf(p),v=A&&A.draggableId===c?h:null;if(!x){if(!y)return n(v);if(p.displaced.invisible[c])return null;const E=L0(g.displacedBy.point),R=e(E.x,E.y);return r(R,v,!0)}if(y)return n(v);const L=p.displacedBy.point,I=e(L.x,L.y);return r(I,v,x.shouldAnimate)};return(c,h)=>{if(sd(c))return c.critical.draggable.id===h.draggableId?null:a(h.draggableId,c.critical.draggable.id,c.impact,c.afterCritical);if(c.phase==="DROP_ANIMATING"){const p=c.completed;return p.result.draggableId===h.draggableId?null:a(h.draggableId,p.result.draggableId,p.impact,p.afterCritical)}return null}}const cj=()=>{const e=aj(),t=lj();return(n,a)=>e(n,a)||t(n,a)||oj},uj={dropAnimationFinished:qy},dj=yy(cj,uj,null,{context:O1,areStatePropsEqual:pv})(nj);function xv(e){return sf(U1).isUsingCloneFor===e.draggableId&&!e.isClone?null:S.createElement(dj,e)}function Al(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return S.createElement(xv,Jh({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const bv=e=>t=>e===t,hj=bv("scroll"),fj=bv("auto"),Wx=(e,t)=>t(e.overflowX)||t(e.overflowY),pj=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return Wx(r,hj)||Wx(r,fj)},mj=()=>!1,yv=e=>e==null?null:e===document.body?mj()?e:null:e===document.documentElement?null:pj(e)?e:yv(e.parentElement);var Um=e=>({x:e.scrollLeft,y:e.scrollTop});const vv=e=>e?window.getComputedStyle(e).position==="fixed"?!0:vv(e.parentElement):!1;var gj=e=>{const t=yv(e),r=vv(e);return{closestScrollable:t,isFixedOnPage:r}},xj=({descriptor:e,isEnabled:t,isCombineEnabled:r,isFixedOnPage:n,direction:a,client:l,page:c,closest:h})=>{const p=(()=>{if(!h)return null;const{scrollSize:A,client:v}=h,L=Xy({scrollHeight:A.scrollHeight,scrollWidth:A.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:h.page.marginBox,frameClient:v,scrollSize:A,shouldClipSubject:h.shouldClipSubject,scroll:{initial:h.scroll,current:h.scroll,max:L,diff:{value:di,displacement:di}}}})(),g=a==="vertical"?L1:Ny,x=y0({page:c,withPlaceholder:null,axis:g,frame:p});return{descriptor:e,isCombineEnabled:r,isFixedOnPage:n,axis:g,isEnabled:t,client:l,page:c,frame:p,subject:x}};const bj=(e,t)=>{const r=wy(e);if(!t||e!==t)return r;const n=r.paddingBox.top-t.scrollTop,a=r.paddingBox.left-t.scrollLeft,l=n+t.scrollHeight,c=a+t.scrollWidth,p=T1({top:n,right:c,bottom:l,left:a},r.border);return S1({borderBox:p,margin:r.margin,border:r.border,padding:r.padding})};var yj=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:l,isCombineEnabled:c,shouldClipSubject:h})=>{const p=r.closestScrollable,g=bj(e,p),x=Xh(g,n),y=(()=>{if(!p)return null;const v=wy(p),L={scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth};return{client:v,page:Xh(v,n),scroll:Um(p),scrollSize:L,shouldClipSubject:h}})();return xj({descriptor:t,isEnabled:!l,isCombineEnabled:c,isFixedOnPage:r.isFixedOnPage,direction:a,client:g,page:x,closest:y})};const vj={passive:!1},wj={passive:!0};var Gx=e=>e.shouldPublishImmediately?vj:wj;const sh=e=>e&&e.env.closestScrollable||null;function Aj(e){const t=b.useRef(null),r=sf(Af),n=F1("droppable"),{registry:a,marshal:l}=r,c=ov(e),h=Tn(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),p=b.useRef(h),g=Tn(()=>ui(($,W)=>{t.current||Wt();const B={x:$,y:W};l.updateDroppableScroll(h.id,B)}),[h.id,l]),x=kr(()=>{const $=t.current;return!$||!$.env.closestScrollable?di:Um($.env.closestScrollable)},[]),y=kr(()=>{const $=x();g($.x,$.y)},[x,g]),A=Tn(()=>Xu(y),[y]),v=kr(()=>{const $=t.current,W=sh($);if($&&W||Wt(),$.scrollOptions.shouldPublishImmediately){y();return}A()},[A,y]),L=kr(($,W)=>{t.current&&Wt();const B=c.current,q=B.getDroppableRef();q||Wt();const ne=gj(q),Be={ref:q,descriptor:h,env:ne,scrollOptions:W};t.current=Be;const fe=yj({ref:q,descriptor:h,env:ne,windowScroll:$,direction:B.direction,isDropDisabled:B.isDropDisabled,isCombineEnabled:B.isCombineEnabled,shouldClipSubject:!B.ignoreContainerClipping}),X=ne.closestScrollable;return X&&(X.setAttribute(Fx.contextId,r.contextId),X.addEventListener("scroll",v,Gx(Be.scrollOptions))),fe},[r.contextId,h,v,c]),I=kr(()=>{const $=t.current,W=sh($);return $&&W||Wt(),Um(W)},[]),E=kr(()=>{const $=t.current;$||Wt();const W=sh($);t.current=null,W&&(A.cancel(),W.removeAttribute(Fx.contextId),W.removeEventListener("scroll",v,Gx($.scrollOptions)))},[v,A]),R=kr($=>{const W=t.current;W||Wt();const B=sh(W);B||Wt(),B.scrollTop+=$.y,B.scrollLeft+=$.x},[]),P=Tn(()=>({getDimensionAndWatchScroll:L,getScrollWhileDragging:I,dragStopped:E,scroll:R}),[E,L,I,R]),Q=Tn(()=>({uniqueId:n,descriptor:h,callbacks:P}),[P,h,n]);Na(()=>(p.current=Q.descriptor,a.droppable.register(Q),()=>{t.current&&E(),a.droppable.unregister(Q)}),[P,h,E,Q,l,a.droppable]),Na(()=>{t.current&&l.updateDroppableIsEnabled(p.current.id,!e.isDropDisabled)},[e.isDropDisabled,l]),Na(()=>{t.current&&l.updateDroppableIsCombineEnabled(p.current.id,e.isCombineEnabled)},[e.isCombineEnabled,l])}function Op(){}const Vx={width:0,height:0,margin:NN},Tj=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?Vx:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},Sj=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=Tj({isAnimatingOpenOnMount:e,placeholder:t,animate:r});return{display:t.display,boxSizing:"border-box",width:n.width,height:n.height,marginTop:n.margin.top,marginRight:n.margin.right,marginBottom:n.margin.bottom,marginLeft:n.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:r!=="none"?Qu.placeholder:null}},Cj=e=>{const t=b.useRef(null),r=kr(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:n,onTransitionEnd:a,onClose:l,contextId:c}=e,[h,p]=b.useState(e.animate==="open");b.useEffect(()=>h?n!=="open"?(r(),p(!1),Op):t.current?Op:(t.current=setTimeout(()=>{t.current=null,p(!1)}),r):Op,[n,h,r]);const g=kr(y=>{y.propertyName==="height"&&(a(),n==="close"&&l())},[n,l,a]),x=Sj({isAnimatingOpenOnMount:h,animate:e.animate,placeholder:e.placeholder});return S.createElement(e.placeholder.tagName,{style:x,"data-rfd-placeholder-context-id":c,onTransitionEnd:g,ref:e.innerRef})};var _j=S.memo(Cj);class Lj extends S.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,r){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:r.isVisible?{isVisible:!0,data:r.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const kj=e=>{const t=b.useContext(Af);t||Wt();const{contextId:r,isMovementAllowed:n}=t,a=b.useRef(null),l=b.useRef(null),{children:c,droppableId:h,type:p,mode:g,direction:x,ignoreContainerClipping:y,isDropDisabled:A,isCombineEnabled:v,snapshot:L,useClone:I,updateViewportMaxScroll:E,getContainerForClone:R}=e,P=kr(()=>a.current,[]),Q=kr((X=null)=>{a.current=X},[]);kr(()=>l.current,[]);const $=kr((X=null)=>{l.current=X},[]),W=kr(()=>{n()&&E({maxScroll:ev()})},[n,E]);Aj({droppableId:h,type:p,mode:g,direction:x,isDropDisabled:A,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:P});const B=Tn(()=>S.createElement(Lj,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:X,data:Qe,animate:Pe})=>S.createElement(_j,{placeholder:Qe,onClose:X,innerRef:$,animate:Pe,contextId:r,onTransitionEnd:W})),[r,W,e.placeholder,e.shouldAnimatePlaceholder,$]),q=Tn(()=>({innerRef:Q,placeholder:B,droppableProps:{"data-rfd-droppable-id":h,"data-rfd-droppable-context-id":r}}),[r,h,B,Q]),ne=I?I.dragging.draggableId:null,Be=Tn(()=>({droppableId:h,type:p,isUsingCloneFor:ne}),[h,ne,p]);function fe(){if(!I)return null;const{dragging:X,render:Qe}=I,Pe=S.createElement(xv,{draggableId:X.draggableId,index:X.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(ue,Ce)=>Qe(ue,Ce,X));return g9.createPortal(Pe,R())}return S.createElement(U1.Provider,{value:Be},c(q,L),fe())};function Ij(){return document.body||Wt(),document.body}const qx={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:Ij},wv=e=>{let t={...e},r;for(r in qx)e[r]===void 0&&(t={...t,[r]:qx[r]});return t},Fp=(e,t)=>e===t.droppable.type,Yx=(e,t)=>t.draggables[e.draggable.id],Ej=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=ui(l=>({draggableId:l.id,type:l.type,source:{index:l.index,droppableId:l.droppableId}})),n=ui((l,c,h,p,g,x)=>{const y=g.descriptor.id;if(g.descriptor.droppableId===l){const L=x?{render:x,dragging:r(g.descriptor)}:null,I={isDraggingOver:h,draggingOverWith:h?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:g.placeholder,shouldAnimatePlaceholder:!1,snapshot:I,useClone:L}}if(!c)return t;if(!p)return e;const v={isDraggingOver:h,draggingOverWith:y,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:g.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(l,c)=>{const h=wv(c),p=h.droppableId,g=h.type,x=!h.isDropDisabled,y=h.renderClone;if(sd(l)){const A=l.critical;if(!Fp(g,A))return t;const v=Yx(A,l.dimensions),L=Ea(l.impact)===p;return n(p,x,L,L,v,y)}if(l.phase==="DROP_ANIMATING"){const A=l.completed;if(!Fp(g,A.critical))return t;const v=Yx(A.critical,l.dimensions);return n(p,x,mv(A.result)===p,Ea(A.impact)===p,v,y)}if(l.phase==="IDLE"&&l.completed&&!l.shouldFlush){const A=l.completed;if(!Fp(g,A.critical))return t;const v=Ea(A.impact)===p,L=!!(A.impact.at&&A.impact.at.type==="COMBINE"),I=A.critical.droppable.id===p;return v?L?e:t:I?e:t}return t}},Nj={updateViewportMaxScroll:zR},Tl=yy(Ej,Nj,(e,t,r)=>({...wv(r),...e,...t}),{context:O1,areStatePropsEqual:pv})(kj);function Rj(){if(typeof window>"u")return d0(void 0);try{const e=window.localStorage.getItem(Lm);return d0(e?JSON.parse(e):void 0)}catch{return d0(void 0)}}function $p(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(Lm),r=t?JSON.parse(t):{},n=d0({...r,...e});window.localStorage.setItem(Lm,JSON.stringify(n))}catch{}}function Mj(){const[e,t]=S.useState(Rj);S.useEffect(()=>{$p(e)},[e]);const r=S.useCallback(a=>{t(l=>{const c=d0({...l,...a});return $p(c),c})},[]),n=S.useCallback(()=>{const a=d0(void 0);t(a),$p(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const zm="termdock-settings";function Dj(e){return e==="shell"||e==="tmux"}function jj(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(zm);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&Dj(t.newSessionMode)?t.newSessionMode:null,n=r??"shell",a=typeof t.newSessionTmuxName=="string"?t.newSessionTmuxName:"";return{mode:n,tmuxName:a,userSelectedMode:r}}catch{return{mode:"shell",tmuxName:"",userSelectedMode:null}}}function Zx(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(zm),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(zm,JSON.stringify(n))}catch{}}function Bj(){const[e,t]=S.useState(jj),r=S.useCallback((a,l)=>{const c=l?.userInitiated!==!1;t(h=>({...h,mode:a,userSelectedMode:c?a:h.userSelectedMode})),c&&Zx({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=S.useCallback(a=>{t(l=>({...l,tmuxName:a})),Zx({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const Qj=550,Pj=10;function Av(){const e=b.useRef(null),t=b.useRef(null),r=b.useRef(!1),n=b.useRef(!1),a=b.useRef(null),l=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),c=b.useCallback(()=>{l(),t.current=null},[l]);return b.useCallback(p=>({onPointerDown:g=>{g.pointerType!=="touch"&&g.pointerType!=="pen"||(c(),r.current=!1,t.current={pointerId:g.pointerId,startX:g.clientX,startY:g.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(r.current=!0,p())},Qj))},onPointerMove:g=>{const x=t.current;if(!x||x.pointerId!==g.pointerId||r.current)return;const y=g.clientX-x.startX,A=g.clientY-x.startY;Math.hypot(y,A)>Pj&&c()},onPointerUp:g=>{r.current&&(g.preventDefault(),r.current=!1,n.current=!0,a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{n.current=!1,a.current=null},600)),c()},onPointerCancel:c,onPointerLeave:g=>{t.current?.pointerId===g.pointerId&&!r.current&&c()},onClickCapture:g=>{n.current&&(n.current=!1,a.current!=null&&(window.clearTimeout(a.current),a.current=null),g.preventDefault(),g.stopPropagation())}}),[c])}function Kx({mode:e,activeProgram:t,promptState:r,shellNames:n}){return e!=="tmux"?!1:r==="running"?!0:r==="idle"?!1:t===null||!n.has(t.toLowerCase())}function Oj(e,t,r){return!!(e&&t===e&&!r)}function Fj({groupId:e,version:t,onRestore:r}){const[n,a]=b.useState([]),[l,c]=b.useState(null),[h,p]=b.useState(""),g=b.useRef(!1);b.useEffect(()=>{let y=!0;const A=async()=>{try{const L=await M8();y&&a(L.entries.filter(I=>I.groups.some(E=>E.id===e)))}catch{}};A();const v=setInterval(()=>{document.hidden||A()},1e4);return()=>{y=!1,clearInterval(v)}},[e,t]);const x=async y=>{if(!g.current){g.current=!0,c(y.sessionId),p("");try{const A=await D8(y.sessionId);await r(A.session),a(v=>v.filter(L=>L.sessionId!==y.sessionId))}catch(A){p(A instanceof Error?A.message:"恢复失败,归档已保留")}finally{g.current=!1,c(null)}}};return!n.length&&!h?null:s.jsxs("details",{className:"border-t border-border/15 text-muted-foreground",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 px-2 text-[11px]",children:[s.jsx(Fb,{size:13}),"已归档的执行会话 · ",n.length]}),h&&s.jsx("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:h}),n.map(y=>s.jsxs("div",{className:"border-t border-border/10 px-2 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:y.title}),s.jsxs("button",{type:"button",disabled:l!==null,onClick:()=>{x(y)},className:"inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-primary hover:bg-primary/10 disabled:opacity-40",children:[l===y.sessionId&&s.jsx(vn,{size:12,className:"animate-spin"}),l===y.sessionId?"恢复中…":"恢复"]})]}),s.jsx("p",{className:"text-[10px] leading-4",children:y.cleanup.state==="removed"?"执行目录已回收,恢复时重建;分支和结果保留。":y.cleanup.reason||"目录保留,可继续恢复原会话。"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[10px]",children:[y.agent.slug," 会话 ID 与目录"]}),s.jsx("code",{className:"block select-text break-all text-[10px]",children:y.agent.sessionId}),s.jsx("span",{className:"mt-1 block select-text break-all text-[10px]",children:y.cwd})]})]},y.sessionId))]})}function Xx(e,t){const r=new Set,n=new Set;for(const a of e.filter(l=>l.groupId===t)){const l=a.attempts.find(h=>h.id===a.activeAttemptId)?.assignee,c=l&&a.memberSessions[`${l.serviceId}:${l.sessionId}`];if(a.status==="open"){c&&n.add(c);const h=a.scheduledAssignee;h&&n.add(a.memberSessions[`${h.serviceId}:${h.sessionId}`])}else c&&a.workspace&&a.workflow?.kind==="step"&&a.workflow.isolated&&r.add(c);a.coordinator&&n.add(a.memberSessions[`${a.coordinator.serviceId}:${a.coordinator.sessionId}`]),a.workflow?.reviewers.forEach(h=>n.add(a.memberSessions[`${h.serviceId}:${h.sessionId}`]))}return n.forEach(a=>r.delete(a)),r}const Hm={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function A0(e){if(e.status==="accepted")return e.completionMode==="reviewed"?"独立评审通过":"已验收";if(e.status==="closed")return"已关闭";if(e.decisions.some(l=>l.status==="pending"))return"需要你回答";if(e.automationIssue)return"需要处理异常";if(e.workflow?.paused)return"自动安排已暂停";const t=e.attempts.find(l=>l.id===e.activeAttemptId),r=e.artifacts.filter(l=>l.kind==="plan"&&l.attemptId===e.activeAttemptId).at(-1);if(r&&r.id!==e.approvedPlanArtifactId)return"需要你确认方案";const n=e.artifacts.filter(l=>l.kind==="result"&&l.attemptId===e.activeAttemptId).at(-1),a=n&&e.events.some(l=>l.kind==="revise"&&l.attemptId===e.activeAttemptId&&l.createdAt>=n.createdAt);if(n&&!a){const l=e.artifacts.filter(c=>c.kind==="review"&&c.reviewsArtifactId===n.id).at(-1);return e.workflow&&l?.verdict!=="pass"?l?.verdict==="changes"?"评审要求修改":"等待独立评审":e.workflow?.kind==="step"?"评审通过 · 等待接续":"等待你验收"}return a?e.events.some(l=>l.kind==="revise"&&l.source==="user"&&l.attemptId===e.activeAttemptId&&l.createdAt>=n.createdAt)?"已要求跟进 · 等待新结果":"已要求修改 · 等待新结果":t?t.report?Hm[t.report.status]:["failed","expired"].includes(t.deliveryStatus??"")?"投递未成功":e.deliveries.some(l=>l.attemptId===e.activeAttemptId&&l.error)?"投递需要关注":t.deliveryStatus==="delivered"?"已写入终端 · 等待回复":"等待投递":e.scheduledAssignee?e.dependsOn.length?"依赖完成后自动分派":e.workflow?.isolated===!1?"等待分派":"准备独立执行目录":e.dependsOn.length?"等待依赖与分派":"待分派"}function Sl(e){return e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","需要处理异常","成员报告受阻","成员报告失败","投递未成功","投递需要关注"].includes(A0(e))}const s0=Jl(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await Ib();e({tasks:r.filter(Sl),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function Jx(e,t){try{localStorage.setItem(`termdock:tasks:${location.origin}:${e}:open-task`,JSON.stringify(t))}catch{}window.dispatchEvent(new CustomEvent("open-collaboration-task",{detail:{groupId:e,taskId:t}}))}function e5({sessionIds:e}){const t=j8(a=>e.reduce((l,c)=>l+(a.unread[c]?.length??0),0)),{locale:r}=Hr();if(!t)return null;const n=r==="zh"?`${t} 条未读进展`:`${t} unread progress updates`;return s.jsx("span",{title:n,"aria-label":n,className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-primary/15 px-1 text-[10px] font-medium text-primary",children:t>99?"99+":t})}function $j(e){if(!e.startsWith("remote:"))return null;const t=e.slice(7).split(":");if(t.length!==2)return null;try{const r=decodeURIComponent(t[0]),n=decodeURIComponent(t[1]),a=new URL(r);return!["https:","http:"].includes(a.protocol)||a.origin!==r||!n?null:{origin:r,sessionId:n}}catch{return null}}async function Tv(e){const t=$j(e);if(!t)throw new Error("远端会话标识无效");if(window.termdockDesktop?.collaborationFocus)try{if(await window.termdockDesktop.collaborationFocus(e))return}catch{}window.dispatchEvent(new CustomEvent("termdock:open-remote-session",{detail:t}))}function Uj(e,t,r){return Math.max(t,Math.min(e,r))}const ds={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function t5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function r5(e,t,r,n=.15){return n===0?Uj(e,t,r):e<t?-t5(t-e,r-t,n)+t:e>r?+t5(e-r,r-t,n)+r:e}function zj(e,[t,r],[n,a]){const[[l,c],[h,p]]=e;return[r5(t,l,c,n),r5(r,h,p,a)]}function Hj(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Wj(e){var t=Hj(e,"string");return typeof t=="symbol"?t:String(t)}function Os(e,t,r){return t=Wj(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function bs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?n5(Object(r),!0).forEach(function(n){Os(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const Sv={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function s5(e){return e?e[0].toUpperCase()+e.slice(1):""}const Gj=["enter","leave"];function Vj(e=!1,t){return e&&!Gj.includes(t)}function qj(e,t="",r=!1){const n=Sv[e],a=n&&n[t]||t;return"on"+s5(e)+s5(a)+(Vj(r,a)?"Capture":"")}const Yj=["gotpointercapture","lostpointercapture"];function Zj(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=Yj.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function Kj(e,t=""){const r=Sv[e],n=r&&r[t]||t;return e+n}function Sf(e){return"touches"in e}function Cv(e){return Sf(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function Xj(e){return Array.from(e.touches).filter(t=>{var r,n;return t.target===e.currentTarget||((r=e.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,t.target))})}function Jj(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function _v(e){return Sf(e)?Jj(e)[0]:e}function Wm(e,t){try{const r=t.clientX-e.clientX,n=t.clientY-e.clientY,a=(t.clientX+e.clientX)/2,l=(t.clientY+e.clientY)/2,c=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:c,origin:[a,l]}}catch{}return null}function eB(e){return Xj(e).map(t=>t.identifier)}function i5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return Wm(r,n)}function Up(e){const t=_v(e);return Sf(e)?t.identifier:t.pointerId}function T0(e){const t=_v(e);return[t.clientX,t.clientY]}const a5=40,o5=800;function Lv(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=a5,r*=a5):n===2&&(t*=o5,r*=o5),[t,r]}function tB(e){var t,r;const{scrollX:n,scrollY:a,scrollLeft:l,scrollTop:c}=e.currentTarget;return[(t=n??l)!==null&&t!==void 0?t:0,(r=a??c)!==null&&r!==void 0?r:0]}function rB(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:r,altKey:n,metaKey:a,ctrlKey:l}=e;Object.assign(t,{shiftKey:r,altKey:n,metaKey:a,ctrlKey:l})}return t}function af(e,...t){return typeof e=="function"?e(...t):e}function nB(){}function sB(...e){return e.length===0?nB:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function l5(e,t){return Object.assign({},t,e||{})}const iB=32;class kv{constructor(t,r,n){this.ctrl=t,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:r,ingKey:n,args:a}=this;r[n]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=t.target,r.currentTarget=t.currentTarget,r.lastOffset=n.from?af(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=t.timeStamp)}computeValues(t){const r=this.state;r._values=t,r.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:r,config:n,shared:a}=this;r.args=this.args;let l=0;if(t&&(r.event=t,n.preventDefault&&t.cancelable&&r.event.preventDefault(),r.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,rB(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,l=t.timeStamp-r.timeStamp,r.timeStamp=t.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const B=r._delta.map(Math.abs);ds.addTo(r._distance,B)}this.axisIntent&&this.axisIntent(t);const[c,h]=r._movement,[p,g]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(c)>=p&&y[0]),x[1]===!1&&(x[1]=Math.abs(h)>=g&&y[1])):(x[0]===!1&&(x[0]=Math.abs(c)>=p&&Math.sign(c)*p),x[1]===!1&&(x[1]=Math.abs(h)>=g&&Math.sign(h)*g)),r.intentional=x[0]!==!1||x[1]!==!1,!r.intentional)return;const A=[0,0];if(n.hasCustomTransform){const[B,q]=y;A[0]=x[0]!==!1?B-x[0]:0,A[1]=x[1]!==!1?q-x[1]:0}else A[0]=x[0]!==!1?c-x[0]:0,A[1]=x[1]!==!1?h-x[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(A);const v=r.offset,L=r._active&&!r._blocked||r.active;L&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=a[this.ingKey]=r._active,t&&(r.first&&("bounds"in n&&(r._bounds=af(n.bounds,r)),this.setup&&this.setup()),r.movement=A,this.computeOffset()));const[I,E]=r.offset,[[R,P],[Q,$]]=r._bounds;r.overflow=[I<R?-1:I>P?1:0,E<Q?-1:E>$?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const W=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=zj(r._bounds,r.offset,W),r.delta=ds.sub(r.offset,v),this.computeMovement(),L&&(!r.last||l>iB)){r.delta=ds.sub(r.offset,v);const B=r.delta.map(Math.abs);ds.addTo(r.distance,B),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&l>0&&(r.velocity=[B[0]/l,B[1]/l],r.timeDelta=l)}}emit(){const t=this.state,r=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const a=this.handler(bs(bs(bs({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function aB([e,t],r){const n=Math.abs(e),a=Math.abs(t);if(n>a&&n>r)return"x";if(a>n&&a>r)return"y"}class fd extends kv{constructor(...t){super(...t),Os(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=ds.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=ds.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const r=this.state,n=this.config;if(!r.axis&&t){const a=typeof n.axisThreshold=="object"?n.axisThreshold[Cv(t)]:n.axisThreshold;r.axis=aB(r._movement,a)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const oB=e=>e,c5=.15,Iv={enabled(e=!0){return e},eventOptions(e,t,r){return bs(bs({},r.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[c5,c5];case!1:return[0,0];default:return ds.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return ds.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||oB},threshold(e){return ds.toVector(e,0)}},lB=0,Dc=bs(bs({},Iv),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=lB){return e},bounds(e={}){if(typeof e=="function")return l=>Dc.bounds(e(l));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=e;return[[t,r],[n,a]]}}),u5={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class cB extends fd{constructor(...t){super(...t),Os(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const r=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),a={left:r.left-n.left+t.offset[0],right:r.right-n.right+t.offset[0],top:r.top-n.top+t.offset[1],bottom:r.bottom-n.bottom+t.offset[1]};t._bounds=Dc.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const r=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(t.buttons):r.pointerButtons!==-1&&r.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);r.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=Up(t),n._pointerActive=!0,this.computeValues(T0(t)),this.computeInitial(),r.preventScrollAxis&&Cv(t)!=="mouse"?(n._active=!1,this.setupScrollPrevention(t)):r.delay>0?(this.setupDelayTrigger(t),r.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const r=this.state,n=this.config;if(!r._pointerActive)return;const a=Up(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const l=T0(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=ds.sub(l,r._values),this.computeValues(l)),ds.addTo(r._movement,r._delta),this.compute(t),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const a=Up(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[l,c]=r._distance;if(r.tap=l<=n.tapsThreshold&&c<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[h,p]=r._delta,[g,x]=r._movement,[y,A]=n.swipe.velocity,[v,L]=n.swipe.distance,I=n.swipe.duration;if(r.elapsedTime<I){const E=Math.abs(h/r.timeDelta),R=Math.abs(p/r.timeDelta);E>y&&Math.abs(g)>v&&(r.swipe[0]=Math.sign(h)),R>A&&Math.abs(x)>L&&(r.swipe[1]=Math.sign(p))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const r=this.config,n=r.device;r.pointerLock&&t.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,uB(t);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const r=u5[t.key];if(r){const n=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=r(this.config.keyboardDisplacement,a),n._keyboardActive=!0,ds.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in u5&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const r=this.config.device;t(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(r,"change",this.pointerMove.bind(this)),t(r,"end",this.pointerUp.bind(this)),t(r,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function uB(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const pd=typeof window<"u"&&window.document&&window.document.createElement;function Ev(){return pd&&"ontouchstart"in window}function dB(){return Ev()||pd&&window.navigator.maxTouchPoints>1}function hB(){return pd&&"onpointerdown"in window}function fB(){return pd&&"exitPointerLock"in window.document}function pB(){try{return"constructor"in GestureEvent}catch{return!1}}const io={isBrowser:pd,gesture:pB(),touch:Ev(),touchscreen:dB(),pointer:hB(),pointerLock:fB()},mB=250,gB=180,xB=.5,bB=50,yB=250,vB=10,d5={mouse:0,touch:0,pen:8},wB=bs(bs({},Dc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&io.pointerLock,io.touch&&r?"touch":this.pointerLock?"mouse":io.pointer&&!a?"pointer":io.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?mB:void 0,!(!io.touchscreen||r===!1))return e||(r!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(e,t,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const l=ds.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,l},swipe({velocity:e=xB,distance:t=bB,duration:r=yB}={}){return{velocity:this.transform(ds.toVector(e)),distance:this.transform(ds.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return gB;case!1:return 0;default:return e}},axisThreshold(e){return e?bs(bs({},d5),e):d5},keyboardDisplacement(e=vB){return e}});function Nv(e){const[t,r]=e.overflow,[n,a]=e._delta,[l,c]=e._direction;(t<0&&n>0&&l<0||t>0&&n<0&&l>0)&&(e._movement[0]=e._movementBound[0]),(r<0&&a>0&&c<0||r>0&&a<0&&c>0)&&(e._movement[1]=e._movementBound[1])}const AB=30,TB=100;class SB extends kv{constructor(...t){super(...t),Os(this,"ingKey","pinching"),Os(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:r,lastOffset:n}=this.state;t==="wheel"?this.state.offset=ds.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:t,lastOffset:r}=this.state;this.state.movement=[t[0]/r[0],t[1]-r[1]]}axisIntent(){const t=this.state,[r,n]=t._movement;if(!t.axis){const a=Math.abs(r)*AB-Math.abs(n);a<0?t.axis="angle":a>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(l=>n.has(l))||n.size<2)return;this.start(t),r._touchIds=Array.from(n).slice(0,2);const a=i5(t,r._touchIds);a&&this.pinchStart(t,a)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const r=this.state,n=r._pointerEvents,a=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(c=>a.has(c))||(n.size<2&&n.set(t.pointerId,t),r._pointerEvents.size<2))return;this.start(t);const l=Wm(...Array.from(n.values()));l&&this.pinchStart(t,l)}pinchStart(t,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const r=i5(t,this.state._touchIds);r&&this.pinchMove(t,r)}pointerMove(t){const r=this.state._pointerEvents;if(r.has(t.pointerId)&&r.set(t.pointerId,t),!this.state._active)return;const n=Wm(...Array.from(r.values()));n&&this.pinchMove(t,n)}pinchMove(t,r){const n=this.state,a=n._values[1],l=r.angle-a;let c=0;Math.abs(l)>270&&(c+=Math.sign(l)),this.computeValues([r.distance,r.angle-360*c]),n.origin=r.origin,n.turns=c,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const r=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}r._pointerEvents.has(t.pointerId)&&r._pointerEvents.delete(t.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const r=this.state;r._active||(this.start(t),this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY];const n=r._movement;r._movement=[t.scale-1,t.rotation],r._delta=ds.sub(r._movement,n),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>t[n]):!t[r])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const n=this.state;n._delta=[-Lv(t)[1]/TB*n.offset[0],0],ds.addTo(n._movement,n._delta),Nv(n),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const r=this.config.device;r&&(t(r,"start",this[r+"Start"].bind(this)),t(r,"change",this[r+"Move"].bind(this)),t(r,"end",this[r+"End"].bind(this)),t(r,"cancel",this[r+"End"].bind(this)),t("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const CB=bs(bs({},Iv),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!io.touch&&io.gesture)return"gesture";if(io.touch&&n)return"touch";if(io.touchscreen){if(io.pointer)return"pointer";if(io.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=c=>{const h=l5(af(r,c),{min:-1/0,max:1/0});return[h.min,h.max]},l=c=>{const h=l5(af(n,c),{min:-1/0,max:1/0});return[h.min,h.max]};return typeof r!="function"&&typeof n!="function"?[a(),l()]:c=>[a(c),l(c)]},threshold(e,t,r){return this.lockDirection=r.axis==="lock",ds.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class _B extends fd{constructor(...t){super(...t),Os(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(T0(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=T0(t),n=this.state;n._delta=ds.sub(r,n._values),ds.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const LB=bs(bs({},Dc),{},{mouseOnly:(e=!0)=>e});class kB extends fd{constructor(...t){super(...t),Os(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const r=this.state,n=tB(t);r._delta=ds.sub(n,r._values),ds.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const IB=Dc;class EB extends fd{constructor(...t){super(...t),Os(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const r=this.state;r._delta=Lv(t),ds.addTo(r._movement,r._delta),Nv(r),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const NB=Dc;class RB extends fd{constructor(...t){super(...t),Os(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(T0(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const r=this.state;if(!r._active)return;r._active=!1;const n=T0(t);r._movement=r._delta=ds.sub(n,r._values),this.computeValues(n),this.compute(t),r.delta=r.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const MB=bs(bs({},Dc),{},{mouseOnly:(e=!0)=>e}),z1=new Map,Gm=new Map;function Rv(e){z1.set(e.key,e.engine),Gm.set(e.key,e.resolver)}const Mv={key:"drag",engine:cB,resolver:wB},DB={key:"hover",engine:RB,resolver:MB},jB={key:"move",engine:_B,resolver:LB},BB={key:"pinch",engine:SB,resolver:CB},QB={key:"scroll",engine:kB,resolver:IB},PB={key:"wheel",engine:EB,resolver:NB};function OB(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,l;for(l=0;l<n.length;l++)a=n[l],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function FB(e,t){if(e==null)return{};var r=OB(e,t),n,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const $B={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=io.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},UB=["target","eventOptions","window","enabled","transform"];function Eh(e={},t){const r={};for(const[n,a]of Object.entries(t))switch(typeof a){case"function":r[n]=a.call(r,e[n],n,e);break;case"object":r[n]=Eh(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function zB(e,t,r={}){const n=e,{target:a,eventOptions:l,window:c,enabled:h,transform:p}=n,g=FB(n,UB);if(r.shared=Eh({target:a,eventOptions:l,window:c,enabled:h,transform:p},$B),t){const x=Gm.get(t);r[t]=Eh(bs({shared:r.shared},g),x)}else for(const x in g){const y=Gm.get(x);y&&(r[x]=Eh(bs({shared:r.shared},g[x]),y))}return r}class Dv{constructor(t,r){Os(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,l){const c=this._listeners,h=Kj(r,n),p=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},g=bs(bs({},p),l);t.addEventListener(h,a,g);const x=()=>{t.removeEventListener(h,a,g),c.delete(x)};return c.add(x),x}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class HB{constructor(){Os(this,"_timeouts",new Map)}add(t,r,n=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(r,n,...a))}remove(t){const r=this._timeouts.get(t);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class WB{constructor(t){Os(this,"gestures",new Set),Os(this,"_targetEventStore",new Dv(this)),Os(this,"gestureEventStores",{}),Os(this,"gestureTimeoutStores",{}),Os(this,"handlers",{}),Os(this,"config",{}),Os(this,"pointerIds",new Set),Os(this,"touchIds",new Set),Os(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),GB(this,t)}setEventIds(t){if(Sf(t))return this.touchIds=new Set(eB(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,r){this.handlers=t,this.nativeHandlers=r}applyConfig(t,r){this.config=zB(t,r,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const c of this.gestures){const h=this.config[c],p=h5(n,h.eventOptions,!!a);if(h.enabled){const g=z1.get(c);new g(this,t,c).bind(p)}}const l=h5(n,r.eventOptions,!!a);for(const c in this.nativeHandlers)l(c,"",h=>this.nativeHandlers[c](bs(bs({},this.state.shared),{},{event:h,args:t})),void 0,!0)}for(const l in n)n[l]=sB(...n[l]);if(!a)return n;for(const l in n){const{device:c,capture:h,passive:p}=Zj(l);this._targetEventStore.add(a,c,"",n[l],{capture:h,passive:p})}}}}function Xc(e,t){e.gestures.add(t),e.gestureEventStores[t]=new Dv(e,t),e.gestureTimeoutStores[t]=new HB}function GB(e,t){t.drag&&Xc(e,"drag"),t.wheel&&Xc(e,"wheel"),t.scroll&&Xc(e,"scroll"),t.move&&Xc(e,"move"),t.pinch&&Xc(e,"pinch"),t.hover&&Xc(e,"hover")}const h5=(e,t,r)=>(n,a,l,c={},h=!1)=>{var p,g;const x=(p=c.capture)!==null&&p!==void 0?p:t.capture,y=(g=c.passive)!==null&&g!==void 0?g:t.passive;let A=h?n:qj(n,a,x);r&&y&&(A+="Passive"),e[A]=e[A]||[],e[A].push(l)},VB=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function qB(e){const t={},r={},n=new Set;for(let a in e)VB.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function Jc(e,t,r,n,a,l){if(!e.has(r)||!z1.has(n))return;const c=r+"Start",h=r+"End",p=g=>{let x;return g.first&&c in t&&t[c](g),r in t&&(x=t[r](g)),g.last&&h in t&&t[h](g),x};a[n]=p,l[n]=l[n]||{}}function YB(e,t){const[r,n,a]=qB(e),l={};return Jc(a,r,"onDrag","drag",l,t),Jc(a,r,"onWheel","wheel",l,t),Jc(a,r,"onScroll","scroll",l,t),Jc(a,r,"onPinch","pinch",l,t),Jc(a,r,"onMove","move",l,t),Jc(a,r,"onHover","hover",l,t),{handlers:l,config:t,nativeHandlers:n}}function jv(e,t={},r,n){const a=S.useMemo(()=>new WB(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),S.useEffect(a.effect.bind(a)),S.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function f5(e,t){return Rv(Mv),jv({drag:e},t||{},"drag")}function ZB(e){return e.forEach(Rv),function(r,n){const{handlers:a,nativeHandlers:l,config:c}=YB(r,n||{});return jv(a,c,void 0,l)}}function i$(e,t){return ZB([Mv,BB,QB,PB,jB,DB])(e,t||{})}const p5={dampingRatio:.8,response:.3},KB=.998;function XB(e,t,r,n){const a=2*Math.PI/Math.max(e.response,.001),l=t-n,c=r,h=e.dampingRatio;if(Math.abs(h-1)<1e-4){const v=l,L=c+a*l;return{value:I=>n+(v+L*I)*Math.exp(-a*I),velocity:I=>(L-a*(v+L*I))*Math.exp(-a*I)}}if(h<1){const v=a*Math.sqrt(1-h*h),L=l,I=(c+h*a*l)/v;return{value:E=>n+Math.exp(-h*a*E)*(L*Math.cos(v*E)+I*Math.sin(v*E)),velocity:E=>Math.exp(-h*a*E)*((I*v-h*a*L)*Math.cos(v*E)-(L*v+h*a*I)*Math.sin(v*E))}}const p=a*Math.sqrt(h*h-1),g=-h*a+p,x=-h*a-p,y=(c-x*l)/(g-x),A=l-y;return{value:v=>n+y*Math.exp(g*v)+A*Math.exp(x*v),velocity:v=>y*g*Math.exp(g*v)+A*x*Math.exp(x*v)}}function JB(e,t=KB){return e/1e3*(t/(1-t))}function m5(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function eQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const tQ=.1,rQ=5;function nQ(e,t,r,n,a){const l=XB(e,t,r,n),c=1e3/60,h=240,p=[];for(let g=0;g<h;g++){const x=g*c/1e3,y=l.value(x),A=l.velocity(x);if(p.push(a?a(y):y),g>0&&Math.abs(y-n)<tQ&&Math.abs(A)<rQ)break}return p.push(a?a(n):n),{frames:p,durationMs:(p.length-1)*c,solver:l}}const sQ='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function iQ(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(sQ)&&e.blur()}const aQ=18,g5=8,x5={touch:g5,pen:g5},oQ=500,zp=200,b5=50,lQ=`[${y9}]`;function Hp(e,t,r){return Math.min(r,Math.max(t,e))}function y5(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function v5(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(lQ)}function cu(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const Bv=S.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:l,children:c,pinned:h=!1},p){const{t:g}=Hr(),x=t==="left",y=x?-n:n,A=b.useRef(null),v=b.useRef(null),L=b.useRef(r?0:y),I=b.useRef(null),E=b.useRef(null),R=b.useRef(0),P=b.useRef(null),Q=b.useRef(null),$=b.useRef(!1),W=b.useRef(null),B=b.useRef(!1),q=b.useRef([]),ne=b.useRef(null),Be=b.useRef(L.current),fe=b.useRef(r?1:0),X=b.useRef(r);X.current=r;const Qe=b.useRef(y);Qe.current=y;const Pe=b.useRef(n);Pe.current=n;const ue=b.useRef(x);ue.current=x;const Ce=b.useRef(a);Ce.current=a;const tt=b.useRef(l);tt.current=l;const we=b.useCallback(xe=>{A.current=xe,typeof p=="function"?p(xe):p&&(p.current=xe)},[p]),ce=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),I.current=null},[]),$e=b.useCallback(xe=>{const Ne=Pe.current;return ue.current?(xe+Ne)/Ne:(Ne-xe)/Ne},[]),ke=b.useCallback(xe=>{const Ne=v.current;Ne&&(Ne.style.opacity=String(Hp($e(xe),0,1)))},[$e]),se=b.useCallback(xe=>{L.current=xe;const Ne=A.current;Ne&&(Ne.style.transform=`translateX(${xe}px)`,ke(xe))},[ke]),je=b.useCallback(xe=>{I.current=xe,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const Ne=I.current;I.current=null,Ne!==null&&se(Ne)}))},[se]),de=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null);const xe=I.current;I.current=null,xe!==null&&se(xe)},[se]),Oe=b.useCallback(xe=>{const Ne=Qe.current;return Hp(xe,Math.min(0,Ne),Math.max(0,Ne))},[]),Ee=b.useCallback(()=>{const xe=P.current;if(!xe)return null;P.current=null;const Ne=(performance.now()-xe.startTime)/1e3,yt={value:xe.solver.value(Ne),velocity:xe.solver.velocity(Ne)};return xe.animations.forEach(gt=>gt.cancel()),yt},[]),_e=b.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),re=b.useCallback(()=>{ne.current?.(),ne.current=null},[]),Fe=b.useCallback(()=>{de(),_e();const xe=Ee();xe&&se(Oe(xe.value));const Ne=A.current,yt=v.current;Ne?.getAnimations().forEach(gt=>gt.cancel()),Ne&&(Ne.style.transition="none",Ne.style.opacity="1"),yt?.getAnimations().forEach(gt=>gt.cancel()),yt&&(yt.style.transition="none")},[se,_e,Oe,de,Ee]),wt=b.useCallback((xe,Ne)=>{de(),_e();const yt=A.current,gt=v.current,At=xe?0:Qe.current;gt&&(gt.style.pointerEvents=xe?"auto":"none");const Ft=Ee(),Z=Ft?Oe(Ft.value):L.current,Ge=Ne?.velocity??Ft?.velocity??0;if(eQ())return L.current=At,yt&&(yt.style.transition=`opacity ${zp}ms ease`,yt.style.opacity=xe?"1":"0",yt.style.transform=`translateX(${At}px)`),gt&&(gt.style.transition=`opacity ${zp}ms ease`,gt.style.opacity=xe?"1":"0"),zp;yt&&(yt.style.transition="none",yt.style.opacity="1"),gt&&(gt.style.transition="none");const pt=Math.abs(Ne?.velocity??0)>oQ,{frames:Pt,durationMs:hr,solver:Zt}=nQ({dampingRatio:pt?p5.dampingRatio:1,response:p5.response},Z,Ge,At,Oe);if(!yt||Math.abs(Z-At)<.5&&Math.abs(Ge)<5)return se(At),0;const _r=yt.animate(Pt.map(ze=>({transform:`translateX(${ze}px)`})),{duration:hr,easing:"linear",fill:"forwards"}),ae=[_r];return gt&&ae.push(gt.animate(Pt.map(ze=>({opacity:String(Hp($e(ze),0,1))})),{duration:hr,easing:"linear",fill:"forwards"})),P.current={solver:Zt,startTime:performance.now(),target:At,animations:ae},cu("spring start",{startX:Z,startVelocity:Ge,targetX:At,frames:Pt.length,durationMs:hr}),_r.onfinish=()=>{const ze=P.current;!ze||!ze.animations.includes(_r)||(P.current=null,se(At),ze.animations.forEach(Je=>Je.cancel()),cu("spring finish",{targetX:At}))},hr},[se,_e,Oe,de,$e,Ee]),Xe=b.useCallback(xe=>{de();const Ne=xe,yt=0,gt=Qe.current,At=L.current+JB(Ne),Ft=Math.abs(At-yt)<=Math.abs(At-gt);cu("decideSnap",{velocity:Ne,currentX:L.current,projected:At,shouldOpen:Ft});const Z=wt(Ft,{velocity:Ne});return Ft&&!X.current?Q.current=window.setTimeout(()=>{Q.current=null,tt.current?.()},Z+b5):!Ft&&X.current&&(Q.current=window.setTimeout(()=>{Q.current=null,Ce.current()},Z+b5)),Ft},[wt,de]),ee=b.useCallback(xe=>{const Ne=Qe.current,yt=Math.min(0,Ne),gt=Math.max(0,Ne),At=Pe.current;return xe<yt?yt-m5(yt-xe,At):xe>gt?gt+m5(xe-gt,At):xe},[]),Ue=b.useCallback(xe=>{const Ne=q.current,yt=performance.now();Ne.push({t:yt,x:xe});const gt=yt-120;for(;Ne.length>0&&Ne[0].t<gt;)Ne.shift()},[]),Le=b.useCallback(()=>{const xe=q.current;if(xe.length<2)return 0;const Ne=xe[xe.length-1];if(performance.now()-Ne.t>60)return 0;const yt=xe[0],gt=(Ne.t-yt.t)/1e3;return gt<.016?0:(Ne.x-yt.x)/gt},[]);b.useEffect(()=>{_e();const xe=P.current,Ne=r?0:Qe.current;xe&&xe.target===Ne||wt(r)},[r,wt,_e]),b.useEffect(()=>{Fe(),je(X.current?0:y)},[y,Fe,je]),b.useEffect(()=>()=>{ce(),_e(),Ee(),re()},[_e,ce,re,Ee]);const te=f5(({active:xe,cancel:Ne,first:yt,last:gt,movement:[At],event:Ft})=>{if(cu("bindPanel",{active:xe,first:yt,last:gt,mx:At}),!y5(Ft)){Ne();return}if(yt){if(re(),$.current=!1,W.current=null,q.current=[],v5(Ft)){Ne();return}const Z=A.current,Ge=Z?v9(Ft.target,Z):null;if(!Ge||w9()){Ne();return}const pt=A9(Ge,At,ue.current?-1:1);if(cu("arbitrate",{owner:pt.kind,mx:At}),pt.kind==="swiper"){ne.current=T9(pt.instance),Ne();return}if(pt.kind==="scroller"){const Pt=S9(pt.element);if(Pt)W.current=Pt;else{Ne();return}}W.current||($.current=!0,Fe(),R.current=L.current)}if(!xe){W.current=null,$.current&&($.current=!1,Xe(Le()));return}if(W.current){C9(W.current,At);return}if($.current){const Z=ee(R.current+At);Ue(Z),je(Z)}},{axis:"x",axisThreshold:x5,filterTaps:!0,pointer:{touch:!0}}),ye=f5(({active:xe,cancel:Ne,first:yt,movement:[gt],event:At})=>{if(!y5(At)){Ne();return}if(X.current){Ne();return}if(yt&&(B.current=!0,q.current=[],Fe(),R.current=L.current),!xe){B.current&&(B.current=!1,Xe(Le())&&iQ());return}if(B.current){const Ft=ee(R.current+gt);Ue(Ft),je(Ft)}},{axis:"x",axisThreshold:x5,filterTaps:!0,pointer:{touch:!0}}),ot=b.useCallback(xe=>{xe.preventDefault(),xe.stopPropagation(),X.current||tt.current?.()},[]);if(h)return s.jsx("aside",{ref:we,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:c});const le=te();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...ye(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:aQ,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:ot,"aria-label":g(x?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),s.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:fe.current,pointerEvents:r?"auto":"none",transition:"none",willChange:"opacity"},onClick:a,"aria-label":g("sidebar.closeSidebar")}),s.jsx("aside",{...le,onClickCapture:xe=>{v5(xe)||le.onClickCapture?.(xe)},ref:we,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${x?"border-r border-border":"border-l border-border/15"}`,style:{...x?{left:0}:{right:0},width:n,maxWidth:x?"94vw":"95vw",transform:`translateX(${Be.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:r?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...x?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:c})]})}),cQ={activeKey:"root",items:[]},uQ=()=>()=>{},dQ=()=>cQ;function hQ(e){const t=rl(),r=b.useSyncExternalStore(t?.subscribe??uQ,t?.snapshot??dQ),n=B8(),a=r.items.map(l=>l.key===n?{...l,reviewCount:e}:l).filter(l=>l.reviewCount>0);return{host:t,groups:a,currentKey:n,active:!t||r.activeKey===n,total:t?e+a.reduce((l,c)=>l+(c.key===n?0:c.reviewCount),0):e,hasOtherAttention:a.some(l=>l.key!==n)}}function fQ({groups:e,currentKey:t,onClose:r}){const{t:n}=Hr(),a=b.useId(),l=b.useRef(null),c=b.useRef(null),h=b.useRef(r);h.current=r;const p=b.useRef(!0),[g,x]=b.useState(""),y=e.reduce((L,I)=>L+I.reviewCount,0);b.useEffect(()=>{const L=document.activeElement;c.current?.focus({preventScroll:!0});const I=E=>{if(E.key==="Escape"&&(E.preventDefault(),E.stopImmediatePropagation(),h.current()),E.key!=="Tab")return;const R=Array.from(l.current?.querySelectorAll("button:not(:disabled)")??[]),P=R[0],Q=R[R.length-1],$=!l.current?.contains(document.activeElement);E.shiftKey&&(document.activeElement===P||$)?(E.preventDefault(),Q?.focus()):!E.shiftKey&&(document.activeElement===Q||$)&&(E.preventDefault(),P?.focus())};return document.addEventListener("keydown",I,!0),()=>{document.removeEventListener("keydown",I,!0),p.current&&L?.isConnected&&!L.closest("[inert]")&&L.focus({preventScroll:!0})}},[]);const A=(L,I)=>{const E=rl(),R=E?.snapshot().items.find(Q=>Q.key===L.key);if(!R?.reviewCount||I&&!R.attentionSessions?.some(Q=>Q.id===I)){x(n("serviceAttention.changed"));return}p.current=!1;let P=!1;I&&L.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:I})),P=!0):I&&R.service?.targetPeerId?P=E?.focusSession(R.service.targetPeerId,I)??!1:R.service&&(P=E?.activate(R.service,!0)??!1),P?r():(p.current=!0,x(n("serviceAttention.unavailable")))},v=L=>L.phase==="offline"?n("serviceAttention.offline"):L.phase==="login"?n("serviceAttention.login"):L.phase==="connecting"||L.phase==="reconnecting"?n("connection.reconnecting"):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":n("common.close"),tabIndex:-1,className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)]",onClick:r}),s.jsx("div",{className:"pointer-events-none fixed inset-0 z-modal-panel flex items-end justify-center p-3 sm:items-center sm:p-6",style:{paddingTop:"max(12px, var(--safe-top-inset, env(safe-area-inset-top, 0px)))",paddingBottom:"max(12px, var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:s.jsxs("section",{ref:l,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-sidebar-gesture-ignore":!0,onKeyDown:L=>L.stopPropagation(),className:"pointer-events-auto flex max-h-full w-full max-w-md flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[s.jsx(Zl,{size:20,className:"shrink-0 text-[color:var(--warning)]","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:a,className:"text-sm font-semibold",children:n("serviceAttention.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n("serviceAttention.summary",{services:e.length,count:y})})]}),s.jsx("button",{ref:c,type:"button","aria-label":n("common.close"),onClick:r,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-muted-foreground hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(Wn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 overflow-y-auto overscroll-contain p-2",children:[e.length===0&&s.jsx("p",{role:"status",className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("serviceAttention.empty")}),e.map(L=>s.jsxs("section",{className:"mb-2 last:mb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pb-1 pt-2 text-xs",children:[s.jsx("h3",{className:"min-w-0 flex-1 truncate font-medium",title:L.service?.label,children:L.service?.label||n("serviceAttention.currentService")}),L.key===t&&s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n("agent.currentSession")}),s.jsx("span",{className:"shrink-0 tabular-nums text-[color:var(--warning)]",children:L.reviewCount})]}),v(L)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(L)}),L.attentionSessions?.length?L.attentionSessions.map(I=>s.jsxs("button",{type:"button",onClick:()=>A(L,I.id),className:"flex min-h-14 w-full items-center gap-3 rounded-xl px-3 py-2 text-left hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"line-clamp-2 break-words text-sm",title:I.label,children:I.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:I.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(lo,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},I.id)):s.jsx("button",{type:"button",onClick:()=>A(L),className:"min-h-11 w-full rounded-xl px-3 py-2 text-left text-sm hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:n("serviceAttention.viewService")})]},L.key))]}),s.jsxs("footer",{className:"shrink-0 border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[g&&s.jsx("p",{role:"alert",className:"mb-1 text-[color:var(--warning)]",children:g}),n("serviceAttention.scope")]})]})})]})}function pQ(e){const t=e.icon&&e.isPlugin?`/api/terminal/agent-plugin-icon/${encodeURIComponent(e.slug)}${e.iconVersion?`?v=${Math.floor(e.iconVersion)}`:""}`:void 0,[r,n]=b.useState();if(b.useEffect(()=>{if(n(void 0),!t)return;const a=new AbortController;let l;return fetch(t,{signal:a.signal}).then(async c=>{if(!c.ok)throw new Error(`Icon request failed: ${c.status}`);const h=await c.blob();a.signal.aborted||(l=URL.createObjectURL(h),n({endpoint:t,src:l}))}).catch(()=>{}),()=>{a.abort(),l&&URL.revokeObjectURL(l)}},[t]),!!e.icon)return e.isPlugin?r?.endpoint===t?r?.src:void 0:`/icons/agents/${e.icon}.svg`}function mQ(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function gQ(e,t,r,n="next"){if(e.length===0)return null;const a=t?e.findIndex(l=>l.sessionId===t):-1;for(let l=1;l<=e.length;l+=1){const c=n==="next"?l:-l,h=(a+c+e.length)%e.length,p=e[h];if(p&&r(p))return p.sessionId}return null}function xQ(e,t,r="next"){return gQ(e,t,mQ,r)}const Ia=42,of=20,bQ=10;function Vm(e,t,r){return Math.min(r,Math.max(t,e))}function Cf(e){const t=Math.max(0,e.safeTop??0),r=Math.max(0,e.safeRight??0),n=Math.max(0,e.safeBottom??0),a=Math.max(0,e.safeLeft??0),l=Math.max(0,e.bottomClearance??72),c=a+of,h=Math.max(c,e.width-r-of-Ia),p=Math.max(t+12,52),g=Math.max(p,e.height-n-l-Ia);return{minX:c,maxX:h,minY:p,maxY:g}}function w5(e,t){const r=Cf(e),n=Vm(t.yRatio,0,1);return{x:t.side==="left"?r.minX:r.maxX,y:r.minY+(r.maxY-r.minY)*n}}function kc(e,t){const r=Cf(e);return{x:Vm(t.x,r.minX,r.maxX),y:Vm(t.y,r.minY,r.maxY)}}function A5(e,t){const r=Cf(e),n=kc(e,t),a=(r.minX+r.maxX+Ia)/2,l=n.x+Ia/2<a?"left":"right",c=r.maxY-r.minY;return{position:{x:l==="left"?r.minX:r.maxX,y:n.y},preference:{side:l,yRatio:c>0?(n.y-r.minY)/c:0}}}function T5(e,t,r){const n=kc(e,t),a=Ia+bQ,l=g=>Math.abs(g.x-r.x)<a&&Math.abs(g.y-r.y)<a;if(!l(n))return n;const c=[{...n,y:r.y-a},{...n,y:r.y+a}].map(g=>kc(e,g)).filter(g=>!l(g)).sort((g,x)=>Math.abs(g.y-n.y)-Math.abs(x.y-n.y));if(c[0])return c[0];const h=Cf(e);return[{...n,x:h.minX},{...n,x:h.maxX}].map(g=>kc(e,g)).filter(g=>!l(g)).sort((g,x)=>Math.abs(g.x-n.x)-Math.abs(x.x-n.x))[0]??n}const Wp="var(--warning)",yQ="var(--success)",S5="var(--tmux)",C5="termdock:mobile-attention-position:v1",_5="termdock:running-session-position:v1",vQ={side:"right",yRatio:.68},wQ={side:"right",yRatio:.54};function L5(e,t){if(typeof window>"u")return t;try{const r=JSON.parse(window.localStorage.getItem(e)??"null");if(r&&(r.side==="left"||r.side==="right")&&typeof r.yRatio=="number"&&Number.isFinite(r.yRatio))return{side:r.side,yRatio:Math.min(1,Math.max(0,r.yRatio))}}catch{}return t}function AQ(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function ih(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function TQ(e,t,r={}){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,a=n?.width??window.innerWidth,l=n?.height??window.innerHeight,c=t?.getBoundingClientRect(),h=!!(c&&c.width>0&&c.height>0);return{width:a,height:l,safeTop:Math.max(ih("--safe-top-inset"),(h?Math.max(0,c.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(ih("--safe-right-inset"),(h?Math.max(0,a-c.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(ih("--safe-bottom-inset"),(h?Math.max(0,l-c.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(ih("--safe-left-inset"),(h?Math.max(0,c.left):0)+Math.max(0,r.left??0)),bottomClearance:e?of:72}}function Qv(){const e=Jr.getState(),t=Array.from(e.sessions.values()),r=xQ(t,e.activeSessionId);if(!r)return;const n=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;n?.agentNeedsReview&&e.clearAgentNeedsReview(n.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:r}))}function k5(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function Pv(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function SQ({indicator:e,tone:t,size:r}){const n=Pv(t);switch(e){case"spinner":return s.jsx(En,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(Ph,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(Zl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx(Eo,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(K9,{size:r,className:"shrink-0 animate-pulse",style:{color:n}});case"ring":return s.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:r,height:r,borderColor:n}});case"dot":return s.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,r-4),height:Math.max(5,r-4),backgroundColor:n}})}}function Ic({agent:e,size:t=12}){const r=t-4,n=pQ(e);return n?e.iconMode==="native"?s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:s.jsx("img",{src:n,alt:e.displayName,style:{width:r,height:r}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx("span",{className:"block bg-white",style:{width:r,height:r,WebkitMask:`url(${n}) center / contain no-repeat`,mask:`url(${n}) center / contain no-repeat`}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx(od,{size:r,className:"text-white"})})}function CQ({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Ic,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(x0,{size:r,className:"shrink-0"}):s.jsx(Eo,{size:r,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?s.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:s.jsx(SQ,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(En,{size:r,className:"shrink-0 animate-spin",style:{color:yQ}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Ph,{size:r,className:"shrink-0 animate-bounce-y",style:{color:Wp}})}):t?.agentStatus==="done"&&t.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Zl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:Wp}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Zl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:Wp}})}):t?.inCopyMode?e==="tmux"?s.jsx(x0,{size:r,className:"shrink-0 animate-pulse",style:{color:S5}}):s.jsx(Eo,{size:r,className:"shrink-0 animate-pulse",style:{color:S5}}):n}function _Q({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=Hr();return t&&!r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:Pv(t.tone)},title:t.label}):e==="working"?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:a("agent.aiRunning")}):e==="waiting"||r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a(r?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a("agent.finishedReview")}):n?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:a("agent.copyMode")}):null}function Ov({count:e,tone:t,title:r}){const{t:n}=Hr();if(e<=0)return null;const a=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",l=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const c=r??n("agent.jumpToNext");return s.jsxs("button",{type:"button",className:a,title:`${c} · ${n("agent.jumpToNext")}`,"aria-label":`${c}: ${e}. ${n("agent.jumpToNext")}`,onClick:Qv,children:[s.jsx(Zl,{size:11,className:"shrink-0"}),s.jsx("span",{children:n("agent.needsReview")}),s.jsx("span",{className:"tabular-nums",children:e})]})}return s.jsxs("span",{className:a,title:r,children:[s.jsx("span",{className:l}),e]})}function LQ({runningCount:e,reviewCount:t,className:r=""}){const n=[];return e>0&&n.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&n.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),n.length===0?null:s.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${n.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${r}`,children:n.map(a=>s.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${a.className}`,children:a.count>9?"9+":a.count},a.key))})}const kQ=380,I5=10,ah=10,Gp=52,IQ=104;function EQ(e,t,r){const n=Math.max(0,t.safeLeft??0),a=t.width-Math.max(0,t.safeRight??0),l=Math.max(0,t.safeTop??0),c=t.height-Math.max(0,t.safeBottom??0),h=of,p=e.x+Ia/2>=n+(a-n)/2,g=p?e.x-ah-n-h:a-h-e.x-Ia-ah,x=Math.max(1,Math.min(Math.max(0,g),Math.max(168,r*IQ))),y=p?e.x-ah-x:e.x+Ia+ah,A=Math.min(Math.max(y,n+h),Math.max(n+h,a-h-x)),v=e.y+Ia/2-Gp/2,L=Math.min(Math.max(v,l+h),Math.max(l+h,c-h-Gp));return{left:A,top:L,width:x,height:Gp,itemWidth:x/Math.max(1,r),side:p?"left":"right"}}function E5(e,t,r,n){return t<e.left||t>e.left+e.width||r<e.top-14||r>e.top+e.height+14?null:Math.min(n-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function NQ(e,t){if(e.length===0)return null;const r=t?e.findIndex(n=>n.id===t):-1;return e[(r+1)%e.length]?.id??null}function RQ({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:l,containerElement:c,occlusionInsets:h}){const{t:p}=Hr(),g=sr(te=>te.leftOpen),x=sr(te=>te.rightOpen),{isOpen:y}=ty({enabled:!l}),A=l||!g&&!x&&!y,v=hQ(e),[L,I]=S.useState(!1);S.useEffect(()=>{(!v.active||!A)&&I(!1)},[v.active,A]);const E=a&&v.total>0&&A,R=t.length>1||t.length===1&&t[0]?.id!==r,P=n&&t.length>0&&R&&A,Q=Math.max(0,h?.top??0),$=Math.max(0,h?.right??0),W=Math.max(0,h?.bottom??0),B=Math.max(0,h?.left??0),q=S.useCallback(()=>TQ(l,c,{top:Q,right:$,bottom:W,left:B}),[c,l,W,B,$,Q]),ne=S.useRef({attention:L5(C5,vQ),running:L5(_5,wQ)}),Be=S.useCallback(()=>{const te=q(),ye=w5(te,ne.current.attention),ot=w5(te,ne.current.running);return{attention:ye,running:E&&P?T5(te,ot,ye):ot}},[E,q,P]),[fe,X]=S.useState(()=>Be()),Qe=S.useRef(fe);Qe.current=fe;const[Pe,ue]=S.useState(null),Ce=S.useRef(null),[tt,we]=S.useState("idle"),[ce,$e]=S.useState(null),ke=S.useRef(null),se=S.useRef({attention:!1,running:!1});S.useEffect(()=>()=>{const te=ke.current?.longPressTimer;te!=null&&window.clearTimeout(te)},[]),S.useEffect(()=>{if(P)return;const te=ke.current?.longPressTimer;te!=null&&window.clearTimeout(te),ke.current=null,we("idle"),$e(null)},[P]),S.useLayoutEffect(()=>{const te=()=>{const ot=Be();Qe.current=ot,X(ot)};te(),window.addEventListener("resize",te),window.addEventListener("orientationchange",te),window.visualViewport?.addEventListener("resize",te);const ye=typeof ResizeObserver>"u"?null:new ResizeObserver(te);return c&&ye?.observe(c),()=>{window.removeEventListener("resize",te),window.removeEventListener("orientationchange",te),window.visualViewport?.removeEventListener("resize",te),ye?.disconnect()}},[c,Be]);const je=S.useCallback(te=>te==="attention"?P:E,[E,P]),de=S.useCallback((te,ye)=>{if(!je(te))return ye;const ot=te==="attention"?"running":"attention";return T5(q(),ye,Qe.current[ot])},[q,je]),Oe=S.useCallback((te,ye,ot,le)=>{const xe=q(),Ne=ye.moved?kc(xe,{x:ye.startX+(ot-ye.originX),y:ye.startY+(le-ye.originY)}):Qe.current[te],yt=A5(xe,Ne),gt=de(te,yt.position),At=A5(xe,gt);ne.current[te]=At.preference,AQ(te==="attention"?C5:_5,At.preference);const Ft={...Qe.current,[te]:At.position};Qe.current=Ft,X(Ft)},[de,q]),Ee=S.useCallback(te=>{se.current[te]=!0,window.setTimeout(()=>{se.current[te]=!1},0)},[]),_e=S.useCallback(te=>{const ye=Ce.current;!ye||ye.kind!=="attention"||ye.pointerId!==te.pointerId||(Ce.current=null,ue(null),Oe("attention",ye,te.clientX,te.clientY),ye.moved&&Ee("attention"))},[Oe,Ee]),re={onPointerDown:te=>{te.stopPropagation(),te.currentTarget.setPointerCapture(te.pointerId),Ce.current={kind:"attention",pointerId:te.pointerId,originX:te.clientX,originY:te.clientY,startX:fe.attention.x,startY:fe.attention.y,moved:!1}},onPointerMove:te=>{const ye=Ce.current;if(!ye||ye.kind!=="attention"||ye.pointerId!==te.pointerId)return;const ot=te.clientX-ye.originX,le=te.clientY-ye.originY;if(!ye.moved&&Math.hypot(ot,le)<5)return;ye.moved=!0,ue("attention");const xe=q(),Ne=de("attention",kc(xe,{x:ye.startX+ot,y:ye.startY+le})),yt={...Qe.current,attention:Ne};Qe.current=yt,X(yt)},onPointerUp:_e,onPointerCancel:_e},Fe=c?EQ(fe.running,q(),t.length):null,wt=te=>{te.longPressTimer!==null&&(window.clearTimeout(te.longPressTimer),te.longPressTimer=null)},Xe={onPointerDown:te=>{te.stopPropagation(),te.currentTarget.setPointerCapture(te.pointerId);const ye=te.pointerId,ot={pointerId:ye,originX:te.clientX,originY:te.clientY,startX:fe.running.x,startY:fe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};ot.longPressTimer=window.setTimeout(()=>{const le=ke.current;!le||le.pointerId!==ye||le.mode!=="pressing"||(le.longPressTimer=null,le.mode="dragging",se.current.running=!0,we("dragging"))},kQ),ke.current=ot,we("pressing"),$e(null)},onPointerMove:te=>{const ye=ke.current;if(!ye||ye.pointerId!==te.pointerId)return;const ot=te.clientX-ye.originX,le=te.clientY-ye.originY;if(ye.mode==="pressing")if(Math.abs(ot)>=I5&&Math.abs(ot)>=Math.abs(le))wt(ye),ye.mode="selecting",se.current.running=!0,we("selecting");else if(Math.hypot(ot,le)>=I5){wt(ye),ye.mode="cancelled",se.current.running=!0,we("idle");return}else return;if(ye.mode==="selecting"){const gt=Fe?E5(Fe,te.clientX,te.clientY,t.length):null;ye.selectedIndex=gt,$e(gt);return}if(ye.mode!=="dragging"||!ye.moved&&Math.hypot(ot,le)<5)return;ye.moved=!0;const xe=q(),Ne=de("running",kc(xe,{x:ye.startX+ot,y:ye.startY+le})),yt={...Qe.current,running:Ne};Qe.current=yt,X(yt)},onPointerUp:te=>{const ye=ke.current;if(!ye||ye.pointerId!==te.pointerId)return;wt(ye);const ot=ye.mode;if(ot==="selecting"){const le=Fe?E5(Fe,te.clientX,te.clientY,t.length):ye.selectedIndex,xe=le===null?null:t[le]?.id;xe&&k5(xe)}else ot==="dragging"&&Oe("running",ye,te.clientX,te.clientY);ke.current=null,we("idle"),$e(null),ot!=="pressing"&&Ee("running")},onPointerCancel:te=>{const ye=ke.current;!ye||ye.pointerId!==te.pointerId||(wt(ye),ke.current=null,we("idle"),$e(null),Ee("running"))}},ee=(te,ye)=>s.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${ye==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:te>9?"9+":te}),Ue=()=>{const te=v.hasOtherAttention?p("serviceAttention.title"):p("agent.jumpToNext"),ye=fe.attention,ot=Pe==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...re,onClick:le=>{le.stopPropagation(),!se.current.attention&&(v.hasOtherAttention?I(!0):Qv())},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${ot?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{display:L?"none":void 0,left:ye.x,top:ye.y,width:Ia,height:Ia,touchAction:"none"},"aria-label":`${te}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:te,children:[s.jsx(Zl,{size:17,className:"shrink-0"}),ee(v.total,"attention")]},"attention")},Le=()=>{const te=t.length,ye=fe.running,ot=tt==="selecting",le=tt==="dragging";return s.jsxs(S.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":tt,...Xe,onClick:xe=>{if(xe.stopPropagation(),se.current.running)return;const Ne=NQ(t,r);Ne&&k5(Ne)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${le?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":ot?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:ye.x,top:ye.y,width:Ia,height:Ia,touchAction:"none"},"aria-label":`${p("agent.jumpToNextRunning")}: ${te}`,title:p("agent.runningSessionGestureHint"),children:[s.jsx(En,{size:18,className:"shrink-0 animate-spin"}),ee(te,"running")]}),ot&&Fe&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":Fe.side,"aria-label":p("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:Fe.left,top:Fe.top,width:Fe.width,height:Fe.height},children:t.map((xe,Ne)=>{const yt=Ne===ce,gt=xe.id===r,At=`${xe.label}${xe.detail?` · ${xe.detail}`:""}${gt?` · ${p("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":yt,"data-running-session-option":xe.id,"data-selected":yt?"true":"false",title:At,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${yt?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":gt?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[s.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${yt?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:Ne+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:xe.label})]},xe.id)})})]},"running")};return!E&&!P&&!L||c===null||typeof document>"u"?null:s.jsxs(Q8,{children:[E&&Ue(),P&&!L&&Le(),L&&v.active&&A&&s.jsx(fQ,{groups:v.groups,currentKey:v.currentKey,onClose:()=>I(!1)})]})}function MQ(){const{t:e}=Hr();return s.jsxs("div",{role:"status",className:"td-loading-skeleton overflow-hidden px-3 py-2",children:[s.jsx("span",{className:"sr-only",children:e("common.loading")}),s.jsx("div",{"aria-hidden":"true",children:["w-2/5","w-3/5","w-1/3","w-1/2","w-2/5","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-8 items-center gap-2",style:{paddingLeft:r>1&&r<5?20:0},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},r))})]})}const DQ=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),N5=120,R5=120,jQ=new Set,BQ=[],QQ={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function H1(e,t){if(t==="directory")return null;if(F8(e))return s.jsx($9,{size:14});if($8(e))return s.jsx(Xb,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return DQ.has(r)?s.jsx(pA,{size:14}):s.jsx(Hb,{size:14})}function Fv({path:e}){const r=sr(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=QQ[r]??{label:"?",className:"text-muted-foreground",title:r};return s.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${n.className}`,title:n.title,children:n.label})}function S0(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100"}function W1(e){return S0(e)}const PQ=b.memo(function({path:t}){const{t:r}=Hr(),[n,a]=b.useState("idle"),[l,c]=b.useState(null),h=b.useCallback(async p=>{if(p.stopPropagation(),n!=="pending"){a("pending"),c(null);try{await Eb(t),a("idle")}catch(g){a("error"),c(g instanceof Error?g.message:r("rightSidebar.downloadFailed"))}}},[t,n,r]);return s.jsx("span",{role:"button",tabIndex:-1,onClick:p=>{h(p)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition active:scale-95 ${S0(n==="pending")} ${n==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:n==="error"?l??r("rightSidebar.downloadFailed"):r("rightSidebar.downloadFile"),children:n==="pending"?s.jsx(En,{size:12,className:"animate-spin"}):s.jsx(Wu,{size:12})})});function $v(){const{t:e}=Hr(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await Eb(a),r({status:"idle"})}catch(l){r({status:"error",message:l instanceof Error?l.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:n}}function qm(e){return e instanceof DOMException&&e.name==="AbortError"}function lf(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function Uv(e){return e.button===2||e.ctrlKey}const OQ=176,FQ=160,uu=8;function M5(e,t,r,n){const a=window.visualViewport,l=a?.offsetLeft??0,c=a?.offsetTop??0,h=l+(a?.width??window.innerWidth),p=c+(a?.height??window.innerHeight),g=l+uu,x=c+uu,y=Math.max(g,h-r-uu),A=Math.max(x,p-n-uu),v=t+n<=p-uu?t:t-n;return{anchorX:e,anchorY:t,left:Math.min(Math.max(e,g),y),top:Math.min(Math.max(v,x),A)}}function zv(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((l,c)=>{r(M5(l,c,OQ,FQ))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const l=n.current.getBoundingClientRect();if(l.width<=0||l.height<=0)return;const c=M5(t.anchorX,t.anchorY,l.width,l.height);c.left===t.left&&c.top===t.top||r(c)},[e,t]),{position:t,menuRef:n,openAt:a,clearPosition:()=>r(null)}}function Hv(e,t){return t&&typeof document<"u"?ki.createPortal(e,document.body):e}function $Q(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function G1(e,t,r){if(!t||$Q(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>G1(a,t,r)):!1}function Ym(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,modified:t.modified,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function Zm(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const UQ=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:l,getReferenceText:c,onReferenceCopied:h,insertedReferenceKey:p,copiedReferenceKey:g,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:A,onFilePinToggle:v,onOpenInFileBrowser:L,canOpenInFileBrowser:I,pinnedPaths:E,selectedFilePath:R,queryLower:P,onDirectoryDropFiles:Q,onFileDeleteRequest:$,deletingFilePath:W,revealedDirectoryPath:B,gitIgnoreRoot:q}){const{t:ne}=Hr(),Be=sr(nt=>nt.expandedPaths.has(t.path)),fe=sr(nt=>nt.directoryCache.get(t.path)),X=sr(nt=>nt.showHiddenFiles),Qe=sr(nt=>nt.toggleExpanded),Pe=sr(nt=>nt.setDirectoryCache),ue=sr(nt=>nt.fileSortModes[t.path]??"name"),Ce=sr(nt=>nt.setDirectorySortMode),[tt,we]=b.useState(!1),[ce,$e]=b.useState(!1),{position:ke,menuRef:se,openAt:je,clearPosition:de}=zv(ce),[Oe,Ee]=b.useState(!1),_e=b.useRef(0),re=b.useRef(null),Fe=b.useRef(null),wt=t.path===R||t.path===B,Xe=t.type==="directory"&&(Be||!!P),ee=t.type==="directory",Ue=E.has(t.path),Le=!ee&&!!v,te=!!(I&&L),ye=`path:${t.path}`,ot=p===ye,le=g===ye,xe=c?.(t.path)??t.path,Ne=s1(h),{state:yt,run:gt}=$v(),At=W===t.path,Ft=ee&&!a&&!!(x||y||A||te),Z=b.useMemo(()=>{if(!fe)return;if(!P)return fe;const nt=sr.getState().directoryCache;return fe.filter(_t=>(!a||_t.type==="directory")&&G1(_t,P,nt))},[fe,a,P]),Ge=b.useCallback(async()=>{if(!sr.getState().directoryCache.has(t.path)&&!tt){const _t=`file-tree:${t.path}`;re.current?.abort(),um(_t);const Qr=new AbortController;re.current=Qr,we(!0);try{const yr=await r1(t.path,Qr.signal,X,"expand_directory",_t,ue,q);if(Qr.signal.aborted)return;const Nt=Ym(yr.entries);Pe(t.path,Nt)}catch(yr){qm(yr)}finally{re.current===Qr&&(re.current=null),we(!1)}}},[t.path,tt,Pe,X,ue,q]),pt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&x){x(t.path);return}const nt=!sr.getState().expandedPaths.has(t.path);Qe(t.path),nt&&await Ge()},[a,t.path,t.type,Ge,x,Qe,n]);b.useEffect(()=>{t.type==="directory"&&Be&&!fe&&!tt&&Ge()},[fe,Be,Ge,tt,t.type]);const Pt=b.useCallback(nt=>{nt.stopPropagation(),l?.(t.path,ye)},[l,t.path,ye]),hr=b.useCallback(nt=>{nt.stopPropagation(),x?.(t.path),$e(!1)},[t.path,x]),Zt=b.useCallback(nt=>{nt.stopPropagation(),y?.(t.path),$e(!1)},[t.path,y]),_r=b.useCallback(nt=>{nt.stopPropagation(),A?.(t.path),$e(!1)},[t.path,A]),ae=b.useCallback(nt=>{nt.stopPropagation(),Ce(t.path,ue==="modified"?"name":"modified"),$e(!1)},[t.path,Ce,ue]),ze=b.useCallback(nt=>{nt.stopPropagation(),v?.(t.path),$e(!1)},[t.path,v]),Je=b.useCallback(nt=>{nt.stopPropagation(),$e(!1),gt(t.path)},[t.path,gt]),Rt=b.useCallback(nt=>{nt.stopPropagation(),$e(!1),$(t)},[t,$]),Mt=b.useCallback(nt=>{nt.stopPropagation(),L?.(t.path),$e(!1)},[t.path,L]),ir=b.useCallback(nt=>{!ee||!Q||!nt.dataTransfer.types.includes("Files")||(nt.preventDefault(),nt.stopPropagation(),_e.current+=1,Ee(!0))},[ee,Q]),Ut=b.useCallback(nt=>{!ee||!Q||!nt.dataTransfer.types.includes("Files")||(nt.preventDefault(),nt.stopPropagation(),nt.dataTransfer.dropEffect="copy",Ee(!0))},[ee,Q]),We=b.useCallback(nt=>{!ee||!Q||(nt.preventDefault(),nt.stopPropagation(),_e.current-=1,_e.current<=0&&(_e.current=0,Ee(!1)))},[ee,Q]),br=b.useCallback(nt=>{if(!ee||!Q)return;nt.preventDefault(),nt.stopPropagation(),_e.current=0,Ee(!1);const _t=Array.from(nt.dataTransfer.files);_t.length>0&&Q(t.path,_t)},[ee,t.path,Q]),Ze=b.useCallback(nt=>{nt.stopPropagation(),de(),$e(_t=>!_t)},[de]),Dt=b.useCallback(nt=>{!Ft||!Uv(nt)||(nt.preventDefault(),nt.stopPropagation(),je(nt.clientX,nt.clientY),$e(!0))},[Ft,je]);return b.useEffect(()=>{if(!ce)return;const nt=Qr=>{const yr=Qr.target;yr instanceof Node&&(Fe.current?.contains(yr)||se.current?.contains(yr))||$e(!1)},_t=Qr=>{Qr.key==="Escape"&&$e(!1)};return document.addEventListener("pointerdown",nt),document.addEventListener("keydown",_t),()=>{document.removeEventListener("pointerdown",nt),document.removeEventListener("keydown",_t)}},[ce,se]),b.useEffect(()=>()=>{re.current?.abort()},[]),s.jsxs("div",{style:!Xe&&!ce?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:Fe,className:"relative",children:[Ne.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":ue,role:"button",tabIndex:0,onClick:()=>{lf()||pt()},onContextMenu:Dt,onKeyDown:nt=>{nt.key!=="Enter"&&nt.key!==" "||(nt.preventDefault(),pt())},onDragEnter:ir,onDragOver:Ut,onDragLeave:We,onDrop:br,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Oe?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":wt?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[r>0&&s.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:`${r*14-4}px`}}),Oe&&s.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:ne("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Xe?s.jsx(ol,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(lo,{size:14,className:"shrink-0 text-muted-foreground/80"}),Xe?s.jsx(c0,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(Ec,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:wt?"text-primary":"text-muted-foreground/80",children:H1(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${wt?"font-medium":""}`,children:[t.name,ue==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:ne("fileTree.sortedByModified"),"aria-label":ne("fileTree.sortedByModified"),children:s.jsx(Hu,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:ne("fileTree.symbolicLink"),children:s.jsx(g0,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${wt?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:nt=>nt.stopPropagation(),onKeyDown:nt=>nt.stopPropagation(),children:[tt&&s.jsx(En,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(Fv,{path:t.path}),Ft&&s.jsx("span",{onClick:Ze,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition active:scale-95 ${S0(ce)} ${ce?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:ne("fileTree.moreDirActions"),children:s.jsx(ll,{size:13})}),!ee&&s.jsx("span",{onClick:Ze,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition active:scale-95 ${S0(ce||yt.status==="pending"||At||Ue)} ${ce?"bg-surface-elevated text-foreground":Ue?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:yt.status==="error"?yt.message??ne("rightSidebar.downloadFailed"):ne("fileTree.moreFileActions"),children:yt.status==="pending"||At?s.jsx(En,{size:13,className:"animate-spin"}):s.jsx(ll,{size:13})}),l&&s.jsx("span",{onClick:Pt,...Ne(xe,ye),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition active:scale-95 ${W1(ot||le)} ${ot||le?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":ne(le?"rightSidebar.copied":ot?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:ne(le?"rightSidebar.copied":ot?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:le||ot?s.jsx(ci,{size:12}):s.jsx(g0,{size:12})}),Ft&&ce&&Hv(s.jsxs("div",{ref:se,className:`${ke?"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:ke?{left:ke.left,top:ke.top}:void 0,children:[te&&s.jsxs("button",{type:"button",onClick:Mt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:ne("fileTree.openInFileBrowserTitle"),children:[s.jsx(c0,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("fileTree.openInFileBrowser")})]}),x&&s.jsxs("button",{type:"button",onClick:hr,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:ne("fileTree.openDirRootTitle"),children:[s.jsx(c0,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:Zt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:ne("fileTree.searchFromDirTitle"),children:[s.jsx(i1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("fileTree.searchFromDir")})]}),A&&s.jsxs("button",{type:"button",onClick:_r,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${Ue?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:ne(Ue?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ue?s.jsx(Vu,{size:13,className:"shrink-0"}):s.jsx(Gu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne(Ue?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:ae,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[ue==="modified"?s.jsx(D9,{size:13,className:"shrink-0"}):s.jsx(Hu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne(ue==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!ke),!ee&&ce&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[te&&s.jsxs("button",{type:"button",onClick:Mt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:ne("fileTree.openInFileBrowserTitle"),children:[s.jsx(Hb,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:Je,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:ne("rightSidebar.downloadFile"),children:[s.jsx(Wu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("rightSidebar.downloadFile")})]}),Le&&s.jsxs("button",{type:"button",onClick:ze,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${Ue?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:ne(Ue?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ue?s.jsx(Vu,{size:13,className:"shrink-0"}):s.jsx(Gu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne(Ue?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:Rt,disabled:At,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:ne("fileTree.deleteFile"),children:[At?s.jsx(En,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ne("fileTree.deleteFile")})]})]})]})]})]}),Xe&&Z&&Z.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:Z.map(nt=>s.jsx(e,{node:nt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:l,getReferenceText:c,onReferenceCopied:h,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:A,onFilePinToggle:v,onOpenInFileBrowser:L,canOpenInFileBrowser:I,pinnedPaths:E,selectedFilePath:R,queryLower:P,insertedReferenceKey:p,copiedReferenceKey:g,onDirectoryDropFiles:Q,onFileDeleteRequest:$,deletingFilePath:W,gitIgnoreRoot:q,revealedDirectoryPath:B},nt.path))})]})}),zQ=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,getReferenceText:l,onReferenceCopied:c,insertedReferenceKey:h,copiedReferenceKey:p,onDirectoryRoot:g,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:A,pinnedPaths:v,selectedFilePath:L,onFileDeleteRequest:I,deletingFilePath:E}){const{t:R}=Hr(),P=t.path===L,Q=t.type==="directory",$=v.has(t.path),W=!Q&&!!A,B=`path:${t.path}`,q=h===B,ne=p===B,Be=l?.(t.path)??t.path,fe=s1(c),{state:X,run:Qe}=$v(),[Pe,ue]=b.useState(!1),{position:Ce,menuRef:tt,openAt:we,clearPosition:ce}=zv(Pe),$e=b.useRef(null),ke=E===t.path,se=Q&&!!(g||x||y),je=b.useCallback(()=>{lf()||(t.type==="directory"?g?.(t.path):n(t.path))},[t.path,t.type,g,n]),de=b.useCallback(Xe=>{Xe.stopPropagation(),a?.(t.path,B)},[a,t.path,B]),Oe=b.useCallback(Xe=>{Xe.stopPropagation(),y?.(t.path),ue(!1)},[t.path,y]),Ee=b.useCallback(Xe=>{Xe.stopPropagation(),A?.(t.path),ue(!1)},[t.path,A]),_e=b.useCallback(Xe=>{Xe.stopPropagation(),ue(!1),Qe(t.path)},[t.path,Qe]),re=b.useCallback(Xe=>{Xe.stopPropagation(),ue(!1),I(t)},[t,I]),Fe=b.useCallback(Xe=>{Xe.stopPropagation(),ce(),ue(ee=>!ee)},[ce]),wt=b.useCallback(Xe=>{!se||!Uv(Xe)||(Xe.preventDefault(),Xe.stopPropagation(),we(Xe.clientX,Xe.clientY),ue(!0))},[se,we]);return b.useEffect(()=>{if(!Pe)return;const Xe=Ue=>{const Le=Ue.target;Le instanceof Node&&($e.current?.contains(Le)||tt.current?.contains(Le))||ue(!1)},ee=Ue=>{Ue.key==="Escape"&&ue(!1)};return document.addEventListener("pointerdown",Xe),document.addEventListener("keydown",ee),()=>{document.removeEventListener("pointerdown",Xe),document.removeEventListener("keydown",ee)}},[Pe,tt]),s.jsxs("div",{ref:$e,className:"relative border-b border-border/10 last:border-b-0",children:[fe.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:je,onContextMenu:wt,onKeyDown:Xe=>{Xe.key!=="Enter"&&Xe.key!==" "||(Xe.preventDefault(),je())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${P?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx(Ec,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:P?"text-primary":"text-muted-foreground/80",children:H1(t.name,t.type)})]}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsxs("span",{className:`block whitespace-normal break-all font-medium leading-snug ${P?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:R("fileTree.symbolicLink"),children:s.jsx(g0,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:Zm(r,t.path)})]}),s.jsx(Fv,{path:t.path}),t.type==="directory"&&(y||x)&&s.jsx("span",{onClick:Fe,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition active:scale-95 ${S0(Pe)} ${Pe?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:R("fileTree.moreDirActions"),children:s.jsx(ll,{size:13})}),!Q&&s.jsx("span",{onClick:Fe,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition active:scale-95 ${S0(Pe||X.status==="pending"||ke||$)} ${Pe?"bg-surface-elevated text-foreground":$?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:X.status==="error"?X.message??R("rightSidebar.downloadFailed"):R("fileTree.moreFileActions"),children:X.status==="pending"||ke?s.jsx(En,{size:13,className:"animate-spin"}):s.jsx(ll,{size:13})}),a&&s.jsx("span",{onClick:de,...fe(Be,B),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition active:scale-95 ${W1(q||ne)} ${q||ne?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":R(ne?"rightSidebar.copied":q?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:R(ne?"rightSidebar.copied":q?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:ne||q?s.jsx(ci,{size:12}):s.jsx(g0,{size:12})})]}),se&&Pe&&Hv(s.jsxs("div",{ref:tt,className:`${Ce?"fixed z-menu-panel":"absolute right-2 top-[calc(100%+2px)] z-30"} w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in`,style:Ce?{left:Ce.left,top:Ce.top}:void 0,children:[g&&s.jsxs("button",{type:"button",onClick:Xe=>{Xe.stopPropagation(),g(t.path),ue(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openDirRootTitle"),children:[s.jsx(c0,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openDirRoot")})]}),x&&s.jsxs("button",{type:"button",onClick:Xe=>{Xe.stopPropagation(),x(t.path),ue(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[s.jsx(i1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.searchFromDir")})]}),y&&s.jsxs("button",{type:"button",onClick:Oe,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R($?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[$?s.jsx(Vu,{size:13,className:"shrink-0"}):s.jsx(Gu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R($?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!Ce),!Q&&Pe&&s.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[s.jsxs("button",{type:"button",onClick:_e,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("rightSidebar.downloadFile"),children:[s.jsx(Wu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("rightSidebar.downloadFile")})]}),W&&s.jsxs("button",{type:"button",onClick:Ee,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${$?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R($?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[$?s.jsx(Vu,{size:13,className:"shrink-0"}):s.jsx(Gu,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R($?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:re,disabled:ke,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:R("fileTree.deleteFile"),children:[ke?s.jsx(En,{size:13,className:"shrink-0 animate-spin"}):s.jsx(Zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.deleteFile")})]})]})]})}),HQ=60,D5=60,WQ=20;function j5({count:e,loading:t,engine:r,limited:n,scope:a,content:l}){const{t:c}=Hr();return s.jsxs("div",{className:"sticky top-0 z-10 -mx-2 -mt-2 mb-2 border-b border-border/15 bg-surface/95 px-3 py-2.5 backdrop-blur",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 text-[12px] font-semibold text-foreground",children:[s.jsx(i1,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{children:l?c("fileTree.contentMatchesCount",{count:e}):c("fileTree.searchResults",{count:e})})]}),r&&s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[9px] uppercase tracking-[0.12em] text-muted-foreground",children:[t&&s.jsx(En,{size:9,className:"animate-spin"}),r,n?" · limited":""]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:c("fileTree.searchScope")}),s.jsx("span",{className:"min-w-0 truncate font-mono text-foreground/75",title:a,children:a}),t&&s.jsx("span",{className:"ml-auto shrink-0",children:c("fileTree.searching")})]})]})}function GQ(e,t){if(!t)return e;const r=e.toLowerCase(),n=t.toLowerCase(),a=[];let l=0,c=r.indexOf(n,l),h=0;for(;c>=0&&n;)c>l&&a.push(e.slice(l,c)),a.push(s.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(c,c+n.length)},`m-${h++}`)),l=c+n.length,c=r.indexOf(n,l);return l<e.length&&a.push(e.slice(l)),a.length>0?a:e}const VQ=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:l,onPathReference:c,getReferenceText:h,onReferenceCopied:p,insertedReferenceKey:g,copiedReferenceKey:x}){const{t:y}=Hr(),[A,v]=b.useState(!0),L=t.path===n,I=A?t.matches.slice(0,WQ):[],E=t.matches.length-I.length,R=`path:${t.path}`,P=g===R,Q=x===R,$=h?.(t.path)??t.path,W=s1(p);return s.jsxs("div",{className:"border-b border-border/10 last:border-b-0",children:[W.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{lf()||v(B=>!B)},onKeyDown:B=>{B.key!=="Enter"&&B.key!==" "||(B.preventDefault(),v(q=>!q))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[A?s.jsx(ol,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(lo,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:H1(t.name,"file")}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:Zm(r,t.path)})]}),s.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),s.jsx(PQ,{path:t.path}),c&&s.jsx("span",{onClick:B=>{B.stopPropagation(),c(t.path,R)},...W($,R),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition active:scale-95 ${W1(P||Q)} ${P||Q?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":y(Q?"rightSidebar.copied":P?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:y(Q?"rightSidebar.copied":P?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:Q||P?s.jsx(ci,{size:12}):s.jsx(g0,{size:12})})]}),A&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[I.map((B,q)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{lf()||l?.(t.path,B.line)},onKeyDown:ne=>{ne.key!=="Enter"&&ne.key!==" "||(ne.preventDefault(),l?.(t.path,B.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${Zm(r,t.path)}:${B.line}`,children:[s.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:B.line}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:GQ(B.text,a)})]},`${B.line}-${q}`)),E>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:y("fileTree.moreMatches",{count:E})})]})]})});function qQ({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,getReferenceText:a,onReferenceCopied:l,insertedReferenceKey:c,copiedReferenceKey:h,onDirectoryRoot:p,onSearchFromDirectory:g,onDirectoryPinToggle:x,onFilePinToggle:y,onOpenInFileBrowser:A,canOpenInFileBrowser:v=!1,pinnedPaths:L=jQ,selectedFilePath:I,query:E="",searchRootPath:R,searchOptions:P={},searchMode:Q="name",onContentMatchSelect:$,onDirectoryDropFiles:W,revealDirectory:B}){const{t:q}=Hr(),ne=sr(ae=>e?ae.directoryCache.get(e):void 0),Be=sr(ae=>ae.setDirectoryCache),fe=sr(ae=>ae.showHiddenFiles),X=sr(ae=>ae.fileSortModesHydrated),Qe=sr(ae=>ae.fileSortModes[e]??"name"),Pe=sr(ae=>ae.hydrateFileSortModes),ue=sr(ae=>ae.hydrateHideGitIgnoredRoots),Ce=sr(ae=>!!ae.hideGitIgnoredRoots[e]),tt=sr(ae=>ae.hideGitIgnoredRootsHydrated),we=sr(ae=>JSON.stringify(ae.gitIgnoreExceptions[e]??[])),ce=sr(ae=>ae.invalidateDirectoryCache);b.useLayoutEffect(()=>{e&&ce(e,!0)},[e,Ce,we,ce]);const[$e,ke]=b.useState(!1),[se,je]=b.useState(null),[de,Oe]=b.useState(!1),[Ee,_e]=b.useState(!1),[re,Fe]=b.useState(null),[wt,Xe]=b.useState(X&&tt),ee=X&&tt||wt;b.useEffect(()=>{let ae=!1;return Promise.all([Pe(),ue()]).catch(()=>{}).finally(()=>{ae||Xe(!0)}),()=>{ae=!0}},[Pe,ue]);const[Ue,Le]=b.useState([]),[te,ye]=b.useState(null),[ot,le]=b.useState(N5),[xe,Ne]=b.useState([]),[yt,gt]=b.useState(null),At=b.useRef(null),Ft=b.useRef(0),Z=E.trim().toLowerCase(),Ge=Q==="content",pt=R||e,Pt=P.excludePatterns??BQ,hr=Pt.join(`
128
+ `);b.useEffect(()=>{const ae=B?.path;if(!ae||!ae.startsWith(`${e}/`)&&ae!==e)return;const ze=ae.slice(e.length).replace(/^\/+/,""),Je=ze?ze.split("/"):[],Rt=Je.map((Dt,nt)=>`${e}/${Je.slice(0,nt+1).join("/")}`),Mt=sr.getState(),ir=Rt.filter(Dt=>!Mt.expandedPaths.has(Dt));ir.length>0&&sr.setState(Dt=>({expandedPaths:new Set([...Dt.expandedPaths,...ir])}));let Ut=!1,We=0;const br=()=>{if(Ut)return;const Dt=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(nt=>nt.dataset.fileTreePath===ae);if(Dt){Dt.scrollIntoView({block:"center",behavior:"smooth"});return}We+=1,We<80&&window.setTimeout(br,50)},Ze=window.requestAnimationFrame(br);return()=>{Ut=!0,window.cancelAnimationFrame(Ze)}},[B?.nonce,B?.path,e]);const Zt=b.useCallback(async ae=>{if(!(yt||ae.type==="directory")&&window.confirm(q("fileTree.deleteFileConfirm",{name:ae.name}))){gt(ae.path);try{await P8(ae.path),sr.getState().applyFileWatchEvents([{type:"deleted",path:ae.path}]),Le(ze=>ze.filter(Je=>Je.path!==ae.path)),Ne(ze=>ze.filter(Je=>Je.path!==ae.path)),L.has(ae.path)&&y?.(ae.path)}catch(ze){const Je=ze instanceof Error?ze.message:String(ze);window.alert(q("fileTree.deleteFileFailed",{message:Je}))}finally{gt(null)}}},[yt,y,L,q]);b.useEffect(()=>{if(!e||!ee)return;if(Z){ke(!1);return}if(sr.getState().directoryCache.has(e)){ke(!1);return}let ae=!1;const ze=new AbortController;return ke(!0),je(null),r1(e,ze.signal,fe,"load_file_tree_root",`file-tree-root:${e}`,Qe,e).then(Je=>{if(ae)return;const Rt=Ym(Je.entries);Oe(!!Je.truncated),Be(e,Rt)}).catch(Je=>{ae||qm(Je)||je(Je instanceof Error?Je.message:"Failed to load directory")}).finally(()=>{ae||ke(!1)}),()=>{ae=!0,ze.abort(),um(`file-tree-root:${e}`)}},[Z,ne,e,Qe,Be,fe,ee,Ce,we]),b.useEffect(()=>{if(!pt||!Z){_e(!1),Fe(null),Le([]),Ne([]),ye(null);return}let ae=!1;const ze=new AbortController,Je=new Set;_e(!0),Fe(null),Le([]),Ne([]),le(Ge?HQ:N5),ye({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const Rt=`file-search:${pt}:${++Ft.current}`;return O8(pt,E.trim(),Mt=>{if(!ae){if(Mt.engine&&ye(ir=>({truncated:ir?.truncated??!1,total:ir?.total??0,engine:Mt.engine,limited:Mt.limited??ir?.limited??!1,done:ir?.done??!1})),Mt.entries?.length){const ir=Mt.entries.filter(Ut=>Je.has(Ut.path)?!1:(Je.add(Ut.path),!0));ir.length>0&&(Le(Ut=>[...Ut,...Ym(ir)]),ye(Ut=>Ut?{...Ut,total:Je.size}:{truncated:!1,total:Je.size,engine:"rg",limited:!1,done:!1}))}if(Mt.contentEntries?.length){const ir=Mt.contentEntries.filter(Ut=>Je.has(Ut.path)?!1:(Je.add(Ut.path),!0));ir.length>0&&(Ne(Ut=>[...Ut,...ir]),ye(Ut=>Ut?{...Ut,total:Je.size}:{truncated:!1,total:Je.size,engine:"rg",limited:!1,done:!1}))}Mt.done&&ye(ir=>({truncated:!!Mt.truncated,total:typeof Mt.total=="number"?Mt.total:Je.size,engine:Mt.engine??ir?.engine??"rg",limited:!!Mt.limited,done:!0}))}},ze.signal,fe,Q,Rt,{excludePatterns:Pt,caseSensitive:P.caseSensitive,wholeWord:P.wholeWord,regex:P.regex}).catch(Mt=>{ae||qm(Mt)||(Fe(Mt instanceof Error?Mt.message:"Failed to search files"),Le([]),Ne([]),ye(null))}).finally(()=>{ae||_e(!1)}),()=>{ae=!0,ze.abort(),um(Rt)}},[pt,hr,Ge,E,Z,Q,P.caseSensitive,P.regex,P.wholeWord,fe]),b.useEffect(()=>{if(!Z)return;const ae=At.current;if(!ae)return;const ze=Ge?xe.length:Ue.length,Je=Ge?D5:R5,Rt=new IntersectionObserver(Mt=>{Mt.some(ir=>ir.isIntersecting)&&le(ir=>Math.min(ir+Je,ze))},{rootMargin:"160px 0px"});return Rt.observe(ae),()=>Rt.disconnect()},[Z,Ue.length,xe.length,Ge]);const _r=b.useMemo(()=>{if(!ne)return;if(!Z)return r?ne.filter(ze=>ze.type==="directory"):ne;const ae=sr.getState().directoryCache;return ne.filter(ze=>(!r||ze.type==="directory")&&G1(ze,Z,ae))},[r,Z,ne]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:q("fileTree.noWorkingDir")});if($e||!ee)return s.jsx(MQ,{});if(Z&&Ge){const ae=te?.total??xe.length,ze=xe.slice(0,ot),Je=ot<xe.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(j5,{count:ae,loading:Ee,engine:te?.engine,limited:te?.limited,scope:pt,content:!0}),re?s.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[q("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:re})]}):Ee&&xe.length===0?s.jsx(Fu,{label:q("fileTree.searching"),className:"py-8"}):xe.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:q("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[te?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:q("fileTree.searchTruncatedHint",{count:te.total})}),ze.map(Rt=>s.jsx(VQ,{entry:Rt,rootPath:pt,selectedFilePath:I,query:E.trim(),onContentMatchSelect:$,onPathReference:n,getReferenceText:a,onReferenceCopied:l,insertedReferenceKey:c,copiedReferenceKey:h},Rt.path)),s.jsx("div",{ref:At,className:"py-2 text-center text-[11px] text-muted-foreground",children:Je?s.jsx("button",{type:"button",onClick:()=>le(Rt=>Math.min(Rt+D5,xe.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:q("fileTree.loadMoreSearchResults",{shown:ze.length,total:xe.length})}):Ee?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(En,{size:10,className:"animate-spin"}),q("fileTree.searchStillRunning")]}):ze.length>0?s.jsx("span",{children:q("fileTree.showingSearchResults",{shown:ze.length,total:ae})}):null})]})]})}if(Z){const ae=te?.total??Ue.length,ze=Ue.slice(0,ot),Je=ot<Ue.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(j5,{count:ae,loading:Ee,engine:te?.engine,limited:te?.limited,scope:pt,content:!1}),Ee&&Ue.length===0?s.jsx(Fu,{label:q("fileTree.searching"),className:"py-8"}):re?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:re}):Ue.length===0?s.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:q("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[te?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:q("fileTree.searchTruncatedHint",{count:te.total})}),ze.map(Rt=>s.jsx(zQ,{node:Rt,rootPath:pt,onFileSelect:t,onPathReference:n,getReferenceText:a,onReferenceCopied:l,onDirectoryRoot:p,onSearchFromDirectory:g,onDirectoryPinToggle:x,onFilePinToggle:y,pinnedPaths:L,selectedFilePath:I,insertedReferenceKey:c,copiedReferenceKey:h,onFileDeleteRequest:Zt,deletingFilePath:yt},Rt.path)),s.jsx("div",{ref:At,className:"py-2 text-center text-[11px] text-muted-foreground",children:Je?s.jsx("button",{type:"button",onClick:()=>le(Rt=>Math.min(Rt+R5,Ue.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:q("fileTree.loadMoreSearchResults",{shown:ze.length,total:Ue.length})}):Ee?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(En,{size:10,className:"animate-spin"}),q("fileTree.searchStillRunning")]}):ze.length>0?s.jsx("span",{children:q("fileTree.showingSearchResults",{shown:ze.length,total:ae})}):null})]})]})}return se?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:se}):!ne||ne.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:q("fileTree.emptyDir")}):!_r||_r.length===0?s.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:q("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[de&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:q("fileTree.truncatedHint")}),_r.map(ae=>s.jsx(UQ,{node:ae,gitIgnoreRoot:e,depth:0,onFileSelect:t,directoriesOnly:r,onPathReference:n,getReferenceText:a,onReferenceCopied:l,onDirectoryRoot:p,onSearchFromDirectory:g,onDirectoryPinToggle:x,onFilePinToggle:y,onOpenInFileBrowser:A,canOpenInFileBrowser:v,pinnedPaths:L,selectedFilePath:I,queryLower:Z,insertedReferenceKey:c,copiedReferenceKey:h,onDirectoryDropFiles:W,onFileDeleteRequest:Zt,deletingFilePath:yt,revealedDirectoryPath:B?.path},ae.path))]})}function Km(e){return e.trim().replace(/\/+$/,"")||"/"}function YQ(e){const t=Km(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function _f({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:l}){const{t:c}=Hr(),h={hint:n?.hint??c("sidebar.directoryPickerHint"),cancel:n?.cancel??c("common.cancel"),confirm:n?.confirm??c("sidebar.useThisFolder"),close:n?.close??c("common.close"),parent:n?.parent??c("rightSidebar.parentFolder")},[p,g]=b.useState(()=>Km(t));return b.useEffect(()=>{e&&g(Km(t))},[t,e]),b.useEffect(()=>{if(!e)return;const x=document.body.style.overflow,y=A=>{A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),a())};return document.body.style.overflow="hidden",document.addEventListener("keydown",y,!0),()=>{document.body.style.overflow=x,document.removeEventListener("keydown",y,!0)}},[a,e]),e?ki.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:a,"aria-label":h.cancel}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(wA,{size:15})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:r}),s.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:h.hint})]}),s.jsx("button",{type:"button",autoFocus:!0,onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":h.close,children:s.jsx(Wn,{size:15})})]}),s.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:p==="/",onClick:()=>g(YQ(p)),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-30","aria-label":h.parent,children:s.jsx($b,{size:14})}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-foreground",title:p,children:p})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",children:s.jsx(qQ,{rootPath:p,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:g,selectedFilePath:t||null})}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[s.jsx("button",{type:"button",onClick:a,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:h.cancel}),s.jsxs("button",{type:"button",onClick:()=>l(p),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[s.jsx(ci,{size:13}),h.confirm]})]})]})]}),document.body):null}const ZQ=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:_f},Symbol.toStringTag,{value:"Module"})),Xm="termdock:new-session-commands:v1",Gl="__saved_command__:";function oh(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(Gl)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function du(){try{const e=JSON.parse(localStorage.getItem(Xm)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function KQ({directories:e,tmuxAvailable:t,options:r,agents:n,selectedAgent:a,detecting:l,resumeHistory:c,resumeHistoryLoading:h,resumeHistoryPendingId:p,resumeHistoryError:g,onRefreshAgents:x,onSelectAgent:y,onLaunchAgent:A,onResumeHistory:v,onRemoveResumeHistory:L,onClose:I,onOptionsChange:E,additionalContent:R,footerActions:P}){const{t:Q,locale:$}=Hr(),W=b.useRef(null),[B,q]=b.useState(a),[ne,Be]=b.useState(!1),[fe,X]=b.useState(!1),[Qe,Pe]=b.useState(du),[ue,Ce]=b.useState(()=>oh(du())),[tt,we]=b.useState(null),[ce,$e]=b.useState("idle"),ke=fe?"__custom__":B?.slug??"__terminal__",se=B?.command??"",je=fe?Qe.__custom__??Qe.__terminal__??"":B?Qe[ke]??se:"",de=()=>{const te=je.trim()||se;if(!(fe&&!te))try{const ye={...du(),[ke]:te};if(fe){for(const ot of oh(du()))ye[Gl+ot]=ot;ye[Gl+te]=te}localStorage.setItem(Xm,JSON.stringify(ye)),Ce(oh(ye)),fe&&we(te),$e("saved")}catch{$e("error")}},Oe=()=>{if(tt)try{const te=du();for(const[ye,ot]of Object.entries(te))(ye.startsWith(Gl)||ye==="__custom__"||ye==="__terminal__")&&ot.trim()===tt&&delete te[ye];localStorage.setItem(Xm,JSON.stringify(te)),Ce(oh(te)),Pe(ye=>({...ye,__custom__:""})),we(null),$e("idle")}catch{$e("error")}},Ee=()=>{const te=je.trim()||se;fe&&!te||(de(),A(B,te))},_e=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),re=fe?tt?Gl+tt:"__custom__":B?.slug??"__terminal__",Fe=te=>{$e("idle");const ye=te.startsWith(Gl)?te.slice(Gl.length):null;we(ye),X(te==="__custom__"||ye!==null),(ye!==null||te==="__custom__")&&Pe(ot=>({...ot,__custom__:ye??""})),q(n.find(ot=>ot.slug===te)??null)},wt=fe?tt??Q("sidebar.customStartupCommand"):B?.displayName??"Terminal",Xe=a?.displayName??"Terminal",ee=!fe&&(B===null?a===null:a?.slug===B.slug);b.useEffect(()=>{const te=ye=>{ye.key!=="Escape"||ye.defaultPrevented||ne||I()};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[ne,I]),b.useEffect(()=>{if(ne)return;const te=ye=>{ye.target instanceof Node&&(W.current?.contains(ye.target)||ye.target instanceof Element&&ye.target.closest("[data-sidebar-composer-popover]")?.getAttribute("data-sidebar-composer-popover")===W.current?.id||ye.target instanceof Element&&ye.target.closest('[aria-controls="sidebar-launch-options"]')||I())};return document.addEventListener("pointerdown",te,!0),()=>document.removeEventListener("pointerdown",te,!0)},[ne,I]);const Ue=te=>{E({...r,cwd:te}),Be(!1)},Le=te=>new Intl.DateTimeFormat($==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(te));return s.jsxs("section",{ref:W,id:"sidebar-launch-options",className:`absolute inset-x-3 bottom-3 z-30 flex flex-col overflow-hidden rounded-2xl border border-border bg-surface shadow-[0_18px_50px_var(--app-shadow-strong),0_4px_14px_var(--app-shadow-soft)] animate-slide-down ${P?"max-h-[min(70svh,42rem,calc(100%_-_4.5rem))]":"max-h-[min(56svh,36rem,calc(100%_-_4.5rem))]"}`,"aria-label":Q("sidebar.newSessionComposerTitle"),children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground",children:s.jsx(Eo,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:Q("sidebar.newSessionComposerTitle")})})]}),s.jsx("button",{type:"button",onClick:I,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":Q("common.close"),children:s.jsx(Wn,{size:14})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 pb-1",children:[s.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:Q("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(te=>s.jsx("button",{type:"button",disabled:te==="tmux"&&!t,onClick:()=>E({...r,mode:te}),"aria-pressed":r.mode===te,title:te==="tmux"?Q(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===te?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:Q(te==="shell"?"sidebar.newShell":"sidebar.newTmux")},te))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Q("sidebar.startupCommand")}),s.jsx("button",{type:"button",onClick:x,disabled:l,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground disabled:opacity-50",title:Q("sidebar.detectAgents"),"aria-label":Q("sidebar.detectAgents"),children:s.jsx(vn,{size:12,className:l?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":Q("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(te=>{const ye=!fe&&B?.slug===te.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":ye,onClick:()=>Fe(te.slug),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${ye?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Ic,{agent:te,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:te.displayName}),a?.slug===te.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:Q("sidebar.defaultAgent")})]},te.slug)}),ue.map(te=>{const ye=fe&&tt===te;return s.jsxs("button",{type:"button",role:"radio","aria-checked":ye,onClick:()=>Fe(Gl+te),title:te,className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 transition ${ye?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(wc,{size:10,className:"shrink-0"}),s.jsx("span",{className:"max-w-[9rem] truncate font-mono text-[10px]",children:te})]},te)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":re==="__terminal__",onClick:()=>Fe("__terminal__"),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${re==="__terminal__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Eo,{size:11,className:"shrink-0"}),s.jsx("span",{children:"Terminal"}),a===null&&s.jsx("span",{className:"ml-0.5 text-[9px] font-normal text-muted-foreground",children:Q("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":re==="__custom__",onClick:()=>Fe("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${re==="__custom__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Ys,{size:10,className:"shrink-0"}),s.jsx("span",{children:Q("sidebar.addStartupCommand")})]})]}),!ee&&!fe&&s.jsxs("div",{className:"mt-1 flex min-h-8 items-center justify-between gap-2 px-0.5 text-[10px]",children:[s.jsx("span",{className:"truncate text-muted-foreground",children:Q("sidebar.currentDefaultAgent",{name:Xe})}),s.jsx("button",{type:"button",onClick:()=>y(B),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:Q("sidebar.makeDefault")})]}),ce==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:Q("sidebar.saveStartupCommandFailed")}),(B||fe)&&s.jsxs("details",{open:fe&&!tt||void 0,className:"group/command mt-0.5",children:[s.jsxs("summary",{className:"ml-auto flex min-h-8 w-fit cursor-pointer list-none items-center gap-1 rounded-md px-1 text-[10px] text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50 [&::-webkit-details-marker]:hidden",children:[Q(fe&&!tt?"sidebar.customStartupCommand":"sidebar.changeStartupCommand"),s.jsx(ol,{size:11,className:"transition-transform group-open/command:rotate-180"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx("label",{htmlFor:"new-session-command",className:"sr-only",children:Q("sidebar.startupCommand")}),B&&je!==se&&s.jsx("button",{type:"button",onClick:()=>{Pe(te=>({...te,[ke]:se})),$e("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:Q("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:je,onChange:te=>{Pe(ye=>({...ye,[ke]:te.target.value})),$e("idle")},placeholder:se||Q("sidebar.startupCommandPlaceholder"),autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoComplete:"off",className:"min-h-10 w-full rounded-lg border-0 bg-surface px-3 font-mono text-[16px] text-foreground outline-none ring-1 ring-inset ring-border transition focus:ring-primary/50 sm:text-[11px]"}),s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2","aria-live":"polite",children:[fe&&tt&&s.jsxs("button",{type:"button",onClick:Oe,className:"mr-auto inline-flex min-h-9 items-center gap-1 rounded-md px-2 text-[10px] text-muted-foreground transition hover:text-destructive","aria-label":Q("sidebar.deleteStartupCommand"),children:[s.jsx(Zs,{size:11}),Q("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:de,disabled:ce==="saved"||fe&&!je.trim(),className:"min-h-8 rounded-md px-2 text-[10px] font-medium text-primary transition hover:bg-primary/10 disabled:cursor-default disabled:opacity-50",children:Q(ce==="saved"?"sidebar.startupCommandSaved":"sidebar.saveStartupCommand")})]}),s.jsx("p",{className:"mb-2 mt-1.5 px-0.5 text-[10px] leading-relaxed text-muted-foreground",children:Q(B?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},tt??ke),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:Q("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>Be(!0),className:"mt-1 flex min-h-11 w-full items-center gap-2 rounded-lg border border-transparent bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary",children:[s.jsx(Ec,{size:12,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${r.cwd?"":"text-muted-foreground"}`,children:r.cwd||Q("sidebar.directoryPlaceholder")})]}),_e.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":Q("sidebar.recentDirectories"),children:_e.map(te=>s.jsx("button",{type:"button",onClick:()=>Ue(te),title:te,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:$u(te)||te},te))}),(c.length>0||g)&&s.jsxs("details",{className:"mt-1",children:[s.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[s.jsx(wc,{size:11}),s.jsx("span",{className:"flex-1",children:Q("sidebar.resumeHistory")}),h&&s.jsx(En,{size:10,className:"animate-spin"}),c.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:Q("sidebar.resumeHistoryCount",{n:c.length})}),s.jsx(ol,{size:11})]}),c.length>0&&s.jsx("div",{className:"mt-1 divide-y divide-border overflow-hidden rounded-lg border border-border bg-surface",children:c.slice(0,6).map(te=>{const ye=p===te.id;return s.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>v(te),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":Q("sidebar.resumeHistoryAction",{title:te.title}),children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:ye?s.jsx(En,{size:13,className:"animate-spin"}):s.jsx(Ic,{agent:te.agent,size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:te.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[te.agent.displayName," · ",Le(te.closedAt)]})]}),s.jsx(Yb,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>L(te.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":Q("sidebar.resumeHistoryRemove",{title:te.title}),children:[s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),s.jsx(Zs,{size:12})]})]},te.id)})}),g&&s.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:g})]}),R]}),s.jsxs("div",{className:"shrink-0 bg-surface px-3 pb-3 pt-2",children:[s.jsxs("button",{type:"button",onClick:Ee,disabled:fe&&!je.trim(),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground transition hover:brightness-110 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40","aria-label":Q("sidebar.launchSessionWith",{name:wt}),children:[B?s.jsx(Ic,{agent:B,size:15}):s.jsx(Eo,{size:14}),s.jsx("span",{className:"truncate",children:Q("sidebar.launchSessionWith",{name:wt})})]}),P]}),s.jsx(_f,{open:ne,initialPath:r.cwd?.trim()||_e[0]||"/",title:Q("sidebar.chooseDirectory"),onCancel:()=>Be(!1),onConfirm:Ue})]})}const Wv="termdock:new-session-agent:v1";function XQ(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(Wv)||"null");return!e||typeof e.slug!="string"||typeof e.command!="string"?null:{slug:e.slug,command:e.command,displayName:typeof e.displayName=="string"?e.displayName:e.slug,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(t=>typeof t=="string"):void 0,accentColor:typeof e.accentColor=="string"?e.accentColor:"var(--muted-foreground)",icon:typeof e.icon=="string"?e.icon:null,isPlugin:e.isPlugin===!0,iconMode:e.iconMode==="native"?"native":e.iconMode==="mask"?"mask":void 0,iconVersion:typeof e.iconVersion=="number"?e.iconVersion:void 0}}catch{return null}}function Vp(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Wv,JSON.stringify(e))}catch{}}function JQ(e,t){return e?t.find(r=>r.slug===e)??null:null}function eP(){const[e,t]=b.useState(XQ),[r,n]=b.useState([]),[a,l]=b.useState(!0),c=b.useCallback(async()=>{l(!0);try{const[p,g]=await Promise.all([ec(),Nb()]),x=JQ(p.newSessionAgentSlug,g);n(g),t(x),Vp(x)}finally{l(!1)}},[]);b.useEffect(()=>{const p=()=>{c().catch(()=>{})};if(performance.getEntriesByName("termdock:startup:initial-viewport-presented").length>0){p();return}return window.addEventListener("termdock:initial-viewport-presented",p,{once:!0}),()=>window.removeEventListener("termdock:initial-viewport-presented",p)},[c]);const h=b.useCallback(async p=>{const g=e;t(p),Vp(p);try{await fa({newSessionAgentSlug:p?.slug??null})}catch(x){throw t(g),Vp(g),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:c,selectAgent:h}}function Gv(e,t){const r=e.trim().split(/\n\s*\n/),n=c=>{const h=r.findIndex(g=>c.test(g.trim()));return h<0?"":r[h].trim().replace(c,"").trim()||r[h+1]?.trim()||""},a=t?.trim()||n(/^(?:#{1,6}\s*)?(?:结论|Summary|Conclusion|结果摘要)(?:[::]\s*|\s*$)/i),l=n(/^(?:#{1,6}\s*)?(?:限制与变更|限制|Limitations)(?:[::]\s*|\s*$)/i);return{summary:a||e.trim(),limitations:a?l:"",condensed:!!a&&a!==e.trim(),explicit:!!t?.trim()}}function Nh({inputKey:e,paneKey:t,label:r,value:n,onChange:a,active:l=!0,disabled:c=!1,required:h,autoFocus:p,placeholder:g,className:x,onUploadChange:y}){const A=b.useId(),v=b.useRef(null),L=b.useRef(null),I=b.useRef({value:n,onChange:a,onUploadChange:y});I.current={value:n,onChange:a,onUploadChange:y};const[E,R]=b.useState(0),[P,Q]=b.useState(""),$=b.useRef(Promise.resolve());b.useEffect(()=>{const X=v.current;X&&X.setSelectionRange(X.value.length,X.value.length)},[e]);const W=()=>({value:I.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),B=(X,Qe=W())=>{I.current.onChange(Pe=>Pe!==Qe.value?Pe+(Pe&&!/\s$/.test(Pe)?`
129
+ `:"")+X:Pe.slice(0,Qe.start)+X+Pe.slice(Qe.end))};b.useEffect(()=>{if(!l)return;const X=Rb(Qe=>B(Qe.replace(/\r\n?/g,`
130
+ `)),e,!!t,t);return t||Eu(e),X},[l,e,t]);const q=()=>{const X=Ou();return`${location.origin}:${X?.targetPeerId??""}:${X?.serviceOrigin??""}`},ne=X=>{const Qe=W(),Pe=q(),ue=I.current.onUploadChange;Q(""),R(Ce=>Ce+1),ue?.(1),$.current=$.current.then(async()=>{try{if(Pe!==q())throw new Error("目标服务已切换,请重新添加附件");const Ce=await X();if(Pe!==q())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(Ce)?B(Ce.map(bc).join(" ")+" ",Qe):Ce&&B(Ce,Qe)}catch(Ce){const tt=Ce instanceof Error?Ce.message:"附件准备失败,请重试";Q(tt.includes("Upload did not return")?"附件上传未返回完整路径,请重试":tt)}finally{R(Ce=>Ce-1),ue?.(-1)}})},Be=async X=>X.length===1&&X[0].type.startsWith("image/")?[await i3(X[0])]:l3(X),fe=X=>{const Qe=X.clipboardData.files.length?Array.from(X.clipboardData.files):Array.from(X.clipboardData.items??[]).filter(Ce=>Ce.kind==="file").map(Ce=>Ce.getAsFile()).filter(Ce=>Ce!==null),Pe=X.clipboardData.getData("text/plain"),ue=ao();!ue?.readClipboardFiles&&!Qe.length&&Pe||!ue&&!Qe.length&&typeof navigator.clipboard?.read!="function"||(X.preventDefault(),ne(async()=>{const Ce=q();let tt;if(ue?.readClipboardFiles)try{const we=await o3();if(we.paths.length||we.files.length)return[...we.paths,...await Be(we.files)]}catch(we){if(we instanceof Mu)throw we;tt=we}if(Ce!==q())throw new Error("目标服务已切换,请重新粘贴");if(Qe.length)return Be(Qe);if(Pe)return Pe;if(typeof navigator.clipboard?.read=="function"){const we=await navigator.clipboard.read(),ce={read:async()=>we},$e=await a3(ce);if($e.length)return Be($e);const ke=await Uh(ce);if(ke)return Be([ke]);for(const se of we)if(se.types.includes("text/plain"))return(await se.getType("text/plain")).text()}else{const we=await Uh();if(we)return Be([we])}if(tt)throw tt;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>Eu(e),onPointerDownCapture:()=>Eu(e),children:[s.jsx("label",{htmlFor:A,className:"block text-xs text-muted-foreground",children:r}),s.jsx("textarea",{ref:v,id:A,value:n,required:h,disabled:c,autoFocus:p,"aria-describedby":E||P?`${A}-status`:void 0,placeholder:g,className:x,onChange:X=>a(X.target.value),onPaste:fe,onDragOver:X=>{!c&&X.dataTransfer.types.includes("Files")&&X.preventDefault()},onDrop:X=>{const Qe=Array.from(X.dataTransfer.files);!Qe.length||c||(X.preventDefault(),X.stopPropagation(),ne(()=>Be(Qe)))}}),s.jsxs("div",{className:"flex min-h-9 items-center gap-2",children:[s.jsx("input",{ref:L,type:"file",multiple:!0,hidden:!0,"aria-label":`选择附件:${r}`,onChange:X=>{const Qe=Array.from(X.target.files??[]);X.target.value="",Qe.length&&ne(()=>Be(Qe))}}),s.jsxs("button",{type:"button","aria-label":`添加附件:${r}`,title:"添加附件",disabled:c,className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>L.current?.click(),children:[s.jsx(XA,{size:14}),"附件"]}),E>0?s.jsxs("span",{id:`${A}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(vn,{size:12,className:"animate-spin"}),"正在准备附件…"]}):P?s.jsx("span",{id:`${A}-status`,role:"alert",className:"break-words text-xs text-destructive",children:P}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function tP(e,t){const r=Math.floor(Math.max(0,t-e)/6e4);return r<1?"刚刚更新":r<60?`${r} 分钟前更新`:r<1440?`${Math.floor(r/60)} 小时前更新`:r<10080?`${Math.floor(r/1440)} 天前更新`:`${new Date(e).toLocaleDateString([],{month:"numeric",day:"numeric"})} 更新`}function gc(e){return e.status!=="open"?"done":Sl(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const vl=[{id:"backlog",label:"待开始",icon:zu,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:Oh,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:a1,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:Uu,hint:"验收后的结果会保留在这里"}];function rP({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:l,navigation:c,settings:h}){const p=b.useRef(null),g=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),A=b.useRef(null),[v,L]=b.useState(Date.now);b.useEffect(()=>{const ee=setInterval(()=>L(Date.now()),3e4);return()=>clearInterval(ee)},[]);const[I,E]=b.useState(!1);b.useEffect(()=>{const ee=new ResizeObserver(Ue=>{const Le=Ue[0].contentRect.width;E(Le>=760),Le!==y.current&&Le<760&&g.current&&(g.current.scrollLeft=vl.findIndex(te=>te.id===x.current)*g.current.clientWidth),y.current=Le});return p.current&&ee.observe(p.current),()=>ee.disconnect()},[]);const[R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[P,Q]=b.useState(()=>vl.some(ee=>ee.id===R?.lane)?R.lane:e.some(ee=>gc(ee)==="attention")?"attention":e.some(ee=>gc(ee)==="running")?"running":e.some(ee=>gc(ee)==="backlog")?"backlog":"done");x.current=P;function $(ee,Ue=!0){Q(ee);const Le=g.current;if(!Le||!Le.clientWidth)return;A.current=ee;const te=vl.findIndex(ot=>ot.id===ee)*Le.clientWidth,ye=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Le.scrollTo?Le.scrollTo({left:te,behavior:Ue&&!ye?"smooth":"auto"}):Le.scrollLeft=te}b.useEffect(()=>{I||$(x.current,!1)},[I]);const[W,B]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[q,ne]=b.useState(typeof R?.query=="string"?R.query:""),[Be,fe]=b.useState(R?.closed===!0),[X,Qe]=b.useState(!!R?.query),[Pe,ue]=b.useState(!1),[Ce,tt]=b.useState(!1),we=b.useRef(null),ce=b.useRef(null);b.useEffect(()=>{if(!Ce)return;we.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const ee=Le=>{we.current?.contains(Le.target)||tt(!1)},Ue=Le=>{Le.key==="Escape"&&(Le.preventDefault(),Le.stopPropagation(),tt(!1),ce.current?.focus())};return document.addEventListener("pointerdown",ee),document.addEventListener("keydown",Ue),()=>{document.removeEventListener("pointerdown",ee),document.removeEventListener("keydown",Ue)}},[Ce]);const $e=b.useRef(null),ke=b.useRef(null),se=b.useRef(null),je=b.useRef(null);b.useEffect(()=>{X&&$e.current?.focus()},[X]),b.useEffect(()=>{if(!Pe)return;se.current?.querySelector("select")?.focus();const ee=Le=>{se.current?.contains(Le.target)||ue(!1)},Ue=Le=>{Le.key==="Escape"&&(Le.preventDefault(),Le.stopPropagation(),ue(!1),(I?je:ce).current?.focus())};return document.addEventListener("pointerdown",ee),document.addEventListener("keydown",Ue),()=>{document.removeEventListener("pointerdown",ee),document.removeEventListener("keydown",Ue)}},[Pe]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:P,scope:W,query:q,closed:Be}))}catch{}},[a,P,W,q,Be]);const de=t?e.find(ee=>ee.id===t):void 0,Oe=de?gc(de):void 0;b.useEffect(()=>{Oe&&$(Oe,!1)},[t,Oe]);const Ee=e.filter(ee=>ee.workflow?.kind==="goal"),_e=e.filter(ee=>(Be||ee.status!=="closed")&&(W==="all"||ee.id===W||ee.parentTaskId===W)&&(!q.trim()||`${ee.title} ${ee.spec} ${ee.attempts.map(Ue=>n(ee,Ue.assignee)).join(" ")}`.toLocaleLowerCase().includes(q.trim().toLocaleLowerCase()))),re=+(W!=="all")+Number(Be),Fe="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",wt=s.jsxs("div",{className:`relative flex min-w-0 items-center ${I?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(Vl,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:$e,"aria-label":"搜索任务",type:"search",value:q,onChange:ee=>ne(ee.target.value),onKeyDown:ee=>{ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),q?ne(""):(Qe(!1),requestAnimationFrame(()=>(I?ke:ce).current?.focus())))},placeholder:"搜索任务或负责人",className:"min-h-11 w-full rounded-lg border border-border/20 bg-transparent pl-9 pr-9 text-xs outline-none focus:border-primary"}),s.jsx("button",{type:"button","aria-label":"关闭搜索",className:"absolute right-0 flex min-h-11 w-9 items-center justify-center text-muted-foreground",onClick:()=>{ne(""),Qe(!1),requestAnimationFrame(()=>(I?ke:ce).current?.focus())},children:s.jsx(Wn,{size:14})})]}),Xe=s.jsxs("div",{"aria-label":"任务筛选",className:"absolute right-0 top-full z-30 mt-1 w-64 space-y-3 rounded-xl border border-border/30 bg-surface p-3 shadow-xl",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"目标范围"}),s.jsxs("select",{"aria-label":"按目标查看",value:W,onChange:ee=>B(ee.target.value),className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 px-3 text-xs text-foreground",children:[s.jsx("option",{value:"all",children:"所有目标"}),Ee.map(ee=>s.jsx("option",{value:ee.id,children:ee.title},ee.id))]})]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:Be,onChange:ee=>fe(ee.target.checked)}),"含已关闭"]}),re>0&&s.jsx("button",{type:"button",className:"min-h-11 w-full rounded-lg text-xs text-primary hover:bg-surface-2",onClick:()=>{B("all"),fe(!1)},children:"清除筛选"})]});return s.jsxs("div",{ref:p,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:I?void 0:se,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:I?s.jsxs(s.Fragment,{children:[c&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:c}),X?wt:s.jsx("button",{ref:ke,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${Fe} ${c?"":"ml-auto"}`,onClick:()=>Qe(!0),children:s.jsx(Vl,{size:16})}),s.jsxs("div",{ref:se,className:"relative shrink-0",children:[s.jsxs("button",{ref:je,type:"button","aria-label":re?`筛选任务,${re} 项已启用`:"筛选任务","aria-expanded":Pe,className:`${Fe} ${re?"text-primary":""}`,onClick:()=>ue(ee=>!ee),children:[s.jsx(hm,{size:15}),s.jsx("span",{children:"筛选"}),re>0&&s.jsx("span",{className:"tabular-nums text-primary",children:re})]}),Pe&&Xe]}),h,l&&s.jsx("div",{className:"shrink-0",children:l})]}):s.jsxs(s.Fragment,{children:[c&&s.jsx("div",{className:"mr-auto flex min-w-0 items-center",children:c}),l&&s.jsx("div",{className:"shrink-0",children:l}),s.jsxs("div",{ref:we,className:"relative shrink-0",children:[s.jsxs("button",{ref:ce,type:"button","aria-label":"更多看板操作","aria-expanded":Ce,className:`${Fe} ${re||q.trim()?"text-primary":""}`,onClick:()=>{tt(ee=>!ee),ue(!1)},children:[s.jsx(ll,{size:18}),re>0&&s.jsx("span",{className:"text-[10px]",children:re})]}),Ce&&s.jsxs("div",{"aria-label":"看板更多操作",className:"absolute right-0 top-full z-30 mt-1 flex w-48 flex-col rounded-xl border border-border/30 bg-surface p-1 shadow-xl",onClick:()=>tt(!1),children:[s.jsxs("button",{ref:ke,type:"button","aria-label":"搜索任务",className:`${Fe} justify-start px-3`,onClick:()=>Qe(!0),children:[s.jsx(Vl,{size:16}),"搜索任务"]}),s.jsxs("button",{ref:je,type:"button","aria-label":re?`筛选任务,${re} 项已启用`:"筛选任务",className:`${Fe} justify-start px-3`,onClick:()=>ue(!0),children:[s.jsx(hm,{size:15}),"筛选任务",re>0&&s.jsx("span",{className:"ml-auto",children:re})]}),h&&s.jsx("div",{className:"border-t border-border/15 pt-1 [&>button]:w-full [&>button]:justify-start",children:h})]})]}),X&&wt,Pe&&Xe]})}),s.jsx("nav",{hidden:I,"aria-label":"看板阶段",className:`${I?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:vl.map(ee=>s.jsxs("button",{type:"button","aria-pressed":P===ee.id,className:`min-h-11 rounded-lg px-1 text-xs ${P===ee.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>$(ee.id),children:[ee.label,s.jsx("span",{className:"ml-1 tabular-nums",children:_e.filter(Ue=>gc(Ue)===ee.id).length})]},ee.id))}),s.jsxs("div",{ref:I?void 0:g,"data-kanban-scroll":!0,onPointerDown:()=>{A.current=null},onWheel:()=>{A.current=null},"aria-label":I?void 0:"可左右滑动的任务看板",onScroll:I?void 0:ee=>{if(ee.target!==ee.currentTarget||!ee.currentTarget.clientWidth)return;const Ue=A.current;if(Ue){const te=vl.findIndex(ye=>ye.id===Ue)*ee.currentTarget.clientWidth;if(Math.abs(ee.currentTarget.scrollLeft-te)>2)return;A.current=null}const Le=Math.max(0,Math.min(vl.length-1,Math.round(ee.currentTarget.scrollLeft/ee.currentTarget.clientWidth)));Q(vl[Le].id)},className:I?"min-h-0 flex-1 overflow-auto pb-3":"min-h-0 flex-1 snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[I&&s.jsx("div",{"aria-label":"看板列标题",className:"sticky top-0 z-10 grid min-w-[1000px] grid-cols-4 gap-4 border-b border-border/15 bg-[var(--chrome-bg)] pb-2",children:vl.map(ee=>{const Ue=ee.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${ee.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(Ue,{size:15}),ee.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:_e.filter(Le=>gc(Le)===ee.id).length})]},ee.id)})}),s.jsx("div",{className:I?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:vl.map(ee=>{const Ue=_e.filter(Le=>gc(Le)===ee.id).sort((Le,te)=>te.updatedAt-Le.updatedAt);return s.jsx("section",{"aria-label":`${ee.label}任务`,"aria-hidden":!I&&P!==ee.id?!0:void 0,ref:Le=>{Le&&(Le.inert=!I&&P!==ee.id)},style:I?void 0:{width:"100%"},className:I?"min-w-0 px-1":"h-full min-w-0 shrink-0 snap-start snap-always overflow-y-auto overscroll-y-contain px-1 pb-3 pt-2",children:s.jsxs("div",{className:"space-y-2",children:[Ue.map(Le=>{const te=Le.attempts.find(pt=>pt.id===Le.activeAttemptId),ye=Le.decisions.find(pt=>pt.status==="pending"),ot=A0(Le),le=Le.status==="open"?Le.automationIssue:void 0,xe=ee.id==="attention",Ne=ye?"回答问题":le?"查看原因与处理":ot==="等待你验收"?"查看结果并验收":ot==="需要你确认方案"?"查看并确认方案":"查看任务并处理",yt=Le.artifacts.filter(pt=>pt.kind==="result"&&pt.attemptId===Le.activeAttemptId).at(-1),gt=Le.events.filter(pt=>pt.kind==="revise"&&pt.source==="user"&&pt.attemptId===Le.activeAttemptId&&(!yt||pt.createdAt>=yt.createdAt)).at(-1),At=ye?.question||le||gt?.content||yt?.summary||(te?.report?.content?Gv(te.report.content).summary:""),Ft=e.find(pt=>pt.id===Le.parentTaskId),Z=Le.children?.filter(pt=>pt.status==="accepted").length??0,Ge=Le.children?.filter(pt=>pt.status!=="closed").length??0;return s.jsxs("button",{type:"button","data-task-id":Le.id,"aria-pressed":t===Le.id,className:`block w-full rounded-xl border bg-surface p-4 text-left shadow-sm transition hover:border-primary/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${t===Le.id?"border-primary/60":le?"border-destructive/35":"border-border/20"}`,onClick:()=>r(Le.id),children:[Ft&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:Ft.title}),s.jsx("span",{className:"block break-words text-sm font-medium leading-6 text-foreground",children:Le.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${le?"text-destructive":xe?"text-primary":"text-muted-foreground"}`,children:[le&&s.jsx(n1,{size:13,className:"shrink-0"}),ot]}),At&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:At}),xe&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${le?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[Ne,s.jsx(Mb,{size:14})]}),Ge>0&&s.jsxs("span",{className:"mt-3 block text-[11px] text-muted-foreground",children:[Z,"/",Ge," 子任务已验收"]}),s.jsxs("span",{className:"mt-4 flex items-center justify-between gap-2 border-t border-border/10 pt-3 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:te?n(Le,te.assignee):Le.scheduledAssignee?n(Le,Le.scheduledAssignee):"未分派"}),s.jsx("time",{dateTime:new Date(Le.updatedAt).toISOString(),title:`更新于 ${new Date(Le.updatedAt).toLocaleString()}`,className:"shrink-0",children:tP(Le.updatedAt,v)})]})]},Le.id)}),!Ue.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:q||W!=="all"?"没有匹配的任务":e.length?"暂无任务":ee.hint})]})},ee.id)})})]})]})}const kl=Jl((e,t)=>({views:{},details:{},ensureDetail:(r,n)=>{const a=t().details[r];return a||(e(l=>({details:{...l.details,[r]:n}})),n)},updateDetail:(r,n,a)=>e(l=>{const c=l.details[r];if(!c)return l;const h=typeof a=="function"?a(c[n]):a;return Object.is(c[n],h)?l:{details:{...l.details,[r]:{...c,[n]:h}}}}),ensure:(r,n)=>{const a=t().views[r];return a||(e(l=>({views:{...l.views,[r]:n}})),n)},update:(r,n,a)=>e(l=>{const c=l.views[r];if(!c)return l;const h=typeof a=="function"?a(c[n]):a;return Object.is(c[n],h)?l:{views:{...l.views,[r]:{...c,[n]:h}}}})}));function lh(e,t){return r=>kl.getState().update(e,t,r)}function qp(e,t){return r=>kl.getState().updateDetail(e,t,r)}const nP=b.lazy(()=>Tc(()=>Promise.resolve().then(()=>ZQ),void 0).then(e=>({default:e.DirectoryPickerDialog}))),sP=b.lazy(()=>Tc(()=>import("./CollaborationTaskContent-C01GXOEq.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),ta="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-[13px] transition disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Vs="w-full min-h-11 rounded-lg border border-border/30 bg-surface-2 px-3 py-2 text-sm text-foreground outline-none focus:border-primary",sl=`${ta} bg-primary text-primary-foreground`,ea=`${ta} bg-surface-2 text-foreground hover:bg-surface-2/80`,iP={created:"创建任务",assigned:"分派",report:"成员报告",question:"提出问题",answer:"用户回答","submit-plan":"提交方案",review:"提交评审","request-review":"请求独立评审","approve-plan":"用户确认方案",accepted:"用户验收",revise:"要求修改",comment:"补充说明",coordinator:"协调者变更",close:"关闭",reopen:"重新打开",scheduled:"等待自动分派",coordinate:"协调说明","child-update":"子任务更新","review-passed":"独立评审通过","review-blocked":"评审受阻","automation-blocked":"自动安排受阻",pause:"暂停安排",resume:"继续安排",retry:"继续协调"},f0=e=>`${e.serviceId}:${e.sessionId}`,La=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function il(e,t){try{const r=JSON.parse(localStorage.getItem(e)??"null");return r===null||t!==null&&(typeof r!=typeof t||Array.isArray(r)!==Array.isArray(t))?t:r}catch{return t}}function ro(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const ku={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]};function aP(e){const t={...ku,...il(e,ku)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(ku).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?ku:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function oP({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:l,board:c=!1,boardNavigation:h,boardSettings:p,paneKey:g,agents:x=[],defaultCwd:y,onTeamReady:A}){const v=`termdock:tasks:${location.origin}:${e.id}`,[L,I]=b.useState([]),[E,R]=b.useState(null),[P]=b.useState(()=>kl.getState().ensure(v,{draft:aP(`${v}:draft`),selectedId:il(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:Q,mobileDetail:$,creating:W,draft:B}=kl(Y=>Y.views[v]??P),q=lh(v,"selectedId"),ne=lh(v,"mobileDetail"),Be=lh(v,"creating"),fe=lh(v,"draft"),[X,Qe]=b.useState(!1),[Pe,ue]=b.useState(!1),Ce=b.useRef(null),tt=b.useRef(null);b.useEffect(()=>{const Y=Ce.current;if(!Y)return;const st=new ResizeObserver(xt=>Qe(xt[0].contentRect.width>=(c?1100:760)));return st.observe(Y),()=>st.disconnect()},[c]);const[we,ce]=b.useState(!1),[$e,ke]=b.useState(null),se=Db(),[je,de]=b.useState(0),[Oe,Ee]=b.useState(null),[_e,re]=b.useState(!1),[Fe,wt]=b.useState(0),Xe=Y=>wt(st=>Math.max(0,st+Y)),[ee,Ue]=b.useState("");b.useEffect(()=>{if(!ee)return;const Y=setTimeout(()=>Ue(""),5e3);return()=>clearTimeout(Y)},[ee]);const[Le,te]=b.useState("open"),[ye,ot]=b.useState(""),le=b.useRef(!1),xe=b.useRef(!0),Ne=b.useRef(new Map),yt=b.useRef(!1),gt=e.sessionIds.flatMap(Y=>{const st=t.find(xt=>xt.sessionId===Y);return st?[st]:[]}),At=gt.map(Y=>({...Y,name:dm(Y,gt)})),Ft=B.coordinator||il(`${v}:lead`,""),Z=At.find(Y=>Y.sessionId===Ft)?.sessionId||At.find(Y=>Y.agent)?.sessionId||At[0]?.sessionId||"",Ge=At.filter(Y=>Y.sessionId!==Z&&Y.agent).map(Y=>Y.sessionId),[pt,Pt]=b.useState(!1),[hr,Zt]=b.useState(!1),[_r,ae]=b.useState(()=>il(`${v}:agent`,x[0]?.slug??"")),[ze,Je]=b.useState(()=>il(`${v}:cwd`,At[0]?.cwd??y??""));b.useEffect(()=>{!_r&&x[0]&&ae(x[0].slug)},[x,_r]);const Rt=!At.find(Y=>Y.sessionId===Z)?.agent||!Ge.length,Mt=!!B.spec.trim()&&(Rt?!e.federated&&!!x.find(Y=>Y.slug===_r)&&!!ze.trim():!0),[ir,Ut]=b.useState(null),We=L.find(Y=>Y.id===Q)??null,br=E?.id===Q?E:null;b.useEffect(()=>(xe.current=!0,()=>{xe.current=!1}),[]),b.useEffect(()=>{ro(`${v}:draft`,B)},[v,B]),b.useEffect(()=>{ro(`${v}:selected`,Q)},[v,Q]),b.useEffect(()=>{const Y=xt=>{const Gt=xt.detail;Gt?.groupId===e.id&&(ro(`${v}:open-task`,null),q(Gt.taskId),ne(!0),Be(!1),te("all"),Ze())};window.addEventListener("open-collaboration-task",Y);const st=il(`${v}:open-task`,null);return st&&(q(st),ne(!0),te("all"),ro(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",Y)},[e.id]),b.useEffect(()=>{if(!r||!We||E?.id===We.id&&E.revision===We.revision)return;let Y=!1;return U8(We.id).then(st=>{Y||(R(st.task),ke(null))}).catch(st=>{Y||ke(st instanceof Error?st.message:"任务详情加载失败")}),()=>{Y=!0}},[r,We?.id,We?.revision,E?.id,E?.revision,je]);const Ze=async()=>{if(!yt.current){yt.current=!0;try{const Y=await Ib(e.id);xe.current&&(I(Y.tasks),ce(!0),ke(null),de(st=>st+1))}catch(Y){xe.current&&ke(Y instanceof Error?Y.message:"任务加载失败")}finally{yt.current=!1}}};b.useEffect(()=>{if(!r)return;Ze();const Y=()=>{!document.hidden&&navigator.onLine!==!1&&Ze()},st=setInterval(Y,2500);return document.addEventListener("visibilitychange",Y),window.addEventListener(Bh,Y),window.addEventListener("pageshow",Y),()=>{clearInterval(st),document.removeEventListener("visibilitychange",Y),window.removeEventListener(Bh,Y),window.removeEventListener("pageshow",Y)}},[r,e.id]);const Dt=Y=>{const st=JSON.stringify(Y),xt=il(`${v}:request`,null);let Gt=Ne.current.get(st)??(xt?.fingerprint===st?xt.key:void 0);return Gt||(Gt=crypto.randomUUID(),Ne.current.set(st,Gt)),ro(`${v}:request`,{fingerprint:st,key:Gt}),Gt},nt=Y=>{Ne.current.delete(JSON.stringify(Y)),ro(`${v}:request`,null)},_t=async(Y,st)=>{if(_e||le.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};le.current=!0,re(!0),Ee(null),Ue("");let xt={...st,expectedRevision:Y.revision};if(["comment","revise"].includes(st.kind)){const Gt=il(`${v}:request`,null);try{const[Gr,Fr]=JSON.parse(Gt?.fingerprint??"null"),{expectedRevision:ur,...tn}=Fr;Gr===Y.id&&JSON.stringify(tn)===JSON.stringify(st)&&(xt=Fr)}catch{}}try{const Gt=await W8(Y.id,{...xt,idempotencyKey:Dt([Y.id,xt])});return nt([Y.id,xt]),s0.getState().refresh(),xe.current&&(I(Gr=>Gr.map(Fr=>Fr.id===Gt.task.id?Gt.task:Fr)),R(Gt.task),Ue(["comment","revise"].includes(st.kind)?"":st.kind==="answer"?"回答已保存,服务端继续投递。":st.kind==="accept"?"已验收此版本结果。":"记录已保存。")),{ok:!0}}catch(Gt){const Gr=Gt instanceof Error?Gt.message:"操作失败";return Gr.includes("任务已更新")&&nt([Y.id,xt]),xe.current&&(Ee(["comment","revise"].includes(st.kind)?null:Gr),Ze()),{ok:!1,error:Gr}}finally{le.current=!1,xe.current&&re(!1)}},Qr=async Y=>{if(Y.preventDefault(),_e||Fe>0||(B.mode==="goal"?!Mt:!B.title.trim()||!B.spec.trim())||le.current)return;le.current=!0,re(!0),Ee(null);const st=B.mode==="goal",xt={groupId:e.id,title:B.title.trim()||B.spec.trim().split(`
131
+ `)[0].slice(0,100),spec:B.spec,constraints:B.constraints,acceptance:B.acceptance,assigneeSessionId:st?void 0:B.assignee||void 0,coordinatorSessionId:st?Z:B.coordinator||void 0,parentTaskId:st?void 0:B.parent||void 0,dependsOn:st?[]:B.dependencies,managed:st,isolated:B.isolated,reviewerSessionIds:st?Ge:void 0};try{if(st&&Rt){Zt(!0);const Gr=ir??await z8(e.id,{agentSlug:_r,cwd:ze.trim()});Zt(!1),Ut(Gr),xt.coordinatorSessionId=Gr.coordinatorSessionId,xt.reviewerSessionIds=Gr.reviewerSessionIds,ro(`${v}:agent`,_r),ro(`${v}:cwd`,ze.trim())}const{task:Gt}=await H8({...xt,idempotencyKey:Dt(xt)});nt(xt),xe.current&&(I(Gr=>[Gt,...Gr.filter(Fr=>Fr.id!==Gt.id)]),q(Gt.id),ne(!0),R(Gt),st&&ro(`${v}:lead`,xt.coordinatorSessionId),Ut(null),A?.(),fe(ku),Be(!1),te("open"),ot(""),Ue(st?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(Gt){xe.current&&Ee(Gt instanceof Error?Gt.message:"创建失败")}finally{le.current=!1,xe.current&&(re(!1),Zt(!1))}},yr=(Y,st)=>{if(!st)return"用户";const xt=Y.memberSessions[f0(st)];return At.find(Gt=>Gt.sessionId===xt)?.name??t.find(Gt=>Gt.sessionId===xt)?.name??"暂不可用的成员"},Nt=L.filter(Y=>(Le==="all"?!0:Le==="archive"?Y.status!=="open":Y.status==="open")&&(Le==="all"||Le==="attention"||Y.workflow?.kind!=="step")&&(Le!=="attention"||Sl(Y))&&(!ye.trim()||`${Y.title} ${Y.spec} ${Y.attempts.map(st=>yr(Y,st.assignee)).join(" ")}`.toLowerCase().includes(ye.trim().toLowerCase()))),Nn=L.filter(Sl).length;b.useEffect(()=>{a?.(Nn)},[Nn,a]);const Zr=!!We&&(c?$:X||$),lt=()=>{Be(!1),requestAnimationFrame(()=>tt.current?.focus())},gr=Y=>{kl.getState().updateDetail(`${v}:${Y}`,"view","overview"),q(Y),ne(!0),Ue("")},Pr=L.filter(Sl).filter(Y=>!ye.trim()||`${Y.title} ${Y.spec} ${Y.attempts.map(st=>yr(Y,st.assignee)).join(" ")}`.toLowerCase().includes(ye.trim().toLowerCase())),be=(Y,st=!1)=>{const xt=Y.attempts.find(ur=>ur.id===Y.activeAttemptId),Gt=Y.children?.filter(ur=>ur.status==="accepted").length??0,Gr=Y.children?.filter(ur=>ur.status!=="closed").length??0,Fr=st?Y.decisions.find(ur=>ur.status==="pending")?.question:xt?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":Q===Y.id,className:`group flex min-h-11 w-full items-start gap-3 rounded-xl p-3 text-left transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${Q===Y.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>gr(Y.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${st||Y.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:st?s.jsx(a1,{size:16}):Y.status==="accepted"?s.jsx(Uu,{size:16}):s.jsx(zu,{size:16})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:Y.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${st?"text-primary":"text-muted-foreground"}`,children:A0(Y)}),Fr&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:Fr}),Gr>0&&s.jsxs("span",{className:"mt-2 flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"flex gap-1","aria-hidden":"true",children:(Y.children??[]).filter(ur=>ur.status!=="closed").slice(0,8).map(ur=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${ur.status==="accepted"?"bg-primary":"bg-border/30"}`},ur.id))}),Gt,"/",Gr," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:[xt?yr(Y,xt.assignee):"尚未分派"," · ",La(Y.updatedAt)]})]}),s.jsx(lo,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},Y.id)},Er=[],at=new Set([Q]);let en=We?.parentTaskId;for(;en&&!at.has(en);){at.add(en);const Y=L.find(st=>st.id===en);if(!Y)break;Er.unshift(Y),en=Y.parentTaskId}const Te=()=>{const Y=Array.from(Ce.current?.querySelectorAll("button[data-task-id]")??[]).find(st=>st.dataset.taskId===Q);ne(!1),requestAnimationFrame(()=>{Y&&!Y.closest("[hidden]")?Y.focus():tt.current?.focus()})},Lt=W||!c&&we&&L.length===0;return s.jsxs("section",{ref:Ce,"aria-label":"协作任务",className:c?"relative flex h-full min-h-0 min-w-0 flex-col gap-2":"space-y-5",children:[c&&(Lt||!we)&&h&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 pb-2",children:[h,s.jsx("div",{className:"ml-auto",children:p})]}),(Oe||$e&&se==="ready"&&!Qh($e))&&s.jsxs("div",{role:"alert",className:"flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[s.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[Oe||$e,!Oe&&we?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:ta,onClick:()=>Oe?Ee(null):void Ze(),children:[s.jsx(vn,{size:14}),Oe?"关闭提示":"重试"]})]}),$e&&Qh($e)&&!c&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"正在恢复任务同步,现有记录和草稿已保留"}),ee&&s.jsx("p",{role:"status",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-primary",children:ee}),Lt?s.jsxs("form",{onSubmit:Y=>{Qr(Y)},className:`mx-auto w-full max-w-xl space-y-4 ${c?"overflow-auto px-1 py-5":""}`,onKeyDown:Y=>{Y.key==="Escape"&&W&&(Y.preventDefault(),Y.stopPropagation(),_e||lt())},children:[s.jsxs("header",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-foreground",children:B.mode==="goal"?"一起完成什么?":"新建手动任务"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:B.mode==="goal"?"交给协调者拆分,你在这里看交付、回答问题。":"选择负责人,保留分派和验收记录。"})]}),(L.length>0||c)&&s.jsx("button",{type:"button","aria-label":"取消创建,保留草稿",className:`${ta} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:_e,onClick:lt,children:s.jsx(Wn,{size:16})})]}),B.mode==="task"&&s.jsx(tl,{label:"任务标题",children:s.jsx("input",{className:Vs,required:!0,maxLength:200,value:B.title,onChange:Y=>fe(st=>({...st,title:Y.target.value})),placeholder:"要完成什么?"})}),s.jsx(Nh,{paneKey:g,inputKey:`${v}:spec`,active:r&&Lt,label:B.mode==="goal"?"协作目标":"目标与交付要求",className:`${Vs} ${Rt&&B.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:W,required:!0,disabled:_e,value:B.spec,onUploadChange:Xe,onChange:Y=>fe(st=>({...st,spec:typeof Y=="function"?Y(st.spec):Y})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),B.mode==="goal"&&Rt?s.jsxs("fieldset",{disabled:_e||!!ir,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:"首次开始时配置 Agent"}),s.jsx(tl,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Vs,value:_r,onChange:Y=>ae(Y.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(Y=>s.jsx("option",{value:Y.slug,children:Y.displayName},Y.slug))]})}),s.jsxs(tl,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Vs} min-w-0 flex-1`,value:ze,onChange:Y=>Je(Y.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:ea,onClick:()=>Pt(!0),children:"浏览目录"})]}),pt&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(nP,{open:!0,initialPath:ze.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>Pt(!1),onConfirm:Y=>{Je(Y),Pt(!1)}})})]}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"开始时配置协调者与执行/评审成员,后续目标复用。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",l&&s.jsx("button",{type:"button",className:ea,onClick:l,children:"管理成员"})]}),!x.length&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["尚未检测到可启动的 Agent。安装后刷新,或从成员设置复用现有 Agent。",l&&s.jsx("button",{type:"button",className:ea,onClick:l,children:"管理成员"})]})]}):B.mode==="goal"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"协调者"}),s.jsx("select",{"aria-label":"协调者",className:`${Vs} min-w-0 flex-1`,value:Z,onChange:Y=>fe(st=>({...st,coordinator:Y.target.value})),children:At.map(Y=>s.jsxs("option",{value:Y.sessionId,disabled:!Y.agent,children:[Y.name,Y.agent?"":"(需要启动 Agent)"]},Y.sessionId))})]}):s.jsx(tl,{label:"分派给",children:s.jsxs("select",{className:Vs,value:B.assignee,onChange:Y=>fe(st=>({...st,assignee:Y.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),At.map(Y=>s.jsx("option",{value:Y.sessionId,children:Y.name},Y.sessionId))]})}),s.jsxs("details",{className:"border-y border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:["验收标准与更多设置",(B.acceptance||B.constraints)&&s.jsx("span",{className:"text-primary",children:"已补充"})]}),s.jsxs("div",{className:"space-y-3 pb-4",children:[s.jsx(tl,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Vs} min-h-20 resize-y`,value:B.acceptance,onChange:Y=>fe(st=>({...st,acceptance:Y.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(tl,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Vs} min-h-20 resize-y`,value:B.constraints,onChange:Y=>fe(st=>({...st,constraints:Y.target.value})),placeholder:"必须保留什么?哪些操作需要先问你?"})}),B.mode==="goal"?s.jsxs("label",{className:"flex min-h-11 items-start gap-2 text-xs leading-5 text-muted-foreground",children:[s.jsx("input",{type:"checkbox",className:"mt-1",checked:B.isolated,onChange:Y=>fe(st=>({...st,isolated:Y.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(tl,{label:"协调者",children:s.jsxs("select",{className:Vs,value:B.coordinator,onChange:Y=>fe(st=>({...st,coordinator:Y.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),At.map(Y=>s.jsx("option",{value:Y.sessionId,children:Y.name},Y.sessionId))]})}),s.jsx(tl,{label:"父任务",children:s.jsxs("select",{className:Vs,value:B.parent,onChange:Y=>fe(st=>({...st,parent:Y.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),L.filter(Y=>!Y.workflow).map(Y=>s.jsx("option",{value:Y.id,children:Y.title},Y.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),L.filter(Y=>Y.status!=="closed").map(Y=>s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-foreground",children:[s.jsx("input",{type:"checkbox",checked:B.dependencies.includes(Y.id),onChange:st=>fe(xt=>({...xt,dependencies:st.target.checked?[...xt.dependencies,Y.id]:xt.dependencies.filter(Gt=>Gt!==Y.id)}))}),Y.title]},Y.id))]})]}),s.jsx("button",{type:"button",className:`${ta} text-muted-foreground hover:bg-surface-2`,onClick:()=>fe(Y=>({...Y,mode:Y.mode==="goal"?"task":"goal"})),children:B.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${sl} w-full`,disabled:_e||Fe>0||(B.mode==="goal"?!Mt:!B.title.trim()||!B.spec.trim()),children:[_e?s.jsx(vn,{size:14,className:"animate-spin"}):s.jsx(Nu,{size:14}),_e?hr?"正在准备成员…":"提交中…":B.mode==="goal"?"开始协作":B.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:B.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):c&&we?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"sr-only",children:"任务看板"}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-5",children:[s.jsx("div",{hidden:Zr,className:`${Zr?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(rP,{navigation:h,settings:p,action:s.jsxs("button",{ref:tt,type:"button",className:sl,disabled:_e,onClick:()=>Be(!0),children:[s.jsx(Ys,{size:14}),"新目标"]}),storage:v,tasks:L,selectedId:Zr?Q:null,name:yr,onSelect:gr})}),Zr&&s.jsxs("aside",{"aria-label":"任务详情",className:"mx-auto flex min-h-0 min-w-0 w-full max-w-[1040px] flex-col",children:[s.jsx("nav",{"aria-label":"任务位置",className:"mb-2 shrink-0",children:s.jsxs("ol",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx("li",{className:"shrink-0",children:s.jsx("button",{type:"button","aria-label":"返回看板",title:"查看此协作组的任务看板",className:`${ta} px-2 hover:bg-surface-2`,onClick:Te,children:"看板"})}),Er.map(Y=>s.jsxs("li",{className:"flex min-w-0 flex-1 items-center gap-1 sm:max-w-xs sm:flex-none",children:[s.jsx(lo,{"aria-hidden":"true",size:12,className:"shrink-0"}),s.jsx("button",{type:"button","aria-label":`查看${Y.workflow?.kind==="goal"?"目标":"父任务"}:${Y.title}`,title:`查看${Y.workflow?.kind==="goal"?"目标":"父任务"}:${Y.title}`,className:`${ta} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>gr(Y.id),children:s.jsxs("span",{className:"truncate",children:[Y.workflow?.kind==="goal"?"目标":"父任务",":",Y.title]})})]},Y.id)),s.jsxs("li",{"aria-current":"page",className:"flex shrink-0 items-center gap-1",children:[s.jsx(lo,{"aria-hidden":"true",size:12}),s.jsx("span",{className:"px-2",children:We?.parentTaskId?"子任务详情":We?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:br?s.jsx(B5,{reader:!0,paneKey:g,active:r,task:br,tasks:L,members:At,busy:_e,name:Y=>yr(br,Y),act:Y=>_t(br,Y),storage:v,onSelectTask:gr,onOpenSession:async Y=>{const st=t.find(xt=>xt.sessionId===br.memberSessions[f0(Y)]);if(!st){Ee("成员会话暂不可用,任务历史已保留。");return}try{await n(st)}catch(xt){Ee(xt instanceof Error?xt.message:"无法打开终端")}}},br.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!we&&!L.length?s.jsxs("div",{role:"status",className:"space-y-3 py-8",children:[s.jsx("p",{className:"text-center text-xs text-muted-foreground",children:$e?"任务暂时无法加载,请重试。":"正在加载目标…"}),!$e&&[0,1,2].map(Y=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},Y))]}):s.jsxs(s.Fragment,{children:[(!Zr||X)&&s.jsxs("header",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:"协作目标"}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[L.filter(Y=>Y.status==="open"&&Y.workflow?.kind!=="step").length," 个进行中 · ",L.filter(Y=>Y.status==="accepted"&&Y.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:tt,type:"button",className:sl,disabled:_e,onClick:()=>Be(!0),children:[s.jsx(Ys,{size:14}),"新目标"]})]}),s.jsxs("div",{className:X&&Zr?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!Zr||X)&&s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{"aria-label":"任务筛选",className:`${Vs} min-w-0 flex-1 border-transparent bg-transparent`,value:Le,onChange:Y=>te(Y.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",Nn,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":Pe,className:`${ta} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{ue(Y=>!Y),ot("")},children:s.jsx(Vl,{size:16})})]}),Pe&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Vs,value:ye,onChange:Y=>ot(Y.target.value),placeholder:"搜索目标、内容或负责人"}),Le==="open"&&Pr.length>0&&s.jsxs("section",{"aria-label":"需要你处理",className:"rounded-xl bg-surface-2/40 p-1",children:[s.jsxs("h4",{className:"flex items-center justify-between px-3 pb-1 pt-3 text-xs font-medium text-primary",children:["需要你处理",s.jsx("span",{className:"rounded-md bg-primary/15 px-2 py-0.5",children:Pr.length})]}),Pr.map(Y=>be(Y,!0))]}),(Le!=="open"||Nt.some(Y=>!Sl(Y))||Nt.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:Le==="attention"?"需要你处理":Le==="archive"?"已归档":Le==="all"?"全部任务":"当前目标"}),Nt.filter(Y=>Le!=="open"||!Sl(Y)).map(Y=>be(Y,Le==="attention")),!Nt.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[ye.trim()?"没有匹配的任务。":Le==="attention"?"目前没有需要你处理的任务。":Le==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(Le!=="all"||ye)&&s.jsx("button",{type:"button",className:`${ta} mt-2 text-primary`,onClick:()=>{te("all"),ot("")},children:"查看全部任务"})]})]})]}),Zr&&s.jsxs("div",{className:"min-w-0",children:[!X&&s.jsxs("button",{type:"button",className:`${ta} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>ne(!1),children:[s.jsx(jb,{size:14}),"全部目标"]}),br?s.jsx(B5,{paneKey:g,active:r,task:br,tasks:L,members:At,busy:_e,name:Y=>yr(br,Y),act:Y=>_t(br,Y),storage:v,onSelectTask:gr,onOpenSession:async Y=>{const st=t.find(xt=>xt.sessionId===br.memberSessions[f0(Y)]);if(!st){Ee("成员会话暂不可用,任务历史已保留。");return}try{await n(st)}catch(xt){Ee(xt instanceof Error?xt.message:"无法打开终端")}}},br.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function tl({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),t]})}function B5({reader:e=!1,active:t,paneKey:r,task:n,tasks:a,members:l,name:c,busy:h,act:p,storage:g,onOpenSession:x,onSelectTask:y}){const[A,v]=b.useState(""),[L,I]=b.useState(""),[E,R]=b.useState(""),[P,Q]=b.useState(!1),[$,W]=b.useState(null),B=b.useRef(!1),q=b.useRef(!0);b.useEffect(()=>(q.current=!0,()=>{q.current=!1}),[]);const ne=b.useRef(null),Be=b.useRef(null);b.useEffect(()=>{!e&&$&&$.state!=="pending"&&t&&requestAnimationFrame(()=>Be.current?.scrollIntoView({block:"nearest"}))},[$]);const fe=b.useRef(null),[X,Qe]=b.useState(0),Pe=Z=>Qe(Ge=>Math.max(0,Ge+Z)),ue=b.useRef(null);b.useEffect(()=>{ue.current?.focus()},[]);const Ce=`${g}:${n.id}`,[tt]=b.useState(()=>kl.getState().ensureDetail(Ce,{feedback:il(`${Ce}:feedback`,""),answers:il(`${Ce}:answers`,{}),view:"overview"})),{feedback:we,answers:ce,view:$e}=kl(Z=>Z.details[Ce]??tt),ke=qp(Ce,"feedback"),se=qp(Ce,"answers"),je=qp(Ce,"view");b.useEffect(()=>{fe.current&&(fe.current.scrollTop=0)},[$e]),b.useEffect(()=>ro(`${g}:${n.id}:answers`,ce),[g,n.id,ce]),b.useEffect(()=>ro(`${g}:${n.id}:feedback`,we),[g,n.id,we]);const de=n.attempts.find(Z=>Z.id===n.activeAttemptId),Oe=n.status==="open",Ee=n.artifacts.filter(Z=>Z.kind==="result"&&Z.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{$?.state==="saved"&&Ee?.id!==$.resultId&&W(null)},[Ee?.id,$]);const _e=n.artifacts.filter(Z=>Z.kind==="plan"&&Z.attemptId===n.activeAttemptId).at(-1),re=Ee&&n.events.some(Z=>Z.kind==="revise"&&Z.attemptId===n.activeAttemptId&&Z.createdAt>=Ee.createdAt),Fe=n.decisions.filter(Z=>Z.status==="pending"&&Z.attemptId===n.activeAttemptId),wt=n.dependsOn.some(Z=>a.find(Ge=>Ge.id===Z)?.status!=="accepted"),Xe=!n.workflow||n.artifacts.filter(Z=>Z.kind==="review"&&Z.reviewsArtifactId===Ee?.id).at(-1)?.verdict==="pass",ee=n.children??[],Ue=n.workflow?.kind==="goal"&&ee.some(Z=>!["accepted","closed"].includes(Z.status)),Le=`任务:${n.title}
132
+ 任务 ID:${n.id}
133
+ ${n.spec}
134
+ 约束:${n.constraints||"未补充"}
135
+ 验收标准:${n.acceptance||"由用户决定"}
136
+ ${de?`当前尝试:${de.id}
137
+ 负责人:${c(de.assignee)}
138
+ `:""}${n.artifacts.filter(Z=>Z.attemptId===n.activeAttemptId).map(Z=>`${Z.kind} · 版本 ${Z.id} · ${La(Z.createdAt)}
139
+ ${Z.summary?`结果摘要:${Z.summary}
140
+ `:""}${Z.content}`).join(`
141
+
142
+ `)}
143
+ ${Fe.map(Z=>`待回答:${Z.question}`).join(`
144
+ `)}`,te=()=>{const Z=URL.createObjectURL(new Blob([JSON.stringify(n,null,2)],{type:"application/json"})),Ge=document.createElement("a");Ge.href=Z,Ge.download=`termdock-task-${n.id}.json`,Ge.click(),setTimeout(()=>URL.revokeObjectURL(Z),1e3)},ye=n.events.filter(Z=>Z.kind==="coordinate").at(-1),ot=$e==="results"?n.artifacts.slice().reverse():n.artifacts.filter(Z=>Z.id===Ee?.id||Z.id===_e?.id&&n.approvedPlanArtifactId!==Z.id||Z.kind==="review"&&Z.reviewsArtifactId===Ee?.id).sort((Z,Ge)=>(Z.kind==="result"?-1:1)-(Ge.kind==="result"?-1:1)||Ge.createdAt-Z.createdAt),le=ee.filter(Z=>Z.status==="accepted").length,xe=ee.filter(Z=>Z.status!=="closed"),Ne=re?"等待新结果通过评审后可验收。":Fe.length?"回答当前问题后可验收。":wt?"依赖任务验收后可验收。":Xe?Ue?"子任务完成并通过评审后可验收。":null:"独立评审通过后可验收。",yt=()=>{je("overview"),Q(!0),requestAnimationFrame(()=>{ne.current?.scrollIntoView({block:"nearest"}),ne.current?.querySelector("textarea")?.focus()})},gt=async Z=>{if(h||X||!we.trim()||B.current)return;const Ge=we;B.current=!0,W({kind:Z,state:"pending",content:Ge,resultId:Ee?.id});const pt=await p({kind:Z,content:Ge});if(B.current=!1,pt.ok){if(ke(Pt=>Pt===Ge?"":Pt),ro(`${Ce}:feedback`,kl.getState().details[Ce]?.feedback??""),!q.current)return;W({kind:Z,state:"saved",content:Ge,resultId:Ee?.id}),e&&kl.getState().details[Ce]?.feedback===""&&Q(!1)}else q.current&&W({kind:Z,state:"error",content:Ge,error:pt.error,resultId:Ee?.id})},At=Z=>s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:Z}),children:s.jsx(sP,{content:Z})}),Ft=Z=>{const Ge=Gv(Z.content,Z.summary);return s.jsxs("section",{className:"space-y-3 rounded-xl border border-border/20 bg-surface-2/30 p-4",children:[s.jsxs("header",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h4",{className:"min-w-0 flex-1 text-sm font-semibold text-foreground",children:Z.kind==="result"?re&&Z.id===Ee?.id?"上一版结果":"交付结果":Z.kind==="plan"?n.approvedPlanArtifactId===Z.id?"已确认的方案":"方案":"独立评审"}),Z.verdict&&s.jsx("span",{className:`rounded-md px-2 py-1 text-[11px] ${Z.verdict==="pass"?"bg-primary/10 text-primary":"bg-surface-2 text-foreground"}`,children:Z.verdict==="pass"?"通过":Z.verdict==="changes"?"需要修改":"受阻"}),n.acceptedArtifactId===Z.id&&s.jsx("span",{className:"text-xs text-primary",children:n.completionMode==="reviewed"?"评审通过":"已验收"}),n.approvedPlanArtifactId===Z.id&&s.jsx("span",{className:"text-xs text-primary",children:"方案已确认"})]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[c(Z.actor)," · ",La(Z.createdAt),Z.attemptId!==n.activeAttemptId&&Z.kind!=="review"?" · 历史分派":""]}),Z.kind==="result"&&Ge.condensed?s.jsxs(s.Fragment,{children:[s.jsx("div",{"aria-label":"结果结论",className:"text-base leading-7",children:At(!Ge.explicit&&!Ge.summary.includes(`
145
+ `)?Ge.summary.replace(/([。;])\s*(?=\S)/g,`$1
146
+
147
+ `):Ge.summary)}),Ge.limitations&&s.jsxs("div",{className:"border-l-2 border-border/40 pl-3",children:[s.jsx("h5",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"适用范围与限制"}),At(Ge.limitations)]}),s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整报告与原始证据"}),s.jsx("div",{className:"space-y-3 pb-3",children:At(Z.content)})]})]}):At(Z.content),Z.evidence!==void 0&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3",children:"交付证据"}),s.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 text-[11px]",children:JSON.stringify(Z.evidence,null,2)})]}),Oe&&Z.attemptId===n.activeAttemptId&&Z.kind!=="review"&&(!e||Z.kind==="plan"||!n.workflow)&&s.jsxs("div",{className:"space-y-2 border-t border-border/15 pt-3",children:[!e&&Ee?.id===Z.id&&n.workflow?.kind!=="step"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`${sl} w-full`,disabled:h||!!Ne,onClick:()=>{p({kind:"accept",artifactId:Z.id})},children:[s.jsx(ci,{size:14}),"验收此结果"]}),Ne&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Ne})]}),_e?.id===Z.id&&n.approvedPlanArtifactId!==Z.id&&s.jsxs("button",{type:"button",className:`${sl} w-full`,disabled:h,onClick:()=>{p({kind:"approve-plan",artifactId:Z.id})},children:[s.jsx(ci,{size:14}),"确认方案并继续"]}),!n.workflow&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"请其他成员评审此版本"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"独立评审成员",className:Vs,value:L,onChange:pt=>I(pt.target.value),children:[s.jsx("option",{value:"",children:"选择独立评审成员"}),l.filter(pt=>pt.sessionId!==n.memberSessions[f0(Z.actor)]).map(pt=>s.jsx("option",{value:pt.sessionId,children:pt.name},pt.sessionId))]}),s.jsx("button",{type:"button",className:ea,disabled:h||!L||L===n.memberSessions[f0(Z.actor)],onClick:()=>{p({kind:"request-review",artifactId:Z.id,assigneeSessionId:L})},children:"请求评审"})]})]})]})]},Z.id)};return s.jsxs("article",{className:e?"flex h-full min-h-0 flex-col":"space-y-5",children:[s.jsxs("div",{ref:fe,"data-task-reader-scroll":!0,className:e?"min-h-0 flex-1 space-y-4 overflow-auto pb-5 pr-1":"contents",children:[s.jsxs("header",{className:"space-y-2",children:[!e&&n.parentTaskId&&s.jsxs("button",{type:"button",className:`${ta} -ml-2 max-w-full text-muted-foreground hover:bg-surface-2`,onClick:()=>y(n.parentTaskId),children:[s.jsxs("span",{className:"truncate",children:["所属任务:",a.find(Z=>Z.id===n.parentTaskId)?.title??"查看父任务"]}),s.jsx(Mb,{size:13,className:"shrink-0"})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("h3",{ref:ue,tabIndex:-1,className:"break-words text-lg font-semibold leading-7 text-foreground outline-none",children:n.title}),s.jsxs("span",{className:`inline-flex items-center gap-2 rounded-md px-2 py-1 text-xs ${Sl(n)?"bg-primary/10 text-primary":"bg-surface-2 text-muted-foreground"}`,children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),A0(n)]})]}),!Fe.length&&!Ee&&n.spec.trim()!==n.title.trim()&&s.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words text-sm leading-6 text-muted-foreground",children:n.spec}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:n.workflow?.kind==="goal"?`协调者 · ${c(n.coordinator)}`:de?`负责人 · ${c(de.assignee)}`:"尚未分派"}),de&&s.jsxs("button",{type:"button",className:`${ta} px-2 text-muted-foreground hover:bg-surface-2 hover:text-primary`,onClick:()=>{x(de.assignee)},children:[s.jsx(ld,{size:13}),"打开终端"]})]}),n.replica&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"此记录由来源服务同步,回答与决定会送回来源服务。"})]}),s.jsx("nav",{"aria-label":"任务详情",className:"flex gap-4 border-b border-border/20",children:[["overview",e&&Ee?"结果":"概览"],["results",e?"历史交付":`交付${n.artifacts.length?` ${n.artifacts.length}`:""}`],["activity","动态"]].map(([Z,Ge])=>s.jsx("button",{type:"button","aria-pressed":$e===Z,className:`min-h-11 border-b-2 px-1 text-xs font-medium transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${$e===Z?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,onClick:()=>je(Z),children:Ge},Z))}),$e==="overview"&&s.jsxs(s.Fragment,{children:[(()=>{const Z=n.events.filter(hr=>hr.kind==="revise"&&hr.source==="user"&&hr.attemptId===n.activeAttemptId).at(-1);if(!Z)return null;const Ge=n.deliveries.find(hr=>hr.id===Z.deliveryId),pt=n.outbox.find(hr=>hr.id===Z.deliveryId),Pt=Ee&&Ee.createdAt>Z.createdAt;return s.jsxs("section",{"aria-label":"最近跟进",className:"space-y-1 rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5",children:[s.jsx("p",{className:"font-medium text-primary",children:Pt?Xe?"新结果已通过独立评审":"新结果已交付,等待独立评审":"已要求继续跟进,等待新结果"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:Z.content}),s.jsxs("p",{className:"text-muted-foreground",children:[La(Z.createdAt),Ge?.status==="delivered"?` · 已写入${Z.target?c(Z.target):"成员"}终端${Ge.deliveredAt?` · ${La(Ge.deliveredAt)}`:""}`:["failed","expired"].includes(Ge?.status??"")||Ge?.error||pt?.lastError?" · 投递未成功,服务端继续重试":Z.deliveryId?" · 等待写入终端":" · 要求已保存"]})]})})(),Fe.map(Z=>s.jsxs("form",{className:"space-y-3 rounded-xl border border-border/30 bg-surface-2/40 p-4",onSubmit:Ge=>{Ge.preventDefault(),!h&&!X&&ce[Z.id]?.trim()&&p({kind:"answer",decisionId:Z.id,content:ce[Z.id]})},children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-primary",children:[s.jsx(a1,{size:14}),"需要你的决定"]}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-foreground",children:Z.question}),!!Z.options.length&&s.jsx("div",{className:"flex flex-col gap-2",children:Z.options.map((Ge,pt)=>s.jsxs("button",{type:"button","aria-pressed":ce[Z.id]===Ge,disabled:h,className:`${ta} justify-start text-left ${ce[Z.id]===Ge?"bg-primary/15 text-primary":"bg-surface-2 text-foreground"}`,onClick:()=>se(Pt=>({...Pt,[Z.id]:Ge})),children:[ce[Z.id]===Ge?s.jsx(ci,{size:14,className:"shrink-0"}):s.jsx(zu,{size:14,className:"shrink-0"}),s.jsx("span",{className:"break-words",children:Ge})]},pt))}),s.jsx(Nh,{paneKey:r,inputKey:`${Ce}:answer:${Z.id}`,active:t,label:"你的回答",className:`${Vs} min-h-20 resize-y`,required:!0,disabled:h,value:ce[Z.id]??"",onUploadChange:Pe,onChange:Ge=>se(pt=>({...pt,[Z.id]:typeof Ge=="function"?Ge(pt[Z.id]??""):Ge})),placeholder:"选择建议,或写下你的决定…"}),s.jsxs("button",{className:`${sl} w-full`,disabled:h||X>0||!ce[Z.id]?.trim(),children:[s.jsx(Nu,{size:14}),"回复并继续"]}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[La(Z.createdAt)," · 回答会保存在任务记录中"]})]},Z.id)),n.automationIssue&&Oe&&s.jsxs("section",{role:"alert",className:"space-y-3 rounded-xl bg-destructive/10 p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-destructive",children:"需要处理一个异常"}),s.jsx("p",{className:"whitespace-pre-wrap break-words text-xs leading-5 text-foreground",children:n.automationIssue}),s.jsxs("button",{type:"button",className:ea,disabled:h,onClick:()=>{p({kind:"retry"})},children:[s.jsx(vn,{size:13}),"重试并继续协调"]})]}),n.workflow?.paused&&Oe&&s.jsxs("section",{className:"space-y-2 rounded-xl bg-surface-2 p-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"后续安排已暂停,已投递的终端工作继续保留。"}),s.jsx("button",{type:"button",className:ea,disabled:h,onClick:()=>{p({kind:"resume"})},children:"继续安排"})]}),ot.map(Z=>Z.kind==="review"?s.jsxs("details",{className:"rounded-lg border border-border/20 px-3",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["独立评审 · ",Z.verdict==="pass"?"通过":Z.verdict==="changes"?"要求修改":"受阻"," · ",c(Z.actor)]}),Ft(Z)]},Z.id):Ft(Z)),ye&&!Ee&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h4",{className:"flex items-center gap-2 text-xs font-medium text-foreground",children:["协调者更新",s.jsx("span",{className:"ml-auto text-[11px] font-normal text-muted-foreground",children:La(ye.createdAt)})]}),s.jsx("div",{className:"rounded-xl bg-surface-2/50 p-3",children:At(ye.content)})]}),!ye&&de?.report&&!Ee&&s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-xs font-medium text-foreground",children:["最近报告",s.jsx("span",{className:"ml-2 text-[11px] font-normal text-muted-foreground",children:La(de.report.createdAt)})]}),At(de.report.content)]}),!!ee.length&&s.jsxs("section",{className:"space-y-3",children:[s.jsxs("header",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-xs font-medium text-foreground",children:"子任务"}),s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[le,"/",xe.length," 已验收"]})]}),s.jsx("div",{className:"divide-y divide-border/15",children:ee.map(Z=>{const Ge=a.find(Pt=>Pt.id===Z.id),pt=Ge&&Sl(Ge);return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-3 rounded-lg px-1 py-3 text-left transition hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>y(Z.id),children:[Z.status==="accepted"?s.jsx(Uu,{size:16,className:"mt-0.5 shrink-0 text-primary"}):s.jsx(zu,{size:16,className:"mt-0.5 shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm leading-5 text-foreground",children:Z.title}),s.jsx("span",{className:`mt-1 block text-[11px] ${pt?"text-primary":"text-muted-foreground"}`,children:Ge?A0(Ge):Z.status==="accepted"?Z.completionMode==="reviewed"?"独立评审通过":"已验收":Z.status==="closed"?"已关闭":"等待报告"})]}),s.jsx(lo,{size:14,className:"mt-1 shrink-0 text-muted-foreground"})]},Z.id)})})]}),!!n.dependsOn.length&&s.jsxs("section",{children:[s.jsx("h4",{className:"mb-2 text-xs font-medium text-foreground",children:"依赖任务"}),n.dependsOn.map(Z=>s.jsxs("button",{type:"button",className:`${ta} w-full justify-start text-left text-muted-foreground hover:bg-surface-2`,onClick:()=>y(Z),children:[s.jsx("span",{className:"min-w-0 flex-1 break-words",children:a.find(Ge=>Ge.id===Z)?.title??Z}),s.jsx("span",{className:"shrink-0 text-[11px]",children:a.find(Ge=>Ge.id===Z)?.status==="accepted"?"已验收":"待验收"})]},Z))]}),Oe&&!de&&!n.scheduledAssignee&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2/50 p-4",children:[s.jsx(tl,{label:"分派给",children:s.jsxs("select",{className:Vs,value:A,onChange:Z=>v(Z.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),l.map(Z=>s.jsx("option",{value:Z.sessionId,children:Z.name},Z.sessionId))]})}),s.jsx("button",{type:"button",className:`${sl} w-full`,disabled:h||!A||wt,onClick:()=>{p({kind:"assign",assigneeSessionId:A})},children:"分派任务"}),wt&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"依赖任务验收后可分派。"})]}),!Fe.length&&!ye&&!de?.report&&!ot.length&&!ee.length&&s.jsxs("div",{className:"rounded-xl bg-surface-2/40 p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-foreground",children:Oe?"等待第一条更新":"任务记录已保留"}),s.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:Oe?"成员明确回复后,报告、问题和交付会出现在这里。":"可在动态中查看分派与决定。"})]})]}),$e==="results"&&s.jsx("div",{className:"space-y-4",children:ot.length?ot.map(Ft):s.jsx("p",{className:"py-8 text-center text-xs leading-5 text-muted-foreground",children:"还没有交付。方案、结果和独立评审会保存在这里。"})}),$e==="activity"&&s.jsxs("section",{"aria-label":"任务动态",children:[s.jsx("ol",{className:"space-y-5",children:n.events.slice().reverse().map(Z=>s.jsxs("li",{className:"relative border-l border-border/30 pl-4",children:[s.jsx("span",{className:"absolute -left-1 top-1 h-2 w-2 rounded-full bg-border"}),s.jsxs("p",{className:"text-xs font-medium text-foreground",children:[iP[Z.kind]??Z.kind,Z.reportStatus?` · ${Hm[Z.reportStatus]}`:""]}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[Z.source==="system"?"服务自动接续":c(Z.actor)," · ",La(Z.createdAt),Z.attemptId&&Z.attemptId!==n.activeAttemptId?" · 历史分派":""]}),s.jsx("div",{className:"mt-2",children:At(Z.content)}),Z.target&&s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["接收人:",c(Z.target)]})]},Z.id))}),!n.events.length&&s.jsx("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"还没有动态记录。"})]}),Oe&&$e!=="activity"&&(!e||!Ee)&&s.jsxs("section",{ref:ne,className:"space-y-2 border-t border-border/20 pt-4",children:[s.jsx(Nh,{paneKey:r,inputKey:`${Ce}:feedback`,active:t,label:"补充说明或修改要求",className:`${Vs} min-h-20 resize-y text-sm leading-6`,disabled:h,value:we,onUploadChange:Pe,onChange:ke,placeholder:"补充上下文,或写下需要修改的地方…"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",className:ea,disabled:h||X>0||!we.trim(),onClick:()=>{gt("comment")},children:[$?.state==="pending"&&$.kind==="comment"?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(Nu,{size:13}),$?.state==="pending"&&$.kind==="comment"?"正在发送…":"发送补充"]}),s.jsxs("button",{type:"button",className:ea,disabled:h||X>0||!de||!we.trim(),onClick:()=>{gt("revise")},children:[$?.state==="pending"&&$.kind==="revise"&&s.jsx(vn,{size:13,className:"animate-spin"}),$?.state==="pending"&&$.kind==="revise"?"正在提交…":"要求修改"]})]}),$&&s.jsx("div",{ref:Be,role:$.state==="error"?"alert":"status",className:`rounded-lg px-3 py-2 text-xs leading-5 ${$.state==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:$.state==="pending"?"正在保存,请稍候…":$.state==="error"?`未确认保存:${$.error}。内容已保留,可重试。`:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:$.kind==="comment"?"补充已保存,服务端将继续投递。":"修改要求已保存,等待新结果后可验收。"}),s.jsx("p",{className:"mt-1 line-clamp-2 whitespace-pre-wrap break-words text-foreground/80",children:$.content}),s.jsx("button",{type:"button",className:"mt-1 min-h-11 text-primary underline underline-offset-4",onClick:()=>je("activity"),children:"查看任务动态"})]})}),!$&&s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"发送补充会保留当前结果;需要更新结果时,请选择“要求修改”。"})]}),s.jsxs("details",{className:"border-t border-border/20",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"任务管理与诊断"}),s.jsxs("div",{className:"space-y-4 pb-4",children:[s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"完整目标与验收标准"}),At(n.spec),n.acceptance&&At(n.acceptance),n.constraints&&At(n.constraints)]}),n.workflow&&Oe&&s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"后续执行与评审安排"}),s.jsx("button",{type:"button",className:ea,disabled:h,onClick:()=>{p({kind:n.workflow.paused?"resume":"pause"})},children:n.workflow.paused?"继续安排":"暂停安排"})]}),n.workspace&&s.jsxs("details",{children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:"交付目录与分支"}),s.jsxs("p",{className:"select-text break-all text-xs text-foreground",children:[n.workspace.cwd,s.jsx("br",{}),n.workspace.branch]}),s.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"基于已提交代码创建;合并到原分支或发布需另行操作。"})]}),Oe&&s.jsxs(s.Fragment,{children:[de&&n.workflow?.kind!=="goal"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("select",{"aria-label":"任务负责人",className:Vs,value:A,onChange:Z=>v(Z.target.value),children:[s.jsx("option",{value:"",children:"选择负责人"}),l.map(Z=>s.jsx("option",{value:Z.sessionId,children:Z.name},Z.sessionId))]}),s.jsx("button",{type:"button",className:ea,disabled:h||!A||wt,onClick:()=>{p({kind:"assign",assigneeSessionId:A,content:we||void 0})},children:"开始新一轮分派"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:wt?"依赖任务验收后可分派。":"新分派保留旧记录,并结束旧问题的回答入口。"})]}),s.jsx(tl,{label:"协调者",children:s.jsxs("select",{className:Vs,disabled:h||n.workflow?.kind==="step",value:n.coordinator?n.memberSessions[f0(n.coordinator)]??"":"",onChange:Z=>{p({kind:"coordinator",coordinatorSessionId:Z.target.value||null})},children:[!n.workflow&&s.jsx("option",{value:"",children:"由用户协调"}),l.map(Z=>s.jsx("option",{value:Z.sessionId,children:Z.name},Z.sessionId))]})}),s.jsx("button",{type:"button",className:`${ta} text-muted-foreground hover:bg-surface-2`,disabled:h,onClick:()=>{p({kind:"close",content:we||void 0})},children:"关闭此任务"}),s.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"关闭会保留历史和成员的终端工作。"})]}),!Oe&&s.jsx("button",{type:"button",className:ea,disabled:h,onClick:()=>{p({kind:"reopen"})},children:"重新打开任务"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["投递凭证与执行尝试 · ",n.attempts.length," 轮"]}),s.jsxs("div",{className:"space-y-3 text-xs leading-5 text-muted-foreground",children:[n.outbox.map(Z=>s.jsxs("p",{className:"break-words",children:[Z.lastError?`等待重试:${Z.lastError}`:"已保存 · 等待投递",Z.messageId?` · 消息 ${Z.messageId}`:""]},Z.id)),n.attempts.map(Z=>s.jsxs("div",{children:[s.jsxs("p",{children:[Z.id===n.activeAttemptId?"当前分派":"历史分派"," · ",c(Z.assignee)," · ",La(Z.createdAt)]}),s.jsxs("p",{className:"mt-1 break-all font-mono text-[11px]",children:["尝试 ID:",Z.id]}),s.jsxs("p",{className:"mt-1",children:[Z.deliveryStatus==="delivered"?`已写入终端 · ${Z.deliveredAt?La(Z.deliveredAt):""}`:Z.deliveryStatus==="failed"||Z.deliveryStatus==="expired"?"本次消息投递未成功":"等待写入终端",Z.report?` · ${Hm[Z.report.status]}(${La(Z.report.createdAt)})`:""]})]},Z.id)),n.deliveries.filter(Z=>Z.kind!=="task").map(Z=>s.jsxs("p",{className:"break-all",children:["后续消息 ",Z.messageId," · ",Z.status==="delivered"?"已写入终端":"等待投递",Z.deliveredAt?` · ${La(Z.deliveredAt)}`:""]},Z.id)),s.jsx("p",{className:"text-[11px]",children:"投递凭证确认终端写入;报告保留成员原始陈述。"})]})]}),s.jsxs("p",{className:"select-text break-all text-[11px] text-muted-foreground",children:["任务:",n.id,s.jsx("br",{}),"来源服务:",n.ownerServiceId,s.jsx("br",{}),"版本:",n.revision]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",className:ea,onClick:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(Le)).then(()=>R("任务上下文已复制。")).catch(()=>R("复制失败,可导出任务记录。"))},children:"复制上下文"}),s.jsx("button",{type:"button",className:ea,onClick:te,children:"导出记录"}),E&&s.jsx("span",{role:"status",className:"self-center text-[11px] text-muted-foreground",children:E})]})]})]})]}),e&&Ee&&n.status!=="closed"&&s.jsxs("footer",{role:"region","aria-label":"结果验收",className:"shrink-0 space-y-2 border-t border-border/25 bg-[var(--chrome-bg)] py-3 [padding-bottom:max(0.75rem,env(safe-area-inset-bottom))]",children:[P?s.jsxs("div",{ref:ne,className:"space-y-2",children:[s.jsx(Nh,{paneKey:r,inputKey:`${Ce}:feedback`,active:t,label:"跟进要求",className:`${Vs} min-h-20 max-h-32 resize-none text-sm leading-6`,disabled:h,value:we,onUploadChange:Pe,onChange:ke,placeholder:"说明哪里不满意,或写下接下来要完成的事…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:ea,disabled:h||X>0,onClick:()=>Q(!1),children:"取消,保留草稿"}),s.jsxs("button",{type:"button",className:`${sl} ml-auto`,disabled:h||X>0||!de||!we.trim(),onClick:()=>{gt("revise")},children:[$?.state==="pending"?s.jsx(vn,{size:14,className:"animate-spin"}):s.jsx(Nu,{size:14}),$?.state==="pending"?"正在发送…":"发送并继续跟进"]})]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",className:`${ea} flex-1 sm:flex-none`,disabled:h,onClick:yt,children:we.trim()?"继续跟进 · 有草稿":"继续跟进"}),$e!=="overview"?s.jsx("button",{type:"button",className:`${sl} ml-auto flex-1 sm:flex-none`,onClick:()=>je("overview"),children:"返回当前结果"}):Oe&&n.workflow?.kind!=="step"?s.jsxs("button",{type:"button",className:`${sl} ml-auto flex-1 sm:flex-none`,disabled:h||X>0||!!Ne||$?.state==="saved"&&$.kind==="revise"&&$.resultId===Ee.id,onClick:()=>{p({kind:"accept",artifactId:Ee.id})},children:[s.jsx(ci,{size:14}),"验收此结果"]}):s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:n.status==="accepted"?n.completionMode==="reviewed"?"已通过独立评审":"已验收":"由独立评审验收"})]}),$&&s.jsx("div",{role:$.state==="error"?"alert":"status",className:`text-xs leading-5 ${$.state==="error"?"text-destructive":"text-primary"}`,children:$.state==="pending"?"正在保存跟进要求…":$.state==="error"?`未确认保存:${$.error}。内容已保留,可重试。`:"跟进要求已保存,等待新结果。"}),!P&&Oe&&Ne&&$?.state!=="saved"&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:Ne})]})]})}function lP(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?e.slice(0,10):e}function Rh(e,t){try{const r=`termdock-workbench:${window.location.origin}:${e}`;return t!==void 0&&localStorage.setItem(r,t),localStorage.getItem(r)}catch{return null}}function cP(){const e=Rh("tab");return e==="automation"||e==="search"?e:"collaboration"}const ks="w-full rounded-lg border border-border/20 bg-surface-2 px-3 py-2 text-[12px] text-foreground outline-none transition focus:border-primary/60",Jm="inline-flex min-h-7 items-center justify-center rounded-md border px-2 py-1 text-[11px] leading-4 font-medium transition",Mr="inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-40";function Q5(e){const[t,r]=b.useState(null),[n,a]=b.useState(!1),[l,c]=b.useState({}),h=b.useCallback(x=>c(y=>({...x,...y})),[]),p=b.useCallback((x,y)=>c(A=>JSON.stringify(A[x])===JSON.stringify(y)?A:{...A,[x]:y}),[]),g={drafts:l,loadDrafts:h,updateDraft:p};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(P5,{...e,...g,overlayObscured:!!t,onOpenOverlay:r,onClose:()=>{t?a(!0):e.onClose()}}),t&&s.jsx(P5,{...e,...g,overlayOnly:!0,initialFloating:t==="floating",onFloatingChange:void 0,onOpenOverlay:r,onClose:()=>{r(null),n&&e.onClose()}})]})}function P5({activeSessionId:e,initialCollaborationGroupId:t=null,initialFloating:r=!1,onFloatingChange:n,onEnterGroup:a,defaultSessionMode:l="shell",onClose:c,onNewSession:h,overlayOnly:p=!1,overlayObscured:g=!1,onOpenOverlay:x,drafts:y,loadDrafts:A,updateDraft:v}){const L=!!t,[I,E]=b.useState(r);b.useEffect(()=>{E(r)},[r]);const[R,P]=b.useState(!1),[Q,$]=b.useState(t),W=ts(Te=>Te.docks[t??"workbench"]),B=ts(Te=>Te.hosts[t??"workbench"]),[q,ne]=b.useState("docked"),[Be,fe]=b.useState(null),[X,Qe]=b.useState({x:16,y:80}),Pe=b.useRef(null),ue=b.useRef(null);b.useEffect(()=>{const Te=Pe.current;Te&&(g?(Te.contains(document.activeElement)&&(ue.current=document.activeElement),Te.inert=!0):(Te.inert=!1,ue.current?.isConnected&&ue.current.focus({preventScroll:!0}),ue.current=null))},[g]),b.useEffect(()=>{if(!p||I)return;const Te=Pe.current;Te?.querySelector('button[aria-label="收起展开视图"]')?.focus({preventScroll:!0});const Lt=Y=>{if(Y.key!=="Tab"||Y.defaultPrevented||!Te)return;const st=Array.from(Te.querySelectorAll('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], summary, [tabindex="0"]')).filter(Fr=>!Fr.closest("[hidden], [inert]")&&Fr.getClientRects().length>0),xt=st[0],Gt=st.at(-1),Gr=!Te.contains(document.activeElement);Y.shiftKey&&(document.activeElement===xt||Gr)?(Y.preventDefault(),Gt?.focus()):!Y.shiftKey&&(document.activeElement===Gt||Gr)&&(Y.preventDefault(),xt?.focus())};return document.addEventListener("keydown",Lt),()=>document.removeEventListener("keydown",Lt)},[p,I]);const[Ce]=b.useState(()=>document.createElement("div")),tt=b.useRef({x:.5,y:.5}),[we,ce]=b.useState(null),[$e,ke]=b.useState(null);b.useEffect(()=>{let Te=!1;return ec().then(Lt=>{if(Te)return;const Y=e3(Lt.collaborationPanels?.[ff()],t);Y.position&&(tt.current=Y.position),Y.size&&fe(Y.size),A(Y.drafts??{}),p||ne(Y.mode??"docked"),ce(Y)}).catch(()=>{Te||ke("面板草稿加载失败,请重新打开面板重试")}),()=>{Te=!0}},[]);const[se,je]=b.useState(null);b.useEffect(()=>{const Te=Lt=>ke(String(Lt.detail));return window.addEventListener("termdock-panel-save-error",Te),()=>{window.removeEventListener("termdock-panel-save-error",Te),p||ts.getState().setDock(t??"workbench",null)}},[]);const de=!p&&I&&q==="docked"&&!!B;b.useLayoutEffect(()=>(Ce.className=de?"h-full min-h-0 w-full min-w-0":"contents",(de?B:document.body)?.appendChild(Ce),()=>Ce.remove()),[Ce,de,B]),b.useEffect(()=>{!p&&!I&&ts.getState().setDock(t??"workbench",null)},[I]);const Oe=async Te=>{if(p||R||Te==="docked"&&!e)return;const Lt={sessionId:e,side:"right"};P(!0);try{await al({mode:Te,...Te==="docked"?{dock:Lt}:{}},t),ne(Te),ts.getState().setDock(t??"workbench",Te==="docked"?{...Lt,...L?{preferredWidth:360}:{}}:null)}catch{ke("面板布局保存失败,请重试")}finally{P(!1)}},Ee=b.useRef(!1),_e=b.useRef(null),re=b.useCallback((Te,Lt)=>{const Y=Pe.current?.getBoundingClientRect(),st=window.visualViewport,xt=(st?.offsetLeft??0)+12,Gt=(st?.offsetTop??0)+12;return{x:Math.max(xt,Math.min(Te,xt+(st?.width??window.innerWidth)-(Y?.width??440)-24)),y:Math.max(Gt,Math.min(Lt,Gt+(st?.height??window.innerHeight)-(Y?.height??340)-24))}},[]),[Fe,wt]=b.useState(()=>t?"collaboration":cP()),[Xe,ee]=b.useState(()=>new Set([Fe])),Ue=Te=>{wt(Te),ee(Lt=>new Set([...Lt,Te])),pt(null),hr(null),!t&&!p&&Rh("tab",Te)},[Le,te]=b.useState([]),[ye,ot]=b.useState([]),[le,xe]=b.useState([]),[Ne,yt]=b.useState([]),[gt,At]=b.useState([]),[Ft,Z]=b.useState(null),[Ge,pt]=b.useState(null),[Pt,hr]=b.useState(null);b.useEffect(()=>{if(!Pt)return;const Te=setTimeout(()=>hr(null),5e3);return()=>clearTimeout(Te)},[Pt]);const[Zt,_r]=b.useState("loading"),[ae,ze]=b.useState("loading"),[Je,Rt]=b.useState(null),[Mt,ir]=b.useState(null),[Ut,We]=b.useState(),[br,Ze]=b.useState(null),Dt=b.useRef(null),nt=b.useRef(null),_t=b.useRef(null),Qr=t?Ne.find(Te=>Te.id===t)??null:null,yr=b.useRef(!1);b.useEffect(()=>{if(t||Zt!=="loaded"||yr.current)return;yr.current=!0;const Te=Rh("group"),Lt=Ne.find(Y=>Y.id===Te)??Ne.find(Y=>e&&Y.sessionIds.includes(e))??Ne[0];$(Y=>Y??Lt?.id??null)},[t,Zt,Ne,e]),b.useEffect(()=>{!t&&!p&&Q&&Ne.some(Te=>Te.id===Q)&&Rh("group",Q)},[Q,Ne,t,p]);const Nt=Q?Ne.find(Te=>Te.id===Q)??null:Ne[0]??null,Nn=!!t&&Zt==="loaded"&&!Qr,Zr=!!we||!!$e,lt=!p&&I&&q==="docked"&&!!(W??we?.dock)&&!B,gr=Zr&&!lt&&!!e&&(!t||!!B||!!Nt?.sessionIds.includes(e)||!!t&&(Zt!=="loading"&&!Qr||!!$e));b.useLayoutEffect(()=>{if(!I||de||!gr)return;const Te=()=>{const Y=window.visualViewport;je(Y?.height??window.innerHeight);const st=Pe.current?.getBoundingClientRect();!st?.width||!st.height||Ee.current||Qe(re((Y?.offsetLeft??0)+12+Math.max(0,(Y?.width??window.innerWidth)-st.width-24)*tt.current.x,(Y?.offsetTop??0)+12+Math.max(0,(Y?.height??window.innerHeight)-st.height-24)*tt.current.y))},Lt=new ResizeObserver(Te);return Pe.current&&Lt.observe(Pe.current),window.addEventListener("resize",Te),window.visualViewport?.addEventListener("resize",Te),Te(),()=>{Lt.disconnect(),window.removeEventListener("resize",Te),window.visualViewport?.removeEventListener("resize",Te)}},[I,de,gr,re,we,Be]),b.useLayoutEffect(()=>{if(p)return;const Te=t??"workbench",Lt=ts.getState();if(Nn)Lt.docks[Te]&&Lt.setDock(Te,null);else if(Zr&&I&&q==="docked"&&e&&(!t||Qr)){const Y=Lt.docks[Te],st=!t||Qr?.sessionIds.includes(e)?e:gt.find(Gr=>Qr?.sessionIds.includes(Gr.sessionId)&&!m0(Gr.sessionId))?.sessionId??e,xt=Y??we?.dock??{sessionId:st,side:window.innerWidth<640?"bottom":"right"},Gt={...xt,sessionId:Qr?.sessionIds.includes(e)?e:xt.sessionId,...L?{preferredWidth:Y?.preferredWidth??360}:{}};(!Y||Gt.sessionId!==Y.sessionId||Gt.preferredWidth!==Y.preferredWidth)&&Lt.setDock(Te,Gt),L&&Y&&Gt.sessionId!==Y.sessionId&&al({dock:{sessionId:Gt.sessionId,side:Gt.side}},t).catch(()=>ke("协作位置保存失败,当前面板仍可使用"))}},[Nn,Qr,I,q,we,Zr,e,t,W,gt]);const Pr=async(Te,Lt=!1)=>{if(!(R||Te&&!Nt)){if(!p&&!Te&&!Lt&&W){x("full");return}if(p){Lt?c():(E(Te),x(Te?"floating":"full"));return}P(!0);try{await n?.(Te?Nt.id:null),E(Te),Te&&q==="docked"&&e&&ts.getState().setDock(t??"workbench",{sessionId:e,side:W?.side??we?.dock?.side??"right"}),Lt&&c()}catch(Y){pt(`常驻浮窗状态保存失败,请重试:${Y instanceof Error?Y.message:"连接失败"}`)}finally{P(!1)}}},be=b.useCallback(Te=>{yt(Te.groups),At(Te.sessions),We(Te.peers),ir(null),_r("loaded")},[]);b.useEffect(()=>Bb(be),[be]);const Er=b.useCallback(async(Te={})=>{Te.silent||pt(null),!L&&!nt.current&&(nt.current=Y8().then(Lt=>{te(Lt.automations),ot(Lt.runs),ze("loaded"),Rt(null)}).catch(Lt=>{ze("error"),Rt(Lt instanceof Error?Lt.message:"自动任务加载失败")}).finally(()=>{nt.current=null})),_t.current||(_t.current=Nb().then(Lt=>{xe(Lt),Ze(null)}).catch(()=>{Ze("Agent 命令检测失败;已有会话可继续协作。")}).finally(()=>{_t.current=null})),Dt.current||(_r(Lt=>Lt==="error"?"loading":Lt),Dt.current=Qb().then(be).catch(Lt=>{_r("error"),ir(`协作会话加载失败:${Lt instanceof Error?Lt.message:"请重试"}`)}).finally(()=>{Dt.current=null})),await Promise.all([Dt.current,nt.current])},[be,L]);b.useEffect(()=>{Er();const Te=window.setInterval(()=>{Er({silent:!0})},1e4);return()=>window.clearInterval(Te)},[Er]),b.useEffect(()=>{const Te=Lt=>{Lt.key==="Escape"&&!Lt.defaultPrevented&&!I&&c()};return window.addEventListener("keydown",Te),()=>window.removeEventListener("keydown",Te)},[c,I]);const at=Te=>{L&&Te&&Te!==t&&Ne.some(Lt=>Lt.id===Te)&&a?a(Te).catch(Lt=>pt(Lt instanceof Error?Lt.message:"无法打开工作区")):$(Te)},en=async Te=>{await yP(Te)};return ki.createPortal(s.jsxs(s.Fragment,{children:[!I&&s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:c,"aria-label":"关闭 Agent 工作台"}),s.jsxs("section",{onPointerDown:Te=>{de&&Te.stopPropagation()},ref:Pe,role:p&&!I?"dialog":void 0,"aria-modal":p&&!I?!0:void 0,"aria-hidden":g||void 0,"aria-label":de?"工作组消息分屏":I?"工作组消息浮窗":"Agent 工作台",style:I&&!de?{display:gr?void 0:"none",left:X.x,top:X.y,...Be?{width:`min(calc(100vw - 24px), max(280px, ${Be.width*100}vw))`,height:`min(calc(100dvh - 24px), max(220px, ${Be.height*100}dvh))`}:{},maxHeight:se?se-24:"calc(100dvh - 24px)"}:void 0,className:de?"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface":I?"fixed z-menu-panel flex w-[min(400px,calc(100vw-24px))] flex-col overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-xl":`fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))] h-[calc(var(--app-visible-vh,100dvh)-max(1.5rem,var(--app-vv-offset-top,0px),env(safe-area-inset-top,0px))-max(1.5rem,env(safe-area-inset-bottom,0px)))] z-modal-panel mx-auto flex ${L?"max-w-6xl":"max-w-3xl"} flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[calc(var(--app-visible-vh,100dvh)*0.08)] sm:h-[calc(var(--app-visible-vh,100dvh)*0.84)]`,children:[s.jsxs("header",{"data-pane-titlebar":de?"true":void 0,"data-panel-drag-title":de?"true":void 0,onDragStart:Te=>Te.preventDefault(),className:`flex items-center gap-2 border-b border-border/15 ${de?"min-h-9 shrink-0 cursor-grab select-none bg-[var(--chrome-bg)] px-3 active:cursor-grabbing":I?"px-3 py-2 cursor-move touch-none select-none":"px-4 py-3"}`,onPointerDown:Te=>{!I||de||Te.button!==0||Te.target.closest("button, summary")||(_e.current={x:Te.clientX,y:Te.clientY,left:X.x,top:X.y},Te.currentTarget.setPointerCapture?.(Te.pointerId))},onPointerMove:Te=>{_e.current&&Qe(re(_e.current.left+Te.clientX-_e.current.x,_e.current.top+Te.clientY-_e.current.y))},onPointerUp:()=>{if(!_e.current)return;_e.current=null;const Te=Pe.current?.getBoundingClientRect(),Lt=window.visualViewport;Te&&(tt.current=Rg(X.x,X.y,(Lt?.offsetLeft??0)+12,(Lt?.offsetTop??0)+12,(Lt?.width??window.innerWidth)-Te.width-24,(Lt?.height??window.innerHeight)-Te.height-24),al({position:tt.current},t).catch(()=>ke("浮窗位置保存失败,请重新拖动重试")))},onPointerCancel:()=>{_e.current=null},children:[s.jsx(od,{size:de?13:17,className:"shrink-0 text-primary"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:`${I?"truncate text-[12px]":"text-[14px]"} font-semibold text-foreground`,title:de?"拖动标题移动面板;放在边缘拆分,中央交换":Qr?.name,children:Qr?Qr.name:t?"协作工作区":"Agent 工作台"}),!de&&!L&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:I?"引用、文件路径和粘贴优先加入此处":Qr?"分派任务、回答问题、审阅与验收结果":"自动任务、会话协作与历史搜索"})]}),!de&&!p&&Fe==="collaboration"&&Ne.length>0&&s.jsx("button",{className:`${Mr} shrink-0 text-primary hover:bg-primary/10`,disabled:R,onClick:()=>{Pr(!I)},children:I?"展开":"放到终端旁"}),L&&Qr&&s.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[Qr.sessionIds.length," 人"]}),de&&s.jsx("button",{type:"button","aria-label":"展开协作工作区",title:"展开查看目标与交付",disabled:R,className:"flex min-h-11 shrink-0 items-center justify-center rounded-lg px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>x("full"),children:s.jsx(k9,{size:15})}),de&&s.jsxs("details",{className:"relative z-20 shrink-0",children:[s.jsx("summary",{"aria-label":"面板布局",title:"面板布局",className:"flex min-h-8 cursor-pointer list-none items-center rounded px-2 text-muted-foreground hover:bg-surface-2 [&::-webkit-details-marker]:hidden",children:s.jsx(ll,{size:16})}),s.jsx("div",{className:"absolute right-0 top-full z-30 w-36 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:s.jsxs("button",{type:"button",disabled:R,className:`${Mr} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:Te=>{Te.currentTarget.closest("details")?.removeAttribute("open"),Oe("floating")},children:[s.jsx(ld,{size:14}),"小浮窗"]})})]}),s.jsx("button",{className:`${de?"min-h-8 rounded px-2":"rounded-lg p-2"} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,disabled:R,onClick:()=>{I?Pr(!1,!0):c()},"aria-label":p?"收起展开视图":"关闭",children:s.jsx(Wn,{size:16})})]}),I&&!de&&!p&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:R,"aria-pressed":q==="floating",className:`${Jm} ${q==="floating"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Oe("floating")},children:"浮窗"}),s.jsx("button",{type:"button",disabled:R||!e||Nn,"aria-pressed":q==="docked",className:`${Jm} ${q==="docked"?"border-primary/40 text-primary":"border-transparent text-muted-foreground"}`,onClick:()=>{Oe("docked")},children:"放到终端旁"})]}),!L&&(!I||de)&&s.jsx("nav",{"aria-label":"工作台功能",className:"grid shrink-0 grid-cols-3 gap-1 border-b border-border/15 px-2 py-1",children:[["collaboration",g0,"协作组"],["automation",Hu,"自动任务"],["search",Vl,"历史搜索"]].map(([Te,Lt,Y])=>s.jsxs("button",{type:"button","aria-pressed":Fe===Te,"aria-controls":`workbench-${Te}`,onClick:()=>Ue(Te),className:`${Mr} ${Fe===Te?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Lt,{size:14}),Y]},Te))}),Fe==="collaboration"&&Mt&&s.jsxs("div",{role:"alert",className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[Mt,s.jsx("button",{className:`${Mr} ml-2`,onClick:()=>{Er()},children:"重新加载会话"})]}),!L&&Fe!=="search"&&br&&s.jsx("div",{className:"mx-4 mt-3 text-[11px] text-muted-foreground",children:br}),Ge&&s.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:Ge}),Pt&&(!I||de)&&s.jsxs("div",{role:"status",className:"mx-3 mt-2 flex items-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-[11px] text-primary",children:[s.jsx(ci,{size:13}),Pt]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[Xe.has("automation")&&s.jsx("div",{id:"workbench-automation",className:Fe==="automation"?"h-full min-h-0 p-4":"hidden",children:s.jsx(uP,{automations:Le,runs:ye,agents:le,sessions:gt.filter(Te=>!m0(Te.sessionId)),activeSessionId:e,loading:ae==="loading",loadError:Je,busy:Ft,setBusy:Z,setError:pt,setNotice:hr,refresh:Er,onClose:c})}),Xe.has("collaboration")&&s.jsxs("div",{id:"workbench-collaboration",className:Fe==="collaboration"?`h-full min-h-0 overflow-x-hidden overflow-y-auto overscroll-y-contain ${I?"p-3":"p-4"}`:"hidden",children:[!we&&!$e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息面板…"}),t&&!Qr&&s.jsxs("div",{role:"status",className:"space-y-2 text-[11px] text-muted-foreground",children:[s.jsx("p",{children:Zt==="loading"?"正在加载协作组…":Zt==="error"?"协作组加载失败,恢复连接后可重试。":"此协作组暂不可用,已释放分屏位置。草稿和布局偏好仍保留。"}),Zt!=="loading"&&s.jsx("button",{className:Mr,onClick:()=>{Er()},children:"重新加载"})]}),$e&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:$e}),we&&(!t||Qr)&&s.jsx(hP,{active:Fe==="collaboration",notice:Pt,initialDrafts:y,onDraftChange:v,docked:de,inputKeySuffix:p?":overlay":"",selectedGroupId:Q,setSelectedGroupId:at,floatingVisible:gr,floating:I,sessionsState:Zt,groups:Ne,sessions:gt,agents:le,activeSessionId:e,initialGroupId:t,onOpenSession:async Te=>{await en(Te),I||c()},onOpenTaskSession:en,onEnterGroup:a,defaultSessionMode:l,busy:Ft,setBusy:Z,setError:pt,setNotice:hr,refresh:Er}),!L&&Ut&&s.jsx(pP,{peers:Ut,currentGroupId:Nt?.id,busy:Ft,setBusy:Z,setError:pt,setNotice:hr,onSelectGroup:at})]}),Xe.has("search")&&s.jsx("div",{id:"workbench-search",className:Fe==="search"?"h-full min-h-0 overflow-y-auto overscroll-y-contain p-4":"hidden",children:s.jsx(SP,{active:Fe==="search",onClose:c,onNewSession:h,setError:pt})})]}),I&&!de&&s.jsx("button",{type:"button","aria-label":"调整协作浮窗大小",className:"absolute bottom-0 right-0 h-4 w-4 cursor-nwse-resize touch-none text-muted-foreground hover:text-primary",onPointerDown:Te=>{Te.preventDefault(),Ee.current=!0,Te.currentTarget.setPointerCapture(Te.pointerId)},onPointerMove:Te=>{if(!Te.currentTarget.hasPointerCapture(Te.pointerId))return;const Lt=window.visualViewport,Y=Lt?.width??window.innerWidth,st=Lt?.height??window.innerHeight;fe({width:Math.min(1,Math.max(280,Te.clientX-X.x)/Y),height:Math.min(1,Math.max(220,Te.clientY-X.y)/st)})},onPointerUp:()=>{Ee.current=!1;const Te=Pe.current?.getBoundingClientRect(),Lt=window.visualViewport;Te&&(tt.current=Rg(X.x,X.y,(Lt?.offsetLeft??0)+12,(Lt?.offsetTop??0)+12,(Lt?.width??window.innerWidth)-Te.width-24,(Lt?.height??window.innerHeight)-Te.height-24)),Be&&al({size:Be,position:tt.current},t).catch(()=>ke("浮窗大小保存失败,请重新调整重试"))},onPointerCancel:()=>{Ee.current=!1},onKeyDown:Te=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Te.key))return;Te.preventDefault();const Lt=Pe.current?.getBoundingClientRect(),Y={width:Math.max(.15,Math.min(1,(Be?.width??(Lt?.width??400)/window.innerWidth)+(Te.key==="ArrowRight"?.03:Te.key==="ArrowLeft"?-.03:0))),height:Math.max(.15,Math.min(1,(Be?.height??(Lt?.height??300)/window.innerHeight)+(Te.key==="ArrowDown"?.03:Te.key==="ArrowUp"?-.03:0)))};fe(Y),al({size:Y},t).catch(()=>ke("浮窗大小保存失败,请重试"))},children:s.jsx("span",{"aria-hidden":"true",children:"⌟"})})]})]}),Ce)}function uP({automations:e,runs:t,agents:r,sessions:n,activeSessionId:a,loading:l,loadError:c,busy:h,setBusy:p,setError:g,setNotice:x,refresh:y,onClose:A}){const[v,L]=b.useState(null),[I,E]=b.useState(!1),[R,P]=b.useState(null),Q=async($,W,B)=>{p($),g(null),x(null);try{await W(),await y(),x(B)}catch(q){g(q instanceof Error?q.message:"操作失败")}finally{p(null)}};return I?s.jsx(dP,{agents:r,sessions:n,activeSessionId:a,initial:v,onCancel:()=>{L(null),E(!1),g(null)},onSaved:async($,W)=>{L(null),E(!1),await y(),x(v?`“${$}”已更新`:W?`“${$}”已创建,将按计划自动运行`:`“${$}”已创建,当前未启用`)},setError:g},v?.id??"new"):s.jsxs("div",{className:"h-full space-y-4 overflow-y-auto overscroll-y-contain",children:[c&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["自动任务同步失败:",c,s.jsx("button",{className:Mr,onClick:()=>{y()},children:"重新加载"})]}),s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"自动任务"}),s.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"定时发送任务,打开运行会话查看输出。"})]}),!I&&e.length>0&&s.jsxs("button",{className:`${Mr} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{L(null),E(!0),x(null)},children:[s.jsx(Ys,{size:13}),"新建任务"]})]}),l&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在加载自动任务…"}),!l&&!c&&e.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx(W9,{size:24,className:"mx-auto text-primary"}),s.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"把重复工作交给 Agent"}),s.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[11px] leading-relaxed text-muted-foreground",children:"写清任务内容,选择运行频率。创建后可以先手动运行一次确认效果。"}),s.jsxs("button",{className:`${Mr} mt-4 bg-primary text-primary-foreground`,onClick:()=>E(!0),children:[s.jsx(Ys,{size:13}),"创建第一个任务"]})]}),s.jsx("div",{className:"space-y-2",children:e.map($=>{const W=t.filter(q=>q.automationId===$.id).sort((q,ne)=>ne.startedAt-q.startedAt)[0],B=r.find(q=>q.command===$.command);return s.jsxs("article",{className:"rounded-xl border border-border/15 bg-surface-2/40 p-3 transition hover:border-border/30",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:$.name}),s.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${$.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:$.enabled?"已启用":"已停用"}),$.lastRunStatus&&s.jsx("span",{className:`text-[10px] ${IP($.lastRunStatus)}`,children:kP($.lastRunStatus)})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Hu,{size:11}),_P($)]}),s.jsx("span",{children:$.enabled&&$.nextRunAt?`下次 ${uf($.nextRunAt)}`:"不会自动运行"})]}),s.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:$.targetSessionId?`发送到 ${n.find(q=>q.sessionId===$.targetSessionId)?.name??"指定会话"}`:`新建 ${B?.displayName??"Agent"} 会话 · ${$.cwd}`}),s.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:$.prompt}),$.lastRunAt&&s.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",uf($.lastRunAt),$.lastRunMessage?` · ${$.lastRunMessage}`:""]})]}),s.jsx("button",{"aria-label":`编辑 ${$.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{L($),E(!0),x(null)},children:s.jsx(bh,{size:13})})]}),s.jsx("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border/10 pt-3",children:R===$.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),s.jsx("button",{className:`${Mr} bg-surface-elevated text-foreground`,onClick:()=>P(null),children:"取消"}),s.jsxs("button",{disabled:h!==null,className:`${Mr} bg-destructive text-destructive-foreground`,onClick:()=>{Q(`delete:${$.id}`,()=>X8($.id),`“${$.name}”已删除`).then(()=>P(null))},children:[h===`delete:${$.id}`?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(Zs,{size:13}),"确认删除"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`${Mr} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>P($.id),children:[s.jsx(Zs,{size:13}),"删除"]}),s.jsxs("button",{disabled:h!==null,className:`${Mr} ${$.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{Q(`toggle:${$.id}`,()=>J8($.id,!$.enabled),$.enabled?`“${$.name}”已暂停,不会自动运行`:`“${$.name}”已恢复,将按原计划运行`)},children:[h===`toggle:${$.id}`?s.jsx(vn,{size:13,className:"animate-spin"}):$.enabled?s.jsx(eT,{size:13}):s.jsx(Oh,{size:13}),$.enabled?"暂停":"恢复"]}),W?.frontendSessionId&&s.jsxs("button",{className:`${Mr} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:W.frontendSessionId})),A()},children:[s.jsx(ld,{size:13}),"打开上次会话"]}),s.jsxs("button",{disabled:h!==null,className:`${Mr} bg-primary/15 text-primary`,onClick:()=>{Q(`run:${$.id}`,()=>ew($.id),`“${$.name}”已投递,可打开会话查看进度`)},children:[h===`run:${$.id}`?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(Oh,{size:13}),"立即运行"]})]})})]},$.id)})})]})}function dP({agents:e,sessions:t,activeSessionId:r,initial:n,onCancel:a,onSaved:l,setError:c}){const[h,p]=b.useState(n?.name??""),g=t.find(le=>le.sessionId===r),x=n?.cwd??g?.cwd??t[0]?.cwd??"",[y,A]=b.useState(x),v=b.useRef(!1),[L,I]=b.useState(!1),[E,R]=b.useState(()=>e.find(le=>le.command===n?.command)?.slug??""),[P,Q]=b.useState(n?.prompt??""),[$,W]=b.useState(n?.targetSessionId??""),[B,q]=b.useState(n?.targetSessionId?"existing":"new"),[ne,Be]=b.useState(n?.schedule.kind??"interval"),[fe,X]=b.useState(n?.schedule.kind==="interval"?n.schedule.everyMinutes:60),[Qe,Pe]=b.useState(n?.schedule.kind==="daily"?n.schedule.time:"09:00"),[ue,Ce]=b.useState(n?.schedule.kind==="daily"?n.schedule.weekdays:[1,2,3,4,5]),[tt,we]=b.useState(()=>n?.schedule.kind==="interval"?![15,60,1440].includes(n.schedule.everyMinutes):!!n&&!["1,2,3,4,5","0,1,2,3,4,5,6"].includes([...n.schedule.weekdays].sort().join())),[ce,$e]=b.useState(!1),[ke,se]=b.useState(n?.enabled??!0),[je,de]=b.useState(!1),Oe=e.find(le=>le.slug===E)??null,Ee=Oe?.command??n?.command??"";b.useEffect(()=>{if(!E){const le=n?e.find(xe=>xe.command===n.command):e[0];le&&R(le.slug)}},[e,n,E]),b.useEffect(()=>{!n&&!v.current&&x&&A(x)},[n,x]);const _e=h.trim()||Array.from(P.trim().split(`
148
+ `)[0].trim()).slice(0,40).join(""),re=t.find(le=>le.sessionId===$),Fe=tt?`custom-${ne}`:ne==="interval"?String(fe):ue.length===7?"daily":"workdays",wt=le=>{we(le.startsWith("custom-")),["15","60","1440","custom-interval"].includes(le)?(Be("interval"),le!=="custom-interval"&&X(Number(le))):(Be("daily"),le==="daily"&&Ce([0,1,2,3,4,5,6]),le==="workdays"&&Ce([1,2,3,4,5]))},Xe=async()=>{if(!(je||!ot)){de(!0),c(null);try{await aw({id:n?.id,name:_e,cwd:y,command:B==="new"?Ee:"",prompt:P,targetSessionId:B==="existing"&&$||null,enabled:ke,schedule:ne==="interval"?{kind:ne,everyMinutes:fe}:{kind:ne,time:Qe,weekdays:ue}}),await l(_e,ke)}catch(le){c(le instanceof Error?le.message:"保存失败")}finally{de(!1)}}},ee=ne==="interval"?{kind:ne,everyMinutes:fe}:{kind:ne,time:Qe,weekdays:ue},[Ue,Le]=Qe.split(":"),te=(le,xe)=>Pe(`${le}:${xe}`),ye=P.trim()?B==="existing"&&!t.some(le=>le.sessionId===$)?"请选择当前服务的可用会话":B==="new"&&!Ee?"请选择可启动的 Agent":ne==="interval"&&(!Number.isInteger(fe)||fe<1||fe>43200)?"间隔需要是 1–43200 分钟的整数":ne==="daily"&&!ue.length?"至少选择一天":"":"请填写任务内容",ot=!ye;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 pb-3",children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:n?"编辑自动任务":"创建自动任务"}),s.jsx("button",{disabled:je,className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground disabled:opacity-40",onClick:a,"aria-label":"关闭任务表单",children:s.jsx(Wn,{size:14})})]}),s.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-y-contain pb-4",children:s.jsxs("fieldset",{disabled:je,className:"min-w-0 space-y-4",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["任务内容",s.jsx("textarea",{autoFocus:!0,className:`${ks} min-h-24 resize-y`,rows:3,value:P,onChange:le=>Q(le.target.value),placeholder:"例如:检查当前项目的待办,整理需要我处理的问题。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"block space-y-1.5 text-[11px] text-muted-foreground",children:["运行频率",s.jsxs("select",{className:ks,value:Fe,onChange:le=>wt(le.target.value),children:[s.jsx("option",{value:"15",children:"每 15 分钟"}),s.jsx("option",{value:"60",children:"每小时"}),s.jsx("option",{value:"1440",children:"每 24 小时"}),s.jsx("option",{value:"daily",children:"每天定时"}),s.jsx("option",{value:"workdays",children:"工作日定时"}),s.jsx("option",{value:"custom-interval",children:"自定义间隔"}),s.jsx("option",{value:"custom-daily",children:"自定义星期"})]})]}),ne==="interval"&&tt&&s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["每隔多少分钟",s.jsx("input",{className:`${ks} min-w-0 flex-1`,type:"number",min:1,max:43200,value:fe,onChange:le=>X(Number(le.target.value))})]}),ne==="daily"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center rounded-lg border border-border/20 bg-surface-2 px-3 py-1.5 focus-within:border-primary/60",children:[s.jsx(Hu,{size:14,className:"mr-2 shrink-0 text-primary"}),s.jsx(O5,{label:"小时",value:Ue,options:24,onChange:le=>te(le,Le)}),s.jsx("span",{"aria-hidden":"true",className:"px-2 text-[16px] text-muted-foreground",children:":"}),s.jsx(O5,{label:"分钟",value:Le,options:60,onChange:le=>te(Ue,le)}),s.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:"24 小时制"})]}),tt&&s.jsx("div",{className:"grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((le,xe)=>{const Ne=ue.includes(xe);return s.jsx("button",{type:"button","aria-pressed":Ne,"aria-label":`星期${le}`,className:`rounded-lg py-2.5 text-[11px] transition ${Ne?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>Ce(yt=>Ne?yt.filter(gt=>gt!==xe):[...yt,xe].sort()),children:le},xe)})}),ue.length===0&&s.jsx("p",{className:"text-[10px] text-destructive",children:"至少选择一天"})]})]}),s.jsxs("div",{className:"space-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx(od,{size:13,className:"shrink-0"}),B==="new"?`每次新建会话 · ${Oe?.displayName??(n?.command?"原 Agent":"暂无可用 Agent")}`:`发送到现有会话 · ${re?.name??"目标会话不可用"}`]}),s.jsx("p",{className:"break-all pl-[19px] text-[10px]",children:B==="new"?y||"默认使用当前目录":"直接写入终端,目标会话需保持在线"})]}),s.jsxs("div",{className:"border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button","aria-expanded":ce,"aria-controls":"automation-more-settings",className:`${Mr} -ml-2 px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>$e(le=>!le),children:[s.jsx(ol,{size:13,className:`transition-transform ${ce?"rotate-180":""}`}),"更多设置"]}),ce&&s.jsxs("div",{id:"automation-more-settings",className:"space-y-3 pt-2",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务名称(可选)",s.jsx("input",{className:ks,value:h,onChange:le=>p(le.target.value),placeholder:_e||"留空则从任务内容自动生成"})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["运行方式",s.jsxs("select",{className:ks,value:B,onChange:le=>{const xe=le.target.value;q(xe),xe==="existing"&&!$&&W(g?.sessionId??t[0]?.sessionId??"")},children:[s.jsx("option",{value:"new",children:"每次新建会话"}),s.jsx("option",{value:"existing",disabled:t.length===0,children:"发送到现有会话"})]})]}),B==="new"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["Agent / Plugin",s.jsxs("select",{className:ks,value:E,onChange:le=>R(le.target.value),children:[n&&!e.some(le=>le.command===n.command)&&s.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(le=>s.jsxs("option",{value:le.slug,children:[le.displayName,le.isPlugin?" · Plugin":""]},le.slug))]})]}),s.jsxs("label",{className:"min-w-0 space-y-1 text-[10px] text-muted-foreground",children:["工作目录",s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{className:`${ks} min-w-0`,value:y,onChange:le=>{v.current=!0,A(le.target.value)},placeholder:"默认使用当前目录"}),s.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${Mr} shrink-0 bg-surface-2 text-foreground`,onClick:()=>I(!0),children:[s.jsx(c0,{size:13}),"选择"]})]})]})]}),e.length===0&&s.jsx("p",{className:"text-[10px] text-destructive",children:"没有检测到可启动的 Agent。请先在 Plugin 设置中安装或配置 Agent。"})]}):s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["目标会话",s.jsxs("select",{className:ks,value:$,onChange:le=>W(le.target.value),children:[!re&&s.jsx("option",{value:$,children:$?"原目标会话不可用,请重新选择":"请选择会话"}),t.map(le=>s.jsxs("option",{value:le.sessionId,children:[le.name," · ",Mh(le)]},le.sessionId))]}),s.jsx("span",{className:"block leading-relaxed",children:"仅支持当前服务的会话。运行时会直接写入终端,请确保目标会话保持在线。"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[s.jsx("input",{type:"checkbox",checked:ke,onChange:le=>se(le.target.checked)}),"保存后启用"]})]})]})]})}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-border/15 pt-3",children:[s.jsx("p",{role:"status",className:"mr-auto min-w-0 flex-[1_1_160px] text-[10px] text-muted-foreground",children:ye||(ke?`${n?"下次运行":"首次运行"}:${uf(LP(ee,Date.now(),n?.createdAt))}`:"保存后暂停,不会自动运行")}),s.jsx("button",{disabled:je,className:`${Mr} bg-surface-2 text-foreground`,onClick:a,children:"取消"}),s.jsx("button",{title:ye||void 0,disabled:je||!ot,className:`${Mr} bg-primary text-primary-foreground`,onClick:()=>{Xe()},children:je?"保存中…":n?"保存修改":"创建任务"})]}),s.jsx(_f,{open:L,initialPath:y||x||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>I(!1),onConfirm:le=>{v.current=!0,A(le),I(!1)}})]})}function O5({label:e,value:t,options:r,onChange:n}){return s.jsxs("label",{className:"relative min-w-0 flex-1",children:[s.jsx("span",{className:"sr-only",children:e}),s.jsx("select",{"aria-label":e,className:"w-full appearance-none bg-transparent py-1 pl-1 pr-7 text-center text-[18px] font-semibold tabular-nums text-foreground outline-none",value:t,onChange:a=>n(a.target.value),children:Array.from({length:r},(a,l)=>{const c=String(l).padStart(2,"0");return s.jsx("option",{value:c,children:c},c)})}),s.jsx(ol,{"aria-hidden":"true",size:13,className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground"})]})}function hP({fullWorkspace:e=!1,active:t,notice:r,initialDrafts:n,onDraftChange:a,docked:l,inputKeySuffix:c,selectedGroupId:h,setSelectedGroupId:p,floatingVisible:g,floating:x,sessionsState:y,groups:A,sessions:v,agents:L,activeSessionId:I,initialGroupId:E,onOpenSession:R,onOpenTaskSession:P,onEnterGroup:Q,defaultSessionMode:$,busy:W,setBusy:B,setError:q,setNotice:ne,refresh:Be}){const[fe,X]=b.useState("tasks"),[Qe,Pe]=b.useState(0);b.useEffect(()=>Pe(0),[h]);const[ue,Ce]=b.useState(""),[tt,we]=b.useState(()=>new Set),[ce,$e]=b.useState(""),[ke,se]=b.useState(()=>new Set),[je,de]=b.useState(!1),[Oe,Ee]=b.useState(),[_e,re]=b.useState([]),[Fe,wt]=b.useState(!1),[Xe,ee]=b.useState(null),Ue=Db(),[Le,te]=b.useState("all"),[ye,ot]=b.useState(!1),[le,xe]=b.useState(new Set),[Ne,yt]=b.useState(null),[gt,At]=b.useState(""),[Ft,Z]=b.useState(!1),[Ge,pt]=b.useState(!1),[Pt,hr]=b.useState(null),[Zt,_r]=b.useState(new Set),[ae,ze]=b.useState(),[Je,Rt]=b.useState({}),[Mt,ir]=b.useState(!1),[Ut,We]=b.useState(""),[br,Ze]=b.useState(""),[Dt,nt]=b.useState(""),[_t,Qr]=b.useState(""),yr=b.useRef(null),Nt=l,Nn=(h??A[0]?.id??"")+c,Zr=b.useRef(!1),lt=h==="new"?null:(h?A.find(V=>V.id===h):A[0])??null,gr=lt?.sessionIds.flatMap(V=>{const et=v.find(kt=>kt.sessionId===V);return et?[et]:[]})??[],[Pr,be]=b.useState(0),Er=b.useRef(new Map(Object.entries(n??{}))),at=b.useRef(void 0),en=b.useRef(!1),Te=b.useRef(Ne);Te.current=Ne;const Lt=b.useRef(gt);Lt.current=gt,b.useLayoutEffect(()=>{if(at.current===lt?.id)return;if(at.current){const et={content:Lt.current,targets:Ne};Er.current.set(at.current,et),al({drafts:{[at.current]:et}}).catch(()=>q("草稿保存失败,请返回该组重试"))}at.current=lt?.id,en.current=!0;const V=Er.current.get(lt?.id??"");At(V?.content??""),yt(V?.targets??null)},[lt?.id]),b.useEffect(()=>{hr(null)},[lt?.id]);const Y=b.useRef(null),st=b.useRef(n);b.useLayoutEffect(()=>{if(st.current===n)return;st.current=n;for(const[et,kt]of Object.entries(n??{}))Er.current.set(et,kt);const V=n?.[lt?.id??""];!V||V.content===Lt.current&&JSON.stringify(V.targets)===JSON.stringify(Te.current)||(en.current=!0,Y.current=null,At(V.content),yt(V.targets))},[n,lt?.id]);const xt=b.useCallback(V=>{al(V).catch(()=>q("草稿保存失败,请保持面板打开,修改内容后重试"))},[q]);b.useEffect(()=>{if(en.current){en.current=!1;return}if(!lt||at.current!==lt.id)return;const V={drafts:{[lt.id]:{content:gt,targets:Ne}}};a(lt.id,V.drafts[lt.id]),Y.current=V;const et=setTimeout(()=>{Y.current=null,xt(V)},400);return()=>{clearTimeout(et)}},[lt?.id,gt,Ne,xt]),b.useEffect(()=>{const V=()=>{Y.current&&(xt(Y.current),Y.current=null)},et=()=>{document.visibilityState==="hidden"&&V()};return document.addEventListener("visibilitychange",et),window.addEventListener("pagehide",V),()=>{document.removeEventListener("visibilitychange",et),window.removeEventListener("pagehide",V),V()}},[xt]),b.useEffect(()=>{if(!(!(x||e)||!t||!g||!lt||Ge||fe!=="messages"))return Rb(V=>{X("messages"),At(et=>et+(et&&!/\s$/.test(et)?`
149
+ `:"")+V.replace(/\r\n?/g,`
150
+ `))},Nn,Nt)},[x,e,t,g,lt?.id,Nt,Nn,fe,Ge]),b.useEffect(()=>{const V=yr.current;if(!x||!V)return;const et=kt=>q(String(kt.detail));return V.addEventListener("termdock:file-drop-error",et),()=>V.removeEventListener("termdock:file-drop-error",et)},[x,lt?.id,q]);const Gt=async V=>{const et=lt?.id;q(null),be(kt=>kt+1);try{const kt=await ad("/tmp",V);if(kt.files.length!==V.length||kt.files.some(zt=>!zt.path))throw new Error("文件路径准备失败,请重试");const Bt=kt.files.map(zt=>bc(zt.path)).join(" ")+" ";if(at.current===et)At(zt=>zt+(zt&&!/\s$/.test(zt)?`
151
+ `:"")+Bt);else if(et){const zt=Er.current.get(et)??{content:"",targets:null},gn={...zt,content:zt.content+`
152
+ `+Bt};Er.current.set(et,gn),xt({drafts:{[et]:gn}})}}catch(kt){q(kt instanceof Error?kt.message:"文件上传失败")}finally{be(kt=>kt-1)}},Gr=new Set(v.filter(Yp).map(V=>V.sessionId)),Fr=tt.size,ur=[...tt].filter(V=>!Gr.has(V)),tn=xP(lt,v),on=ce.trim().toLocaleLowerCase(),Xr=v.filter(V=>!on||[V.name,V.serviceLabel??"",V.cwd,Kp(V.currentTask)].some(et=>et.toLocaleLowerCase().includes(on))),Wr=F5(Xr),$r=F5(tn),Ur=V=>!on&&ke.has(V),Cn=V=>se(et=>{const kt=new Set(et);return kt.has(V)?kt.delete(V):kt.add(V),kt});b.useEffect(()=>{Z(!1),pt(!1),ir(!1),de(!1),Rt({});try{xe(new Set(JSON.parse(localStorage.getItem(`collab-seen:${lt?.id}`)??"[]")))}catch{xe(new Set)}_r(new Set(lt?.sessionIds??[]))},[lt?.id]),b.useEffect(()=>{!Ut&&L[0]&&We(L[0].slug)},[L,Ut]),b.useEffect(()=>{re([]),ee(null)},[lt?.id]),b.useEffect(()=>{if(!E||!t||x&&!g||!lt){wt(!1);return}wt(!0);let V=!1,et=0,kt=!1;const Bt=()=>{if(V||kt||document.hidden||navigator.onLine===!1)return;kt=!0;const gn=++et;Ag(lt.id).then(lr=>{!V&&gn===et&&(re(lr.messages),ee(null))}).catch(lr=>{!V&&gn===et&&ee(lr instanceof Error?lr.message:"消息加载失败")}).finally(()=>{kt=!1,!V&&gn===et&&wt(!1)})};Bt();const zt=window.setInterval(Bt,3e3);return document.addEventListener("visibilitychange",Bt),window.addEventListener(Bh,Bt),window.addEventListener("pageshow",Bt),()=>{V=!0,window.clearInterval(zt),document.removeEventListener("visibilitychange",Bt),window.removeEventListener(Bh,Bt),window.removeEventListener("pageshow",Bt)}},[lt?.id,t,x,g]),b.useEffect(()=>{!E||lt?.id!==E||Zr.current||(Zr.current=!0,fe==="messages"&&yr.current?.scrollIntoView?.({block:"nearest"}))},[E,lt?.id]);const Rn=async()=>{B("create-group"),q(null),ne(null);try{if(ur.length)throw new Error("所选会话已变化,请先清除不可用选择");const V=await Sc({name:ue,sessionIds:[...tt]});Ce(""),$e(""),p(V.group.id),await Be(),ne(`“${V.group.name}”已创建,可以添加第一个目标。`),Q&&await Q(V.group.id)}catch(V){q(V instanceof Error?V.message:"创建失败")}finally{B(null)}},hn=lt?.sessionIds.filter(V=>Ne===null||Ne.includes(V))??[],Vr=async()=>{if(!lt||W||Pr||!gt.trim()||!hn.length)return;const V=gt,et=lt.id;B("send-message"),q(null),ne(null);try{const kt=await G8(lt.id,{fromSessionId:null,toSessionIds:Ne===null?void 0:hn,kind:"message",content:gt});if(at.current===et){const lr=Lt.current,yn=lr===V?"":lr.startsWith(V)?lr.slice(V.length).replace(/^\n/,""):lr;At(yn),xt({drafts:{[et]:{content:yn,targets:Te.current}}})}else{const lr=Er.current.get(et);if(lr){const yn={...lr,content:lr.content===V?"":lr.content.startsWith(V)?lr.content.slice(V.length).replace(/^\n/,""):lr.content};Er.current.set(et,yn),xt({drafts:{[et]:yn}})}}const Bt=await Ag(et).catch(()=>null);Bt&&at.current===et&&re(Bt.messages);const zt=kt.deliveries?.filter(lr=>lr.serviceUnavailable).length??0,gn=kt.deliveries?.filter(lr=>lr.pending>0).length??0;ne(zt>0?`已保存消息;${zt} 个接收成员的服务不可达,尚未送达,等待重连`:gn>0?`已保存消息;${gn} 个成员等待投递确认`:`消息已送达 ${kt.messages.length} 个会话`)}catch(kt){q(kt instanceof Error?kt.message:"发送失败")}finally{B(null)}},ys=async()=>{if(!lt)return;B(`delete:${lt.id}`),q(null),ne(null);const V=lt.name;try{await V8(lt.id,Oe),p(null),de(!1),await Be(),ne(`“${V}”已删除`)}catch(et){q(et instanceof Error?et.message:"删除失败")}finally{B(null)}},cn=async()=>{if(!lt)return;const V=[...Zt];B("save-members"),q(null),ne(null);try{const et=await Sc({id:lt.id,name:lt.name,sessionIds:V,expectedUpdatedAt:ae});p(et.group.id),Z(!1),await Be(),ne(`“${lt.name}”成员已更新,共 ${V.length} 个会话`)}catch(et){q(et instanceof Error?et.message:"成员更新失败")}finally{B(null)}},Vt=async V=>{if(!lt||!lt.sessionIds.includes(V)){hr(null);return}const et=v.find(Bt=>Bt.sessionId===V)?.name??V,kt=lt.name;B(`remove-member:${V}`),q(null),ne(null);try{await Sc({id:lt.id,name:kt,sessionIds:lt.sessionIds.filter(Bt=>Bt!==V),expectedUpdatedAt:lt.updatedAt}),hr(null),_r(Bt=>new Set([...Bt].filter(zt=>zt!==V))),Rt(Bt=>Object.fromEntries(Object.entries(Bt).filter(([zt])=>zt!==V))),await Be(),ne(`已把“${et}”移出“${kt}”`)}catch(Bt){q(Bt instanceof Error?Bt.message:"移出成员失败")}finally{B(null)}},hs=async V=>{if(!lt)return;const et=Je[V]??"";B(`role:${V}`),q(null),ne(null);try{await K8(lt.id,V,et.trim()||null),await Be(),ne(et.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(kt){q(kt instanceof Error?kt.message:"定位保存失败")}finally{B(null)}},Sn=()=>{const V=v.find(et=>et.sessionId===I)?.cwd??v.find(et=>lt?.sessionIds.includes(et.sessionId))?.cwd??"";nt(V),Ze(""),Qr(""),ir(!0),Z(!1)},rs=async()=>{if(!(!lt||!Ut)){B("spawn-agent"),q(null),ne(null);try{const V=await q8(lt.id,{agentSlug:Ut,name:br.trim()||void 0,cwd:Dt.trim()||void 0,task:_t.trim()||void 0,mode:$});ir(!1),await Be(),ne(`“${V.session.name}”已创建并加入“${V.group.name}”`)}catch(V){q(V instanceof Error?V.message:"Agent Session 创建失败")}finally{B(null)}}},qr=_e.filter(V=>(!ye||!le.has(V.id))&&(Le==="all"||V.responseKind===Le)),_n=AP(qr,v),un=()=>{const V=new Set([...le,...qr.map(et=>et.id)].slice(-1e4));try{localStorage.setItem(`collab-seen:${lt?.id}`,JSON.stringify([...V]))}catch{q("无法保存已看记录,请检查浏览器存储空间");return}xe(V)},Bn=V=>s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-2 py-2.5 transition hover:bg-surface-2",children:[s.jsx("input",{className:"mt-0.5",type:"checkbox",disabled:!Yp(V),checked:tt.has(V.sessionId),onChange:()=>we(et=>{const kt=new Set(et);return kt.has(V.sessionId)?kt.delete(V.sessionId):kt.add(V.sessionId),kt})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-[12px] text-foreground",children:V.name}),s.jsx(Zp,{session:V}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:Mh(V)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:V.currentTask?`${Kp(V.currentTask)} · ${V.cwd}`:V.cwd||V.capability||"终端会话"})]})]},V.sessionId),Nr=V=>{const et=Je[V.sessionId]??"",kt=lt?.roles?.[V.sessionId]??"";return s.jsxs("div",{className:"px-2 py-2 transition hover:bg-surface-2",children:[s.jsxs("label",{className:"flex cursor-pointer items-center gap-3",children:[s.jsx("input",{type:"checkbox",disabled:!lt?.sessionIds.includes(V.sessionId)&&!Yp(V),checked:Zt.has(V.sessionId),onChange:()=>_r(Bt=>{const zt=new Set(Bt);return zt.has(V.sessionId)?zt.delete(V.sessionId):zt.add(V.sessionId),zt})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] text-foreground",children:V.name}),s.jsx(Zp,{session:V}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[Mh(V)," · ",V.cwd]})]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 pl-7",children:[s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:"定位"}),s.jsx("input",{"aria-label":`${V.name} 的定位`,className:`${ks} min-h-8 py-1 text-[10px]`,value:et,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:Bt=>Rt(zt=>({...zt,[V.sessionId]:Bt.target.value}))}),s.jsx("button",{"aria-label":`保存 ${V.name} 的定位`,title:et.trim()===kt?"定位未变化":"保存此成员的定位",disabled:W!==null||et.trim()===kt,className:`${Mr} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{hs(V.sessionId)},children:W===`role:${V.sessionId}`?s.jsx(vn,{size:12,className:"animate-spin"}):s.jsx(ci,{size:12})})]})]},V.sessionId)},zr=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e?"看板":"目标"],["messages","成员与消息"]].map(([V,et])=>s.jsxs("button",{type:"button","aria-label":et,"aria-pressed":fe===V,className:`${Mr} min-h-11 ${fe===V?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:kt=>{const Bt=kt.currentTarget.closest("[data-collaboration-views]");X(V),requestAnimationFrame(()=>Array.from(Bt?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(zt=>zt.getAttribute("aria-pressed")==="true"&&!zt.closest("[hidden]"))?.focus())},children:[e&&V==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:et})]}):et,!e&&V==="tasks"&&Qe>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[Qe," 待处理"]})]},V))}),wn=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":Ge,className:`${Mr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:()=>{pt(V=>!V),q(null),ne(null)},children:[s.jsx(bh,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{className:e?"flex min-h-0 flex-1 flex-col gap-3":"space-y-3",children:[Xe&&Ue==="ready"&&!Qh(Xe)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",Xe]}),Xe&&Qh(Xe)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?Ge?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[(!E||!lt)&&s.jsxs("div",{className:"flex items-center gap-2",children:[A.length>0?s.jsxs("label",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"sr-only",children:"选择协作组"}),s.jsxs("select",{className:ks,value:lt?.id??"new",onChange:V=>p(V.target.value),children:[!lt&&s.jsx("option",{value:"new",children:"新建协作组"}),A.map(V=>s.jsxs("option",{value:V.id,children:[V.name," · ",V.sessionIds.length," 个成员"]},V.id))]})]}):s.jsx("h3",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:"建立协作组"}),lt&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":Ge,className:`${Mr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:()=>{pt(V=>!V),q(null),ne(null)},children:s.jsx(bh,{size:14})}),s.jsx("button",{type:"button","aria-label":"新建协作组",title:"新建协作组",className:`${Mr} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:()=>{p("new"),de(!1),ne(null)},children:s.jsx(Ys,{size:14})})]})]}),Ge&&lt&&s.jsx(fP,{group:lt,activeSessionId:I,sessions:v,busy:W,setBusy:B,setError:q,setNotice:ne,refresh:Be,onClose:()=>pt(!1)},lt.id),!lt&&s.jsxs("section",{className:"border-y border-border/15 py-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"先建立项目或目标空间,再写下目标。开始协作时配置 Agent;也可以复用已有会话。"})]}),s.jsxs("span",{className:`shrink-0 text-[10px] ${Fr>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",Fr," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:ks,value:ue,onChange:V=>Ce(V.target.value),placeholder:"例如:发布准备"})]}),s.jsxs("details",{className:"mt-3",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["复用已有会话(选填) · 已选 ",Fr," 个"]}),v.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(Vl,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${ks} pl-8`,value:ce,onChange:V=>$e(V.target.value),placeholder:"按名称、目录或当前任务筛选"})]}),s.jsxs("div",{className:"mt-3 max-h-64 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[Wr.length<=1?Xr.map(Bn):Wr.map(V=>{const et=Ur(V.key);return s.jsxs("div",{children:[s.jsx($5,{label:V.label,count:V.sessions.length,collapsed:et,onToggle:()=>Cn(V.key)}),!et&&s.jsx("div",{className:"divide-y divide-border/10",children:V.sessions.map(Bn)})]},V.key)}),v.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:y==="loading"?"正在加载会话…":y==="error"?"会话加载失败,请重试":"没有现有会话也可以创建,开始目标时会启动 Agent"}),v.length>0&&Xr.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),ur.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",ur.length," 个所选会话暂不可用。",s.jsx("button",{className:Mr,onClick:()=>we(V=>new Set([...V].filter(et=>Gr.has(et)))),children:"清除不可用选择"})]}),s.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[s.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${Fr<2?"text-muted-foreground":"text-primary"}`,children:ue.trim()?"创建后进入看板,添加第一个目标":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[A.length>0&&s.jsx("button",{className:`${Mr} bg-surface-2 text-foreground`,onClick:()=>p(A[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:W!==null||!ue.trim()||ur.length>0,className:`${Mr} bg-primary text-primary-foreground`,onClick:()=>{Rn()},children:[W==="create-group"?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(Ys,{size:13}),"创建协作组"]})]})]})]})]}),lt&&!E&&s.jsxs("div",{className:"space-y-3 py-3",children:[s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"进入工作组看板,查看任务、处理问题和验收交付。"}),s.jsxs("button",{type:"button",className:`${Mr} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{Q?.(lt.id).catch(V=>q(V instanceof Error?V.message:"无法打开协作区"))},children:["打开 ",lt.name]})]}),lt&&E&&s.jsxs("div",{"data-collaboration-views":!0,hidden:Ge,className:e?`${Ge?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:"space-y-3",children:[(!e||fe==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[zr,s.jsx("div",{className:"ml-auto",children:wn})]}),fe==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:gr.map(V=>s.jsx("button",{type:"button","aria-pressed":V.sessionId===I,title:`${V.name} · ${V.cwd||"终端会话"}`,className:`${Mr} min-h-9 shrink-0 ${V.sessionId===I?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{P(V).catch(et=>q(et instanceof Error?et.message:"无法打开终端"))},children:dm(V,gr)},V.sessionId))}),s.jsx("div",{hidden:fe!=="tasks",className:e?`${fe==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(oP,{paneKey:l?Nn:void 0,boardNavigation:e?zr:void 0,boardSettings:e?wn:void 0,board:e,group:lt,sessions:v,agents:L,defaultCwd:v.find(V=>V.sessionId===I)?.cwd??void 0,onTeamReady:Be,active:t&&!Ge&&fe==="tasks"&&(!x||g),onAttentionChange:Pe,onManageMembers:()=>X("messages"),onOpenSession:P},lt.id)}),s.jsxs("div",{hidden:fe!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>Eu(Nn),onPointerDownCapture:()=>Eu(Nn),"data-termdock-terminal-dropzone":x?I??"collaboration-composer":void 0,onDragOver:V=>{x&&V.preventDefault()},onDrop:V=>{if(!x)return;const et=Array.from(V.dataTransfer.files);if(!(et.length&&ao()))if(V.preventDefault(),V.stopPropagation(),et.length)Gt(et);else{const kt=V.dataTransfer.getData("text/plain")||V.dataTransfer.getData("text/uri-list");kt&&At(Bt=>Bt+(Bt?`
153
+ `:"")+kt)}},ref:yr,className:x?"":"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[!x&&s.jsxs("h4",{className:"truncate text-[12px] font-medium text-foreground",children:[lt.name," · 发送给成员"]}),s.jsx("div",{className:x?"space-y-2":"mt-2 space-y-2",children:s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...lt.sessionIds.map(V=>({id:V,label:(()=>{const et=gr.find(kt=>kt.sessionId===V);return et?dm(et,gr):void 0})()??`${V.slice(0,8)}(离线)`}))].map(({id:V,label:et})=>{const kt=V==="*"?Ne===null:Ne?.includes(V)??!1,Bt=v.find(zt=>zt.sessionId===V);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":kt,onClick:()=>yt(zt=>V==="*"?null:zt?.includes(V)?zt.filter(gn=>gn!==V):[...zt??[],V]),className:`${Jm} min-h-9 min-w-0 gap-1 sm:min-h-7 ${kt?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[kt&&s.jsx(ci,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:et})]}),Bt&&s.jsx("button",{type:"button","aria-label":`打开 ${et} 的终端`,title:`打开 ${et} 的终端`,className:"inline-flex h-9 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-primary sm:h-7 sm:w-6",onClick:()=>{R(Bt).catch(zt=>q(zt instanceof Error?zt.message:"无法打开会话"))},children:s.jsx(ld,{size:12})})]},V)})})]})}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["内容",s.jsx("textarea",{onKeyDown:V=>{V.key==="Enter"&&(V.metaKey||V.ctrlKey)&&!V.nativeEvent.isComposing&&V.keyCode!==229&&(V.preventDefault(),Vr())},onPaste:V=>{const et=Array.from(V.clipboardData.files);et.length&&(V.preventDefault(),Gt(et))},className:`${ks} min-h-16 max-h-48 resize-y`,value:gt,onChange:V=>At(V.target.value),placeholder:"输入消息,可粘贴引用或文件…"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("p",{role:"status","aria-live":"polite",title:x&&r?r:void 0,className:`min-w-0 flex-1 text-[9px] leading-relaxed ${x?"truncate":""} ${x&&r?"text-primary":"text-muted-foreground"}`,children:Pr>0?"正在准备文件路径…":x&&r?r:lt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:W!==null||Pr>0||!gt.trim()||!hn.length,className:`${Mr} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Vr()},children:[W==="send-message"?s.jsx(vn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{className:"mt-4 rounded-xl border border-border/15",children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-3 text-[11px] font-medium text-foreground",children:["管理成员、角色与删除 · ",lt.sessionIds.length," 个成员"]}),s.jsxs("section",{className:"border-t border-border/15 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:lt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[lt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:lP(lt.id)})]})]}),je?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${Mr} bg-surface-2 px-2 text-foreground`,onClick:()=>de(!1),children:"取消"}),s.jsxs("button",{disabled:W!==null,className:`${Mr} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{ys()},children:[W===`delete:${lt.id}`?s.jsx(vn,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsxs("button",{className:`${Mr} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{_r(new Set(lt.sessionIds)),ze(lt.updatedAt);const V=!Ft;Z(V),V&&Rt(Object.fromEntries(lt.sessionIds.map(et=>[et,lt.roles?.[et]??""]))),ir(!1)},children:[s.jsx(bh,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${Mr} px-2 text-primary hover:bg-primary/10`,onClick:Sn,children:[s.jsx(Ys,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${lt.name}`,title:"删除协作组",disabled:W!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{Ee(lt.updatedAt),de(!0)},children:s.jsx(Zs,{size:14})})]})]}),je&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",lt.name,"”协作组及其协作记录,",lt.sessionIds.length," 个成员的终端会话会保留。"]}),s.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:lt.sessionIds.map(V=>{const et=v.find(zt=>zt.sessionId===V),kt=lt.roles?.[V],Bt=et?.name??V;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${Pt===V?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!et,onClick:()=>et&&void R(et).catch(zt=>q(zt instanceof Error?zt.message:"无法打开会话")),className:"min-w-0 flex-1 px-3 py-2.5 text-left disabled:cursor-default",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${et&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(et.status)&&et.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:Bt}),et&&s.jsx(Zp,{session:et}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:et?Mh(et):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[kt?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",kt]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,et?s.jsx("span",{className:"min-w-0 truncate",children:Kp(et.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${Bt} 移出协作组`,"aria-expanded":Pt===V,title:"移出协作组",disabled:W!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${Pt===V?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>hr(Pt===V?null:V),children:s.jsx(Zs,{size:13})})]},V)})}),Pt&&lt.sessionIds.includes(Pt)&&(()=>{const V=v.find(kt=>kt.sessionId===Pt)?.name??Pt,et=W===`remove-member:${Pt}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${V}`,className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-y border-destructive/25 bg-destructive/5 px-3 py-2.5",children:[s.jsx("p",{className:"min-w-0 flex-1 text-[10px] leading-relaxed text-destructive",children:`把“${V}”移出“${lt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${Mr} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>hr(null),children:"取消"}),s.jsxs("button",{disabled:W!==null,className:`${Mr} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{Vt(Pt)},children:[et?s.jsx(vn,{size:12,className:"animate-spin"}):s.jsx(Zs,{size:12}),"移出"]})]})]})})(),Ft&&s.jsxs("div",{className:"mt-4 border-t border-border/15 pt-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"管理成员"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"暂不可用的原成员会保留,只有取消勾选才会移出;定位(角色)在每行独立保存,成员收到消息时会看到自己的定位。"})]}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["已选 ",Zt.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:$r.length<=1?tn.map(Nr):$r.map(V=>{const et=Ur(V.key);return s.jsxs("div",{children:[s.jsx($5,{label:V.label,count:V.sessions.length,collapsed:et,onToggle:()=>Cn(V.key)}),!et&&s.jsx("div",{className:"divide-y divide-border/10",children:V.sessions.map(Nr)})]},V.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Mr} bg-surface-2 text-foreground`,onClick:()=>{Z(!1),Rt({})},children:"取消"}),s.jsxs("button",{disabled:W!==null||y!=="loaded",className:`${Mr} bg-primary text-primary-foreground`,onClick:()=>{cn()},children:[W==="save-members"?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(ci,{size:13}),"保存成员"]})]})]}),Mt&&s.jsxs("div",{className:"mt-4 border-t border-primary/20 pt-4",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"创建 Agent Session"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"新会话启动后自动加入本组,并收到初始任务和成员信息。"})]}),s.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["Agent / Plugin",s.jsx("select",{"aria-label":"新 Agent 类型",className:ks,value:Ut,onChange:V=>We(V.target.value),children:L.map(V=>s.jsxs("option",{value:V.slug,children:[V.displayName,V.isPlugin?" · Plugin":""]},V.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:ks,value:br,onChange:V=>Ze(V.target.value),placeholder:"留空则自动命名"})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["工作目录",s.jsx("input",{"aria-label":"新 Agent 工作目录",className:ks,value:Dt,onChange:V=>nt(V.target.value),placeholder:"默认继承当前会话"})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["初始任务",s.jsx("textarea",{"aria-label":"新 Agent 初始任务",className:`${ks} min-h-16 resize-y`,value:_t,onChange:V=>Qr(V.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Mr} bg-surface-2 text-foreground`,onClick:()=>ir(!1),children:"取消"}),s.jsxs("button",{disabled:W!==null||!Ut,className:`${Mr} bg-primary text-primary-foreground`,onClick:()=>{rs()},children:[W==="spawn-agent"?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(od,{size:13}),"创建并加入"]})]})]})]})]},lt.id),s.jsxs("section",{className:"mt-4",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[_n.length," 条"]})]}),s.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[s.jsxs("select",{"aria-label":"筛选回复类型",className:`${ks} w-auto`,value:Le,onChange:V=>te(V.target.value),children:[s.jsx("option",{value:"all",children:"全部类型"}),s.jsx("option",{value:"ack",children:"收到确认"}),s.jsx("option",{value:"progress",children:"进展"}),s.jsx("option",{value:"result",children:"结果与证据"})]}),s.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:ye,onChange:V=>ot(V.target.checked)}),"只看新记录"]}),s.jsx("button",{className:`${Mr} min-h-9 text-muted-foreground`,disabled:!qr.length,onClick:un,children:"标记当前记录已看"})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[_n.map(V=>s.jsxs("div",{className:"px-2 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-primary",children:V.responseKind==="ack"?"收到确认":V.responseKind==="progress"?"进展":V.responseKind==="result"?"结果":wP(V.kind)}),s.jsx("span",{children:V.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:V.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(V.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:V.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:V.status==="pending"?"已入队 · 等待投递":V.status==="failed"?"投递失败":V.status==="expired"?"消息已过期,未继续投递":"已写入接收方终端 · 等待接手确认"}),(V.task||V.failureReason)&&s.jsxs("details",{className:"mt-2 text-[10px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:"任务详情与证据"}),s.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:JSON.stringify(V.task??{failure_reason:V.failureReason},null,2)})]})]},V.key)),_n.length===0&&s.jsx(EP,{text:Fe?"正在加载协作记录…":_e.length?"没有符合筛选条件的新记录。可切换类型或取消“只看新记录”。":"还没有消息。可以先发一个任务或问题。"})]})]})]})]})]})]})}function fP({group:e,activeSessionId:t,sessions:r,busy:n,setBusy:a,setError:l,setNotice:c,refresh:h,onClose:p}){const[g,x]=b.useState(e),[y,A]=b.useState(e.name),[v,L]=b.useState(e.instructions?.text??""),[I,E]=b.useState(e.instructions?.version??""),[R,P]=b.useState(e.instructions?.text??""),Q=r.filter(X=>e.sessionIds.includes(X.sessionId)&&!m0(X.sessionId)),[$,W]=b.useState(()=>t&&Q.some(X=>X.sessionId===t)?t:""),B=new TextEncoder().encode(v).length,q=Q.some(X=>X.sessionId===$),ne=async()=>{if(!(n||!y.trim())){a("group-name"),l(null),c(null);try{const X=await Sc({id:g.id,name:y.trim(),sessionIds:g.sessionIds,expectedUpdatedAt:g.updatedAt});x(X.group),A(X.group.name),v===R&&(L(X.group.instructions?.text??""),P(X.group.instructions?.text??""),E(X.group.instructions?.version??"")),await h(),c("协作组名称已更新")}catch(X){l(X instanceof Error?X.message:"改名失败")}finally{a(null)}}},Be=async()=>{if(!(n||!q||B>8192)){a("group-rules"),l(null),c(null);try{const X=await Z8(g.id,{sessionId:$,text:v,expectedVersion:I});y===g.name&&A(X.group.name),x(X.group),P(X.group.instructions?.text??""),E(X.group.instructions?.version??""),await h(),c(v.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(X){l(X instanceof Error?X.message:"群规保存失败")}finally{a(null)}}},fe=()=>{x(e),A(e.name),L(e.instructions?.text??""),P(e.instructions?.text??""),E(e.instructions?.version??""),l(null)};return s.jsxs("section",{"aria-label":"协作组设置",className:"mt-3 rounded-xl border border-border/20 bg-surface-2 p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"组设置"}),s.jsx("button",{type:"button",disabled:!!n,"aria-label":"关闭组设置",className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-elevated",onClick:p,children:s.jsx(Wn,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:ks,value:y,maxLength:240,disabled:!!n,onChange:X=>A(X.target.value)})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!n||!y.trim()||y.trim()===g.name,className:`${Mr} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{ne()},children:n==="group-name"?"保存中…":"保存名称"})}),s.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/15 pt-3",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["由本组成员发布群规变更",s.jsxs("select",{className:ks,value:$,disabled:!!n||!Q.length,onChange:X=>W(X.target.value),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!Q.some(X=>X.sessionId===$)&&$&&s.jsx("option",{value:$,children:"原成员已不在组内,请重新选择"}),Q.map(X=>s.jsx("option",{value:X.sessionId,children:X.name},X.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${ks} min-h-24 resize-y`,value:v,maxLength:8192,disabled:!!n,onChange:X=>L(X.target.value),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!q&&s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:Q.length?"选择发布变更的成员后即可保存,不需要关闭工作台。":"当前服务没有本组成员,请先添加成员或切换到成员所在的服务。已有群规可在此查看。"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx("p",{className:`text-[9px] ${B>8192?"text-destructive":"text-muted-foreground"}`,children:B>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!n||!q||B>8192||v===R,className:`${Mr} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{Be()},children:n==="group-rules"?"保存中…":v.trim()?"保存群规":"清空群规"})]}),s.jsxs("div",{className:"mt-3 flex justify-between gap-2 border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button",disabled:!!n,className:`${Mr} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:fe,children:[s.jsx(vn,{size:12}),"重新载入",(y!==g.name||v!==R)&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!n,className:`${Mr} min-h-9 bg-surface text-foreground`,onClick:p,children:"完成"})]})]})}function pP({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:l,onSelectGroup:c}){const[h,p]=b.useState(null),[g,x]=b.useState(!1),y=e.services??[],A=e.removedServices??[],v=y.filter(E=>!E.connected),L=v.some(E=>E.groups?.some(R=>R.id===t)),I=async(E,R)=>{if(!r){n(`peer:${E}`),a(null),l(null);try{R?await rw(E):await nw(E),p(null),x(!1),l(R?"协作连接已恢复,正在连接服务":"协作连接已移除,不会再自动重连;已有会话和消息保留")}catch(P){a(P instanceof Error?P.message:R?"重新连接失败":"移除连接失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-4 shrink-0 rounded-lg border border-border/15",open:L||void 0,children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-2.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"协作连接与管理"}),s.jsx("span",{className:"ml-2",children:e.state==="loading"?"正在加载…":`${y.length-v.length} 个已连接${v.length?` · ${v.length} 个离线`:""}`})]}),s.jsxs("div",{className:"max-h-64 overflow-y-auto border-t border-border/15 px-3 py-2",children:[y.length>0&&s.jsx("p",{className:"mb-1 text-[10px] leading-relaxed text-muted-foreground",children:"与以下服务进行跨服务协作,名称与服务切换器一致。"}),v.length>0&&s.jsx("p",{className:"mb-2 text-[10px] leading-relaxed text-muted-foreground",children:L?"当前协作组的部分服务不可达,消息会保留并等待重连。":"其他服务暂时离线;当前服务内的协作可以继续。不再使用的连接可移除。"}),e.error&&s.jsx("p",{role:"status",className:"mb-2 break-words text-[10px] text-destructive",children:e.error}),e.state==="unsupported"&&s.jsx("p",{className:"mb-2 text-[10px] text-muted-foreground",children:"请更新客户端以管理跨服务连接。"}),s.jsx("div",{className:"divide-y divide-border/10",children:y.map(E=>s.jsxs("div",{className:"py-2.5",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[Kl({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${E.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:E.connected?"已连接":E.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx(mP,{service:E})]}),E.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${E.origin}`,className:`${Mr} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>p(h===E.serviceId?null:E.serviceId),children:[s.jsx(Zs,{size:12}),"移除"]})]}),!!E.groups?.length&&s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{children:"用于"}),E.groups.map(R=>s.jsx("button",{type:"button",className:"rounded px-1.5 py-1 text-primary hover:bg-primary/10",onClick:()=>c(R.id),children:R.name},R.id))]}),!E.connected&&E.error&&E.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:TP(E.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:E.error})]}),h===E.serviceId&&s.jsxs("div",{role:"group","aria-label":"确认移除协作连接",className:"mt-2 rounded-lg bg-surface-2 p-2.5",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-foreground",children:E.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${Mr} min-h-9 text-muted-foreground`,onClick:()=>p(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!E.groups?.length,className:`${Mr} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{I(E.serviceId,!1)},children:r===`peer:${E.serviceId}`?"正在移除…":"确认移除"})]})]})]},E.serviceId||E.origin))}),y.length===0&&e.state==="ready"&&s.jsx("p",{className:"py-2 text-[10px] text-muted-foreground",children:"当前没有其他协作服务,当前服务内仍可创建协作组。"}),v.length>0&&s.jsxs("button",{type:"button",className:`${Mr} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:tw,children:[s.jsx(vn,{size:12}),"重试连接"]}),A.length>0&&s.jsxs("div",{className:"mt-2 border-t border-border/15 pt-1",children:[s.jsx("button",{type:"button","aria-expanded":g,className:`${Mr} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(E=>!E),children:g?"收起恢复列表":"恢复已移除连接"}),g&&s.jsxs("section",{"aria-label":"恢复已移除连接",className:"mt-1 rounded-lg bg-surface-2 px-2.5 py-2",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"以下是恢复记录,连接已停用,不会自动重连。点击恢复后才会重新启用协作。"}),s.jsx("div",{className:"mt-1 divide-y divide-border/10",children:A.map(E=>s.jsxs("div",{className:"flex items-start gap-2 py-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"break-words text-[10px] text-foreground",children:[Kl({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:"ml-2 text-[9px] text-muted-foreground",children:"已停用"})]}),s.jsx("p",{className:"mt-0.5 select-text break-all text-[9px] text-muted-foreground",children:E.accessUrl||E.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!E.serviceId,className:`${Mr} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{I(E.serviceId,!0)},children:r===`peer:${E.serviceId}`?"恢复中…":"恢复连接"})]},E.serviceId||E.origin))})]})]})]})]},L?"affected":"other")}function mP({service:e}){let t=!1;try{t=["localhost","127.0.0.1","[::1]"].includes(new URL(e.origin).hostname)}catch{}const r=e.accessUrl||(t?"":e.origin);return s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"w-fit cursor-pointer py-1",children:"连接详情"}),s.jsxs("dl",{className:"mt-1 space-y-1 select-text break-all",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务地址:"}),s.jsx("dd",{className:"inline",children:r||"暂未获取,请在服务切换器中查看"})]}),e.serviceId&&s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务身份:"}),s.jsx("dd",{className:"inline",children:e.serviceId})]})]})]})}function Yp(e){return!m0(e.sessionId)||e.serviceConnected!==!1}function gP(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:m0(e.sessionId)?.origin??""}function F5(e){const t=new Map;for(const r of e){const n=gP(r),a=t.get(n)??{key:n,label:n?Kl(r):"本机服务",sessions:[]};n&&a.label==="远端服务"&&(a.label=Kl(r)),a.sessions.push(r),t.set(n,a)}return[...t.values()].sort((r,n)=>(r.key?1:0)-(n.key?1:0)||r.label.localeCompare(n.label))}function $5({label:e,count:t,collapsed:r,onToggle:n}){return s.jsxs("button",{type:"button","aria-expanded":!r,onClick:n,className:"flex w-full items-center gap-1.5 bg-surface-2/50 px-2 py-1.5 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsx(ol,{size:12,className:`shrink-0 transition-transform ${r?"-rotate-90":""}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wide",children:e}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground/70",children:t})]})}function xP(e,t){const r=new Map(t.map(n=>[n.sessionId,n]));for(const n of e?.sessionIds??[]){if(r.has(n))continue;const a=e?.remoteSessions?.find(l=>l.sessionId===n);r.set(n,a?{...a,status:"offline",serviceConnected:!1}:{sessionId:n,name:n,backendSessionId:null,cwd:"",agent:null,status:"offline",capability:"",currentTask:"暂不可用,保留成员身份",updatedAt:0,...m0(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function Zp({session:e}){return!e.serviceOrigin||e.serviceOrigin===window.location.origin?null:s.jsxs("span",{className:"inline-flex max-w-28 shrink-0 items-center gap-1 rounded border border-border/20 px-1 py-0.5 text-[9px] text-muted-foreground",children:[s.jsx(ld,{size:9}),s.jsx("span",{className:"truncate",children:Kl(e)})]})}function Mh(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":vP(e.status)}function bP(e,t=[]){if(!e)return;const r=t.some(a=>a.sessionId!==e.sessionId&&a.name.trim()===e.name.trim()),n=e.sessionId.startsWith("remote:")?Kl(e):"本机服务";return r?`${e.name} · ${n}`:e.name}async function yP(e){e.sessionId.startsWith("remote:")?await Tv(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function vP(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function Kp(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return cf(t.prompt)||"暂无任务摘要"}catch{}return cf(e)||"暂无任务摘要"}function wP(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function AP(e,t){const r=new Map(t.map(a=>[a.sessionId,bP(a,t)])),n=new Map;for(const a of e){const l=`${a.threadId}:${a.createdAt}:${a.fromSessionId??"user"}:${a.kind}:${a.responseKind??""}:${JSON.stringify(a.task??null)}:${a.content}`,c=n.get(l),h=r.get(a.toSessionId)??a.toSessionId.slice(0,8);if(c){c.toNames.push(h);const p={failed:-2,expired:-1,pending:0,delivered:1,read:2};p[a.status]<p[c.status]&&(c.status=a.status);continue}n.set(l,{key:l,kind:a.kind,content:a.content,createdAt:a.createdAt,fromName:a.fromSessionId?r.get(a.fromSessionId)??a.fromSessionId.slice(0,8):"你",toNames:[h],status:a.status,responseKind:a.responseKind,task:a.task,failureReason:a.failureReason})}return[...n.values()].sort((a,l)=>l.createdAt-a.createdAt)}function TP(e){return/timeout|timed out|超时|operation was aborted/i.test(e)?"连接超时,暂时无法访问该服务。请确认远端服务已启动,并检查网络或 VPN 连接。":/ECONNREFUSED|connection refused/i.test(e)?"远端拒绝连接,请确认服务已启动且端口正确。":/ENOTFOUND|EHOSTUNREACH|ENETUNREACH/i.test(e)?"无法访问远端地址,请检查地址和网络连接。":/certificate|fingerprint|TLS|证书/i.test(e)?"远端证书校验失败,请检查服务连接授权。":"服务连接暂时不可用,可查看连接详情并重试。"}function Xp({value:e,query:t}){const r=t.trim().toLocaleLowerCase();if(!r)return s.jsx(s.Fragment,{children:e});const n=e.toLocaleLowerCase(),a=[];let l=0,c;for(;(c=n.indexOf(r,l))>=0;)a.push(e.slice(l,c)),a.push(s.jsx("mark",{className:"rounded bg-primary/15 text-primary",children:e.slice(c,c+r.length)},c)),l=c+r.length;return a.push(e.slice(l)),s.jsx(s.Fragment,{children:a})}function SP({active:e,onClose:t,onNewSession:r,setError:n}){const[a,l]=b.useState(""),[c,h]=b.useState([]),[p,g]=b.useState(0),[x,y]=b.useState(),[A,v]=b.useState(50),[L,I]=b.useState(0),[E,R]=b.useState(!1),[P,Q]=b.useState(null),[$,W]=b.useState(null),B=b.useRef(null),q=b.useRef(0);b.useEffect(()=>{e&&B.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const fe=++q.current,X=new AbortController;let Qe;Q(null),R(!0);const Pe=async()=>{try{const ue=await sw(a.trim(),A,X.signal);if(fe!==q.current)return;h(ue.results),g(ue.total??ue.results.length),y(ue.index),ue.index?.building&&(Qe=window.setTimeout(()=>{Pe()},2500))}catch(ue){fe===q.current&&!X.signal.aborted&&Q(ue instanceof Error?ue.message:"搜索失败")}finally{fe===q.current&&R(!1)}};return Qe=window.setTimeout(()=>{Pe()},a.trim()?250:0),()=>{window.clearTimeout(Qe),X.abort(),++q.current}},[e,a,A,L]);const ne=fe=>{n(null),l(fe),h([]),g(0),v(50)},Be=async fe=>{if(!$){if(fe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:fe.sessionId})),t();return}if(!(!fe.nativeKey&&!fe.resumeHistoryId)){W(fe.sessionId),n(null);try{const X=fe.nativeKey?await iw(fe.nativeKey):await Pb(fe.resumeHistoryId);if("sessionId"in X&&X.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:X.sessionId}));else if(X.command)r({mode:"shell",cwd:X.cwd,command:X.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(X){n(X instanceof Error?X.message:"恢复失败")}finally{W(null)}}}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"历史会话搜索"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"搜索当前服务的 Codex、Claude 历史对话和 Termdock 终端记录,未启动的会话也能找到并恢复。"})]}),s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"搜索历史会话"}),s.jsx(Vl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:B,maxLength:512,className:`${ks} pl-9 pr-9`,value:a,onChange:fe=>ne(fe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),E?s.jsx(vn,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):a&&s.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>ne(""),children:s.jsx(Wn,{size:13})})]}),x?.building&&s.jsxs("div",{role:"status",className:"mt-2 text-[10px] text-muted-foreground",children:["正在建立历史索引:",x.indexed,"/",x.total," 个会话。可以先搜名称和目录,对话结果会自动补齐。"]}),x?.warning&&s.jsx("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:x.warning}),!!x?.failed&&s.jsxs("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:[x.failed," 个会话暂未完成索引,其余结果可正常使用。请稍后刷新重试。"]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[a.trim()?`找到 ${p} 个会话`:"最近的会话",p>c.length?` · 显示 ${c.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:E,className:`${Mr} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>I(fe=>fe+1),children:[s.jsx(vn,{size:12}),"刷新"]})]}),!a.trim()&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:"记得之前讨论过什么?输入一句话中的关键词,就能找到对应会话。历史对话与索引保存在当前服务机器上。"}),s.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:c.map(fe=>{const X=fe.live||!!(fe.nativeKey||fe.resumeHistoryId),Qe=$===fe.sessionId?"正在恢复…":fe.live?"打开会话":X?"恢复会话":"仅供查阅",Pe=fe.source==="codex"||fe.source==="claude"?fe.snippet:CP(fe),ue=fe.source==="codex"?"Codex 历史":fe.source==="claude"?"Claude 历史":"终端记录",Ce=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-words text-[12px] font-medium text-foreground",children:s.jsx(Xp,{value:fe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(Xp,{value:fe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${fe.live?"text-[var(--success)]":X?"text-primary":"text-muted-foreground"}`,children:Qe})]}),Pe&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(Xp,{value:Pe,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[ue," · ",uf(fe.updatedAt),a.trim()?` · ${fe.matchCount>=999?"999+":fe.matchCount} 处匹配`:"",X?"":" · 没有可恢复记录"]}),fe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:fe.agentNativeSessionId})]});return X?s.jsx("button",{disabled:!!$,onClick:()=>{Be(fe)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:Ce},fe.nativeKey||fe.sessionId):s.jsx("article",{className:"px-2 py-3",children:Ce},fe.sessionId)})}),p>c.length&&A<5e3&&s.jsx("button",{type:"button",disabled:E,className:`${Mr} w-full bg-surface-2 text-foreground`,onClick:()=>v(fe=>fe+50),children:E?"正在加载…":"加载更多会话"}),P&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",P,s.jsx("button",{type:"button",className:`${Mr} ml-2`,onClick:()=>I(fe=>fe+1),children:"重试"})]}),!E&&!P&&c.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx("p",{className:"text-[12px] text-foreground",children:x?.building?"历史对话仍在索引,请稍候":x?.warning||x?.failed?"暂未找到结果,部分历史记录尚不可搜索":a.trim()?`没有找到“${a.trim()}”`:"当前服务还没有可搜索的历史会话"}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x?.building?"新结果会自动显示,也可以先搜会话名称或目录。":"可尝试更短的关键词、项目目录或 session ID;其他机器的历史需切换到对应服务搜索。"}),a.trim()&&s.jsx("button",{className:`${Mr} mt-3 bg-surface-2 text-foreground`,onClick:()=>ne(""),children:"查看最近会话"})]})]})}function cf(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function CP(e){let t=cf(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return cf(t)}function _P(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(n=>`周${t[n]}`).join("、")} ${e.schedule.time}`}function LP(e,t=Date.now(),r=t){if(e.kind==="interval"){const l=e.everyMinutes*6e4,c=Math.max(0,t-r);return r+(Math.floor(c/l)+1)*l}const[n,a]=e.time.split(":").map(Number);for(let l=0;l<=7;l+=1){const c=new Date(t);if(c.setDate(c.getDate()+l),c.setHours(n,a,0,0),c.getTime()>t&&e.weekdays.includes(c.getDay()))return c.getTime()}return t}function uf(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function kP(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function IP(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function EP({text:e}){return s.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}function NP({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=Hr(),[a,l]=b.useState(!1),c=b.useRef(null),h=b.useRef(null),p=b.useRef(null),g=b.useId();return b.useLayoutEffect(()=>{if(!a)return;const x=c.current,y=p.current;if(!x||!y)return;const A=window.visualViewport,v=()=>{const I=x.getBoundingClientRect(),E=(A?.offsetLeft??0)+8,R=(A?.offsetTop??0)+8,P=(A?.width??window.innerWidth)-16,Q=(A?.offsetTop??0)+(A?.height??window.innerHeight)-8,$=Math.max(0,Math.min(256,P)),W=Math.max(0,I.top-R-4),B=Math.max(0,Q-I.bottom-4),q=W>=180||W>=B;Object.assign(y.style,{width:`${$}px`,left:`${Math.max(E,Math.min(I.right-$,E+P-$))}px`,top:`${q?I.top-4:I.bottom+4}px`,maxHeight:`${q?W:B}px`,transform:q?"translateY(-100%)":"none"})};v();const L=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return L?.observe(x),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),A?.addEventListener("resize",v),A?.addEventListener("scroll",v),()=>{L?.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),A?.removeEventListener("resize",v),A?.removeEventListener("scroll",v)}},[a]),b.useEffect(()=>{if(!a)return;p.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const x=y=>{y.target instanceof Node&&!c.current?.contains(y.target)&&!p.current?.contains(y.target)&&l(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[a]),s.jsxs("div",{ref:c,role:"group","data-sidebar-gesture-ignore":!0,"aria-label":n("sidebar.moreActions"),className:"relative z-20 mt-2 flex items-center justify-between gap-2",onKeyDown:x=>{a&&x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),l(!1),h.current?.focus({preventScroll:!0}))},children:[s.jsxs("button",{type:"button",onClick:e,title:t?n("sidebar.serverAttention"):void 0,className:"inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(vT,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:n("sidebar.settings")})]}),s.jsxs("button",{ref:h,type:"button","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?g:void 0,onClick:()=>l(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),l(!0))},className:`inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${a?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(ll,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&ki.createPortal(s.jsx("div",{ref:p,id:g,role:"menu","data-sidebar-gesture-ignore":!0,"data-sidebar-composer-popover":"sidebar-launch-options","aria-label":n("sidebar.moreActions"),className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)] animate-fade-in",onKeyDown:x=>{const y=[...x.currentTarget.querySelectorAll('[role="menuitem"]')],A=y.indexOf(document.activeElement);let v;if(x.key==="ArrowDown")v=(A+1)%y.length;else if(x.key==="ArrowUp")v=(A-1+y.length)%y.length;else if(x.key==="Home")v=0;else if(x.key==="End")v=y.length-1;else if(x.key==="Tab"){l(!1);return}else return;x.preventDefault(),y[v]?.focus({preventScroll:!0})},children:r.map(({label:x,icon:y,onSelect:A,separated:v})=>s.jsxs("div",{role:"none",children:[v&&s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/40"}),s.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{l(!1),A()},className:"flex min-h-10 w-full items-center gap-2.5 whitespace-nowrap rounded-lg px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",children:[s.jsx(y,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{children:x})]})]},x))}),document.body)]})}const hu=64,U5=10,RP=120;function MP({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:l,compact:c}){const h=b.useRef(null),p=b.useRef(null),g=b.useRef(0),[x,y]=b.useState(null),A=x??(t?hu:0);return b.useEffect(()=>{if(!t)return;const v=L=>{L.target instanceof Node&&!h.current?.contains(L.target)&&r(!1)};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[t,r]),s.jsxs("div",{ref:h,"data-sidebar-gesture-ignore":!0,"data-session-swipe":!0,className:`relative flex min-w-0 flex-1 items-center ${c?"":"gap-1"}`,style:{touchAction:"pan-y"},onPointerDown:v=>{if(g.current=0,!(v.pointerType!=="touch"&&v.pointerType!=="pen")){if(v.isPrimary===!1){p.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(p.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?hu:0,offset:t?hu:0,horizontal:!1})}},onPointerMove:v=>{const L=p.current;if(!L||L.pointerId!==v.pointerId)return;const I=v.clientX-L.x,E=v.clientY-L.y;if(!L.horizontal){if(v.defaultPrevented||Date.now()-L.startedAt>=RP||Math.abs(E)>U5){p.current=null;return}if(Math.abs(I)<=U5)return;if(Math.abs(I)<Math.abs(E)*1.5||!t&&I<0){p.current=null;return}L.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),L.offset=Math.max(0,Math.min(hu,L.initialOffset+I)),y(L.offset)},onPointerUp:v=>{const L=p.current;!L||L.pointerId!==v.pointerId||(p.current=null,L.horizontal&&(g.current=Date.now()+600,r(L.offset>=hu/2),y(null)))},onPointerCancel:()=>{p.current?.horizontal&&(g.current=Date.now()+600),p.current=null,y(null)},onClickCapture:v=>{if(Date.now()<g.current){g.current=0,v.preventDefault(),v.stopPropagation();return}t&&v.target instanceof Element&&v.target.closest(".sidebar-session-primary")&&(r(!1),v.preventDefault(),v.stopPropagation())},onKeyDown:v=>{t&&v.key==="Escape"&&(v.stopPropagation(),r(!1))},children:[s.jsx("div",{className:"shrink-0 overflow-hidden rounded-md transition-[width] duration-150 ease-out motion-reduce:transition-none",style:{width:A,transition:x===null?void 0:"none"},children:A>0&&s.jsxs("button",{type:"button",tabIndex:t?0:-1,"aria-hidden":!t,"aria-label":l,className:"flex min-h-8 w-16 flex-col items-center justify-center gap-0.5 bg-destructive py-1 text-[10px] text-destructive-foreground",onClick:v=>{v.stopPropagation(),r(!1),n(v)},children:[s.jsx(Zs,{size:14}),a]})}),e]})}function DP(e,t){return mw(e,t)}function fu(e,t){const r=new Set(e),n=t.filter(l=>l.sessionIds.length>=2&&l.sessionIds.every(c=>r.has(c))),a=new Set;return e.flatMap(l=>{const c=n.find(h=>h.sessionIds.includes(l));return c?a.has(c.id)?[]:(a.add(c.id),[{sessionIds:c.sessionIds,workspace:c}]):[{sessionIds:[l]}]})}function pu(e,t,r,n=[]){const a=new Map,l=new Map,c=new Set(e.map(x=>x.id));for(const x of n){const y=x.sessionIds.filter(v=>c.has(v));if(!y.length)continue;const A=y.length===x.sessionIds.length?x:{...x,sessionIds:y};y.forEach(v=>a.set(v,A))}for(const x of t)if(!(x.sessionIds.length<2||!x.sessionIds.every(y=>c.has(y)))&&!x.sessionIds.some(y=>a.has(y)))for(const y of x.sessionIds)l.set(y,x);const h=new Set,p=new Set,g=[];for(const x of e){const y=a.get(x.id);if(y){if(h.has(y.id))continue;h.add(y.id);const L=y.sessionIds.flatMap(I=>{const E=r.get(I);return E?[E]:[]});g.push({kind:"collaboration",id:`collaboration:${y.id}`,group:y,members:L,sessionIds:y.sessionIds});continue}const A=l.get(x.id);if(!A){g.push({kind:"session",id:`session:${x.id}`,session:x,sessionIds:[x.id]});continue}if(p.has(A.id))continue;p.add(A.id);const v=A.sessionIds.flatMap(L=>{const I=r.get(L);return I?[I]:[]});g.push({kind:"workspace",id:`workspace:${A.id}`,workspace:A,members:v,sessionIds:A.sessionIds})}return g}function z5(e,t,r){const n=Math.min(e.length,Math.max(0,r)),a=e.slice(0,n).flatMap(c=>c.sessionIds.filter(h=>h!==t)),l=e.slice(n).flatMap(c=>c.sessionIds.filter(h=>h!==t));return[...a,t,...l]}function jP({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(_Q,{status:e,detail:t,needsReview:r,inCopyMode:n})}function H5({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:l,sessionStates:c,onJumpToNextAttention:h,onNewSession:p,onCloseSession:g,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:A,splitWorkspaces:v,onSetSplitLayout:L,onReorderSplitWorkspace:I,onCombineSplitSessions:E,onReorderSessions:R,onSessionMenu:P,onOpenSettings:Q,onOpenQuota:$,updateState:W,updateActionPending:B=!1,onConfirmUpdateRestart:q,onRetryUpdate:ne,serverHealthState:Be,tmuxAvailable:fe=!0,defaultSessionMode:X="shell",push:Qe,pinned:Pe,onTogglePinned:ue,recoverableTmuxSessions:Ce=[],recoverableTmuxSessionsLoading:tt=!1,onRefreshRecoverableTmuxSessions:we}){const{t:ce}=Hr(),[,$e]=b.useState(0),[ke,se]=b.useState(null),[je,de]=b.useState(!1),[Oe,Ee]=b.useState(!1),_e=yc(z=>z.groupId),[re,Fe]=b.useState({}),wt=Oe||Object.keys(re).length>0,Xe=b.useRef(!1);b.useEffect(()=>{let z=!1;return ec().then(ge=>{z||Xe.current||Fe(Object.fromEntries(t3(ge.collaborationPanels?.[ff()]).map(Ye=>[Ye,!0])))}).catch(()=>{}),()=>{z=!0}},[]);const ee=async(z,ge)=>{Xe.current=!0,await al({floatingGroupId:ge},z),Fe(Ye=>({...Ye,[z]:ge!==null}))},[Ue,Le]=b.useState([]),[te,ye]=b.useState(!1),[ot,le]=b.useState(null),[xe,Ne]=b.useState(null),[yt,gt]=b.useState(null),[At,Ft]=b.useState(null),Z=s0(z=>z.tasks),Ge=s0(z=>z.allTasks),[pt,Pt]=b.useState(0),[hr,Zt]=b.useState(null),_r=b.useRef(!1),[ae,ze]=b.useState({}),Je=s0(z=>z.error),[Rt,Mt]=b.useState(!1);b.useEffect(()=>{const z=()=>{document.hidden||s0.getState().refresh()};z();const ge=window.setInterval(z,5e3);return document.addEventListener("visibilitychange",z),()=>{clearInterval(ge),document.removeEventListener("visibilitychange",z)}},[]);const ir=async z=>(Xe.current=!0,z?(ts.getState().setDock(z,null),Fe(ge=>{const Ye={...ge};return delete Ye[z],Ye}),yc.getState().open(z),Vt(),!0):(Ee(!0),Vt(),!0)),Ut=Fh(z=>z.collaborationGroups),We=Fh(z=>z.setCollaborationGroups),[br,Ze]=b.useState({mode:X}),{preference:Dt,agents:nt,detecting:_t,refresh:Qr,selectAgent:yr}=eP(),Nt=b.useRef(null),Nn=!!(W?.latestVersion&&["installing","ready","restarting","error"].includes(W.status)),Zr=!!Be?.attention,lt=[ce("sidebar.moreActions"),Zr?ce("sidebar.serverAttention"):null,Nn&&W?.latestVersion?ce("sidebar.updateAvailable",{version:W.latestVersion}):null].filter(Boolean).join(": "),gr=sr(z=>z.groupByFolder),Pr=sr(z=>z.collapsedGroups),be=sr(z=>z.toggleGroupCollapsed),Er=b.useRef(null),at=b.useRef(null),en=b.useRef(null),Te=b.useRef(0),Lt=b.useRef(!1),Y=b.useRef(null),st=b.useRef(null),[xt,Gt]=b.useState(!1),Gr=b.useRef([]),Fr=b.useRef(null),ur=b.useRef(null),tn=b.useRef(new Set),on=b.useRef(null),Xr=b.useMemo(()=>new Set(v.flatMap(z=>z.sessionIds)),[v]),Wr=b.useMemo(()=>new Map(a.map(z=>[z.id,z])),[a]),$r=b.useMemo(()=>DP(Ut,new Set(Wr.keys())),[Ut,Wr]),Ur=b.useCallback(async()=>{const z=++Te.current;try{const ge=await Qb();if(z!==Te.current)return;We(Array.isArray(ge.groups)?ge.groups:[])}catch{}},[]);b.useEffect(()=>Bb(z=>We(z.groups)),[]),b.useEffect(()=>{Ur();const z=window.setInterval(()=>{Ur()},1e4),ge=()=>{Ur()};return window.addEventListener("focus",ge),()=>{Te.current+=1,window.clearInterval(z),window.removeEventListener("focus",ge)}},[Ur]),b.useEffect(()=>{(e||!wt)&&Ur()},[wt,e,Ur]);const Cn=b.useCallback(()=>{Gr.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(z=>{const ge=z.dataset.collaborationMember??"",Ye=z.hasAttribute("data-collaboration-background"),ct=z.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!ge&&!Ye||!ct)return[];const it=[];for(let bt=z.parentElement;bt;bt=bt.parentElement)it.push({element:bt,top:bt.scrollTop,left:bt.scrollLeft});return[{element:z,sessionId:ge,groupId:ct,background:Ye,rect:z.getBoundingClientRect(),scrollParents:it}]})},[]),Rn=b.useCallback((z,ge)=>{if(!Lt.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(rt=>rt.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(rt=>rt.removeAttribute("data-drop-active"));const ct=document.elementsFromPoint(z,ge).map(rt=>rt.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(ct?.dataset.collaborationGroup){ct.dataset.dropActive="true",ur.current={kind:"collaboration",groupId:ct.dataset.collaborationGroup,background:!0};return}const it=Gr.current.find(rt=>{if(rt.sessionId===st.current||!rt.element.isConnected)return!1;const jt=rt.scrollParents.reduce((G,he)=>G+he.element.scrollLeft-he.left,0),U=rt.scrollParents.reduce((G,he)=>G+he.element.scrollTop-he.top,0);return z>=rt.rect.left-jt&&z<=rt.rect.right-jt&&ge>=rt.rect.top-U+rt.rect.height*.25&&ge<=rt.rect.bottom-U-rt.rect.height*.25});if(it?.background){it.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),ur.current={kind:"collaboration",groupId:it.groupId,background:!0};return}if(it&&!v.find(jt=>jt.sessionIds.includes(it.sessionId))?.sessionIds.includes(st.current??"")){it.element.dataset.dropActive="true",ur.current={kind:"split",sessionId:it.sessionId,groupId:it.groupId};return}const bt=document.elementsFromPoint(z,ge).filter(rt=>{const jt=rt.closest("[data-rfd-draggable-id]");return!jt||!["session:","split-member:","collaboration-member:"].some(U=>jt.dataset.rfdDraggableId===`${U}${st.current}`)}),Ot=bt.map(rt=>rt.closest("[data-collaboration-group]")).find(rt=>rt?.dataset.collaborationGroup);if(Ot?.dataset.collaborationGroup){const rt=Ot.dataset.collaborationGroup,jt=bt.map(Me=>Me.closest("[data-collaboration-split]")).find(Boolean),U=bt.map(Me=>Me.closest("[data-collaboration-member]")).find(Boolean),G=U?.dataset.collaborationMember??jt?.dataset.splitAnchor,he=rt===Y.current&&v.some(Me=>Me.sessionIds.includes(G??"")&&Me.sessionIds.includes(st.current??""));if(G&&!he&&(rt!==Y.current||!U&&jt)){Ot.dataset.dropActive="true";const Me=U??jt;Me&&(Me.dataset.dropActive="true"),ur.current={kind:"split",sessionId:G,groupId:rt}}else{const Me=bt.some(Qt=>Qt.closest("[data-collaboration-background]"));(rt!==Y.current||Me)&&(Ot.dataset.dropActive="true"),ur.current={kind:"collaboration",groupId:rt,background:Me}}return}const dt=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(rt=>rt.dataset.sidebarEntityListId===Fr.current).find(rt=>{const jt=rt.getBoundingClientRect();return z>=jt.left&&z<=jt.right&&ge>=jt.top-8&&ge<=jt.bottom+8});if(!dt){ur.current=null;return}const nr=Array.from(dt.children).filter(rt=>rt instanceof HTMLElement&&rt.hasAttribute("data-sidebar-entity-index")),Lr=nr.findIndex(rt=>{const jt=rt.getBoundingClientRect();return ge<jt.top+jt.height/2}),vr=Lr<0?nr.length:Lr;ur.current={kind:"list",listId:dt.dataset.sidebarEntityListId??"",index:vr};const $t=Array.from(dt.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(rt=>rt.dataset.splitExitDropIndex===String(vr));$t instanceof HTMLElement&&($t.dataset.active="true")},[v]);b.useEffect(()=>{const z=Ye=>Rn(Ye.clientX,Ye.clientY),ge=Ye=>{const ct=Ye.touches[0];ct&&Rn(ct.clientX,ct.clientY)};return window.addEventListener("pointermove",z),window.addEventListener("touchmove",ge,{passive:!0}),()=>{window.removeEventListener("pointermove",z),window.removeEventListener("touchmove",ge)}},[Rn]);const hn=b.useCallback((z,ge)=>{try{z(ge)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach(Ye=>{delete Ye.dataset.sidebarDragging}),Lt.current=!1,Gr.current=[],Gt(!1),Y.current=null,st.current=null,Fr.current=null,ur.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ye=>Ye.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ye=>Ye.removeAttribute("data-drop-active"))}},[]),Vr=b.useMemo(()=>a.filter(z=>!Xr.has(z.id)),[a,Xr]),ys=b.useMemo(()=>{let z=0;for(const ge of a)c.get(ge.id)?.agentStatus==="working"&&(z+=1);return z},[a,c]);b.useLayoutEffect(()=>{const z=Er.current,ge=at.current;if(!e||!z||!ge){en.current=null;return}const Ye=ge.getBoundingClientRect(),ct=z.getBoundingClientRect(),it={item:z,top:Math.round(ct.top-Ye.top+ge.scrollTop),height:Math.round(ct.height),viewportHeight:ge.clientHeight},bt=en.current;if(en.current=it,bt?.item===it.item&&bt.top===it.top&&bt.height===it.height&&bt.viewportHeight===it.viewportHeight||Lt.current||ge.clientHeight===0)return;const Ot=8,qt=ct.top-Ye.top,dt=ct.bottom-Ye.top;qt<Ot?ge.scrollTop+=qt-Ot:dt>ge.clientHeight-Ot&&(ge.scrollTop+=dt-ge.clientHeight+Ot)});const cn=b.useMemo(()=>{if(!gr||!l)return null;const z=c.get(l)?.cwd??null;return ow(z)},[gr,l,c]);b.useEffect(()=>{if(!gr){on.current=null,tn.current.clear();return}if(!l){on.current=null;return}const z=sr.getState(),ge=tn.current,Ye=on.current,ct=cn;Ye!==null&&Ye!==ct&&ge.has(Ye)&&(z.collapsedGroups.has(Ye)||z.toggleGroupCollapsed(Ye),ge.delete(Ye)),ct!==null&&ct!==""&&z.collapsedGroups.has(ct)&&(z.toggleGroupCollapsed(ct),ge.add(ct)),on.current=ct},[gr,l,cn]),b.useEffect(()=>{e||de(!1)},[e]),b.useEffect(()=>{Ze(z=>({...z,command:Dt?.command}))},[Dt]),b.useEffect(()=>{if(!je)return;let z=!1;return ye(!0),Ne(null),Tg().then(ge=>{z||Le(ge)}).catch(()=>{z||Ne(ce("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{z||ye(!1)}),()=>{z=!0}},[je,ce]),b.useEffect(()=>{if(!ke)return;const z=ge=>{ge instanceof KeyboardEvent&&ge.key!=="Escape"||ge instanceof PointerEvent&&ge.target instanceof Node&&Nt.current?.contains(ge.target)||se(null)};return window.addEventListener("pointerdown",z),window.addEventListener("keydown",z),()=>{window.removeEventListener("pointerdown",z),window.removeEventListener("keydown",z)}},[ke]);const Vt=()=>{!Qe&&!Pe&&r()},hs=X==="tmux"&&!fe?"shell":X,Sn=()=>{p({mode:hs}),Vt()},rs=()=>{Dt&&(p({mode:hs,command:Dt.command}),Vt())},qr=z=>{gt(z.name),p({mode:"tmux",tmuxSessionName:z.name,cwd:z.cwd??void 0}),Vt()};b.useEffect(()=>{yt&&(Ce.some(z=>z.name===yt)||gt(null))},[yt,Ce]);const _n=(z,ge)=>{p({...br,cwd:br.cwd?.trim()||void 0,command:ge??z?.command}),de(!1),Vt()},un=async z=>{le(z.id),Ne(null);try{const ge=await Pb(z.id);p({mode:"shell",cwd:ge.cwd,command:ge.command}),de(!1),Vt()}catch(ge){const Ye=ge&&typeof ge=="object"&&"code"in ge?String(ge.code??""):"";Ne(ce(Ye==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{le(null)}},Bn=async z=>{Le(ge=>ge.filter(Ye=>Ye.id!==z));try{await xw(z)}catch{Ne(ce("sidebar.resumeHistoryRemoveFailed")),Tg().then(Le).catch(()=>{})}},Nr=()=>{if(je){de(!1);return}Ze({mode:X==="tmux"&&!fe?"shell":X,cwd:l?c.get(l)?.cwd??void 0:void 0,command:Dt?.command}),de(!0)},zr=b.useCallback(z=>{const ge=c.get(z);return ge?.agentStatus==="waiting"||ge?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":ge?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":ge?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[c]),wn=Av(),[V,et]=b.useState(null);b.useEffect(()=>{e||et(null)},[e]);const kt=b.useCallback((z,ge,Ye,ct,it)=>{const bt=!_e&&z.id===l,Ot=Xr.has(z.id),qt=!!(Ye&&Ot),dt=c.get(z.id),nr=$u(dt?.cwd??null),Lr=dt?.shellTitle??lw(z.id),vr=Lr===dt?.cwd||Lr===nr?null:Lr,$t=cw(z,dt?.activeProgram??null,null,uw,vr,dt?.promptState??null),rt=!!(dt?.tuiProgress&&dt.tuiProgress.state!=="remove"),U=dt?.promptState==="running"||dt?.agentStatus==="working"||rt?"bg-[var(--success)]":dt?.agentStatus==="waiting"||dt?.agentNeedsReview?"bg-[var(--warning)]":dt?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(MP,{open:V===z.id,onOpenChange:G=>et(he=>G?z.id:he===z.id?null:he),onClose:G=>g(z.id,G,{skipConfirmation:!0}),closeLabel:ce("common.close"),closeTitle:ce("sidebar.closeSession",{name:$t}),compact:Ye,children:[s.jsxs("button",{ref:bt?Er:null,type:"button",...ge??{},onContextMenu:G=>{P&&(G.preventDefault(),P(z.id,{x:G.clientX,y:G.clientY}))},onClick:()=>{yc.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:z.id})),Vt()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${ge?"cursor-grab active:cursor-grabbing ":""}${Ye?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:dt?.cwd??z.name,children:[bt&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${U}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${Ye?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${bt?z.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":z.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[dt?.isConnecting||rt&&!dt?.agentStatus?s.jsx(En,{size:Ye?10:11,className:"animate-spin"}):dt?.agent??Sg(z.id)?s.jsx(Ic,{agent:dt?.agent??Sg(z.id),size:Ye?13:15}):z.mode==="tmux"?s.jsx(x0,{size:Ye?10:11}):s.jsx(Eo,{size:Ye?10:11}),s.jsx(jP,{status:dt?.agentStatus??null,detail:dt?.agentStatusDetail,needsReview:dt?.agentNeedsReview,inCopyMode:dt?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${Ye?"text-[11px]":"text-[12px]"} ${bt?"font-medium text-foreground":""} ${dt?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:$t}),s.jsx(e5,{sessionIds:[z.id]})]}),ct,s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),qt?A(z.id):Ot?y(z.id):x(z.id)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Ye?"h-6 w-6":"h-[26px] w-[26px]"} ${Ot?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${ce(qt?"tab.splitRemovePane":Ot?"tab.splitClose":"tab.split")} ${$t}`,title:ce(qt?"tab.splitRemovePane":Ot?"tab.splitClose":"tab.split"),children:qt?s.jsx(jT,{size:11}):s.jsx(Cl,{size:12})}),it??s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),g(z.id,G)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95 ${Ye?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":ce("sidebar.closeSession",{name:$t}),title:ce("common.close"),children:s.jsx(Wn,{size:Ye?11:12})})]})},[l,Xr,c,g,x,y,A,P,ce,V]),Bt=b.useMemo(()=>jh(a,z=>c.get(z.id)?.cwd??null,gr,ce("sidebar.ungrouped"),v,$r).groups,[$r,gr,a,c,v,ce]),zt=b.useMemo(()=>pu(a,v,Wr,$r),[$r,a,Wr,v]),gn=b.useCallback(z=>{Gt(z.draggableId.startsWith("collaboration:")||z.draggableId.startsWith("workspace:"));const ge=z.draggableId.replace(/^split-member:/,"");st.current=z.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const Ye=z.type==="split-member"?v.find(qt=>qt.sessionIds.includes(ge)):null,ct=z.type==="collaboration-member"?z.source.droppableId.replace(/^collaboration-members:/,""):null,it=ct?$r.find(qt=>qt.id===ct):null;Lt.current=!!(Ye||it||z.type==="session"&&z.draggableId.startsWith("session:")),Lt.current&&document.querySelectorAll("[data-collaboration-group]").forEach(qt=>{qt.dataset.sidebarDragging="true"}),Y.current=it?.id??null;const bt=Ye?.sessionIds??it?.sessionIds??[],Ot=bt.length>0?Bt.find(qt=>bt.every(dt=>qt.sessions.some(nr=>nr.id===dt))):null;Fr.current=gr?Ot?`group-sessions:${Ot.key}`:null:bt.length>0?"sidebar-entities":null,ur.current=null},[$r,Bt,gr,v]),lr=b.useCallback((z,ge,Ye)=>{if(ge===Ye)return;const ct=ge?Ut.find(dt=>dt.id===ge):null,it=Ye?Ut.find(dt=>dt.id===Ye):null;if(Ye&&!it)return;if(it){const dt=a.map(Lr=>Lr.id).filter(Lr=>Lr!==z);let nr=-1;dt.forEach((Lr,vr)=>{it.sessionIds.includes(Lr)&&(nr=vr)}),nr>=0&&(dt.splice(nr+1,0,z),R(dt))}const bt=ct?.sessionIds.filter(dt=>dt!==z)??[],Ot=it?[...it.sessionIds.filter(dt=>dt!==z),z]:[];We(dt=>dt.flatMap(nr=>nr.id===ge?[{...nr,sessionIds:bt}]:nr.id===Ye?[{...nr,sessionIds:Ot}]:[nr])),Ft(null),(ct&&it?dw({sourceGroupId:ct.id,targetGroupId:it.id,sessionId:z,expectedSourceUpdatedAt:ct.updatedAt,expectedTargetUpdatedAt:it.updatedAt}):ct?Sc({id:ct.id,name:ct.name,sessionIds:bt,expectedUpdatedAt:ct.updatedAt}):it?Sc({id:it.id,name:it.name,sessionIds:Ot,expectedUpdatedAt:it.updatedAt}):Promise.resolve()).then(()=>Ur(),dt=>(Ft(dt instanceof Error?dt.message:"协作成员移动失败"),Ur()))},[Ut,Ur,a,R]),yn=b.useCallback((z,ge,Ye,ct=!1)=>{const it=Ut.find(jt=>jt.id===z);if(!it||ge===Ye)return;const bt=it.sessionIds.filter(jt=>!jt.startsWith("remote:")),Ot=fu(bt,v).flatMap(jt=>jt.sessionIds),qt=Xx(Ge,it.id),dt=ct&&!ae[it.id]?Ot.filter(jt=>!qt.has(jt)||jt===l||Xr.has(jt)):Ot.slice(),nr=new Set(dt),[Lr]=dt.splice(ge,1);if(!Lr)return;dt.splice(Ye,0,Lr);let vr=0;const $t=Ot.map(jt=>nr.has(jt)?dt[vr++]:jt),rt=v.find(jt=>jt.sessionIds.includes(Lr));if(rt&&rt.sessionIds.every(jt=>it.sessionIds.includes(jt))){const jt=$t.filter(U=>rt.sessionIds.includes(U));I(rt.id,jt)}$t.push(...it.sessionIds.filter(jt=>jt.startsWith("remote:"))),We(jt=>jt.map(U=>U.id===z?{...U,sessionIds:$t}:U)),Ft(null),Sc({id:it.id,name:it.name,sessionIds:$t,expectedUpdatedAt:it.updatedAt}).then(()=>Ur(),jt=>(Ft(jt instanceof Error?jt.message:"成员排序失败"),Ur()))},[Ut,Ur,v,I,Ge,ae,l,Xr]);b.useEffect(()=>{const z=ge=>{const{sourceId:Ye,targetId:ct}=ge.detail;if(!Ye||!ct||Ye===ct)return;const it=jh(a,G=>c.get(G.id)?.cwd??null,gr,"",v,$r).arranged.map(G=>G.id),bt=it.indexOf(Ye),Ot=it.indexOf(ct);if(bt<0||Ot<0)return;const qt=$r.find(G=>G.sessionIds.includes(Ye));if(qt?.sessionIds.includes(ct)){const G=fu(qt.sessionIds,v).flatMap(he=>he.sessionIds);yn(qt.id,G.indexOf(Ye),G.indexOf(ct));return}const dt=v.filter(G=>G.sessionIds.length>=2&&G.sessionIds.every(he=>Wr.has(he))&&!$r.some(he=>G.sessionIds.some(Me=>he.sessionIds.includes(Me)))),nr=dt.find(G=>G.sessionIds.includes(Ye));if(nr?.sessionIds.includes(ct)){const G=[...nr.sessionIds];G.splice(G.indexOf(Ye),1),G.splice(nr.sessionIds.indexOf(ct),0,Ye),I(nr.id,G);return}const Lr=G=>$r.find(he=>he.sessionIds.includes(G))?.sessionIds??dt.find(he=>he.sessionIds.includes(G))?.sessionIds??[G],vr=new Set(Lr(Ye)),$t=new Set(Lr(ct)),rt=it.filter(G=>!vr.has(G)),jt=rt.flatMap((G,he)=>$t.has(G)?[he]:[]),U=bt<Ot?Math.max(...jt)+1:Math.min(...jt);rt.splice(U,0,...it.filter(G=>vr.has(G))),R(rt)};return window.addEventListener("reorder-navigation-session",z),()=>window.removeEventListener("reorder-navigation-session",z)},[a,c,gr,v,$r,Wr,yn,I,R]);const ar=b.useCallback(z=>{if(z.type!=="collaboration-member")return!1;if(z.reason==="CANCEL")return!0;const ge=z.source.droppableId.replace(/^collaboration-members:/,""),Ye=z.draggableId.replace(/^collaboration-member:/,""),ct=ur.current;if(ct?.kind==="split")return lr(Ye,ge,ct.groupId),E(ct.sessionId,Ye),!0;if(ct?.kind==="collaboration"&&ct.groupId!==ge)return lr(Ye,ge,ct.groupId),!0;if(ct?.kind==="collaboration"&&ct.background)return Xr.has(Ye)&&A(Ye),!0;if(z.destination&&z.destination.droppableId!==z.source.droppableId){const it=z.destination.droppableId.replace(/^collaboration-members:/,"");if($r.some(bt=>bt.id===it))return lr(Ye,ge,it),!0}if(z.combine){const it=z.combine.droppableId.replace(/^collaboration-members:/,"");it!==ge&&lr(Ye,ge,it);const bt=z.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(qt=>qt.sessionIds.includes(Ye))?.sessionIds.includes(bt)){const qt=$r.find(nr=>nr.id===ge),dt=qt?fu(qt.sessionIds,v).flatMap(nr=>nr.sessionIds).indexOf(bt):-1;dt>=0&&qt&&yn(ge,fu(qt.sessionIds,v).flatMap(nr=>nr.sessionIds).indexOf(Ye),dt)}else Wr.has(bt)&&E(bt,Ye);return!0}if(z.destination?.droppableId===z.source.droppableId)return yn(ge,z.source.index,z.destination.index,!0),!0;if(ct?.kind!=="list")return!0;if(ct?.kind==="list"){const it=Bt.find(Ot=>`group-sessions:${Ot.key}`===ct.listId),bt=ct.listId==="sidebar-entities"?zt:it?pu(it.sessions,v,Wr,$r):null;if(bt){const Ot=z5(bt,Ye,ct.index);ct.listId==="sidebar-entities"?R(Ot):it&&R(Bt.flatMap(qt=>qt.key===it.key?Ot:qt.sessions.map(dt=>dt.id)))}}return lr(Ye,ge,null),!0},[$r,zt,Bt,lr,R,yn,Wr,v,Xr,A,E]),Ln=b.useCallback(z=>{if(z.type!=="split-member")return!1;if(z.reason==="CANCEL")return!0;const ge=z.draggableId.replace(/^split-member:/,""),Ye=v.find(dt=>dt.sessionIds.includes(ge));if(!Ye?.sessionIds.includes(ge))return!0;const ct=Ye.id,it=ur.current;if(it?.kind==="split")return lr(ge,null,it.groupId),E(it.sessionId,ge),!0;if(it?.kind==="collaboration")return lr(ge,null,it.groupId),!0;if(!z.destination&&it?.kind==="list"){const dt=Bt.find(vr=>`group-sessions:${vr.key}`===it.listId),nr=it.listId==="sidebar-entities"?zt:dt?pu(dt.sessions,v,Wr,$r):null;if(!nr)return!0;const Lr=z5(nr,ge,it.index);return A(ge),it.listId==="sidebar-entities"?R(Lr):dt&&R(Bt.flatMap(vr=>vr.key===dt.key?Lr:vr.sessions.map($t=>$t.id))),!0}if(!z.destination)return!0;const bt=z.destination.droppableId.replace(/^split-members:/,"");if(bt!==ct){const nr=v.find(Lr=>Lr.id===bt)?.sessionIds[0];return nr&&E(nr,ge),!0}if(z.source.index===z.destination.index)return!0;const Ot=[...Ye.sessionIds],[qt]=Ot.splice(z.source.index,1);return qt&&(Ot.splice(z.destination.index,0,qt),I(ct,Ot)),!0},[$r,zt,Bt,lr,E,A,R,I,Wr,v]),rn=(z,ge="top")=>s.jsx("div",{"data-split-exit-drop-index":z,className:`group/split-exit pointer-events-none absolute inset-x-0 z-10 h-2 ${ge==="top"?"-top-1":"-bottom-1"}`,children:s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-1 top-1/2 h-px -translate-y-1/2 rounded-full bg-transparent transition-colors group-data-[active=true]/split-exit:bg-primary"})}),$n=b.useCallback((z,ge,Ye)=>{if(ar(z)||Ln(z)||z.reason==="CANCEL")return;const ct=ge.find(dt=>dt.id===z.draggableId);if(!ct)return;const it=ur.current;if(it?.kind==="split"&&ct.kind==="session"){lr(ct.session.id,null,it.groupId),E(it.sessionId,ct.session.id);return}if(it?.kind==="collaboration"&&ct.kind==="session"){lr(ct.session.id,null,it.groupId);return}if(z.combine&&ct.kind!=="session"){const dt=ge.findIndex(nr=>nr.id===z.combine?.draggableId);if(dt<0)return;z={...z,combine:null,destination:{...z.source,index:dt}}}if(z.combine){const dt=ge.find(rt=>rt.id===z.combine?.draggableId);if(!dt)return;const nr=dt.kind==="workspace"?dt:ct.kind==="workspace"?ct:dt,Lr=nr===ct?dt:ct,vr=nr.sessionIds[0],$t=Lr.sessionIds[0];vr&&$t&&vr!==$t&&E(vr,$t);return}if(!z.destination||z.source.index===z.destination.index)return;const bt=[...ge],[Ot]=bt.splice(z.source.index,1);if(!Ot)return;bt.splice(z.destination.index,0,Ot);const qt=bt.flatMap(dt=>dt.sessionIds);if(Ye===void 0){R(qt);return}R(Bt.flatMap(dt=>dt.key===Ye?qt:dt.sessions.map(nr=>nr.id)))},[Bt,ar,Ln,lr,E,R]),ns=b.useCallback(z=>{if(z.reason==="CANCEL"||ar(z)||Ln(z))return;if(z.type==="group"){if(!z.destination||z.source.index===z.destination.index)return;R(Ob(Bt,z.source.index,z.destination.index));return}const ge=z.source.droppableId.replace(/^group-sessions:/,""),Ye=Bt.find(it=>it.key===ge);if(!Ye)return;const ct=pu(Ye.sessions,v,Wr,$r);if(z.combine||ur.current?.kind==="collaboration"||ur.current?.kind==="split"){$n(z,ct,ge);return}!z.destination||z.destination.droppableId!==z.source.droppableId||$n(z,ct,ge)},[$r,Bt,Wr,v,ar,$n,Ln,R]),vs=z=>{const ge=ke===z.id,Ye=[{layout:"horizontal",label:ce("tab.splitHorizontal"),icon:Cl},{layout:"vertical",label:ce("tab.splitVertical"),icon:Ig},...z.sessionIds.length>=3||z.layout==="grid"?[{layout:"grid",label:ce("tab.splitGrid"),icon:kg}]:[]],ct=z.layout==="vertical"?Ig:z.layout==="grid"?kg:Cl,it=Ye.find(bt=>bt.layout===z.layout)?.label??ce("tab.splitHorizontal");return s.jsxs("div",{ref:ge?Nt:void 0,className:"relative shrink-0",onPointerDown:bt=>bt.stopPropagation(),children:[s.jsx("button",{type:"button",className:`sidebar-session-action inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${ge?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${ce("tab.splitLayout")}: ${it}`,"aria-haspopup":"menu","aria-expanded":ge,title:ce("tab.splitLayout"),onClick:bt=>{bt.stopPropagation(),se(Ot=>Ot===z.id?null:z.id)},children:s.jsx(ct,{size:12})}),ge&&s.jsx("div",{role:"menu","aria-label":ce("tab.splitLayout"),className:"absolute right-0 top-full z-30 mt-1 flex gap-0.5 rounded-md border border-border bg-surface-elevated p-1 shadow-lg",children:Ye.map(bt=>{const Ot=bt.icon,qt=bt.layout===z.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":qt,"aria-label":bt.label,title:bt.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${qt?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:dt=>{dt.stopPropagation(),L(z.sessionIds[0],bt.layout),se(null)},children:s.jsx(Ot,{size:13})},bt.layout)})})]})},fs=(z,ge)=>ge&&s.jsx("button",{type:"button",...ge,"aria-label":z,title:z,onClick:Ye=>Ye.stopPropagation(),className:"absolute -left-2 inset-y-0 z-10 flex w-3 cursor-grab items-start justify-center pt-1.5 text-muted-foreground/60 transition hover:text-foreground focus-visible:text-foreground active:cursor-grabbing",children:s.jsx(hf,{size:10})}),Gn=(z,ge,Ye=!1,ct=!1,it)=>{if(ge.length<2)return null;const bt=ge.some(vr=>vr.id===l),Ot=[],qt=[],dt=[];for(const vr of ge){const $t=c.get(vr.id);$t?.agentStatus==="waiting"||$t?.agentNeedsReview?Ot.push(vr):$t?.agentStatus==="working"?qt.push(vr):$t?.inCopyMode&&dt.push(vr)}const nr=z.name?.trim()||`${ce("tab.splitWorkspace")} ${v.findIndex(vr=>vr.id===z.id)+1}`,Lr=ke===z.id;return s.jsxs("section",{"data-split-workspace":z.id,"aria-label":nr,className:`group/split relative rounded-md p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border transition-colors ${ct?"bg-primary/15 ring-1 ring-primary/40":Ye?"bg-surface-elevated opacity-90 shadow-lg":Ot.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":qt.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":dt.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":bt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[fs(`移动分屏组 ${nr}`,it),s.jsx(Tl,{droppableId:`split-members:${z.id}`,type:"split-member",direction:"vertical",children:(vr,$t)=>s.jsxs("div",{ref:vr.innerRef,...vr.droppableProps,"data-split-members":!0,className:$t.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[ge.map((rt,jt)=>s.jsx(Al,{draggableId:`split-member:${rt.id}`,index:jt,disableInteractiveElementBlocking:!0,children:(U,G)=>s.jsx("div",{ref:U.innerRef,...U.draggableProps,...P?wn(()=>P(rt.id)):{},className:`${jt===0&&Lr?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${G.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${zr(rt.id)??(rt.id===l?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:kt(rt,U.dragHandleProps,!0,jt===0?vs(z):void 0)})},rt.id)),vr.placeholder]})})]})},fn=(z,ge,Ye,ct=!1,it=!1)=>{const bt=_e===z.id||!_e&&ge.some(rt=>rt.id===l),Ot=Xx(Ge,z.id),qt=z.sessionIds.filter(rt=>Ot.has(rt)&&rt!==l&&!Xr.has(rt)),dt=ae[z.id]===!0,nr=dt?z.sessionIds:z.sessionIds.filter(rt=>!qt.includes(rt)),Lr=fu(nr,v),vr=Lr.flatMap(rt=>rt.sessionIds),$t=Lr.length===1?Lr[0]?.workspace:void 0;return s.jsxs("section",{"data-collaboration-group":z.id,"data-collaboration-group-name":z.name,"aria-label":`Agent 工作组:${z.name}`,className:`group/collaboration relative rounded-md p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${it?"bg-primary/15 ring-1 ring-primary/40":ct?"bg-surface-elevated opacity-90 shadow-lg":bt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[fs(`移动工作组 ${z.name}`,Ye),s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-xs font-medium text-foreground transition hover:bg-surface-elevated md:min-h-8",title:`打开 ${z.name} 的协作工作区`,"aria-label":`打开协作工作区:${z.name}`,"aria-current":_e===z.id?"page":void 0,onClick:rt=>{rt.stopPropagation(),ir(z.id)},children:[s.jsx(Qd,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:z.name}),s.jsx("span",{className:`shrink-0 text-[10px] font-normal ${Z.some(rt=>rt.groupId===z.id)?"text-primary":"text-muted-foreground"}`,children:Z.filter(rt=>rt.groupId===z.id).length?`${Z.filter(rt=>rt.groupId===z.id).length} 待处理`:"协作"})]}),qt.length>0&&s.jsxs("button",{type:"button","aria-expanded":dt,className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-elevated md:min-h-8",title:"展开后可查看或归档执行会话,任务结果保留。",onClick:()=>ze(rt=>({...rt,[z.id]:!dt})),children:[s.jsx(lo,{size:12,className:dt?"rotate-90":""}),"已完成的执行会话 · ",qt.length]}),s.jsx(Tl,{droppableId:`collaboration-members:${z.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(rt,jt)=>s.jsxs("div",{ref:rt.innerRef,...rt.droppableProps,"data-collaboration-members":!0,className:`${jt.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[Lr.map(U=>s.jsx("div",{"data-collaboration-split":U.workspace?.id,"data-split-anchor":U.workspace?.sessionIds[0],role:U.workspace?"region":void 0,"aria-label":U.workspace?`${ce("tab.splitWorkspace")} · ${U.sessionIds.length}`:void 0,className:U.workspace&&!$t?`relative my-0.5 rounded-sm before:pointer-events-none before:absolute before:inset-0 before:rounded-sm before:border before:border-border data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${U.sessionIds.includes(l??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:U.sessionIds.map(G=>{const he=Wr.get(G);return he?s.jsx(Al,{draggableId:`collaboration-member:${he.id}`,index:vr.indexOf(he.id),disableInteractiveElementBlocking:!0,children:(Me,Qt)=>s.jsxs("div",{ref:Me.innerRef,...Me.draggableProps,"data-collaboration-member":he.id,"data-split-member":Xr.has(he.id)?"true":void 0,...P?wn(()=>P(he.id)):{},className:`${U.workspace&&G===U.sessionIds[0]&&ke===U.workspace.id?"z-20 ":""}relative flex items-center rounded-sm pr-0.5 transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${Qt.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":Qt.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${zr(he.id)??(he.id===l?"bg-surface-elevated/80 text-foreground":Xr.has(he.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[kt(he,Me.dragHandleProps,!0,U.workspace&&G===U.sessionIds[0]?vs(U.workspace):void 0,Ot.has(G)?s.jsxs("button",{type:"button","aria-label":`归档 ${he.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:hr!==null,className:"sidebar-session-action inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-primary/15 hover:text-primary disabled:opacity-40 md:h-6 md:min-w-6 md:px-1",onClick:It=>{It.stopPropagation(),!_r.current&&(_r.current=!0,Zt(G),Ft(null),gw(G).then(async()=>{Pt(tr=>tr+1),await Ur()}).catch(tr=>Ft(tr instanceof Error?tr.message:"归档失败,终端已保留")).finally(()=>{_r.current=!1,Zt(null)}))},children:[hr===G?s.jsx(vn,{size:13,className:"animate-spin"}):s.jsx(Fb,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!U.workspace&&Xr.has(he.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(It=>It.sessionIds.includes(he.id))?.sessionIds.filter(It=>It!==he.id).map(It=>Wr.get(It)?.name??It).join("、")} 分屏`,"aria-label":`查看 ${he.name} 的跨组分屏`,onClick:()=>{yc.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:he.id})),Vt()},children:s.jsx(Cl,{size:10})})]})},he.id):null})},U.workspace?.id??U.sessionIds[0])),rt.placeholder]})}),s.jsx(Fj,{groupId:z.id,version:pt,onRestore:async rt=>{window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:rt.cwd,preferredFrontendSessionId:rt.sessionId,requireExisting:!0}})),await Ur(),yc.getState().terminal(),Vt()}}),z.remoteSessions?.map(rt=>s.jsxs("button",{type:"button",title:`${Kl(rt)} · ${rt.serviceConnected===!1?"服务不可达,消息尚未送达":rt.status}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[11px] text-muted-foreground hover:bg-surface-2",onClick:()=>{Tv(rt.sessionId).catch(()=>{ir(z.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${rt.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:rt.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:Kl(rt)}),rt.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},rt.sessionId)),s.jsx("div",{"data-collaboration-background":!0,className:"h-1.5"})]})},Un=(z,ge,Ye)=>s.jsx(Pu,{onBeforeCapture:Cn,onDragStart:gn,onDragEnd:ct=>hn(it=>$n(it,z,Ye),ct),children:s.jsx(Tl,{droppableId:ge,direction:"vertical",isCombineEnabled:!xt,children:ct=>s.jsxs("div",{ref:ct.innerRef,...ct.droppableProps,"data-sidebar-entity-list-id":ge,className:"flex-1 space-y-0.5",children:[z.map((it,bt)=>s.jsx(Al,{draggableId:it.id,index:bt,disableInteractiveElementBlocking:!0,children:(Ot,qt)=>s.jsxs("div",{ref:Ot.innerRef,...Ot.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":bt,className:"relative",children:[rn(bt),bt===z.length-1&&rn(z.length,"bottom"),it.kind==="workspace"?Gn(it.workspace,it.members,qt.isDragging,!!qt.combineTargetFor,Ot.dragHandleProps):it.kind==="collaboration"?fn(it.group,it.members,Ot.dragHandleProps,qt.isDragging,!!qt.combineTargetFor):s.jsx("div",{...P?wn(()=>P(it.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${qt.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":qt.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":zr(it.session.id)??(!_e&&it.session.id===l?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:kt(it.session,Ot.dragHandleProps)})]})},it.id)),ct.placeholder]})})}),xr=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{"data-session-sidebar-header":!0,className:"relative z-20 shrink-0 px-3 py-0.5",children:[s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-3 bottom-0 z-10 h-px bg-border opacity-40"}),s.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:ce("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),ys>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(Ov,{count:ys,tone:"running",title:ce("agent.aiRunning")})})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:()=>{de(!1),ir(null)},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":"Agent 工作台",title:"Agent 工作台",children:s.jsx(Qd,{size:16})}),(!Qe||Pe)&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:r,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":ce("common.close"),children:s.jsx(Wn,{size:16})})]})]})]}),At&&s.jsxs("div",{role:"alert",className:"mx-2 mt-2 flex items-start gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:At}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>Ft(null),children:s.jsx(Wn,{size:14})})]}),s.jsxs("div",{ref:at,className:"relative z-10 flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain px-1.5 pt-0.5 pb-1.5",children:[(Z.length>0||Je)&&s.jsxs("section",{className:"mb-2 rounded-lg border border-primary/20 bg-primary/5","aria-label":"协作待处理事项",children:[s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 px-3 text-left text-xs text-primary","aria-expanded":Rt,onClick:()=>Mt(z=>!z),children:[s.jsx(Qd,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:Z.length}),s.jsx(lo,{size:12,className:Rt?"rotate-90":""})]}),Rt&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[Je&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[Je,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{s0.getState().refresh()},children:"重试"})]}),Z.map(z=>s.jsxs("button",{type:"button",className:"min-h-11 w-full rounded-md px-2 py-2 text-left hover:bg-surface-2",onClick:()=>{Jx(z.groupId,z.id),ir(z.groupId).then(ge=>{ge&&Jx(z.groupId,z.id)})},children:[s.jsx("span",{className:"block truncate text-xs text-foreground",children:z.title}),s.jsxs("span",{className:"mt-1 block truncate text-[10px] text-muted-foreground",children:[Ut.find(ge=>ge.id===z.groupId)?.name??"协作组"," · ",A0(z)]})]},z.id))]})]}),Ce.length>0&&s.jsxs("section",{className:"mb-2 shrink-0 rounded-lg bg-[rgb(var(--tmux-rgb)_/_0.07)] p-1","aria-label":ce("sidebar.recoverableSessions"),children:[s.jsxs("div",{className:"flex min-h-8 items-center gap-2 px-2 text-[10.5px] font-semibold text-[color:var(--tmux)]",children:[s.jsx(wc,{size:12,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:ce("sidebar.recoverableSessions")}),s.jsx("span",{className:"text-muted-foreground",children:Ce.length}),we&&s.jsx("button",{type:"button",onClick:we,disabled:tt,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":ce("sidebar.refreshRecoverableSessions"),title:ce("sidebar.refreshRecoverableSessions"),children:s.jsx(vn,{size:11,className:tt?"animate-spin":""})})]}),s.jsx("div",{className:"space-y-0.5",children:Ce.slice(0,4).map(z=>{const ge=z.friendlyName?.trim()||z.label?.trim()||z.name,Ye=$u(z.cwd??null),ct=yt===z.name;return s.jsxs("button",{type:"button",disabled:yt!==null,onClick:()=>qr(z),className:"group flex min-h-10 w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-wait disabled:opacity-60","aria-label":ce("sidebar.restoreRecoverableSession",{name:ge}),title:z.cwd||z.name,children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--tmux-rgb)_/_0.11)] text-[color:var(--tmux)]",children:ct?s.jsx(En,{size:12,className:"animate-spin"}):s.jsx(x0,{size:12})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:ge}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[z.program,Ye].filter(Boolean).join(" · ")||`tmux:${z.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:ce(ct?"sidebar.restoringRecoverableSession":"sidebar.restore")})]},z.name)})})]}),$r.filter(z=>!z.sessionIds.length).map(z=>s.jsx(Pu,{onDragEnd:()=>{},children:fn(z,[])},z.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx(Eo,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:ce("sidebar.noSessions")})]}):Vr.length===0&&v.length===0?s.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:s.jsx("p",{className:"text-[12px] text-muted-foreground",children:ce("sidebar.noMatchingSessions")})}):gr?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(Pu,{onBeforeCapture:Cn,onDragStart:gn,onDragEnd:z=>hn(ns,z),children:s.jsx(Tl,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:z=>s.jsxs("div",{ref:z.innerRef,...z.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[Bt.map((ge,Ye)=>{const ct=Pr.has(ge.key),it=!ct&&Ye===Bt.length-1,bt=pu(ge.sessions,v,Wr,$r);let Ot=0,qt=0;for(const nr of ge.sessions){const Lr=c.get(nr.id);Lr?.agentStatus==="working"&&(Ot+=1),(Lr?.agentStatus==="waiting"||Lr?.agentNeedsReview)&&(qt+=1)}const dt=ge.key==="";return s.jsx(Al,{draggableId:`sidebar-group:${ge.key||"__ungrouped__"}`,index:Ye,isDragDisabled:dt,disableInteractiveElementBlocking:!0,children:(nr,Lr)=>s.jsxs("div",{ref:nr.innerRef,...nr.draggableProps,className:`shrink-0 rounded-md transition-colors ${it?"flex flex-1 flex-col ":""}${Lr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...dt?{}:nr.dragHandleProps,onClick:()=>{be(ge.key),tn.current.delete(ge.key)},className:`flex w-full shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${dt?"":"cursor-grab active:cursor-grabbing"}`,title:ge.key||ge.label,children:[s.jsx(lo,{size:13,className:`shrink-0 transition-transform ${ct?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:ge.label}),Ot>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),qt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx(e5,{sessionIds:ge.sessions.map(vr=>vr.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:ge.sessions.length})]}),!ct&&s.jsx("div",{className:`mt-0.5 pl-2 ${it?"flex flex-1 flex-col":""}`,children:s.jsx(Tl,{droppableId:`group-sessions:${ge.key}`,type:"session",direction:"vertical",isCombineEnabled:!xt,children:vr=>s.jsxs("div",{ref:vr.innerRef,...vr.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${ge.key}`,className:`${it?"flex-1 ":""}space-y-0.5`,children:[bt.map(($t,rt)=>s.jsx(Al,{draggableId:$t.id,index:rt,disableInteractiveElementBlocking:!0,children:(jt,U)=>s.jsxs("div",{ref:jt.innerRef,...jt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":rt,className:"relative",children:[rn(rt),rt===bt.length-1&&rn(bt.length,"bottom"),$t.kind==="workspace"?Gn($t.workspace,$t.members,U.isDragging,!!U.combineTargetFor,jt.dragHandleProps):$t.kind==="collaboration"?fn($t.group,$t.members,jt.dragHandleProps,U.isDragging,!!U.combineTargetFor):s.jsx("div",{...P?wn(()=>P($t.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${U.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":U.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":zr($t.session.id)??(!_e&&$t.session.id===l?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:kt($t.session,jt.dragHandleProps)})]})},$t.id)),vr.placeholder]})})})]})},ge.key||"__ungrouped__")}),z.placeholder]})})})}):Un(zt,"sidebar-entities")]}),s.jsx(hw,{onReselect:()=>{h&&(en.current=null,$e(z=>z+1),h())}}),je&&s.jsx(KQ,{directories:a.flatMap(z=>{const ge=c.get(z.id)?.cwd;return ge?[ge]:[]}),tmuxAvailable:fe,options:br,agents:nt,selectedAgent:Dt,detecting:_t,resumeHistory:Ue,resumeHistoryLoading:te,resumeHistoryPendingId:ot,resumeHistoryError:xe,onRefreshAgents:()=>{Qr().catch(()=>{})},onSelectAgent:z=>{yr(z).catch(()=>{})},onLaunchAgent:_n,onResumeHistory:z=>{un(z)},onRemoveResumeHistory:z=>{Bn(z)},onClose:()=>de(!1),onOptionsChange:Ze,additionalContent:Nn&&W?.latestVersion&&s.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:s.jsx(vn,{size:13,className:W.status==="installing"||W.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:ce("sidebar.updateAvailable",{version:W.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:W.status==="installing"?ce("sidebar.updateInstalling"):W.status==="ready"?ce("sidebar.updateReady"):W.status==="restarting"?ce("sidebar.updateRestarting"):ce("sidebar.updateFailed")})]})]}),W.status==="ready"&&q&&s.jsx("button",{type:"button",disabled:B,onClick:q,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:ce("sidebar.updateRestart")}),W.status==="error"&&ne&&s.jsx("button",{type:"button",disabled:B,onClick:ne,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:ce("sidebar.updateRetry")})]}),footerActions:s.jsx(NP,{serverAttention:Zr,onOpenSettings:()=>{de(!1),Q()},actions:[...$?[{label:ce("sidebar.subscriptionQuota"),icon:Y9,onSelect:()=>{de(!1),$()}}]:[],{label:"Agent 工作台",icon:Qd,onSelect:()=>{de(!1),ir(null)}},{label:"服务与设备",icon:fw,onSelect:()=>{de(!1),pw()}},...ue?[{label:ce(Pe?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:Pe?Vu:Gu,separated:!0,onSelect:()=>{de(!1),ue()}}]:[]]})}),Oe&&s.jsx(Q5,{onEnterGroup:async z=>{if(!await ir(z))throw new Error("协作组已保存,打开工作区失败,请重试");Ee(!1)},onFloatingChange:async z=>{if(z){if(!await ir(z))throw new Error("打开协作工作区失败");Ee(!1)}},activeSessionId:l,defaultSessionMode:X,onClose:()=>Ee(!1),onNewSession:z=>p(z)}),!_e&&Object.entries(re).map(([z,ge])=>s.jsx(Q5,{activeSessionId:l,initialCollaborationGroupId:z,initialFloating:ge,onEnterGroup:async Ye=>{if(Ye!==z){if(!await ir(Ye))throw new Error("协作组已保存,打开工作区失败,请重试");await al({floatingGroupId:null},z),Fe(ct=>{const it={...ct};return delete it[z],it})}},onFloatingChange:Ye=>ee(z,Ye),defaultSessionMode:X,onClose:()=>{Xe.current=!0,Fe(Ye=>{const ct={...Ye};return delete ct[z],ct})},onNewSession:Ye=>p(Ye)},z)),!je&&s.jsx("div",{className:"relative z-10 shrink-0 bg-[var(--chrome-bg)] px-3 pb-3 pt-1 md:border-t md:border-border md:p-2",children:s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${Dt?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:Sn,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${Dt?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:ce("sidebar.newSession"),"aria-label":ce("sidebar.newSession"),children:[s.jsx(Eo,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:"Terminal"})]}),Dt&&s.jsxs("button",{type:"button",onClick:rs,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:ce("sidebar.newSessionWithAgent",{agent:Dt.displayName}),"aria-label":ce("sidebar.newSessionWithAgent",{agent:Dt.displayName}),children:[s.jsx(Ic,{agent:Dt,size:15}),s.jsx("span",{className:"truncate",children:Dt.displayName})]}),s.jsxs("button",{type:"button",onClick:Nr,className:"relative inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:lt,"aria-label":lt,"aria-expanded":je,"aria-controls":"sidebar-launch-options",children:[s.jsx(ll,{size:15}),Zr&&s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2 w-2 rounded-full bg-destructive ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"}),Nn&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${Zr?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})})]});return Pe?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:xr}):s.jsx(Bv,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:Qe,children:xr})}function BP(){const{t:e}=Hr();return s.jsxs("div",{role:"status","aria-label":e("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[s.jsx("span",{className:"sr-only",children:e("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",className:"shrink-0 border-b border-border/15 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex h-5 items-center gap-1",children:[s.jsx("div",{className:"h-4 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-7 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-12 rounded bg-surface-2"})]}),s.jsxs("div",{className:"flex h-[15px] items-center justify-between",children:[s.jsx("div",{className:"h-2 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-6 rounded bg-surface-2"})]}),s.jsxs("div",{className:"mt-2 flex h-7 items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-12 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-7 w-16 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-3 w-24 max-w-[30%] rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-4 rounded-full bg-surface-2"})]})]}),s.jsxs("div",{"aria-hidden":"true",className:"overflow-hidden px-3 py-2",children:[s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("div",{className:"h-3 w-3 rounded-sm bg-surface-2"}),s.jsx("div",{className:"h-2 w-32 max-w-[55%] rounded bg-surface-2"})]}),["w-3/5","w-2/5","w-1/2","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-9 items-center gap-2 pl-5",style:{opacity:1-r*.15},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},t))]})]})}function QP({slow:e=!1}){const{t}=Hr();return s.jsxs("div",{role:"status","aria-label":t("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton relative h-full min-h-0 overflow-hidden bg-surface px-3",children:[s.jsx("span",{className:"sr-only",children:t("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",children:[s.jsxs("div",{className:"flex h-[76px] items-center gap-2 border-b border-border/40 px-2",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-12 rounded bg-surface-2"})]})]}),s.jsxs("div",{className:"flex h-11 items-center gap-2 px-1 pt-3",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-12 rounded-full bg-surface-2"})]}),[!1,!0].map(r=>s.jsxs("div",{className:"border-b border-border/40 px-1 py-4",children:[s.jsxs("div",{className:"mb-2 flex h-8 items-center justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),r&&s.jsx("div",{className:"h-2 w-28 rounded bg-surface-2"})]}),s.jsx("div",{className:"h-8 w-12 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]},String(r))),s.jsx("div",{className:"flex h-[69px] items-center border-b border-border/40 px-2",children:s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"})}),s.jsxs("div",{className:"space-y-2 px-1 py-4",children:[s.jsxs("div",{className:"flex h-8 items-center justify-between",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-8 w-28 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-7 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]})]}),e&&s.jsx("div",{className:"absolute inset-x-3 bottom-3 rounded-md bg-surface-elevated px-3 py-2 text-xs text-muted-foreground",children:t("rightSidebar.loadingGitChangesSlow")})]})}const Vv=()=>Tc(()=>import("./RightSidebar-Cp5b_y0u.js").then(e=>e.R),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17])).then(e=>({default:e.RightSidebar})),PP=b.lazy(Vv);function W5(e){const t=b.useRef(!1);b.useEffect(()=>{const p=navigator.connection;if(!(p?.saveData||/2g|3g/.test(p?.effectiveType??"")))return o1(()=>{Vv().catch(()=>{})},3e3)},[]);const{t:r}=Hr(),n=sr(p=>p.rootPath),a=sr(p=>p.rightTab),l=sr(p=>p.setRightTab),c=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const h=s.jsx(Bv,{side:"right",isOpen:e.isOpen,drawerWidthPx:e.drawerWidthPx,onClose:e.onClose,onOpen:e.onOpen,pinned:e.pinned,children:s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 px-1",children:s.jsx("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:s.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",children:c})})}),s.jsx("div",{"aria-hidden":"true",className:"flex items-center gap-1.5",children:[Vl,sT,ll].map((p,g)=>s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-surface-2 text-muted-foreground",children:s.jsx(p,{size:14})},g))}),s.jsx("button",{type:"button",onClick:e.onClose,"aria-label":r("common.close"),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:s.jsx(Wn,{size:14})})]}),s.jsx("div",{className:"mt-2 grid grid-cols-4 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[["git",I9,"rightSidebar.tabGit"],["diff",N9,"rightSidebar.tabChanges"],["files",Ec,"rightSidebar.tabFiles"],["computer",bw,"rightSidebar.tabComputer"]].map(([p,g,x])=>s.jsxs("button",{type:"button",onClick:()=>l(p),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===p?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(g,{size:12}),r(x)]},p))}),s.jsx("div",{className:"h-2"})]}),s.jsx("div",{className:"min-h-0 flex-1 bg-surface",children:a==="computer"?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:r("computer.loading")}):a==="git"?s.jsx(QP,{}):s.jsx(BP,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:h,children:s.jsx(PP,{...e})}):h}const G5=Jl(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function OP(e){let t=1,r="terminal";for(;;){let n=!1;for(const a of e.values())if(a.name===r){n=!0;break}if(!n)break;r=`terminal-${t}`,t++}return r}const FP=Jl((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=r3(),a=Date.now(),l=t().sessions,c=OP(l),h={id:n,cwd:r,sessionId:null,name:c,customName:!1,createdAt:a,lastActivity:a};return e(p=>{const g=new Map(p.sessions);return g.set(n,h),{sessions:g,activeSessionId:p.activeSessionId??n,nextSessionNumber:p.nextSessionNumber+1}}),n},closeSession:r=>{e(n=>{const a=new Map(n.sessions),l=n.activeSessionId===r;a.delete(r);let c=n.activeSessionId;if(l){const h=Array.from(a.keys());c=h.length>0?h[0]:null}return{sessions:a,activeSessionId:c}})},switchSession:r=>{e(n=>n.sessions.has(r)?{activeSessionId:r}:n)},updateSession:(r,n)=>{e(a=>{const l=a.sessions.get(r);if(!l)return a;const c=new Map(a.sessions);return c.set(r,{...l,...n,lastActivity:Date.now()}),{sessions:c}})},setTerminalSession:(r,n)=>{t().updateSession(r,{sessionId:n.sessionId})},getActiveSession:()=>{const r=t();if(r.activeSessionId)return r.sessions.get(r.activeSessionId)},getSessionCount:()=>t().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}})),$P=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class UP{level=6;badSince=null;goodSince=null;connectedAt=0;lastSample=-1/0;lastChange=-1/0;lastUpgrade=-1/0;upgradeAfter=0;failedProbes=0;baselineRtt=1/0;get quality(){return $P[this.level]}connected(t){this.connectedAt=t,this.badSince=this.goodSince=null,this.lastSample=-1/0}sample(t,r,n=1600){if(r-this.lastSample>2500&&(this.badSince=this.goodSince=null),this.lastSample=r,t.rttMs!==null&&(this.baselineRtt=Math.min(this.baselineRtt,t.rttMs)),r-this.connectedAt<3e3)return null;const a=t.rttMs!==null&&t.rttMs>this.baselineRtt+150,l=t.deliveryDelayMs>250||t.decodeQueue>=4||a&&t.frames>0&&t.deliveryDelayMs>100,c=t.deliveryDelayMs>800||t.decodeQueue>=8,h=t.rttMs!==null&&t.rttMs<this.baselineRtt+100&&t.deliveryDelayMs<80&&t.decodeQueue<=1;this.badSince=l?this.badSince??r:null,this.goodSince=h?this.goodSince??r:null;const p=n<=1080?7:n<=1600?9:11;if(this.badSince!==null&&r-this.badSince>=(c?1e3:2e3)&&r-this.lastChange>=(c?2e3:3e3)&&this.level>0){this.level=Math.max(0,this.level-(c?2:1));const g=r-this.lastUpgrade<2e4;this.failedProbes=g?this.failedProbes+1:0,this.upgradeAfter=r+(g?Math.min(3e4,8e3*2**(this.failedProbes-1)):5e3),this.lastUpgrade=-1/0}else if(this.goodSince!==null&&r-this.goodSince>=3e3&&r-this.lastChange>=4e3&&r>=this.upgradeAfter&&this.level<p)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function jc(e,t){const r=await fetch(e,{...t,headers:{"Content-Type":"application/json",Accept:"application/json",...t?.headers??{}}}),n=await r.json().catch(()=>null);if(!r.ok||!n){const a=n?.error||n?.code||`ANDROID_REQUEST_FAILED_${r.status}`;throw new Error(a)}return n}async function zP(){return jc("/api/android/devices")}async function HP(e){return jc("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const df=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],id=df[1];function e1(e){if(!e||typeof e!="object")return id;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=df.find(c=>c.id===t.id);if(r)return r;if(t.id!=="custom")return id;const n=typeof t.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(t.maxSize))):1080,a=typeof t.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(t.bitRate))):4e6,l=typeof t.maxFps=="number"?Math.max(0,Math.min(60,Math.round(t.maxFps))):30;return{id:"custom",maxSize:n,bitRate:a,maxFps:l}}function WP(e,t){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const r=new URLSearchParams;t&&(r.set("max_size",String(t.maxSize)),r.set("bit_rate",String(t.bitRate)),t.maxFps>0&&r.set("max_fps",String(t.maxFps)));const n=r.toString();return`/api/android/${e}/ws${n?`?${n}`:""}`}function V5(e){const t={ADB_UNAVAILABLE:"本机没有可用的 adb,请先安装 Android platform-tools。",ADB_NOT_FOUND:"找不到 adb 可执行文件,可用 TERMDOCK_ADB_BIN 指定路径。",SCRCPY_NOT_FOUND:"本机没有 scrcpy,请先安装(含 scrcpy-server)。",SCRCPY_SERVER_NOT_FOUND:"找不到 scrcpy-server,可用 TERMDOCK_SCRCPY_SERVER 指定路径。",SCRCPY_VERSION_UNKNOWN:"无法读取 scrcpy 版本,请确认 scrcpy --version 可执行。",SCRCPY_CONNECT_TIMEOUT:"设备连接超时,请确认已授权 USB 调试并保持解锁。",SCRCPY_UNSUPPORTED_CODEC:"设备返回了不支持的视频编码。",INVALID_ADDRESS:"地址格式不正确,应为 ip:port。",API_NOT_ALLOWED:"当前设备权限不足:投屏需要全权服务授权。"};for(const[r,n]of Object.entries(t))if(e.includes(r))return n;return e}function GP(e){return jc(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function VP(e){return jc("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function qP(e){return jc(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function YP(e,t){return jc(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function ZP(e){return jc(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const KP=0,XP=1,JP=2,eO=3,tO=4,rO=5,nO=7,sO=10,iO=11,aO=16,q5=17,Y5=0,Jp=1,oO=2,Z5=3,em=0,K5=1,X5=1,e0=0xffffffffffffffffn,ch=0xfffffffffffffffen,mu={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function qv(e,t,r){e.setUint32(t,Math.max(0,Math.round(r.x))&4294967295),e.setUint32(t+4,Math.max(0,Math.round(r.y))&4294967295),e.setUint16(t+8,Math.min(65535,Math.round(r.screenWidth))),e.setUint16(t+10,Math.min(65535,Math.round(r.screenHeight)))}function lO(e,t,r,n,a,l){const c=new Uint8Array(32),h=new DataView(c.buffer);return h.setUint8(0,JP),h.setUint8(1,e),h.setBigUint64(2,t),qv(h,10,r),h.setUint16(22,Math.max(0,Math.min(65535,Math.round(n*65536)))),h.setUint32(24,a>>>0),h.setUint32(28,l>>>0),c}function tm(e,t,r=0,n=0){const a=new Uint8Array(14),l=new DataView(a.buffer);return l.setUint8(0,KP),l.setUint8(1,e),l.setUint32(2,t>>>0),l.setUint32(6,r>>>0),l.setUint32(10,n>>>0),a}function cO(e,t,r,n=0){const a=new Uint8Array(21),l=new DataView(a.buffer);l.setUint8(0,eO),qv(l,1,e);const c=h=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,h/16))*32768)));return l.setInt16(13,c(t)),l.setInt16(15,c(r)),l.setUint32(17,n>>>0),a}function uO(e){const t=new TextEncoder().encode(e);if(!t.length)return null;const r=t.subarray(0,300),n=new Uint8Array(5+r.length),a=new DataView(n.buffer);return a.setUint8(0,XP),a.setUint32(1,r.length),n.set(r,5),n}function dO(e){const t=new TextEncoder().encode(e);if(!t.length||t.length>255)return null;const r=new Uint8Array(2+t.length);return r[0]=aO,r[1]=t.length,r.set(t,2),r}function gu(e){return new Uint8Array([e])}function J5(e){return new Uint8Array([tO,e])}function hO(e){return new Uint8Array([sO,e?1:0])}function fO(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function pO(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function rm(e){return e.toString(16).padStart(2,"0")}function Yv(e,t,r){for(let n=0;n+4<e.length;n++){const a=e[n]===0&&e[n+1]===0&&e[n+2]===1,c=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1?n+4:a?n+3:-1;if(c<0||c>=e.length)continue;if((r?e[c]>>1&63:e[c]&31)!==t){n=c-1;continue}let p=c+1;for(;p+2<e.length&&!(e[p]===0&&e[p+1]===0&&(e[p+2]===1||e[p+2]===0&&e[p+3]===1));)p++;return e.subarray(c,Math.min(e.length,p))}return null}function mO(e){const t=e?Yv(e,7,!1):null;return t&&t.length>=4?`avc1.${rm(t[1])}${rm(t[2])}${rm(t[3])}`:"avc1.42e01e"}function gO(e){const t=e?Yv(e,32,!0):null;if(t&&t.length>=13){const r=t[1]>>6&3,n=t[1]&31,a=t[12];return`hev1.${r}.${n}.L${a}.B0`}return"hev1.1.6.L120.B0"}class xO{constructor(t,r){this.canvas=t,this.callbacks=r}canvas;callbacks;liveBitrate=!1;bitrateFailureDetail;get lastBitrateFailure(){return this.bitrateFailureDetail}bitrateRequestId=0;bitratePending=null;get supportsLiveBitrate(){return this.liveBitrate}get canSetBitrate(){return this.liveBitrate&&!this.bitratePending&&this.socket?.readyState===1}setBitrate(t){return!this.canSetBitrate||!Number.isInteger(t)||t<3e5||t>3e7?Promise.resolve(!1):new Promise(r=>{const n=++this.bitrateRequestId,a=setTimeout(()=>this.finishBitrate(!1,`BITRATE_CLIENT_TIMEOUT: requested=${t} bps; no server confirmation within 4000ms`),4e3);this.bitratePending={id:n,value:t,resolve:r,timer:a},this.send({type:"bitrate",requestId:n,bitRate:t})})}finishBitrate(t,r){const n=this.bitratePending;n&&(this.bitratePending=null,clearTimeout(n.timer),t||(this.liveBitrate=!1,this.bitrateFailureDetail=r??this.bitrateFailureDetail??"BITRATE_REASON_UNAVAILABLE: server rejected adjustment without a diagnostic",this.closedByUser||this.callbacks.onBitrateSupport?.(!1,this.bitrateFailureDetail)),n.resolve(t))}socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;lastFrameAt=0;lastResetAt=0;heartbeat=null;statsTimer=null;stallTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";autoQuality=!1;pingAt=null;rttMs=null;rttAt=0;minimumFrameOffset=1/0;deliveryDelayMs=0;peakDecodeQueue=0;sampleFrames=0;get currentHeader(){return this.header}connect(t,r){this.liveBitrate=!1,this.bitrateFailureDetail=void 0,this.serial=t,this.autoQuality=r?.id==="auto",this.closedByUser=!1,this.callbacks.onState("connecting");let n;try{n=yw(WP(t,r))}catch(a){this.callbacks.onState("error",a instanceof Error?a.message:"ANDROID_STREAM_FAILED");return}this.socket=n,n.onopen=()=>{this.lastMessageAt=Date.now()},n.onmessage=a=>{this.closedByUser||this.handleMessage(a.data)},n.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},n.onclose=()=>{this.finishBitrate(!1,"BITRATE_CONNECTION_CLOSED: preview connection closed"),this.liveBitrate=!1,this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.finishBitrate(!1),this.liveBitrate=!1,this.teardownTimers();try{this.decoder?.close()}catch{}this.decoder=null,this.configured=!1;try{this.socket?.close()}catch{}this.socket=null,this.callbacks.onState("idle")}teardownTimers(){this.heartbeat&&clearInterval(this.heartbeat),this.statsTimer&&clearInterval(this.statsTimer),this.stallTimer&&clearInterval(this.stallTimer),this.heartbeat=null,this.statsTimer=null,this.stallTimer=null}startTimers(){this.lastSampleAt=Date.now(),this.heartbeat=setInterval(()=>{if(!(!this.socket||this.socket.readyState!==1)){if(Date.now()-this.lastMessageAt>45e3){try{this.socket.close()}catch{}return}this.pingAt===null&&(this.pingAt=performance.now(),this.send({type:"ping"}))}},this.autoQuality?2e3:15e3),this.stallTimer=setInterval(()=>{if(!this.header||this.closedByUser)return;const t=Date.now();t-this.lastFrameAt>8e3&&t-this.lastResetAt>8e3&&(this.lastResetAt=t,console.warn("[android] no frames for 8s; requesting keyframe reset"),this.sendControl(gu(q5)))},2e3),this.statsTimer=setInterval(()=>{const t=Date.now(),r=(t-this.lastSampleAt)/1e3;r<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/r*10)/10,kbps:Math.round(this.bytesSinceSample*8/r/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType,adaptation:this.autoQuality?{rttMs:this.pingAt!==null&&performance.now()-this.pingAt>2e3?performance.now()-this.pingAt:performance.now()-this.rttAt<6e3?this.rttMs:null,deliveryDelayMs:this.sampleFrames?this.deliveryDelayMs:0,decodeQueue:Math.max(this.peakDecodeQueue,this.decoder?.decodeQueueSize??0),frames:this.sampleFrames}:void 0}),this.sampleFrames=0,this.peakDecodeQueue=0,this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=t)},1e3)}send(t){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(t))}catch{}}sendControl(t){t&&(this.controlsSent++,this.send({type:"control",data:fO(t)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(t){if(typeof t!="string")return;this.lastMessageAt=Date.now();let r;try{r=JSON.parse(t)}catch{return}this.lastType=`${r.type??"?"}${r.config?":cfg":""}${r.key?":key":""}`;try{this.dispatchMessage(r)}catch(n){console.warn("[android] message handling failed",n),this.callbacks.onWarning(`处理消息失败:${n instanceof Error?n.message:String(n)}`)}}dispatchMessage(t){switch(t.type){case"bitrate-support":this.liveBitrate=t.supported===!0,this.bitrateFailureDetail=this.liveBitrate?void 0:typeof t.detail=="string"?t.detail.slice(0,4096):"BITRATE_REASON_UNAVAILABLE: server did not provide diagnostics",this.liveBitrate||this.finishBitrate(!1,this.bitrateFailureDetail),this.callbacks.onBitrateSupport?.(this.liveBitrate,this.bitrateFailureDetail);break;case"bitrate-result":t.requestId===this.bitratePending?.id&&this.finishBitrate(t.applied===!0&&t.bitRate===this.bitratePending?.value,typeof t.detail=="string"?t.detail.slice(0,4096):void 0);break;case"header":this.header={deviceName:t.deviceName??this.serial,codec:t.codec??"h264",width:t.width??0,height:t.height??0},this.lastFrameAt=Date.now(),this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(t);break;case"error":this.callbacks.onState("error",t.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break;case"pong":this.pingAt!==null&&(this.rttMs=performance.now()-this.pingAt,this.rttAt=performance.now(),this.pingAt=null);break}}handleFrame(t){if(typeof t.data!="string")return;typeof t.seq=="number"&&(this.lastSeq=t.seq);const r=pO(t.data);if(this.bytesSinceSample+=t.data.length,this.receivedFrames++,this.lastFrameAt=Date.now(),this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),t.config){this.configData=r,this.pendingConfig=r,this.configureDecoder(),this.ack();return}this.sampleFrames++;const n=Number(t.pts);if(t.pts!==void 0&&Number.isFinite(n)){const c=performance.now()-n/1e3;this.minimumFrameOffset=Math.min(this.minimumFrameOffset,c),this.deliveryDelayMs=Math.max(0,c-this.minimumFrameOffset)}this.configured||this.configureDecoder();const a=t.key===!0;if(this.needsKeyframe&&!a){this.ack();return}let l=r;this.pendingConfig&&(l=new Uint8Array(this.pendingConfig.length+r.length),l.set(this.pendingConfig,0),l.set(r,this.pendingConfig.length),this.pendingConfig=null),a&&(this.needsKeyframe=!1),this.decode(l,a,t.pts),this.ack()}configureDecoder(){const t=this.header?.codec??"h264";if(!this.decoder||this.decoder.state==="closed"){if(typeof VideoDecoder>"u"){this.warnedUnsupported||(this.warnedUnsupported=!0,this.callbacks.onWarning("当前浏览器不支持 WebCodecs(VideoDecoder),无法解码投屏画面。")),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}try{this.decoder=new VideoDecoder({output:l=>this.onDecodedFrame(l),error:l=>{this.configured=!1,console.warn("[android] video decoder error",l),this.callbacks.onState("error",l instanceof Error?l.message:"VIDEO_DECODER_ERROR"),this.sendControl(gu(q5))}})}catch(l){console.warn("[android] VideoDecoder unavailable",l),this.callbacks.onWarning(`创建 VideoDecoder 失败:${l instanceof Error?l.message:String(l)}`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED");return}}const r={codec:"avc1.42e01e",optimizeForLatency:!0};let n;t==="h264"?(n=[mO(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((c,h,p)=>p.indexOf(c)===h),r.avc={format:"annexb"}):t==="h265"?(n=[gO(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],r.hevc={format:"annexb"}):n=["av01.0.04M.08"];const a=[];for(const l of n)try{this.decoder.configure({...r,codec:l}),this.configured=!0,this.needsKeyframe=!0,l!==n[0]&&console.warn("[android] decoder configured with fallback codec",l);return}catch(c){a.push(`${l}: ${c instanceof Error?c.message:String(c)}`),console.warn("[android] decoder configure failed",l,c)}this.callbacks.onWarning(`解码器配置失败(${a.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(t,r,n){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:r?"key":"delta",timestamp:n?Number(n):this.lastTimestamp+1,data:t})),this.peakDecodeQueue=Math.max(this.peakDecodeQueue,this.decoder.decodeQueueSize),this.lastTimestamp=n?Number(n):this.lastTimestamp+1}catch(a){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",a),this.callbacks.onWarning(`送入解码器失败:${a instanceof Error?a.message:String(a)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(t){this.frameCount++,this.decodedFrames++;const r=t.displayWidth||t.codedWidth,n=t.displayHeight||t.codedHeight,a=this.canvas;(a.width!==r||a.height!==n)&&(a.width=r,a.height=n,this.header&&(this.header={...this.header,width:r,height:n},this.callbacks.onHeader(this.header)));const l=a.getContext("2d");l&&l.drawImage(t,0,0,a.width,a.height),t.close()}pointerPoint(t,r){return{x:t,y:r,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(t,r,n,a){const l=t===Jp||t===Z5,c=l?0:1,h=a===e0&&!l?X5:0,p=(t===Y5||t===Jp)&&a===e0?X5:0;this.sendControl(lO(t,a,this.pointerPoint(r,n),c,p,h))}pointerDown(t,r,n){this.touch(Y5,t,r,n==="mouse"?e0:ch)}pointerMove(t,r,n){this.touch(oO,t,r,n==="mouse"?e0:ch)}pointerUp(t,r,n){this.touch(Jp,t,r,n==="mouse"?e0:ch)}pointerCancel(t,r,n){this.touch(Z5,t,r,n==="mouse"?e0:ch)}scroll(t,r,n,a){this.sendControl(cO(this.pointerPoint(t,r),n,a))}key(t,r=em){this.sendControl(tm(r,t))}tapKey(t){this.sendControl(tm(em,t)),this.sendControl(tm(K5,t))}back(){this.sendControl(J5(em)),this.sendControl(J5(K5))}home(){this.tapKey(mu.HOME)}recents(){this.tapKey(mu.APP_SWITCH)}power(){this.tapKey(mu.POWER)}volumeUp(){this.tapKey(mu.VOLUME_UP)}volumeDown(){this.tapKey(mu.VOLUME_DOWN)}rotate(){this.sendControl(gu(iO))}expandNotifications(){this.sendControl(gu(rO))}collapsePanels(){this.sendControl(gu(nO))}setDisplayPower(t){this.sendControl(hO(t))}sendText(t){this.sendControl(uO(t))}startApp(t){this.sendControl(dO(t))}}function bO(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function yO(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${bO()}.png`}function eb(e){const t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}async function vO(e,t=yO()){const r=e.width,n=e.height;if(!r||!n)throw new Error("投屏画面尚未就绪");const a=document.createElement("canvas");a.width=r,a.height=n;const l=a.getContext("2d");if(!l)throw new Error("无法读取投屏画面");l.drawImage(e,0,0);const c=await new Promise(h=>a.toBlob(h,"image/png"));if(!c||c.size===0)throw new Error("截图失败,请重试");return new File([c],t,{type:"image/png"})}function Zv(e,t,r){const n=r.contentWidth*(t-1)/2,a=r.contentHeight*(t-1)/2;return{x:Math.max(-n,Math.min(n,e.x)),y:Math.max(-a,Math.min(a,e.y))}}function tb(e,t,r,n,a){const l=Math.max(1,Math.min(8,e.zoom*a)),c=l/e.zoom;return{zoom:l,pan:Zv({x:n.x-t.cx-(r.x-t.cx-e.pan.x)*c,y:n.y-t.cy-(r.y-t.cy-e.pan.y)*c},l,t)}}function Kv(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),l=p=>{window.clearTimeout(h),window.removeEventListener("termdock-insert-reference-ack",c),p?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},c=p=>{const g=p.detail;g?.nonce===a&&l(g.ok===!0)},h=window.setTimeout(()=>l(!1),1e4);window.addEventListener("termdock-insert-reference-ack",c),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:e,sessionId:t,nonce:a,focus:!1,paste:!0}}))}):Promise.reject(new Error("没有可接收内容的终端"))}function rb(e,t){return Kv(ny(e,null),t)}const nm=Jl(e=>({pending:[],enqueue:(t,r,n="/",a)=>e(l=>l.pending.some(c=>c.file.id===t.id)?l:{pending:[...l.pending,{file:t,sessionId:r,initialPath:n,insert:a}]}),remove:t=>e(r=>({pending:r.pending.filter(n=>n.file.id!==t)}))}));function wO({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=Hr(),[l,c]=b.useState(!1),[h,p]=b.useState(!1),[g,x]=b.useState(!1),[y,A]=b.useState(!1),[v,L]=b.useState(null),I=b.useRef(!1),E=b.useRef(null),R=async()=>{if(!I.current){I.current=!0,p(!0),A(!0);try{await ZP(e.id),n()}catch(Q){L(Q instanceof Error?Q.message:String(Q))}finally{I.current=!1,p(!1),A(!1)}}};b.useEffect(()=>{if(l)return;E.current?.focus();const Q=$=>{if($.stopPropagation(),$.key==="Escape"&&$.preventDefault(),$.key!=="Tab")return;const W=Array.from(E.current?.querySelectorAll("button:not(:disabled)")??[]),B=W[0],q=W.at(-1);$.shiftKey&&(document.activeElement===B||document.activeElement===E.current)?($.preventDefault(),q?.focus()):!$.shiftKey&&document.activeElement===q&&($.preventDefault(),B?.focus())};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[l]);const P=async Q=>{if(!I.current){I.current=!0,p(!0),x(Q!==void 0),c(!1),L(null);try{const $=await YP(e.id,Q);Q===void 0&&await r($.path),n()}catch($){L($ instanceof Error?$.message:String($))}finally{I.current=!1,p(!1)}}};return l?s.jsx(_f,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>c(!1),onConfirm:Q=>{P(Q)}}):ki.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex items-center justify-center bg-[var(--app-backdrop)] p-4",children:s.jsxs("div",{ref:E,role:"dialog","aria-modal":"true","aria-labelledby":"recording-save-title",tabIndex:-1,"aria-busy":h,className:"w-full max-w-sm rounded-xl border border-border bg-surface p-4 text-foreground shadow-xl outline-none",children:[s.jsx("h2",{id:"recording-save-title",className:"text-sm font-semibold",children:a("android.recordingConfirm")}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("android.recordingSaveHint")}),s.jsxs("p",{className:"mt-2 break-all text-xs text-muted-foreground",children:[e.name," · ",(e.size/1024/1024).toFixed(1)," MB"]}),(v||e.error)&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs text-destructive",children:v||e.error}),h&&s.jsxs("p",{role:"status",className:"mt-3 flex items-center gap-2 text-sm text-primary",children:[s.jsx(En,{size:16,className:"animate-spin"}),y?`${a("android.recordingDiscard")}…`:a(g?"android.recordingSaving":"android.captureInserting")]}),s.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>{P()},className:"min-h-10 rounded-lg bg-primary px-3 text-sm text-primary-foreground disabled:opacity-40",children:a("android.recordingInsert")}),s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>c(!0),className:"min-h-10 rounded-lg bg-surface-2 px-3 text-sm disabled:opacity-40",children:a("android.recordingSave")}),s.jsx("button",{type:"button",disabled:h,onClick:()=>{R()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const Iu="android-mirror",xu=Iu,Xv="termdock:android:quality:v1",sm=176,AO=204,wl=1,Dh=8,nb=[1,1.25,1.5,2,2.5,3,4,6,8],TO=e=>Math.max(wl,Math.min(Dh,e));function SO(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function uh(e){const t=e.parentElement;if(!t)return null;const r=t.getBoundingClientRect(),n=getComputedStyle(t),a=parseFloat(n.paddingLeft)||0,l=parseFloat(n.paddingTop)||0,c=t.clientWidth-a-(parseFloat(n.paddingRight)||0),h=t.clientHeight-l-(parseFloat(n.paddingBottom)||0);return{cx:r.left+t.clientLeft+a+c/2,cy:r.top+t.clientTop+l+h/2,width:c,height:h,contentWidth:e.offsetWidth,contentHeight:e.offsetHeight}}function CO(e,t){try{e.setPointerCapture?.(t)}catch{}}function sb(e,t){try{e.releasePointerCapture?.(t)}catch{}}const ib=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),dh=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},im={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},_O=()=>{try{const e=localStorage.getItem(Xv);return e?e1(JSON.parse(e)):id}catch{return id}},bu=e=>{try{localStorage.setItem(Xv,JSON.stringify(e))}catch{}};function LO({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:l}){const{t:c}=Hr(),h=G5(O=>O.overlay),p=G5(O=>O.setOverlay),g=b.useRef(null),x=b.useRef(null),y=b.useRef(null),A=b.useMemo(_O,[]),v=b.useRef(A),L=b.useRef(null),I=b.useRef(null),[E,R]=b.useState(4e6),P=b.useRef(null),Q=b.useRef(new Map),$=b.useRef(null),W=b.useRef(!1),[B,q]=b.useState(wl),ne=b.useRef(B),Be=b.useRef({x:0,y:0}),fe=b.useRef(null),X=b.useRef(0),Qe=b.useRef(0),Pe=b.useRef(null),ue=b.useRef(0),[Ce,tt]=b.useState(null),[we,ce]=b.useState(null),[$e,ke]=b.useState(!0),[se,je]=b.useState(""),[de,Oe]=b.useState(A.id),[Ee,_e]=b.useState([]),[re,Fe]=b.useState(null),[wt,Xe]=b.useState(""),[ee,Ue]=b.useState(!0),[Le,te]=b.useState({maxSize:A.maxSize,bitRate:A.bitRate,maxFps:A.maxFps}),[ye,ot]=b.useState("idle"),[le,xe]=b.useState(null),[Ne,yt]=b.useState(null),[gt,At]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Ft,Z]=b.useState(null),[Ge,pt]=b.useState(null),[Pt,hr]=b.useState(!1),[Zt,_r]=b.useState([]),[ae,ze]=b.useState(null),[Je,Rt]=b.useState([]),[Mt,ir]=b.useState(!1),Ut=b.useRef(null),We=b.useRef(0),br=b.useRef([]),[Ze,Dt]=b.useState(!1),[nt,_t]=b.useState(""),[Qr,yr]=b.useState(!1),[Nt,Nn]=b.useState(!1),[Zr,lt]=b.useState(""),[gr,Pr]=b.useState(null),[be,Er]=b.useState(null),[at,en]=b.useState(!1),[Te,Lt]=b.useState(0),Y=b.useRef(null),[st,xt]=b.useState(!1),Gt=b.useRef(!1),Gr=b.useRef(new Set),Fr=b.useRef(null),ur=b.useRef(null),tn=b.useRef(!1),[on,Xr]=b.useState(!1),Wr=b.useRef(a);Wr.current=a;const[$r,Ur]=b.useState(!1),[Cn,Rn]=b.useState(null),hn=b.useRef(null),Vr=b.useRef(null),ys=FP(O=>O.activeSessionId??O.sessions.keys().next().value??null),cn=e??ys,Vt=ts(O=>!!O.docks[xu]),hs=ts(O=>O.hosts[xu]),Sn=ts(O=>O.setDock),rs=b.useCallback(async()=>{ke(!0);try{const O=await zP();tt(O),ce(null)}catch(O){ce(O instanceof Error?O.message:"ADB_UNAVAILABLE")}finally{ke(!1)}},[]);b.useEffect(()=>{rs()},[rs]);const qr=Ce?.devices??[],_n=qr.find(O=>O.serial===se)??null,un=!!(we&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(we)),Bn=!!(Ce?.adbAvailable&&!Ce.scrcpyVersion),Nr=b.useCallback(()=>{const O=P.current,Ae=[...Q.current.keys()];P.current=null,Q.current.clear(),$.current=null,W.current=!1,Ut.current=null,dh(X.current),X.current=0,O&&x.current?.pointerCancel(O.x,O.y,O.type);const Re=g.current;if(Re)for(const mt of Ae)sb(Re,mt);ze(null),ir(!1),Rt([]),q(ne.current)},[]);b.useEffect(()=>{const O=mt=>{Q.current.has(mt.pointerId)&&(mt.type==="pointercancel"||mt.target!==g.current)&&Nr()},Ae=()=>Nr(),Re=()=>{document.hidden&&Nr()};return window.addEventListener("pointerup",O,!0),window.addEventListener("pointercancel",O,!0),window.addEventListener("blur",Ae),document.addEventListener("visibilitychange",Re),()=>{window.removeEventListener("pointerup",O,!0),window.removeEventListener("pointercancel",O,!0),window.removeEventListener("blur",Ae),document.removeEventListener("visibilitychange",Re),Nr()}},[Nr]);const zr=b.useCallback(()=>{Nr(),x.current?.disconnect(),x.current=null,ot("idle"),xe(null),yt(null)},[Nr]),wn=b.useCallback((O,Ae=!1)=>{const Re=g.current;if(!Re||!O)return;Nr(),x.current?.disconnect(),xe(null),!Ae&&y.current!==O&&yt(null),y.current=O,pt(null),Z(null);const mt=new xO(Re,{onBitrateSupport:(or,Jt)=>{x.current!==mt||v.current.id!=="auto"||Z(or?null:Jt??"BITRATE_REASON_UNAVAILABLE")},onState:(or,Jt)=>{x.current===mt&&(ot(or),xe(Jt??null))},onHeader:or=>{x.current===mt&&yt(or)},onStats:or=>{x.current===mt&&At(or)},onWarning:or=>{x.current===mt&&pt(or)}});x.current=mt;let Ct=v.current;Ct.id==="auto"?(L.current?.serial!==O&&(L.current={serial:O,policy:new UP}),L.current.policy.connected(performance.now()),Ct=L.current.policy.quality,R(Ct.bitRate)):L.current=null,I.current=Ct,mt.connect(O,Ct)},[Nr]);b.useEffect(()=>{if(de!=="auto"||v.current.id!=="auto"||ye!=="streaming"||!gt.adaptation||document.hidden)return;const O=L.current,Ae=x.current;if(!O||O.serial!==se||!Ae?.canSetBitrate)return;const Re=g.current,mt=Re?Math.max(Re.clientWidth,Re.clientHeight)*(window.devicePixelRatio||1)*ne.current:1600,Ct=O.policy.sample(gt.adaptation,performance.now(),mt||1600);Ct&&Ae.setBitrate(Ct.bitRate).then(or=>{or&&x.current===Ae&&(I.current=Ct,R(Ct.bitRate))})},[gt,de,ye,se,wn]);const V=b.useCallback(O=>{const Ae={...O.quality?{quality:{id:O.quality.id,maxSize:O.quality.maxSize,bitRate:O.quality.bitRate,maxFps:O.quality.maxFps}}:{},...O.activePresetId!==void 0?{activePresetId:O.activePresetId}:{},...O.presets!==void 0?{presets:O.presets}:{},...O.docked!==void 0?{docked:O.docked}:{},...O.deviceSerial!==void 0?{deviceSerial:O.deviceSerial}:{}};fa({androidPanel:Ae}).catch(()=>{})},[]);b.useEffect(()=>{let O=!1;return ec().then(Ae=>{if(O)return;const Re=Ae.androidPanel;if(Re?.quality){const mt=e1(Re.quality);v.current=mt,Oe(mt.id),te({maxSize:mt.maxSize,bitRate:mt.bitRate,maxFps:mt.maxFps}),bu(mt)}_e(Re?.presets??[]),Fe(Re?.activePresetId??null),Re?.deviceSerial&&(Pe.current=Re.deviceSerial,je(Re.deviceSerial))}).catch(()=>{}),()=>{O=!0}},[]);const et=b.useCallback(O=>{const Ae=++We.current;_r(mt=>[...mt,{id:Ae,left:O.left,top:O.top}]);const Re=window.setTimeout(()=>{_r(mt=>mt.filter(Ct=>Ct.id!==Ae)),br.current=br.current.filter(mt=>mt!==Re)},300);br.current.push(Re)},[]),kt=b.useCallback((O,Ae)=>{const Re=x.current,mt=I.current;Re?.supportsLiveBitrate&&y.current===O&&mt&&mt.maxSize===Ae.maxSize&&mt.maxFps===Ae.maxFps?Re.setBitrate(Ae.bitRate).then(Ct=>{x.current===Re&&(Ct?(I.current=Ae,Z(null)):Z(Re.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):wn(O)},[wn,c]),Bt=b.useCallback(O=>{if(L.current=null,O.startsWith("user:")){const Re=Ee.find(Ct=>Ct.id===O.slice(5));if(!Re)return;const mt={id:"custom",maxSize:Re.maxSize,bitRate:Re.bitRate,maxFps:Re.maxFps};v.current=mt,Oe("custom"),Fe(Re.id),te({maxSize:Re.maxSize,bitRate:Re.bitRate,maxFps:Re.maxFps}),Ue(!0),bu(mt),V({quality:mt,activePresetId:Re.id}),se&&wn(se);return}if(O==="custom"){const Re=v.current;Oe("custom"),Fe(null),te({maxSize:Re.maxSize,bitRate:Re.bitRate,maxFps:Re.maxFps}),Ue(!0);return}const Ae=O==="auto"?e1({id:"auto"}):df.find(Re=>Re.id===O)??id;v.current=Ae,Oe(Ae.id),Fe(null),bu(Ae),V({quality:Ae,activePresetId:null}),se&&wn(se)},[wn,se,Ee,V]),zt=b.useCallback(()=>{const O={id:"custom",maxSize:Le.maxSize,bitRate:Le.bitRate,maxFps:Le.maxFps};v.current=O,bu(O),V({quality:O,activePresetId:null}),Oe("custom"),Fe(null),se&&kt(se,O)},[kt,se,Le,V]),gn=b.useCallback(()=>{const O=wt.trim();if(!O)return;const Ae=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,Re={id:Ae,name:O,maxSize:Le.maxSize,bitRate:Le.bitRate,maxFps:Le.maxFps},mt=[...Ee.filter(or=>or.name!==O),Re].slice(-12),Ct={id:"custom",maxSize:Le.maxSize,bitRate:Le.bitRate,maxFps:Le.maxFps};_e(mt),Xe(""),Fe(Ae),Oe("custom"),v.current=Ct,bu(Ct),V({quality:Ct,activePresetId:Ae,presets:mt}),se&&kt(se,Ct)},[wt,Le,Ee,se,kt,V]),lr=b.useCallback(()=>{if(!re)return;const O=Ee.filter(Ae=>Ae.id!==re);_e(O),Fe(null),V({activePresetId:null,presets:O})},[re,Ee,V]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const O of br.current)window.clearTimeout(O);br.current=[]},[]),b.useEffect(()=>{if(h==="off")return;const O=Ae=>{Ae.key==="Escape"&&p("off")};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[h,p]),b.useEffect(()=>{const O=qr.filter(Re=>Re.state==="device");if(se||O.length!==1)return;const Ae=O[0].serial;Pe.current!==Ae&&(Pe.current=Ae,je(Ae))},[qr,se]),b.useEffect(()=>{se&&wn(se)},[se,wn]),b.useEffect(()=>{if(ye==="streaming"){ue.current=0,hr(!1);return}if(ye!=="error"||!se||!IO(le??""))return;const O=Math.min(8e3,700*2**ue.current);ue.current+=1,hr(!0);const Ae=window.setTimeout(()=>{hr(!1),wn(se)},O);return()=>window.clearTimeout(Ae)},[ye,le,se,wn]);const yn=b.useCallback((O,Ae,Re)=>{const mt=g.current,Ct=Re??(mt?uh(mt):null);return!mt||!Ct?{x:0,y:0}:Zv(O,Ae,Ct)},[]),ar=b.useCallback(()=>{const O=g.current;if(!O)return;const{x:Ae,y:Re}=Be.current,mt=ne.current,Ct=mt===wl&&Ae===0&&Re===0?"":`translate3d(${Ae}px, ${Re}px, 0) scale(${mt})`;O.style.transform!==Ct&&(O.style.transform=Ct);const or=fe.current;or&&(or.textContent=mt>wl?SO(mt):"")},[]),Ln=b.useCallback((O,Ae,Re=!0)=>{const mt=g.current,Ct=ne.current,or=TO(O);if(!mt||or===Ct)return;const Jt=uh(mt);if(!Jt)return;const Ht=Ae??{x:Jt.cx,y:Jt.cy},Or=tb({zoom:Ct,pan:Be.current},Jt,Ht,Ht,or/Ct);ne.current=Or.zoom,Be.current=Or.pan,Re&&ar()},[ar]),rn=b.useCallback(()=>{const O=ne.current;q(Ae=>Ae<=wl+.01==O<=wl+.01&&Ae>=Dh-.01==O>=Dh-.01?Ae:O)},[]);b.useEffect(()=>()=>{dh(X.current),dh(Qe.current)},[]);const $n=()=>{let O=0,Ae=0;for(const mt of Q.current.values())O+=mt.x,Ae+=mt.y;const Re=Q.current.size;return Re?{x:O/Re,y:Ae/Re}:null},ns=()=>{const[O,Ae]=Array.from(Q.current.values());return O&&Ae?Math.hypot(O.x-Ae.x,O.y-Ae.y):0},vs=()=>{const O=$n(),Ae=g.current?uh(g.current):null;!O||!Ae||($.current={startCentroid:O,startDistance:ns(),box:Ae})},fs=b.useCallback(()=>{const O=$.current,Ae=$n();if(!O||!Ae)return;const Re=ns(),mt=O.startDistance>0&&Re>0?Re/O.startDistance:1,Ct=tb({zoom:ne.current,pan:Be.current},O.box,O.startCentroid,Ae,mt);ne.current=Ct.zoom,Be.current=Ct.pan,O.startCentroid=Ae,O.startDistance=Re},[]),Gn=b.useCallback(()=>{X.current||(X.current=ib(()=>{X.current=0,fs(),ar()}))},[fs,ar]),fn=b.useCallback(()=>{X.current&&(dh(X.current),X.current=0,fs(),ar())},[fs,ar]);b.useEffect(()=>{const O=g.current;if(!O)return;const Ae=O.parentElement;if(!Ae)return;const Re=Ct=>{if(Ct.ctrlKey||Ct.metaKey){if(Ct.preventDefault(),!Ct.deltaY||$.current)return;const Ht=Ct.deltaMode===1?16:Ct.deltaMode===2?O.parentElement?.clientHeight||600:1,Or=Math.max(-600,Math.min(600,Ct.deltaY*Ht));Ln(ne.current*Math.exp(-Or*.002),{x:Ct.clientX,y:Ct.clientY},!1),Qe.current||(Qe.current=ib(()=>{Qe.current=0,ar(),rn()}));return}const or=x.current;if(!or||Ct.target!==O)return;Ct.preventDefault();const Jt=fh(O,Ct.clientX,Ct.clientY);or.scroll(Jt.x,Jt.y,Ct.deltaX,Ct.deltaY)},mt=Ct=>Ct.preventDefault();return Ae.addEventListener("wheel",Re,{passive:!1}),Ae.addEventListener("gesturestart",mt,{passive:!1}),Ae.addEventListener("gesturechange",mt,{passive:!1}),()=>{Ae.removeEventListener("wheel",Re),Ae.removeEventListener("gesturestart",mt),Ae.removeEventListener("gesturechange",mt)}},[Ln,ar,rn]),b.useEffect(()=>{const O=g.current,Ae=O?.parentElement;if(!O||!Ae||typeof ResizeObserver>"u")return;const Re=new ResizeObserver(()=>{$.current&&($.current.box=uh(O));const mt=yn(Be.current,ne.current);mt.x===Be.current.x&&mt.y===Be.current.y||(Be.current=mt,ar())});return Re.observe(O),Re.observe(Ae),()=>Re.disconnect()},[yn,ar]),b.useLayoutEffect(()=>{ar()});const Un=O=>{const Ae=x.current,Re=g.current;if(!Ae||!Re)return;if(O.pointerType==="mouse"&&O.button!==0){O.preventDefault(),O.button===2?Ae.back():O.button===1&&Ae.home();return}O.preventDefault(),Re.closest(".android-mirror-panel")?.focus({preventScroll:!0}),ar(),rn(),fn(),CO(Re,O.pointerId),Q.current.set(O.pointerId,{x:O.clientX,y:O.clientY});const mt=O.pointerType==="mouse"&&O.altKey;if(Q.current.size>=2||mt){const Jt=P.current;Jt&&(Ae.pointerCancel(Jt.x,Jt.y,Jt.type),P.current=null,Ut.current=null,ze(null),ir(!1),Rt([])),W.current=!0,vs();return}if(W.current)return;const Ct=fh(Re,O.clientX,O.clientY);P.current={id:O.pointerId,type:O.pointerType,x:Ct.x,y:Ct.y},Ae.pointerDown(Ct.x,Ct.y,O.pointerType);const or=ub(Re,O.clientX,O.clientY);or&&(Ut.current={left:or.left,top:or.top},Rt([]),ir(!1),ze(or))},xr=O=>{const Ae=x.current,Re=g.current;if(!Re||!Q.current.has(O.pointerId))return;if(O.pointerType==="mouse"){const Ht=Re.getBoundingClientRect(),Or=Re.parentElement?.getBoundingClientRect()??Ht;if(!(O.buttons&1)||O.clientX<Math.max(Ht.left,Or.left)||O.clientX>=Math.min(Ht.right,Or.right)||O.clientY<Math.max(Ht.top,Or.top)||O.clientY>=Math.min(Ht.bottom,Or.bottom)){Nr();return}}if(O.preventDefault(),Q.current.set(O.pointerId,{x:O.clientX,y:O.clientY}),$.current){Gn();return}const mt=P.current;if(!Ae||!mt||mt.id!==O.pointerId)return;const Ct=fh(Re,O.clientX,O.clientY);mt.x=Ct.x,mt.y=Ct.y,Ae.pointerMove(Ct.x,Ct.y,mt.type);const or=ub(Re,O.clientX,O.clientY),Jt=Ut.current;!or||!Jt||(ze(or),Math.hypot(or.left-Jt.left,or.top-Jt.top)>=6&&(ir(!0),Rt(Ht=>{const Or=Ht[Ht.length-1];if(Or&&Math.hypot(or.left-Or.x,or.top-Or.y)<4)return Ht;const Mn=[...Ht,{x:or.left,y:or.top}];return Mn.length>12?Mn.slice(Mn.length-12):Mn})))},z=O=>{const Ae=x.current,Re=g.current;if(!Re||!Q.current.has(O.pointerId))return;if(fn(),Q.current.delete(O.pointerId),sb(Re,O.pointerId),Q.current.size===0&&(W.current=!1),$.current){Q.current.size===0?($.current=null,q(ne.current)):vs();return}const mt=P.current;if(!mt||mt.id!==O.pointerId)return;const Ct=fh(Re,O.clientX,O.clientY);Ae?.pointerUp(Ct.x,Ct.y,mt.type),ae&&et(ae),ze(null),ir(!1),window.setTimeout(()=>Rt([]),200),P.current=null,Ut.current=null},ge=O=>{if($r||Ze||Nt)return;const Ae=x.current;Ae&&(O.key==="Backspace"?(O.preventDefault(),Ae.key(67)):O.key==="Escape"?(O.preventDefault(),Ae.back()):O.key==="Enter"&&(O.preventDefault(),Ae.key(66)))},Ye=async()=>{const O=nt.trim();if(O){yr(!0);try{const Ae=await HP(O);_t(""),Dt(!1),await rs(),je(Ae.serial)}catch(Ae){ce(Ae instanceof Error?Ae.message:"ADB_CONNECT_FAILED")}finally{yr(!1)}}},ct=()=>{const O=x.current,Ae=Zr;!O||!Ae||(O.sendText(Ae),lt(""))},it=b.useCallback(O=>{Pr(O),ur.current!==null&&window.clearTimeout(ur.current),ur.current=window.setTimeout(()=>{ur.current=null,Pr(null)},2500)},[]),bt=b.useCallback(O=>{const Ae=ne.current,Re=O==="in"?nb.find(mt=>mt>Ae+.01):[...nb].reverse().find(mt=>mt<Ae-.01);Re!==void 0&&(Ae<=wl&&Re>wl&&it(c("android.zoomPanHint")),fn(),Ln(Re),q(Re))},[Ln,fn,it,c]),Ot=O=>{Promise.resolve().then(()=>r?.(O)).catch(Ae=>{Er(Ae instanceof Error?Ae.message:String(Ae))})},qt=b.useCallback(async(O,Ae)=>{try{if(!n)throw new Error(c("android.captureUnavailable"));await n(O),it(Ae)}catch(Re){Er(c("android.captureFailed")+(Re instanceof Error?`:${Re.message}`:""))}},[n,it,c]),dt=async()=>{const O=g.current;if(!(!O||tn.current)){tn.current=!0,Xr(!0),Er(null);try{const Ae=await vO(O);await qt(Ae,c("android.captureInserted"))}catch(Ae){Er(Ae instanceof Error?Ae.message:String(Ae))}finally{tn.current=!1,Xr(!1)}}},nr=b.useCallback(O=>{(O.status==="ready"||O.status==="error")&&Wr.current&&!Gr.current.has(O.id)&&(Gr.current.add(O.id),Wr.current?.(O))},[]),Lr=b.useCallback(async O=>{const Ae=Y.current;if(!(!Ae||Gt.current)){Gt.current=!0,xt(!0),Er(null);try{const Re=await qP(Ae.id);Y.current=null,en(!1),nr(Re)}catch(Re){Er(Re instanceof Error?Re.message:String(Re))}finally{Gt.current=!1,xt(!1)}}},[nr]),vr=async()=>{if(!(!se||Gt.current||Y.current)){Gt.current=!0,xt(!0),Er(null);try{const O=await VP(se);O.status==="recording"||O.status==="starting"||O.status==="stopping"?(Y.current=O,en(!0),Lt(Math.max(0,Date.now()-O.startedAt))):nr(O)}catch(O){Er(O instanceof Error?O.message:String(O))}finally{Gt.current=!1,xt(!1)}}};b.useEffect(()=>{let O=!1,Ae=!1;Y.current=null,en(!1);const Re=async()=>{if(!(!se||Ae||Gt.current)){Ae=!0;try{const{recordings:Ct}=await GP(se);if(O||Gt.current)return;const or=Ct.find(Jt=>["starting","recording","stopping"].includes(Jt.status));Y.current=or??null,en(!!or);for(const Jt of Ct)nr(Jt)}catch{}finally{Ae=!1}}};Re();const mt=window.setInterval(()=>{Re()},2e3);return Fr.current=window.setInterval(()=>{Y.current&&Lt(Math.max(0,Date.now()-Y.current.startedAt))},500),()=>{O=!0,window.clearInterval(mt),Fr.current!==null&&window.clearInterval(Fr.current)}},[se,nr]),b.useEffect(()=>{if(!$r)return;const O=()=>Ur(!1),Ae=mt=>{const Ct=mt.target;Ct instanceof Node&&(hn.current?.contains(Ct)||Vr.current?.contains(Ct)||O())},Re=mt=>{mt.key==="Escape"&&(mt.preventDefault(),mt.stopPropagation(),O())};return document.addEventListener("pointerdown",Ae,!0),document.addEventListener("keydown",Re,!0),window.addEventListener("resize",O),()=>{document.removeEventListener("pointerdown",Ae,!0),document.removeEventListener("keydown",Re,!0),window.removeEventListener("resize",O)}},[$r]),b.useEffect(()=>()=>{ur.current!==null&&window.clearTimeout(ur.current)},[]);const $t=ye==="streaming",rt=Vt,jt=rt?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-surface-2 disabled:opacity-40":"rounded p-1.5 hover:bg-surface-2 disabled:opacity-40",U=_n?(_n.model||_n.serial)+db(_n,c):qr.length?c("android.selectDevice"):c("android.noDevices"),he=(re?Ee.find(O=>O.id===re):null)?.name??(de==="auto"?`${c("android.qualityAuto")} · ${E/1e6} Mbps`:c(im[de])),Me=rt?"relative flex h-5 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50":"relative flex h-7 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50",Qt=rt?"pointer-events-none block min-w-0 truncate px-1 text-[10px] leading-none text-foreground":"pointer-events-none block min-w-0 truncate px-2 text-[11px] leading-none text-foreground",It="absolute inset-0 h-full w-full cursor-pointer opacity-0",tr=()=>{const O=hn.current?.getBoundingClientRect();O&&Rn({left:Math.max(8,Math.min(O.right-sm,window.innerWidth-sm-8)),top:Math.min(O.bottom+4,Math.max(8,window.innerHeight-AO-8))}),Ur(!0)},fr=()=>{if(Vt){Sn(xu,null),V({docked:null});return}if(!cn)return;const O={sessionId:cn,side:"right"};Sn(xu,O),V({docked:O})},jr=Ze||Vt||h!=="off",kn=s.jsxs("div",{className:"android-mirror-panel flex h-full min-h-0 min-w-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:ge,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":Vt?"true":void 0,className:rt?"flex h-6 min-h-6 shrink-0 flex-nowrap items-center gap-1 overflow-hidden border-b border-border/15 bg-[var(--chrome-bg)] px-1.5 cursor-grab select-none active:cursor-grabbing":"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[Vt&&s.jsx("span",{"data-panel-drag-title":"true",role:"button","aria-label":c("android.splitDrag"),title:c("android.splitDrag"),className:"flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground active:cursor-grabbing",children:s.jsx(hf,{size:12})}),s.jsx(vw,{size:rt?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${Me} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Qt} w-full`,children:U}),s.jsxs("select",{value:se,onChange:O=>{const Ae=O.target.value;je(Ae),Pe.current=Ae,Ae&&V({deviceSerial:Ae})},className:It,"aria-label":c("android.device"),children:[s.jsx("option",{value:"",children:qr.length?c("android.selectDevice"):c("android.noDevices")}),qr.map(O=>s.jsx("option",{value:O.serial,children:(O.model||O.serial)+db(O,c)},O.serial))]})]}),s.jsxs("div",{className:`${Me} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Qt,children:he}),s.jsxs("select",{value:re?`user:${re}`:de,onChange:O=>Bt(O.target.value),className:It,title:c(de==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":c("android.quality"),children:[s.jsxs("option",{value:"auto",children:[c("android.qualityAuto"),de==="auto"?` · ${E/1e6} Mbps`:""]}),df.map(O=>s.jsx("option",{value:O.id,children:c(im[O.id])},O.id)),Ee.map(O=>s.jsx("option",{value:`user:${O.id}`,children:O.name},O.id)),s.jsx("option",{value:"custom",children:c(im.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{rs()},className:`${jt} text-muted-foreground`,title:c("android.refresh"),children:$e?s.jsx(En,{size:13,className:"animate-spin"}):s.jsx(vn,{size:13})}),$t?s.jsx("button",{type:"button",onClick:zr,className:`${jt} text-destructive`,title:c("android.disconnect"),children:s.jsx(Kb,{size:13})}):s.jsx("button",{type:"button",onClick:()=>se&&wn(se),disabled:!se,className:`${jt} text-primary`,title:c("android.connect"),children:s.jsx(cT,{size:13})}),($t||at)&&s.jsx("button",{type:"button",onClick:()=>{dt()},disabled:!n||on,className:`${jt} text-muted-foreground`,title:c(n?"android.screenshot":"android.captureUnavailable"),"aria-label":c("android.screenshot"),children:on?s.jsx(En,{size:rt?12:13,className:"animate-spin"}):s.jsx(V9,{size:rt?12:13})}),($t||at)&&s.jsx("button",{type:"button",onClick:()=>{at?Lr("manual"):vr()},disabled:st||!at&&!a,className:`${jt} ${at?"text-destructive":"text-muted-foreground"}`,title:c(at?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":c(at?"android.recordingStop":"android.recordingStart"),children:st?s.jsx(En,{className:"animate-spin",size:13}):at?s.jsx(Zb,{size:rt?10:11,fill:"currentColor"}):s.jsx(Xb,{size:rt?12:13})}),s.jsx("button",{ref:hn,type:"button",onClick:()=>$r?Ur(!1):tr(),"aria-haspopup":"menu","aria-expanded":$r,className:`${jt} ${jr?"text-primary":"text-muted-foreground"}`,title:c("android.more"),"aria-label":c("android.more"),children:s.jsx(ll,{size:rt?13:14})}),l&&!t&&s.jsx("button",{type:"button",onClick:()=>{Ur(!1),p("off"),l()},className:`${jt} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:c("android.closeTab"),"aria-label":c("android.closeTab"),children:s.jsx(Wn,{size:14})})]}),$r&&Cn&&ki.createPortal(s.jsxs("div",{ref:Vr,role:"menu","aria-label":c("android.more"),style:{left:Cn.left,top:Cn.top,width:sm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(hh,{icon:s.jsx(ol,{size:13}),label:c("android.addDevice"),active:Ze,onSelect:()=>{Dt(O=>!O),Ur(!1)}}),s.jsx(hh,{icon:Vt?s.jsx(Wn,{size:13}):s.jsx(Cl,{size:13}),label:c(Vt?"android.splitClose":"android.splitOpen"),active:Vt,disabled:!Vt&&!cn,onSelect:()=>{fr(),Ur(!1)}}),s.jsx(hh,{icon:h==="window"?s.jsx(QA,{size:13}):s.jsx(MA,{size:13}),label:c(h==="window"?"android.exitFullscreen":"android.fullscreen"),active:h==="window",onSelect:()=>{p(h==="window"?"off":"window"),Ur(!1)}}),!t&&s.jsx(hh,{icon:h==="sidebar"?s.jsx(WA,{size:13}):s.jsx(YA,{size:13}),label:c(h==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:h==="sidebar",onSelect:()=>{p(h==="sidebar"?"off":"sidebar"),Ur(!1)}}),Ne&&s.jsxs("div",{className:"mt-1 border-t border-border px-3 py-2 text-[10px] leading-4 tabular-nums text-muted-foreground",children:[s.jsx("div",{className:"truncate",children:`${gt.fps} fps · ${gt.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${gt.width}×${gt.height}`})]})]}),document.body),(de==="custom"||re)&&s.jsxs("div",{className:"border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[s.jsxs("button",{type:"button",onClick:()=>Ue(O=>!O),"aria-expanded":ee,className:"flex w-full items-center gap-1 rounded text-muted-foreground hover:text-foreground",children:[s.jsx(ol,{size:12,className:`transition-transform ${ee?"":"-rotate-90"}`}),s.jsxs("span",{children:[c("android.quality"),re?` · ${Ee.find(O=>O.id===re)?.name??""}`:""]})]}),ee&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(cb,{label:c("android.qualityResolution"),display:`${Le.maxSize}px`,min:360,max:2160,step:8,value:Le.maxSize,onChange:O=>te(Ae=>({...Ae,maxSize:O}))}),s.jsx(cb,{label:c("android.qualityBitRate"),display:`${(Le.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:Le.bitRate/1e6,onChange:O=>te(Ae=>({...Ae,bitRate:Math.round(O*1e6)}))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:c("android.qualityFrameRate")}),s.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(O=>s.jsx("button",{type:"button",onClick:()=>te(Ae=>({...Ae,maxFps:O})),className:`rounded px-2 py-0.5 ${Le.maxFps===O?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:O},O)),s.jsx("button",{type:"button",onClick:()=>te(O=>({...O,maxFps:0})),className:`rounded px-2 py-0.5 ${Le.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:c("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:zt,disabled:!se,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:c("android.qualityApply")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:wt,onChange:O=>Xe(O.target.value),onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&gn()},placeholder:c("android.presetNamePlaceholder"),maxLength:40,className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:gn,disabled:!wt.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:c("android.presetSave")}),re&&s.jsx("button",{type:"button",onClick:lr,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:c("android.presetDelete")})]})]})]}),Ze&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:nt,onChange:O=>_t(O.target.value),onKeyDown:O=>{O.key==="Enter"&&Ye()},placeholder:c("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{Ye()},disabled:Qr,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:Qr?s.jsx(En,{size:12,className:"animate-spin"}):c("android.connect")})]}),un&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:c("android.adbUnavailable")}),s.jsx(ob,{label:c("android.insertFixPrompt"),onClick:()=>Ot(lb("adb",we??"")),enabled:!!r})]}),!un&&Bn&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsx("span",{className:"min-w-0 flex-1",children:c("android.scrcpyUnavailable")}),s.jsx(ob,{label:c("android.insertFixPrompt"),onClick:()=>Ot(lb("scrcpy","")),enabled:!!r})]}),_n&&_n.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:EO(_n,c)}),we&&!un&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:V5(we)}),Ft&&s.jsxs("details",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsxs("summary",{className:"cursor-pointer",children:[c("android.qualityAutoUnavailable")," ",c(Ft.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Ft.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Ft.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Ft.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Ft.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Ft.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Ft})]}),Ge&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:Ge}),be&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:be}),s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 touch-none items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[s.jsx("canvas",{ref:g,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:$t||Ne?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:Un,onPointerMove:xr,onPointerUp:z,onPointerCancel:()=>Nr(),onLostPointerCapture:O=>{Q.current.has(O.pointerId)&&Nr()},onPointerLeave:O=>{Q.current.has(O.pointerId)&&!O.currentTarget.hasPointerCapture?.(O.pointerId)&&Nr()},onContextMenu:O=>O.preventDefault()}),ae&&s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border border-primary/80 bg-primary/35",style:{left:ae.left,top:ae.top}}),Je.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:Mt?1:0,transition:"opacity 160ms linear"},children:Je.slice(1).map((O,Ae)=>{const Re=Je[Ae],mt=(Ae+1)/(Je.length-1);return s.jsx("line",{x1:Re.x,y1:Re.y,x2:O.x,y2:O.y,stroke:"var(--primary)",strokeWidth:1+1.6*mt,strokeLinecap:"round",opacity:.06+.45*mt},Ae)})}),Zt.map(O=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:O.left,top:O.top}},O.id)),!$t&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[ye==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(En,{size:18,className:"animate-spin"}),s.jsx("span",{children:c("android.connecting")})]}),ye==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(zu,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Pt?c("android.reconnecting"):V5(le||"")}),se&&s.jsx("button",{type:"button",onClick:()=>{ue.current=0,wn(se)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:c("android.retry")})]}),ye==="idle"&&!un&&!Bn&&s.jsxs(s.Fragment,{children:[s.jsx(OA,{size:22,className:"opacity-60"}),s.jsx("span",{children:qr.length?c("android.idleHint"):c("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${rt?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(_o,{compact:rt,label:c("android.back"),onClick:()=>x.current?.back(),disabled:!$t,children:s.jsx(jb,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.home"),onClick:()=>x.current?.home(),disabled:!$t,children:s.jsx(kA,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.recents"),onClick:()=>x.current?.recents(),disabled:!$t,children:s.jsx(Gb,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!$t,children:s.jsx(Ub,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!$t,children:s.jsx(mT,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!$t,children:s.jsx(OT,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!$t,children:s.jsx($T,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.power"),onClick:()=>x.current?.power(),disabled:!$t,children:s.jsx(dT,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.inputText"),active:Nt,onClick:()=>Nn(O=>!O),disabled:!$t,children:s.jsx(Wb,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.zoomIn"),onClick:()=>bt("in"),disabled:!$t||B>=Dh-.01,children:s.jsx(Ys,{size:14})}),s.jsx(_o,{compact:rt,label:c("android.zoomOut"),onClick:()=>bt("out"),disabled:!$t||B<=wl+.01,children:s.jsx(Vb,{size:14})}),s.jsxs("div",{className:"relative ml-auto h-5 w-24 min-w-0 max-w-full shrink-0","data-mirror-capture-status":!0,children:[s.jsx("span",{"aria-hidden":at||!!gr||on,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${at||gr||on?"invisible":""}`,children:Ne?s.jsx(s.Fragment,{children:s.jsx("span",{ref:fe})}):""}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-end overflow-hidden",children:s.jsx(kO,{recording:at,elapsed:Te,status:on?c("android.captureInserting"):gr,stopLabel:c("android.recordingStop"),onStop:()=>{Lr("manual")}})})]})]}),Nt&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:Zr,onChange:O=>lt(O.target.value),onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&(O.preventDefault(),ct())},placeholder:c("android.inputPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground",autoFocus:!0}),s.jsx("button",{type:"button",onClick:ct,disabled:!Zr,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:c("android.send"),children:s.jsx(Nu,{size:13})})]})]});return h==="window"?ki.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-[var(--chrome-bg)]",style:{paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:kn}),document.body):t?Vt&&hs?ki.createPortal(kn,hs):null:Vt&&hs?s.jsxs(s.Fragment,{children:[ki.createPortal(kn,hs),s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[s.jsx(Cl,{size:18,className:"opacity-60"}),s.jsx("span",{children:c("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Sn(xu,null),V({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:c("android.splitClose")})]})]}):kn}function hh({icon:e,label:t,active:r=!1,disabled:n=!1,onSelect:a}){return s.jsxs("button",{type:"button",role:"menuitem",disabled:n,onClick:a,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition hover:bg-surface-2 disabled:opacity-40 disabled:hover:bg-transparent ${r?"text-primary":"text-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r&&s.jsx(ci,{size:12,className:"shrink-0"})]})}function kO({recording:e,elapsed:t,status:r,stopLabel:n,onStop:a}){return e?s.jsxs("span",{role:"status","aria-live":"polite",className:"ml-auto inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] tabular-nums text-destructive",children:[s.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-destructive"}),eb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${eb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(Zb,{size:8,fill:"currentColor"})})]}):r?s.jsx("span",{role:"status","aria-live":"polite",title:r,className:"ml-auto truncate text-[10px] text-primary",children:r}):null}function ab({sessionId:e}){const t=ts(x=>x.docks[Iu]),r=!!t,n=t?.sessionId??e??null,l=nm(x=>x.pending)[0],c=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const A=(await ad("/tmp",[x])).files[0]?.path;if(!A)throw new Error("截图上传未返回文件路径");await rb(A,n)},[n]),h=b.useCallback(x=>{nm.getState().enqueue(x,n)},[n]),p=ts(x=>!!x.hosts[Iu]),g=b.useRef(!1);return b.useEffect(()=>{g.current||(g.current=!0,ec().then(x=>{const y=x.androidPanel?.docked;y&&(ts.getState().docks[Iu]||ts.getState().setDock(Iu,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&p&&s.jsx(LO,{sessionId:n,dockOnly:!0,onInsertFile:n?c:void 0,onInsertPrompt:n?x=>Kv(x,n):void 0,onRecordingComplete:h}),l&&s.jsx(wO,{file:l.file,initialPath:l.initialPath,onInsert:x=>l.insert?l.insert(x):rb(x,l.sessionId),onDone:()=>nm.getState().remove(l.file.id)},l.file.id)]})}function ob({label:e,onClick:t,enabled:r}){return r?s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-elevated",children:e}):null}function lb(e,t){return[`Termdock 的“设备投屏”在当前服务端不可用:未找到 ${e==="adb"?"adb(Android platform-tools)":"scrcpy / scrcpy-server"}${t?`(错误:${t})`:""}。`,"请在本机安装并让 Termdock 恢复可用:","1) 安装依赖:"," - macOS: brew install android-platform-tools scrcpy"," - Ubuntu/Debian: sudo apt install adb scrcpy"," - Windows: winget install Google.PlatformTools && winget install Genymobile.scrcpy","2) 若不在 PATH,请在 ~/.termdock/.env 指定 TERMDOCK_ADB_BIN / TERMDOCK_SCRCPY_BIN / TERMDOCK_SCRCPY_SERVER。","3) 完成后重启 Termdock 服务,并用 adb version、scrcpy --version 验证。","边界:只做本机环境安装与配置,不要改动 Termdock 仓库代码。"].join(`
154
+ `)}function cb({label:e,display:t,min:r,max:n,step:a,value:l,onChange:c}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),s.jsx("input",{type:"range",min:r,max:n,step:a,value:l,onChange:h=>c(Number(h.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),s.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:t})]})}function _o({label:e,onClick:t,disabled:r,active:n,compact:a,children:l}){return s.jsx("button",{type:"button",onClick:t,disabled:r,title:e,"aria-label":e,className:`${a?"inline-flex h-5 w-5 items-center justify-center":"p-1.5"} rounded transition active:scale-95 disabled:opacity-30 ${n?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l})}function ub(e,t,r){const n=e.parentElement;if(!n)return null;const a=e.getBoundingClientRect(),l=n.getBoundingClientRect();return{left:a.left-l.left+(t-a.left),top:a.top-l.top+(r-a.top)}}function fh(e,t,r){const n=e.getBoundingClientRect(),a=e.width||n.width,l=e.height||n.height,c=n.width?(t-n.left)/n.width*a:0,h=n.height?(r-n.top)/n.height*l:0;return{x:Math.max(0,Math.min(a,c)),y:Math.max(0,Math.min(l,h))}}function IO(e){return!(/ADB_NOT_FOUND|SCRCPY_NOT_FOUND|SCRCPY_SERVER_NOT_FOUND|SCRCPY_VERSION_UNKNOWN|SCRCPY_UNSUPPORTED_CODEC|VIDEO_DECODER_UNSUPPORTED|decoder|decode/i.test(e)||/INVALID_SERIAL|INVALID_ADDRESS|API_NOT_ALLOWED|AUTHORIZATION_DENIED/i.test(e))}function db(e,t){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${t("android.stateUnauthorized")}`:e.state==="offline"?` · ${t("android.stateOffline")}`:` · ${t("android.stateUnknown")}`}function EO(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function NO(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function RO(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function MO(e){if(!e)return"";const t=new Date(e),r=Date.now(),n=t.getTime()-r;if(n<=0)return"";const a=Math.floor(n/6e4),l=Math.floor(a/60),c=Math.floor(l/24),h=l%24,p=a%60,g=t.toLocaleDateString(void 0,{month:"short",day:"numeric"}),x=t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});let y;return c>0?y=`${c}d ${h}h`:h>0?y=`${h}h ${p}m`:p>0?y=`${p}m`:y="soon",`resets in ${y} (${g} ${x})`}function DO(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function jO({result:e}){const{t}=Hr(),r=e.windows.filter(h=>h.percent===0&&!h.resetAt),n=e.windows.filter(h=>h.percent>0||h.resetAt),a=r.length>0?r.map(h=>h.label).join(" · "):"",l=!!e.error;let c=null;return!l&&e.entitlement&&(e.usagePercent>=90?c=t("quota.exhausted"):e.remaining!==void 0&&e.remaining<e.entitlement?c=t("quota.left",{n:e.remaining}):c=`${Math.round(e.usagePercent)}%`),s.jsxs("div",{className:"rounded-xl border border-border/15 bg-surface-2 p-3 sm:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-foreground",children:[s.jsx("span",{className:"shrink-0",children:DO(e.slug)}),s.jsx("span",{className:"truncate",children:e.displayName}),a&&s.jsx("span",{className:"shrink-0 rounded-full bg-surface-elevated px-2 py-0.5 text-[10px] font-normal text-muted-foreground",children:a})]}),c&&s.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:c})]}),n.length>0?s.jsx("div",{className:"mt-2.5 space-y-2",children:n.map(h=>{const p=Math.max(0,Math.min(100,h.percent));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[s.jsx("span",{className:"w-14 shrink-0 truncate text-muted-foreground sm:w-16",children:h.label}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:"h-2 rounded-full",style:{background:RO(h.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${p}%`,background:NO(h.percent)}})})}),s.jsxs("span",{className:"w-9 shrink-0 text-right tabular-nums font-medium text-foreground",children:[Math.round(h.percent),"%"]})]}),h.resetAt&&s.jsx("p",{className:"mt-1 pl-14 text-[10px] text-muted-foreground sm:pl-16",children:MO(h.resetAt)})]},h.label)})}):l?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function BO({isOpen:e,onClose:t}){const{t:r}=Hr(),[n,a]=b.useState([]),[l,c]=b.useState(!1),h=async(x=!1)=>{c(!0);try{const y=x?await ww():await Aw();a(y.providers||[])}catch{}finally{c(!1)}};if(b.useEffect(()=>{e&&h()},[e]),b.useEffect(()=>{if(!e)return;const x=y=>{const A=y.detail;Array.isArray(A)&&a(A)};return window.addEventListener("termdock:quota-update",x),()=>{window.removeEventListener("termdock:quota-update",x)}},[e]),!e)return null;const p=n.filter(x=>!x.error),g=p.length>0?new Date(Math.max(...p.map(x=>x.fetchedAt||0))):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t}),s.jsxs("div",{className:"fixed inset-x-3 z-modal-panel mx-auto flex max-w-lg flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",style:{top:"max(1.5rem, env(safe-area-inset-top, 0px))",bottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-3 py-2.5 sm:px-6 sm:py-3",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground sm:text-base",children:r("quota.title")}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>h(!0),disabled:l,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":r("quota.refresh"),children:s.jsx(vn,{size:15,className:l?"animate-spin":""})}),s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":r("quota.close"),children:s.jsx(Wn,{size:17})})]})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:[l&&p.length===0?s.jsx(Fu,{label:r("common.loading"),className:"py-12"}):p.length===0?s.jsxs("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:[s.jsx("p",{children:r("quota.noProviders")}),s.jsx("p",{className:"mt-1.5 text-[11px]",children:r("quota.noProvidersHint")})]}):s.jsx("div",{className:"space-y-2.5",children:p.map(x=>s.jsx(jO,{result:x},x.slug))}),g&&s.jsx("p",{className:"mt-3 text-center text-[10px] text-muted-foreground",children:r("quota.updated",{time:g.toLocaleTimeString()})})]})]})]})}const hb=[{label:"Esc",sequence:"\\u001b"},{label:"Tab",sequence:"\\t"},{label:"Enter",sequence:"\\r"},{label:"S-Tab",sequence:"\\u001b[Z"},{label:"C-c",sequence:"\\u0003"},{label:"C-d",sequence:"\\u0004"},{label:"C-l",sequence:"\\u000c"},{label:"C-r",sequence:"\\u0012"},{label:"C-z",sequence:"\\u001a"},{label:"C-w",sequence:"\\u0017"},{label:"Up",sequence:"\\u001b[A"},{label:"Down",sequence:"\\u001b[B"},{label:"Left",sequence:"\\u001b[D"},{label:"Right",sequence:"\\u001b[C"},{label:"PgUp",sequence:"\\u001b[5~"},{label:"PgDn",sequence:"\\u001b[6~"}],QO=2,PO=20;function OO({label:e}){return s.jsx("div",{className:"h-7 rounded-full bg-surface-2 px-3 text-[11px] leading-7 text-center text-muted-foreground truncate",children:e})}function FO({value:e,onChange:t,placeholder:r}){const{t:n}=Hr(),[a,l]=S.useState(""),c=y=>{const A=[];let v="",L=!1;const I=()=>{const R=v.trim();R&&A.push(R),v=""};for(let R=0;R<y.length;R+=1){const P=y[R];if(!L&&P==="/"&&v.trim().length===0){L=!0,v+=P;continue}if(L){if(v+=P,P==="/"&&y[R-1]!=="\\"&&v.length>1){for(;R+1<y.length&&/[gimsuy]/.test(y[R+1]??"");)R+=1,v+=y[R];I(),L=!1}continue}if(P===","||/\s/.test(P)){I();continue}v+=P}if(I(),A.length===0)return;const E=[...e];for(const R of A){const P=K3(R);P&&(E.includes(P)||E.push(P))}t(E),l("")},h=y=>{t(e.filter(A=>A!==y))},p=a.trim(),g=p.length>0&&q2(p),x=g&&!qh(p);return s.jsx("div",{className:"rounded-2xl bg-surface px-3 py-2 ring-1 ring-border/15 focus-within:ring-accent/40",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.map(y=>{const A=q2(y),v=A&&!qh(y);return s.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] ${v?"bg-destructive/15 text-destructive":A?"bg-accent/15 font-mono text-accent":"bg-surface-elevated text-foreground"}`,title:A?v?n("settings.invalidRegex"):"Regex match":"Substring match (case-insensitive)",children:[A&&s.jsx("span",{className:"text-[10px] opacity-70",children:"re"}),y,s.jsx("button",{type:"button",onClick:()=>h(y),className:"rounded-full p-0.5 text-muted-foreground hover:bg-destructive/20 hover:text-destructive","aria-label":n("toolbarPresets.removeAction",{name:y}),children:s.jsx(Wn,{size:12})})]},y)}),s.jsx("input",{type:"text",value:a,onChange:y=>l(y.target.value),onKeyDown:y=>{y.key==="Enter"||y.key===","&&!g?(y.preventDefault(),c(a)):y.key==="Backspace"&&a.length===0&&e.length>0&&h(e[e.length-1])},onBlur:()=>c(a),placeholder:e.length===0?r:"",className:`min-w-[8ch] flex-1 bg-transparent py-1 text-sm outline-none placeholder:text-muted/60 ${g?"font-mono":""} ${x?"text-destructive":""}`,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off"})]})})}function $O({value:e,min:t,max:r,onChange:n}){const{t:a}=Hr();return s.jsxs("div",{className:"inline-flex items-center gap-1 rounded-full bg-surface px-1 py-1 ring-1 ring-border/15",children:[s.jsx("button",{type:"button",onClick:()=>n(Math.max(t,e-1)),disabled:e<=t,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.decrease"),children:s.jsx(Vb,{size:14})}),s.jsx("span",{className:"w-6 text-center text-sm font-medium tabular-nums text-foreground",children:e}),s.jsx("button",{type:"button",onClick:()=>n(Math.min(r,e+1)),disabled:e>=r,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.increase"),children:s.jsx(Ys,{size:14})})]})}const UO=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:l,onResetDefaults:c})=>{const{t:h}=Hr(),p=e.find(R=>R.id===t)??e[0]??null,[g,x]=S.useState(null);if(!p)return null;const y=p.actions.length>0,A=[{id:"preview-auto",label:p.label,kind:"preset"},...p.includeAlt?[{id:"preview-alt",label:"Alt"}]:[],...y?p.actions.map((R,P)=>({id:R.id,label:Im(R,P)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(R=>({id:R,label:R}))],v=X3(A,p.rowLayout),L=(R,P)=>{n(p.id,Q=>{const $=Q.actions.findIndex(q=>q.id===R);if($===-1)return Q;const W=$+P;if(W<0||W>=Q.actions.length)return Q;const B=[...Q.actions];return[B[$],B[W]]=[B[W],B[$]],{...Q,actions:B}})},I=p.rowLayout.reduce((R,P)=>R+P,0),E=1+(p.includeAlt?1:0);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky top-[-1rem] sm:top-[-1.5rem] z-10 -mx-4 -mt-4 sm:-mx-6 sm:-mt-6 border-b border-border/15 bg-surface/95 backdrop-blur px-4 py-3 sm:px-6",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.preview")}),s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[p.actions.length," button",p.actions.length===1?"":"s"," · ",I," slot",I===1?"":"s"]})]}),s.jsx("div",{className:"space-y-1 rounded-2xl bg-surface-2/60 p-2",children:v.map((R,P)=>{const Q=R.items[0]?.kind==="preset",$=Math.max(2,R.columns),W=Q?`${J3}px repeat(${Math.max(1,$-1)}, minmax(0, 1fr))`:`repeat(${$}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:W},children:R.items.map(B=>B.kind==="preset"?s.jsx(ey,{mode:"auto",presetLabel:B.label,title:`Auto preset · ${B.label}`,disabled:!0},B.id):s.jsx(OO,{label:B.label},B.id))},`preview-row-${P}`)})}),p.actions.length>I-E&&s.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground",children:h("toolbarPresets.overCapacityHint")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.presets")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(Ys,{size:14}),h("toolbarPresets.new")]}),s.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(vn,{size:14}),h("toolbarPresets.reset")]})]})]}),s.jsx("div",{className:"-mx-1 flex flex-wrap gap-1.5 px-1",children:e.map(R=>s.jsxs("button",{type:"button",onClick:()=>r(R.id),className:`rounded-full px-3 py-2 text-xs font-medium transition ${R.id===p.id?"bg-primary/20 text-primary ring-1 ring-primary/30":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,children:[R.label,R.actions.length>0&&s.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:R.actions.length})]},R.id))})]}),s.jsxs("div",{className:"space-y-4 rounded-2xl bg-surface p-4 ring-1 ring-border/10",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.label")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:p.label,onChange:R=>n(p.id,P=>({...P,label:R.target.value})),className:"flex-1 rounded-full bg-surface-2 px-4 py-2.5 text-sm placeholder:text-muted/60 outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.presetLabelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"}),p.id!=="default"&&s.jsx("button",{type:"button",onClick:()=>l(p.id),className:"shrink-0 rounded-full bg-surface-2 px-3 py-2.5 text-destructive hover:bg-destructive/15","aria-label":h("toolbarPresets.deletePreset",{name:p.label}),children:s.jsx(Zs,{size:14})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.matchPrograms")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:h("toolbarPresets.typeEnterHint")})]}),s.jsx(FO,{value:p.programs,onChange:R=>n(p.id,P=>({...P,programs:R})),placeholder:h("toolbarPresets.programsPlaceholder")}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:h("toolbarPresets.programsHelp")})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,includeAlt:!R.includeAlt})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:h("toolbarPresets.altSlot")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:h("toolbarPresets.altSlotHint")})]}),s.jsx(nl,{checked:p.includeAlt})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,showOnDesktop:!R.showOnDesktop})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:h("toolbarPresets.desktopVisibility")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:h("toolbarPresets.desktopVisibilityHint")})]}),s.jsx(nl,{checked:p.showOnDesktop===!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.rowLayout")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("toolbarPresets.rowLayoutHint")})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,rowLayout:[...x1(R.rowLayout),3]})),className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium hover:bg-surface-elevated",children:[s.jsx(Ys,{size:12}),h("toolbarPresets.addRow")]})]}),s.jsx("div",{className:"space-y-2",children:p.rowLayout.map((R,P)=>s.jsxs("div",{className:"flex items-center gap-3 rounded-2xl bg-surface-2 px-3 py-2",children:[s.jsx("span",{className:"w-12 shrink-0 text-xs text-muted-foreground",children:h("toolbarPresets.rowN",{n:P+1})}),s.jsx("div",{className:"flex-1"}),s.jsx($O,{value:R,min:QO,max:PO,onChange:Q=>n(p.id,$=>({...$,rowLayout:$.rowLayout.map((W,B)=>B===P?Q:W)}))}),p.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(p.id,Q=>({...Q,rowLayout:Q.rowLayout.filter(($,W)=>W!==P)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":h("toolbarPresets.removeRow",{n:P+1}),children:h("toolbarPresets.del")})]},`row-${P}`))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.buttons")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("toolbarPresets.buttonsHint")})]}),s.jsxs("button",{type:"button",onClick:()=>{const R=`${p.id}-action-${Date.now()}`;n(p.id,P=>({...P,actions:[...P.actions,{id:R,label:`Key ${P.actions.length+1}`,sequence:""}]})),x(R)},className:"inline-flex items-center gap-1 rounded-full bg-primary/15 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/25",children:[s.jsx(Ys,{size:12}),h("toolbarPresets.addButton")]})]}),p.actions.length===0&&s.jsx("div",{className:"rounded-2xl bg-surface-2/60 px-4 py-6 text-center text-[11px] text-muted-foreground",children:h("toolbarPresets.noCustomButtons")}),p.actions.map((R,P)=>{const Q=g===R.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${Q?"ring-1 ring-accent/40":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>L(R.id,-1),disabled:P===0,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":h("toolbarPresets.moveUp"),children:s.jsx($b,{size:12})}),s.jsx("button",{type:"button",onClick:()=>L(R.id,1),disabled:P===p.actions.length-1,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":h("toolbarPresets.moveDown"),children:s.jsx(B9,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(Q?null:R.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Im(R,P)}),s.jsxs("div",{className:"truncate text-[11px] text-muted-foreground",children:[R.sequence?R.sequence:h("toolbarPresets.noSequence"),R.doubleTapSequence&&s.jsxs("span",{className:"ml-1 text-accent/70",children:["· 2× ",R.doubleTapSequence]})]})]}),s.jsx("button",{type:"button",onClick:()=>n(p.id,$=>({...$,actions:$.actions.filter(W=>W.id!==R.id)})),className:"shrink-0 rounded-full bg-surface p-2 text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":h("toolbarPresets.removeAction",{name:R.label}),children:s.jsx(Zs,{size:14})})]}),Q&&s.jsxs("div",{className:"space-y-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.labelField")}),s.jsx("input",{type:"text",value:R.label,onChange:$=>n(p.id,W=>({...W,actions:W.actions.map(B=>B.id===R.id?{...B,label:$.target.value}:B)})),className:"w-full rounded-full bg-surface px-4 py-2.5 text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.labelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.sequence")}),s.jsx("input",{type:"text",value:R.sequence,onChange:$=>n(p.id,W=>({...W,actions:W.actions.map(B=>B.id===R.id?{...B,sequence:$.target.value}:B)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.sequencePlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:hb.map($=>s.jsx("button",{type:"button",onClick:()=>n(p.id,W=>({...W,actions:W.actions.map(B=>B.id===R.id?{...B,sequence:$.sequence}:B)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:$.label},$.label))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.doubleTap")}),!R.doubleTapSequence&&s.jsx("button",{type:"button",onClick:()=>n(p.id,$=>({...$,actions:$.actions.map(W=>W.id===R.id?{...W,doubleTapSequence:""}:W)})),className:"text-[10px] text-accent hover:text-accent/80",children:h("toolbarPresets.doubleTapAdd")})]}),R.doubleTapSequence!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:R.doubleTapSequence,onChange:$=>n(p.id,W=>({...W,actions:W.actions.map(B=>B.id===R.id?{...B,doubleTapSequence:$.target.value}:B)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.doubleTapPlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[hb.map($=>s.jsx("button",{type:"button",onClick:()=>n(p.id,W=>({...W,actions:W.actions.map(B=>B.id===R.id?{...B,doubleTapSequence:(B.doubleTapSequence??"")+$.sequence}:B)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:$.label},$.label)),s.jsx("button",{type:"button",onClick:()=>n(p.id,$=>({...$,actions:$.actions.map(W=>{if(W.id!==R.id)return W;const{doubleTapSequence:B,...q}=W;return q})})),className:"rounded-full bg-destructive/10 px-2.5 py-1 text-[11px] font-medium text-destructive/70 hover:bg-destructive/20 hover:text-destructive",children:h("toolbarPresets.remove")})]})]})]})]})]},R.id)})]})]})]})},zO={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function HO(){const{t:e}=Hr(),[t,r]=S.useState(null),[n,a]=S.useState(null),[l,c]=S.useState(null),[h,p]=S.useState(null),[g,x]=S.useState(!1),[y,A]=S.useState(!1),[v,L]=S.useState(""),[I,E]=S.useState(""),[R,P]=S.useState(null),[Q,$]=S.useState([]),[W,B]=S.useState([]),[q,ne]=S.useState(null),[Be,fe]=S.useState(new Set),[X,Qe]=S.useState(null),[Pe,ue]=S.useState("auto"),[Ce,tt]=S.useState({}),[we,ce]=S.useState(null),[$e,ke]=S.useState(null),[se,je]=S.useState(10),[de,Oe]=S.useState(""),[Ee,_e]=S.useState(""),[re,Fe]=S.useState(12e3),[wt,Xe]=S.useState(null),[ee,Ue]=S.useState(null),Le=S.useCallback(async()=>{const[ae,ze,Je,Rt]=await Promise.allSettled([Tw(),Sw(),ec(),O0()]);if(r(ae.status==="fulfilled"?ae.value:[]),ze.status==="fulfilled"){const Mt=ze.value;$(Mt.plugins??[]),B(Mt.errors??[])}else $([]),B([]);if(Je.status==="fulfilled"){const Mt=Je.value;fe(new Set(Mt.autoRenameAgents??[])),ue(Mt.autoRenameNamer??"auto"),tt(Mt.autoRenameModels??{}),je(Mt.autoRenameIntervalMinutes??10),Oe(Mt.autoRenamePromptPreference??""),_e(Mt.autoRenamePromptPreference??""),Fe(Mt.autoRenamePromptPayloadChars??12e3)}else fe(new Set);ce(Rt.status==="fulfilled"?Rt.value:[])},[]);S.useEffect(()=>{Le()},[Le]);const te=async(ae,ze)=>{a(ae),c(null);try{ze==="install"?(await Cw(ae)).devMode&&p(ae):(await _w(ae),h===ae&&p(null)),await Le()}catch(Je){c(Je instanceof Error?Je.message:String(Je))}finally{a(null)}},ye=ae=>e(ae==="installed"?"settings.agentHooksInstalled":ae==="outdated"?"settings.agentHooksOutdated":ae==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),ot=async()=>{P(null);let ae;try{ae=JSON.parse(I)}catch{P("Invalid JSON");return}try{await Rw(ae),E(""),x(!1),await Le()}catch(ze){if(ze instanceof Mw&&ze.migration){B(Je=>[{slug:typeof ae.slug=="string"?ae.slug:"manifest.json",errors:ze.message.split(`
155
+ `),code:ze.code,migration:ze.migration},...Je.filter(Rt=>Rt.slug!==ae.slug)]);return}P(ze instanceof Error?ze.message:String(ze))}},le=async()=>{const ae=v.trim();if(ae){Xe("install"),P(null);try{await Lw(ae),L(""),A(!1),await Le()}catch(ze){P(ze instanceof Error?ze.message:String(ze))}finally{Xe(null)}}},xe=async ae=>{Xe(`remove:${ae}`);try{await Nw(ae),Ue(ze=>ze?.slug===ae?null:ze),await Le()}catch(ze){c(ze instanceof Error?ze.message:String(ze))}finally{Xe(null)}},Ne=async ae=>{Xe(`check:${ae}`),c(null);try{await Ew(ae),await Le()}catch(ze){c(ze instanceof Error?ze.message:String(ze))}finally{Xe(null)}},yt=async ae=>{Xe(`update:${ae}`),c(null);try{const ze=await Iw(ae),Je=[ze.hookWarning,ze.titleWarning].filter(Boolean).join(" ");Je&&c(Je),Ue(Rt=>Rt?.slug===ae?null:Rt),await Le()}catch(ze){c(ze instanceof Error?ze.message:String(ze))}finally{Xe(null)}},gt=async ae=>{Xe(`doctor:${ae}`),c(null),Ue(null);try{const ze=await kw(ae);Ue(ze),ce(await O0())}catch(ze){c(ze instanceof Error?ze.message:String(ze))}finally{Xe(null)}},At=async ae=>{const ze=ae.migration?.aiPrompt??ae.errors.join(`
156
+ `);try{await navigator.clipboard.writeText(ze),ne(ae.slug),window.setTimeout(()=>ne(Je=>Je===ae.slug?null:Je),1800)}catch{P(ze)}},Ft=async ae=>{if(X)return;const ze=Be,Je=new Set(ze);Je.has(ae)?Je.delete(ae):Je.add(ae),fe(Je),Qe(ae),c(null);try{const Rt=await fa({autoRenameAgents:[...Je]});fe(new Set(Rt.autoRenameAgents??[])),ce(await O0(!0))}catch(Rt){fe(ze),c(Rt instanceof Error?Rt.message:String(Rt))}finally{Qe(null)}},Z=async ae=>{const ze=Pe;ue(ae),ke("namer"),c(null);try{const Je=await fa({autoRenameNamer:ae});ue(Je.autoRenameNamer??"auto"),ce(await O0(!0))}catch(Je){ue(ze),c(Je instanceof Error?Je.message:String(Je))}finally{ke(null)}},Ge=async(ae,ze)=>{const Je=Ce,Rt={...Je};ze?Rt[ae]=ze:delete Rt[ae],tt(Rt),ke(ae),c(null);try{const Mt=await fa({autoRenameModels:Rt});tt(Mt.autoRenameModels??{})}catch(Mt){tt(Je),c(Mt instanceof Error?Mt.message:String(Mt))}finally{ke(null)}},pt=async ae=>{const ze=se;je(ae),ke("interval"),c(null);try{const Je=await fa({autoRenameIntervalMinutes:ae});je(Je.autoRenameIntervalMinutes??10)}catch(Je){je(ze),c(Je instanceof Error?Je.message:String(Je))}finally{ke(null)}},Pt=async()=>{const ae=de.trim();if(ae!==Ee){ke("preference"),c(null);try{const Je=(await fa({autoRenamePromptPreference:ae})).autoRenamePromptPreference??"";Oe(Je),_e(Je)}catch(ze){Oe(Ee),c(ze instanceof Error?ze.message:String(ze))}finally{ke(null)}}},hr=async ae=>{const ze=Math.max(1e3,Math.min(64e3,Math.round(ae||12e3))),Je=re;Fe(ze),ke("payload-limit"),c(null);try{const Rt=await fa({autoRenamePromptPayloadChars:ze});Fe(Rt.autoRenamePromptPayloadChars??12e3)}catch(Rt){Fe(Je),c(Rt instanceof Error?Rt.message:String(Rt))}finally{ke(null)}},Zt=new Set(Q.map(ae=>ae.slug)),_r=ee?{ok:e("settings.agentPluginDoctorStatusOk"),"missing-title-namer":e("settings.agentPluginDoctorStatusMissing"),"cli-default":e("settings.agentPluginDoctorStatusCliDefault"),"no-models":e("settings.agentPluginDoctorStatusNoModels"),"probe-failed":e("settings.agentPluginDoctorStatusFailed")}[ee.status]:"";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentAutoRename")}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameHint")}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameNamer")}),s.jsxs("select",{value:Pe,disabled:$e!==null,onChange:ae=>{Z(ae.target.value)},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:e("settings.agentAutoRenameFollow")}),we?.filter(ae=>ae.available).map(ae=>s.jsx("option",{value:ae.slug,children:ae.displayName},ae.slug))]})]}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameInterval")}),s.jsx("select",{value:se,disabled:$e!==null,onChange:ae=>{pt(Number(ae.target.value))},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[5,10,30,60].map(ae=>s.jsxs("option",{value:ae,children:[ae," ",e("settings.agentAutoRenameMinutes")]},ae))})]}),s.jsxs("details",{className:"mt-2 border-t border-border/40 pt-2",children:[s.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentAutoRenameAdvanced")}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePreference")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePreferenceHint")}),s.jsx("textarea",{value:de,maxLength:2e3,rows:3,disabled:$e!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:ae=>Oe(ae.target.value),onBlur:()=>{Pt()},className:"mt-1.5 w-full resize-y rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:ring-1 focus:ring-primary/50 disabled:opacity-50"}),s.jsx("span",{className:"mt-1 block text-right text-[10px] text-muted-foreground",children:$e==="preference"?e("settings.saving"):`${de.length}/2000`})]}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePayloadLimit")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePayloadLimitHint")}),s.jsx("input",{type:"number",min:1e3,max:64e3,step:1e3,value:re,disabled:$e!==null,onChange:ae=>Fe(Number(ae.target.value)),onBlur:ae=>{hr(Number(ae.target.value))},className:"mt-1.5 w-full rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameModelsFromCli")}),s.jsx("button",{type:"button",onClick:async()=>{ce(null);try{ce(await O0(!0))}catch{ce([])}},className:"rounded p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",title:e("settings.agentAutoRenameRefreshModels"),children:s.jsx(vn,{size:11,className:we===null?"animate-spin":""})})]}),we?.filter(ae=>ae.available).map(ae=>{const ze=ae.models.find(Je=>Je.id===ae.recommendedModel);return s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:ae.displayName}),s.jsxs("select",{value:Ce[ae.slug]??"",disabled:$e!==null,onChange:Je=>{Ge(ae.slug,Je.target.value)},className:"min-w-0 max-w-[68%] rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"",children:ze?`${e("settings.agentAutoRenameAutomatic")} · ${ze.displayName}`:e("settings.agentAutoRenameCliDefault")}),ae.models.map(Je=>s.jsx("option",{value:Je.id,children:Je.displayName},Je.id))]})]},ae.slug)}),we?.length===0&&s.jsx("div",{className:"text-[10px] text-[color:var(--warning)]",children:e("settings.agentAutoRenameNoCli")})]})]}),t===null&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx(En,{size:12,className:"animate-spin"})," …"]}),t?.map(ae=>{const ze=n===ae.slug,Je=ae.state!=="not-installed",Rt=Zt.has(ae.slug);return s.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx(Ic,{agent:{slug:ae.slug,displayName:ae.displayName,accentColor:ae.accentColor??"#878580",icon:ae.icon,isPlugin:Rt,iconMode:ae.iconMode,iconVersion:ae.iconVersion??void 0},size:18}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[13px] font-medium text-foreground",children:ae.displayName}),Rt&&s.jsx("span",{className:"rounded bg-[rgb(var(--success-rgb)_/_0.12)] px-1 py-px text-[9px] font-medium text-[color:var(--success)]",children:"plugin"}),s.jsxs("span",{className:`text-[10px] ${zO[ae.state]}`,children:[ae.state==="installed"&&s.jsx(Uu,{size:10,className:"mr-0.5 inline"}),(ae.state==="outdated"||ae.state==="needs-approval")&&s.jsx(n1,{size:10,className:"mr-0.5 inline"}),ye(ae.state)]})]}),s.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",title:ae.targetDisplay,children:[e("settings.agentHooksTarget")," ",ae.targetDisplay]}),h===ae.slug&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksDevMode")}),ae.state==="needs-approval"&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksApprovalHint")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",disabled:X!==null,onClick:()=>{Ft(ae.slug)},className:"flex shrink-0 items-center gap-1.5 rounded-full px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-pressed":Be.has(ae.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(nl,{checked:Be.has(ae.slug),disabled:X!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:ze,onClick:()=>{te(ae.slug,Je?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${Je?"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)]"} disabled:opacity-50`,children:[ze?s.jsx(En,{size:11,className:"animate-spin"}):Je?s.jsx(Zs,{size:11}):ae.state==="outdated"?s.jsx(vn,{size:11}):s.jsx(Wu,{size:11}),ze?"…":Je?e("settings.agentHooksUninstall"):ae.state==="outdated"?e("settings.agentHooksReinstall"):e("settings.agentHooksInstall")]})]})]},ae.slug)}),l&&s.jsx("div",{className:"rounded-xl bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:l}),s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentPlugins")}),s.jsxs("button",{type:"button",onClick:()=>A(!y),className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-2.5 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(Ys,{size:11}),e("settings.agentPluginAdd")]})]}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentPluginHint")}),y&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:v,onChange:ae=>L(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&le()},className:"min-w-0 flex-1 rounded-lg bg-surface px-3 py-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground outline-none",placeholder:e("settings.agentPluginSourcePlaceholder")}),s.jsxs("button",{type:"button",disabled:!v.trim()||wt!==null,onClick:()=>{le()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] transition hover:bg-[rgb(var(--success-rgb)_/_0.22)] disabled:opacity-50",children:[wt==="install"?s.jsx(En,{size:11,className:"animate-spin"}):s.jsx(Wu,{size:11}),e("settings.agentPluginInstallPackage")]})]}),s.jsx("button",{type:"button",onClick:()=>x(!g),className:"text-[10px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentPluginAdvancedManifest")})]}),Q.map(ae=>{const ze=ae.revision?.slice(0,8),Je=wt?.endsWith(`:${ae.slug}`)===!0;return s.jsxs("div",{className:"mt-2 flex items-center gap-2 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[s.jsx("span",{className:"truncate",children:ae.displayName}),ae.updateAvailable&&s.jsx("span",{className:"text-[9px] text-[color:var(--warning)]",children:e("settings.agentPluginUpdateAvailable")})]}),s.jsxs("div",{className:"truncate text-[9px] text-muted-foreground",title:ae.source??void 0,children:[ae.source??e("settings.agentPluginManualSource"),ze?` · ${ze}`:""]})]}),s.jsxs("button",{type:"button",disabled:wt!==null,onClick:()=>{gt(ae.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",title:e("settings.agentPluginDoctorHint"),children:[wt===`doctor:${ae.slug}`?s.jsx(En,{size:10,className:"animate-spin"}):s.jsx(kT,{size:10}),e("settings.agentPluginDoctor")]}),ae.updateSupported&&s.jsxs("button",{type:"button",disabled:wt!==null,onClick:()=>{ae.updateAvailable?yt(ae.slug):Ne(ae.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",children:[Je?s.jsx(En,{size:10,className:"animate-spin"}):s.jsx(vn,{size:10}),ae.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:wt!==null,onClick:()=>{xe(ae.slug)},className:"rounded-full p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-[color:var(--warning)] disabled:opacity-50",title:e("settings.agentPluginDelete"),children:s.jsx(Zs,{size:11})})]},ae.slug)}),ee&&s.jsxs("div",{className:`mt-2 rounded-lg px-3 py-2 text-[10px] ${ee.status==="ok"||ee.status==="cli-default"?"bg-[rgb(var(--success-rgb)_/_0.10)] text-[color:var(--success)]":"bg-[rgb(var(--warning-rgb)_/_0.10)] text-[color:var(--warning)]"}`,children:[s.jsxs("div",{className:"font-medium",children:[ee.displayName,": ",_r]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:ee.models.length>0?`${ee.models.length} ${e("settings.agentPluginDoctorModels")}${ee.recommendedModel?` · ${e("settings.agentPluginDoctorAutomatic")} ${ee.recommendedModel}`:""}`:e("settings.agentPluginDoctorCliDefault")}),ee.error&&s.jsx("div",{className:"mt-1 break-words",children:ee.error}),ee.warnings.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:ee.warnings.map(ae=>s.jsxs("div",{children:["• ",ae]},ae))}),ee.nextSteps.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:ee.nextSteps.map(ae=>s.jsxs("div",{children:["→ ",ae]},ae))})]}),W.map(ae=>s.jsxs("div",{className:"mt-2 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[10px] text-[color:var(--warning)]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"font-medium",children:[ae.slug,": ",ae.code??e("settings.agentPluginInvalid")]}),s.jsxs("button",{type:"button",onClick:()=>{At(ae)},className:"flex shrink-0 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-1 font-medium transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)]",children:[q===ae.slug?s.jsx(Uu,{size:10}):s.jsx(zb,{size:10}),q===ae.slug?e("settings.agentPluginCopied"):e("settings.agentPluginCopyAiPrompt")]})]}),s.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-muted-foreground",children:ae.errors.join(`
157
+ `)}),ae.migration?.guideCommand&&s.jsx("code",{className:"mt-1 block select-all text-foreground",children:ae.migration.guideCommand})]},ae.slug)),y&&g&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsx("textarea",{value:I,onChange:ae=>E(ae.target.value),rows:10,className:"w-full rounded-lg bg-surface px-3 py-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground outline-none resize-y",placeholder:`{
158
+ "version": 2,
159
+ "slug": "my-agent",
160
+ "displayName": "My Agent",
161
+ "aliases": ["my-agent"],
162
+ "accentColor": "#4385BE",
163
+ "statuses": [
164
+ { "id": "thinking", "phase": "working", "label": "Thinking", "indicator": "spinner", "tone": "info" },
165
+ { "id": "approval", "phase": "waiting", "label": "Needs approval", "indicator": "question", "tone": "warning" },
166
+ { "id": "complete", "phase": "done", "label": "Complete", "indicator": "badge", "tone": "success" }
167
+ ],
168
+ "hooks": {
169
+ "target": "~/.my-agent/settings.json",
170
+ "events": [
171
+ { "hook": "UserPromptSubmit", "event": "prompt-submit", "status": "thinking" },
172
+ { "hook": "PermissionRequest", "event": "permission-request", "status": "approval" },
173
+ { "hook": "Stop", "event": "stop", "status": "complete" }
174
+ ]
175
+ }
176
+ }`}),R&&s.jsx("div",{className:"whitespace-pre-wrap break-words text-[10px] text-[color:var(--warning)]",children:R}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{ot()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(oA,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),E(""),P(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function WO({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:l=!1,desktopSnapshot:c,desktopActions:h,onCheckDesktop:p,onInstallDesktop:g}){const{t:x}=Hr(),y=e?.status??"idle",A=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,L=y==="checking"?x("settings.updateChecking"):y==="installing"?x("sidebar.updateInstalling"):y==="ready"?x("sidebar.updateReady"):y==="restarting"?x("sidebar.updateRestarting"):y==="current"?x("settings.updateCurrent"):y==="error"?e?.error||x("sidebar.updateFailed"):x("settings.updateHint"),I=a?.currentVersion||c?.appVersion,E=a?.status??"idle",R=l||E==="checking"||E==="downloading"||E==="installing",P=E==="ready",Q=a?.error||(E==="unsupported"?x("settings.desktopUpdateUnsupported"):E==="checking"?x("settings.desktopUpdateChecking"):E==="current"?x("settings.desktopUpdateCurrent"):E==="downloading"?x("settings.desktopUpdateDownloading"):E==="ready"?x("settings.desktopUpdateReady"):E==="installing"?x("settings.desktopUpdateInstalling"):E==="error"&&a?.error||x("settings.desktopUpdateHint"));return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"termdock-update-title",children:[s.jsx("div",{id:"termdock-update-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:x("settings.updateTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(vn,{size:15,className:A?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.updateRuntimeTitle")}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:L}),e&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:v&&e.latestVersion?`${e.currentVersion} → ${e.latestVersion}`:`v${e.currentVersion}`})]})]}),v?s.jsx("button",{type:"button",disabled:A,onClick:n,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("sidebar.updateRestart")}):s.jsx("button",{type:"button",disabled:A,onClick:r,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(y==="checking"?"settings.updateCheckingShort":y==="installing"?"settings.updateInstallingShort":y==="error"?"sidebar.updateRetry":y==="current"?"settings.updateCheckAgain":"settings.updateCheck")})]}),(a||h)&&s.jsxs("div",{className:"flex items-start justify-between gap-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${P?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(vn,{size:15,className:R?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.desktopUpdateTitle")}),s.jsx("div",{className:`mt-0.5 text-[10px] leading-relaxed ${a?.error?"text-destructive":"text-muted-foreground"}`,role:a?.error?"alert":void 0,children:a?Q:x(p?"settings.desktopStatusLoading":"settings.desktopUpdateUnsupported")}),s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:P&&a?.latestVersion?`${a.currentVersion} → ${a.latestVersion}`:I?`v${I}`:null})]})]}),P?s.jsx("button",{type:"button",disabled:R||!g,onClick:g,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("settings.desktopUpdateRestart")}):s.jsx("button",{type:"button",disabled:!a||R||E==="unsupported"||!p,onClick:p,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(E==="installing"?"settings.updateInstallingShort":E==="downloading"?"settings.desktopUpdateDownloadingShort":E==="checking"?"settings.updateCheckingShort":E==="current"||E==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),h]})}function GO({quality:e}){const{locale:t}=Hr(),r=(h,p)=>t==="zh"?h:p,n=h=>h==null||!Number.isFinite(h)?"—":`${h.toFixed(1)} ms`,a=e?.diagnostics,l=h=>s.jsx("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1.5 tabular-nums",children:h.map(([p,g])=>s.jsxs(S.Fragment,{children:[s.jsx("dt",{children:p}),s.jsx("dd",{className:"text-right text-foreground break-all",children:g})]},p))}),c=(h,p)=>s.jsxs("section",{className:"mt-3 border-t border-border/30 pt-3",children:[s.jsx("h3",{className:"mb-2 font-medium text-foreground",children:h}),p]});return s.jsxs("div",{className:"text-[11px] leading-relaxed",children:[c(r("往返统计","Round-trip statistics"),s.jsxs(s.Fragment,{children:[l([[r("平均延迟","Average latency"),n(e?.average)],["P95",n(e?.p95)],[r("服务端回包处理","Server reply handler"),n(e?.handlerMs)]]),s.jsx("p",{className:"mt-2",children:r("8 秒未响应计为超时,不等于网络丢包。回包处理仅含消息解析至构造回复,不含解密、排队和发包。","A probe times out after 8s; this is not packet loss. Handler timing covers parsing through reply creation, excluding decryption, queues and transmission.")})]})),c(r("当前发送与排队","Current buffers and queues"),a?s.jsxs(s.Fragment,{children:[l([[r("传输层发送缓冲","Transport send buffer"),`${a.bufferedBytes} B`],[r("加密通道待发送","Channel writes pending"),a.pendingWrites?r("有","Yes"):r("无","No")],[r("进行中的非终端请求","Active non-terminal requests"),a.activeRequests],[r("等待通道的请求","Requests waiting for capacity"),a.waitingRequests]]),s.jsx("p",{className:"mt-2",children:r("属于此服务共用的连接,包含文件等其他请求。","Shared by this service, including file transfers and other requests.")})]}):s.jsx("p",{children:r("尚无连接记录。","No connection record yet.")})),c(r("本次连接建立 · 历史耗时","Connection setup · recorded timings"),s.jsxs(s.Fragment,{children:[l([[r("传输通道就绪","Transport ready"),n(a?.transportOpenMs)],...a?.relay?[[r("其中:连上入口 WebSocket","Within transport: entry WebSocket"),n(a.relay.entryOpenMs)],[r("其中:请求中转至通道打开","Within transport: relay open request"),n(a.relay.routeOpenMs)]]:[],[r("Noise 加密握手","Noise handshake"),n(a?.handshakeMs)],[r("终端逻辑通道就绪","Terminal logical channel ready"),n(a?.socketOpenMs)],[r("其中:等待本地通道名额","Within logical open: local capacity wait"),n(a?.socketQueueMs)]]),s.jsx("p",{className:"mt-2",children:r("这是建链时的历史耗时,不代表当前延迟。“其中”为子项,不能重复相加;中转耗时含处理和建链,不含之前的授权。","Recorded setup timings, not live latency. “Within” rows are subsets, not additive. Relay timing includes processing and setup, excluding earlier authorization.")})]}))]})}function VO({backendSessionId:e}){const{locale:t}=Hr(),r=t==="zh",[n,a]=S.useState(null),[l,c]=S.useState(!1);S.useEffect(()=>{if(a(null),!l||!e)return;const y=()=>a(Dw(e));y();const A=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(A),document.removeEventListener("visibilitychange",y)}},[e,l]);const h=n?.diagnostics,p=n?.rtt,g=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":p==null?r?"测量中…":"Measuring…":`${p} ms · ${p<150?r?"流畅":"Low latency":p<300?r?"有延迟":"Moderate latency":r?"高延迟":"High latency"}`:r?"未连接":"Disconnected",x=y=>y==null?"—":`${Math.round(y)} ms`;return s.jsxs("div",{className:"mt-3 rounded-xl bg-surface-2 px-3 text-muted-foreground",children:[s.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(y=>!y),className:"flex min-h-11 w-full items-center gap-2 py-2 text-[12px] tabular-nums hover:text-foreground","aria-label":`${r?"连接质量":"Connection quality"}${l?`: ${g}`:""}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${l&&n&&(!n.connected||n.waiting||p!=null&&p>=300)?"bg-destructive":"bg-current"}`}),s.jsxs("span",{className:"flex-1 text-left",children:[r?"连接质量":"Connection quality",l?` · ${g}`:""]}),s.jsx("span",{"aria-hidden":"true",children:l?"▾":"▸"})]}),l&&s.jsxs("div",{className:"pb-3 text-[11px] leading-relaxed",children:[!e&&s.jsx("p",{children:r?"请先打开一个终端会话,再查看连接质量。":"Open a terminal session to measure connection quality."}),s.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 tabular-nums",children:[s.jsx("dt",{children:r?"近期延迟":"Recent latency"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.minimum==null?"—":`${Math.round(n.minimum)}–${Math.round(n.maximum??n.minimum)} ms`}),s.jsx("dt",{children:r?"波动":"Jitter"}),s.jsx("dd",{className:"text-right text-foreground",children:x(n?.jitter)}),s.jsx("dt",{children:r?"探测超时":"Probe timeouts"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.samples?`${n.timeouts} / ${n.samples}`:"—"}),s.jsx("dt",{children:r?"连接路径":"Connection route"}),s.jsx("dd",{className:"text-right text-foreground break-words",children:h?`${h.path==="relay"?r?"经入口中转":"Via relay":r?"直连":"Direct"} · ${h.endpoint}`:"—"})]}),s.jsx("p",{className:"mt-2",children:r?"每 5 秒更新,统计最近 20 次;波动越小越稳定。":"Updates every 5s, using the last 20 probes. Lower jitter means more consistent latency."}),s.jsxs("details",{className:"mt-3 border-t border-border/30 pt-2",children:[s.jsx("summary",{className:"cursor-pointer py-1 hover:text-foreground",children:r?"诊断详情":"Diagnostics"}),s.jsx(GO,{quality:n})]})]})]})}const fb={"startup-failure":"settings.serverHealthEventStartupFailure",crash:"settings.serverHealthEventCrash","crash-native":"settings.serverHealthEventCrashNative",killed:"settings.serverHealthEventKilled",wedge:"settings.serverHealthEventWedge","port-conflict":"settings.serverHealthEventPortConflict","gave-up":"settings.serverHealthEventGaveUp","exit-zero-unexpected":"settings.serverHealthEventExitZero","terminated-externally":"settings.serverHealthEventTerminated","supervisor-lost":"settings.serverHealthEventSupervisorLost","uncaught-exception":"settings.serverHealthEventUncaughtException","unhandled-rejection":"settings.serverHealthEventUnhandledRejection","exit-nonzero":"settings.serverHealthEventExitNonzero"};function qO(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function YO({state:e,onDismiss:t}){const{t:r}=Hr(),[n,a]=b.useState(!1),[l,c]=b.useState(!1),h=b.useRef(!1),p=b.useRef(!0);b.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(h.current=!1,a(!1),c(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const Q=window.setTimeout(()=>{h.current=!1,a(!1),c(!0)},45e3);return()=>window.clearTimeout(Q)},[n]);const g=async()=>{if(!h.current){h.current=!0,c(!1),a(!0);try{await jw()}catch{if(!p.current)return;h.current=!1,a(!1),c(!0)}}};if(!e)return null;const x=e.incident,y=!e.supervised&&e.supervisor?.phase==="gave-up",A=!e.supervised&&e.supervisor!==null&&!e.supervisor.alive,v=y||A||e.attention,L=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",I=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):A?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),E=x?r(fb[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(fb[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",P=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:qO(x.uptimeMs)}):null,x.signal?`signal ${x.signal}`:null,x.exitCode!==null?`exit ${x.exitCode}`:null].filter(Boolean).join(" · "):"";return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"server-health-title",children:[s.jsx("div",{id:"server-health-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:r("settings.serverHealthTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-destructive/15 text-destructive":"bg-primary/15 text-primary"}`,children:v?s.jsx(AT,{size:15}):s.jsx(ST,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:I}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(L?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${E}${R?` · ${R}`:""}`:r("settings.serverHealthClean")}),x&&L&&s.jsx("div",{className:"mt-1 text-[11px] text-primary",children:r("settings.serverHealthRunningNow")}),x&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:P}),x?.detail&&s.jsx("div",{className:"mt-1 break-words text-[10px] text-muted-foreground/75",children:x.detail}),x?.oomSuspect&&s.jsx("div",{className:"mt-1 text-[10px] text-[color:var(--warning)]",children:r("settings.serverHealthOomNote")}),e.supervisor&&e.supervisor.restarts>0&&!y&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:r("settings.serverHealthRestarted",{count:e.supervisor.restarts})})]})]}),e.attention&&s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:r("settings.serverHealthDismiss")})]}),!e.supervised&&s.jsxs("div",{className:"border-t border-border px-3 py-3",children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:e.canEnableSupervision?r("settings.serverHealthEnableHint"):r("settings.serverHealthEnableUnavailable")}),e.canEnableSupervision&&s.jsx("button",{type:"button",onClick:g,disabled:n,className:"mt-2 min-h-11 rounded-lg bg-primary px-3 text-[12px] font-medium text-primary-foreground disabled:opacity-60",children:r(n?"settings.serverHealthEnabling":"settings.serverHealthEnable")}),n&&s.jsx("p",{role:"status",className:"mt-2 text-[11px] text-muted-foreground",children:r("settings.serverHealthEnablePending")}),l&&s.jsx("p",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:r("settings.serverHealthEnableError")})]})]})}const ZO=()=>()=>{},KO=()=>1/0;function XO(){const{t:e}=Hr(),t=b.useId(),r=rl(),n=b.useSyncExternalStore(r?.subscribe??ZO,r?.retentionLimit??KO);if(!r)return null;const a=Bw+1,l=n===1/0?e("settings.workspaceUnlimited"):String(n);return s.jsxs("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:t,className:"shrink-0 text-[12px] font-medium text-foreground/90",children:e("settings.workspaceLimit")}),s.jsx("input",{id:t,type:"range",min:3,max:a,step:1,value:n===1/0?a:n,"aria-valuetext":l,"aria-describedby":`${t}-hint`,onChange:c=>{const h=Number(c.target.value);r.setRetentionLimit(h===a?1/0:h)},className:"h-8 min-w-0 flex-1"}),s.jsx("output",{htmlFor:t,className:"min-w-12 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:l})]}),s.jsx("p",{id:`${t}-hint`,className:"text-[11px] leading-relaxed text-muted-foreground",children:e("settings.workspaceLimitHint")})]})}const t1="mobile-session-destroy";function JO(e,t){return t&&e.type==="session"&&e.destination?.droppableId===t1}const ua="termdock-program-rules-cache",ph="termdock-toolbar-presets-cache",yu="termdock-settings-cache",pb="termdock-color-theme",mb="termdock:right-sidebar:file-preview-open-by-session:v2",vu="termdock:running-session-button-enabled:v1",wu="termdock:attention-button-enabled:v1",eF=60,gb=320,xb=420,Lo=8;function bb(e,t,r){return Math.min(Math.max(e,t),r)}function yb(e){if(typeof window>"u")return{left:Lo,top:Lo};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,l=Math.max(Lo,window.innerWidth-gb-Lo),c=Math.max(Lo,window.innerHeight-xb-Lo);return{left:bb(n+Lo,Lo,l),top:bb(a+Lo,Lo,c),width:gb,maxHeight:`min(${xb}px, calc(100vh - ${Lo*2}px))`}}function tF(e){return e==="dark"||e==="light"}function rF(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,r])=>{if(!t||!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)})}function am(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,eF);return Object.fromEntries(t)}function nF(e){return Array.isArray(e)&&e.every(t=>{if(!t||typeof t!="object")return!1;const r=t;return typeof r.id=="string"&&typeof r.pattern=="string"&&typeof r.output=="string"&&(r.matchType==="exact"||r.matchType==="includes"||r.matchType==="prefix"||r.matchType==="regex")})}function sF(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function iF(e,t){const r=Zu(),n=new Set(rI()),a=Array.isArray(e)?e:[],l=o0(a),c=t<_u;if(l.length===0)return r;if(c){const p=new Map(l.map(A=>[A.id,A])),g=new Map(a.map(A=>[typeof A.id=="string"?A.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):"",A])),x=l.filter(A=>!n.has(A.id));return[...r.map(A=>{const v=p.get(A.id),L=g.get(A.id);return v?{...A,rowLayout:v.rowLayout,showOnDesktop:typeof L?.showOnDesktop=="boolean"?L.showOnDesktop:A.showOnDesktop}:A}),...x]}const h=new Set(l.map(p=>p.id));return[...l,...r.filter(p=>!h.has(p.id))]}function aF(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const oF={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},Lf="__termdockOverlay",kf="__termdockBaseAnchor",If="__termdockBaseGuard",lF=3,vb=250,cF="termdock-notification-target-v1",wb="/__termdock-notification-target",Ab=3e4;function uF(e){return e==="left-sidebar"||e==="right-sidebar"||e==="right-sidebar-repo-picker"||e==="right-sidebar-file-preview"||e==="settings"||e==="markdown-outline"||e==="markdown-image-lightbox"}function t0(e){if(!e||typeof e!="object")return null;const t=e[Lf];return uF(t)?t:null}function V1(e){return e&&typeof e=="object"?{...e}:{}}function Jv(e){const t=V1(e);return delete t[Lf],t}function dF(e){const t=Jv(e);return delete t[If],{...t,[kf]:!0}}function hF(){typeof window>"u"||window.history.pushState({...Jv(window.history.state),[kf]:!0,[If]:!0},"",window.location.href)}function e6(){for(let e=0;e<lF;e+=1)hF()}function mh(){typeof window>"u"||(window.history.replaceState(dF(window.history.state),"",window.location.href),e6())}function Au(e){typeof window>"u"||window.history.pushState({...V1(window.history.state),[kf]:!0,[Lf]:e,[If]:!1},"",window.location.href)}function fF(e){typeof window>"u"||window.history.replaceState({...V1(window.history.state),[kf]:!0,[Lf]:e,[If]:!1},"",window.location.href)}const t6=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let da=new Set(t6);function Tb(e){const t=new Map;for(const[r,n]of e)t.set(r,{cwd:n.cwd,activeProgram:n.activeProgram,activeProgramRaw:n.activeProgramRaw,inCopyMode:n.inCopyMode,isConnecting:n.isConnecting,agentStatus:n.agentStatus,agentIndicator:n.agentIndicator,agentStatusDetail:n.agentStatusDetail,agent:n.agent,agentMessage:n.agentMessage,agentNativeSessionId:n.agentNativeSessionId,agentResumeRecovered:n.agentResumeRecovered,terminalSessionId:n.terminalSessionId,agentNeedsReview:n.agentNeedsReview,gitStatus:n.gitStatus,shellTitle:n.shellTitle,promptState:n.promptState,tuiProgress:n.tuiProgress});return t}function pF(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t){const a=e.get(r);if(!a||a.cwd!==n.cwd||a.activeProgram!==n.activeProgram||a.activeProgramRaw!==n.activeProgramRaw||a.inCopyMode!==n.inCopyMode||a.isConnecting!==n.isConnecting||a.agentStatus!==n.agentStatus||a.agentIndicator!==n.agentIndicator||a.agentStatusDetail!==n.agentStatusDetail||a.agent!==n.agent||a.agentMessage!==n.agentMessage||a.agentNativeSessionId!==n.agentNativeSessionId||a.agentResumeRecovered!==n.agentResumeRecovered||a.terminalSessionId!==n.terminalSessionId||a.agentNeedsReview!==n.agentNeedsReview||a.gitStatus!==n.gitStatus||a.shellTitle!==n.shellTitle||a.promptState!==n.promptState||a.tuiProgress?.state!==n.tuiProgress?.state||a.tuiProgress?.progress!==n.tuiProgress?.progress)return!1}return!0}function Sb(e,t){return s.jsx(CQ,{sessionMode:e,state:t})}function mF(e,t){const r=new Map(e.map(c=>[c.id,c])),n=t.map(c=>r.get(c)).filter(c=>c!==void 0),a=new Set(t),l=e.filter(c=>!a.has(c.id));return[...n,...l]}const gF=S.lazy(()=>Tc(()=>import("./CollaborationMainWorkspace-B0OgRtyR.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function xF(){const{t:e,locale:t,setLocale:r}=Hr(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";Qw();const l=S.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[c,h]=S.useState(!1),[p,g]=S.useState(()=>lc(pb,tF)??"dark"),x=S.useRef(lc(yu,aF)).current,[y,A]=S.useState(x?.preventSleep??!1),[v,L]=S.useState(x?.networkAvailable??!0),[I,E]=S.useState(Pw),[R,P]=S.useState(Ow),[Q,$]=S.useState(Fw),[W,B]=S.useState($w),[q,ne]=S.useState(qf),[Be,fe]=S.useState(x?.localAccess??oF),[X,Qe]=S.useState(x?.localAccess?.name??""),[Pe,ue]=S.useState(!1),[Ce,tt]=S.useState(null),[we,ce]=S.useState(null),[$e,ke]=S.useState(null),[se,je]=S.useState(!1),[de,Oe]=S.useState(null),Ee=S.useMemo(()=>ao(),[]),_e=!!(Ee?.desktopUpdateState&&Ee.checkDesktopUpdate&&Ee.installDesktopUpdate),[re,Fe]=S.useState(null),[wt,Xe]=S.useState(null),[ee,Ue]=S.useState(!1),[Le,te]=S.useState(null),[ye,ot]=S.useState(!1),[le,xe]=S.useState(()=>am(lc(mb,rF)??{})),[Ne,yt]=S.useState(0),[gt,At]=S.useState(!1),[Ft,Z]=S.useState(0),[Ge,pt]=S.useState(!1),[Pt,hr]=S.useState(0),[Zt,_r]=S.useState(!1),[ae,ze]=S.useState(0),Je=S.useRef(null),[Rt,Mt]=S.useState({}),{terminalSettings:ir,updateTerminalSettings:Ut}=Mj(),We=ir.fontSize,br=ir.rendererMode,[Ze,Dt]=S.useState(!1),nt=S.useRef(Uw()).current,[_t,Qr]=b.useState(()=>nt.sessions.map(C=>({id:C.sessionId,name:C.name,customName:C.customName,mode:C.mode,tmuxSessionName:C.tmuxSessionName}))),yr=yc(C=>C.groupId);S.useEffect(()=>{const C=()=>yc.getState().terminal();return window.addEventListener("switch-terminal-session",C),()=>window.removeEventListener("switch-terminal-session",C)},[]);const[Nt,Nn]=S.useState(nt.activeSessionId),[Zr,lt]=S.useState(!1);S.useEffect(()=>{Zr&&zw({rendered:!0})},[Zr]);const[gr,Pr]=S.useState(null),[be,Er]=S.useState(null),[at,en]=S.useState([]),[Te,Lt]=b.useState(()=>{const C=Jr.getState();return nt.sessions.forEach(j=>{j.backendSessionId&&C.setTerminalSession(j.sessionId,{sessionId:j.backendSessionId,cols:80,rows:24,mode:j.mode,tmuxSessionName:j.tmuxSessionName}),j.activeProgram!=null&&C.setSessionActiveProgram(j.sessionId,j.activeProgram),j.cwd!=null&&C.setSessionCwd(j.sessionId,j.cwd),j.shellTitle!=null&&C.setSessionShellTitle(j.sessionId,j.shellTitle)}),l0("session-chrome-hydrated"),Tb(Jr.getState().sessions)});b.useEffect(()=>{!Ee||!Ze||Promise.all([Ee.snapshot(),Ee.desktopUpdateState?.()??Promise.resolve(null)]).then(([C,j])=>{Fe(C),Xe(j)}).catch(C=>te(C instanceof Error?C.message:String(C)))},[Ee,Ze]),b.useEffect(()=>{Ee?.onDesktopUpdateState&&Ee.onDesktopUpdateState(Xe)},[Ee]),b.useEffect(()=>Jr.subscribe(C=>{const j=Tb(C.sessions);Lt(me=>pF(me,j)?me:j)}),[]);const Y=b.useCallback(async(C,j)=>{Er(null),Pr({sessionId:C,status:"submitting",error:null});try{await Hw(j),Pr(me=>me?.sessionId===C?{...me,status:"waiting",error:null}:me)}catch(me){const St=(me&&typeof me=="object"&&"code"in me?String(me.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):me instanceof Error&&/busy/i.test(me.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");Pr(rr=>rr?.sessionId===C?{...rr,error:St}:rr),Er({tone:"error",message:St})}},[e]);b.useEffect(()=>{if(!gr||gr.status!=="waiting")return;const C=Te.get(gr.sessionId);if(!C||C.agentResumeRecovered||C.agentStatus===null&&!C.agent)return;const j=C.agent?.displayName??"Agent";Pr(null),Er({tone:"success",message:e("tab.resumeAgentSuccess",{agent:j})})},[gr,Te,e]),b.useEffect(()=>{if(!gr||gr.status!=="waiting"||gr.error)return;const C=gr.sessionId,j=window.setTimeout(()=>{const me=e("tab.resumeAgentTimeout");Pr(Ke=>Ke?.sessionId===C&&Ke.status==="waiting"?{...Ke,error:me}:Ke),Er({tone:"error",message:me})},15e3);return()=>window.clearTimeout(j)},[gr,e]),b.useEffect(()=>{if(be?.tone!=="success")return;const C=window.setTimeout(()=>Er(null),3200);return()=>window.clearTimeout(C)},[be]),b.useEffect(()=>{let C=!1;Ww().then(me=>{C||ke(me)}).catch(()=>{}),Gw().then(me=>{C||Oe(me)}).catch(()=>{});const j=Cg(me=>{C||(me.type==="update-state"?ke(me.state):me.type==="server-health"&&Oe(me.state))});return()=>{C=!0,j()}},[]);const st=b.useCallback(async()=>{try{Oe(await Vw())}catch(C){window.alert(C instanceof Error?C.message:String(C))}},[]),xt=b.useCallback(async()=>{const C=$e?.latestVersion;if(!(!C||se)&&window.confirm(e("sidebar.updateRestartConfirm",{version:C}))){je(!0);try{ke(await qw())}catch(j){window.alert(j instanceof Error?j.message:String(j))}finally{je(!1)}}},[$e?.latestVersion,e,se]),Gt=b.useCallback(async()=>{if(!se){je(!0);try{ke(await Yw())}catch(C){window.alert(C instanceof Error?C.message:String(C))}finally{je(!1)}}},[se]),Gr=b.useCallback(async()=>{if(!(!Ee?.checkDesktopUpdate||ee)){Ue(!0);try{Xe(await Ee.checkDesktopUpdate())}catch(C){te(C instanceof Error?C.message:String(C))}finally{Ue(!1)}}},[Ee,ee]),Fr=b.useCallback(async()=>{if(!(!Ee?.installDesktopUpdate||ee||wt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ue(!0);try{Xe(await Ee.installDesktopUpdate())}catch(C){te(C instanceof Error?C.message:String(C))}finally{Ue(!1)}}},[Ee,ee,wt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=p,Zw(p),On(pb,p)},[p]),b.useEffect(()=>{On(mb,am(le))},[le]);const ur=sr(C=>C.leftOpen),tn=sr(C=>C.rightOpen),on=sr(C=>C.leftPinned),Xr=sr(C=>C.leftSidebarWidth),Wr=sr(C=>C.rightPinned),$r=sr(C=>C.rightSidebarWidth),Ur=sr(C=>C.rootPath),Cn=sr(C=>C.contextKey),Rn=sr(C=>C.selectedFilePath),hn=sr(C=>C.groupByFolder),Vr=Fh(C=>C.collaborationGroups),ys=sr(C=>C.collapsedGroups),cn=sr(C=>C.toggleGroupCollapsed),[Vt,hs]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Sn,rs]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[qr,_n]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[un,Bn]=b.useState([]),[Nr,zr]=b.useState({available:!0,version:null,reason:null}),[wn,V]=b.useState(!1),[et,kt]=b.useState(null),[Bt,zt]=b.useState(null),[gn,lr]=b.useState(null),[yn,ar]=b.useState(null),[Ln,rn]=b.useState(null),[$n,ns]=b.useState(null),[vs,fs]=b.useState(null),[,Gn]=b.useState(0),[fn,Un]=b.useState(null),[xr,z]=b.useState(null),[ge,Ye]=b.useState(null),[ct,it]=b.useState(!1),[bt,Ot]=b.useState(()=>lc(vu,C=>typeof C=="boolean")??!1),qt=b.useCallback(async C=>{const j=bt;Ot(C),On(vu,C);try{const me=await fa({runningSessionButtonEnabled:C});Ot(me.runningSessionButtonEnabled),On(vu,me.runningSessionButtonEnabled)}catch{Ot(j),On(vu,j)}},[bt]),[dt,nr]=b.useState(()=>lc(wu,C=>typeof C=="boolean")??!0),Lr=b.useCallback(async C=>{const j=dt;nr(C),On(wu,C);try{const me=await fa({attentionButtonEnabled:C});nr(me.attentionButtonEnabled),On(wu,me.attentionButtonEnabled)}catch{nr(j),On(wu,j)}},[dt]),[vr,$t]=b.useState(null),rt=b.useCallback(C=>{$t(C)},[]),jt=b.useRef(!1),[U,G]=b.useState(null),[he,Me]=b.useState(null),Qt=S.useRef(null),It=S.useRef(!1),tr=S.useRef(null),fr=S.useRef(!1),jr=b.useCallback(()=>{ns(null),fs(null)},[]),kn=S.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[O,Ae]=S.useState(kn.current),[Re,mt]=S.useState(!0),Ct=S.useRef(kn.current),or=S.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const C=window.matchMedia("(min-width: 1024px)"),j=()=>{hs(C.matches),rs(window.innerWidth)};return j(),C.addEventListener("change",j),window.addEventListener("resize",j),()=>{C.removeEventListener("change",j),window.removeEventListener("resize",j)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const C=window.matchMedia("(orientation: landscape)"),j=()=>_n(C.matches);return j(),C.addEventListener("change",j),()=>C.removeEventListener("change",j)},[]);const Jt=S.useMemo(()=>Nt?at.find(C=>C.sessionIds.includes(Nt))??null:null,[Nt,at]),Ht=Jt?.id??null,Or=Jt?.sessionIds[0]??Nt,Mn=S.useRef([]);S.useLayoutEffect(()=>{const C=Mn.current;if(Mn.current=at,C.length===0)return;const j=new Set(at.flatMap(me=>me.sessionIds));for(const me of C){const Ke=me.sessionIds.filter(St=>!j.has(St)).map(St=>({sessionId:St,rootPath:Jr.getState().sessions.get(St)?.cwd??null}));Ke.length>0&&sr.getState().inheritRightSidebarStateFromSplitWorkspace(me.id,Ke)}},[at]),S.useLayoutEffect(()=>((()=>{const j=Or?Jr.getState().sessions.get(Or)?.cwd??null:null;sr.getState().setRootPath(j,Or,Ht)})(),Jr.subscribe((j,me)=>{const Ke=Or?j.sessions.get(Or)?.cwd??null:null,St=Or?me.sessions.get(Or)?.cwd??null:null;Ke!==St&&sr.getState().setRootPath(Ke,Or,Ht)})),[Ht,Or]);const ws=Vt||qr,Pi=Sn*.95,Oi=ws?Math.min(Math.max(Sn*.22,280),340):Math.min(Sn*.86,380),gs=Nt&&Ur?`${Nt}\0${Ur}`:"",Ks=!!(gs&&Rn&&le[gs]),hi=b.useCallback(C=>{gs&&(C&&!sr.getState().selectedFilePath||xe(j=>{if(!!j[gs]===C)return j;if(C)return am({...j,[gs]:{updatedAt:Date.now()}});const Ke={...j};return delete Ke[gs],Ke}))},[gs]);b.useEffect(()=>{Oj(gs,Cn,Rn)&&xe(C=>{if(!C[gs])return C;const j={...C};return delete j[gs],j})},[gs,Cn,Rn]);const As=Zt?"markdown-image-lightbox":Ge?"markdown-outline":gt?"right-sidebar-repo-picker":tn&&Ks?"right-sidebar-file-preview":Ze?"settings":tn&&!(Wr&&Vt)?"right-sidebar":ur&&!(on&&Vt)?"left-sidebar":null,zn=S.useRef(As),na=S.useRef(As),Ra=S.useRef(!1),Xs=S.useRef(!1),uo=b.useCallback(()=>{if(typeof window>"u")return;const C=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!Vt||!C||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[Vt]),Es=b.useCallback(C=>{if(C==="markdown-image-lightbox"){_r(!1),ze(j=>j+1);return}if(C==="markdown-outline"){pt(!1),hr(j=>j+1);return}if(C==="right-sidebar-file-preview"){pt(!1),hr(j=>j+1),hi(!1),yt(j=>j+1);return}if(C==="right-sidebar-repo-picker"){At(!1),Z(j=>j+1);return}if(C==="settings"){Dt(!1),sa(!1),Qs(!1),oe(!1);return}if(C==="left-sidebar"){sr.getState().closeLeft();return}pt(!1),hr(j=>j+1),At(!1),Z(j=>j+1),_r(!1),ze(j=>j+1),sr.getState().closeRight()},[hi]),Vn=b.useCallback(C=>{if(!l&&typeof window<"u"&&zn.current===C&&t0(window.history.state)===C){window.history.back();return}Es(C)},[Es,l]),Ms=b.useCallback(()=>{Dt(!1);const C=sr.getState();C.closeRight(),C.openLeft()},[]),ho=b.useCallback(()=>{Dt(!1);const C=sr.getState();C.closeLeft(),C.openRight()},[]),pa=b.useCallback(()=>{Dt(!1);const C=sr.getState();C.closeLeft(),C.openRight(),C.setRightTab("files"),C.openRightSearch()},[]),Fi=b.useCallback(()=>{const C=sr.getState();if(C.leftPinned){C.setLeftPinned(!1),C.closeLeft();return}if(ur){Vn("left-sidebar");return}Ms()},[Ms,Vn,ur]),ma=b.useCallback(()=>{const C=sr.getState();C.leftPinned?(C.setLeftPinned(!1),C.openLeft()):(C.setLeftPinned(!0),C.openLeft())},[]),Ma=b.useCallback(()=>{const C=sr.getState();C.setLeftPinned(!1),C.closeLeft()},[]),$i=b.useCallback(()=>{const C=sr.getState();C.rightPinned?(C.setRightPinned(!1),C.openRight()):(C.setRightPinned(!0),C.openRight())},[]),fo=b.useCallback(()=>{const C=sr.getState();C.setRightPinned(!1),C.closeRight()},[]),fi=b.useRef(0),Ds=b.useRef(0),pn=b.useRef(null),Da=b.useCallback(C=>{C.preventDefault(),fi.current=C.clientX,Ds.current=sr.getState().leftSidebarWidth;const j=Ke=>{pn.current===null&&(pn.current=requestAnimationFrame(()=>{pn.current=null;const St=Ke.clientX-fi.current;sr.getState().setLeftSidebarWidth(Ds.current+St)}))},me=()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",me),pn.current!==null&&(cancelAnimationFrame(pn.current),pn.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",j),window.addEventListener("mouseup",me)},[]),ss=b.useRef(0),ga=b.useRef(0),Ns=b.useRef(null),cl=b.useCallback(C=>{C.preventDefault(),ss.current=C.clientX;const j=sr.getState(),me=j.leftPinned?j.leftSidebarWidth:0;ga.current=xh(j.rightSidebarWidth,window.innerWidth,me);const Ke=rr=>{Ns.current===null&&(Ns.current=requestAnimationFrame(()=>{Ns.current=null;const Ir=ss.current-rr.clientX,nn=sr.getState(),An=nn.leftPinned?nn.leftSidebarWidth:0;nn.setRightSidebarWidth(xh(ga.current+Ir,window.innerWidth,An))}))},St=()=>{window.removeEventListener("mousemove",Ke),window.removeEventListener("mouseup",St),Ns.current!==null&&(cancelAnimationFrame(Ns.current),Ns.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",Ke),window.addEventListener("mouseup",St)},[]),pi=b.useCallback(()=>{const C=sr.getState();if(C.rightPinned){C.setRightPinned(!1),C.closeRight();return}if(tn){Vn("right-sidebar");return}ho()},[ho,Vn,tn]),ja=b.useCallback(()=>{!Ks&&!l&&typeof window<"u"&&zn.current==="right-sidebar"&&t0(window.history.state)==="right-sidebar"&&(Au("right-sidebar-file-preview"),na.current="right-sidebar-file-preview"),hi(!0)},[Ks,l,hi]),po=b.useCallback(()=>{Vn("right-sidebar-file-preview")},[Vn]),Il=b.useCallback(()=>{!gt&&!l&&typeof window<"u"&&zn.current==="right-sidebar"&&t0(window.history.state)==="right-sidebar"&&(Au("right-sidebar-repo-picker"),na.current="right-sidebar-repo-picker"),At(!0)},[gt,l]),ul=b.useCallback(()=>{Vn("right-sidebar-repo-picker")},[Vn]),No=b.useCallback(()=>{!Ge&&!l&&typeof window<"u"&&zn.current&&t0(window.history.state)===zn.current&&(Au("markdown-outline"),na.current="markdown-outline"),pt(!0)},[Ge,l]),Js=b.useCallback(()=>{Vn("markdown-outline")},[Vn]),Ro=b.useCallback(()=>{!l&&typeof window<"u"&&zn.current&&t0(window.history.state)===zn.current&&(Au("markdown-image-lightbox"),na.current="markdown-image-lightbox"),_r(!0)},[l]),mo=b.useCallback(()=>{Vn("markdown-image-lightbox")},[Vn]),go=b.useCallback(()=>{!l&&typeof window<"u"&&zn.current&&t0(window.history.state)===zn.current&&(fF("settings"),na.current="settings"),sr.getState().closeAll(),Dt(!0)},[l]),mi=b.useCallback(()=>{Vn("settings")},[Vn]);b.useEffect(()=>{if(!Ee)return;const C=()=>go();return window.addEventListener("termdock:open-settings",C),()=>window.removeEventListener("termdock:open-settings",C)},[Ee,go]);const ps=b.useCallback(()=>{ot(!0),Je.current!==null&&(window.clearTimeout(Je.current),Je.current=null)},[]),Ei=b.useCallback(()=>{Je.current!==null&&(window.clearTimeout(Je.current),Je.current=null),ot(!1),Xs.current=!0,mh(),Xs.current},[]);b.useEffect(()=>()=>{Je.current!==null&&window.clearTimeout(Je.current)},[]),b.useEffect(()=>{l||mh()},[l]),b.useEffect(()=>{if(typeof window>"u"||l)return;let C=null;const j=()=>{C!==null&&(window.clearTimeout(C),C=null)},me=nn=>{if(zn.current,Xs.current,zn.current){zn.current;return}!nn?.force&&Xs.current||(nn?.userActivated&&(Xs.current=!0),mh(),Xs.current,void 0)},Ke=()=>{j(),C=window.setTimeout(()=>{C=null,me({force:!0})},vb)},St=()=>{me({userActivated:!0})},rr=()=>{Ke()},Ir=()=>{document.visibilityState==="visible"&&Ke()};return window.addEventListener("pointerdown",St,{capture:!0,passive:!0}),window.addEventListener("touchstart",St,{capture:!0,passive:!0}),window.addEventListener("keydown",St,{capture:!0}),window.addEventListener("pageshow",rr),document.addEventListener("visibilitychange",Ir),()=>{j(),window.removeEventListener("pointerdown",St,{capture:!0}),window.removeEventListener("touchstart",St,{capture:!0}),window.removeEventListener("keydown",St,{capture:!0}),window.removeEventListener("pageshow",rr),document.removeEventListener("visibilitychange",Ir)}},[l]),b.useEffect(()=>{zn.current=As},[As]),b.useEffect(()=>{if(typeof window>"u"||As||l)return;const C=window.setTimeout(()=>{zn.current?(zn.current,void 0):mh()},vb);return()=>window.clearTimeout(C)},[As,l]),b.useEffect(()=>{if(typeof window>"u"||l)return;const C=na.current;Ra.current,As&&As!==C&&!Ra.current&&Au(As),!As&&C&&uo(),na.current=As,!As&&Ra.current&&window.setTimeout(()=>{Ra.current=!1},0)},[As,l,uo]),b.useEffect(()=>{if(typeof window>"u"||l)return;const C=()=>{const j=zn.current;if(Xs.current,!j){Xs.current=!1,Xs.current,ps(),e6();return}Ra.current=!0,Es(j)};return window.addEventListener("popstate",C),()=>window.removeEventListener("popstate",C)},[Es,ps,l]),b.useEffect(()=>{const C=j=>{const me=j.metaKey||j.ctrlKey;if(me&&j.key==="b"&&!j.shiftKey&&(j.preventDefault(),Fi()),me&&j.shiftKey&&j.key==="E"&&(j.preventDefault(),pi()),me&&j.shiftKey&&j.key==="P"&&(j.preventDefault(),pa()),me&&!j.shiftKey&&j.altKey&&(j.key==="ArrowLeft"||j.key==="ArrowRight")){j.preventDefault();const Ke=j.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:Ke}}));return}if(me&&j.shiftKey&&!j.altKey&&(j.code==="BracketLeft"||j.code==="BracketRight")){j.preventDefault();const Ke=j.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:Ke}}));return}};return document.addEventListener("keydown",C),()=>{document.removeEventListener("keydown",C)}},[Fi,pi,pa]);const xo=b.useCallback(async()=>{ue(!0),tt(null);try{const C=await fa({localAccess:{name:X}});fe(C.localAccess),Qe(C.localAccess.name),On(yu,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){tt(C instanceof Error?C.message:"Failed to save local access name")}finally{ue(!1)}},[X]),dl=b.useCallback(async()=>{ue(!0),tt(null);try{const C=await fa({localAccess:{reset:!0}});fe(C.localAccess),Qe(C.localAccess.name),On(yu,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}catch(C){tt(C instanceof Error?C.message:"Failed to reset local access name")}finally{ue(!1)}},[]),Mo=b.useCallback(async(C,j="url")=>{if(C)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(C);else{const me=document.createElement("textarea");me.value=C,me.style.position="fixed",me.style.left="-9999px",document.body.appendChild(me),me.focus(),me.select(),document.execCommand("copy"),document.body.removeChild(me)}ce(j),window.setTimeout(()=>ce(me=>me===j?null:me),1600)}catch{ce(null)}},[]),js=b.useCallback(C=>{const j=mF(_t,C);j.map(me=>me.id).join("\0")!==_t.map(me=>me.id).join("\0")&&(Qr(j),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:j.map(me=>me.id)}})))},[_t]),ei=b.useCallback(C=>{Vt||C.type!=="session"||(jt.current=!1,it(!1),Ye(C.draggableId))},[Vt]),El=b.useCallback(C=>{if(Vt||C.type!=="session")return;const j=C.destination?.droppableId===t1;j!==jt.current&&(jt.current=j,it(j),j&&navigator.vibrate?.(20))},[Vt]),Xn=b.useCallback(C=>{const j=JO(C,!Vt);if(jt.current=!1,it(!1),Ye(null),!j)return!1;const me=_t.find(St=>St.id===C.draggableId),Ke=me?Te.get(me.id):null;return me&&Kx({mode:me.mode,activeProgram:Ke?.activeProgram??null,promptState:Ke?.promptState??null,shellNames:da})?(Me(null),G(me.id),lr(null)):me&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:me.id,source:"other",closeMode:me.mode==="tmux"?"destroy":"auto"}})),!0},[Vt,_t,Te]),{groups:gi,arranged:qn}=S.useMemo(()=>jh(_t,C=>Te.get(C.id)?.cwd??null,hn,e("sidebar.ungrouped"),at,Vr),[_t,Te,hn,e,at,Vr]),xa=b.useCallback(C=>{Xn(C)||!C.destination||C.source.index===C.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:qn[C.source.index]?.id,targetId:qn[C.destination.index]?.id}}))},[Xn,qn]),Ui=b.useCallback((C,j)=>{const me=j.trim();me&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:C,name:me}}))},[]),Do=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:C}}))},[]),{newSessionMode:Bs,newSessionTmuxName:Us,userSelectedNewSessionMode:zi,setNewSessionMode:dn}=Bj(),[Ni,xi]=b.useState(null),[ba,sa]=S.useState(!1),[ya,bi]=S.useState(!1),[va,Qs]=S.useState(!1),[Ri,Ba]=S.useState("idle"),zs=S.useRef(lc(ph,sF)).current,[Yn,Mi]=S.useState(()=>{const C=zs?.presets;if(C&&C.length>0){const j=o0(C);if(j.length>0)return j}return Zu()}),[jo,wa]=S.useState(!1),[Bo,Qo]=S.useState("default"),Qa=S.useRef(typeof zs?.updatedAt=="number"?zs.updatedAt:null),bo=S.useRef(!1),[Pa,oe]=S.useState(!1),[Ve,Tt]=S.useState(!1),Et=S.useRef(lc(ua,nF)).current,[qe,vt]=S.useState(Et??[]),[wr,Yr]=S.useState(Et!==null),[k,D]=S.useState(!1),F=!yr&&!As&&!ya&&!va&&!ba&&!Pa&&!Ve&&!$n&&!U&&!Ni,H=S.useCallback(C=>{const j=typeof C.version=="number"?C.version:0,me=iF(Array.isArray(C.presets)?C.presets:[],j);Qa.current=typeof C.updatedAt=="number"?C.updatedAt:null,Mi(Ke=>Kw(Ke,me)?Ke:(bo.current=!0,me)),On(ph,{version:_u,presets:me,updatedAt:Qa.current??void 0})},[]);b.useEffect(()=>{const C=j=>{if(j.key!=="Escape")return;if(ya){j.preventDefault(),bi(!1);return}if(va){j.preventDefault(),Qs(!1);return}if(ba){j.preventDefault(),sa(!1);return}if(Pa){j.preventDefault(),oe(!1);return}if(Ve){j.preventDefault(),Tt(!1);return}if($n){j.preventDefault(),jr();return}if(fn){j.preventDefault(),rn(null),Un(null);return}if(Ze){j.preventDefault(),mi();return}if(tn&&!(Wr&&Vt)){j.preventDefault(),Vn("right-sidebar");return}ur&&!(on&&Vt)&&(j.preventDefault(),Vn("left-sidebar"))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[ya,va,ba,Pa,$n,jr,Ze,tn,Wr,ur,on,Vt,mi,Vn]),b.useEffect(()=>{Yr(!0)},[]);const[He,Ie]=S.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:t6}),[,ft]=S.useState(!1),ut=S.useCallback(()=>Xw().then(C=>{Ie(C),da=new Set(C.shellNames),ft(!0)}).catch(()=>{}),[]);b.useEffect(()=>{ut()},[ut]),b.useEffect(()=>Cg(C=>{if(C.type==="config-updated"){if(C.key==="toolbar-presets"){_g().then(j=>H(j)).catch(j=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",j)});return}C.key==="program-detection"&&ut()}}),[H,ut]),b.useEffect(()=>{let C=!1;return(async()=>{try{const j=await _g();if(C)return;H(j)}catch(j){console.warn("[toolbar-presets] Failed to load from server:",j)}finally{C||wa(!0)}})(),()=>{C=!0}},[H]),b.useEffect(()=>{if(jo){if(bo.current){bo.current=!1;return}On(ph,{version:_u,presets:Yn,updatedAt:Qa.current??void 0}),Jw({version:_u,presets:Yn,baseUpdatedAt:Qa.current??void 0}).then(C=>{Qa.current=typeof C.updatedAt=="number"?C.updatedAt:null,On(ph,{version:_u,presets:Yn,updatedAt:Qa.current??void 0})}).catch(C=>{const j=C instanceof Error&&"current"in C?C.current:null;j&&typeof j=="object"&&H(j),console.warn("[toolbar-presets] Failed to save to server:",C)})}},[H,Yn,jo]),b.useEffect(()=>{ec().then(C=>{A(j=>j===C.preventSleep?j:C.preventSleep),L(j=>j===C.networkAvailable?j:C.networkAvailable),fe(C.localAccess),Qe(C.localAccess.name),Ot(C.runningSessionButtonEnabled),On(vu,C.runningSessionButtonEnabled),nr(C.attentionButtonEnabled),On(wu,C.attentionButtonEnabled),On(yu,{preventSleep:C.preventSleep,networkAvailable:C.networkAvailable,localAccess:C.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!I)return;const C=qf();ne(C),C!=="granted"&&(E(!1),jd(!1))},[I]),b.useEffect(()=>{if(!I)return;F0();const C=()=>{document.visibilityState==="visible"&&(F0(),f9())},j=window.setInterval(()=>{F0()},360*60*1e3);return document.addEventListener("visibilitychange",C),window.addEventListener("focus",C),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",C),window.removeEventListener("focus",C)}},[I]);const Yt=b.useCallback(async()=>{if(I){E(!1),jd(!1),e9(),ne(qf());return}const C=await t9();if(ne(C),C!=="granted"){E(!1),jd(!1);return}E(!0),jd(!0),await F0(!0,!0),Ba("idle")},[I]),Ar=b.useCallback(async()=>{Ba("checking"),await ao()?.prepareNotificationTest?.();const C=await r9({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Ba(C?"delivered":"failed")},[e]),ln=b.useCallback(C=>{P(C),n9(C),Yf()},[]),Qn=b.useCallback(C=>{$(C),s9(C),Yf()},[]),In=b.useCallback(C=>{B(C),i9(C),Yf()},[]);b.useEffect(()=>{Yn.some(C=>C.id===Bo)||Qo(Yn[0]?.id??"default")},[Bo,Yn]),b.useEffect(()=>{if(!Nr.available&&Bs==="tmux"){dn("shell",{userInitiated:!1});return}Nr.available&&zi!=="shell"&&Bs!=="tmux"&&dn("tmux",{userInitiated:!1})},[Bs,Nr.available,zi,dn]),b.useEffect(()=>{xi(null)},[Ze,Bs,Nr.available]),b.useEffect(()=>{const C={};typeof navigator<"u"&&(C.userAgent=navigator.userAgent,C.platform=navigator.platform,C.maxTouchPoints=navigator.maxTouchPoints,C.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,C.vendor=navigator.vendor),typeof window<"u"&&(C.screenWidth=window.innerWidth,C.screenHeight=window.innerHeight,C.pixelRatio=window.devicePixelRatio,C.orientation=window.screen?.orientation?.type||"unknown",C.hasVisualViewport=!!window.visualViewport,C.visualViewportHeight=window.visualViewport?.height,C.visualViewportWidth=window.visualViewport?.width,C.location=window.location.href),C.timestamp=new Date().toISOString(),C.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,C.isAndroid=/Android/.test(navigator.userAgent),Mt(C)},[]);const is=b.useCallback(C=>{if(Xn(C)||!C.destination)return;if(C.type==="group"){if(C.source.index===C.destination.index)return;js(Ob(gi,C.source.index,C.destination.index));return}if(C.source.droppableId!==C.destination.droppableId||C.source.index===C.destination.index)return;const j=C.source.droppableId.replace(/^group-sessions:/,""),me=gi.find(Ke=>Ke.key===j);me&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:me.sessions[C.source.index]?.id,targetId:me.sessions[C.destination.index]?.id}}))},[gi,js,Xn]),Br=S.useMemo(()=>qn.flatMap(C=>{const j=Te.get(C.id);if(j?.agentStatus!=="working")return[];const{primary:me,secondary:Ke}=Xo(C,j?.activeProgram??null,j?.cwd??null,da,j?.shellTitle??null,j?.promptState??null);return[{id:C.id,label:me,detail:Ke}]}),[qn,Te]),xn=Nt?qn.findIndex(C=>C.id===Nt):-1,ls=qn.length>0&&xn>=0?`${xn+1}/${qn.length}`:`${qn.length}`,as=S.useMemo(()=>{let C=0;for(const j of _t){const me=Te.get(j.id);(me?.agentStatus==="waiting"||me?.agentNeedsReview)&&(C+=1)}return{running:Br.length,review:C}},[Br.length,_t,Te]),E0=S.useMemo(()=>qn.flatMap(C=>{const j=Te.get(C.id);if(j?.agentStatus!=="waiting"&&!j?.agentNeedsReview)return[];const{primary:me}=Xo(C,j.activeProgram,j.cwd,da,j.shellTitle,j.promptState);return[{id:j.terminalSessionId??C.id,label:me,waiting:j.agentStatus==="waiting"}]}),[qn,Te]);a9(as.running,as.review,E0);const Jn=Nt?_t.find(C=>C.id===Nt)??null:null,Oa=Jn?Te.get(Jn.id):void 0,yo=!!(Jn&&Oa?.agentResumeRecovered&&Oa.agentNativeSessionId&&Oa.terminalSessionId),Hs=Jn&&gr?.sessionId===Jn.id?gr:null;S.useLayoutEffect(()=>{if(!Re)return;const C=tr.current;if(!C)return;const j=!fr.current;C.scrollIntoView({inline:"nearest",block:"nearest",behavior:j?"auto":"smooth"}),fr.current=!0,j&&l0("active-tab-positioned")},[Nt,Re]),b.useEffect(()=>{Ln&&Qt.current&&(Qt.current.scrollIntoView({block:"nearest",inline:"nearest"}),Qt.current.focus(),Qt.current.select()),Ln||(It.current=!1)},[Ln]);const tc=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:C}))},[]),Nl=b.useCallback((C,j)=>{fs(j??null),ns(C)},[]),rc=Av(),Fa=b.useCallback(C=>{if(!C)return;Ae(C),or.current&&ha("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:or.current,requestedSessionId:C,activeSessionId:Nt,sessions:_t.map(me=>({id:me.id,terminalSessionId:Te.get(me.id)?.terminalSessionId??null}))}),o9(C);const j=_t.find(me=>me.id===C||Te.get(me.id)?.terminalSessionId===C);j?(Ct.current=null,or.current&&ha("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:or.current,requestedSessionId:C,targetSessionId:j.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j.id}))):(Ct.current=C,or.current&&ha("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:or.current,requestedSessionId:C}))},[Nt,_t,Te]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let C=!1;const j=async()=>{if(window.parent!==window&&rl()){mt(!0);return}try{const Ke=await caches.open(cF),St=await Ke.match(wb);if(!St)return;await Ke.delete(wb);const rr=await St.json();if(C)return;const Ir=typeof rr.sessionId=="string"?rr.sessionId:null,nn=typeof rr.traceId=="string"?rr.traceId:null,An=typeof rr.clickedAt=="number"?rr.clickedAt:0,Dn=Date.now()-An;ha("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:nn,sessionId:Ir,ageMs:Dn,valid:!!(Ir&&Dn>=0&&Dn<=Ab),visibilityState:document.visibilityState}),Ir&&Dn>=0&&Dn<=Ab&&(or.current=nn,typeof rr.targetPeerId=="string"&&rr.targetPeerId!==$0()?.targetPeerId?rl()?.focusSession(rr.targetPeerId,Ir):Fa(Ir))}catch(Ke){ha("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:Ke instanceof Error?Ke.message:String(Ke)})}finally{C||mt(!0)}},me=()=>{document.visibilityState==="visible"&&j()};return j(),document.addEventListener("visibilitychange",me),window.addEventListener("pageshow",j),()=>{C=!0,document.removeEventListener("visibilitychange",me),window.removeEventListener("pageshow",j)}},[Fa]),b.useEffect(()=>{if(typeof window>"u")return;const C=new URLSearchParams(window.location.search),j=C.get("session");if(!j)return;ha("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:or.current,targetSessionId:j,href:window.location.href,visibilityState:document.visibilityState});const me=C.get("service");me&&me!==$0()?.targetPeerId?rl()?.focusSession(me,j):Ct.current=j,C.delete("service"),C.delete("session"),C.delete("_notifTrace");const Ke=C.toString(),St=`${window.location.pathname}${Ke?`?${Ke}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",St)},[]),b.useEffect(()=>{if(typeof window>"u")return;const C=new URLSearchParams(window.location.search);if(C.get("_notif")!=="1")return;const j=C.get("session");C.delete("_notif");const me=C.toString(),Ke=`${window.location.pathname}${me?`?${me}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",Ke),window.parent!==window&&rl())return;const St=new BroadcastChannel("termdock:notif");let rr=!1;const Ir=An=>{An.data?.type==="termdock:notif-pong"&&!rr&&(rr=!0,St.close(),window.close())};St.addEventListener("message",Ir),St.postMessage({type:"termdock:notif-ping",sessionId:j,targetPeerId:C.get("service")});const nn=setTimeout(()=>{rr||St.close()},500);return()=>{clearTimeout(nn),rr||St.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&rl())return;const C=new BroadcastChannel("termdock:notif"),j=me=>{me.data?.type==="termdock:notif-ping"&&(C.postMessage({type:"termdock:notif-pong"}),typeof me.data.sessionId=="string"&&(typeof me.data.targetPeerId=="string"&&me.data.targetPeerId!==$0()?.targetPeerId?rl()?.focusSession(me.data.targetPeerId,me.data.sessionId):Fa(me.data.sessionId)))};return C.addEventListener("message",j),()=>C.close()},[Fa]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const C=j=>{const me=j.data;if(me&&me.type==="termdock:focus-session"&&typeof me.sessionId=="string"){if(typeof me.targetPeerId=="string"&&me.targetPeerId!==$0()?.targetPeerId){rl()?.focusSession(me.targetPeerId,me.sessionId)&&j.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}j.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),Fa(me.sessionId)}else me?.type==="termdock:push-subscription-changed"?F0(!0):me?.type};return navigator.serviceWorker.addEventListener("message",C),()=>navigator.serviceWorker.removeEventListener("message",C)},[Fa]),b.useEffect(()=>{const C=j=>{const me=j.detail;typeof me=="string"&&Fa(me)};return window.addEventListener("termdock:focus-session",C),()=>window.removeEventListener("termdock:focus-session",C)},[Fa]),b.useEffect(()=>{const C=()=>{const j=p9($0()?.targetPeerId);j&&Fa(j)};return C(),window.addEventListener("termdock:workspace-session",C),()=>window.removeEventListener("termdock:workspace-session",C)},[Fa]),b.useEffect(()=>{const C=Ct.current;if(!C)return;const j=_t.find(me=>me.id===C||Te.get(me.id)?.terminalSessionId===C);j?(Ct.current=null,or.current&&ha("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:or.current,requestedSessionId:C,targetSessionId:j.id,activeSessionId:Nt}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j.id}))):or.current&&ha("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:or.current,requestedSessionId:C,activeSessionId:Nt,sessions:_t.map(me=>({id:me.id,terminalSessionId:Te.get(me.id)?.terminalSessionId??null}))})},[Nt,_t,Te]);const cs=S.useMemo(()=>{const C=[];for(const j of _t){const me=Te.get(j.id);(me?.agentStatus==="waiting"||me?.agentNeedsReview)&&C.push(j.id)}return C},[_t,Te]),Po=b.useCallback(()=>{if(cs.length===0)return;Nt&&Jr.getState().clearAgentNeedsReview(Nt);const C=Nt?_t.findIndex(me=>me.id===Nt):-1,j=cs.find(me=>_t.findIndex(Ke=>Ke.id===me)>C)??cs[0];j&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j}))},[cs,_t,Nt]),Bc=b.useCallback(()=>{if(cs.length===0)return;Nt&&Jr.getState().clearAgentNeedsReview(Nt);const C=Nt?_t.findIndex(me=>me.id===Nt):_t.length,j=[...cs].reverse().find(me=>_t.findIndex(Ke=>Ke.id===me)<C)??cs[cs.length-1];j&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j}))},[cs,_t,Nt]);b.useEffect(()=>{const C=j=>{!j.altKey||!j.shiftKey||j.metaKey||j.ctrlKey||j.key!=="ArrowUp"&&j.key!=="ArrowDown"||(j.preventDefault(),j.key==="ArrowUp"?Bc():Po())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Po,Bc]);const md=b.useCallback(async C=>{const me=Jr.getState().sessions.get(C)?.cwd;if(me)try{await navigator.clipboard?.writeText(me),z(me),window.setTimeout(()=>{z(Ke=>Ke===me?null:Ke)},1400)}catch{}},[]),Ef=b.useCallback(C=>{Qr(C.sessions),Nn(C.activeSessionId),en(C.splitWorkspaces),Jr.getState().setActiveSessionId(C.activeSessionId)},[]),Nf=b.useCallback(()=>{lt(!0)},[]),Rf=b.useCallback(()=>{lt(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!O||!Nt)return;_t.find(j=>j.id===O||Te.get(j.id)?.terminalSessionId===O)?.id===Nt&&Ae(null)},[Nt,O,_t,Te]);const vo=b.useCallback(C=>{const j=C?.mode??Bs,me=j==="tmux"&&(C?.tmuxSessionName?.trim()||Us.trim())||void 0,Ke=C?.cwd||(Nt?Jr.getState().sessions.get(Nt)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:j,tmuxSessionName:me,cwd:Ke,command:C?.command}}))},[Bs,Us,Nt]),hl=b.useCallback(async()=>{V(!0);try{const C=await om();if(zr(C),!C.available){Bn([]);return}const j=await lm();Bn(j)}catch{zr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Bn([])}finally{V(!1)}},[]),Mf=b.useCallback(async C=>{zt(C),lr(null);try{const{cleanedSessions:j}=await kb(C);for(const me of j)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:me}));kt(null),await hl()}catch(j){lr(j instanceof Error?j.message:"Failed to kill tmux session")}finally{zt(null)}},[hl]);b.useEffect(()=>{if(!yn)return;if(un.find(me=>me.name===yn&&(me.connected||me.boundFrontendSessionId))){ar(null);return}const j=setTimeout(()=>ar(null),1e4);return()=>clearTimeout(j)},[yn,un]);const nc=b.useCallback(C=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:C}))},[]),gd=b.useCallback(C=>{const j=C??Nt;j&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:j}))},[Nt]),xd=b.useCallback((C,j)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:C,layout:j}}))},[]),Qc=b.useCallback((C,j)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:C,sessionIds:j}}))},[]),N0=b.useCallback((C,j)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:C,name:j}}))},[]),R0=b.useCallback((C,j)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:C,secondaryId:j}}))},[]),Oo=b.useCallback((C,j,me)=>{const Ke=_t.find(rr=>rr.id===C);if(!Ke)return;const St=Te.get(C);if(me?.skipConfirmation||!Kx({mode:Ke.mode,activeProgram:St?.activeProgram??null,promptState:St?.promptState??null,shellNames:da})){nc({sessionId:C,source:"sidebar",closeMode:Ke.mode==="tmux"?"destroy":"auto"});return}Me(j?{x:j.clientX,y:j.clientY}:null),G(C),lr(null)},[_t,Te,nc]);b.useEffect(()=>{if(!Ee)return;const C=j=>{const me=j.detail;me==="new-session"?vo():me==="close-session"?Nt&&Oo(Nt):me==="previous-session"||me==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:me==="next-session"?"next":"prev"}})):me==="toggle-left-sidebar"?Fi():me==="toggle-right-sidebar"?pi():me==="previous-attention"?Bc():me==="next-attention"&&Po()};return window.addEventListener("termdock:native-command",C),()=>window.removeEventListener("termdock:native-command",C)},[Nt,Ee,vo,Oo,Fi,pi,Po,Bc]);const $a=S.useMemo(()=>_t.find(C=>C.id===U)??null,[_t,U]),sc=b.useCallback(()=>{$a&&(nc({sessionId:$a.id,source:"sidebar",closeMode:"destroy"}),G(null),Me(null))},[$a,nc]);b.useEffect(()=>{if(!$a)return;const C=j=>{if(j.key==="Escape"){j.preventDefault(),j.stopImmediatePropagation(),G(null),Me(null),lr(null);return}j.key!=="Enter"||j.isComposing||j.keyCode===229||j.altKey||j.ctrlKey||j.metaKey||j.shiftKey||(j.preventDefault(),j.stopImmediatePropagation(),j.repeat||sc())};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[$a,sc]);const bd=S.useMemo(()=>{if(!$a)return"";const C=Te.get($a.id);return Xo($a,C?.activeProgram??null,C?.cwd??null,da,C?.shellTitle??null,C?.promptState??null).primary},[$a,Te]);b.useEffect(()=>{if(!Ze)return;let C=!1,j=!1;const me=async()=>{if(!j)try{const St=await om();if(C||zr(St),!St.available){C||Bn([]);return}const rr=await lm();C||Bn(rr)}catch{j=!0,C||(zr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Bn([]))}};me();const Ke=setInterval(()=>{me()},4e3);return()=>{C=!0,clearInterval(Ke)}},[Ze]);const yd=Ni??Bs,M0=yd==="shell",D0=yd==="tmux"&&Nr.available,vd=S.useMemo(()=>l9(un.map(C=>({...C,id:C.name})),C=>C.cwd??null,e("sidebar.ungrouped")),[un,e]),wd=S.useMemo(()=>un.filter(C=>C.recoveryCandidate===!0&&!C.connected&&!C.boundFrontendSessionId).sort((C,j)=>(j.lastActiveAt??j.createdAt??0)-(C.lastActiveAt??C.createdAt??0)),[un]);b.useEffect(()=>{!ur&&!(on&&Vt)||hl()},[ur,on,Vt,_t.length,hl]);const j0=(C,j,me,Ke=!1)=>{const St=C.id===Nt,rr=C.id===Ln,Ir=Te.get(C.id),{primary:nn,secondary:An}=Xo(C,Ir?.activeProgram??null,Ir?.cwd??null,da,Ir?.shellTitle??null,Ir?.promptState??null),Dn=$u(Ir?.cwd??null),xs=j?An??(Dn&&Dn!==nn?Dn:null):null,mn=Ir?.gitStatus,Di=`${Ir?.cwd||C.name}${mn?`
177
+ ⎇ ${mn.branch} +${mn.added} −${mn.removed}`:""}`,Ua=!!(Ir?.tuiProgress&&Ir.tuiProgress.state!=="remove"),za=Ir?.agentStatus==="working"||Ua?"var(--success)":Ir?.agentStatus==="waiting"||Ir?.agentNeedsReview?"var(--warning)":Ir?.inCopyMode?"var(--tmux)":null;if(rr&&Vt&&!fn){const ia=C.customName?C.name:nn,vi=(Ta,Df)=>{const Q0=Df.trim();Q0?Q0!==ia&&Ui(Ta,Q0):Do(Ta),rn(null)};return s.jsx("input",{ref:Ta=>{Qt.current=Ta},type:"text",defaultValue:ia,className:"h-8 shrink-0 rounded-md bg-surface-elevated px-2 text-[12px] leading-none text-foreground outline-none ring-1 ring-primary/50 sm:h-8 min-w-[5rem]",style:{width:`${Math.max(ia.length,5)}ch`},onKeyDown:Ta=>{Ta.key==="Enter"?vi(C.id,Ta.target.value):Ta.key==="Escape"&&rn(null)},onBlur:Ta=>vi(C.id,Ta.target.value)})}return s.jsx("div",{ref:St?tr:null,onContextMenu:ia=>{ia.preventDefault(),fs({x:ia.clientX,y:ia.clientY}),ns(C.id)},...rc(()=>Nl(C.id)),className:Ke?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${St?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/40 hover:text-foreground"}`:`group relative inline-flex h-8 shrink-0 items-center rounded-md text-[12px] leading-none transition sm:h-8 ${St?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!Ke&&St&&za?{boxShadow:`inset 2px 0 0 0 ${za}`}:!Ke&&St?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:Di,children:s.jsx("button",{type:"button",...me??{},onClick:()=>tc(C.id),className:`inline-flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left ${Ke?"px-1":"py-1 pl-1 pr-1.5 sm:pl-1.5 sm:pr-2"} ${me?"cursor-grab active:cursor-grabbing":""}`,title:Di,children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 overflow-hidden",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center",children:[Sb(C.mode,Ir),Ir?.agentResumeRecovered&&s.jsx(wc,{size:Ke?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),Ua&&!Ir?.agentStatus&&s.jsx(En,{size:Ke?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),xs?s.jsxs("span",{className:"flex min-w-0 flex-col justify-center leading-[0.82rem] sm:leading-[0.85rem]",children:[s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Ir?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:nn}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:xs})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${Ir?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:nn})]})})})},B0=()=>s.jsx(Tl,{droppableId:t1,type:"session",isDropDisabled:Vt,children:(C,j)=>{const me=ct||j.isDraggingOver;return s.jsxs("div",{ref:C.innerRef,...C.droppableProps,className:"pointer-events-none fixed left-1/2 top-[42%] z-toast flex h-32 w-32 -translate-x-1/2 -translate-y-1/2 items-center justify-center",role:"status","aria-live":"polite","aria-hidden":!ge,"data-mobile-session-destroy-target":"","data-active":me?"true":"false",children:[s.jsxs("div",{className:`flex h-28 w-28 flex-col items-center justify-center gap-2 rounded-full border bg-surface-elevated/95 shadow-2xl backdrop-blur transition duration-200 ${ge?me?"scale-110 border-destructive bg-destructive text-destructive-foreground opacity-100":"scale-100 border-destructive/50 text-destructive opacity-100":"scale-75 border-transparent opacity-0"}`,children:[s.jsx(Zs,{size:28,strokeWidth:1.8}),s.jsx("span",{className:"px-2 text-center text-[11px] font-semibold leading-tight",children:e(me?"tab.releaseToClose":"tab.dragToClose")})]}),C.placeholder]})}}),yi=on&&Vt,Fo=Wr&&Vt,Pc=xh($r,Sn,yi?Xr:0),Aa=Fo?Pc+Lb:0,fl=yi?_t.find(C=>C.id===Nt):null,Ts=fl?Te.get(fl.id):void 0,Ad=fl?Xo(fl,Ts?.activeProgram??null,Ts?.cwd??null,da,Ts?.shellTitle??null,Ts?.promptState??null).primary:"",Td=Vt?Jt:null,Sd=yi&&!Td&&Ts?Ts.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Ts.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Ts.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Ts.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",Cd=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[s.jsx("main",{className:"relative min-h-0 flex-1 overflow-visible px-0 pb-0 pt-0",children:s.jsxs(ZT,{rightInset:Aa,workspace:yr&&s.jsx(S.Suspense,{fallback:s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--chrome-bg)] text-sm text-muted-foreground",children:"正在打开协作工作区…"}),children:s.jsx(gF,{groupId:yr,activeSessionId:Nt,defaultSessionMode:Bs,onOpenSidebar:Fi,leftSidebarVisible:ur||yi,onToggleRightSidebar:pi,rightSidebarOpen:tn||Fo},yr)}),children:[s.jsxs("div",{className:`${Vt?"absolute inset-x-0 top-0 z-20":"relative"} shrink-0 items-center gap-1 app-chrome-bg px-1 sm:px-1.5 transition-colors duration-500 ${yi?"flex justify-end":"flex justify-between"} ${hn?"h-10 sm:h-10":"h-9 sm:h-10"} ${Sd}`,style:{position:Vt?"absolute":void 0,marginRight:Aa||void 0,display:Td?"none":void 0},children:[!yi&&s.jsxs("button",{type:"button",onClick:Fi,className:"relative inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.sessionsTitle"),title:`${e("tab.sessionsTitle")} · ${e("agent.aiRunning")}: ${as.running} · ${e("agent.needsReview")}: ${as.review}`,children:[s.jsx(VA,{size:14}),s.jsx(LQ,{runningCount:as.running,reviewCount:as.review,className:"sm:hidden"})]}),yi?s.jsx("div",{className:"absolute left-1/2 flex max-w-[40%] min-w-0 -translate-x-1/2 items-center justify-center gap-1.5 overflow-hidden",children:fl?s.jsxs(s.Fragment,{children:[Sb(fl.mode,Ts),s.jsx("span",{className:`truncate text-[12px] font-medium ${Ts?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:Ad}),Ts?.agentStatus==="working"&&s.jsx("span",{title:Ts?.agentMessage??void 0,children:s.jsx(En,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Ts?.agentStatus==="waiting"&&s.jsx("span",{title:Ts?.agentMessage??void 0,children:s.jsx(Ph,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Ts?.agentStatus&&Ts?.agentNeedsReview&&s.jsx("span",{title:Ts?.agentMessage??void 0,children:s.jsx(Zl,{size:13,className:"shrink-0 animate-pulse text-[color:var(--warning)]"})})]}):s.jsx("span",{className:"truncate px-2 text-[12px] text-muted-foreground",children:e("sidebar.sessions")})}):hn?s.jsxs(Pu,{onDragStart:ei,onDragUpdate:El,onDragEnd:is,children:[B0(),s.jsx(Tl,{droppableId:"groups",type:"group",direction:"horizontal",children:C=>s.jsxs("div",{ref:C.innerRef,...C.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap px-0.5 py-0.5",style:{touchAction:"pan-x"},children:[gi.map((j,me)=>{let Ke=0,St=0;for(const An of j.sessions){const Dn=Te.get(An.id);Dn?.agentStatus==="working"&&(Ke+=1),(Dn?.agentStatus==="waiting"||Dn?.agentNeedsReview)&&(St+=1)}const rr=j.sessions.some(An=>An.id===Nt),Ir=ys.has(j.key),nn=j.key==="";return s.jsx(Al,{draggableId:`group-${j.key||"__ungrouped__"}`,index:me,isDragDisabled:nn,disableInteractiveElementBlocking:!0,children:(An,Dn)=>s.jsxs("div",{ref:An.innerRef,...An.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${Dn.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":rr?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...nn?{}:An.dragHandleProps,onClick:()=>cn(j.key),className:`flex ${Ir?"":j.sessions.length>1?"w-0 min-w-full":""} items-center gap-0.5 rounded text-[9px] font-semibold uppercase tracking-[0.08em] leading-none transition hover:bg-surface-elevated/40 ${nn?"":"cursor-grab active:cursor-grabbing"} ${rr?"text-primary/80":"text-muted-foreground/55"}`,title:j.key||j.label,children:[s.jsx(lo,{size:9,className:`shrink-0 opacity-70 transition-transform ${Ir?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 truncate",children:j.label}),Ke>0&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)]"}),St>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${Ke>0?"":"ml-auto"}`})]}),Ir?s.jsx("span",{className:"flex h-5 items-center text-[10px] leading-none text-muted-foreground/50",children:e("tab.sessionCount",{count:j.sessions.length})}):s.jsx(Tl,{droppableId:`group-sessions:${j.key}`,type:"session",direction:"horizontal",children:xs=>s.jsxs("div",{ref:xs.innerRef,...xs.droppableProps,className:"flex items-center gap-px",children:[j.sessions.map((mn,Di)=>s.jsx(Al,{draggableId:mn.id,index:Di,disableInteractiveElementBlocking:!0,children:(Ua,za)=>s.jsx("div",{ref:Ua.innerRef,...Ua.draggableProps,className:`flex shrink-0 items-center ${za.isDragging?"opacity-70":""}`,children:j0(mn,!1,Ua.dragHandleProps,!0)})},mn.id)),xs.placeholder]})})]})},j.key||"__ungrouped__")}),C.placeholder,s.jsx("button",{type:"button",onClick:()=>vo(),className:"my-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Ys,{size:14})})]})})]}):s.jsxs(Pu,{onDragStart:ei,onDragUpdate:El,onDragEnd:xa,children:[B0(),s.jsx(Tl,{droppableId:"tabs",type:"session",direction:"horizontal",children:C=>s.jsxs("div",{ref:C.innerRef,...C.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap",style:{touchAction:"pan-x"},children:[qn.map((j,me)=>j.id===Ln?s.jsx(S.Fragment,{children:s.jsx(Al,{draggableId:j.id,index:me,isDragDisabled:!0,children:St=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:"flex h-full items-center",children:j0(j,!0)})})},j.id):s.jsx(S.Fragment,{children:s.jsx(Al,{draggableId:j.id,index:me,disableInteractiveElementBlocking:!0,children:(St,rr)=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:`flex h-full shrink-0 items-center ${rr.isDragging?"opacity-70":""}`,children:j0(j,!0,St.dragHandleProps)})})},j.id)),s.jsx("button",{type:"button",onClick:()=>vo(),className:"ml-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Ys,{size:14})}),C.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!yi&&as.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(Ov,{count:as.running,tone:"running",title:e("agent.aiRunning")})}),!yi&&_t.length>0&&s.jsx("span",{className:"inline-flex shrink-0 items-center px-1 text-[10px] uppercase tracking-[0.16em] text-muted-foreground sm:text-[11px]",title:`Session ${xn+1} of ${_t.length}`,children:ls}),!Fo&&s.jsx("button",{type:"button",onClick:pi,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.explorerTitle"),title:e("tab.explorerTitle"),children:s.jsx(qb,{size:14})})]})]}),yo&&Jn&&Oa?.terminalSessionId&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 bg-surface/80 px-3 py-2 animate-fade-in sm:px-4",style:{marginRight:Aa||void 0},role:"status","data-testid":"agent-resume-recovery-banner",children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] text-[color:var(--warning)]",children:!Hs?.error&&(Hs?.status==="submitting"||Hs?.status==="waiting")?s.jsx(En,{size:14,className:"animate-spin"}):s.jsx(wc,{size:14})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:e("tab.resumeAgentRecoveredTitle",{agent:Oa.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${Hs?.error?"text-destructive":"text-muted-foreground"}`,children:Hs?.error??(Hs?.status==="submitting"?e("tab.resumeAgentSubmitting"):Hs?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!Hs?.error&&(Hs?.status==="submitting"||Hs?.status==="waiting"),onClick:()=>{Y(Jn.id,Oa.terminalSessionId)},className:"shrink-0 rounded-full bg-primary px-3 py-1.5 text-[11px] font-semibold text-primary-foreground transition hover:opacity-90 active:scale-95 disabled:cursor-wait disabled:opacity-60 sm:text-[12px]",children:Hs?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Jr.getState().setAgentResumeRecovered(Jn.id,!1),Pr(C=>C?.sessionId===Jn.id?null:C)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("tab.resumeAgentLater"),title:e("tab.resumeAgentLater"),children:s.jsx(Wn,{size:13})})]}),s.jsx("div",{ref:rt,className:"min-h-0 flex-1 flex overflow-hidden app-chrome-bg",children:s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(fE,{terminalSettings:ir,colorTheme:p,toolbarPresets:Yn,showDebug:c&&Vt,terminalFocusAvailable:F,defaultSessionMode:Bs,defaultTmuxSessionName:Us,connectionPrioritySessionId:O,connectionPriorityReady:Re,desktopRightSidebarEnabled:Vt,onToggleRightSidebar:pi,desktopFloatingTitle:Vt,desktopPinnedLeftSidebarWidth:yi?Xr:0,desktopViewportWidth:Sn,onSessionDataUpdate:Ef,onInitialViewportReady:Rf,onInitialRecoveryRequired:Nf})})})]})}),!yr&&s.jsx(RQ,{reviewCount:as.review,runningSessions:Br,activeSessionId:Nt,runningButtonEnabled:bt,attentionButtonEnabled:dt,isDesktopLayout:Vt,containerElement:vr,occlusionInsets:{right:Aa}}),Ze&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-drawer-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm animate-fade-in cursor-default",onClick:mi,"aria-label":e("settings.closeSettings")}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-dialog-title",className:"pointer-events-none fixed inset-0 z-drawer-panel flex items-stretch justify-center p-0 animate-fade-in sm:p-4 md:p-6",children:s.jsxs("div",{className:"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden bg-surface shadow-[0_28px_90px_var(--app-shadow-strong),0_14px_34px_var(--app-shadow-soft)] sm:max-h-[calc(100dvh-3rem)] sm:rounded-3xl sm:border sm:border-border/15",style:{paddingTop:n,paddingBottom:a},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/15 px-4 py-3 sm:px-6 sm:py-4",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary/15 text-primary sm:h-9 sm:w-9",children:s.jsx(hm,{size:15})}),s.jsx("h2",{id:"settings-dialog-title",className:"text-[15px] font-semibold text-foreground sm:text-[16px]",children:e("settings.title")})]}),s.jsx("button",{type:"button",onClick:mi,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive","aria-label":e("common.close"),children:s.jsx(Wn,{size:16})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background/25 px-3 py-3 sm:px-6 sm:py-5 md:px-8",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>Ut({fontSize:Math.max(8,We-1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"−"}),s.jsx("input",{type:"range",min:"8",max:"32",value:We,onChange:C=>Ut({fontSize:parseInt(C.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>Ut({fontSize:Math.min(32,We+1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"+"}),s.jsxs("span",{className:"w-8 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:[We,"px"]})]}),s.jsx(XO,{}),s.jsx("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.render")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["auto","webgl","canvas"].map(C=>{const j=br===C;return s.jsx("button",{type:"button",onClick:()=>Ut({rendererMode:C}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${j?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:e(C==="auto"?"settings.auto":C==="webgl"?"settings.webgl":"settings.canvas")},C)})})]})}),s.jsx("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.theme")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[["dark",$A,e("settings.darkTheme")],["light",ET,e("settings.lightTheme")]].map(([C,j,me])=>{const Ke=p===C;return s.jsxs("button",{type:"button",onClick:()=>g(C),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition ${Ke?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:[s.jsx(j,{size:12}),s.jsx("span",{children:me})]},C)})})]})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.newTab")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["shell","tmux"].map(C=>{const j=Bs===C,me=C==="tmux"&&!Nr.available;return s.jsx("button",{type:"button",disabled:me,onClick:()=>dn(C,{userInitiated:!0}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${j?"bg-primary/20 text-primary":me?"cursor-not-allowed text-muted-foreground/40":"text-muted-foreground hover:bg-surface-elevated"}`,title:me?Nr.reason||e("settings.installTmuxHint"):void 0,children:e(C==="shell"?"settings.shell":"settings.tmux")},C)})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>h(!c),className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${c?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,children:[s.jsx("span",{className:"font-medium",children:e("settings.debug")}),s.jsx(nl,{checked:c,size:"sm"})]}),s.jsxs("button",{type:"button",onClick:async()=>{const C=!y;A(C);try{const j=await fa({preventSleep:C});A(j.preventSleep),L(j.networkAvailable),fe(j.localAccess),On(yu,{preventSleep:j.preventSleep,networkAvailable:j.networkAvailable,localAccess:j.localAccess})}catch{A(!C)}},className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${y?"bg-[rgb(var(--success-rgb)_/_0.15)] text-[color:var(--success)]":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:!v&&y?e("settings.noSleepUnavailable"):void 0,children:[s.jsx("span",{className:"font-medium truncate",children:e("settings.noSleep")}),s.jsx(nl,{checked:y,size:"sm"})]})]})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":bt,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{qt(!bt)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(Oh,{size:14,className:bt?"shrink-0 text-[color:var(--success)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.runningSessionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.runningSessionButtonHint")})]}),s.jsx(nl,{checked:bt,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":dt,"aria-label":e("sidebar.attentionButton"),onClick:()=>{Lr(!dt)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(Zl,{size:14,className:dt?"shrink-0 text-[color:var(--warning)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.attentionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.attentionButtonHint")})]}),s.jsx(nl,{checked:dt,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>Qs(!0),className:"mt-3 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Ub,{size:14,className:I?"shrink-0 text-primary":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("settings.notifications")}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e(I?R&&Q?"settings.notificationsBothOnSummary":R?"settings.notificationsAiOnSummary":Q?"settings.notificationsExitOnSummary":"settings.notificationsNoEventsSummary":"settings.notificationsOffSummary")})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e(I?"common.on":"common.off")}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>bi(!0),className:"mt-3 flex w-full items-center justify-between gap-3 rounded-xl bg-surface-2 px-3 py-3 text-left transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block text-[12px] font-medium text-foreground/90",children:e("settings.localAccess")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.localAccessHint")})]}),s.jsx(lo,{size:16,className:"shrink-0 text-muted-foreground"})]}),s.jsx(WO,{state:$e,pending:se,onCheck:()=>{Gt()},onConfirmRestart:()=>{xt()},desktopState:_e?wt:void 0,desktopPending:ee,onCheckDesktop:_e?()=>{Gr()}:void 0,onInstallDesktop:()=>{Fr()},desktopSnapshot:re,desktopActions:Ee?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-px border-t border-border/10 bg-border/10 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Ee.showConnectionCenter()},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(z9,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{te(null),Ee.revealDataDirectory().catch(C=>te(C instanceof Error?C.message:String(C)))},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(c0,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),Le&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:Le})]}):void 0}),s.jsx(VO,{backendSessionId:Nt?Te.get(Nt)?.terminalSessionId??null:null}),s.jsx(YO,{state:de,onDismiss:()=>{st()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{xi(null),vo({mode:"shell"}),mi()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${M0?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:e(Ni==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(Ys,{size:14,className:M0?"shrink-0":"hidden"}),s.jsx(Eo,{size:12}),s.jsx("span",{className:M0?"whitespace-nowrap":"hidden",children:e(Ni==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Nr.available,onClick:()=>{Nr.available&&(xi(null),vo({mode:"tmux"}),mi())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Nr.available?D0?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"flex-1 bg-surface-2/50 text-muted-foreground/50 cursor-not-allowed"}`,title:Nr.available?e(Ni==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Nr.reason||e("settings.installTmuxHint"),children:[s.jsx(Ys,{size:14,className:D0?"shrink-0":"hidden"}),s.jsx(x0,{size:12}),s.jsx("span",{className:D0?"whitespace-nowrap":"hidden",children:e(Ni==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Nr.available||un.length>0)&&s.jsxs("details",{className:"mt-3 group rounded-xl bg-surface-2 [&[open]]:bg-surface-2",children:[s.jsxs("summary",{className:"flex cursor-pointer items-center justify-between rounded-xl px-3 py-2.5 text-[13px] hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-flex h-2 w-2 rounded-full ${Nr.available?"bg-primary":"bg-destructive"}`}),s.jsx("span",{className:"font-medium",children:e("settings.tmuxServer")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Nr.available?e("settings.sessions",{n:un.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),hl()},disabled:wn,className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":e("settings.refresh"),children:s.jsx(vn,{size:12,className:wn?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Nr.available?un.length===0?s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:e("settings.noTmuxSessions")}):s.jsxs("div",{className:"space-y-2",children:[vd.map(C=>s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1.5 py-1 text-[10px] text-muted-foreground",children:[s.jsx(Ec,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"shrink-0 font-medium text-foreground/75",children:C.label}),s.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:e("settings.sessions",{n:C.sessions.length})}),C.key&&s.jsx("span",{className:"min-w-0 truncate text-muted-foreground/60",children:C.key})]}),C.sessions.map(j=>{const me=j.boundFrontendSessionId??null,Ke=!!(j.connected||me),St=me?_t.find(vi=>vi.id===me)??null:null,rr=j.friendlyName?.trim()||null,Ir=j.label&&j.label!==j.name?j.label:null,nn=rr||Ir||j.name,An=rr||Ir?`tmux:${j.name}`:null,Dn=j.clientCount&&j.clientCount>0?t==="zh"?`网页连接 ${j.clientCount}`:`Web clients ${j.clientCount}`:null,xs=j.attached>0?t==="zh"?`原生 tmux ${j.attached}`:`Native tmux ${j.attached}`:null,mn=[An,Ke?j.restorable?e("settings.restorable"):e("settings.attached"):null,Dn,xs].filter(vi=>!!vi),Di=[e("settings.windows",{n:j.windows}),j.createdAt?new Date(j.createdAt).toLocaleDateString():null].filter(vi=>!!vi),Ua=et===j.name,za=Bt===j.name,ia=yn===j.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${Ua?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(x0,{size:13,className:Ke?"mt-0.5 shrink-0 text-primary":"mt-0.5 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:nn}),j.friendlyName&&s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:t==="zh"?"自定义":"custom"})]}),mn.length>0&&s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:mn.map(vi=>s.jsx("span",{className:"max-w-full truncate",children:vi},vi))}),(j.program||j.cwd)&&s.jsxs("div",{className:"grid min-w-0 gap-0.5 text-[10px] text-muted-foreground",children:[j.program&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(CA,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate text-foreground/75",children:j.program})]}),j.cwd&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(Ec,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:j.cwd})]})]}),s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/80",children:Di.map(vi=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(iA,{size:10,className:"shrink-0 text-muted-foreground/60"}),vi]},vi))})]}),Ua?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:za,onClick:()=>{Mf(j.name)},className:"shrink-0 rounded-full bg-destructive/90 px-2.5 py-1 text-[11px] font-medium text-destructive-foreground transition hover:bg-destructive disabled:opacity-50",children:za?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:za,onClick:()=>{kt(null),lr(null)},className:"shrink-0 rounded-full bg-surface-2 px-2.5 py-1 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:e("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>{St?tc(St.id):(ar(j.name),vo({mode:"tmux",tmuxSessionName:j.name}))},disabled:ia,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${Ke?"bg-surface text-foreground hover:bg-surface-elevated":ia?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:ia?s.jsxs(s.Fragment,{children:[s.jsx(En,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(Ke?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:za,onClick:()=>{lr(null),kt(j.name)},className:"shrink-0 inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":`Kill tmux session ${j.name}`,children:s.jsx(Zs,{size:12})})]})]},j.name)})]},C.key||"__ungrouped_tmux__")),gn&&s.jsx("p",{className:"px-2 text-[11px] text-destructive",children:gn})]}):s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:Nr.reason||e("settings.installTmuxHint")})})]}),s.jsxs("button",{type:"button",onClick:()=>sa(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Wb,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.keyboardToolbar")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e("settings.sessions",{n:Yn.length})}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>oe(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(od,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.aiAgentDetection")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"hooks"}),s.jsx("span",{children:"›"})]})]}),s.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.language")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[{code:"en",label:"English"},{code:"zh",label:"中文"}].map(C=>{const j=t===C.code;return s.jsx("button",{type:"button",onClick:()=>r(C.code),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${j?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:C.label},C.code)})})]}),s.jsxs("button",{type:"button",onClick:async()=>{try{await c9()}catch{}window.dispatchEvent(new CustomEvent("auth:unauthorized"))},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-xl bg-destructive/10 px-3 py-2.5 text-[13px] font-medium text-destructive transition hover:bg-destructive/20 active:scale-[0.98]",children:[s.jsx(Kb,{size:14}),e("settings.signOut")]})]})]})})]}),$a&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm cursor-default animate-fade-in",onClick:()=>{G(null),Me(null),lr(null)},"aria-label":e("common.close")}),s.jsxs("div",{className:`fixed z-menu-panel rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in ${he&&Vt?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:he&&Vt?{...yb(he),paddingBottom:a}:{paddingBottom:a},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.closeChooserTitle")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:bd}),s.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground/80",children:e("tab.closeChooserDescription")})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:sc,className:"flex items-center gap-3 px-4 py-3 text-left text-[13px] text-destructive transition hover:bg-destructive/10",children:[s.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:s.jsx(Zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.confirmDestroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}),gn&&s.jsx("p",{className:"px-4 py-2 text-[11px] text-destructive",children:gn})]}),s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:()=>{G(null),Me(null),lr(null)},className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]}),$n&&(()=>{const C=_t.find(Dn=>Dn.id===$n);if(!C)return null;const j=Te.get(C.id),{primary:me}=Xo(C,j?.activeProgram??null,j?.cwd??null,da),Ke=Vt,St=Ke?yb(vs):{paddingBottom:a},rr=Ke?"fixed z-menu-panel overflow-y-auto overflow-x-hidden rounded-lg bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in":"fixed inset-x-3 bottom-6 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in sm:bottom-auto sm:top-[15%]",Ir=Ke?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",nn=Ke?"flex items-center gap-2 px-3 py-2 text-left text-[12px] transition":"flex items-center gap-3 px-4 py-3 text-left text-[13px] transition",An=Ke?"inline-flex h-6 w-6 items-center justify-center rounded-md":"inline-flex h-7 w-7 items-center justify-center rounded-full";return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:`fixed inset-0 z-menu-backdrop cursor-default animate-fade-in ${Ke?"bg-transparent":"bg-[var(--app-backdrop-soft)] backdrop-blur-sm"}`,onClick:jr,"aria-label":"Close menu"}),s.jsxs("div",{className:rr,style:St,children:[s.jsxs("div",{className:Ir,children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:me}),j?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/80",children:j.cwd})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{const Dn=vs;jr(),Un(Dn),rn(C.id)},className:`${nn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${An} bg-primary/15 text-primary`,children:s.jsx(rT,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.rename")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.renameHint")})]})]}),s.jsxs("button",{type:"button",disabled:!j?.cwd,onClick:()=>{md(C.id),jr()},className:`${nn} ${j?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${An} bg-surface-2 text-muted-foreground`,children:s.jsx(Gb,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.copyCwd")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.copyCwdHint")})]}),xr&&xr===j?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const Dn=cm(C.id),xs=Dn??We;return s.jsxs("div",{className:`${nn} text-foreground`,children:[s.jsx("span",{className:`${An} bg-surface-2 text-muted-foreground`,children:s.jsx(MT,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.fontSize")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.fontSizeHint")})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>{gh(C.id,xs-1),Gn(mn=>mn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} -1`,children:"−"}),s.jsxs("span",{className:"w-8 text-center text-[11px] tabular-nums text-muted-foreground",children:[xs,"px"]}),s.jsx("button",{type:"button",onClick:()=>{gh(C.id,xs+1),Gn(mn=>mn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} +1`,children:"+"}),Dn!==null&&s.jsx("button",{type:"button",onClick:()=>{gh(C.id,null),Gn(mn=>mn+1)},className:"ml-1 shrink-0 rounded-md px-1.5 py-1 text-[11px] text-primary transition hover:bg-primary/10",children:e("tab.fontSizeReset")})]})]})})(),j?.agentNativeSessionId&&j.agentStatus!=="working"&&j.agentStatus!=="waiting"&&j.terminalSessionId&&s.jsxs("button",{type:"button",onClick:()=>{const Dn=j.terminalSessionId;Dn&&(jr(),Y(C.id,Dn))},className:`${nn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${An} bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)]`,children:s.jsx(wc,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block font-medium",children:[e("tab.resumeAgent"),j.agent?.displayName?` · ${j.agent.displayName}`:""]}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.resumeAgentHint")})]})]}),s.jsx("div",{className:"my-1 border-t border-border/15"}),C.mode==="tmux"?s.jsxs("button",{type:"button",onClick:()=>{jr(),Oo(C.id)},className:`${nn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${An} bg-destructive/15 text-destructive`,children:s.jsx(Zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.destroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}):s.jsxs("button",{type:"button",onClick:()=>{jr(),nc({sessionId:C.id,source:"tab-menu",closeMode:"auto"})},className:`${nn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${An} bg-destructive/15 text-destructive`,children:s.jsx(Wn,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.close")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.closeHint")})]})]}),!Ke&&s.jsx("button",{type:"button",className:"flex items-center justify-center px-4 py-2 text-[11px] text-muted-foreground/80 transition hover:text-foreground",onClick:()=>{jr()},children:e("tab.longPressTip")})]}),!Ke&&s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:jr,className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]})})(),Ln&&fn&&Vt&&(()=>{const C=_t.find(mn=>mn.id===Ln);if(!C)return null;const j=Te.get(C.id),{primary:me}=Xo(C,j?.activeProgram??null,j?.cwd??null,da,j?.shellTitle??null,j?.promptState??null),Ke=C.customName?C.name:me,St=mn=>{const Di=mn.trim();Di?Di!==Ke&&Ui(C.id,Di):Do(C.id),rn(null),Un(null)},rr=300,Ir=160,nn=fn.x,An=fn.y,Dn=Math.min(Math.max(nn-rr/2,12),window.innerWidth-rr-12),xs=An+Ir+20>window.innerHeight?Math.max(An-Ir-12,12):An+12;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-transparent",onClick:()=>{rn(null),Un(null)},"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed z-menu-panel w-[300px] rounded-xl bg-surface-elevated border border-border/15 shadow-[0_12px_36px_var(--app-shadow-soft)] animate-fade-in",style:{left:`${Dn}px`,top:`${xs}px`},children:[s.jsxs("div",{className:"border-b border-border/15 px-3 py-2.5",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.rename")}),s.jsx("div",{className:"mt-0.5 truncate text-[13px] font-medium text-foreground",children:me}),j?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",children:j.cwd})]}),s.jsxs("form",{className:"px-3 py-2.5",onSubmit:mn=>{mn.preventDefault();const Di=new FormData(mn.currentTarget).get("session-name");St(typeof Di=="string"?Di:"")},children:[s.jsx("input",{ref:mn=>{Qt.current=mn,mn&&!It.current&&(It.current=!0,mn.focus({preventScroll:!0}),mn.select())},type:"text",name:"session-name",defaultValue:Ke,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,className:"w-full rounded-lg bg-surface-2 px-3 py-2 text-[13px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:mn=>{mn.key==="Escape"&&(mn.stopPropagation(),rn(null),Un(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{rn(null),Un(null)},className:"flex-1 rounded-full bg-surface-2 px-3 py-1.5 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary px-3 py-1.5 text-[12px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.97]",children:e("common.save")})]})]})]})]})})(),Ln&&!Vt&&(()=>{const C=_t.find(rr=>rr.id===Ln);if(!C)return null;const j=Te.get(C.id),{primary:me}=Xo(C,j?.activeProgram??null,j?.cwd??null,da,j?.shellTitle??null,j?.promptState??null),Ke=C.customName?C.name:me,St=rr=>{const Ir=rr.trim();Ir?Ir!==Ke&&Ui(C.id,Ir):Do(C.id),rn(null)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>rn(null),"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed inset-x-3 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",style:{top:`calc(${n} + 3.5rem)`},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 text-[14px] font-medium text-foreground",children:e("tab.rename")})]}),s.jsxs("form",{className:"px-4 py-3",onSubmit:rr=>{rr.preventDefault();const Ir=new FormData(rr.currentTarget).get("session-name");St(typeof Ir=="string"?Ir:"")},children:[s.jsx("input",{ref:rr=>{Qt.current=rr,rr&&!It.current&&(It.current=!0,rr.focus({preventScroll:!0}),rr.select())},type:"text",name:"session-name",defaultValue:Ke,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,enterKeyHint:"done",className:"w-full rounded-lg bg-surface-2 px-3 py-2.5 text-[16px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:rr=>{rr.key==="Escape"&&(rr.stopPropagation(),rn(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>rn(null),className:"flex-1 rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary/20 px-3 py-2 text-[12px] font-medium text-primary transition hover:bg-primary/30",children:e("common.save")})]})]})]})]})})(),ya&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":e("common.close"),className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>bi(!1)}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"local-access-title",className:"fixed inset-x-3 top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 p-4",children:[s.jsx("h2",{id:"local-access-title",className:"section-title",children:e("settings.localAccess")}),s.jsx("button",{autoFocus:!0,type:"button","aria-label":e("common.close"),onClick:()=>bi(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(Wn,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(KT,{state:Be,onCopy:C=>{Mo(C,"setup")},copied:we==="setup"}),s.jsxs("div",{className:"mt-3 flex items-center overflow-hidden rounded-lg bg-surface ring-1 ring-border/10 focus-within:ring-primary/40",children:[s.jsx("input",{value:X,onChange:C=>Qe(C.target.value.toLowerCase()),className:"min-w-0 flex-1 bg-transparent px-2.5 py-2 text-[12px] text-foreground outline-none",placeholder:"jovn",spellCheck:!1}),s.jsx("span",{className:"shrink-0 border-l border-border/10 px-2.5 py-2 text-[11px] text-muted-foreground",children:".termdock.local"})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:Pe,onClick:()=>{xo()},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary transition hover:bg-primary/25 disabled:opacity-50",children:e(Pe?"settings.saving":"common.save")}),s.jsx("button",{type:"button",disabled:Pe,onClick:()=>{dl()},className:"rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-50",children:e("settings.resetAutoName")})]}),s.jsxs("div",{className:"mt-3 space-y-1.5 text-[11px]",children:[Be.url&&s.jsxs("button",{type:"button",onClick:()=>{Mo(Be.url,"lan")},className:"flex w-full items-center justify-between gap-2 rounded-lg bg-surface px-2.5 py-2 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"min-w-0 truncate",children:["Branded: ",Be.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:we==="lan"?"Copied":e("common.copy")})]}),Be.interfaces.length>0&&s.jsxs("details",{className:"rounded-lg bg-surface px-2.5 py-2 text-muted-foreground",open:!1,children:[s.jsx("summary",{className:"cursor-pointer text-[11px] font-medium text-foreground/80",children:"IP fallback addresses"}),s.jsx("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:Be.interfaces.map(C=>{const j=C.url??`${Be.httpsEnabled?"https":"http"}://${C.address}:9834`;return s.jsxs("div",{className:"rounded-lg bg-surface-2 p-2",children:[s.jsxs("div",{className:"text-[11px] font-medium text-foreground/85",children:[C.label," (",C.name,")"]}),s.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:C.address}),C.qrDataUrl&&s.jsx("div",{className:"mt-2 inline-block rounded-lg bg-[var(--background)] p-1.5",children:s.jsx("img",{src:C.qrDataUrl,alt:`QR code for ${j}`,className:"h-28 w-28"})}),s.jsxs("button",{type:"button",onClick:()=>{Mo(j,`ip-${C.address}`)},className:"mt-2 flex w-full items-center justify-between gap-2 rounded-md bg-surface px-2 py-1.5 text-left text-[11px] transition hover:bg-surface-elevated",children:[s.jsx("span",{className:"min-w-0 truncate",children:j}),s.jsx("span",{className:"shrink-0 text-[10px]",children:we===`ip-${C.address}`?"Copied":e("common.copy")})]})]},`${C.name}-${C.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[Be.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!Be.caAvailable&&` · ${e("settings.caMissing")}`]}),Be.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:Be.reason}),Ce&&s.jsx("div",{className:"text-destructive",children:Ce})]})]})]})]}),va&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>Qs(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notifications")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.notificationsTitle")})]}),s.jsx("button",{type:"button",onClick:()=>Qs(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close notifications settings",children:s.jsx(Wn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:e("settings.notificationsPageHint")}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsMaster")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:q==="denied"?e("settings.notificationsDenied"):Bd()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),Bd()&&!u9()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{Yt()},disabled:!Bd()||q==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":I,children:s.jsx(nl,{checked:I,disabled:!Bd()||q==="denied"})})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[s.jsxs("span",{className:`rounded-full px-2 py-0.5 ${q==="granted"?"bg-primary/15 text-primary":"bg-surface text-muted-foreground"}`,children:[e("settings.notificationsPermission"),": ",ao()?e("settings.notificationsPermissionSystem"):q]}),s.jsx("button",{type:"button",disabled:!I||q!=="granted"||Ri==="checking",onClick:()=>{Ar()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:e(Ri==="checking"?"settings.notificationsTestChecking":"settings.notificationsTest")}),ao()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{ao()?.openNotificationSettings?.()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:e("settings.notificationsOpenSystemSettings")})]}),Ri!=="idle"&&Ri!=="checking"&&s.jsx("div",{className:`mt-2 text-[11px] leading-relaxed ${Ri==="delivered"?"text-primary":"text-[var(--warning)]"}`,children:e(Ri==="delivered"?"settings.notificationsTestDelivered":"settings.notificationsTestFailed")})]}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAlertStyle")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAlertStyleHint")}),s.jsx("div",{className:"mt-3 grid grid-cols-3 gap-1 rounded-xl bg-surface p-1",children:[["normal",e("settings.notificationsStyleNormal"),e("settings.notificationsStyleNormalHint")],["quiet",e("settings.notificationsStyleQuiet"),e("settings.notificationsStyleQuietHint")],["persistent",e("settings.notificationsStylePersistent"),e("settings.notificationsStylePersistentHint")]].map(([C,j,me])=>{const Ke=W===C;return s.jsxs("button",{type:"button",disabled:!I,onClick:()=>In(C),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${Ke&&I?"bg-primary/15 text-primary":I?"text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"cursor-not-allowed text-muted-foreground/40"}`,title:me,children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold",children:j}),s.jsx("span",{className:"mt-0.5 block truncate text-[9px] opacity-80",children:me})]},C)})})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notificationsEvents")}),s.jsxs("div",{className:"mt-2 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAiFinished")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAiFinishedHint")})]}),s.jsx("button",{type:"button",disabled:!I,onClick:()=>ln(!R),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":R&&I,children:s.jsx(nl,{checked:R&&I,disabled:!I})})]}),s.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-border/10 pt-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsSessionExited")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsSessionExitedHint")})]}),s.jsx("button",{type:"button",disabled:!I,onClick:()=>Qn(!Q),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":Q&&I,children:s.jsx(nl,{checked:Q&&I,disabled:!I})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),ba&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>sa(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.mobileKeyboard")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.toolbarPresets")})]}),s.jsx("button",{type:"button",onClick:()=>sa(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close toolbar presets",children:s.jsx(Wn,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(UO,{presets:Yn,selectedPresetId:Bo,onSelectPreset:Qo,onUpdatePreset:(C,j)=>{Mi(me=>o0(me.map(Ke=>Ke.id===C?j(Ke):Ke)))},onAddPreset:()=>{const C=`preset-${Date.now()}`;Mi(j=>o0([...j,{id:C,label:`Preset ${j.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),Qo(C)},onRemovePreset:C=>{Mi(j=>o0(j.filter(me=>me.id!==C)))},onResetDefaults:()=>{Mi(Zu()),Qo("default")}})})]})]}),Pa&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>oe(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.aiAgentDetection")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.detectionRules")})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{type:"button",onClick:()=>oe(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close agent rules",children:s.jsx(Wn,{size:18})})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:e("settings.agentHooksHint")}),s.jsx(HO,{}),s.jsxs("div",{className:"mt-6 border-t border-border/15 pt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.programLabelResolution")}),s.jsx("h3",{className:"mt-1 text-sm font-semibold text-foreground",children:e("settings.rawCommandMapping")}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:e("settings.rawCommandMappingHint")}),s.jsx("div",{className:"mt-3 space-y-2 rounded-xl bg-surface-2 p-3",children:_t.map(C=>{const j=Te.get(C.id),me=j?.activeProgramRaw??null,Ke=j?.activeProgram??null;return s.jsxs("div",{className:"rounded-lg bg-surface/60 px-2.5 py-2",children:[s.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:C.name}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-foreground",children:[s.jsx("span",{className:"text-muted-foreground",children:"display:"})," ",Ke||"—"]}),s.jsxs("div",{className:"mt-0.5 break-all font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"text-muted-foreground/80",children:"raw:"})," ",me||"—"]})]},`raw-${C.id}`)})}),s.jsxs("div",{className:"mt-3 space-y-3",children:[[{key:"genericProgramNames",label:e("settings.genericProgramNames"),hint:e("settings.genericProgramNamesHint")},{key:"wrapperScriptNames",label:e("settings.wrapperScriptNames"),hint:e("settings.wrapperScriptNamesHint")},{key:"shellNames",label:e("settings.shellNamesConfig"),hint:e("settings.shellNamesHint")}].map(({key:C,label:j,hint:me})=>s.jsxs("div",{children:[s.jsx("div",{className:"mb-0.5 text-[11px] font-medium text-foreground",children:j}),s.jsx("div",{className:"text-[10px] text-muted-foreground",children:me}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[He[C].map(Ke=>s.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] font-mono text-foreground",children:[Ke,s.jsx("button",{type:"button",onClick:()=>{const St={...He,[C]:He[C].filter(rr=>rr!==Ke)};Ie(St),C==="shellNames"&&(da=new Set(St.shellNames)),Lg(St).catch(()=>{})},className:"ml-0.5 text-muted-foreground hover:text-destructive",children:"×"})]},Ke)),s.jsx("input",{placeholder:e("settings.addTag"),className:"w-16 rounded bg-surface px-1.5 py-0.5 text-[11px] font-mono",onKeyDown:Ke=>{if(Ke.key!=="Enter")return;const St=Ke.target.value.trim().toLowerCase();if(!St||He[C].includes(St))return;const rr={...He,[C]:[...He[C],St]};Ie(rr),C==="shellNames"&&(da=new Set(rr.shellNames)),Ke.target.value="",Lg(rr).catch(()=>{})}})]})]},C)),s.jsx("button",{type:"button",onClick:()=>{d9().then(C=>{Ie(C),da=new Set(C.shellNames)}).catch(()=>{})},className:"rounded-full bg-surface-2 px-3 py-1 text-[11px] text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")})]}),s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"mb-1 text-[11px] font-medium text-foreground",children:e("settings.customRules")}),qe.map((C,j)=>s.jsx("div",{className:"mb-2 rounded-lg bg-surface-2 p-2.5",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:C.enabled!==!1,onChange:me=>{const Ke=qe.map((St,rr)=>rr===j?{...St,enabled:me.target.checked}:St);vt(Ke),On(ua,Ke),D(!0),Uc(Ke).then(St=>{vt(St),On(ua,St)}).catch(()=>{}).finally(()=>D(!1))}}),s.jsxs("select",{value:C.matchType,onChange:me=>{const Ke=qe.map((St,rr)=>rr===j?{...St,matchType:me.target.value}:St);vt(Ke),On(ua,Ke),D(!0),Uc(Ke).then(St=>{vt(St),On(ua,St)}).catch(()=>{}).finally(()=>D(!1))},className:"rounded bg-surface px-2 py-1 text-[11px]",children:[s.jsx("option",{value:"includes",children:"includes"}),s.jsx("option",{value:"exact",children:"exact"}),s.jsx("option",{value:"prefix",children:"prefix"}),s.jsx("option",{value:"regex",children:"regex"})]}),s.jsx("input",{value:C.pattern,onChange:me=>{const Ke=qe.map((St,rr)=>rr===j?{...St,pattern:me.target.value}:St);vt(Ke),On(ua,Ke)},onBlur:()=>{D(!0),Uc(qe).then(me=>{vt(me),On(ua,me)}).catch(()=>{}).finally(()=>D(!1))},placeholder:"pattern",className:"min-w-[180px] flex-1 rounded bg-surface px-2 py-1 text-[11px] font-mono"}),s.jsx("input",{value:C.output,onChange:me=>{const Ke=qe.map((St,rr)=>rr===j?{...St,output:me.target.value}:St);vt(Ke),On(ua,Ke)},onBlur:()=>{D(!0),Uc(qe).then(me=>{vt(me),On(ua,me)}).catch(()=>{}).finally(()=>D(!1))},placeholder:"output",className:"w-28 rounded bg-surface px-2 py-1 text-[11px]"}),s.jsx("button",{type:"button",onClick:()=>{const me=qe.filter((Ke,St)=>St!==j);vt(me),On(ua,me),D(!0),Uc(me).then(Ke=>{vt(Ke),On(ua,Ke)}).catch(()=>{}).finally(()=>D(!1))},className:"rounded bg-surface px-2 py-1 text-[11px] text-muted-foreground hover:text-destructive",children:e("common.delete")})]})},C.id)),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{const C=[...qe,{id:`rule-${Date.now()}`,enabled:!0,priority:100,matchType:"includes",pattern:"",output:""}];vt(C),On(ua,C),D(!0),Uc(C).then(j=>{vt(j),On(ua,j)}).catch(()=>{}).finally(()=>D(!1))},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-primary/25",children:e("settings.addRule")}),s.jsx("button",{type:"button",onClick:()=>{D(!0),h9().then(C=>{vt(C),On(ua,C)}).catch(()=>{}).finally(()=>D(!1))},className:"rounded-full bg-surface-2 px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:k?e("settings.saving"):wr?`${qe.length} rules`:"…"})]})]})]})]})]})]}),Ve&&s.jsx(BO,{isOpen:Ve,onClose:()=>Tt(!1)}),!yi&&s.jsx(H5,{isOpen:ur,drawerWidthPx:Oi,onClose:()=>Vn("left-sidebar"),onOpen:Ms,sessions:_t,activeSessionId:Nt,sessionStates:Te,onNewSession:C=>vo(C),recoverableTmuxSessions:wd,recoverableTmuxSessionsLoading:wn,onRefreshRecoverableTmuxSessions:()=>{hl()},onCloseSession:Oo,onSplitSession:gd,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:at,onSetSplitLayout:xd,onReorderSplitWorkspace:Qc,onRenameSplitWorkspace:N0,onCombineSplitSessions:R0,onReorderSessions:js,onSessionMenu:Nl,onOpenSettings:go,onJumpToNextAttention:cs.length>0?Po:void 0,onOpenQuota:()=>Tt(!0),updateState:$e,updateActionPending:se,onConfirmUpdateRestart:xt,onRetryUpdate:Gt,serverHealthState:de,tmuxAvailable:Nr.available,defaultSessionMode:Bs,onTogglePinned:Vt?ma:void 0}),!Fo&&s.jsx(W5,{isOpen:tn,sessionId:Nt,drawerWidthPx:Pi,onClose:()=>Vn("right-sidebar"),onOpen:ho,rightSidebarFilePreviewOpen:Ks,rightSidebarFilePreviewCloseSignal:Ne,onOpenRightSidebarFilePreview:ja,onCloseRightSidebarFilePreview:po,rightSidebarRepoPickerOpen:gt,rightSidebarRepoPickerCloseSignal:Ft,onOpenRightSidebarRepoPicker:Il,onCloseRightSidebarRepoPicker:ul,markdownOutlineOpen:Ge,markdownOutlineCloseSignal:Pt,onOpenMarkdownOutline:No,onCloseMarkdownOutline:Js,markdownImageLightboxOpen:Zt,markdownImageLightboxCloseSignal:ae,onOpenMarkdownImageLightbox:Ro,onCloseMarkdownImageLightbox:mo,onTogglePinned:Vt?$i:void 0}),ye&&!l&&s.jsx("button",{type:"button",onClick:Ei,className:"fixed inset-0 z-toast flex cursor-default items-center justify-center bg-[var(--app-backdrop-soft)] px-6 text-left backdrop-blur-[1px]","aria-label":t==="zh"?"继续使用 Termdock":"Continue using Termdock",children:s.jsxs("div",{className:"max-w-[18rem] rounded-2xl border border-border/15 bg-surface/95 px-5 py-4 text-center shadow-[0_18px_50px_var(--app-shadow-strong)] backdrop-blur animate-fade-in",children:[s.jsx("div",{className:"text-[14px] font-semibold text-foreground",children:t==="zh"?"建议使用 Home":"Use Home instead"}),s.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:t==="zh"?"按 Home 退后台,点任意位置继续。":"Use Home to leave. Tap anywhere to continue."}),s.jsx("div",{className:"mt-3 text-[11px] font-medium text-muted-foreground/80",children:t==="zh"?"轻点关闭提示":"Tap to dismiss"})]})}),be&&s.jsxs("div",{className:`fixed inset-x-3 bottom-4 z-toast mx-auto flex max-w-md items-center gap-2 rounded-xl border px-4 py-3 text-[12px] shadow-lg animate-fade-in ${be.tone==="success"?"border-[rgb(var(--success-rgb)_/_0.24)] bg-surface-elevated text-foreground":"border-destructive/30 bg-surface-elevated text-destructive"}`,role:be.tone==="error"?"alert":"status",children:[be.tone==="success"?s.jsx(wc,{size:14,className:"shrink-0 text-[color:var(--success)]"}):s.jsx(Ph,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:be.message}),s.jsx("button",{type:"button",onClick:()=>Er(null),className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("common.close"),children:s.jsx(Wn,{size:12})})]}),c&&s.jsxs(s.Fragment,{children:[!Vt&&s.jsx(XT,{onClose:()=>h(!1)}),s.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-toast hidden max-h-48 overflow-y-auto border-t border-border/15 bg-surface p-3 animate-fade-in md:block",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h4",{className:"ui-kicker",children:"Debug Info"}),s.jsx("button",{type:"button",onClick:()=>h(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Close"})]}),s.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(Rt,null,2)})]})]})]}),_d=Zr?null:s.jsx(m9,{className:"z-modal-panel",status:"正在恢复终端…"});return Vt?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[yi&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:Xr,flexShrink:0,height:"100%"},children:s.jsx(H5,{isOpen:ur,drawerWidthPx:Xr,onClose:Ma,onOpen:Ms,sessions:_t,activeSessionId:Nt,sessionStates:Te,onNewSession:C=>vo(C),recoverableTmuxSessions:wd,recoverableTmuxSessionsLoading:wn,onRefreshRecoverableTmuxSessions:()=>{hl()},onCloseSession:Oo,onSplitSession:gd,onCloseSplit:C=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:C})),onRemoveFromSplit:C=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:C})),splitWorkspaces:at,onSetSplitLayout:xd,onReorderSplitWorkspace:Qc,onRenameSplitWorkspace:N0,onCombineSplitSessions:R0,onReorderSessions:js,onSessionMenu:Nl,onOpenSettings:go,onJumpToNextAttention:cs.length>0?Po:void 0,onOpenQuota:()=>Tt(!0),updateState:$e,updateActionPending:se,onConfirmUpdateRestart:xt,onRetryUpdate:Gt,serverHealthState:de,tmuxAvailable:Nr.available,defaultSessionMode:Bs,pinned:!0,onTogglePinned:ma})}),s.jsx("div",{role:"separator",tabIndex:-1,className:"shrink-0 w-[5px] h-full cursor-col-resize bg-border/10 hover:bg-primary/30 active:bg-primary/50 transition-colors",onMouseDown:Da})]}),s.jsxs("div",{className:"relative flex-1 min-w-0 h-full overflow-hidden",children:[Cd,Fo&&s.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex",style:{width:Aa},children:[s.jsx("div",{role:"separator",tabIndex:-1,className:"h-full w-[5px] shrink-0 cursor-col-resize bg-border/10 transition-colors hover:bg-primary/30 active:bg-primary/50",onMouseDown:cl}),s.jsx("div",{style:{width:Pc,flexShrink:0,height:"100%"},children:s.jsx(W5,{isOpen:!0,sessionId:Nt,drawerWidthPx:Pc,onClose:fo,onOpen:ho,pinned:!0,onTogglePinned:$i,rightSidebarFilePreviewOpen:Ks,rightSidebarFilePreviewCloseSignal:Ne,onOpenRightSidebarFilePreview:ja,onCloseRightSidebarFilePreview:po,rightSidebarRepoPickerOpen:gt,rightSidebarRepoPickerCloseSignal:Ft,onOpenRightSidebarRepoPicker:Il,onCloseRightSidebarRepoPicker:ul,markdownOutlineOpen:Ge,markdownOutlineCloseSignal:Pt,onOpenMarkdownOutline:No,onCloseMarkdownOutline:Js,markdownImageLightboxOpen:Zt,markdownImageLightboxCloseSignal:ae,onOpenMarkdownImageLightbox:Ro,onCloseMarkdownImageLightbox:mo})})]})]}),s.jsx(ab,{sessionId:Nt}),_d]}):s.jsxs(s.Fragment,{children:[Cd,s.jsx(ab,{sessionId:Nt}),_d]})}const a$=Object.freeze(Object.defineProperty({__proto__:null,default:xF},Symbol.toStringTag,{value:"Module"}));export{yc as $,Iu as A,Zs as B,BP as C,Wu as D,ry as E,Hb as F,QP as G,kA as H,n$ as I,ex as J,ny as K,Gb as L,MA as M,ff as N,rb as O,VA as P,yP as Q,vn as R,Vl as S,dk as T,Kb as U,$T as V,Qd as W,QI as X,s$ as Y,G5 as Z,nm as _,LO as a,i$ as a0,FP as a1,r3 as a2,a$ as b,Fb as c,B9 as d,D9 as e,$b as f,Hu as g,hP as h,uA as i,qQ as j,i1 as k,QA as l,$A as m,qb as n,eT as o,rT as p,sT as q,Gu as r,Vu as s,Oh as t,Yb as u,mT as v,Nu as w,Bv as x,hm as y,ET as z};