@saluzi/saluzi-edu 0.2.2 → 0.2.3

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 (112) hide show
  1. package/dist/cli.js +41 -41
  2. package/dist/rcs-web/assets/Dashboard-BjLgSBGe.js +2 -0
  3. package/dist/rcs-web/assets/{SessionDetail-CWUE75ns.js → SessionDetail-CruRK24e.js} +3 -3
  4. package/{packages/remote-control-server/web/dist/assets/arc-4X1dRN53.js → dist/rcs-web/assets/arc-CrOXzA8z.js} +1 -1
  5. package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-DuqRXyIw.js} +1 -1
  6. package/dist/rcs-web/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-DXIr9X16.js} +1 -1
  7. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-CZ-In_ld.js} +1 -1
  8. package/dist/rcs-web/assets/channel-DDF8LJWa.js +1 -0
  9. package/dist/rcs-web/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-DBlf3wf4.js} +1 -1
  10. package/dist/rcs-web/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-BT5ihCmq.js} +1 -1
  11. package/dist/rcs-web/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-royQmypD.js} +1 -1
  12. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BLXUmKhM.js → dist/rcs-web/assets/chunk-727SXJPM-DRB3M5lQ.js} +1 -1
  13. package/dist/rcs-web/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-DW5gI14p.js} +1 -1
  14. package/dist/rcs-web/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-DmyrNfml.js} +1 -1
  15. package/dist/rcs-web/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BBWD_dZm.js} +1 -1
  16. package/dist/rcs-web/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-BWCGFw9J.js} +1 -1
  17. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DrPr7R0m.js +1 -0
  18. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DrPr7R0m.js +1 -0
  19. package/dist/rcs-web/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-DkWGV1LC.js} +1 -1
  20. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-Bs-352tg.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A--hX8gn8J.js} +1 -1
  21. package/dist/rcs-web/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-B8qDaDD5.js} +1 -1
  22. package/dist/rcs-web/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-2sX5H1Xt.js} +1 -1
  23. package/dist/rcs-web/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-FLLyF0xn.js} +1 -1
  24. package/dist/rcs-web/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-CvHr1zie.js} +1 -1
  25. package/dist/rcs-web/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-PjhDCqWG.js} +1 -1
  26. package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-DJgCZbOs.js → dist/rcs-web/assets/diagram-OG6HWLK6-Bh0CGmhG.js} +1 -1
  27. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DdhPUNhs.js} +1 -1
  28. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-DDoYcc-o.js} +1 -1
  29. package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-mG8bRCFp.js} +1 -1
  30. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-r-matTCu.js} +1 -1
  31. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-C9z9HgPv.js} +1 -1
  32. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-Bqj7zMWp.js} +1 -1
  33. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-BatnAUtx.js} +1 -1
  34. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-M5Z4A6zF.js} +1 -1
  35. package/dist/rcs-web/assets/{linear-DjOGLk2Z.js → linear-7g0gh_s4.js} +1 -1
  36. package/dist/rcs-web/assets/{main-5uxJJ_sE.js → main-kYahqh88.js} +17 -17
  37. package/dist/rcs-web/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-C_e5Vkmm.js} +4 -4
  38. package/dist/rcs-web/assets/{mermaid.core-slLRH1UY.js → mermaid.core-BqN6IVxp.js} +5 -5
  39. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-OVu38HYw.js} +1 -1
  40. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-W3fqeMGS.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-DAXlPFus.js} +1 -1
  42. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-DnByCurZ.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-pRjQ5CvU.js} +1 -1
  44. package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-CRNEGhTF.js} +1 -1
  45. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-Btaq-01j.js} +1 -1
  46. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-BIaHdJLR.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-dOdpmXck.js} +1 -1
  48. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-7VD_vmAe.js} +1 -1
  49. package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-B0kguESu.js} +1 -1
  50. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-D6clBho1.js} +1 -1
  51. package/dist/rcs-web/index.html +1 -1
  52. package/package.json +2 -2
  53. package/packages/remote-control-server/web/dist/assets/Dashboard-BjLgSBGe.js +2 -0
  54. package/packages/remote-control-server/web/dist/assets/{SessionDetail-CWUE75ns.js → SessionDetail-CruRK24e.js} +3 -3
  55. package/{dist/rcs-web/assets/arc-4X1dRN53.js → packages/remote-control-server/web/dist/assets/arc-CrOXzA8z.js} +1 -1
  56. package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-DuqRXyIw.js} +1 -1
  57. package/packages/remote-control-server/web/dist/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-DXIr9X16.js} +1 -1
  58. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CZ-In_ld.js} +1 -1
  59. package/packages/remote-control-server/web/dist/assets/channel-DDF8LJWa.js +1 -0
  60. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-DBlf3wf4.js} +1 -1
  61. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-BT5ihCmq.js} +1 -1
  62. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-royQmypD.js} +1 -1
  63. package/{dist/rcs-web/assets/chunk-727SXJPM-BLXUmKhM.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-DRB3M5lQ.js} +1 -1
  64. package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-DW5gI14p.js} +1 -1
  65. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-DmyrNfml.js} +1 -1
  66. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BBWD_dZm.js} +1 -1
  67. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-BWCGFw9J.js} +1 -1
  68. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DrPr7R0m.js +1 -0
  69. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DrPr7R0m.js +1 -0
  70. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-DkWGV1LC.js} +1 -1
  71. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-Bs-352tg.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A--hX8gn8J.js} +1 -1
  72. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-B8qDaDD5.js} +1 -1
  73. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-2sX5H1Xt.js} +1 -1
  74. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-FLLyF0xn.js} +1 -1
  75. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-CvHr1zie.js} +1 -1
  76. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-PjhDCqWG.js} +1 -1
  77. package/{dist/rcs-web/assets/diagram-OG6HWLK6-DJgCZbOs.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-Bh0CGmhG.js} +1 -1
  78. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DdhPUNhs.js} +1 -1
  79. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-DDoYcc-o.js} +1 -1
  80. package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-mG8bRCFp.js} +1 -1
  81. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-r-matTCu.js} +1 -1
  82. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-C9z9HgPv.js} +1 -1
  83. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-Bqj7zMWp.js} +1 -1
  84. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-BatnAUtx.js} +1 -1
  85. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-M5Z4A6zF.js} +1 -1
  86. package/packages/remote-control-server/web/dist/assets/{linear-DjOGLk2Z.js → linear-7g0gh_s4.js} +1 -1
  87. package/packages/remote-control-server/web/dist/assets/{main-5uxJJ_sE.js → main-kYahqh88.js} +17 -17
  88. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-C_e5Vkmm.js} +4 -4
  89. package/packages/remote-control-server/web/dist/assets/{mermaid.core-slLRH1UY.js → mermaid.core-BqN6IVxp.js} +5 -5
  90. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-OVu38HYw.js} +1 -1
  91. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-W3fqeMGS.js} +1 -1
  92. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-DAXlPFus.js} +1 -1
  93. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-DnByCurZ.js} +1 -1
  94. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-pRjQ5CvU.js} +1 -1
  95. package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-CRNEGhTF.js} +1 -1
  96. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-Btaq-01j.js} +1 -1
  97. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-BIaHdJLR.js} +1 -1
  98. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-dOdpmXck.js} +1 -1
  99. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-7VD_vmAe.js} +1 -1
  100. package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-B0kguESu.js} +1 -1
  101. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-D6clBho1.js} +1 -1
  102. package/packages/remote-control-server/web/dist/index.html +1 -1
  103. package/dist/rcs-web/assets/Dashboard-BiApZyPx.js +0 -2
  104. package/dist/rcs-web/assets/channel-D0E2lnim.js +0 -1
  105. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  106. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  107. package/dist/rcs-web/assets/workerType-Bd-zteMi.js +0 -1
  108. package/packages/remote-control-server/web/dist/assets/Dashboard-BiApZyPx.js +0 -2
  109. package/packages/remote-control-server/web/dist/assets/channel-D0E2lnim.js +0 -1
  110. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  111. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  112. package/packages/remote-control-server/web/dist/assets/workerType-Bd-zteMi.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-VLURNSYL-kyqcLTJM.js","assets/shiki-mEP5vQQu.js","assets/vendor-DE_-CLIE.js","assets/Dashboard-BiApZyPx.js","assets/workerType-Bd-zteMi.js","assets/qr-C0jP9HcD.js","assets/motion-BILbV7YQ.js","assets/SessionDetail-CWUE75ns.js"])))=>i.map(i=>d[i]);
2
- var rc=Object.defineProperty;var oc=(e,t,n)=>t in e?rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>oc(e,typeof t!="symbol"?t+"":t,n);import{e as m,a as rt,j as d,R as Gr,r as Ps,b as sc,c as Kr,d as ac}from"./vendor-DE_-CLIE.js";import{_ as on}from"./shiki-mEP5vQQu.js";import{Q as ic}from"./qr-C0jP9HcD.js";import{m as lc}from"./motion-BILbV7YQ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();function Os(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Os(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ds(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Os(e))&&(r&&(r+=" "),r+=t);return r}const cc=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},dc=(e,t)=>({classGroupId:e,validator:t}),Ls=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Nn="-",$o=[],uc="arbitrary..",fc=e=>{const t=mc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return hc(a);const i=a.split(Nn),h=i[0]===""&&i.length>1?1:0;return $s(i,h,t)},getConflictingClassGroupIds:(a,i)=>{if(i){const h=r[a],f=n[a];return h?f?cc(f,h):h:f||$o}return n[a]||$o}}},$s=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const f=$s(e,t+1,s);if(f)return f}const a=n.validators;if(a===null)return;const i=t===0?e.join(Nn):e.slice(t).join(Nn),h=a.length;for(let f=0;f<h;f++){const c=a[f];if(c.validator(i))return c.classGroupId}},hc=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?uc+r:void 0})(),mc=e=>{const{theme:t,classGroups:n}=e;return pc(n,t)},pc=(e,t)=>{const n=Ls();for(const r in e){const o=e[r];qr(o,n,r,t)}return n},qr=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const a=e[s];gc(a,t,n,r)}},gc=(e,t,n,r)=>{if(typeof e=="string"){xc(e,t,n);return}if(typeof e=="function"){vc(e,t,n,r);return}yc(e,t,n,r)},xc=(e,t,n)=>{const r=e===""?t:Fs(t,e);r.classGroupId=n},vc=(e,t,n,r)=>{if(bc(e)){qr(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(dc(n,e))},yc=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let a=0;a<s;a++){const[i,h]=o[a];qr(h,Fs(t,i),n,r)}},Fs=(e,t)=>{let n=e;const r=t.split(Nn),o=r.length;for(let s=0;s<o;s++){const a=r[s];let i=n.nextPart.get(a);i||(i=Ls(),n.nextPart.set(a,i)),n=i}return n},bc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,wc=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,a)=>{n[s]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let a=n[s];if(a!==void 0)return a;if((a=r[s])!==void 0)return o(s,a),a},set(s,a){s in n?n[s]=a:o(s,a)}}},Ar="!",Fo=":",Cc=[],Uo=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Sc=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let a=0,i=0,h=0,f;const c=o.length;for(let v=0;v<c;v++){const C=o[v];if(a===0&&i===0){if(C===Fo){s.push(o.slice(h,v)),h=v+1;continue}if(C==="/"){f=v;continue}}C==="["?a++:C==="]"?a--:C==="("?i++:C===")"&&i--}const l=s.length===0?o:o.slice(h);let u=l,p=!1;l.endsWith(Ar)?(u=l.slice(0,-1),p=!0):l.startsWith(Ar)&&(u=l.slice(1),p=!0);const g=f&&f>h?f-h:void 0;return Uo(s,p,u,g)};if(t){const o=t+Fo,s=r;r=a=>a.startsWith(o)?s(a.slice(o.length)):Uo(Cc,!1,a,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},kc=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const a=n[s],i=a[0]==="[",h=t.has(a);i||h?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(a)):o.push(a)}return o.length>0&&(o.sort(),r.push(...o)),r}},_c=e=>({cache:wc(e.cacheSize),parseClassName:Sc(e),sortModifiers:kc(e),postfixLookupClassGroupIds:Ec(e),...fc(e)}),Ec=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},Nc=/\s+/,jc=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:a}=t,i=[],h=e.trim().split(Nc);let f="";for(let c=h.length-1;c>=0;c-=1){const l=h[c],{isExternal:u,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:C}=n(l);if(u){f=l+(f.length>0?" "+f:f);continue}let b=!!C,R;if(b){const N=v.substring(0,C);R=r(N);const x=R&&a[R]?r(v):void 0;x&&x!==R&&(R=x,b=!1)}else R=r(v);if(!R){if(!b){f=l+(f.length>0?" "+f:f);continue}if(R=r(v),!R){f=l+(f.length>0?" "+f:f);continue}b=!1}const j=p.length===0?"":p.length===1?p[0]:s(p).join(":"),_=g?j+Ar:j,$=_+R;if(i.indexOf($)>-1)continue;i.push($);const k=o(R,b);for(let N=0;N<k.length;++N){const x=k[N];i.push(_+x)}f=l+(f.length>0?" "+f:f)}return f},Ac=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Us(n))&&(o&&(o+=" "),o+=r);return o},Us=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Us(e[r]))&&(n&&(n+=" "),n+=t);return n},Rc=(e,...t)=>{let n,r,o,s;const a=h=>{const f=t.reduce((c,l)=>l(c),e());return n=_c(f),r=n.cache.get,o=n.cache.set,s=i,i(h)},i=h=>{const f=r(h);if(f)return f;const c=jc(h,n);return o(h,c),c};return s=a,(...h)=>s(Ac(...h))},Tc=[],ve=e=>{const t=n=>n[e]||Tc;return t.isThemeGetter=!0,t},zs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Bs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ic=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Mc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Pc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Oc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Dc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nt=e=>Ic.test(e),se=e=>!!e&&!Number.isNaN(Number(e)),Fe=e=>!!e&&Number.isInteger(Number(e)),cr=e=>e.endsWith("%")&&se(e.slice(0,-1)),Ge=e=>Mc.test(e),Ws=()=>!0,$c=e=>Pc.test(e)&&!Oc.test(e),Yr=()=>!1,Fc=e=>Dc.test(e),Uc=e=>Lc.test(e),zc=e=>!Y(e)&&!Q(e),Bc=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Wc=e=>dt(e,Gs,Yr),Y=e=>zs.test(e),xt=e=>dt(e,Ks,$c),zo=e=>dt(e,Qc,se),Hc=e=>dt(e,Ys,Ws),Vc=e=>dt(e,qs,Yr),Bo=e=>dt(e,Hs,Yr),Gc=e=>dt(e,Vs,Uc),vn=e=>dt(e,Xs,Fc),Q=e=>Bs.test(e),qt=e=>_t(e,Ks),Kc=e=>_t(e,qs),Wo=e=>_t(e,Hs),qc=e=>_t(e,Gs),Yc=e=>_t(e,Vs),yn=e=>_t(e,Xs,!0),Xc=e=>_t(e,Ys,!0),dt=(e,t,n)=>{const r=zs.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},_t=(e,t,n=!1)=>{const r=Bs.exec(e);return r?r[1]?t(r[1]):n:!1},Hs=e=>e==="position"||e==="percentage",Vs=e=>e==="image"||e==="url",Gs=e=>e==="length"||e==="size"||e==="bg-size",Ks=e=>e==="length",Qc=e=>e==="number",qs=e=>e==="family-name",Ys=e=>e==="number"||e==="weight",Xs=e=>e==="shadow",Zc=()=>{const e=ve("color"),t=ve("font"),n=ve("text"),r=ve("font-weight"),o=ve("tracking"),s=ve("leading"),a=ve("breakpoint"),i=ve("container"),h=ve("spacing"),f=ve("radius"),c=ve("shadow"),l=ve("inset-shadow"),u=ve("text-shadow"),p=ve("drop-shadow"),g=ve("blur"),v=ve("perspective"),C=ve("aspect"),b=ve("ease"),R=ve("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],$=()=>[..._(),Q,Y],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],x=()=>[Q,Y,h],y=()=>[nt,"full","auto",...x()],A=()=>[Fe,"none","subgrid",Q,Y],O=()=>["auto",{span:["full",Fe,Q,Y]},Fe,Q,Y],P=()=>[Fe,"auto",Q,Y],F=()=>["auto","min","max","fr",Q,Y],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],S=()=>["auto",...x()],w=()=>[nt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],L=()=>[nt,"screen","full","dvw","lvw","svw","min","max","fit",...x()],E=()=>[nt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],I=()=>[e,Q,Y],W=()=>[..._(),Wo,Bo,{position:[Q,Y]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],B=()=>["auto","cover","contain",qc,Wc,{size:[Q,Y]}],z=()=>[cr,qt,xt],U=()=>["","none","full",f,Q,Y],V=()=>["",se,qt,xt],G=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[se,cr,Wo,Bo],ne=()=>["","none",g,Q,Y],ae=()=>["none",se,Q,Y],de=()=>["none",se,Q,Y],me=()=>[se,Q,Y],H=()=>[nt,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ge],breakpoint:[Ge],color:[Ws],container:[Ge],"drop-shadow":[Ge],ease:["in","out","in-out"],font:[zc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ge],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ge],shadow:[Ge],spacing:["px",se],text:[Ge],"text-shadow":[Ge],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nt,Y,Q,C]}],container:["container"],"container-type":[{"@container":["","normal","size",Q,Y]}],"container-named":[Bc],columns:[{columns:[se,Y,Q,i]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:$()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:y()}],"inset-x":[{"inset-x":y()}],"inset-y":[{"inset-y":y()}],start:[{"inset-s":y(),start:y()}],end:[{"inset-e":y(),end:y()}],"inset-bs":[{"inset-bs":y()}],"inset-be":[{"inset-be":y()}],top:[{top:y()}],right:[{right:y()}],bottom:[{bottom:y()}],left:[{left:y()}],visibility:["visible","invisible","collapse"],z:[{z:[Fe,"auto",Q,Y]}],basis:[{basis:[nt,"full","auto",i,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[se,nt,"auto","initial","none",Y]}],grow:[{grow:["",se,Q,Y]}],shrink:[{shrink:["",se,Q,Y]}],order:[{order:[Fe,"first","last","none",Q,Y]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:S()}],mx:[{mx:S()}],my:[{my:S()}],ms:[{ms:S()}],me:[{me:S()}],mbs:[{mbs:S()}],mbe:[{mbe:S()}],mt:[{mt:S()}],mr:[{mr:S()}],mb:[{mb:S()}],ml:[{ml:S()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:w()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...E()]}],"min-block-size":[{"min-block":["auto",...E()]}],"max-block-size":[{"max-block":["none",...E()]}],w:[{w:[i,"screen",...w()]}],"min-w":[{"min-w":[i,"screen","none",...w()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[a]},...w()]}],h:[{h:["screen","lh",...w()]}],"min-h":[{"min-h":["screen","lh","none",...w()]}],"max-h":[{"max-h":["screen","lh",...w()]}],"font-size":[{text:["base",n,qt,xt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Xc,Hc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",cr,Y]}],"font-family":[{font:[Kc,Vc,t]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Q,Y]}],"line-clamp":[{"line-clamp":[se,"none",Q,zo]}],leading:[{leading:[s,...x()]}],"list-image":[{"list-image":["none",Q,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Q,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[se,"from-font","auto",Q,xt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[se,"auto",Q,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[Fe,Q,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:T()}],"bg-size":[{bg:B()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fe,Q,Y],radial:["",Q,Y],conic:[Fe,Q,Y]},Yc,Gc]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:U()}],"rounded-s":[{"rounded-s":U()}],"rounded-e":[{"rounded-e":U()}],"rounded-t":[{"rounded-t":U()}],"rounded-r":[{"rounded-r":U()}],"rounded-b":[{"rounded-b":U()}],"rounded-l":[{"rounded-l":U()}],"rounded-ss":[{"rounded-ss":U()}],"rounded-se":[{"rounded-se":U()}],"rounded-ee":[{"rounded-ee":U()}],"rounded-es":[{"rounded-es":U()}],"rounded-tl":[{"rounded-tl":U()}],"rounded-tr":[{"rounded-tr":U()}],"rounded-br":[{"rounded-br":U()}],"rounded-bl":[{"rounded-bl":U()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-bs":[{"border-bs":V()}],"border-w-be":[{"border-be":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[se,Q,Y]}],"outline-w":[{outline:["",se,qt,xt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",c,yn,vn]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",l,yn,vn]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[se,xt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",u,yn,vn]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[se,Q,Y]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[se]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[Q,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[se]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:T()}],"mask-size":[{mask:B()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Q,Y]}],filter:[{filter:["","none",Q,Y]}],blur:[{blur:ne()}],brightness:[{brightness:[se,Q,Y]}],contrast:[{contrast:[se,Q,Y]}],"drop-shadow":[{"drop-shadow":["","none",p,yn,vn]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",se,Q,Y]}],"hue-rotate":[{"hue-rotate":[se,Q,Y]}],invert:[{invert:["",se,Q,Y]}],saturate:[{saturate:[se,Q,Y]}],sepia:[{sepia:["",se,Q,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Q,Y]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[se,Q,Y]}],"backdrop-contrast":[{"backdrop-contrast":[se,Q,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",se,Q,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[se,Q,Y]}],"backdrop-invert":[{"backdrop-invert":["",se,Q,Y]}],"backdrop-opacity":[{"backdrop-opacity":[se,Q,Y]}],"backdrop-saturate":[{"backdrop-saturate":[se,Q,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",se,Q,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Q,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[se,"initial",Q,Y]}],ease:[{ease:["linear","initial",b,Q,Y]}],delay:[{delay:[se,Q,Y]}],animate:[{animate:["none",R,Q,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,Q,Y]}],"perspective-origin":[{"perspective-origin":$()}],rotate:[{rotate:ae()}],"rotate-x":[{"rotate-x":ae()}],"rotate-y":[{"rotate-y":ae()}],"rotate-z":[{"rotate-z":ae()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[Q,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:$()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:H()}],"translate-x":[{"translate-x":H()}],"translate-y":[{"translate-y":H()}],"translate-z":[{"translate-z":H()}],"translate-none":["translate-none"],zoom:[{zoom:[Fe,Q,Y]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q,Y]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[se,qt,xt,zo]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Jc=Rc(Zc);function Z(...e){return Jc(Ds(e))}function ed(e){if(!e)return"";const t=String(e),n=document.createElement("div");return n.textContent=t,n.innerHTML}function Jv(e){return e?new Date(e*1e3).toLocaleString():""}function ey(e){return e==="archived"||e==="inactive"}function ty(e,t){if(!e)return"";const n=String(e);return n.length>t?n.slice(0,t)+"...":n}function td(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,n=>n.toString(16).padStart(2,"0"));return[t.slice(0,4).join(""),t.slice(4,6).join(""),t.slice(6,8).join(""),t.slice(8,10).join(""),t.slice(10,16).join("")].join("-")}function nd(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(!e||typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate message UUIDs");const t=new Uint8Array(16);return e.getRandomValues(t),td(t)}/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-VLURNSYL-C_e5Vkmm.js","assets/shiki-mEP5vQQu.js","assets/vendor-DE_-CLIE.js","assets/Dashboard-BjLgSBGe.js","assets/qr-C0jP9HcD.js","assets/motion-BILbV7YQ.js","assets/SessionDetail-CruRK24e.js"])))=>i.map(i=>d[i]);
2
+ var rc=Object.defineProperty;var oc=(e,t,n)=>t in e?rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>oc(e,typeof t!="symbol"?t+"":t,n);import{e as m,a as rt,j as d,R as Gr,r as Ps,b as sc,c as Kr,d as ac}from"./vendor-DE_-CLIE.js";import{_ as on}from"./shiki-mEP5vQQu.js";import{Q as ic}from"./qr-C0jP9HcD.js";import{m as lc}from"./motion-BILbV7YQ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();function Os(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Os(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ds(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Os(e))&&(r&&(r+=" "),r+=t);return r}const cc=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},dc=(e,t)=>({classGroupId:e,validator:t}),Ls=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Nn="-",$o=[],uc="arbitrary..",fc=e=>{const t=mc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return hc(a);const i=a.split(Nn),h=i[0]===""&&i.length>1?1:0;return $s(i,h,t)},getConflictingClassGroupIds:(a,i)=>{if(i){const h=r[a],f=n[a];return h?f?cc(f,h):h:f||$o}return n[a]||$o}}},$s=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const f=$s(e,t+1,s);if(f)return f}const a=n.validators;if(a===null)return;const i=t===0?e.join(Nn):e.slice(t).join(Nn),h=a.length;for(let f=0;f<h;f++){const c=a[f];if(c.validator(i))return c.classGroupId}},hc=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?uc+r:void 0})(),mc=e=>{const{theme:t,classGroups:n}=e;return pc(n,t)},pc=(e,t)=>{const n=Ls();for(const r in e){const o=e[r];qr(o,n,r,t)}return n},qr=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const a=e[s];gc(a,t,n,r)}},gc=(e,t,n,r)=>{if(typeof e=="string"){xc(e,t,n);return}if(typeof e=="function"){vc(e,t,n,r);return}bc(e,t,n,r)},xc=(e,t,n)=>{const r=e===""?t:Fs(t,e);r.classGroupId=n},vc=(e,t,n,r)=>{if(yc(e)){qr(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(dc(n,e))},bc=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let a=0;a<s;a++){const[i,h]=o[a];qr(h,Fs(t,i),n,r)}},Fs=(e,t)=>{let n=e;const r=t.split(Nn),o=r.length;for(let s=0;s<o;s++){const a=r[s];let i=n.nextPart.get(a);i||(i=Ls(),n.nextPart.set(a,i)),n=i}return n},yc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,wc=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,a)=>{n[s]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let a=n[s];if(a!==void 0)return a;if((a=r[s])!==void 0)return o(s,a),a},set(s,a){s in n?n[s]=a:o(s,a)}}},Ar="!",Fo=":",Cc=[],Uo=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Sc=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let a=0,i=0,h=0,f;const c=o.length;for(let v=0;v<c;v++){const C=o[v];if(a===0&&i===0){if(C===Fo){s.push(o.slice(h,v)),h=v+1;continue}if(C==="/"){f=v;continue}}C==="["?a++:C==="]"?a--:C==="("?i++:C===")"&&i--}const l=s.length===0?o:o.slice(h);let u=l,p=!1;l.endsWith(Ar)?(u=l.slice(0,-1),p=!0):l.startsWith(Ar)&&(u=l.slice(1),p=!0);const g=f&&f>h?f-h:void 0;return Uo(s,p,u,g)};if(t){const o=t+Fo,s=r;r=a=>a.startsWith(o)?s(a.slice(o.length)):Uo(Cc,!1,a,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},kc=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const a=n[s],i=a[0]==="[",h=t.has(a);i||h?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(a)):o.push(a)}return o.length>0&&(o.sort(),r.push(...o)),r}},_c=e=>({cache:wc(e.cacheSize),parseClassName:Sc(e),sortModifiers:kc(e),postfixLookupClassGroupIds:Ec(e),...fc(e)}),Ec=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},Nc=/\s+/,jc=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:a}=t,i=[],h=e.trim().split(Nc);let f="";for(let c=h.length-1;c>=0;c-=1){const l=h[c],{isExternal:u,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:C}=n(l);if(u){f=l+(f.length>0?" "+f:f);continue}let y=!!C,R;if(y){const N=v.substring(0,C);R=r(N);const x=R&&a[R]?r(v):void 0;x&&x!==R&&(R=x,y=!1)}else R=r(v);if(!R){if(!y){f=l+(f.length>0?" "+f:f);continue}if(R=r(v),!R){f=l+(f.length>0?" "+f:f);continue}y=!1}const j=p.length===0?"":p.length===1?p[0]:s(p).join(":"),_=g?j+Ar:j,$=_+R;if(i.indexOf($)>-1)continue;i.push($);const k=o(R,y);for(let N=0;N<k.length;++N){const x=k[N];i.push(_+x)}f=l+(f.length>0?" "+f:f)}return f},Ac=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Us(n))&&(o&&(o+=" "),o+=r);return o},Us=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Us(e[r]))&&(n&&(n+=" "),n+=t);return n},Rc=(e,...t)=>{let n,r,o,s;const a=h=>{const f=t.reduce((c,l)=>l(c),e());return n=_c(f),r=n.cache.get,o=n.cache.set,s=i,i(h)},i=h=>{const f=r(h);if(f)return f;const c=jc(h,n);return o(h,c),c};return s=a,(...h)=>s(Ac(...h))},Tc=[],ve=e=>{const t=n=>n[e]||Tc;return t.isThemeGetter=!0,t},zs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Bs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ic=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Mc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Pc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Oc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Dc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nt=e=>Ic.test(e),se=e=>!!e&&!Number.isNaN(Number(e)),Fe=e=>!!e&&Number.isInteger(Number(e)),cr=e=>e.endsWith("%")&&se(e.slice(0,-1)),Ge=e=>Mc.test(e),Ws=()=>!0,$c=e=>Pc.test(e)&&!Oc.test(e),Yr=()=>!1,Fc=e=>Dc.test(e),Uc=e=>Lc.test(e),zc=e=>!Y(e)&&!Q(e),Bc=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Wc=e=>dt(e,Gs,Yr),Y=e=>zs.test(e),xt=e=>dt(e,Ks,$c),zo=e=>dt(e,Qc,se),Hc=e=>dt(e,Ys,Ws),Vc=e=>dt(e,qs,Yr),Bo=e=>dt(e,Hs,Yr),Gc=e=>dt(e,Vs,Uc),vn=e=>dt(e,Xs,Fc),Q=e=>Bs.test(e),qt=e=>_t(e,Ks),Kc=e=>_t(e,qs),Wo=e=>_t(e,Hs),qc=e=>_t(e,Gs),Yc=e=>_t(e,Vs),bn=e=>_t(e,Xs,!0),Xc=e=>_t(e,Ys,!0),dt=(e,t,n)=>{const r=zs.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},_t=(e,t,n=!1)=>{const r=Bs.exec(e);return r?r[1]?t(r[1]):n:!1},Hs=e=>e==="position"||e==="percentage",Vs=e=>e==="image"||e==="url",Gs=e=>e==="length"||e==="size"||e==="bg-size",Ks=e=>e==="length",Qc=e=>e==="number",qs=e=>e==="family-name",Ys=e=>e==="number"||e==="weight",Xs=e=>e==="shadow",Zc=()=>{const e=ve("color"),t=ve("font"),n=ve("text"),r=ve("font-weight"),o=ve("tracking"),s=ve("leading"),a=ve("breakpoint"),i=ve("container"),h=ve("spacing"),f=ve("radius"),c=ve("shadow"),l=ve("inset-shadow"),u=ve("text-shadow"),p=ve("drop-shadow"),g=ve("blur"),v=ve("perspective"),C=ve("aspect"),y=ve("ease"),R=ve("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],$=()=>[..._(),Q,Y],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],x=()=>[Q,Y,h],b=()=>[nt,"full","auto",...x()],A=()=>[Fe,"none","subgrid",Q,Y],O=()=>["auto",{span:["full",Fe,Q,Y]},Fe,Q,Y],P=()=>[Fe,"auto",Q,Y],F=()=>["auto","min","max","fr",Q,Y],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],S=()=>["auto",...x()],w=()=>[nt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],L=()=>[nt,"screen","full","dvw","lvw","svw","min","max","fit",...x()],E=()=>[nt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],I=()=>[e,Q,Y],W=()=>[..._(),Wo,Bo,{position:[Q,Y]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],B=()=>["auto","cover","contain",qc,Wc,{size:[Q,Y]}],z=()=>[cr,qt,xt],U=()=>["","none","full",f,Q,Y],V=()=>["",se,qt,xt],G=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[se,cr,Wo,Bo],ne=()=>["","none",g,Q,Y],ae=()=>["none",se,Q,Y],de=()=>["none",se,Q,Y],me=()=>[se,Q,Y],H=()=>[nt,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ge],breakpoint:[Ge],color:[Ws],container:[Ge],"drop-shadow":[Ge],ease:["in","out","in-out"],font:[zc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ge],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ge],shadow:[Ge],spacing:["px",se],text:[Ge],"text-shadow":[Ge],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nt,Y,Q,C]}],container:["container"],"container-type":[{"@container":["","normal","size",Q,Y]}],"container-named":[Bc],columns:[{columns:[se,Y,Q,i]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:$()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:b()}],"inset-x":[{"inset-x":b()}],"inset-y":[{"inset-y":b()}],start:[{"inset-s":b(),start:b()}],end:[{"inset-e":b(),end:b()}],"inset-bs":[{"inset-bs":b()}],"inset-be":[{"inset-be":b()}],top:[{top:b()}],right:[{right:b()}],bottom:[{bottom:b()}],left:[{left:b()}],visibility:["visible","invisible","collapse"],z:[{z:[Fe,"auto",Q,Y]}],basis:[{basis:[nt,"full","auto",i,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[se,nt,"auto","initial","none",Y]}],grow:[{grow:["",se,Q,Y]}],shrink:[{shrink:["",se,Q,Y]}],order:[{order:[Fe,"first","last","none",Q,Y]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:S()}],mx:[{mx:S()}],my:[{my:S()}],ms:[{ms:S()}],me:[{me:S()}],mbs:[{mbs:S()}],mbe:[{mbe:S()}],mt:[{mt:S()}],mr:[{mr:S()}],mb:[{mb:S()}],ml:[{ml:S()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:w()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...E()]}],"min-block-size":[{"min-block":["auto",...E()]}],"max-block-size":[{"max-block":["none",...E()]}],w:[{w:[i,"screen",...w()]}],"min-w":[{"min-w":[i,"screen","none",...w()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[a]},...w()]}],h:[{h:["screen","lh",...w()]}],"min-h":[{"min-h":["screen","lh","none",...w()]}],"max-h":[{"max-h":["screen","lh",...w()]}],"font-size":[{text:["base",n,qt,xt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Xc,Hc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",cr,Y]}],"font-family":[{font:[Kc,Vc,t]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Q,Y]}],"line-clamp":[{"line-clamp":[se,"none",Q,zo]}],leading:[{leading:[s,...x()]}],"list-image":[{"list-image":["none",Q,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Q,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[se,"from-font","auto",Q,xt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[se,"auto",Q,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[Fe,Q,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:T()}],"bg-size":[{bg:B()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fe,Q,Y],radial:["",Q,Y],conic:[Fe,Q,Y]},Yc,Gc]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:U()}],"rounded-s":[{"rounded-s":U()}],"rounded-e":[{"rounded-e":U()}],"rounded-t":[{"rounded-t":U()}],"rounded-r":[{"rounded-r":U()}],"rounded-b":[{"rounded-b":U()}],"rounded-l":[{"rounded-l":U()}],"rounded-ss":[{"rounded-ss":U()}],"rounded-se":[{"rounded-se":U()}],"rounded-ee":[{"rounded-ee":U()}],"rounded-es":[{"rounded-es":U()}],"rounded-tl":[{"rounded-tl":U()}],"rounded-tr":[{"rounded-tr":U()}],"rounded-br":[{"rounded-br":U()}],"rounded-bl":[{"rounded-bl":U()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-bs":[{"border-bs":V()}],"border-w-be":[{"border-be":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[se,Q,Y]}],"outline-w":[{outline:["",se,qt,xt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",c,bn,vn]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",l,bn,vn]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[se,xt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",u,bn,vn]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[se,Q,Y]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[se]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[Q,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[se]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:T()}],"mask-size":[{mask:B()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Q,Y]}],filter:[{filter:["","none",Q,Y]}],blur:[{blur:ne()}],brightness:[{brightness:[se,Q,Y]}],contrast:[{contrast:[se,Q,Y]}],"drop-shadow":[{"drop-shadow":["","none",p,bn,vn]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",se,Q,Y]}],"hue-rotate":[{"hue-rotate":[se,Q,Y]}],invert:[{invert:["",se,Q,Y]}],saturate:[{saturate:[se,Q,Y]}],sepia:[{sepia:["",se,Q,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Q,Y]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[se,Q,Y]}],"backdrop-contrast":[{"backdrop-contrast":[se,Q,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",se,Q,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[se,Q,Y]}],"backdrop-invert":[{"backdrop-invert":["",se,Q,Y]}],"backdrop-opacity":[{"backdrop-opacity":[se,Q,Y]}],"backdrop-saturate":[{"backdrop-saturate":[se,Q,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",se,Q,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Q,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[se,"initial",Q,Y]}],ease:[{ease:["linear","initial",y,Q,Y]}],delay:[{delay:[se,Q,Y]}],animate:[{animate:["none",R,Q,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,Q,Y]}],"perspective-origin":[{"perspective-origin":$()}],rotate:[{rotate:ae()}],"rotate-x":[{"rotate-x":ae()}],"rotate-y":[{"rotate-y":ae()}],"rotate-z":[{"rotate-z":ae()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[Q,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:$()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:H()}],"translate-x":[{"translate-x":H()}],"translate-y":[{"translate-y":H()}],"translate-z":[{"translate-z":H()}],"translate-none":["translate-none"],zoom:[{zoom:[Fe,Q,Y]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q,Y]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[se,qt,xt,zo]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Jc=Rc(Zc);function Z(...e){return Jc(Ds(e))}function ed(e){if(!e)return"";const t=String(e),n=document.createElement("div");return n.textContent=t,n.innerHTML}function eb(e){return e?new Date(e*1e3).toLocaleString():""}function tb(e){return e==="archived"||e==="inactive"}function nb(e,t){if(!e)return"";const n=String(e);return n.length>t?n.slice(0,t)+"...":n}function td(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,n=>n.toString(16).padStart(2,"0"));return[t.slice(0,4).join(""),t.slice(4,6).join(""),t.slice(6,8).join(""),t.slice(8,10).join(""),t.slice(10,16).join("")].join("-")}function nd(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(!e||typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate message UUIDs");const t=new Uint8Array(16);return e.getRandomValues(t),td(t)}/**
3
3
  * @license lucide-react v0.555.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -59,7 +59,7 @@ var rc=Object.defineProperty;var oc=(e,t,n)=>t in e?rc(e,t,{enumerable:!0,config
59
59
  *
60
60
  * This source code is licensed under the ISC license.
61
61
  * See the LICENSE file in the root directory of this source tree.
62
- */const yd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],bd=re("circle",yd);/**
62
+ */const bd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],yd=re("circle",bd);/**
63
63
  * @license lucide-react v0.555.0 - ISC
64
64
  *
65
65
  * This source code is licensed under the ISC license.
@@ -224,11 +224,11 @@ var rc=Object.defineProperty;var oc=(e,t,n)=>t in e?rc(e,t,{enumerable:!0,config
224
224
  *
225
225
  * This source code is licensed under the ISC license.
226
226
  * See the LICENSE file in the root directory of this source tree.
227
- */const xu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],an=re("x",xu),ia=m.createContext(void 0),la="theme";function Go(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ko(){if(typeof window>"u")return"system";try{const e=localStorage.getItem(la);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function qo(e){const t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e)}function ca(){const e=m.useContext(ia);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function vu({children:e,defaultTheme:t="system"}){const[n,r]=m.useState(()=>Ko()||t),[o,s]=m.useState(()=>{const h=Ko()||t;return h==="system"?Go():h}),a=m.useCallback(h=>{r(h);try{localStorage.setItem(la,h)}catch{}},[]);m.useEffect(()=>{const h=n==="system"?Go():n;s(h),qo(h)},[n]),m.useEffect(()=>{if(n!=="system")return;const h=window.matchMedia("(prefers-color-scheme: dark)"),f=c=>{const l=c.matches?"dark":"light";s(l),qo(l)};return h.addEventListener("change",f),()=>h.removeEventListener("change",f)},[n]);const i={theme:n,resolvedTheme:o,setTheme:a};return rt.createElement(ia.Provider,{value:i},e)}function Yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function We(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Yo(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Yo(e[o],null)}}}}function pe(...e){return m.useCallback(We(...e),e)}var yu=Symbol.for("react.lazy"),jn=Gr[" use ".trim().toString()];function bu(e){return typeof e=="object"&&e!==null&&"then"in e}function da(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===yu&&"_payload"in e&&bu(e._payload)}function ua(e){const t=Cu(e),n=m.forwardRef((r,o)=>{let{children:s,...a}=r;da(s)&&typeof jn=="function"&&(s=jn(s._payload));const i=m.Children.toArray(s),h=i.find(ku);if(h){const f=h.props.children,c=i.map(l=>l===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:l);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,c):null})}return d.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var wu=ua("Slot");function Cu(e){const t=m.forwardRef((n,r)=>{let{children:o,...s}=n;if(da(o)&&typeof jn=="function"&&(o=jn(o._payload)),m.isValidElement(o)){const a=Eu(o),i=_u(s,o.props);return o.type!==m.Fragment&&(i.ref=r?We(r,a):a),m.cloneElement(o,i)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Su=Symbol("radix.slottable");function ku(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Su}function _u(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{const h=s(...i);return o(...i),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Eu(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Xo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Qo=Ds,Nu=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Qo(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,a=Object.keys(o).map(f=>{const c=n==null?void 0:n[f],l=s==null?void 0:s[f];if(c===null)return null;const u=Xo(c)||Xo(l);return o[f][u]}),i=n&&Object.entries(n).reduce((f,c)=>{let[l,u]=c;return u===void 0||(f[l]=u),f},{}),h=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((f,c)=>{let{class:l,className:u,...p}=c;return Object.entries(p).every(g=>{let[v,C]=g;return Array.isArray(C)?C.includes({...s,...i}[v]):{...s,...i}[v]===C})?[...f,l,u]:f},[]);return Qo(e,a,h,n==null?void 0:n.class,n==null?void 0:n.className)},ju=Nu("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Et({className:e,variant:t,size:n,asChild:r=!1,...o}){const s=r?wu:"button";return d.jsx(s,{"data-slot":"button",className:Z(ju({variant:t,size:n,className:e})),...o})}function ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Au(e,t){const n=m.createContext(t),r=s=>{const{children:a,...i}=s,h=m.useMemo(()=>i,Object.values(i));return d.jsx(n.Provider,{value:h,children:a})};r.displayName=e+"Provider";function o(s){const a=m.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Qe(e,t=[]){let n=[];function r(s,a){const i=m.createContext(a),h=n.length;n=[...n,a];const f=l=>{var b;const{scope:u,children:p,...g}=l,v=((b=u==null?void 0:u[e])==null?void 0:b[h])||i,C=m.useMemo(()=>g,Object.values(g));return d.jsx(v.Provider,{value:C,children:p})};f.displayName=s+"Provider";function c(l,u){var v;const p=((v=u==null?void 0:u[e])==null?void 0:v[h])||i,g=m.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${l}\` must be used within \`${s}\``)}return[f,c]}const o=()=>{const s=n.map(a=>m.createContext(a));return function(i){const h=(i==null?void 0:i[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...i,[e]:h}}),[i,h])}};return o.scopeName=e,[r,Ru(o,...t)]}function Ru(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:h,scopeName:f})=>{const l=h(s)[`__scope${f}`];return{...i,...l}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ke=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Tu=Gr[" useInsertionEffect ".trim().toString()]||Ke;function at({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=Iu({defaultProp:t,onChange:n}),i=e!==void 0,h=i?e:o;{const c=m.useRef(e!==void 0);m.useEffect(()=>{const l=c.current;l!==i&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=i},[i,r])}const f=m.useCallback(c=>{var l;if(i){const u=Mu(c)?c(e):c;u!==e&&((l=a.current)==null||l.call(a,u))}else s(c)},[i,e,s,a]);return[h,f]}function Iu({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Tu(()=>{s.current=t},[t]),m.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mu(e){return typeof e=="function"}function Dt(e){const t=Pu(e),n=m.forwardRef((r,o)=>{const{children:s,...a}=r,i=m.Children.toArray(s),h=i.find(Du);if(h){const f=h.props.children,c=i.map(l=>l===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:l);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,c):null})}return d.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}function Pu(e){const t=m.forwardRef((n,r)=>{const{children:o,...s}=n;if(m.isValidElement(o)){const a=$u(o),i=Lu(s,o.props);return o.type!==m.Fragment&&(i.ref=r?We(r,a):a),m.cloneElement(o,i)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fa=Symbol("radix.slottable");function Ou(e){const t=({children:n})=>d.jsx(d.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=fa,t}function Du(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fa}function Lu(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{const h=s(...i);return o(...i),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $u(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ue=Fu.reduce((e,t)=>{const n=Dt(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,h=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ha(e,t){e&&Ps.flushSync(()=>e.dispatchEvent(t))}function ma(e){const t=e+"CollectionProvider",[n,r]=Qe(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:C,children:b}=v,R=rt.useRef(null),j=rt.useRef(new Map).current;return d.jsx(o,{scope:C,itemMap:j,collectionRef:R,children:b})};a.displayName=t;const i=e+"CollectionSlot",h=Dt(i),f=rt.forwardRef((v,C)=>{const{scope:b,children:R}=v,j=s(i,b),_=pe(C,j.collectionRef);return d.jsx(h,{ref:_,children:R})});f.displayName=i;const c=e+"CollectionItemSlot",l="data-radix-collection-item",u=Dt(c),p=rt.forwardRef((v,C)=>{const{scope:b,children:R,...j}=v,_=rt.useRef(null),$=pe(C,_),k=s(c,b);return rt.useEffect(()=>(k.itemMap.set(_,{ref:_,...j}),()=>void k.itemMap.delete(_))),d.jsx(u,{[l]:"",ref:$,children:R})});p.displayName=c;function g(v){const C=s(e+"CollectionConsumer",v);return rt.useCallback(()=>{const R=C.collectionRef.current;if(!R)return[];const j=Array.from(R.querySelectorAll(`[${l}]`));return Array.from(C.itemMap.values()).sort((k,N)=>j.indexOf(k.ref.current)-j.indexOf(N.ref.current))},[C.collectionRef,C.itemMap])}return[{Provider:a,Slot:f,ItemSlot:p},g,r]}var Uu=m.createContext(void 0);function pa(e){const t=m.useContext(Uu);return e||t||"ltr"}function qe(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function zu(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bu="DismissableLayer",Rr="dismissableLayer.update",Wu="dismissableLayer.pointerDownOutside",Hu="dismissableLayer.focusOutside",Zo,ga=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ln=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:i,...h}=e,f=m.useContext(ga),[c,l]=m.useState(null),u=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),g=pe(t,N=>l(N)),v=Array.from(f.layers),[C]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(C),R=c?v.indexOf(c):-1,j=f.layersWithOutsidePointerEventsDisabled.size>0,_=R>=b,$=Ku(N=>{const x=N.target,y=[...f.branches].some(A=>A.contains(x));!_||y||(o==null||o(N),a==null||a(N),N.defaultPrevented||i==null||i())},u),k=qu(N=>{const x=N.target;[...f.branches].some(A=>A.contains(x))||(s==null||s(N),a==null||a(N),N.defaultPrevented||i==null||i())},u);return zu(N=>{R===f.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&i&&(N.preventDefault(),i()))},u),m.useEffect(()=>{if(c)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Zo=u.body.style.pointerEvents,u.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(c)),f.layers.add(c),Jo(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(u.body.style.pointerEvents=Zo)}},[c,u,n,f]),m.useEffect(()=>()=>{c&&(f.layers.delete(c),f.layersWithOutsidePointerEventsDisabled.delete(c),Jo())},[c,f]),m.useEffect(()=>{const N=()=>p({});return document.addEventListener(Rr,N),()=>document.removeEventListener(Rr,N)},[]),d.jsx(ue.div,{...h,ref:g,style:{pointerEvents:j?_?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,k.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,$.onPointerDownCapture)})});ln.displayName=Bu;var Vu="DismissableLayerBranch",Gu=m.forwardRef((e,t)=>{const n=m.useContext(ga),r=m.useRef(null),o=pe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(ue.div,{...e,ref:o})});Gu.displayName=Vu;function Ku(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=i=>{if(i.target&&!r.current){let h=function(){xa(Wu,n,f,{discrete:!0})};const f={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=h,t.addEventListener("click",o.current,{once:!0})):h()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function qu(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&xa(Hu,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Jo(){const e=new CustomEvent(Rr);document.dispatchEvent(e)}function xa(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ha(o,s):o.dispatchEvent(s)}var dr=0;function Jr(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??es()),document.body.insertAdjacentElement("beforeend",e[1]??es()),dr++,()=>{dr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),dr--}},[])}function es(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ur="focusScope.autoFocusOnMount",fr="focusScope.autoFocusOnUnmount",ts={bubbles:!1,cancelable:!0},Yu="FocusScope",Wn=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[i,h]=m.useState(null),f=qe(o),c=qe(s),l=m.useRef(null),u=pe(t,v=>h(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(j){if(p.paused||!i)return;const _=j.target;i.contains(_)?l.current=_:ot(l.current,{select:!0})},C=function(j){if(p.paused||!i)return;const _=j.relatedTarget;_!==null&&(i.contains(_)||ot(l.current,{select:!0}))},b=function(j){if(document.activeElement===document.body)for(const $ of j)$.removedNodes.length>0&&ot(i)};document.addEventListener("focusin",v),document.addEventListener("focusout",C);const R=new MutationObserver(b);return i&&R.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",C),R.disconnect()}}},[r,i,p.paused]),m.useEffect(()=>{if(i){rs.add(p);const v=document.activeElement;if(!i.contains(v)){const b=new CustomEvent(ur,ts);i.addEventListener(ur,f),i.dispatchEvent(b),b.defaultPrevented||(Xu(tf(va(i)),{select:!0}),document.activeElement===v&&ot(i))}return()=>{i.removeEventListener(ur,f),setTimeout(()=>{const b=new CustomEvent(fr,ts);i.addEventListener(fr,c),i.dispatchEvent(b),b.defaultPrevented||ot(v??document.body,{select:!0}),i.removeEventListener(fr,c),rs.remove(p)},0)}}},[i,f,c,p]);const g=m.useCallback(v=>{if(!n&&!r||p.paused)return;const C=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,b=document.activeElement;if(C&&b){const R=v.currentTarget,[j,_]=Qu(R);j&&_?!v.shiftKey&&b===_?(v.preventDefault(),n&&ot(j,{select:!0})):v.shiftKey&&b===j&&(v.preventDefault(),n&&ot(_,{select:!0})):b===R&&v.preventDefault()}},[n,r,p.paused]);return d.jsx(ue.div,{tabIndex:-1,...a,ref:u,onKeyDown:g})});Wn.displayName=Yu;function Xu(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ot(r,{select:t}),document.activeElement!==n)return}function Qu(e){const t=va(e),n=ns(t,e),r=ns(t.reverse(),e);return[n,r]}function va(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ns(e,t){for(const n of e)if(!Zu(n,{upTo:t}))return n}function Zu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ju(e){return e instanceof HTMLInputElement&&"select"in e}function ot(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ju(e)&&t&&e.select()}}var rs=ef();function ef(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=os(e,t),e.unshift(t)},remove(t){var n;e=os(e,t),(n=e[0])==null||n.resume()}}}function os(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function tf(e){return e.filter(t=>t.tagName!=="A")}var nf=Gr[" useId ".trim().toString()]||(()=>{}),rf=0;function Ce(e){const[t,n]=m.useState(nf());return Ke(()=>{n(r=>r??String(rf++))},[e]),e||(t?`radix-${t}`:"")}const of=["top","right","bottom","left"],it=Math.min,Ne=Math.max,An=Math.round,bn=Math.floor,Be=e=>({x:e,y:e}),sf={left:"right",right:"left",bottom:"top",top:"bottom"};function Tr(e,t,n){return Ne(e,it(t,n))}function Ye(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Bt(e){return e.split("-")[1]}function eo(e){return e==="x"?"y":"x"}function to(e){return e==="y"?"height":"width"}function ze(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function no(e){return eo(ze(e))}function af(e,t,n){n===void 0&&(n=!1);const r=Bt(e),o=no(e),s=to(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Rn(a)),[a,Rn(a)]}function lf(e){const t=Rn(e);return[Ir(e),t,Ir(t)]}function Ir(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ss=["left","right"],as=["right","left"],cf=["top","bottom"],df=["bottom","top"];function uf(e,t,n){switch(e){case"top":case"bottom":return n?t?as:ss:t?ss:as;case"left":case"right":return t?cf:df;default:return[]}}function ff(e,t,n,r){const o=Bt(e);let s=uf(Xe(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Ir)))),s}function Rn(e){const t=Xe(e);return sf[t]+e.slice(t.length)}function hf(e){return{top:0,right:0,bottom:0,left:0,...e}}function ya(e){return typeof e!="number"?hf(e):{top:e,right:e,bottom:e,left:e}}function Tn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function is(e,t,n){let{reference:r,floating:o}=e;const s=ze(t),a=no(t),i=to(a),h=Xe(t),f=s==="y",c=r.x+r.width/2-o.width/2,l=r.y+r.height/2-o.height/2,u=r[i]/2-o[i]/2;let p;switch(h){case"top":p={x:c,y:r.y-o.height};break;case"bottom":p={x:c,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:l};break;case"left":p={x:r.x-o.width,y:l};break;default:p={x:r.x,y:r.y}}switch(Bt(t)){case"start":p[a]-=u*(n&&f?-1:1);break;case"end":p[a]+=u*(n&&f?-1:1);break}return p}async function mf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:h}=e,{boundary:f="clippingAncestors",rootBoundary:c="viewport",elementContext:l="floating",altBoundary:u=!1,padding:p=0}=Ye(t,e),g=ya(p),C=i[u?l==="floating"?"reference":"floating":l],b=Tn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:f,rootBoundary:c,strategy:h})),R=l==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),_=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},$=Tn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:R,offsetParent:j,strategy:h}):R);return{top:(b.top-$.top+g.top)/_.y,bottom:($.bottom-b.bottom+g.bottom)/_.y,left:(b.left-$.left+g.left)/_.x,right:($.right-b.right+g.right)/_.x}}const pf=50,gf=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:mf},h=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:l}=is(f,r,h),u=r,p=0;const g={};for(let v=0;v<s.length;v++){const C=s[v];if(!C)continue;const{name:b,fn:R}=C,{x:j,y:_,data:$,reset:k}=await R({x:c,y:l,initialPlacement:r,placement:u,strategy:o,middlewareData:g,rects:f,platform:i,elements:{reference:e,floating:t}});c=j??c,l=_??l,g[b]={...g[b],...$},k&&p<pf&&(p++,typeof k=="object"&&(k.placement&&(u=k.placement),k.rects&&(f=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:c,y:l}=is(f,u,h)),v=-1)}return{x:c,y:l,placement:u,strategy:o,middlewareData:g}},xf=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:h}=t,{element:f,padding:c=0}=Ye(e,t)||{};if(f==null)return{};const l=ya(c),u={x:n,y:r},p=no(o),g=to(p),v=await a.getDimensions(f),C=p==="y",b=C?"top":"left",R=C?"bottom":"right",j=C?"clientHeight":"clientWidth",_=s.reference[g]+s.reference[p]-u[p]-s.floating[g],$=u[p]-s.reference[p],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let N=k?k[j]:0;(!N||!await(a.isElement==null?void 0:a.isElement(k)))&&(N=i.floating[j]||s.floating[g]);const x=_/2-$/2,y=N/2-v[g]/2-1,A=it(l[b],y),O=it(l[R],y),P=A,F=N-v[g]-O,M=N/2-v[g]/2+x,D=Tr(P,M,F),S=!h.arrow&&Bt(o)!=null&&M!==D&&s.reference[g]/2-(M<P?A:O)-v[g]/2<0,w=S?M<P?M-P:M-F:0;return{[p]:u[p]+w,data:{[p]:D,centerOffset:M-D-w,...S&&{alignmentOffset:w}},reset:S}}}),vf=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:h,elements:f}=t,{mainAxis:c=!0,crossAxis:l=!0,fallbackPlacements:u,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...C}=Ye(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=Xe(o),R=ze(i),j=Xe(i)===i,_=await(h.isRTL==null?void 0:h.isRTL(f.floating)),$=u||(j||!v?[Rn(i)]:lf(i)),k=g!=="none";!u&&k&&$.push(...ff(i,v,g,_));const N=[i,...$],x=await h.detectOverflow(t,C),y=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(c&&y.push(x[b]),l){const M=af(o,a,_);y.push(x[M[0]],x[M[1]])}if(A=[...A,{placement:o,overflows:y}],!y.every(M=>M<=0)){var O,P;const M=(((O=s.flip)==null?void 0:O.index)||0)+1,D=N[M];if(D&&(!(l==="alignment"?R!==ze(D):!1)||A.every(L=>ze(L.placement)===R?L.overflows[0]>0:!0)))return{data:{index:M,overflows:A},reset:{placement:D}};let S=(P=A.filter(w=>w.overflows[0]<=0).sort((w,L)=>w.overflows[1]-L.overflows[1])[0])==null?void 0:P.placement;if(!S)switch(p){case"bestFit":{var F;const w=(F=A.filter(L=>{if(k){const E=ze(L.placement);return E===R||E==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(E=>E>0).reduce((E,I)=>E+I,0)]).sort((L,E)=>L[1]-E[1])[0])==null?void 0:F[0];w&&(S=w);break}case"initialPlacement":S=i;break}if(o!==S)return{reset:{placement:S}}}return{}}}};function ls(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cs(e){return of.some(t=>e[t]>=0)}const yf=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Ye(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=ls(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:cs(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=ls(a,n.floating);return{data:{escapedOffsets:i,escaped:cs(i)}}}default:return{}}}}},ba=new Set(["left","top"]);async function bf(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Xe(n),i=Bt(n),h=ze(n)==="y",f=ba.has(a)?-1:1,c=s&&h?-1:1,l=Ye(t,e);let{mainAxis:u,crossAxis:p,alignmentAxis:g}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return i&&typeof g=="number"&&(p=i==="end"?g*-1:g),h?{x:p*c,y:u*f}:{x:u*f,y:p*c}}const wf=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,h=await bf(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+h.x,y:s+h.y,data:{...h,placement:a}}}}},Cf=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:h={fn:b=>{let{x:R,y:j}=b;return{x:R,y:j}}},...f}=Ye(e,t),c={x:n,y:r},l=await s.detectOverflow(t,f),u=ze(Xe(o)),p=eo(u);let g=c[p],v=c[u];if(a){const b=p==="y"?"top":"left",R=p==="y"?"bottom":"right",j=g+l[b],_=g-l[R];g=Tr(j,g,_)}if(i){const b=u==="y"?"top":"left",R=u==="y"?"bottom":"right",j=v+l[b],_=v-l[R];v=Tr(j,v,_)}const C=h.fn({...t,[p]:g,[u]:v});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[p]:a,[u]:i}}}}}},Sf=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:h=!0,crossAxis:f=!0}=Ye(e,t),c={x:n,y:r},l=ze(o),u=eo(l);let p=c[u],g=c[l];const v=Ye(i,t),C=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(h){const j=u==="y"?"height":"width",_=s.reference[u]-s.floating[j]+C.mainAxis,$=s.reference[u]+s.reference[j]-C.mainAxis;p<_?p=_:p>$&&(p=$)}if(f){var b,R;const j=u==="y"?"width":"height",_=ba.has(Xe(o)),$=s.reference[l]-s.floating[j]+(_&&((b=a.offset)==null?void 0:b[l])||0)+(_?0:C.crossAxis),k=s.reference[l]+s.reference[j]+(_?0:((R=a.offset)==null?void 0:R[l])||0)-(_?C.crossAxis:0);g<$?g=$:g>k&&(g=k)}return{[u]:p,[l]:g}}}},kf=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:h=()=>{},...f}=Ye(e,t),c=await a.detectOverflow(t,f),l=Xe(o),u=Bt(o),p=ze(o)==="y",{width:g,height:v}=s.floating;let C,b;l==="top"||l==="bottom"?(C=l,b=u===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(b=l,C=u==="end"?"top":"bottom");const R=v-c.top-c.bottom,j=g-c.left-c.right,_=it(v-c[C],R),$=it(g-c[b],j),k=!t.middlewareData.shift;let N=_,x=$;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(x=j),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=R),k&&!u){const A=Ne(c.left,0),O=Ne(c.right,0),P=Ne(c.top,0),F=Ne(c.bottom,0);p?x=g-2*(A!==0||O!==0?A+O:Ne(c.left,c.right)):N=v-2*(P!==0||F!==0?P+F:Ne(c.top,c.bottom))}await h({...t,availableWidth:x,availableHeight:N});const y=await a.getDimensions(i.floating);return g!==y.width||v!==y.height?{reset:{rects:!0}}:{}}}};function Hn(){return typeof window<"u"}function Wt(e){return wa(e)?(e.nodeName||"").toLowerCase():"#document"}function je(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function He(e){var t;return(t=(wa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wa(e){return Hn()?e instanceof Node||e instanceof je(e).Node:!1}function Oe(e){return Hn()?e instanceof Element||e instanceof je(e).Element:!1}function Ze(e){return Hn()?e instanceof HTMLElement||e instanceof je(e).HTMLElement:!1}function ds(e){return!Hn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof je(e).ShadowRoot}function cn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function _f(e){return/^(table|td|th)$/.test(Wt(e))}function Vn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ef=/transform|translate|scale|rotate|perspective|filter/,Nf=/paint|layout|strict|content/,vt=e=>!!e&&e!=="none";let hr;function ro(e){const t=Oe(e)?De(e):e;return vt(t.transform)||vt(t.translate)||vt(t.scale)||vt(t.rotate)||vt(t.perspective)||!oo()&&(vt(t.backdropFilter)||vt(t.filter))||Ef.test(t.willChange||"")||Nf.test(t.contain||"")}function jf(e){let t=lt(e);for(;Ze(t)&&!Lt(t);){if(ro(t))return t;if(Vn(t))return null;t=lt(t)}return null}function oo(){return hr==null&&(hr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hr}function Lt(e){return/^(html|body|#document)$/.test(Wt(e))}function De(e){return je(e).getComputedStyle(e)}function Gn(e){return Oe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lt(e){if(Wt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ds(e)&&e.host||He(e);return ds(t)?t.host:t}function Ca(e){const t=lt(e);return Lt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ze(t)&&cn(t)?t:Ca(t)}function Jt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ca(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=je(o);if(s){const i=Mr(a);return t.concat(a,a.visualViewport||[],cn(o)?o:[],i&&n?Jt(i):[])}else return t.concat(o,Jt(o,[],n))}function Mr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sa(e){const t=De(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ze(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=An(n)!==s||An(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function so(e){return Oe(e)?e:e.contextElement}function Pt(e){const t=so(e);if(!Ze(t))return Be(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sa(t);let a=(s?An(n.width):n.width)/r,i=(s?An(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Af=Be(0);function ka(e){const t=je(e);return!oo()||!t.visualViewport?Af:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rf(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==je(e)?!1:t}function Ct(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=so(e);let a=Be(1);t&&(r?Oe(r)&&(a=Pt(r)):a=Pt(e));const i=Rf(s,n,r)?ka(s):Be(0);let h=(o.left+i.x)/a.x,f=(o.top+i.y)/a.y,c=o.width/a.x,l=o.height/a.y;if(s){const u=je(s),p=r&&Oe(r)?je(r):r;let g=u,v=Mr(g);for(;v&&r&&p!==g;){const C=Pt(v),b=v.getBoundingClientRect(),R=De(v),j=b.left+(v.clientLeft+parseFloat(R.paddingLeft))*C.x,_=b.top+(v.clientTop+parseFloat(R.paddingTop))*C.y;h*=C.x,f*=C.y,c*=C.x,l*=C.y,h+=j,f+=_,g=je(v),v=Mr(g)}}return Tn({width:c,height:l,x:h,y:f})}function Kn(e,t){const n=Gn(e).scrollLeft;return t?t.left+n:Ct(He(e)).left+n}function _a(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Kn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Tf(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=He(r),i=t?Vn(t.floating):!1;if(r===a||i&&s)return n;let h={scrollLeft:0,scrollTop:0},f=Be(1);const c=Be(0),l=Ze(r);if((l||!l&&!s)&&((Wt(r)!=="body"||cn(a))&&(h=Gn(r)),l)){const p=Ct(r);f=Pt(r),c.x=p.x+r.clientLeft,c.y=p.y+r.clientTop}const u=a&&!l&&!s?_a(a,h):Be(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-h.scrollLeft*f.x+c.x+u.x,y:n.y*f.y-h.scrollTop*f.y+c.y+u.y}}function If(e){return Array.from(e.getClientRects())}function Mf(e){const t=He(e),n=Gn(e),r=e.ownerDocument.body,o=Ne(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ne(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Kn(e);const i=-n.scrollTop;return De(r).direction==="rtl"&&(a+=Ne(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const us=25;function Pf(e,t){const n=je(e),r=He(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,h=0;if(o){s=o.width,a=o.height;const c=oo();(!c||c&&t==="fixed")&&(i=o.offsetLeft,h=o.offsetTop)}const f=Kn(r);if(f<=0){const c=r.ownerDocument,l=c.body,u=getComputedStyle(l),p=c.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(r.clientWidth-l.clientWidth-p);g<=us&&(s-=g)}else f<=us&&(s+=f);return{width:s,height:a,x:i,y:h}}function Of(e,t){const n=Ct(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ze(e)?Pt(e):Be(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,h=o*s.x,f=r*s.y;return{width:a,height:i,x:h,y:f}}function fs(e,t,n){let r;if(t==="viewport")r=Pf(e,n);else if(t==="document")r=Mf(He(e));else if(Oe(t))r=Of(t,n);else{const o=ka(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Tn(r)}function Ea(e,t){const n=lt(e);return n===t||!Oe(n)||Lt(n)?!1:De(n).position==="fixed"||Ea(n,t)}function Df(e,t){const n=t.get(e);if(n)return n;let r=Jt(e,[],!1).filter(i=>Oe(i)&&Wt(i)!=="body"),o=null;const s=De(e).position==="fixed";let a=s?lt(e):e;for(;Oe(a)&&!Lt(a);){const i=De(a),h=ro(a);!h&&i.position==="fixed"&&(o=null),(s?!h&&!o:!h&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||cn(a)&&!h&&Ea(e,a))?r=r.filter(c=>c!==a):o=i,a=lt(a)}return t.set(e,r),r}function Lf(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Vn(t)?[]:Df(t,this._c):[].concat(n),r],i=fs(t,a[0],o);let h=i.top,f=i.right,c=i.bottom,l=i.left;for(let u=1;u<a.length;u++){const p=fs(t,a[u],o);h=Ne(p.top,h),f=it(p.right,f),c=it(p.bottom,c),l=Ne(p.left,l)}return{width:f-l,height:c-h,x:l,y:h}}function $f(e){const{width:t,height:n}=Sa(e);return{width:t,height:n}}function Ff(e,t,n){const r=Ze(t),o=He(t),s=n==="fixed",a=Ct(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const h=Be(0);function f(){h.x=Kn(o)}if(r||!r&&!s)if((Wt(t)!=="body"||cn(o))&&(i=Gn(t)),r){const p=Ct(t,!0,s,t);h.x=p.x+t.clientLeft,h.y=p.y+t.clientTop}else o&&f();s&&!r&&o&&f();const c=o&&!r&&!s?_a(o,i):Be(0),l=a.left+i.scrollLeft-h.x-c.x,u=a.top+i.scrollTop-h.y-c.y;return{x:l,y:u,width:a.width,height:a.height}}function mr(e){return De(e).position==="static"}function hs(e,t){if(!Ze(e)||De(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return He(e)===n&&(n=n.ownerDocument.body),n}function Na(e,t){const n=je(e);if(Vn(e))return n;if(!Ze(e)){let o=lt(e);for(;o&&!Lt(o);){if(Oe(o)&&!mr(o))return o;o=lt(o)}return n}let r=hs(e,t);for(;r&&_f(r)&&mr(r);)r=hs(r,t);return r&&Lt(r)&&mr(r)&&!ro(r)?n:r||jf(e)||n}const Uf=async function(e){const t=this.getOffsetParent||Na,n=this.getDimensions,r=await n(e.floating);return{reference:Ff(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zf(e){return De(e).direction==="rtl"}const Bf={convertOffsetParentRelativeRectToViewportRelativeRect:Tf,getDocumentElement:He,getClippingRect:Lf,getOffsetParent:Na,getElementRects:Uf,getClientRects:If,getDimensions:$f,getScale:Pt,isElement:Oe,isRTL:zf};function ja(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wf(e,t){let n=null,r;const o=He(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,h){i===void 0&&(i=!1),h===void 0&&(h=1),s();const f=e.getBoundingClientRect(),{left:c,top:l,width:u,height:p}=f;if(i||t(),!u||!p)return;const g=bn(l),v=bn(o.clientWidth-(c+u)),C=bn(o.clientHeight-(l+p)),b=bn(c),j={rootMargin:-g+"px "+-v+"px "+-C+"px "+-b+"px",threshold:Ne(0,it(1,h))||1};let _=!0;function $(k){const N=k[0].intersectionRatio;if(N!==h){if(!_)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!ja(f,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver($,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver($,j)}n.observe(e)}return a(!0),s}function Hf(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:h=!1}=r,f=so(e),c=o||s?[...f?Jt(f):[],...t?Jt(t):[]]:[];c.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const l=f&&i?Wf(f,n):null;let u=-1,p=null;a&&(p=new ResizeObserver(b=>{let[R]=b;R&&R.target===f&&p&&t&&(p.unobserve(t),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var j;(j=p)==null||j.observe(t)})),n()}),f&&!h&&p.observe(f),t&&p.observe(t));let g,v=h?Ct(e):null;h&&C();function C(){const b=Ct(e);v&&!ja(v,b)&&n(),v=b,g=requestAnimationFrame(C)}return n(),()=>{var b;c.forEach(R=>{o&&R.removeEventListener("scroll",n),s&&R.removeEventListener("resize",n)}),l==null||l(),(b=p)==null||b.disconnect(),p=null,h&&cancelAnimationFrame(g)}}const Vf=wf,Gf=Cf,Kf=vf,qf=kf,Yf=yf,ms=xf,Xf=Sf,Qf=(e,t,n)=>{const r=new Map,o={platform:Bf,...n},s={...o.platform,_c:r};return gf(e,t,{...o,platform:s})};var Zf=typeof document<"u",Jf=function(){},kn=Zf?m.useLayoutEffect:Jf;function In(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!In(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!In(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Aa(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ps(e,t){const n=Aa(e);return Math.round(t*n)/n}function pr(e){const t=m.useRef(e);return kn(()=>{t.current=e}),t}function eh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:h,open:f}=e,[c,l]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[u,p]=m.useState(r);In(u,r)||p(r);const[g,v]=m.useState(null),[C,b]=m.useState(null),R=m.useCallback(L=>{L!==k.current&&(k.current=L,v(L))},[]),j=m.useCallback(L=>{L!==N.current&&(N.current=L,b(L))},[]),_=s||g,$=a||C,k=m.useRef(null),N=m.useRef(null),x=m.useRef(c),y=h!=null,A=pr(h),O=pr(o),P=pr(f),F=m.useCallback(()=>{if(!k.current||!N.current)return;const L={placement:t,strategy:n,middleware:u};O.current&&(L.platform=O.current),Qf(k.current,N.current,L).then(E=>{const I={...E,isPositioned:P.current!==!1};M.current&&!In(x.current,I)&&(x.current=I,Ps.flushSync(()=>{l(I)}))})},[u,t,n,O,P]);kn(()=>{f===!1&&x.current.isPositioned&&(x.current.isPositioned=!1,l(L=>({...L,isPositioned:!1})))},[f]);const M=m.useRef(!1);kn(()=>(M.current=!0,()=>{M.current=!1}),[]),kn(()=>{if(_&&(k.current=_),$&&(N.current=$),_&&$){if(A.current)return A.current(_,$,F);F()}},[_,$,F,A,y]);const D=m.useMemo(()=>({reference:k,floating:N,setReference:R,setFloating:j}),[R,j]),S=m.useMemo(()=>({reference:_,floating:$}),[_,$]),w=m.useMemo(()=>{const L={position:n,left:0,top:0};if(!S.floating)return L;const E=ps(S.floating,c.x),I=ps(S.floating,c.y);return i?{...L,transform:"translate("+E+"px, "+I+"px)",...Aa(S.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:I}},[n,i,S.floating,c.x,c.y]);return m.useMemo(()=>({...c,update:F,refs:D,elements:S,floatingStyles:w}),[c,F,D,S,w])}const th=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?ms({element:r.current,padding:o}).fn(n):{}:r?ms({element:r,padding:o}).fn(n):{}}}},nh=(e,t)=>{const n=Vf(e);return{name:n.name,fn:n.fn,options:[e,t]}},rh=(e,t)=>{const n=Gf(e);return{name:n.name,fn:n.fn,options:[e,t]}},oh=(e,t)=>({fn:Xf(e).fn,options:[e,t]}),sh=(e,t)=>{const n=Kf(e);return{name:n.name,fn:n.fn,options:[e,t]}},ah=(e,t)=>{const n=qf(e);return{name:n.name,fn:n.fn,options:[e,t]}},ih=(e,t)=>{const n=Yf(e);return{name:n.name,fn:n.fn,options:[e,t]}},lh=(e,t)=>{const n=th(e);return{name:n.name,fn:n.fn,options:[e,t]}};var ch="Arrow",Ra=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(ue.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ra.displayName=ch;var dh=Ra;function uh(e){const[t,n]=m.useState(void 0);return Ke(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,i;if("borderBoxSize"in s){const h=s.borderBoxSize,f=Array.isArray(h)?h[0]:h;a=f.inlineSize,i=f.blockSize}else a=e.offsetWidth,i=e.offsetHeight;n({width:a,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ao="Popper",[Ta,Ht]=Qe(ao),[fh,Ia]=Ta(ao),Ma=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return d.jsx(fh,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ma.displayName=ao;var Pa="PopperAnchor",Oa=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ia(Pa,n),a=m.useRef(null),i=pe(t,a),h=m.useRef(null);return m.useEffect(()=>{const f=h.current;h.current=(r==null?void 0:r.current)||a.current,f!==h.current&&s.onAnchorChange(h.current)}),r?null:d.jsx(ue.div,{...o,ref:i})});Oa.displayName=Pa;var io="PopperContent",[hh,mh]=Ta(io),Da=m.forwardRef((e,t)=>{var G,X,K,ne,ae,de;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:i=0,avoidCollisions:h=!0,collisionBoundary:f=[],collisionPadding:c=0,sticky:l="partial",hideWhenDetached:u=!1,updatePositionStrategy:p="optimized",onPlaced:g,...v}=e,C=Ia(io,n),[b,R]=m.useState(null),j=pe(t,me=>R(me)),[_,$]=m.useState(null),k=uh(_),N=(k==null?void 0:k.width)??0,x=(k==null?void 0:k.height)??0,y=r+(s!=="center"?"-"+s:""),A=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},O=Array.isArray(f)?f:[f],P=O.length>0,F={padding:A,boundary:O.filter(gh),altBoundary:P},{refs:M,floatingStyles:D,placement:S,isPositioned:w,middlewareData:L}=eh({strategy:"fixed",placement:y,whileElementsMounted:(...me)=>Hf(...me,{animationFrame:p==="always"}),elements:{reference:C.anchor},middleware:[nh({mainAxis:o+x,alignmentAxis:a}),h&&rh({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?oh():void 0,...F}),h&&sh({...F}),ah({...F,apply:({elements:me,rects:H,availableWidth:q,availableHeight:J})=>{const{width:te,height:ie}=H.reference,oe=me.floating.style;oe.setProperty("--radix-popper-available-width",`${q}px`),oe.setProperty("--radix-popper-available-height",`${J}px`),oe.setProperty("--radix-popper-anchor-width",`${te}px`),oe.setProperty("--radix-popper-anchor-height",`${ie}px`)}}),_&&lh({element:_,padding:i}),xh({arrowWidth:N,arrowHeight:x}),u&&ih({strategy:"referenceHidden",...F})]}),[E,I]=Fa(S),W=qe(g);Ke(()=>{w&&(W==null||W())},[w,W]);const T=(G=L.arrow)==null?void 0:G.x,B=(X=L.arrow)==null?void 0:X.y,z=((K=L.arrow)==null?void 0:K.centerOffset)!==0,[U,V]=m.useState();return Ke(()=>{b&&V(window.getComputedStyle(b).zIndex)},[b]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:w?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:U,"--radix-popper-transform-origin":[(ne=L.transformOrigin)==null?void 0:ne.x,(ae=L.transformOrigin)==null?void 0:ae.y].join(" "),...((de=L.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(hh,{scope:n,placedSide:E,onArrowChange:$,arrowX:T,arrowY:B,shouldHideArrow:z,children:d.jsx(ue.div,{"data-side":E,"data-align":I,...v,ref:j,style:{...v.style,animation:w?void 0:"none"}})})})});Da.displayName=io;var La="PopperArrow",ph={top:"bottom",right:"left",bottom:"top",left:"right"},$a=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=mh(La,r),a=ph[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(dh,{...o,ref:n,style:{...o.style,display:"block"}})})});$a.displayName=La;function gh(e){return e!==null}var xh=e=>({name:"transformOrigin",options:e,fn(t){var C,b,R;const{placement:n,rects:r,middlewareData:o}=t,a=((C=o.arrow)==null?void 0:C.centerOffset)!==0,i=a?0:e.arrowWidth,h=a?0:e.arrowHeight,[f,c]=Fa(n),l={start:"0%",center:"50%",end:"100%"}[c],u=(((b=o.arrow)==null?void 0:b.x)??0)+i/2,p=(((R=o.arrow)==null?void 0:R.y)??0)+h/2;let g="",v="";return f==="bottom"?(g=a?l:`${u}px`,v=`${-h}px`):f==="top"?(g=a?l:`${u}px`,v=`${r.floating.height+h}px`):f==="right"?(g=`${-h}px`,v=a?l:`${p}px`):f==="left"&&(g=`${r.floating.width+h}px`,v=a?l:`${p}px`),{data:{x:g,y:v}}}});function Fa(e){const[t,n="center"]=e.split("-");return[t,n]}var lo=Ma,qn=Oa,co=Da,uo=$a,vh="Portal",dn=m.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,s]=m.useState(!1);Ke(()=>s(!0),[]);const a=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return a?sc.createPortal(d.jsx(ue.div,{...r,ref:t}),a):null});dn.displayName=vh;function yh(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ae=e=>{const{present:t,children:n}=e,r=bh(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=pe(r.ref,wh(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Ae.displayName="Presence";function bh(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),a=e?"mounted":"unmounted",[i,h]=yh(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=wn(r.current);s.current=i==="mounted"?f:"none"},[i]),Ke(()=>{const f=r.current,c=o.current;if(c!==e){const u=s.current,p=wn(f);e?h("MOUNT"):p==="none"||(f==null?void 0:f.display)==="none"?h("UNMOUNT"):h(c&&u!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),Ke(()=>{if(t){let f;const c=t.ownerDocument.defaultView??window,l=p=>{const v=wn(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(h("ANIMATION_END"),!o.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",f=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},u=p=>{p.target===t&&(s.current=wn(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{c.clearTimeout(f),t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:m.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function wn(e){return(e==null?void 0:e.animationName)||"none"}function wh(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gr="rovingFocusGroup.onEntryFocus",Ch={bubbles:!1,cancelable:!0},un="RovingFocusGroup",[Pr,Ua,Sh]=ma(un),[kh,za]=Qe(un,[Sh]),[_h,Eh]=kh(un),Ba=m.forwardRef((e,t)=>d.jsx(Pr.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Pr.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Nh,{...e,ref:t})})}));Ba.displayName=un;var Nh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:h,onEntryFocus:f,preventScrollOnEntryFocus:c=!1,...l}=e,u=m.useRef(null),p=pe(t,u),g=pa(s),[v,C]=at({prop:a,defaultProp:i??null,onChange:h,caller:un}),[b,R]=m.useState(!1),j=qe(f),_=Ua(n),$=m.useRef(!1),[k,N]=m.useState(0);return m.useEffect(()=>{const x=u.current;if(x)return x.addEventListener(gr,j),()=>x.removeEventListener(gr,j)},[j]),d.jsx(_h,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(x=>C(x),[C]),onItemShiftTab:m.useCallback(()=>R(!0),[]),onFocusableItemAdd:m.useCallback(()=>N(x=>x+1),[]),onFocusableItemRemove:m.useCallback(()=>N(x=>x-1),[]),children:d.jsx(ue.div,{tabIndex:b||k===0?-1:0,"data-orientation":r,...l,ref:p,style:{outline:"none",...e.style},onMouseDown:ee(e.onMouseDown,()=>{$.current=!0}),onFocus:ee(e.onFocus,x=>{const y=!$.current;if(x.target===x.currentTarget&&y&&!b){const A=new CustomEvent(gr,Ch);if(x.currentTarget.dispatchEvent(A),!A.defaultPrevented){const O=_().filter(S=>S.focusable),P=O.find(S=>S.active),F=O.find(S=>S.id===v),D=[P,F,...O].filter(Boolean).map(S=>S.ref.current);Va(D,c)}}$.current=!1}),onBlur:ee(e.onBlur,()=>R(!1))})})}),Wa="RovingFocusGroupItem",Ha=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...i}=e,h=Ce(),f=s||h,c=Eh(Wa,n),l=c.currentTabStopId===f,u=Ua(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:v}=c;return m.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),d.jsx(Pr.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:d.jsx(ue.span,{tabIndex:l?0:-1,"data-orientation":c.orientation,...i,ref:t,onMouseDown:ee(e.onMouseDown,C=>{r?c.onItemFocus(f):C.preventDefault()}),onFocus:ee(e.onFocus,()=>c.onItemFocus(f)),onKeyDown:ee(e.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){c.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const b=Rh(C,c.orientation,c.dir);if(b!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let j=u().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")j.reverse();else if(b==="prev"||b==="next"){b==="prev"&&j.reverse();const _=j.indexOf(C.currentTarget);j=c.loop?Th(j,_+1):j.slice(_+1)}setTimeout(()=>Va(j))}}),children:typeof a=="function"?a({isCurrentTabStop:l,hasTabStop:v!=null}):a})})});Ha.displayName=Wa;var jh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ah(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Rh(e,t,n){const r=Ah(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jh[r]}function Va(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Th(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ih=Ba,Mh=Ha,Ph=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rt=new WeakMap,Cn=new WeakMap,Sn={},xr=0,Ga=function(e){return e&&(e.host||Ga(e.parentNode))},Oh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ga(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Dh=function(e,t,n,r){var o=Oh(t,Array.isArray(e)?e:[e]);Sn[n]||(Sn[n]=new WeakMap);var s=Sn[n],a=[],i=new Set,h=new Set(o),f=function(l){!l||i.has(l)||(i.add(l),f(l.parentNode))};o.forEach(f);var c=function(l){!l||h.has(l)||Array.prototype.forEach.call(l.children,function(u){if(i.has(u))c(u);else try{var p=u.getAttribute(r),g=p!==null&&p!=="false",v=(Rt.get(u)||0)+1,C=(s.get(u)||0)+1;Rt.set(u,v),s.set(u,C),a.push(u),v===1&&g&&Cn.set(u,!0),C===1&&u.setAttribute(n,"true"),g||u.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",u,b)}})};return c(t),i.clear(),xr++,function(){a.forEach(function(l){var u=Rt.get(l)-1,p=s.get(l)-1;Rt.set(l,u),s.set(l,p),u||(Cn.has(l)||l.removeAttribute(r),Cn.delete(l)),p||l.removeAttribute(n)}),xr--,xr||(Rt=new WeakMap,Rt=new WeakMap,Cn=new WeakMap,Sn={})}},fo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ph(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Dh(r,o,n,"aria-hidden")):function(){return null}},Or=["Enter"," "],Lh=["ArrowDown","PageUp","Home"],Ka=["ArrowUp","PageDown","End"],$h=[...Lh,...Ka],Fh={ltr:[...Or,"ArrowRight"],rtl:[...Or,"ArrowLeft"]},Uh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fn="Menu",[en,zh,Bh]=ma(fn),[Nt,qa]=Qe(fn,[Bh,Ht,za]),Yn=Ht(),Ya=za(),[Wh,jt]=Nt(fn),[Hh,hn]=Nt(fn),Xa=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,i=Yn(t),[h,f]=m.useState(null),c=m.useRef(!1),l=qe(s),u=pa(o);return m.useEffect(()=>{const p=()=>{c.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>c.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),d.jsx(lo,{...i,children:d.jsx(Wh,{scope:t,open:n,onOpenChange:l,content:h,onContentChange:f,children:d.jsx(Hh,{scope:t,onClose:m.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:c,dir:u,modal:a,children:r})})})};Xa.displayName=fn;var Vh="MenuAnchor",ho=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(qn,{...o,...r,ref:t})});ho.displayName=Vh;var mo="MenuPortal",[Gh,Qa]=Nt(mo,{forceMount:void 0}),Za=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=jt(mo,t);return d.jsx(Gh,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};Za.displayName=mo;var Te="MenuContent",[Kh,po]=Nt(Te),Ja=m.forwardRef((e,t)=>{const n=Qa(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu);return d.jsx(en.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(en.Slot,{scope:e.__scopeMenu,children:a.modal?d.jsx(qh,{...o,ref:t}):d.jsx(Yh,{...o,ref:t})})})})}),qh=m.forwardRef((e,t)=>{const n=jt(Te,e.__scopeMenu),r=m.useRef(null),o=pe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return fo(s)},[]),d.jsx(go,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yh=m.forwardRef((e,t)=>{const n=jt(Te,e.__scopeMenu);return d.jsx(go,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xh=Dt("MenuContent.ScrollLock"),go=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEntryFocus:h,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,onDismiss:p,disableOutsideScroll:g,...v}=e,C=jt(Te,n),b=hn(Te,n),R=Yn(n),j=Ya(n),_=zh(n),[$,k]=m.useState(null),N=m.useRef(null),x=pe(t,N,C.onContentChange),y=m.useRef(0),A=m.useRef(""),O=m.useRef(0),P=m.useRef(null),F=m.useRef("right"),M=m.useRef(0),D=g?Kr:m.Fragment,S=g?{as:Xh,allowPinchZoom:!0}:void 0,w=E=>{var G,X;const I=A.current+E,W=_().filter(K=>!K.disabled),T=document.activeElement,B=(G=W.find(K=>K.ref.current===T))==null?void 0:G.textValue,z=W.map(K=>K.textValue),U=lm(z,I,B),V=(X=W.find(K=>K.textValue===U))==null?void 0:X.ref.current;(function K(ne){A.current=ne,window.clearTimeout(y.current),ne!==""&&(y.current=window.setTimeout(()=>K(""),1e3))})(I),V&&setTimeout(()=>V.focus())};m.useEffect(()=>()=>window.clearTimeout(y.current),[]),Jr();const L=m.useCallback(E=>{var W,T;return F.current===((W=P.current)==null?void 0:W.side)&&dm(E,(T=P.current)==null?void 0:T.area)},[]);return d.jsx(Kh,{scope:n,searchRef:A,onItemEnter:m.useCallback(E=>{L(E)&&E.preventDefault()},[L]),onItemLeave:m.useCallback(E=>{var I;L(E)||((I=N.current)==null||I.focus(),k(null))},[L]),onTriggerLeave:m.useCallback(E=>{L(E)&&E.preventDefault()},[L]),pointerGraceTimerRef:O,onPointerGraceIntentChange:m.useCallback(E=>{P.current=E},[]),children:d.jsx(D,{...S,children:d.jsx(Wn,{asChild:!0,trapped:o,onMountAutoFocus:ee(s,E=>{var I;E.preventDefault(),(I=N.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,onDismiss:p,children:d.jsx(Ih,{asChild:!0,...j,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:$,onCurrentTabStopIdChange:k,onEntryFocus:ee(h,E=>{b.isUsingKeyboardRef.current||E.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(co,{role:"menu","aria-orientation":"vertical","data-state":pi(C.open),"data-radix-menu-content":"",dir:b.dir,...R,...v,ref:x,style:{outline:"none",...v.style},onKeyDown:ee(v.onKeyDown,E=>{const W=E.target.closest("[data-radix-menu-content]")===E.currentTarget,T=E.ctrlKey||E.altKey||E.metaKey,B=E.key.length===1;W&&(E.key==="Tab"&&E.preventDefault(),!T&&B&&w(E.key));const z=N.current;if(E.target!==z||!$h.includes(E.key))return;E.preventDefault();const V=_().filter(G=>!G.disabled).map(G=>G.ref.current);Ka.includes(E.key)&&V.reverse(),am(V)}),onBlur:ee(e.onBlur,E=>{E.currentTarget.contains(E.target)||(window.clearTimeout(y.current),A.current="")}),onPointerMove:ee(e.onPointerMove,tn(E=>{const I=E.target,W=M.current!==E.clientX;if(E.currentTarget.contains(I)&&W){const T=E.clientX>M.current?"right":"left";F.current=T,M.current=E.clientX}}))})})})})})})});Ja.displayName=Te;var Qh="MenuGroup",xo=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"group",...r,ref:t})});xo.displayName=Qh;var Zh="MenuLabel",ei=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{...r,ref:t})});ei.displayName=Zh;var Mn="MenuItem",gs="menu.itemSelect",Xn=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),a=hn(Mn,e.__scopeMenu),i=po(Mn,e.__scopeMenu),h=pe(t,s),f=m.useRef(!1),c=()=>{const l=s.current;if(!n&&l){const u=new CustomEvent(gs,{bubbles:!0,cancelable:!0});l.addEventListener(gs,p=>r==null?void 0:r(p),{once:!0}),ha(l,u),u.defaultPrevented?f.current=!1:a.onClose()}};return d.jsx(ti,{...o,ref:h,disabled:n,onClick:ee(e.onClick,c),onPointerDown:l=>{var u;(u=e.onPointerDown)==null||u.call(e,l),f.current=!0},onPointerUp:ee(e.onPointerUp,l=>{var u;f.current||(u=l.currentTarget)==null||u.click()}),onKeyDown:ee(e.onKeyDown,l=>{const u=i.searchRef.current!=="";n||u&&l.key===" "||Or.includes(l.key)&&(l.currentTarget.click(),l.preventDefault())})})});Xn.displayName=Mn;var ti=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=po(Mn,n),i=Ya(n),h=m.useRef(null),f=pe(t,h),[c,l]=m.useState(!1),[u,p]=m.useState("");return m.useEffect(()=>{const g=h.current;g&&p((g.textContent??"").trim())},[s.children]),d.jsx(en.ItemSlot,{scope:n,disabled:r,textValue:o??u,children:d.jsx(Mh,{asChild:!0,...i,focusable:!r,children:d.jsx(ue.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:ee(e.onPointerMove,tn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ee(e.onPointerLeave,tn(g=>a.onItemLeave(g))),onFocus:ee(e.onFocus,()=>l(!0)),onBlur:ee(e.onBlur,()=>l(!1))})})})}),Jh="MenuCheckboxItem",ni=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(ii,{scope:e.__scopeMenu,checked:n,children:d.jsx(Xn,{role:"menuitemcheckbox","aria-checked":Pn(n)?"mixed":n,...o,ref:t,"data-state":yo(n),onSelect:ee(o.onSelect,()=>r==null?void 0:r(Pn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ni.displayName=Jh;var ri="MenuRadioGroup",[em,tm]=Nt(ri,{value:void 0,onValueChange:()=>{}}),oi=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=qe(r);return d.jsx(em,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(xo,{...o,ref:t})})});oi.displayName=ri;var si="MenuRadioItem",ai=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=tm(si,e.__scopeMenu),s=n===o.value;return d.jsx(ii,{scope:e.__scopeMenu,checked:s,children:d.jsx(Xn,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":yo(s),onSelect:ee(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});ai.displayName=si;var vo="MenuItemIndicator",[ii,nm]=Nt(vo,{checked:!1}),li=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=nm(vo,n);return d.jsx(Ae,{present:r||Pn(s.checked)||s.checked===!0,children:d.jsx(ue.span,{...o,ref:t,"data-state":yo(s.checked)})})});li.displayName=vo;var rm="MenuSeparator",ci=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ci.displayName=rm;var om="MenuArrow",di=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(uo,{...o,...r,ref:t})});di.displayName=om;var sm="MenuSub",[ny,ui]=Nt(sm),Xt="MenuSubTrigger",fi=m.forwardRef((e,t)=>{const n=jt(Xt,e.__scopeMenu),r=hn(Xt,e.__scopeMenu),o=ui(Xt,e.__scopeMenu),s=po(Xt,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:h}=s,f={__scopeMenu:e.__scopeMenu},c=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>c,[c]),m.useEffect(()=>{const l=i.current;return()=>{window.clearTimeout(l),h(null)}},[i,h]),d.jsx(ho,{asChild:!0,...f,children:d.jsx(ti,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pi(n.open),...e,ref:We(t,o.onTriggerChange),onClick:l=>{var u;(u=e.onClick)==null||u.call(e,l),!(e.disabled||l.defaultPrevented)&&(l.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ee(e.onPointerMove,tn(l=>{s.onItemEnter(l),!l.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:ee(e.onPointerLeave,tn(l=>{var p,g;c();const u=(p=n.content)==null?void 0:p.getBoundingClientRect();if(u){const v=(g=n.content)==null?void 0:g.dataset.side,C=v==="right",b=C?-5:5,R=u[C?"left":"right"],j=u[C?"right":"left"];s.onPointerGraceIntentChange({area:[{x:l.clientX+b,y:l.clientY},{x:R,y:u.top},{x:j,y:u.top},{x:j,y:u.bottom},{x:R,y:u.bottom}],side:v}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(l),l.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ee(e.onKeyDown,l=>{var p;const u=s.searchRef.current!=="";e.disabled||u&&l.key===" "||Fh[r.dir].includes(l.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),l.preventDefault())})})})});fi.displayName=Xt;var hi="MenuSubContent",mi=m.forwardRef((e,t)=>{const n=Qa(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu),i=ui(hi,e.__scopeMenu),h=m.useRef(null),f=pe(t,h);return d.jsx(en.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(en.Slot,{scope:e.__scopeMenu,children:d.jsx(go,{id:i.contentId,"aria-labelledby":i.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{var l;a.isUsingKeyboardRef.current&&((l=h.current)==null||l.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:ee(e.onFocusOutside,c=>{c.target!==i.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ee(e.onEscapeKeyDown,c=>{a.onClose(),c.preventDefault()}),onKeyDown:ee(e.onKeyDown,c=>{var p;const l=c.currentTarget.contains(c.target),u=Uh[a.dir].includes(c.key);l&&u&&(s.onOpenChange(!1),(p=i.trigger)==null||p.focus(),c.preventDefault())})})})})})});mi.displayName=hi;function pi(e){return e?"open":"closed"}function Pn(e){return e==="indeterminate"}function yo(e){return Pn(e)?"indeterminate":e?"checked":"unchecked"}function am(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function im(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function lm(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=im(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const h=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return h!==n?h:void 0}function cm(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],h=t[a],f=i.x,c=i.y,l=h.x,u=h.y;c>r!=u>r&&n<(l-f)*(r-c)/(u-c)+f&&(o=!o)}return o}function dm(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return cm(n,t)}function tn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var um=Xa,fm=ho,hm=Za,mm=Ja,pm=xo,gm=ei,xm=Xn,vm=ni,ym=oi,bm=ai,wm=li,Cm=ci,Sm=di,km=fi,_m=mi,Qn="DropdownMenu",[Em]=Qe(Qn,[qa]),Se=qa(),[Nm,gi]=Em(Qn),xi=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,h=Se(t),f=m.useRef(null),[c,l]=at({prop:o,defaultProp:s??!1,onChange:a,caller:Qn});return d.jsx(Nm,{scope:t,triggerId:Ce(),triggerRef:f,contentId:Ce(),open:c,onOpenChange:l,onOpenToggle:m.useCallback(()=>l(u=>!u),[l]),modal:i,children:d.jsx(um,{...h,open:c,onOpenChange:l,dir:r,modal:i,children:n})})};xi.displayName=Qn;var vi="DropdownMenuTrigger",yi=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=gi(vi,n),a=Se(n);return d.jsx(fm,{asChild:!0,...a,children:d.jsx(ue.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:We(t,s.triggerRef),onPointerDown:ee(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(s.onOpenToggle(),s.open||i.preventDefault())}),onKeyDown:ee(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&s.onOpenToggle(),i.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});yi.displayName=vi;var jm="DropdownMenuPortal",bi=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Se(t);return d.jsx(hm,{...r,...n})};bi.displayName=jm;var wi="DropdownMenuContent",Ci=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gi(wi,n),s=Se(n),a=m.useRef(!1);return d.jsx(mm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ee(e.onCloseAutoFocus,i=>{var h;a.current||(h=o.triggerRef.current)==null||h.focus(),a.current=!1,i.preventDefault()}),onInteractOutside:ee(e.onInteractOutside,i=>{const h=i.detail.originalEvent,f=h.button===0&&h.ctrlKey===!0,c=h.button===2||f;(!o.modal||c)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ci.displayName=wi;var Am="DropdownMenuGroup",Rm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(pm,{...o,...r,ref:t})});Rm.displayName=Am;var Tm="DropdownMenuLabel",Im=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(gm,{...o,...r,ref:t})});Im.displayName=Tm;var Mm="DropdownMenuItem",Si=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(xm,{...o,...r,ref:t})});Si.displayName=Mm;var Pm="DropdownMenuCheckboxItem",Om=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(vm,{...o,...r,ref:t})});Om.displayName=Pm;var Dm="DropdownMenuRadioGroup",Lm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(ym,{...o,...r,ref:t})});Lm.displayName=Dm;var $m="DropdownMenuRadioItem",Fm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(bm,{...o,...r,ref:t})});Fm.displayName=$m;var Um="DropdownMenuItemIndicator",zm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(wm,{...o,...r,ref:t})});zm.displayName=Um;var Bm="DropdownMenuSeparator",Wm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Cm,{...o,...r,ref:t})});Wm.displayName=Bm;var Hm="DropdownMenuArrow",Vm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Sm,{...o,...r,ref:t})});Vm.displayName=Hm;var Gm="DropdownMenuSubTrigger",Km=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(km,{...o,...r,ref:t})});Km.displayName=Gm;var qm="DropdownMenuSubContent",Ym=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(_m,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ym.displayName=qm;var Xm=xi,Qm=yi,Zm=bi,Jm=Ci,ep=Si;function tp({...e}){return d.jsx(Xm,{"data-slot":"dropdown-menu",...e})}function np({...e}){return d.jsx(Qm,{"data-slot":"dropdown-menu-trigger",...e})}function rp({className:e,sideOffset:t=4,...n}){return d.jsx(Zm,{children:d.jsx(Jm,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function op({className:e,inset:t,variant:n="default",...r}){return d.jsx(ep,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Z("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}const sp=[{value:"light",label:"Light",icon:d.jsx(oa,{className:"h-4 w-4"})},{value:"dark",label:"Dark",icon:d.jsx(ra,{className:"h-4 w-4"})},{value:"system",label:"System",icon:d.jsx(Dd,{className:"h-4 w-4"})}];function ap(){const{theme:e,setTheme:t,resolvedTheme:n}=ca();return d.jsxs(tp,{children:[d.jsx(np,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[n==="dark"?d.jsx(ra,{className:"h-4 w-4"}):d.jsx(oa,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),d.jsx(rp,{align:"end",children:sp.map(r=>d.jsxs(op,{onClick:()=>t(r.value),className:e===r.value?"bg-accent":"",children:[r.icon,d.jsx("span",{className:"ml-2",children:r.label})]},r.value))})]})}function ip({onIdentityClick:e,onTokenClick:t,activeTokenLabel:n,sessionTitle:r,sessionSource:o,onBack:s}){return d.jsx("nav",{className:"sticky top-0 z-40 border-b border-border bg-surface-1/80 backdrop-blur-md",children:d.jsxs("div",{className:"mx-auto flex h-11 sm:h-12 max-w-5xl items-center justify-between px-3 sm:px-4",children:[r?d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors flex-shrink-0",children:[d.jsx(pd,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Dashboard"})]}),d.jsx("span",{className:"text-text-muted/40",children:"/"}),d.jsx("span",{className:"text-sm font-display font-medium text-text-primary truncate",children:r}),o&&d.jsx("span",{className:"rounded-full bg-brand/15 px-2 py-0.5 text-[10px] font-medium text-brand flex-shrink-0",children:o==="acp"?"ACP":"RCS"})]}):d.jsxs("a",{href:"/code/",className:"flex items-center gap-2 font-display text-lg font-semibold text-text-primary no-underline",children:[d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"flex-shrink-0",children:d.jsx("path",{d:"M10 1L12.2 7.8L19 10L12.2 12.2L10 19L7.8 12.2L1 10L7.8 7.8L10 1Z",fill:"var(--color-brand)"})}),d.jsx("span",{className:"hidden sm:inline",children:"Remote Control"})]}),d.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[!r&&d.jsxs("a",{href:"/code/",className:"flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm text-text-secondary hover:bg-surface-2 hover:text-text-primary no-underline transition-colors",title:"Dashboard",children:[d.jsx(Td,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Dashboard"})]}),d.jsx(ap,{}),d.jsxs("button",{onClick:t,className:Z("flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm transition-colors",n?"bg-brand/10 text-text-primary hover:bg-brand-light hover:text-white":"text-text-primary font-bold hover:bg-brand-light hover:text-white"),title:"Token Manager",children:[d.jsx(ta,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline max-w-24 truncate font-bold",children:n||"No Token"})]}),d.jsxs("button",{onClick:e,className:"flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",title:"Identity & QR",children:[d.jsx(pu,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline font-bold",children:"Identity"})]})]})]})})}function ry({status:e}){const t={active:"bg-status-active/20 text-status-active",running:"bg-status-running/20 text-status-running",idle:"bg-status-idle/20 text-status-idle",inactive:"bg-text-muted/20 text-text-muted",requires_action:"bg-status-warning/20 text-status-warning",archived:"bg-text-muted/20 text-text-muted",error:"bg-status-error/20 text-status-error"};return d.jsx("span",{className:Z("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",t[e]||"bg-surface-3 text-text-secondary"),children:e})}let $t=class ce{constructor(t,n,r,o,s){this._legacyCanvasSize=ce.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),r&&typeof r=="object"?this._onDecode=n:(console.warn(r||o||s?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof r=="object"?r:{},this._onDecodeError=n.onDecodeError||(typeof r=="function"?r:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||s||this._preferredCamera,this._legacyCanvasSize=typeof r=="number"?r:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let a=!1;if(t.hidden&&(t.hidden=!1,a=!0),document.body.contains(t)||(document.body.appendChild(t),a=!0),r=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),s=this.$overlay.style,s.position="absolute",s.display="none",s.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}r.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let i=window.getComputedStyle(t);i.display==="none"&&(t.style.setProperty("display","block","important"),a=!0),i.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),a=!0),a&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=ce.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await ce.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),r;try{t&&(await n()).every(o=>!o.label)&&(r=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,s)=>({id:o.deviceId,label:o.label||(s===0?"Default Camera":`Camera ${s+1}`)}))}finally{r&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),ce._stopVideoStream(r))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),ce._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),ce._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?ce._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(ce._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(r=>setTimeout(r,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,r,o,s=!1,a=!1){let i,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(i=n.scanRegion,r=n.qrEngine,o=n.canvas,s=n.disallowCanvasResizing||!1,a=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||r||o||s||a?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!r;try{let f,c;[r,f]=await Promise.all([r||ce.createQrEngine(),ce._loadImage(t)]),[o,c]=ce._drawToCanvas(f,i,o,s);let l;if(r instanceof Worker){let u=r;n||ce._postWorkerMessageSync(u,"inversionMode","both"),l=await new Promise((p,g)=>{let v,C,b,R=-1;C=_=>{_.data.id===R&&(u.removeEventListener("message",C),u.removeEventListener("error",b),clearTimeout(v),_.data.data!==null?p({data:_.data.data,cornerPoints:ce._convertPoints(_.data.cornerPoints,i)}):g(ce.NO_QR_CODE_FOUND))},b=_=>{u.removeEventListener("message",C),u.removeEventListener("error",b),clearTimeout(v),g("Scanner error: "+(_?_.message||_:"Unknown Error"))},u.addEventListener("message",C),u.addEventListener("error",b),v=setTimeout(()=>b("timeout"),1e4);let j=c.getImageData(0,0,o.width,o.height);R=ce._postWorkerMessageSync(u,"decode",j,[j.data.buffer])})}else l=await Promise.race([new Promise((u,p)=>window.setTimeout(()=>p("Scanner error: timeout"),1e4)),(async()=>{try{var[u]=await r.detect(o);if(!u)throw ce.NO_QR_CODE_FOUND;return{data:u.rawValue,cornerPoints:ce._convertPoints(u.cornerPoints,i)}}catch(p){if(u=p.message||p,/not implemented|service unavailable/.test(u))return ce._disableBarcodeDetector=!0,ce.scanImage(t,{scanRegion:i,canvas:o,disallowCanvasResizing:s,alsoTryWithoutScanRegion:a});throw`Scanner error: ${u}`}})()]);return h?l:l.data}catch(f){if(!i||!a)throw f;let c=await ce.scanImage(t,{qrEngine:r,canvas:o,disallowCanvasResizing:s});return h?c:c.data}finally{n||ce._postWorkerMessage(r,"close")}}setGrayscaleWeights(t,n,r,o=!0){ce._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:r,useIntegerApproximation:o})}setInversionMode(t){ce._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>on(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(r=>r.createWorker()),!(!ce._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:r})=>/Chromium/i.test(r))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:r,platformVersion:o})=>/arm/i.test(r||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,r=t.videoHeight,o=t.offsetWidth,s=t.offsetHeight,a=t.offsetLeft,i=t.offsetTop,h=window.getComputedStyle(t),f=h.objectFit,c=n/r,l=o/s;switch(f){case"none":var u=n,p=r;break;case"fill":u=o,p=s;break;default:(f==="cover"?c>l:c<l)?(p=s,u=p*c):(u=o,p=u/c),f==="scale-down"&&(u=Math.min(u,n),p=Math.min(p,r))}var[g,v]=h.objectPosition.split(" ").map((b,R)=>{const j=parseFloat(b);return b.endsWith("%")?(R?s-p:o-u)*j/100:j});h=this._scanRegion.width||n,l=this._scanRegion.height||r,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;c=this.$overlay.style,c.width=`${h/n*u}px`,c.height=`${l/r*p}px`,c.top=`${i+v+C/r*p}px`,r=/scaleX\(-1\)/.test(t.style.transform),c.left=`${a+(r?o-g-u:g)+(r?n-f-h:f)/n*u}px`,c.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let r=n.x||0,o=n.y||0,s=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let a of t)a.x=a.x*s+r,a.y=a.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var r=await ce.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!ce._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=ce.createQrEngine()),r?(this._onDecode?this._onDecode(r):this._legacyOnDecode&&this._legacyOnDecode(r.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",r.cornerPoints.map(({x:o,y:s})=>`${o},${s}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==ce.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],r=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...r,...n])try{let s=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),a=this._getFacingMode(s)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:s,facingMode:a}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,r,o=!1){r=r||document.createElement("canvas");let s=n&&n.x?n.x:0,a=n&&n.y?n.y:0,i=n&&n.width?n.width:t.videoWidth||t.width,h=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:i,n=n&&n.downScaledHeight?n.downScaledHeight:h,r.width!==o&&(r.width=o),r.height!==n&&(r.height=n)),n=r.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,s,a,i,h,0,0,r.width,r.height),[r,n]}static async _loadImage(t){if(t instanceof Image)return await ce._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await ce._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,r)=>{let o=s=>{t.removeEventListener("load",o),t.removeEventListener("error",o),s instanceof ErrorEvent?r("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,r,o){return ce._postWorkerMessageSync(await t,n,r,o)}static _postWorkerMessageSync(t,n,r,o){if(!(t instanceof Worker))return-1;let s=ce._workerMessageId++;return t.postMessage({id:s,type:n,data:r},o),s}};$t.DEFAULT_CANVAS_SIZE=400;$t.NO_QR_CODE_FOUND="No QR code found";$t._disableBarcodeDetector=!1;$t._workerMessageId=0;const lp="";function bo(){let e=localStorage.getItem("rcs_uuid");return e||(e=nd(),localStorage.setItem("rcs_uuid",e)),e}function _n(e){try{const t=localStorage.getItem("rcs_uuid");t&&t!==e&&!localStorage.getItem("rcs_uuid_previous")&&localStorage.setItem("rcs_uuid_previous",t)}catch{}localStorage.setItem("rcs_uuid",e)}function Dr(){try{return localStorage.getItem("rcs_uuid_previous")}catch{return null}}function cp(){const e=Dr();if(!e)return!1;try{localStorage.setItem("rcs_uuid",e),localStorage.removeItem("rcs_uuid_previous")}catch{return!1}return!0}let On=null;function dp(e){On=e}function oy(){return On}const ki="rcs_worker_token_",_i="rcs_worker_tokens";function Zn(){try{const e=localStorage.getItem(_i);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&typeof n.envId=="string"&&typeof n.token=="string"):[]}catch{return[]}}function Ei(e){try{localStorage.setItem(_i,JSON.stringify(e))}catch{}}function Lr(e){var n;return e?((n=Zn().find(r=>r.envId===e))==null?void 0:n.token)??null:null}function up(e,t,n){const r=Zn(),o=r.findIndex(s=>s.envId===e);o>=0?r[o]={...r[o],token:t,label:n??r[o].label}:r.push({envId:e,token:t,label:n}),Ei(r)}function fp(e){const t=Zn().filter(n=>n.envId!==e);Ei(t)}function Qt(){return Zn()}const $r=new Map;function sy(e,t){t?$r.set(e,t):$r.delete(e)}function hp(e){const t=$r.get(e);if(t){const n=Lr(t);if(n)return n}try{return localStorage.getItem(ki+e)}catch{return null}}function ay(e,t){try{localStorage.setItem(ki+e,t)}catch{}}class mp extends Error{constructor(n,r,o){super(n);le(this,"type");le(this,"status");this.name="ApiError",this.type=r,this.status=o}}async function Ie(e,t,n){const r={"Content-Type":"application/json"};On&&(r.Authorization=`Bearer ${On}`);const o=t.match(/^\/web\/sessions\/([^/]+)/);if(o){const l=o[1],u=hp(l);u&&(r["X-Worker-Token"]=u)}const s=bo(),a=t.includes("?")?"&":"?",i=`${lp}${t}${a}uuid=${encodeURIComponent(s)}`,h={method:e,headers:r};n!==void 0&&(h.body=JSON.stringify(n));const f=await fetch(i,h),c=await f.json();if(!f.ok){const l=c.error||{type:"unknown",message:f.statusText};throw new mp(l.message||l.type,l.type||"unknown",f.status)}return c}function pp(e){return Ie("POST","/web/bind",{sessionId:e})}function iy(){return Ie("GET","/web/sessions/all")}function ly(e){return Ie("GET",`/web/sessions/${e}`)}function cy(e){return Ie("GET",`/web/sessions/${e}/history`)}function gp(){return Ie("GET","/web/environments")}function xp(e,t){return Ie("POST",`/web/environments/${e}/test-worker-token`,{token:t})}function vp(){return Ie("GET","/web/server-info")}function dy(e,t){return Ie("POST",`/web/sessions/${e}/events`,t)}function uy(e,t){return Ie("POST",`/web/sessions/${e}/control`,t)}function fy(e){return Ie("POST",`/web/sessions/${e}/interrupt`)}function hy(e){return Ie("DELETE",`/web/sessions/${e}`)}function my(e){return Ie("POST","/web/sessions",e)}var Jn="Dialog",[Ni]=Qe(Jn),[yp,Le]=Ni(Jn),ji=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,i=m.useRef(null),h=m.useRef(null),[f,c]=at({prop:r,defaultProp:o??!1,onChange:s,caller:Jn});return d.jsx(yp,{scope:t,triggerRef:i,contentRef:h,contentId:Ce(),titleId:Ce(),descriptionId:Ce(),open:f,onOpenChange:c,onOpenToggle:m.useCallback(()=>c(l=>!l),[c]),modal:a,children:n})};ji.displayName=Jn;var Ai="DialogTrigger",bp=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Ai,n),s=pe(t,o.triggerRef);return d.jsx(ue.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":So(o.open),...r,ref:s,onClick:ee(e.onClick,o.onOpenToggle)})});bp.displayName=Ai;var wo="DialogPortal",[wp,Ri]=Ni(wo,{forceMount:void 0}),Ti=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Le(wo,t);return d.jsx(wp,{scope:t,forceMount:n,children:m.Children.map(r,a=>d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:a})}))})};Ti.displayName=wo;var Dn="DialogOverlay",Ii=m.forwardRef((e,t)=>{const n=Ri(Dn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Le(Dn,e.__scopeDialog);return s.modal?d.jsx(Ae,{present:r||s.open,children:d.jsx(Sp,{...o,ref:t})}):null});Ii.displayName=Dn;var Cp=Dt("DialogOverlay.RemoveScroll"),Sp=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Dn,n);return d.jsx(Kr,{as:Cp,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(ue.div,{"data-state":So(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),St="DialogContent",Mi=m.forwardRef((e,t)=>{const n=Ri(St,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Le(St,e.__scopeDialog);return d.jsx(Ae,{present:r||s.open,children:s.modal?d.jsx(kp,{...o,ref:t}):d.jsx(_p,{...o,ref:t})})});Mi.displayName=St;var kp=m.forwardRef((e,t)=>{const n=Le(St,e.__scopeDialog),r=m.useRef(null),o=pe(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return fo(s)},[]),d.jsx(Pi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,i=a.button===0&&a.ctrlKey===!0;(a.button===2||i)&&s.preventDefault()}),onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault())})}),_p=m.forwardRef((e,t)=>{const n=Le(St,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return d.jsx(Pi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,i;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var h,f;(h=e.onInteractOutside)==null||h.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Pi=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,i=Le(St,n),h=m.useRef(null),f=pe(t,h);return Jr(),d.jsxs(d.Fragment,{children:[d.jsx(Wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(ln,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":So(i.open),...a,ref:f,onDismiss:()=>i.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Ep,{titleId:i.titleId}),d.jsx(jp,{contentRef:h,descriptionId:i.descriptionId})]})]})}),Co="DialogTitle",Oi=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Co,n);return d.jsx(ue.h2,{id:o.titleId,...r,ref:t})});Oi.displayName=Co;var Di="DialogDescription",Li=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Di,n);return d.jsx(ue.p,{id:o.descriptionId,...r,ref:t})});Li.displayName=Di;var $i="DialogClose",Fi=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le($i,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});Fi.displayName=$i;function So(e){return e?"open":"closed"}var Ui="DialogTitleWarning",[py,zi]=Au(Ui,{contentName:St,titleName:Co,docsSlug:"dialog"}),Ep=({titleId:e})=>{const t=zi(Ui),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
227
+ */const xu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],an=re("x",xu),ia=m.createContext(void 0),la="theme";function Go(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ko(){if(typeof window>"u")return"system";try{const e=localStorage.getItem(la);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function qo(e){const t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e)}function ca(){const e=m.useContext(ia);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function vu({children:e,defaultTheme:t="system"}){const[n,r]=m.useState(()=>Ko()||t),[o,s]=m.useState(()=>{const h=Ko()||t;return h==="system"?Go():h}),a=m.useCallback(h=>{r(h);try{localStorage.setItem(la,h)}catch{}},[]);m.useEffect(()=>{const h=n==="system"?Go():n;s(h),qo(h)},[n]),m.useEffect(()=>{if(n!=="system")return;const h=window.matchMedia("(prefers-color-scheme: dark)"),f=c=>{const l=c.matches?"dark":"light";s(l),qo(l)};return h.addEventListener("change",f),()=>h.removeEventListener("change",f)},[n]);const i={theme:n,resolvedTheme:o,setTheme:a};return rt.createElement(ia.Provider,{value:i},e)}function Yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function We(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Yo(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Yo(e[o],null)}}}}function pe(...e){return m.useCallback(We(...e),e)}var bu=Symbol.for("react.lazy"),jn=Gr[" use ".trim().toString()];function yu(e){return typeof e=="object"&&e!==null&&"then"in e}function da(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===bu&&"_payload"in e&&yu(e._payload)}function ua(e){const t=Cu(e),n=m.forwardRef((r,o)=>{let{children:s,...a}=r;da(s)&&typeof jn=="function"&&(s=jn(s._payload));const i=m.Children.toArray(s),h=i.find(ku);if(h){const f=h.props.children,c=i.map(l=>l===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:l);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,c):null})}return d.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var wu=ua("Slot");function Cu(e){const t=m.forwardRef((n,r)=>{let{children:o,...s}=n;if(da(o)&&typeof jn=="function"&&(o=jn(o._payload)),m.isValidElement(o)){const a=Eu(o),i=_u(s,o.props);return o.type!==m.Fragment&&(i.ref=r?We(r,a):a),m.cloneElement(o,i)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Su=Symbol("radix.slottable");function ku(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Su}function _u(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{const h=s(...i);return o(...i),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Eu(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Xo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Qo=Ds,Nu=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Qo(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,a=Object.keys(o).map(f=>{const c=n==null?void 0:n[f],l=s==null?void 0:s[f];if(c===null)return null;const u=Xo(c)||Xo(l);return o[f][u]}),i=n&&Object.entries(n).reduce((f,c)=>{let[l,u]=c;return u===void 0||(f[l]=u),f},{}),h=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((f,c)=>{let{class:l,className:u,...p}=c;return Object.entries(p).every(g=>{let[v,C]=g;return Array.isArray(C)?C.includes({...s,...i}[v]):{...s,...i}[v]===C})?[...f,l,u]:f},[]);return Qo(e,a,h,n==null?void 0:n.class,n==null?void 0:n.className)},ju=Nu("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Et({className:e,variant:t,size:n,asChild:r=!1,...o}){const s=r?wu:"button";return d.jsx(s,{"data-slot":"button",className:Z(ju({variant:t,size:n,className:e})),...o})}function ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Au(e,t){const n=m.createContext(t),r=s=>{const{children:a,...i}=s,h=m.useMemo(()=>i,Object.values(i));return d.jsx(n.Provider,{value:h,children:a})};r.displayName=e+"Provider";function o(s){const a=m.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Qe(e,t=[]){let n=[];function r(s,a){const i=m.createContext(a),h=n.length;n=[...n,a];const f=l=>{var y;const{scope:u,children:p,...g}=l,v=((y=u==null?void 0:u[e])==null?void 0:y[h])||i,C=m.useMemo(()=>g,Object.values(g));return d.jsx(v.Provider,{value:C,children:p})};f.displayName=s+"Provider";function c(l,u){var v;const p=((v=u==null?void 0:u[e])==null?void 0:v[h])||i,g=m.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${l}\` must be used within \`${s}\``)}return[f,c]}const o=()=>{const s=n.map(a=>m.createContext(a));return function(i){const h=(i==null?void 0:i[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...i,[e]:h}}),[i,h])}};return o.scopeName=e,[r,Ru(o,...t)]}function Ru(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((i,{useScope:h,scopeName:f})=>{const l=h(s)[`__scope${f}`];return{...i,...l}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ke=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Tu=Gr[" useInsertionEffect ".trim().toString()]||Ke;function at({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=Iu({defaultProp:t,onChange:n}),i=e!==void 0,h=i?e:o;{const c=m.useRef(e!==void 0);m.useEffect(()=>{const l=c.current;l!==i&&console.warn(`${r} is changing from ${l?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=i},[i,r])}const f=m.useCallback(c=>{var l;if(i){const u=Mu(c)?c(e):c;u!==e&&((l=a.current)==null||l.call(a,u))}else s(c)},[i,e,s,a]);return[h,f]}function Iu({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Tu(()=>{s.current=t},[t]),m.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mu(e){return typeof e=="function"}function Dt(e){const t=Pu(e),n=m.forwardRef((r,o)=>{const{children:s,...a}=r,i=m.Children.toArray(s),h=i.find(Du);if(h){const f=h.props.children,c=i.map(l=>l===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:l);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,c):null})}return d.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}function Pu(e){const t=m.forwardRef((n,r)=>{const{children:o,...s}=n;if(m.isValidElement(o)){const a=$u(o),i=Lu(s,o.props);return o.type!==m.Fragment&&(i.ref=r?We(r,a):a),m.cloneElement(o,i)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fa=Symbol("radix.slottable");function Ou(e){const t=({children:n})=>d.jsx(d.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=fa,t}function Du(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fa}function Lu(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...i)=>{const h=s(...i);return o(...i),h}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $u(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ue=Fu.reduce((e,t)=>{const n=Dt(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,h=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ha(e,t){e&&Ps.flushSync(()=>e.dispatchEvent(t))}function ma(e){const t=e+"CollectionProvider",[n,r]=Qe(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:C,children:y}=v,R=rt.useRef(null),j=rt.useRef(new Map).current;return d.jsx(o,{scope:C,itemMap:j,collectionRef:R,children:y})};a.displayName=t;const i=e+"CollectionSlot",h=Dt(i),f=rt.forwardRef((v,C)=>{const{scope:y,children:R}=v,j=s(i,y),_=pe(C,j.collectionRef);return d.jsx(h,{ref:_,children:R})});f.displayName=i;const c=e+"CollectionItemSlot",l="data-radix-collection-item",u=Dt(c),p=rt.forwardRef((v,C)=>{const{scope:y,children:R,...j}=v,_=rt.useRef(null),$=pe(C,_),k=s(c,y);return rt.useEffect(()=>(k.itemMap.set(_,{ref:_,...j}),()=>void k.itemMap.delete(_))),d.jsx(u,{[l]:"",ref:$,children:R})});p.displayName=c;function g(v){const C=s(e+"CollectionConsumer",v);return rt.useCallback(()=>{const R=C.collectionRef.current;if(!R)return[];const j=Array.from(R.querySelectorAll(`[${l}]`));return Array.from(C.itemMap.values()).sort((k,N)=>j.indexOf(k.ref.current)-j.indexOf(N.ref.current))},[C.collectionRef,C.itemMap])}return[{Provider:a,Slot:f,ItemSlot:p},g,r]}var Uu=m.createContext(void 0);function pa(e){const t=m.useContext(Uu);return e||t||"ltr"}function qe(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function zu(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bu="DismissableLayer",Rr="dismissableLayer.update",Wu="dismissableLayer.pointerDownOutside",Hu="dismissableLayer.focusOutside",Zo,ga=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ln=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:i,...h}=e,f=m.useContext(ga),[c,l]=m.useState(null),u=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),g=pe(t,N=>l(N)),v=Array.from(f.layers),[C]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(C),R=c?v.indexOf(c):-1,j=f.layersWithOutsidePointerEventsDisabled.size>0,_=R>=y,$=Ku(N=>{const x=N.target,b=[...f.branches].some(A=>A.contains(x));!_||b||(o==null||o(N),a==null||a(N),N.defaultPrevented||i==null||i())},u),k=qu(N=>{const x=N.target;[...f.branches].some(A=>A.contains(x))||(s==null||s(N),a==null||a(N),N.defaultPrevented||i==null||i())},u);return zu(N=>{R===f.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&i&&(N.preventDefault(),i()))},u),m.useEffect(()=>{if(c)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Zo=u.body.style.pointerEvents,u.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(c)),f.layers.add(c),Jo(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(u.body.style.pointerEvents=Zo)}},[c,u,n,f]),m.useEffect(()=>()=>{c&&(f.layers.delete(c),f.layersWithOutsidePointerEventsDisabled.delete(c),Jo())},[c,f]),m.useEffect(()=>{const N=()=>p({});return document.addEventListener(Rr,N),()=>document.removeEventListener(Rr,N)},[]),d.jsx(ue.div,{...h,ref:g,style:{pointerEvents:j?_?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,k.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,$.onPointerDownCapture)})});ln.displayName=Bu;var Vu="DismissableLayerBranch",Gu=m.forwardRef((e,t)=>{const n=m.useContext(ga),r=m.useRef(null),o=pe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(ue.div,{...e,ref:o})});Gu.displayName=Vu;function Ku(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=i=>{if(i.target&&!r.current){let h=function(){xa(Wu,n,f,{discrete:!0})};const f={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=h,t.addEventListener("click",o.current,{once:!0})):h()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function qu(e,t=globalThis==null?void 0:globalThis.document){const n=qe(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&xa(Hu,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Jo(){const e=new CustomEvent(Rr);document.dispatchEvent(e)}function xa(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ha(o,s):o.dispatchEvent(s)}var dr=0;function Jr(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??es()),document.body.insertAdjacentElement("beforeend",e[1]??es()),dr++,()=>{dr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),dr--}},[])}function es(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ur="focusScope.autoFocusOnMount",fr="focusScope.autoFocusOnUnmount",ts={bubbles:!1,cancelable:!0},Yu="FocusScope",Wn=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[i,h]=m.useState(null),f=qe(o),c=qe(s),l=m.useRef(null),u=pe(t,v=>h(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(j){if(p.paused||!i)return;const _=j.target;i.contains(_)?l.current=_:ot(l.current,{select:!0})},C=function(j){if(p.paused||!i)return;const _=j.relatedTarget;_!==null&&(i.contains(_)||ot(l.current,{select:!0}))},y=function(j){if(document.activeElement===document.body)for(const $ of j)$.removedNodes.length>0&&ot(i)};document.addEventListener("focusin",v),document.addEventListener("focusout",C);const R=new MutationObserver(y);return i&&R.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",C),R.disconnect()}}},[r,i,p.paused]),m.useEffect(()=>{if(i){rs.add(p);const v=document.activeElement;if(!i.contains(v)){const y=new CustomEvent(ur,ts);i.addEventListener(ur,f),i.dispatchEvent(y),y.defaultPrevented||(Xu(tf(va(i)),{select:!0}),document.activeElement===v&&ot(i))}return()=>{i.removeEventListener(ur,f),setTimeout(()=>{const y=new CustomEvent(fr,ts);i.addEventListener(fr,c),i.dispatchEvent(y),y.defaultPrevented||ot(v??document.body,{select:!0}),i.removeEventListener(fr,c),rs.remove(p)},0)}}},[i,f,c,p]);const g=m.useCallback(v=>{if(!n&&!r||p.paused)return;const C=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,y=document.activeElement;if(C&&y){const R=v.currentTarget,[j,_]=Qu(R);j&&_?!v.shiftKey&&y===_?(v.preventDefault(),n&&ot(j,{select:!0})):v.shiftKey&&y===j&&(v.preventDefault(),n&&ot(_,{select:!0})):y===R&&v.preventDefault()}},[n,r,p.paused]);return d.jsx(ue.div,{tabIndex:-1,...a,ref:u,onKeyDown:g})});Wn.displayName=Yu;function Xu(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ot(r,{select:t}),document.activeElement!==n)return}function Qu(e){const t=va(e),n=ns(t,e),r=ns(t.reverse(),e);return[n,r]}function va(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ns(e,t){for(const n of e)if(!Zu(n,{upTo:t}))return n}function Zu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ju(e){return e instanceof HTMLInputElement&&"select"in e}function ot(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ju(e)&&t&&e.select()}}var rs=ef();function ef(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=os(e,t),e.unshift(t)},remove(t){var n;e=os(e,t),(n=e[0])==null||n.resume()}}}function os(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function tf(e){return e.filter(t=>t.tagName!=="A")}var nf=Gr[" useId ".trim().toString()]||(()=>{}),rf=0;function Ce(e){const[t,n]=m.useState(nf());return Ke(()=>{n(r=>r??String(rf++))},[e]),e||(t?`radix-${t}`:"")}const of=["top","right","bottom","left"],it=Math.min,Ne=Math.max,An=Math.round,yn=Math.floor,Be=e=>({x:e,y:e}),sf={left:"right",right:"left",bottom:"top",top:"bottom"};function Tr(e,t,n){return Ne(e,it(t,n))}function Ye(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Bt(e){return e.split("-")[1]}function eo(e){return e==="x"?"y":"x"}function to(e){return e==="y"?"height":"width"}function ze(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function no(e){return eo(ze(e))}function af(e,t,n){n===void 0&&(n=!1);const r=Bt(e),o=no(e),s=to(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Rn(a)),[a,Rn(a)]}function lf(e){const t=Rn(e);return[Ir(e),t,Ir(t)]}function Ir(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ss=["left","right"],as=["right","left"],cf=["top","bottom"],df=["bottom","top"];function uf(e,t,n){switch(e){case"top":case"bottom":return n?t?as:ss:t?ss:as;case"left":case"right":return t?cf:df;default:return[]}}function ff(e,t,n,r){const o=Bt(e);let s=uf(Xe(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Ir)))),s}function Rn(e){const t=Xe(e);return sf[t]+e.slice(t.length)}function hf(e){return{top:0,right:0,bottom:0,left:0,...e}}function ba(e){return typeof e!="number"?hf(e):{top:e,right:e,bottom:e,left:e}}function Tn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function is(e,t,n){let{reference:r,floating:o}=e;const s=ze(t),a=no(t),i=to(a),h=Xe(t),f=s==="y",c=r.x+r.width/2-o.width/2,l=r.y+r.height/2-o.height/2,u=r[i]/2-o[i]/2;let p;switch(h){case"top":p={x:c,y:r.y-o.height};break;case"bottom":p={x:c,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:l};break;case"left":p={x:r.x-o.width,y:l};break;default:p={x:r.x,y:r.y}}switch(Bt(t)){case"start":p[a]-=u*(n&&f?-1:1);break;case"end":p[a]+=u*(n&&f?-1:1);break}return p}async function mf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:h}=e,{boundary:f="clippingAncestors",rootBoundary:c="viewport",elementContext:l="floating",altBoundary:u=!1,padding:p=0}=Ye(t,e),g=ba(p),C=i[u?l==="floating"?"reference":"floating":l],y=Tn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:f,rootBoundary:c,strategy:h})),R=l==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),_=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},$=Tn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:R,offsetParent:j,strategy:h}):R);return{top:(y.top-$.top+g.top)/_.y,bottom:($.bottom-y.bottom+g.bottom)/_.y,left:(y.left-$.left+g.left)/_.x,right:($.right-y.right+g.right)/_.x}}const pf=50,gf=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:mf},h=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:l}=is(f,r,h),u=r,p=0;const g={};for(let v=0;v<s.length;v++){const C=s[v];if(!C)continue;const{name:y,fn:R}=C,{x:j,y:_,data:$,reset:k}=await R({x:c,y:l,initialPlacement:r,placement:u,strategy:o,middlewareData:g,rects:f,platform:i,elements:{reference:e,floating:t}});c=j??c,l=_??l,g[y]={...g[y],...$},k&&p<pf&&(p++,typeof k=="object"&&(k.placement&&(u=k.placement),k.rects&&(f=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:c,y:l}=is(f,u,h)),v=-1)}return{x:c,y:l,placement:u,strategy:o,middlewareData:g}},xf=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:h}=t,{element:f,padding:c=0}=Ye(e,t)||{};if(f==null)return{};const l=ba(c),u={x:n,y:r},p=no(o),g=to(p),v=await a.getDimensions(f),C=p==="y",y=C?"top":"left",R=C?"bottom":"right",j=C?"clientHeight":"clientWidth",_=s.reference[g]+s.reference[p]-u[p]-s.floating[g],$=u[p]-s.reference[p],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let N=k?k[j]:0;(!N||!await(a.isElement==null?void 0:a.isElement(k)))&&(N=i.floating[j]||s.floating[g]);const x=_/2-$/2,b=N/2-v[g]/2-1,A=it(l[y],b),O=it(l[R],b),P=A,F=N-v[g]-O,M=N/2-v[g]/2+x,D=Tr(P,M,F),S=!h.arrow&&Bt(o)!=null&&M!==D&&s.reference[g]/2-(M<P?A:O)-v[g]/2<0,w=S?M<P?M-P:M-F:0;return{[p]:u[p]+w,data:{[p]:D,centerOffset:M-D-w,...S&&{alignmentOffset:w}},reset:S}}}),vf=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:h,elements:f}=t,{mainAxis:c=!0,crossAxis:l=!0,fallbackPlacements:u,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...C}=Ye(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Xe(o),R=ze(i),j=Xe(i)===i,_=await(h.isRTL==null?void 0:h.isRTL(f.floating)),$=u||(j||!v?[Rn(i)]:lf(i)),k=g!=="none";!u&&k&&$.push(...ff(i,v,g,_));const N=[i,...$],x=await h.detectOverflow(t,C),b=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(c&&b.push(x[y]),l){const M=af(o,a,_);b.push(x[M[0]],x[M[1]])}if(A=[...A,{placement:o,overflows:b}],!b.every(M=>M<=0)){var O,P;const M=(((O=s.flip)==null?void 0:O.index)||0)+1,D=N[M];if(D&&(!(l==="alignment"?R!==ze(D):!1)||A.every(L=>ze(L.placement)===R?L.overflows[0]>0:!0)))return{data:{index:M,overflows:A},reset:{placement:D}};let S=(P=A.filter(w=>w.overflows[0]<=0).sort((w,L)=>w.overflows[1]-L.overflows[1])[0])==null?void 0:P.placement;if(!S)switch(p){case"bestFit":{var F;const w=(F=A.filter(L=>{if(k){const E=ze(L.placement);return E===R||E==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(E=>E>0).reduce((E,I)=>E+I,0)]).sort((L,E)=>L[1]-E[1])[0])==null?void 0:F[0];w&&(S=w);break}case"initialPlacement":S=i;break}if(o!==S)return{reset:{placement:S}}}return{}}}};function ls(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cs(e){return of.some(t=>e[t]>=0)}const bf=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Ye(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=ls(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:cs(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=ls(a,n.floating);return{data:{escapedOffsets:i,escaped:cs(i)}}}default:return{}}}}},ya=new Set(["left","top"]);async function yf(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Xe(n),i=Bt(n),h=ze(n)==="y",f=ya.has(a)?-1:1,c=s&&h?-1:1,l=Ye(t,e);let{mainAxis:u,crossAxis:p,alignmentAxis:g}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return i&&typeof g=="number"&&(p=i==="end"?g*-1:g),h?{x:p*c,y:u*f}:{x:u*f,y:p*c}}const wf=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,h=await yf(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+h.x,y:s+h.y,data:{...h,placement:a}}}}},Cf=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:h={fn:y=>{let{x:R,y:j}=y;return{x:R,y:j}}},...f}=Ye(e,t),c={x:n,y:r},l=await s.detectOverflow(t,f),u=ze(Xe(o)),p=eo(u);let g=c[p],v=c[u];if(a){const y=p==="y"?"top":"left",R=p==="y"?"bottom":"right",j=g+l[y],_=g-l[R];g=Tr(j,g,_)}if(i){const y=u==="y"?"top":"left",R=u==="y"?"bottom":"right",j=v+l[y],_=v-l[R];v=Tr(j,v,_)}const C=h.fn({...t,[p]:g,[u]:v});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[p]:a,[u]:i}}}}}},Sf=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:h=!0,crossAxis:f=!0}=Ye(e,t),c={x:n,y:r},l=ze(o),u=eo(l);let p=c[u],g=c[l];const v=Ye(i,t),C=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(h){const j=u==="y"?"height":"width",_=s.reference[u]-s.floating[j]+C.mainAxis,$=s.reference[u]+s.reference[j]-C.mainAxis;p<_?p=_:p>$&&(p=$)}if(f){var y,R;const j=u==="y"?"width":"height",_=ya.has(Xe(o)),$=s.reference[l]-s.floating[j]+(_&&((y=a.offset)==null?void 0:y[l])||0)+(_?0:C.crossAxis),k=s.reference[l]+s.reference[j]+(_?0:((R=a.offset)==null?void 0:R[l])||0)-(_?C.crossAxis:0);g<$?g=$:g>k&&(g=k)}return{[u]:p,[l]:g}}}},kf=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:h=()=>{},...f}=Ye(e,t),c=await a.detectOverflow(t,f),l=Xe(o),u=Bt(o),p=ze(o)==="y",{width:g,height:v}=s.floating;let C,y;l==="top"||l==="bottom"?(C=l,y=u===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(y=l,C=u==="end"?"top":"bottom");const R=v-c.top-c.bottom,j=g-c.left-c.right,_=it(v-c[C],R),$=it(g-c[y],j),k=!t.middlewareData.shift;let N=_,x=$;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(x=j),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=R),k&&!u){const A=Ne(c.left,0),O=Ne(c.right,0),P=Ne(c.top,0),F=Ne(c.bottom,0);p?x=g-2*(A!==0||O!==0?A+O:Ne(c.left,c.right)):N=v-2*(P!==0||F!==0?P+F:Ne(c.top,c.bottom))}await h({...t,availableWidth:x,availableHeight:N});const b=await a.getDimensions(i.floating);return g!==b.width||v!==b.height?{reset:{rects:!0}}:{}}}};function Hn(){return typeof window<"u"}function Wt(e){return wa(e)?(e.nodeName||"").toLowerCase():"#document"}function je(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function He(e){var t;return(t=(wa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wa(e){return Hn()?e instanceof Node||e instanceof je(e).Node:!1}function Oe(e){return Hn()?e instanceof Element||e instanceof je(e).Element:!1}function Ze(e){return Hn()?e instanceof HTMLElement||e instanceof je(e).HTMLElement:!1}function ds(e){return!Hn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof je(e).ShadowRoot}function cn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function _f(e){return/^(table|td|th)$/.test(Wt(e))}function Vn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ef=/transform|translate|scale|rotate|perspective|filter/,Nf=/paint|layout|strict|content/,vt=e=>!!e&&e!=="none";let hr;function ro(e){const t=Oe(e)?De(e):e;return vt(t.transform)||vt(t.translate)||vt(t.scale)||vt(t.rotate)||vt(t.perspective)||!oo()&&(vt(t.backdropFilter)||vt(t.filter))||Ef.test(t.willChange||"")||Nf.test(t.contain||"")}function jf(e){let t=lt(e);for(;Ze(t)&&!Lt(t);){if(ro(t))return t;if(Vn(t))return null;t=lt(t)}return null}function oo(){return hr==null&&(hr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hr}function Lt(e){return/^(html|body|#document)$/.test(Wt(e))}function De(e){return je(e).getComputedStyle(e)}function Gn(e){return Oe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lt(e){if(Wt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ds(e)&&e.host||He(e);return ds(t)?t.host:t}function Ca(e){const t=lt(e);return Lt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ze(t)&&cn(t)?t:Ca(t)}function Jt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ca(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=je(o);if(s){const i=Mr(a);return t.concat(a,a.visualViewport||[],cn(o)?o:[],i&&n?Jt(i):[])}else return t.concat(o,Jt(o,[],n))}function Mr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sa(e){const t=De(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ze(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=An(n)!==s||An(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function so(e){return Oe(e)?e:e.contextElement}function Pt(e){const t=so(e);if(!Ze(t))return Be(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sa(t);let a=(s?An(n.width):n.width)/r,i=(s?An(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Af=Be(0);function ka(e){const t=je(e);return!oo()||!t.visualViewport?Af:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rf(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==je(e)?!1:t}function Ct(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=so(e);let a=Be(1);t&&(r?Oe(r)&&(a=Pt(r)):a=Pt(e));const i=Rf(s,n,r)?ka(s):Be(0);let h=(o.left+i.x)/a.x,f=(o.top+i.y)/a.y,c=o.width/a.x,l=o.height/a.y;if(s){const u=je(s),p=r&&Oe(r)?je(r):r;let g=u,v=Mr(g);for(;v&&r&&p!==g;){const C=Pt(v),y=v.getBoundingClientRect(),R=De(v),j=y.left+(v.clientLeft+parseFloat(R.paddingLeft))*C.x,_=y.top+(v.clientTop+parseFloat(R.paddingTop))*C.y;h*=C.x,f*=C.y,c*=C.x,l*=C.y,h+=j,f+=_,g=je(v),v=Mr(g)}}return Tn({width:c,height:l,x:h,y:f})}function Kn(e,t){const n=Gn(e).scrollLeft;return t?t.left+n:Ct(He(e)).left+n}function _a(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Kn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Tf(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=He(r),i=t?Vn(t.floating):!1;if(r===a||i&&s)return n;let h={scrollLeft:0,scrollTop:0},f=Be(1);const c=Be(0),l=Ze(r);if((l||!l&&!s)&&((Wt(r)!=="body"||cn(a))&&(h=Gn(r)),l)){const p=Ct(r);f=Pt(r),c.x=p.x+r.clientLeft,c.y=p.y+r.clientTop}const u=a&&!l&&!s?_a(a,h):Be(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-h.scrollLeft*f.x+c.x+u.x,y:n.y*f.y-h.scrollTop*f.y+c.y+u.y}}function If(e){return Array.from(e.getClientRects())}function Mf(e){const t=He(e),n=Gn(e),r=e.ownerDocument.body,o=Ne(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ne(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Kn(e);const i=-n.scrollTop;return De(r).direction==="rtl"&&(a+=Ne(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const us=25;function Pf(e,t){const n=je(e),r=He(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,h=0;if(o){s=o.width,a=o.height;const c=oo();(!c||c&&t==="fixed")&&(i=o.offsetLeft,h=o.offsetTop)}const f=Kn(r);if(f<=0){const c=r.ownerDocument,l=c.body,u=getComputedStyle(l),p=c.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(r.clientWidth-l.clientWidth-p);g<=us&&(s-=g)}else f<=us&&(s+=f);return{width:s,height:a,x:i,y:h}}function Of(e,t){const n=Ct(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ze(e)?Pt(e):Be(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,h=o*s.x,f=r*s.y;return{width:a,height:i,x:h,y:f}}function fs(e,t,n){let r;if(t==="viewport")r=Pf(e,n);else if(t==="document")r=Mf(He(e));else if(Oe(t))r=Of(t,n);else{const o=ka(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Tn(r)}function Ea(e,t){const n=lt(e);return n===t||!Oe(n)||Lt(n)?!1:De(n).position==="fixed"||Ea(n,t)}function Df(e,t){const n=t.get(e);if(n)return n;let r=Jt(e,[],!1).filter(i=>Oe(i)&&Wt(i)!=="body"),o=null;const s=De(e).position==="fixed";let a=s?lt(e):e;for(;Oe(a)&&!Lt(a);){const i=De(a),h=ro(a);!h&&i.position==="fixed"&&(o=null),(s?!h&&!o:!h&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||cn(a)&&!h&&Ea(e,a))?r=r.filter(c=>c!==a):o=i,a=lt(a)}return t.set(e,r),r}function Lf(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Vn(t)?[]:Df(t,this._c):[].concat(n),r],i=fs(t,a[0],o);let h=i.top,f=i.right,c=i.bottom,l=i.left;for(let u=1;u<a.length;u++){const p=fs(t,a[u],o);h=Ne(p.top,h),f=it(p.right,f),c=it(p.bottom,c),l=Ne(p.left,l)}return{width:f-l,height:c-h,x:l,y:h}}function $f(e){const{width:t,height:n}=Sa(e);return{width:t,height:n}}function Ff(e,t,n){const r=Ze(t),o=He(t),s=n==="fixed",a=Ct(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const h=Be(0);function f(){h.x=Kn(o)}if(r||!r&&!s)if((Wt(t)!=="body"||cn(o))&&(i=Gn(t)),r){const p=Ct(t,!0,s,t);h.x=p.x+t.clientLeft,h.y=p.y+t.clientTop}else o&&f();s&&!r&&o&&f();const c=o&&!r&&!s?_a(o,i):Be(0),l=a.left+i.scrollLeft-h.x-c.x,u=a.top+i.scrollTop-h.y-c.y;return{x:l,y:u,width:a.width,height:a.height}}function mr(e){return De(e).position==="static"}function hs(e,t){if(!Ze(e)||De(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return He(e)===n&&(n=n.ownerDocument.body),n}function Na(e,t){const n=je(e);if(Vn(e))return n;if(!Ze(e)){let o=lt(e);for(;o&&!Lt(o);){if(Oe(o)&&!mr(o))return o;o=lt(o)}return n}let r=hs(e,t);for(;r&&_f(r)&&mr(r);)r=hs(r,t);return r&&Lt(r)&&mr(r)&&!ro(r)?n:r||jf(e)||n}const Uf=async function(e){const t=this.getOffsetParent||Na,n=this.getDimensions,r=await n(e.floating);return{reference:Ff(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zf(e){return De(e).direction==="rtl"}const Bf={convertOffsetParentRelativeRectToViewportRelativeRect:Tf,getDocumentElement:He,getClippingRect:Lf,getOffsetParent:Na,getElementRects:Uf,getClientRects:If,getDimensions:$f,getScale:Pt,isElement:Oe,isRTL:zf};function ja(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wf(e,t){let n=null,r;const o=He(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,h){i===void 0&&(i=!1),h===void 0&&(h=1),s();const f=e.getBoundingClientRect(),{left:c,top:l,width:u,height:p}=f;if(i||t(),!u||!p)return;const g=yn(l),v=yn(o.clientWidth-(c+u)),C=yn(o.clientHeight-(l+p)),y=yn(c),j={rootMargin:-g+"px "+-v+"px "+-C+"px "+-y+"px",threshold:Ne(0,it(1,h))||1};let _=!0;function $(k){const N=k[0].intersectionRatio;if(N!==h){if(!_)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!ja(f,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver($,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver($,j)}n.observe(e)}return a(!0),s}function Hf(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:h=!1}=r,f=so(e),c=o||s?[...f?Jt(f):[],...t?Jt(t):[]]:[];c.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const l=f&&i?Wf(f,n):null;let u=-1,p=null;a&&(p=new ResizeObserver(y=>{let[R]=y;R&&R.target===f&&p&&t&&(p.unobserve(t),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var j;(j=p)==null||j.observe(t)})),n()}),f&&!h&&p.observe(f),t&&p.observe(t));let g,v=h?Ct(e):null;h&&C();function C(){const y=Ct(e);v&&!ja(v,y)&&n(),v=y,g=requestAnimationFrame(C)}return n(),()=>{var y;c.forEach(R=>{o&&R.removeEventListener("scroll",n),s&&R.removeEventListener("resize",n)}),l==null||l(),(y=p)==null||y.disconnect(),p=null,h&&cancelAnimationFrame(g)}}const Vf=wf,Gf=Cf,Kf=vf,qf=kf,Yf=bf,ms=xf,Xf=Sf,Qf=(e,t,n)=>{const r=new Map,o={platform:Bf,...n},s={...o.platform,_c:r};return gf(e,t,{...o,platform:s})};var Zf=typeof document<"u",Jf=function(){},kn=Zf?m.useLayoutEffect:Jf;function In(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!In(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!In(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Aa(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ps(e,t){const n=Aa(e);return Math.round(t*n)/n}function pr(e){const t=m.useRef(e);return kn(()=>{t.current=e}),t}function eh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:h,open:f}=e,[c,l]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[u,p]=m.useState(r);In(u,r)||p(r);const[g,v]=m.useState(null),[C,y]=m.useState(null),R=m.useCallback(L=>{L!==k.current&&(k.current=L,v(L))},[]),j=m.useCallback(L=>{L!==N.current&&(N.current=L,y(L))},[]),_=s||g,$=a||C,k=m.useRef(null),N=m.useRef(null),x=m.useRef(c),b=h!=null,A=pr(h),O=pr(o),P=pr(f),F=m.useCallback(()=>{if(!k.current||!N.current)return;const L={placement:t,strategy:n,middleware:u};O.current&&(L.platform=O.current),Qf(k.current,N.current,L).then(E=>{const I={...E,isPositioned:P.current!==!1};M.current&&!In(x.current,I)&&(x.current=I,Ps.flushSync(()=>{l(I)}))})},[u,t,n,O,P]);kn(()=>{f===!1&&x.current.isPositioned&&(x.current.isPositioned=!1,l(L=>({...L,isPositioned:!1})))},[f]);const M=m.useRef(!1);kn(()=>(M.current=!0,()=>{M.current=!1}),[]),kn(()=>{if(_&&(k.current=_),$&&(N.current=$),_&&$){if(A.current)return A.current(_,$,F);F()}},[_,$,F,A,b]);const D=m.useMemo(()=>({reference:k,floating:N,setReference:R,setFloating:j}),[R,j]),S=m.useMemo(()=>({reference:_,floating:$}),[_,$]),w=m.useMemo(()=>{const L={position:n,left:0,top:0};if(!S.floating)return L;const E=ps(S.floating,c.x),I=ps(S.floating,c.y);return i?{...L,transform:"translate("+E+"px, "+I+"px)",...Aa(S.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:I}},[n,i,S.floating,c.x,c.y]);return m.useMemo(()=>({...c,update:F,refs:D,elements:S,floatingStyles:w}),[c,F,D,S,w])}const th=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?ms({element:r.current,padding:o}).fn(n):{}:r?ms({element:r,padding:o}).fn(n):{}}}},nh=(e,t)=>{const n=Vf(e);return{name:n.name,fn:n.fn,options:[e,t]}},rh=(e,t)=>{const n=Gf(e);return{name:n.name,fn:n.fn,options:[e,t]}},oh=(e,t)=>({fn:Xf(e).fn,options:[e,t]}),sh=(e,t)=>{const n=Kf(e);return{name:n.name,fn:n.fn,options:[e,t]}},ah=(e,t)=>{const n=qf(e);return{name:n.name,fn:n.fn,options:[e,t]}},ih=(e,t)=>{const n=Yf(e);return{name:n.name,fn:n.fn,options:[e,t]}},lh=(e,t)=>{const n=th(e);return{name:n.name,fn:n.fn,options:[e,t]}};var ch="Arrow",Ra=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(ue.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ra.displayName=ch;var dh=Ra;function uh(e){const[t,n]=m.useState(void 0);return Ke(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,i;if("borderBoxSize"in s){const h=s.borderBoxSize,f=Array.isArray(h)?h[0]:h;a=f.inlineSize,i=f.blockSize}else a=e.offsetWidth,i=e.offsetHeight;n({width:a,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ao="Popper",[Ta,Ht]=Qe(ao),[fh,Ia]=Ta(ao),Ma=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return d.jsx(fh,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ma.displayName=ao;var Pa="PopperAnchor",Oa=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ia(Pa,n),a=m.useRef(null),i=pe(t,a),h=m.useRef(null);return m.useEffect(()=>{const f=h.current;h.current=(r==null?void 0:r.current)||a.current,f!==h.current&&s.onAnchorChange(h.current)}),r?null:d.jsx(ue.div,{...o,ref:i})});Oa.displayName=Pa;var io="PopperContent",[hh,mh]=Ta(io),Da=m.forwardRef((e,t)=>{var G,X,K,ne,ae,de;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:i=0,avoidCollisions:h=!0,collisionBoundary:f=[],collisionPadding:c=0,sticky:l="partial",hideWhenDetached:u=!1,updatePositionStrategy:p="optimized",onPlaced:g,...v}=e,C=Ia(io,n),[y,R]=m.useState(null),j=pe(t,me=>R(me)),[_,$]=m.useState(null),k=uh(_),N=(k==null?void 0:k.width)??0,x=(k==null?void 0:k.height)??0,b=r+(s!=="center"?"-"+s:""),A=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},O=Array.isArray(f)?f:[f],P=O.length>0,F={padding:A,boundary:O.filter(gh),altBoundary:P},{refs:M,floatingStyles:D,placement:S,isPositioned:w,middlewareData:L}=eh({strategy:"fixed",placement:b,whileElementsMounted:(...me)=>Hf(...me,{animationFrame:p==="always"}),elements:{reference:C.anchor},middleware:[nh({mainAxis:o+x,alignmentAxis:a}),h&&rh({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?oh():void 0,...F}),h&&sh({...F}),ah({...F,apply:({elements:me,rects:H,availableWidth:q,availableHeight:J})=>{const{width:te,height:ie}=H.reference,oe=me.floating.style;oe.setProperty("--radix-popper-available-width",`${q}px`),oe.setProperty("--radix-popper-available-height",`${J}px`),oe.setProperty("--radix-popper-anchor-width",`${te}px`),oe.setProperty("--radix-popper-anchor-height",`${ie}px`)}}),_&&lh({element:_,padding:i}),xh({arrowWidth:N,arrowHeight:x}),u&&ih({strategy:"referenceHidden",...F})]}),[E,I]=Fa(S),W=qe(g);Ke(()=>{w&&(W==null||W())},[w,W]);const T=(G=L.arrow)==null?void 0:G.x,B=(X=L.arrow)==null?void 0:X.y,z=((K=L.arrow)==null?void 0:K.centerOffset)!==0,[U,V]=m.useState();return Ke(()=>{y&&V(window.getComputedStyle(y).zIndex)},[y]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:w?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:U,"--radix-popper-transform-origin":[(ne=L.transformOrigin)==null?void 0:ne.x,(ae=L.transformOrigin)==null?void 0:ae.y].join(" "),...((de=L.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(hh,{scope:n,placedSide:E,onArrowChange:$,arrowX:T,arrowY:B,shouldHideArrow:z,children:d.jsx(ue.div,{"data-side":E,"data-align":I,...v,ref:j,style:{...v.style,animation:w?void 0:"none"}})})})});Da.displayName=io;var La="PopperArrow",ph={top:"bottom",right:"left",bottom:"top",left:"right"},$a=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=mh(La,r),a=ph[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(dh,{...o,ref:n,style:{...o.style,display:"block"}})})});$a.displayName=La;function gh(e){return e!==null}var xh=e=>({name:"transformOrigin",options:e,fn(t){var C,y,R;const{placement:n,rects:r,middlewareData:o}=t,a=((C=o.arrow)==null?void 0:C.centerOffset)!==0,i=a?0:e.arrowWidth,h=a?0:e.arrowHeight,[f,c]=Fa(n),l={start:"0%",center:"50%",end:"100%"}[c],u=(((y=o.arrow)==null?void 0:y.x)??0)+i/2,p=(((R=o.arrow)==null?void 0:R.y)??0)+h/2;let g="",v="";return f==="bottom"?(g=a?l:`${u}px`,v=`${-h}px`):f==="top"?(g=a?l:`${u}px`,v=`${r.floating.height+h}px`):f==="right"?(g=`${-h}px`,v=a?l:`${p}px`):f==="left"&&(g=`${r.floating.width+h}px`,v=a?l:`${p}px`),{data:{x:g,y:v}}}});function Fa(e){const[t,n="center"]=e.split("-");return[t,n]}var lo=Ma,qn=Oa,co=Da,uo=$a,vh="Portal",dn=m.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,s]=m.useState(!1);Ke(()=>s(!0),[]);const a=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return a?sc.createPortal(d.jsx(ue.div,{...r,ref:t}),a):null});dn.displayName=vh;function bh(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ae=e=>{const{present:t,children:n}=e,r=yh(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=pe(r.ref,wh(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Ae.displayName="Presence";function yh(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),a=e?"mounted":"unmounted",[i,h]=bh(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=wn(r.current);s.current=i==="mounted"?f:"none"},[i]),Ke(()=>{const f=r.current,c=o.current;if(c!==e){const u=s.current,p=wn(f);e?h("MOUNT"):p==="none"||(f==null?void 0:f.display)==="none"?h("UNMOUNT"):h(c&&u!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),Ke(()=>{if(t){let f;const c=t.ownerDocument.defaultView??window,l=p=>{const v=wn(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(h("ANIMATION_END"),!o.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",f=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},u=p=>{p.target===t&&(s.current=wn(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{c.clearTimeout(f),t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:m.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function wn(e){return(e==null?void 0:e.animationName)||"none"}function wh(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gr="rovingFocusGroup.onEntryFocus",Ch={bubbles:!1,cancelable:!0},un="RovingFocusGroup",[Pr,Ua,Sh]=ma(un),[kh,za]=Qe(un,[Sh]),[_h,Eh]=kh(un),Ba=m.forwardRef((e,t)=>d.jsx(Pr.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Pr.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Nh,{...e,ref:t})})}));Ba.displayName=un;var Nh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:h,onEntryFocus:f,preventScrollOnEntryFocus:c=!1,...l}=e,u=m.useRef(null),p=pe(t,u),g=pa(s),[v,C]=at({prop:a,defaultProp:i??null,onChange:h,caller:un}),[y,R]=m.useState(!1),j=qe(f),_=Ua(n),$=m.useRef(!1),[k,N]=m.useState(0);return m.useEffect(()=>{const x=u.current;if(x)return x.addEventListener(gr,j),()=>x.removeEventListener(gr,j)},[j]),d.jsx(_h,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(x=>C(x),[C]),onItemShiftTab:m.useCallback(()=>R(!0),[]),onFocusableItemAdd:m.useCallback(()=>N(x=>x+1),[]),onFocusableItemRemove:m.useCallback(()=>N(x=>x-1),[]),children:d.jsx(ue.div,{tabIndex:y||k===0?-1:0,"data-orientation":r,...l,ref:p,style:{outline:"none",...e.style},onMouseDown:ee(e.onMouseDown,()=>{$.current=!0}),onFocus:ee(e.onFocus,x=>{const b=!$.current;if(x.target===x.currentTarget&&b&&!y){const A=new CustomEvent(gr,Ch);if(x.currentTarget.dispatchEvent(A),!A.defaultPrevented){const O=_().filter(S=>S.focusable),P=O.find(S=>S.active),F=O.find(S=>S.id===v),D=[P,F,...O].filter(Boolean).map(S=>S.ref.current);Va(D,c)}}$.current=!1}),onBlur:ee(e.onBlur,()=>R(!1))})})}),Wa="RovingFocusGroupItem",Ha=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...i}=e,h=Ce(),f=s||h,c=Eh(Wa,n),l=c.currentTabStopId===f,u=Ua(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:v}=c;return m.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),d.jsx(Pr.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:d.jsx(ue.span,{tabIndex:l?0:-1,"data-orientation":c.orientation,...i,ref:t,onMouseDown:ee(e.onMouseDown,C=>{r?c.onItemFocus(f):C.preventDefault()}),onFocus:ee(e.onFocus,()=>c.onItemFocus(f)),onKeyDown:ee(e.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){c.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const y=Rh(C,c.orientation,c.dir);if(y!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let j=u().filter(_=>_.focusable).map(_=>_.ref.current);if(y==="last")j.reverse();else if(y==="prev"||y==="next"){y==="prev"&&j.reverse();const _=j.indexOf(C.currentTarget);j=c.loop?Th(j,_+1):j.slice(_+1)}setTimeout(()=>Va(j))}}),children:typeof a=="function"?a({isCurrentTabStop:l,hasTabStop:v!=null}):a})})});Ha.displayName=Wa;var jh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ah(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Rh(e,t,n){const r=Ah(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jh[r]}function Va(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Th(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ih=Ba,Mh=Ha,Ph=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rt=new WeakMap,Cn=new WeakMap,Sn={},xr=0,Ga=function(e){return e&&(e.host||Ga(e.parentNode))},Oh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ga(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Dh=function(e,t,n,r){var o=Oh(t,Array.isArray(e)?e:[e]);Sn[n]||(Sn[n]=new WeakMap);var s=Sn[n],a=[],i=new Set,h=new Set(o),f=function(l){!l||i.has(l)||(i.add(l),f(l.parentNode))};o.forEach(f);var c=function(l){!l||h.has(l)||Array.prototype.forEach.call(l.children,function(u){if(i.has(u))c(u);else try{var p=u.getAttribute(r),g=p!==null&&p!=="false",v=(Rt.get(u)||0)+1,C=(s.get(u)||0)+1;Rt.set(u,v),s.set(u,C),a.push(u),v===1&&g&&Cn.set(u,!0),C===1&&u.setAttribute(n,"true"),g||u.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",u,y)}})};return c(t),i.clear(),xr++,function(){a.forEach(function(l){var u=Rt.get(l)-1,p=s.get(l)-1;Rt.set(l,u),s.set(l,p),u||(Cn.has(l)||l.removeAttribute(r),Cn.delete(l)),p||l.removeAttribute(n)}),xr--,xr||(Rt=new WeakMap,Rt=new WeakMap,Cn=new WeakMap,Sn={})}},fo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ph(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Dh(r,o,n,"aria-hidden")):function(){return null}},Or=["Enter"," "],Lh=["ArrowDown","PageUp","Home"],Ka=["ArrowUp","PageDown","End"],$h=[...Lh,...Ka],Fh={ltr:[...Or,"ArrowRight"],rtl:[...Or,"ArrowLeft"]},Uh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fn="Menu",[en,zh,Bh]=ma(fn),[Nt,qa]=Qe(fn,[Bh,Ht,za]),Yn=Ht(),Ya=za(),[Wh,jt]=Nt(fn),[Hh,hn]=Nt(fn),Xa=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,i=Yn(t),[h,f]=m.useState(null),c=m.useRef(!1),l=qe(s),u=pa(o);return m.useEffect(()=>{const p=()=>{c.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>c.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),d.jsx(lo,{...i,children:d.jsx(Wh,{scope:t,open:n,onOpenChange:l,content:h,onContentChange:f,children:d.jsx(Hh,{scope:t,onClose:m.useCallback(()=>l(!1),[l]),isUsingKeyboardRef:c,dir:u,modal:a,children:r})})})};Xa.displayName=fn;var Vh="MenuAnchor",ho=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(qn,{...o,...r,ref:t})});ho.displayName=Vh;var mo="MenuPortal",[Gh,Qa]=Nt(mo,{forceMount:void 0}),Za=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=jt(mo,t);return d.jsx(Gh,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};Za.displayName=mo;var Te="MenuContent",[Kh,po]=Nt(Te),Ja=m.forwardRef((e,t)=>{const n=Qa(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu);return d.jsx(en.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(en.Slot,{scope:e.__scopeMenu,children:a.modal?d.jsx(qh,{...o,ref:t}):d.jsx(Yh,{...o,ref:t})})})})}),qh=m.forwardRef((e,t)=>{const n=jt(Te,e.__scopeMenu),r=m.useRef(null),o=pe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return fo(s)},[]),d.jsx(go,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yh=m.forwardRef((e,t)=>{const n=jt(Te,e.__scopeMenu);return d.jsx(go,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xh=Dt("MenuContent.ScrollLock"),go=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEntryFocus:h,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,onDismiss:p,disableOutsideScroll:g,...v}=e,C=jt(Te,n),y=hn(Te,n),R=Yn(n),j=Ya(n),_=zh(n),[$,k]=m.useState(null),N=m.useRef(null),x=pe(t,N,C.onContentChange),b=m.useRef(0),A=m.useRef(""),O=m.useRef(0),P=m.useRef(null),F=m.useRef("right"),M=m.useRef(0),D=g?Kr:m.Fragment,S=g?{as:Xh,allowPinchZoom:!0}:void 0,w=E=>{var G,X;const I=A.current+E,W=_().filter(K=>!K.disabled),T=document.activeElement,B=(G=W.find(K=>K.ref.current===T))==null?void 0:G.textValue,z=W.map(K=>K.textValue),U=lm(z,I,B),V=(X=W.find(K=>K.textValue===U))==null?void 0:X.ref.current;(function K(ne){A.current=ne,window.clearTimeout(b.current),ne!==""&&(b.current=window.setTimeout(()=>K(""),1e3))})(I),V&&setTimeout(()=>V.focus())};m.useEffect(()=>()=>window.clearTimeout(b.current),[]),Jr();const L=m.useCallback(E=>{var W,T;return F.current===((W=P.current)==null?void 0:W.side)&&dm(E,(T=P.current)==null?void 0:T.area)},[]);return d.jsx(Kh,{scope:n,searchRef:A,onItemEnter:m.useCallback(E=>{L(E)&&E.preventDefault()},[L]),onItemLeave:m.useCallback(E=>{var I;L(E)||((I=N.current)==null||I.focus(),k(null))},[L]),onTriggerLeave:m.useCallback(E=>{L(E)&&E.preventDefault()},[L]),pointerGraceTimerRef:O,onPointerGraceIntentChange:m.useCallback(E=>{P.current=E},[]),children:d.jsx(D,{...S,children:d.jsx(Wn,{asChild:!0,trapped:o,onMountAutoFocus:ee(s,E=>{var I;E.preventDefault(),(I=N.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,onDismiss:p,children:d.jsx(Ih,{asChild:!0,...j,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:$,onCurrentTabStopIdChange:k,onEntryFocus:ee(h,E=>{y.isUsingKeyboardRef.current||E.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(co,{role:"menu","aria-orientation":"vertical","data-state":pi(C.open),"data-radix-menu-content":"",dir:y.dir,...R,...v,ref:x,style:{outline:"none",...v.style},onKeyDown:ee(v.onKeyDown,E=>{const W=E.target.closest("[data-radix-menu-content]")===E.currentTarget,T=E.ctrlKey||E.altKey||E.metaKey,B=E.key.length===1;W&&(E.key==="Tab"&&E.preventDefault(),!T&&B&&w(E.key));const z=N.current;if(E.target!==z||!$h.includes(E.key))return;E.preventDefault();const V=_().filter(G=>!G.disabled).map(G=>G.ref.current);Ka.includes(E.key)&&V.reverse(),am(V)}),onBlur:ee(e.onBlur,E=>{E.currentTarget.contains(E.target)||(window.clearTimeout(b.current),A.current="")}),onPointerMove:ee(e.onPointerMove,tn(E=>{const I=E.target,W=M.current!==E.clientX;if(E.currentTarget.contains(I)&&W){const T=E.clientX>M.current?"right":"left";F.current=T,M.current=E.clientX}}))})})})})})})});Ja.displayName=Te;var Qh="MenuGroup",xo=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"group",...r,ref:t})});xo.displayName=Qh;var Zh="MenuLabel",ei=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{...r,ref:t})});ei.displayName=Zh;var Mn="MenuItem",gs="menu.itemSelect",Xn=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),a=hn(Mn,e.__scopeMenu),i=po(Mn,e.__scopeMenu),h=pe(t,s),f=m.useRef(!1),c=()=>{const l=s.current;if(!n&&l){const u=new CustomEvent(gs,{bubbles:!0,cancelable:!0});l.addEventListener(gs,p=>r==null?void 0:r(p),{once:!0}),ha(l,u),u.defaultPrevented?f.current=!1:a.onClose()}};return d.jsx(ti,{...o,ref:h,disabled:n,onClick:ee(e.onClick,c),onPointerDown:l=>{var u;(u=e.onPointerDown)==null||u.call(e,l),f.current=!0},onPointerUp:ee(e.onPointerUp,l=>{var u;f.current||(u=l.currentTarget)==null||u.click()}),onKeyDown:ee(e.onKeyDown,l=>{const u=i.searchRef.current!=="";n||u&&l.key===" "||Or.includes(l.key)&&(l.currentTarget.click(),l.preventDefault())})})});Xn.displayName=Mn;var ti=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=po(Mn,n),i=Ya(n),h=m.useRef(null),f=pe(t,h),[c,l]=m.useState(!1),[u,p]=m.useState("");return m.useEffect(()=>{const g=h.current;g&&p((g.textContent??"").trim())},[s.children]),d.jsx(en.ItemSlot,{scope:n,disabled:r,textValue:o??u,children:d.jsx(Mh,{asChild:!0,...i,focusable:!r,children:d.jsx(ue.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:ee(e.onPointerMove,tn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ee(e.onPointerLeave,tn(g=>a.onItemLeave(g))),onFocus:ee(e.onFocus,()=>l(!0)),onBlur:ee(e.onBlur,()=>l(!1))})})})}),Jh="MenuCheckboxItem",ni=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(ii,{scope:e.__scopeMenu,checked:n,children:d.jsx(Xn,{role:"menuitemcheckbox","aria-checked":Pn(n)?"mixed":n,...o,ref:t,"data-state":bo(n),onSelect:ee(o.onSelect,()=>r==null?void 0:r(Pn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ni.displayName=Jh;var ri="MenuRadioGroup",[em,tm]=Nt(ri,{value:void 0,onValueChange:()=>{}}),oi=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=qe(r);return d.jsx(em,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(xo,{...o,ref:t})})});oi.displayName=ri;var si="MenuRadioItem",ai=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=tm(si,e.__scopeMenu),s=n===o.value;return d.jsx(ii,{scope:e.__scopeMenu,checked:s,children:d.jsx(Xn,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":bo(s),onSelect:ee(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});ai.displayName=si;var vo="MenuItemIndicator",[ii,nm]=Nt(vo,{checked:!1}),li=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=nm(vo,n);return d.jsx(Ae,{present:r||Pn(s.checked)||s.checked===!0,children:d.jsx(ue.span,{...o,ref:t,"data-state":bo(s.checked)})})});li.displayName=vo;var rm="MenuSeparator",ci=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ci.displayName=rm;var om="MenuArrow",di=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(uo,{...o,...r,ref:t})});di.displayName=om;var sm="MenuSub",[rb,ui]=Nt(sm),Xt="MenuSubTrigger",fi=m.forwardRef((e,t)=>{const n=jt(Xt,e.__scopeMenu),r=hn(Xt,e.__scopeMenu),o=ui(Xt,e.__scopeMenu),s=po(Xt,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:h}=s,f={__scopeMenu:e.__scopeMenu},c=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>c,[c]),m.useEffect(()=>{const l=i.current;return()=>{window.clearTimeout(l),h(null)}},[i,h]),d.jsx(ho,{asChild:!0,...f,children:d.jsx(ti,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pi(n.open),...e,ref:We(t,o.onTriggerChange),onClick:l=>{var u;(u=e.onClick)==null||u.call(e,l),!(e.disabled||l.defaultPrevented)&&(l.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ee(e.onPointerMove,tn(l=>{s.onItemEnter(l),!l.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:ee(e.onPointerLeave,tn(l=>{var p,g;c();const u=(p=n.content)==null?void 0:p.getBoundingClientRect();if(u){const v=(g=n.content)==null?void 0:g.dataset.side,C=v==="right",y=C?-5:5,R=u[C?"left":"right"],j=u[C?"right":"left"];s.onPointerGraceIntentChange({area:[{x:l.clientX+y,y:l.clientY},{x:R,y:u.top},{x:j,y:u.top},{x:j,y:u.bottom},{x:R,y:u.bottom}],side:v}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(l),l.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ee(e.onKeyDown,l=>{var p;const u=s.searchRef.current!=="";e.disabled||u&&l.key===" "||Fh[r.dir].includes(l.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),l.preventDefault())})})})});fi.displayName=Xt;var hi="MenuSubContent",mi=m.forwardRef((e,t)=>{const n=Qa(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu),i=ui(hi,e.__scopeMenu),h=m.useRef(null),f=pe(t,h);return d.jsx(en.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(en.Slot,{scope:e.__scopeMenu,children:d.jsx(go,{id:i.contentId,"aria-labelledby":i.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{var l;a.isUsingKeyboardRef.current&&((l=h.current)==null||l.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:ee(e.onFocusOutside,c=>{c.target!==i.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ee(e.onEscapeKeyDown,c=>{a.onClose(),c.preventDefault()}),onKeyDown:ee(e.onKeyDown,c=>{var p;const l=c.currentTarget.contains(c.target),u=Uh[a.dir].includes(c.key);l&&u&&(s.onOpenChange(!1),(p=i.trigger)==null||p.focus(),c.preventDefault())})})})})})});mi.displayName=hi;function pi(e){return e?"open":"closed"}function Pn(e){return e==="indeterminate"}function bo(e){return Pn(e)?"indeterminate":e?"checked":"unchecked"}function am(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function im(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function lm(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=im(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const h=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return h!==n?h:void 0}function cm(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],h=t[a],f=i.x,c=i.y,l=h.x,u=h.y;c>r!=u>r&&n<(l-f)*(r-c)/(u-c)+f&&(o=!o)}return o}function dm(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return cm(n,t)}function tn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var um=Xa,fm=ho,hm=Za,mm=Ja,pm=xo,gm=ei,xm=Xn,vm=ni,bm=oi,ym=ai,wm=li,Cm=ci,Sm=di,km=fi,_m=mi,Qn="DropdownMenu",[Em]=Qe(Qn,[qa]),Se=qa(),[Nm,gi]=Em(Qn),xi=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,h=Se(t),f=m.useRef(null),[c,l]=at({prop:o,defaultProp:s??!1,onChange:a,caller:Qn});return d.jsx(Nm,{scope:t,triggerId:Ce(),triggerRef:f,contentId:Ce(),open:c,onOpenChange:l,onOpenToggle:m.useCallback(()=>l(u=>!u),[l]),modal:i,children:d.jsx(um,{...h,open:c,onOpenChange:l,dir:r,modal:i,children:n})})};xi.displayName=Qn;var vi="DropdownMenuTrigger",bi=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=gi(vi,n),a=Se(n);return d.jsx(fm,{asChild:!0,...a,children:d.jsx(ue.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:We(t,s.triggerRef),onPointerDown:ee(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(s.onOpenToggle(),s.open||i.preventDefault())}),onKeyDown:ee(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&s.onOpenToggle(),i.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});bi.displayName=vi;var jm="DropdownMenuPortal",yi=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Se(t);return d.jsx(hm,{...r,...n})};yi.displayName=jm;var wi="DropdownMenuContent",Ci=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gi(wi,n),s=Se(n),a=m.useRef(!1);return d.jsx(mm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ee(e.onCloseAutoFocus,i=>{var h;a.current||(h=o.triggerRef.current)==null||h.focus(),a.current=!1,i.preventDefault()}),onInteractOutside:ee(e.onInteractOutside,i=>{const h=i.detail.originalEvent,f=h.button===0&&h.ctrlKey===!0,c=h.button===2||f;(!o.modal||c)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ci.displayName=wi;var Am="DropdownMenuGroup",Rm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(pm,{...o,...r,ref:t})});Rm.displayName=Am;var Tm="DropdownMenuLabel",Im=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(gm,{...o,...r,ref:t})});Im.displayName=Tm;var Mm="DropdownMenuItem",Si=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(xm,{...o,...r,ref:t})});Si.displayName=Mm;var Pm="DropdownMenuCheckboxItem",Om=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(vm,{...o,...r,ref:t})});Om.displayName=Pm;var Dm="DropdownMenuRadioGroup",Lm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(bm,{...o,...r,ref:t})});Lm.displayName=Dm;var $m="DropdownMenuRadioItem",Fm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(ym,{...o,...r,ref:t})});Fm.displayName=$m;var Um="DropdownMenuItemIndicator",zm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(wm,{...o,...r,ref:t})});zm.displayName=Um;var Bm="DropdownMenuSeparator",Wm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Cm,{...o,...r,ref:t})});Wm.displayName=Bm;var Hm="DropdownMenuArrow",Vm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Sm,{...o,...r,ref:t})});Vm.displayName=Hm;var Gm="DropdownMenuSubTrigger",Km=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(km,{...o,...r,ref:t})});Km.displayName=Gm;var qm="DropdownMenuSubContent",Ym=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(_m,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ym.displayName=qm;var Xm=xi,Qm=bi,Zm=yi,Jm=Ci,ep=Si;function tp({...e}){return d.jsx(Xm,{"data-slot":"dropdown-menu",...e})}function np({...e}){return d.jsx(Qm,{"data-slot":"dropdown-menu-trigger",...e})}function rp({className:e,sideOffset:t=4,...n}){return d.jsx(Zm,{children:d.jsx(Jm,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function op({className:e,inset:t,variant:n="default",...r}){return d.jsx(ep,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Z("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}const sp=[{value:"light",label:"Light",icon:d.jsx(oa,{className:"h-4 w-4"})},{value:"dark",label:"Dark",icon:d.jsx(ra,{className:"h-4 w-4"})},{value:"system",label:"System",icon:d.jsx(Dd,{className:"h-4 w-4"})}];function ap(){const{theme:e,setTheme:t,resolvedTheme:n}=ca();return d.jsxs(tp,{children:[d.jsx(np,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[n==="dark"?d.jsx(ra,{className:"h-4 w-4"}):d.jsx(oa,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),d.jsx(rp,{align:"end",children:sp.map(r=>d.jsxs(op,{onClick:()=>t(r.value),className:e===r.value?"bg-accent":"",children:[r.icon,d.jsx("span",{className:"ml-2",children:r.label})]},r.value))})]})}function ip({onIdentityClick:e,onTokenClick:t,activeTokenLabel:n,sessionTitle:r,sessionSource:o,onBack:s}){return d.jsx("nav",{className:"sticky top-0 z-40 border-b border-border bg-surface-1/80 backdrop-blur-md",children:d.jsxs("div",{className:"mx-auto flex h-11 sm:h-12 max-w-5xl items-center justify-between px-3 sm:px-4",children:[r?d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1 text-sm text-text-muted hover:text-text-primary transition-colors flex-shrink-0",children:[d.jsx(pd,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Dashboard"})]}),d.jsx("span",{className:"text-text-muted/40",children:"/"}),d.jsx("span",{className:"text-sm font-display font-medium text-text-primary truncate",children:r}),o&&d.jsx("span",{className:"rounded-full bg-brand/15 px-2 py-0.5 text-[10px] font-medium text-brand flex-shrink-0",children:o==="acp"?"ACP":"RCS"})]}):d.jsxs("a",{href:"/code/",className:"flex items-center gap-2 font-display text-lg font-semibold text-text-primary no-underline",children:[d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"flex-shrink-0",children:d.jsx("path",{d:"M10 1L12.2 7.8L19 10L12.2 12.2L10 19L7.8 12.2L1 10L7.8 7.8L10 1Z",fill:"var(--color-brand)"})}),d.jsx("span",{className:"hidden sm:inline",children:"Remote Control"})]}),d.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[!r&&d.jsxs("a",{href:"/code/",className:"flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm text-text-secondary hover:bg-surface-2 hover:text-text-primary no-underline transition-colors",title:"Dashboard",children:[d.jsx(Td,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Dashboard"})]}),d.jsx(ap,{}),d.jsxs("button",{onClick:t,className:Z("flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm transition-colors",n?"bg-brand/10 text-text-primary hover:bg-brand-light hover:text-white":"text-text-primary font-bold hover:bg-brand-light hover:text-white"),title:"Token Manager",children:[d.jsx(ta,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline max-w-24 truncate font-bold",children:n||"No Token"})]}),d.jsxs("button",{onClick:e,className:"flex items-center gap-1 rounded-md px-2 sm:px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",title:"Identity & QR",children:[d.jsx(pu,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline font-bold",children:"Identity"})]})]})]})})}function ob({status:e}){const t={active:"bg-status-active/20 text-status-active",running:"bg-status-running/20 text-status-running",idle:"bg-status-idle/20 text-status-idle",inactive:"bg-text-muted/20 text-text-muted",requires_action:"bg-status-warning/20 text-status-warning",archived:"bg-text-muted/20 text-text-muted",error:"bg-status-error/20 text-status-error"};return d.jsx("span",{className:Z("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",t[e]||"bg-surface-3 text-text-secondary"),children:e})}let $t=class ce{constructor(t,n,r,o,s){this._legacyCanvasSize=ce.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),r&&typeof r=="object"?this._onDecode=n:(console.warn(r||o||s?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof r=="object"?r:{},this._onDecodeError=n.onDecodeError||(typeof r=="function"?r:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||s||this._preferredCamera,this._legacyCanvasSize=typeof r=="number"?r:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let a=!1;if(t.hidden&&(t.hidden=!1,a=!0),document.body.contains(t)||(document.body.appendChild(t),a=!0),r=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),s=this.$overlay.style,s.position="absolute",s.display="none",s.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}r.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let i=window.getComputedStyle(t);i.display==="none"&&(t.style.setProperty("display","block","important"),a=!0),i.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),a=!0),a&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=ce.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await ce.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),r;try{t&&(await n()).every(o=>!o.label)&&(r=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,s)=>({id:o.deviceId,label:o.label||(s===0?"Default Camera":`Camera ${s+1}`)}))}finally{r&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),ce._stopVideoStream(r))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),ce._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),ce._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?ce._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(ce._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(r=>setTimeout(r,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,r,o,s=!1,a=!1){let i,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(i=n.scanRegion,r=n.qrEngine,o=n.canvas,s=n.disallowCanvasResizing||!1,a=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||r||o||s||a?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!r;try{let f,c;[r,f]=await Promise.all([r||ce.createQrEngine(),ce._loadImage(t)]),[o,c]=ce._drawToCanvas(f,i,o,s);let l;if(r instanceof Worker){let u=r;n||ce._postWorkerMessageSync(u,"inversionMode","both"),l=await new Promise((p,g)=>{let v,C,y,R=-1;C=_=>{_.data.id===R&&(u.removeEventListener("message",C),u.removeEventListener("error",y),clearTimeout(v),_.data.data!==null?p({data:_.data.data,cornerPoints:ce._convertPoints(_.data.cornerPoints,i)}):g(ce.NO_QR_CODE_FOUND))},y=_=>{u.removeEventListener("message",C),u.removeEventListener("error",y),clearTimeout(v),g("Scanner error: "+(_?_.message||_:"Unknown Error"))},u.addEventListener("message",C),u.addEventListener("error",y),v=setTimeout(()=>y("timeout"),1e4);let j=c.getImageData(0,0,o.width,o.height);R=ce._postWorkerMessageSync(u,"decode",j,[j.data.buffer])})}else l=await Promise.race([new Promise((u,p)=>window.setTimeout(()=>p("Scanner error: timeout"),1e4)),(async()=>{try{var[u]=await r.detect(o);if(!u)throw ce.NO_QR_CODE_FOUND;return{data:u.rawValue,cornerPoints:ce._convertPoints(u.cornerPoints,i)}}catch(p){if(u=p.message||p,/not implemented|service unavailable/.test(u))return ce._disableBarcodeDetector=!0,ce.scanImage(t,{scanRegion:i,canvas:o,disallowCanvasResizing:s,alsoTryWithoutScanRegion:a});throw`Scanner error: ${u}`}})()]);return h?l:l.data}catch(f){if(!i||!a)throw f;let c=await ce.scanImage(t,{qrEngine:r,canvas:o,disallowCanvasResizing:s});return h?c:c.data}finally{n||ce._postWorkerMessage(r,"close")}}setGrayscaleWeights(t,n,r,o=!0){ce._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:r,useIntegerApproximation:o})}setInversionMode(t){ce._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>on(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(r=>r.createWorker()),!(!ce._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:r})=>/Chromium/i.test(r))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:r,platformVersion:o})=>/arm/i.test(r||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,r=t.videoHeight,o=t.offsetWidth,s=t.offsetHeight,a=t.offsetLeft,i=t.offsetTop,h=window.getComputedStyle(t),f=h.objectFit,c=n/r,l=o/s;switch(f){case"none":var u=n,p=r;break;case"fill":u=o,p=s;break;default:(f==="cover"?c>l:c<l)?(p=s,u=p*c):(u=o,p=u/c),f==="scale-down"&&(u=Math.min(u,n),p=Math.min(p,r))}var[g,v]=h.objectPosition.split(" ").map((y,R)=>{const j=parseFloat(y);return y.endsWith("%")?(R?s-p:o-u)*j/100:j});h=this._scanRegion.width||n,l=this._scanRegion.height||r,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;c=this.$overlay.style,c.width=`${h/n*u}px`,c.height=`${l/r*p}px`,c.top=`${i+v+C/r*p}px`,r=/scaleX\(-1\)/.test(t.style.transform),c.left=`${a+(r?o-g-u:g)+(r?n-f-h:f)/n*u}px`,c.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let r=n.x||0,o=n.y||0,s=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let a of t)a.x=a.x*s+r,a.y=a.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var r=await ce.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!ce._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=ce.createQrEngine()),r?(this._onDecode?this._onDecode(r):this._legacyOnDecode&&this._legacyOnDecode(r.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",r.cornerPoints.map(({x:o,y:s})=>`${o},${s}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==ce.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],r=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...r,...n])try{let s=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),a=this._getFacingMode(s)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:s,facingMode:a}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,r,o=!1){r=r||document.createElement("canvas");let s=n&&n.x?n.x:0,a=n&&n.y?n.y:0,i=n&&n.width?n.width:t.videoWidth||t.width,h=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:i,n=n&&n.downScaledHeight?n.downScaledHeight:h,r.width!==o&&(r.width=o),r.height!==n&&(r.height=n)),n=r.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,s,a,i,h,0,0,r.width,r.height),[r,n]}static async _loadImage(t){if(t instanceof Image)return await ce._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await ce._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,r)=>{let o=s=>{t.removeEventListener("load",o),t.removeEventListener("error",o),s instanceof ErrorEvent?r("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,r,o){return ce._postWorkerMessageSync(await t,n,r,o)}static _postWorkerMessageSync(t,n,r,o){if(!(t instanceof Worker))return-1;let s=ce._workerMessageId++;return t.postMessage({id:s,type:n,data:r},o),s}};$t.DEFAULT_CANVAS_SIZE=400;$t.NO_QR_CODE_FOUND="No QR code found";$t._disableBarcodeDetector=!1;$t._workerMessageId=0;const lp="";function yo(){let e=localStorage.getItem("rcs_uuid");return e||(e=nd(),localStorage.setItem("rcs_uuid",e)),e}function _n(e){try{const t=localStorage.getItem("rcs_uuid");t&&t!==e&&!localStorage.getItem("rcs_uuid_previous")&&localStorage.setItem("rcs_uuid_previous",t)}catch{}localStorage.setItem("rcs_uuid",e)}function Dr(){try{return localStorage.getItem("rcs_uuid_previous")}catch{return null}}function cp(){const e=Dr();if(!e)return!1;try{localStorage.setItem("rcs_uuid",e),localStorage.removeItem("rcs_uuid_previous")}catch{return!1}return!0}let On=null;function dp(e){On=e}function sb(){return On}const ki="rcs_worker_token_",_i="rcs_worker_tokens";function Zn(){try{const e=localStorage.getItem(_i);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&typeof n.envId=="string"&&typeof n.token=="string"):[]}catch{return[]}}function Ei(e){try{localStorage.setItem(_i,JSON.stringify(e))}catch{}}function Lr(e){var n;return e?((n=Zn().find(r=>r.envId===e))==null?void 0:n.token)??null:null}function up(e,t,n){const r=Zn(),o=r.findIndex(s=>s.envId===e);o>=0?r[o]={...r[o],token:t,label:n??r[o].label}:r.push({envId:e,token:t,label:n}),Ei(r)}function fp(e){const t=Zn().filter(n=>n.envId!==e);Ei(t)}function Qt(){return Zn()}const $r=new Map;function ab(e,t){t?$r.set(e,t):$r.delete(e)}function hp(e){const t=$r.get(e);if(t){const n=Lr(t);if(n)return n}try{return localStorage.getItem(ki+e)}catch{return null}}function ib(e,t){try{localStorage.setItem(ki+e,t)}catch{}}class mp extends Error{constructor(n,r,o){super(n);le(this,"type");le(this,"status");this.name="ApiError",this.type=r,this.status=o}}async function Ie(e,t,n){const r={"Content-Type":"application/json"};On&&(r.Authorization=`Bearer ${On}`);const o=t.match(/^\/web\/sessions\/([^/]+)/);if(o){const l=o[1],u=hp(l);u&&(r["X-Worker-Token"]=u)}const s=yo(),a=t.includes("?")?"&":"?",i=`${lp}${t}${a}uuid=${encodeURIComponent(s)}`,h={method:e,headers:r};n!==void 0&&(h.body=JSON.stringify(n));const f=await fetch(i,h),c=await f.json();if(!f.ok){const l=c.error||{type:"unknown",message:f.statusText};throw new mp(l.message||l.type,l.type||"unknown",f.status)}return c}function pp(e){return Ie("POST","/web/bind",{sessionId:e})}function lb(){return Ie("GET","/web/sessions/all")}function cb(e){return Ie("GET",`/web/sessions/${e}`)}function db(e){return Ie("GET",`/web/sessions/${e}/history`)}function gp(){return Ie("GET","/web/environments")}function xp(e,t){return Ie("POST",`/web/environments/${e}/test-worker-token`,{token:t})}function vp(){return Ie("GET","/web/server-info")}function ub(e,t){return Ie("POST",`/web/sessions/${e}/events`,t)}function fb(e,t){return Ie("POST",`/web/sessions/${e}/control`,t)}function hb(e){return Ie("POST",`/web/sessions/${e}/interrupt`)}function mb(e){return Ie("DELETE",`/web/sessions/${e}`)}function pb(e){return Ie("POST","/web/sessions",e)}var Jn="Dialog",[Ni]=Qe(Jn),[bp,Le]=Ni(Jn),ji=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,i=m.useRef(null),h=m.useRef(null),[f,c]=at({prop:r,defaultProp:o??!1,onChange:s,caller:Jn});return d.jsx(bp,{scope:t,triggerRef:i,contentRef:h,contentId:Ce(),titleId:Ce(),descriptionId:Ce(),open:f,onOpenChange:c,onOpenToggle:m.useCallback(()=>c(l=>!l),[c]),modal:a,children:n})};ji.displayName=Jn;var Ai="DialogTrigger",yp=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Ai,n),s=pe(t,o.triggerRef);return d.jsx(ue.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":So(o.open),...r,ref:s,onClick:ee(e.onClick,o.onOpenToggle)})});yp.displayName=Ai;var wo="DialogPortal",[wp,Ri]=Ni(wo,{forceMount:void 0}),Ti=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Le(wo,t);return d.jsx(wp,{scope:t,forceMount:n,children:m.Children.map(r,a=>d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:a})}))})};Ti.displayName=wo;var Dn="DialogOverlay",Ii=m.forwardRef((e,t)=>{const n=Ri(Dn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Le(Dn,e.__scopeDialog);return s.modal?d.jsx(Ae,{present:r||s.open,children:d.jsx(Sp,{...o,ref:t})}):null});Ii.displayName=Dn;var Cp=Dt("DialogOverlay.RemoveScroll"),Sp=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Dn,n);return d.jsx(Kr,{as:Cp,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(ue.div,{"data-state":So(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),St="DialogContent",Mi=m.forwardRef((e,t)=>{const n=Ri(St,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Le(St,e.__scopeDialog);return d.jsx(Ae,{present:r||s.open,children:s.modal?d.jsx(kp,{...o,ref:t}):d.jsx(_p,{...o,ref:t})})});Mi.displayName=St;var kp=m.forwardRef((e,t)=>{const n=Le(St,e.__scopeDialog),r=m.useRef(null),o=pe(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return fo(s)},[]),d.jsx(Pi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,i=a.button===0&&a.ctrlKey===!0;(a.button===2||i)&&s.preventDefault()}),onFocusOutside:ee(e.onFocusOutside,s=>s.preventDefault())})}),_p=m.forwardRef((e,t)=>{const n=Le(St,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return d.jsx(Pi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,i;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var h,f;(h=e.onInteractOutside)==null||h.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Pi=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,i=Le(St,n),h=m.useRef(null),f=pe(t,h);return Jr(),d.jsxs(d.Fragment,{children:[d.jsx(Wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(ln,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":So(i.open),...a,ref:f,onDismiss:()=>i.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Ep,{titleId:i.titleId}),d.jsx(jp,{contentRef:h,descriptionId:i.descriptionId})]})]})}),Co="DialogTitle",Oi=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Co,n);return d.jsx(ue.h2,{id:o.titleId,...r,ref:t})});Oi.displayName=Co;var Di="DialogDescription",Li=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Di,n);return d.jsx(ue.p,{id:o.descriptionId,...r,ref:t})});Li.displayName=Di;var $i="DialogClose",Fi=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le($i,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});Fi.displayName=$i;function So(e){return e?"open":"closed"}var Ui="DialogTitleWarning",[gb,zi]=Au(Ui,{contentName:St,titleName:Co,docsSlug:"dialog"}),Ep=({titleId:e})=>{const t=zi(Ui),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
228
228
 
229
229
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
230
230
 
231
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Np="DialogDescriptionWarning",jp=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zi(Np).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Bi=ji,Wi=Ti,Hi=Ii,Vi=Mi,Ap=Oi,Rp=Li,Tp=Fi;function Gi({...e}){return d.jsx(Bi,{"data-slot":"dialog",...e})}function Ip({...e}){return d.jsx(Wi,{"data-slot":"dialog-portal",...e})}function Mp({className:e,...t}){return d.jsx(Hi,{"data-slot":"dialog-overlay",className:Z("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ki({className:e,children:t,showCloseButton:n=!0,...r}){return d.jsxs(Ip,{"data-slot":"dialog-portal",children:[d.jsx(Mp,{}),d.jsxs(Vi,{"data-slot":"dialog-content",className:Z("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&d.jsxs(Tp,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(an,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function qi({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:Z("flex flex-col gap-2 text-center sm:text-left",e),...t})}function gy({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:Z("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Yi({className:e,...t}){return d.jsx(Ap,{"data-slot":"dialog-title",className:Z("text-lg leading-none font-semibold",e),...t})}function Pp({className:e,...t}){return d.jsx(Rp,{"data-slot":"dialog-description",className:Z("text-muted-foreground text-sm",e),...t})}function Op(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m ${e%60}s`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Dp({open:e,onClose:t}){const[n,r]=m.useState(!1),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),[c,l]=m.useState(""),[u,p]=m.useState(""),[g,v]=m.useState(""),[C,b]=m.useState(()=>Dr()),R=m.useRef(null),j=m.useRef(null),_=m.useRef(null),$=bo(),{resolvedTheme:k}=ca(),N=k==="dark"?{dark:"#ECE9E0",light:"#1C1B18"}:{dark:"#141413",light:"#FDFCF8"};if(m.useEffect(()=>{e&&(l(""),vp().then(D=>f(D)).catch(D=>l(D instanceof Error?D.message:"Failed to load server info")))},[e]),m.useEffect(()=>{if(!e||!a)return;const D=requestAnimationFrame(()=>{if(!R.current)return;const S=`${window.location.origin}/code?uuid=${encodeURIComponent($)}`;ic.toCanvas(R.current,S,{width:200,margin:1,color:N}).catch(w=>{console.error("QR generation failed:",w)})});return()=>cancelAnimationFrame(D)},[e,a,$,k,N]),m.useEffect(()=>{!e&&_.current&&(_.current.stop(),_.current.destroy(),_.current=null,s(!1))},[e]),!e)return null;const x=async()=>{await navigator.clipboard.writeText($),r(!0),setTimeout(()=>r(!1),2e3)},y=()=>{const D=u.trim();if(D.length<32){v("Invalid UUID");return}v(""),_n(D),b(Dr()),window.location.reload()},A=()=>{cp()&&(b(null),window.location.reload())},O=async()=>{if(j.current){s(!0);try{const D=new $t(j.current,S=>{F(S.data)},{returnDetailedScanResult:!0});_.current=D,await D.start()}catch(D){console.error("Camera error:",D),s(!1)}}},P=()=>{_.current&&(_.current.stop(),_.current.destroy(),_.current=null),s(!1)},F=D=>{try{const S=JSON.parse(D);if(S.url&&S.token){P(),t(),sessionStorage.setItem("acp_connection",JSON.stringify({url:S.url,token:S.token})),window.location.href="/code/?acp=1";return}}catch{}try{const w=new URL(D).searchParams.get("uuid");if(w){_n(w),P(),t();return}}catch{}if(D.length>=32){_n(D),P(),t();return}},M=()=>{const D=document.createElement("input");D.type="file",D.accept="image/*",D.onchange=async S=>{var L;const w=(L=S.target.files)==null?void 0:L[0];if(w)try{const E=await $t.scanImage(w,{returnDetailedScanResult:!0});F(E.data)}catch{alert("No QR code found in image")}},D.click()};return d.jsx(Gi,{open:e,onOpenChange:D=>{D||t()},children:d.jsxs(Ki,{className:"max-w-sm rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsx(qi,{children:d.jsx(Yi,{className:"font-display text-lg font-semibold text-text-primary",children:"Identity & Server"})}),d.jsxs("div",{className:"space-y-5",children:[d.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 p-3",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-text-secondary",children:[d.jsx(eu,{className:"h-4 w-4"}),"Server"]}),c?d.jsx("p",{className:"text-xs text-status-error",children:c}):h?d.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Version"}),d.jsx("dd",{className:"font-mono text-text-primary",children:h.version})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Uptime"}),d.jsx("dd",{className:"font-mono text-text-primary",children:Op(h.uptime_seconds)})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Workers"}),d.jsxs("dd",{className:"font-mono text-text-primary",children:[h.workers_active," active / ",h.workers_total]})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Your sessions"}),d.jsxs("dd",{className:"font-mono text-text-primary",children:[h.sessions_active," active / ",h.sessions_owned," owned"]})]})]}):d.jsx("p",{className:"text-xs text-text-muted",children:"Loading…"})]}),d.jsxs("section",{children:[d.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-text-secondary",children:[d.jsx(aa,{className:"h-4 w-4"}),"Your Identity"]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 truncate rounded-lg bg-surface-2 px-3 py-2 font-mono text-xs text-text-primary",children:$}),d.jsx("button",{onClick:x,className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:n?"Copied!":"Copy"})]}),d.jsx("p",{className:"mt-2 text-xs text-text-muted",children:"此 UUID 标识你创建的会话归属。分享它可授予他人访问你创建的会话。"}),C&&C!==$&&d.jsxs("div",{className:"mt-3 flex items-center justify-between rounded-lg border border-border bg-surface-2 px-3 py-2",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-xs font-medium text-text-secondary",children:"已切换至他人身份"}),d.jsxs("p",{className:"truncate font-mono text-xs text-text-muted",children:["原 UUID: ",C]})]}),d.jsx("button",{onClick:A,className:"ml-2 shrink-0 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-1",children:"Switch back"})]}),d.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[d.jsx("input",{type:"text",value:u,onChange:D=>{p(D.target.value),v("")},onKeyDown:D=>{D.key==="Enter"&&u.trim()&&y()},placeholder:"粘贴他人的 UUID 以访问其会话",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 font-mono text-xs text-text-primary placeholder:text-text-muted focus:border-border focus:outline-none"}),d.jsxs("button",{onClick:y,disabled:!u.trim(),className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(ta,{className:"h-4 w-4"}),"Import"]})]}),g&&d.jsx("p",{className:"mt-1 text-xs text-status-error",children:g})]}),d.jsxs("section",{className:"border-t border-border pt-4",children:[d.jsxs("button",{onClick:()=>i(!a),className:"flex w-full items-center justify-between text-sm font-medium text-text-secondary hover:text-text-primary transition-colors",children:[d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(lu,{className:"h-4 w-4"}),"Device Sync"]}),d.jsx("span",{className:"text-xs text-text-muted",children:a?"▾":"▸"})]}),a&&d.jsxs("div",{className:"mt-4 space-y-4",children:[!o&&d.jsxs("div",{children:[d.jsx("label",{className:"mb-2 block text-xs text-text-secondary",children:"Scan on another device"}),d.jsx("div",{className:"flex justify-center",children:d.jsx("canvas",{ref:R})})]}),o&&d.jsxs("div",{children:[d.jsx("label",{className:"mb-2 block text-xs text-text-secondary",children:"Camera scanner"}),d.jsx("div",{className:"relative overflow-hidden rounded-lg",children:d.jsx("video",{ref:j,className:"w-full"})}),d.jsx("button",{onClick:P,className:"mt-2 w-full rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Stop scanning"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("button",{onClick:o?P:O,className:Z("flex flex-1 items-center justify-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors",o?"border-status-error/30 text-status-error hover:bg-status-error/10":"border-border text-text-secondary hover:bg-surface-2"),children:[d.jsx(qd,{className:"h-4 w-4"}),o?"Stop":"Scan"]}),d.jsx("button",{onClick:M,className:"flex flex-1 items-center justify-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Upload"})]})]})]})]})]})})}const ko="rcs_worker_tokens",xs="rcs_worker_token_",vs="rcs_worker_tokens_migrated";function Lp(){let e=Qt();if(typeof window>"u")return e;try{if(localStorage.getItem(vs))return e}catch{return e}try{for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!n||!n.startsWith(xs))continue;const r=n.slice(xs.length);if(!r)continue;const o=localStorage.getItem(n);if(!o)continue;const s=`__legacy_${r}`;e.some(a=>a.envId===s)||(e=[...e,{envId:s,token:o,label:`Migrated (session ${r.slice(0,8)})`}])}localStorage.setItem(ko,JSON.stringify(e)),localStorage.setItem(vs,"1")}catch{}return e}function xy(e){const t=Qt();let n=!1;const r=t.map(o=>{if(!o.envId.startsWith("__legacy_"))return o;const s=o.envId.slice(9),a=e.find(h=>h.id===s),i=a==null?void 0:a.environment_id;return i?t.some(h=>h!==o&&h.envId===i)?(n=!0,null):(n=!0,{...o,envId:i}):o}).filter(o=>o!==null);if(n){try{localStorage.setItem(ko,JSON.stringify(r))}catch{}window.dispatchEvent(new Event("rcs_worker_tokens_changed"))}}function $p(){const[e,t]=m.useState(()=>Lp()),n=m.useCallback(()=>{t(Qt())},[]);m.useEffect(()=>{const i=()=>t(Qt());return window.addEventListener("rcs_worker_tokens_changed",i),window.addEventListener("storage",i),()=>{window.removeEventListener("rcs_worker_tokens_changed",i),window.removeEventListener("storage",i)}},[]);const r=m.useCallback(i=>Lr(i),[]),o=m.useCallback((i,h,f)=>{up(i,h,f),n()},[n]),s=m.useCallback(i=>{fp(i),n()},[n]),a=m.useCallback(async i=>{const h=Lr(i);if(!h)return"unknown";try{const f=await xp(i,h),c=Qt().map(l=>l.envId===i?{...l,verifiedAt:f.valid?Date.now():l.verifiedAt}:l);try{localStorage.setItem(ko,JSON.stringify(c))}catch{}return n(),f.valid?"valid":"invalid"}catch{return"unknown"}},[n]);return{entries:e,getForEnv:r,add:o,remove:s,verify:a,refresh:n}}function Fp({open:e,onClose:t,tokens:n,activeTokenId:r,onSetActive:o,onAdd:s,onRemove:a,onUpdate:i}){const[h,f]=m.useState("api_keys");return d.jsx(Gi,{open:e,onOpenChange:c=>{c||t()},children:d.jsxs(Ki,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsxs(qi,{children:[d.jsx(Yi,{className:"font-display text-lg font-semibold text-text-primary",children:"Token Manager"}),d.jsx(Pp,{className:"text-sm text-text-muted",children:"Manage API tokens and per-environment worker tokens for RCS authentication."})]}),d.jsxs("div",{className:"flex border-b border-border",children:[d.jsx("button",{onClick:()=>f("api_keys"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${h==="api_keys"?"border-b-2 border-brand text-text-primary":"text-text-muted hover:text-text-secondary"}`,children:"API Keys"}),d.jsx("button",{onClick:()=>f("worker_tokens"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${h==="worker_tokens"?"border-b-2 border-brand text-text-primary":"text-text-muted hover:text-text-secondary"}`,children:"Worker Tokens"})]}),h==="api_keys"?d.jsx(Up,{tokens:n,activeTokenId:r,onSetActive:o,onAdd:s,onRemove:a,onUpdate:i,onClose:t}):d.jsx(zp,{})]})})}function Up({tokens:e,activeTokenId:t,onSetActive:n,onAdd:r,onRemove:o,onUpdate:s,onClose:a}){const[i,h]=m.useState(""),[f,c]=m.useState(""),[l,u]=m.useState(""),[p,g]=m.useState(null),[v,C]=m.useState(""),[b,R]=m.useState(null),[j,_]=m.useState(null),$=(A,O)=>{navigator.clipboard.writeText(O).then(()=>{_(A),setTimeout(()=>_(null),1500)})},k=()=>{const A=r(i,f);if(A){u(A);return}h(""),c(""),u("")},N=A=>{g(A.id),C(A.label)},x=A=>{s(A,v.trim()||"Unnamed"),g(null)},y=A=>{n(A),a()};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(A=>d.jsx("div",{className:"group flex items-center gap-1",children:p===A.id?d.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-lg bg-surface-2 px-3 py-1.5",children:[d.jsx("input",{value:v,onChange:O=>C(O.target.value),onKeyDown:O=>{O.key==="Enter"&&x(A.id),O.key==="Escape"&&g(null)},className:"flex-1 rounded border border-border bg-surface-1 px-2 py-1 text-sm text-text-primary focus:border-brand focus:outline-none",autoFocus:!0}),d.jsx("button",{onClick:()=>x(A.id),className:"text-brand hover:opacity-70 transition-opacity",children:d.jsx(wt,{className:"h-4 w-4"})}),d.jsx("button",{onClick:()=>g(null),className:"text-text-muted hover:text-text-primary transition-colors",children:d.jsx(an,{className:"h-4 w-4"})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>y(A.id),className:`flex flex-1 items-center justify-between rounded-lg px-3 py-2 text-sm transition-colors ${t===A.id?"bg-brand/10 text-brand":"text-text-secondary hover:bg-surface-2"}`,children:[d.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[d.jsx("span",{className:"font-medium truncate w-full",children:A.label}),d.jsx("span",{className:"text-xs text-text-muted font-mono",children:b===A.id?A.token:`${A.token.slice(0,6)}${"•".repeat(6)}`})]}),t===A.id&&d.jsx(wt,{className:"h-4 w-4 flex-shrink-0"})]}),d.jsx("button",{onClick:()=>R(b===A.id?null:A.id),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Toggle token visibility",children:b===A.id?d.jsx(Js,{className:"h-3.5 w-3.5"}):d.jsx(ea,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>$(A.id,A.token),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Copy token",children:j===A.id?d.jsx(wt,{className:"h-3.5 w-3.5 text-status-active"}):d.jsx(Cd,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>N(A),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Edit label",children:d.jsx(Vd,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>o(A.id),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-status-error transition-all",title:"Delete token",children:d.jsx(sa,{className:"h-3.5 w-3.5"})})]})},A.id)),e.length===0&&d.jsx("div",{className:"py-4 text-center text-sm text-text-muted",children:"No tokens saved yet. Add one below."})]}),d.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[d.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"Add Token"}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("input",{type:"text",value:i,onChange:A=>{h(A.target.value),u("")},placeholder:"API Token",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono",onKeyDown:A=>{A.key==="Enter"&&k()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:f,onChange:A=>c(A.target.value),placeholder:"Label (optional)",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:A=>{A.key==="Enter"&&k()}}),d.jsx("button",{onClick:k,disabled:!i.trim(),className:"rounded-lg bg-brand px-3 py-2 text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:d.jsx(Bn,{className:"h-4 w-4"})})]})]}),l&&d.jsx("div",{className:"text-xs text-status-error",children:l})]})]})}function zp(){const{entries:e,add:t,remove:n,verify:r,refresh:o}=$p(),[s,a]=m.useState([]),[i,h]=m.useState(""),[f,c]=m.useState(""),[l,u]=m.useState(""),[p,g]=m.useState(""),[v,C]=m.useState(new Set),[b,R]=m.useState({});m.useEffect(()=>{gp().then(N=>a(N||[])).catch(N=>console.error("Failed to load environments:",N))},[]);const j=N=>{if(N.startsWith("__legacy_"))return`Legacy session ${N.slice(9).slice(0,8)}`;const x=s.find(y=>y.id===N);return(x==null?void 0:x.machine_name)||N},_=()=>{const N=f.trim();if(!N){g("Token is required");return}if(!i){g("Select an environment");return}t(i,N,l.trim()||void 0),c(""),u(""),g("")},$=async N=>{R(y=>({...y,[N]:"pending"}));const x=await r(N);R(y=>({...y,[N]:x})),o()},k=N=>{C(x=>{const y=new Set(x);return y.has(N)?y.delete(N):y.add(N),y})};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(N=>{const x=b[N.envId];return d.jsxs("div",{className:"group flex items-center gap-1 rounded-lg px-2 py-2 text-sm text-text-secondary hover:bg-surface-2",children:[d.jsxs("div",{className:"flex flex-1 flex-col items-start min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[d.jsx("span",{className:"font-medium truncate",children:j(N.envId)}),N.label&&d.jsxs("span",{className:"text-xs text-text-muted truncate",children:["· ",N.label]}),x==="valid"&&d.jsx(Vo,{className:"h-3.5 w-3.5 text-status-active flex-shrink-0"}),x==="invalid"&&d.jsx(Qr,{className:"h-3.5 w-3.5 text-status-error flex-shrink-0"})]}),d.jsx("span",{className:"text-xs text-text-muted font-mono",children:v.has(N.envId)?N.token:`${N.token.slice(0,6)}${"•".repeat(6)}`})]}),d.jsx("button",{onClick:()=>k(N.envId),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Toggle token visibility",children:v.has(N.envId)?d.jsx(Js,{className:"h-3.5 w-3.5"}):d.jsx(ea,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>$(N.envId),disabled:x==="pending",className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-brand transition-all disabled:opacity-50",title:"Test token",children:d.jsx(Vo,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>n(N.envId),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-status-error transition-all",title:"Delete worker token",children:d.jsx(sa,{className:"h-3.5 w-3.5"})})]},N.envId)}),e.length===0&&d.jsx("div",{className:"py-4 text-center text-sm text-text-muted",children:"No worker tokens saved. Add one for an environment below."})]}),d.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[d.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"Add Worker Token"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("select",{value:i,onChange:N=>h(N.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[d.jsx("option",{value:"",children:"-- Select environment --"}),s.map(N=>d.jsxs("option",{value:N.id,children:[N.machine_name||N.id,N.has_worker_token?" (protected)":" (open)"]},N.id))]}),d.jsx("input",{type:"password",value:f,onChange:N=>{c(N.target.value),g("")},placeholder:"RCS_WORKER_TOKENS value",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono",onKeyDown:N=>{N.key==="Enter"&&_()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:l,onChange:N=>u(N.target.value),placeholder:"Label (optional)",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:N=>{N.key==="Enter"&&_()}}),d.jsx("button",{onClick:_,disabled:!f.trim()||!i,className:"rounded-lg bg-brand px-3 py-2 text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:d.jsx(Bn,{className:"h-4 w-4"})})]})]}),p&&d.jsx("div",{className:"text-xs text-status-error",children:p}),d.jsx("p",{className:"text-xs text-text-muted",children:"Worker tokens are stored per-environment and applied automatically to all sessions in that environment."})]})]})}function Bp(e){const t=new TextEncoder().encode(e);let n="";for(const o of t)n+=String.fromCharCode(o);return`rcs.auth.${btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}class Xi extends Error{constructor(){super("Disconnect requested"),this.name="DisconnectRequestedError"}}const st=class st{constructor(t){le(this,"ws",null);le(this,"settings");le(this,"connectionState","disconnected");le(this,"sessionId",null);le(this,"_agentCapabilities",null);le(this,"_promptCapabilities",null);le(this,"_modelState",null);le(this,"_availableCommands",[]);le(this,"onModelChanged",new Set);le(this,"onModelStateChanged",new Set);le(this,"onAvailableCommandsChanged",null);le(this,"onSessionLoaded",null);le(this,"onSessionSwitching",null);le(this,"onConnectionStateChange",new Set);le(this,"onSessionUpdate",null);le(this,"onSessionCreated",null);le(this,"onPromptComplete",null);le(this,"onPermissionRequest",null);le(this,"onBrowserToolCall",null);le(this,"onErrorMessage",null);le(this,"pendingSessionList",null);le(this,"pendingSessionLoad",null);le(this,"pendingSessionResume",null);le(this,"pendingSessionTarget",null);le(this,"connectResolve",null);le(this,"connectReject",null);le(this,"heartbeatInterval",null);le(this,"heartbeatTimeout",null);le(this,"missedPongs",0);this.settings=t}updateSettings(t){this.settings=t}setConnectionStateHandler(t){this.onConnectionStateChange.add(t)}removeConnectionStateHandler(t){this.onConnectionStateChange.delete(t)}setSessionUpdateHandler(t){this.onSessionUpdate=t}setSessionCreatedHandler(t){this.onSessionCreated=t}setPromptCompleteHandler(t){this.onPromptComplete=t}setModelChangedHandler(t){this.onModelChanged.add(t)}removeModelChangedHandler(t){this.onModelChanged.delete(t)}setModelStateChangedHandler(t){this.onModelStateChanged.add(t),t(this._modelState)}removeModelStateChangedHandler(t){this.onModelStateChanged.delete(t)}setAvailableCommandsChangedHandler(t){this.onAvailableCommandsChanged=t,t(this._availableCommands)}setPermissionRequestHandler(t){this.onPermissionRequest=t}setBrowserToolCallHandler(t){this.onBrowserToolCall=t}setErrorMessageHandler(t){this.onErrorMessage=t}setSessionSwitchingHandler(t){this.onSessionSwitching=t}setState(t,n){this.connectionState=t;for(const r of this.onConnectionStateChange)r(t,n)}getState(){return this.connectionState}getSessionId(){return this.sessionId}get supportsImages(){var t;return((t=this._promptCapabilities)==null?void 0:t.image)===!0}getPromptCapabilities(){return this._promptCapabilities}get modelState(){return this._modelState}get availableCommands(){return this._availableCommands}get supportsModelSelection(){return this._modelState!==null&&this._modelState.availableModels.length>0}get agentCapabilities(){return this._agentCapabilities}get supportsLoadSession(){var t;return((t=this._agentCapabilities)==null?void 0:t.loadSession)===!0}get supportsResumeSession(){var t,n,r,o;return((n=(t=this._agentCapabilities)==null?void 0:t.sessionCapabilities)==null?void 0:n.resume)!==void 0&&((o=(r=this._agentCapabilities)==null?void 0:r.sessionCapabilities)==null?void 0:o.resume)!==null}get supportsSessionList(){var t,n,r,o;return((n=(t=this._agentCapabilities)==null?void 0:t.sessionCapabilities)==null?void 0:n.list)!==void 0&&((o=(r=this._agentCapabilities)==null?void 0:r.sessionCapabilities)==null?void 0:o.list)!==null}get supportsSessionHistory(){return this.supportsLoadSession||this.supportsResumeSession}async connect(){if(this.ws){const t=this.ws;this.ws=null;try{t.close()}catch{}this.stopHeartbeat(),this.connectResolve=null,this.connectReject=null}return this.setState("connecting"),new Promise((t,n)=>{this.connectResolve=t,this.connectReject=n;try{const r=new WebSocket(this.settings.proxyUrl,this.settings.token?[Bp(this.settings.token)]:void 0);this.ws=r,r.onopen=()=>{if(this.ws!==r){console.log("[ACPClient] WebSocket opened but already disconnected/replaced, closing stale socket"),r.close();return}console.log("[ACPClient] WebSocket connected, sending connect command"),this.send({type:"connect"})},r.onmessage=o=>{if(this.ws===r)try{const s=JSON.parse(o.data);this.handleResponse(s)}catch(s){console.error("[ACPClient] Failed to parse message:",s)}},r.onerror=()=>{var o;this.ws===r&&(console.error("[ACPClient] WebSocket error"),this.setState("error","WebSocket connection error"),(o=this.connectReject)==null||o.call(this,new Error("WebSocket connection error")),this.connectResolve=null,this.connectReject=null)},r.onclose=o=>{if(this.ws===r){if(console.log("[ACPClient] WebSocket closed",o.code,o.reason),this.connectReject){const s=o.reason||`Connection closed (code: ${o.code})`;this.setState("error",s),this.connectReject(new Error(s)),this.connectResolve=null,this.connectReject=null}else this.setState("disconnected");this.ws=null,this.sessionId=null}}}catch(r){this.setState("error",r.message),n(r)}})}handleResponse(t){var n,r,o,s,a,i,h,f,c,l,u;switch(console.log("[ACPClient] Received:",t.type),t.type){case"status":t.payload.connected?(this._agentCapabilities=t.payload.capabilities??null,this.setState("connected"),this.startHeartbeat(),(n=this.connectResolve)==null||n.call(this,void 0)):(this.stopHeartbeat(),this.setState("disconnected")),this.connectResolve=null,this.connectReject=null;break;case"error":console.error("[ACPClient] Error:",t.payload);const p=((r=t.payload)==null?void 0:r.message)||JSON.stringify(t.payload);this.pendingSessionTarget=null,this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.reject(new Error(p)),this.pendingSessionList=null),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.reject(new Error(p)),this.pendingSessionLoad=null),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.reject(new Error(p)),this.pendingSessionResume=null),this.connectReject?(this.connectReject(new Error(p)),this.connectResolve=null,this.connectReject=null):(console.error("[ACPClient] Agent error:",p),(o=this.onErrorMessage)==null||o.call(this,p));break;case"session_created":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session created, promptCapabilities:",this._promptCapabilities,"models:",this._modelState),(s=this.onSessionCreated)==null||s.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_list":console.log("[ACPClient] Session list received:",t.payload.sessions.length,"sessions"),this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.resolve(t.payload),this.pendingSessionList=null);break;case"session_loaded":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session loaded:",t.payload.sessionId),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.resolve(t.payload.sessionId),this.pendingSessionLoad=null),(a=this.onSessionLoaded)==null||a.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_resumed":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session resumed:",t.payload.sessionId),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.resolve(t.payload.sessionId),this.pendingSessionResume=null),(i=this.onSessionLoaded)==null||i.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_update":const g=(h=t.payload.update)==null?void 0:h.sessionUpdate;console.log("[ACPClient] session_update type:",g,"payload:",t.payload),g==="available_commands_update"&&(this._availableCommands=t.payload.update.availableCommands,console.log("[ACPClient] Available commands updated:",this._availableCommands.length,"commands"),(f=this.onAvailableCommandsChanged)==null||f.call(this,this._availableCommands)),(c=this.onSessionUpdate)==null||c.call(this,t.payload.sessionId,t.payload.update);break;case"prompt_complete":(l=this.onPromptComplete)==null||l.call(this,t.payload.stopReason);break;case"permission_request":console.log("[ACPClient] Permission request:",t.payload),(u=this.onPermissionRequest)==null||u.call(this,t.payload);break;case"model_changed":console.log("[ACPClient] Model changed:",t.payload.modelId),this._modelState&&(this._modelState={...this._modelState,currentModelId:t.payload.modelId});for(const v of this.onModelChanged)v(t.payload.modelId);break;case"browser_tool_call":this.handleBrowserToolCall(t.callId,t.params);break;case"pong":this.missedPongs=0,this.heartbeatTimeout&&(clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=null);break}}async handleBrowserToolCall(t,n){if(console.log("[ACPClient] Browser tool call:",t,n),!this.onBrowserToolCall){console.error("[ACPClient] No browser tool handler registered"),this.send({type:"browser_tool_result",callId:t,result:{error:"No browser tool handler registered"}});return}try{const r=await this.onBrowserToolCall(n);this.send({type:"browser_tool_result",callId:t,result:r})}catch(r){console.error("[ACPClient] Browser tool error:",r),this.send({type:"browser_tool_result",callId:t,result:{error:r.message}})}}startHeartbeat(){this.stopHeartbeat(),this.missedPongs=0,this.heartbeatInterval=setInterval(()=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.stopHeartbeat();return}this.ws.send(JSON.stringify({type:"ping"})),this.heartbeatTimeout=setTimeout(()=>{var t;this.missedPongs++,this.missedPongs>=st.MAX_MISSED_PONGS&&(console.warn(`[ACPClient] Server unresponsive (${this.missedPongs} missed pongs), closing connection`),this.stopHeartbeat(),(t=this.ws)==null||t.close(4e3,"Heartbeat timeout"))},st.PONG_TIMEOUT_MS)},st.HEARTBEAT_INTERVAL_MS)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null),this.heartbeatTimeout&&(clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=null)}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(t))}async createSession(t,n){const r=t??this.settings.cwd;this.send({type:"new_session",payload:{cwd:r,permissionMode:n}})}async sendPrompt(t){if(!this.sessionId)throw new Error("No active session");const n=typeof t=="string"?[{type:"text",text:t}]:t;this.send({type:"prompt",payload:{content:n}})}cancel(){this.send({type:"cancel"})}async setSessionModel(t){if(!this.sessionId)throw new Error("No active session");this.send({type:"set_session_model",payload:{modelId:t}})}respondToPermission(t,n){const r=n?{outcome:"selected",optionId:n}:{outcome:"cancelled"};this.send({type:"permission_response",payload:{requestId:t,outcome:r}})}setSessionLoadedHandler(t){this.onSessionLoaded=t}async listSessions(t){if(!this.supportsSessionList)throw new Error("Listing sessions is not supported by this agent");return new Promise((n,r)=>{const o=setTimeout(()=>{this.pendingSessionList&&(this.pendingSessionList=null,r(new Error("List sessions timed out")))},3e4);this.pendingSessionList={resolve:n,reject:r,timer:o};try{this.send({type:"list_sessions",payload:t})}catch(s){clearTimeout(o),this.pendingSessionList=null,r(s)}})}async loadSession(t){if(!this.supportsLoadSession)throw new Error("Loading sessions is not supported by this agent");return new Promise((n,r)=>{var s;this.pendingSessionTarget=t.sessionId,(s=this.onSessionSwitching)==null||s.call(this,t.sessionId);const o=setTimeout(()=>{this.pendingSessionLoad&&(this.pendingSessionTarget=null,this.pendingSessionLoad=null,r(new Error("Load session timed out")))},6e4);this.pendingSessionLoad={resolve:n,reject:r,timer:o};try{this.send({type:"load_session",payload:t})}catch(a){clearTimeout(o),this.pendingSessionTarget=null,this.pendingSessionLoad=null,r(a)}})}async resumeSession(t){if(!this.supportsResumeSession)throw new Error("Resuming sessions is not supported by this agent");return new Promise((n,r)=>{var s;this.pendingSessionTarget=t.sessionId,(s=this.onSessionSwitching)==null||s.call(this,t.sessionId);const o=setTimeout(()=>{this.pendingSessionResume&&(this.pendingSessionTarget=null,this.pendingSessionResume=null,r(new Error("Resume session timed out")))},3e4);this.pendingSessionResume={resolve:n,reject:r,timer:o};try{this.send({type:"resume_session",payload:t})}catch(a){clearTimeout(o),this.pendingSessionTarget=null,this.pendingSessionResume=null,r(a)}})}disconnect(){var n;this.stopHeartbeat(),this.connectReject&&this.connectReject(new Xi),this.connectResolve=null,this.connectReject=null,this.ws&&(this.ws.close(),this.ws=null),this.setState("disconnected"),this.sessionId=null,this.pendingSessionTarget=null,this._modelState=null,this._agentCapabilities=null,this._availableCommands=[];for(const r of this.onModelStateChanged)r(null);(n=this.onAvailableCommandsChanged)==null||n.call(this,[]);const t=new Error("Disconnected");this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.reject(t),this.pendingSessionList=null),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.reject(t),this.pendingSessionLoad=null),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.reject(t),this.pendingSessionResume=null)}};le(st,"HEARTBEAT_INTERVAL_MS",3e4),le(st,"PONG_TIMEOUT_MS",1e4),le(st,"MAX_MISSED_PONGS",2);let Fr=st;function Wp(e,t){return t.forEach((function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach((function(r){if(r!=="default"&&!(r in e)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}}))})),Object.freeze(e)}function Qi(e,t){return new Promise((function(n,r){let o;return Hp(e).then((function(s){try{return o=s,n(new Blob([t.slice(0,2),o,t.slice(2)],{type:"image/jpeg"}))}catch(a){return r(a)}}),r)}))}const Hp=e=>new Promise(((t,n)=>{const r=new FileReader;r.addEventListener("load",(({target:{result:o}})=>{const s=new DataView(o);let a=0;if(s.getUint16(a)!==65496)return n("not a valid JPEG");for(a+=2;;){const i=s.getUint16(a);if(i===65498)break;const h=s.getUint16(a+2);if(i===65505&&s.getUint32(a+4)===1165519206){const f=a+10;let c;switch(s.getUint16(f)){case 18761:c=!0;break;case 19789:c=!1;break;default:return n("TIFF header contains invalid endian")}if(s.getUint16(f+2,c)!==42)return n("TIFF header contains invalid version");const l=s.getUint32(f+4,c),u=f+l+2+12*s.getUint16(f+l,c);for(let p=f+l+2;p<u;p+=12)if(s.getUint16(p,c)==274){if(s.getUint16(p+2,c)!==3)return n("Orientation data type is invalid");if(s.getUint32(p+4,c)!==1)return n("Orientation data count is invalid");s.setUint16(p+8,1,c);break}return t(o.slice(a,a+2+h))}a+=2+h}return t(new Blob)})),r.readAsArrayBuffer(e)}));var Ln={},Vp={get exports(){return Ln},set exports(e){Ln=e}};(function(e){var t,n,r={};Vp.exports=r,r.parse=function(o,s){for(var a=r.bin.readUshort,i=r.bin.readUint,h=0,f={},c=new Uint8Array(o),l=c.length-4;i(c,l)!=101010256;)l--;h=l,h+=4;var u=a(c,h+=4);a(c,h+=2);var p=i(c,h+=2),g=i(c,h+=4);h+=4,h=g;for(var v=0;v<u;v++){i(c,h),h+=4,h+=4,h+=4,i(c,h+=4),p=i(c,h+=4);var C=i(c,h+=4),b=a(c,h+=4),R=a(c,h+2),j=a(c,h+4);h+=6;var _=i(c,h+=8);h+=4,h+=b+R+j,r._readLocal(c,_,f,p,C,s)}return f},r._readLocal=function(o,s,a,i,h,f){var c=r.bin.readUshort,l=r.bin.readUint;l(o,s),c(o,s+=4),c(o,s+=2);var u=c(o,s+=2);l(o,s+=2),l(o,s+=4),s+=4;var p=c(o,s+=8),g=c(o,s+=2);s+=2;var v=r.bin.readUTF8(o,s,p);if(s+=p,s+=g,f)a[v]={size:h,csize:i};else{var C=new Uint8Array(o.buffer,s);if(u==0)a[v]=new Uint8Array(C.buffer.slice(s,s+i));else{if(u!=8)throw"unknown compression method: "+u;var b=new Uint8Array(h);r.inflateRaw(C,b),a[v]=b}}},r.inflateRaw=function(o,s){return r.F.inflate(o,s)},r.inflate=function(o,s){return o[0],o[1],r.inflateRaw(new Uint8Array(o.buffer,o.byteOffset+2,o.length-6),s)},r.deflate=function(o,s){s==null&&(s={level:6});var a=0,i=new Uint8Array(50+Math.floor(1.1*o.length));i[a]=120,i[a+1]=156,a+=2,a=r.F.deflateRaw(o,i,a,s.level);var h=r.adler(o,0,o.length);return i[a+0]=h>>>24&255,i[a+1]=h>>>16&255,i[a+2]=h>>>8&255,i[a+3]=h>>>0&255,new Uint8Array(i.buffer,0,a+4)},r.deflateRaw=function(o,s){s==null&&(s={level:6});var a=new Uint8Array(50+Math.floor(1.1*o.length)),i=r.F.deflateRaw(o,a,i,s.level);return new Uint8Array(a.buffer,0,i)},r.encode=function(o,s){s==null&&(s=!1);var a=0,i=r.bin.writeUint,h=r.bin.writeUshort,f={};for(var c in o){var l=!r._noNeed(c)&&!s,u=o[c],p=r.crc.crc(u,0,u.length);f[c]={cpr:l,usize:u.length,crc:p,file:l?r.deflateRaw(u):u}}for(var c in f)a+=f[c].file.length+30+46+2*r.bin.sizeUTF8(c);a+=22;var g=new Uint8Array(a),v=0,C=[];for(var c in f){var b=f[c];C.push(v),v=r._writeHeader(g,v,c,b,0)}var R=0,j=v;for(var c in f)b=f[c],C.push(v),v=r._writeHeader(g,v,c,b,1,C[R++]);var _=v-j;return i(g,v,101010256),v+=4,h(g,v+=4,R),h(g,v+=2,R),i(g,v+=2,_),i(g,v+=4,j),v+=4,v+=2,g.buffer},r._noNeed=function(o){var s=o.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(s)!=-1},r._writeHeader=function(o,s,a,i,h,f){var c=r.bin.writeUint,l=r.bin.writeUshort,u=i.file;return c(o,s,h==0?67324752:33639248),s+=4,h==1&&(s+=2),l(o,s,20),l(o,s+=2,0),l(o,s+=2,i.cpr?8:0),c(o,s+=2,0),c(o,s+=4,i.crc),c(o,s+=4,u.length),c(o,s+=4,i.usize),l(o,s+=4,r.bin.sizeUTF8(a)),l(o,s+=2,0),s+=2,h==1&&(s+=2,s+=2,c(o,s+=6,f),s+=4),s+=r.bin.writeUTF8(o,s,a),h==0&&(o.set(u,s),s+=u.length),s},r.crc={table:(function(){for(var o=new Uint32Array(256),s=0;s<256;s++){for(var a=s,i=0;i<8;i++)1&a?a=3988292384^a>>>1:a>>>=1;o[s]=a}return o})(),update:function(o,s,a,i){for(var h=0;h<i;h++)o=r.crc.table[255&(o^s[a+h])]^o>>>8;return o},crc:function(o,s,a){return 4294967295^r.crc.update(4294967295,o,s,a)}},r.adler=function(o,s,a){for(var i=1,h=0,f=s,c=s+a;f<c;){for(var l=Math.min(f+5552,c);f<l;)h+=i+=o[f++];i%=65521,h%=65521}return h<<16|i},r.bin={readUshort:function(o,s){return o[s]|o[s+1]<<8},writeUshort:function(o,s,a){o[s]=255&a,o[s+1]=a>>8&255},readUint:function(o,s){return 16777216*o[s+3]+(o[s+2]<<16|o[s+1]<<8|o[s])},writeUint:function(o,s,a){o[s]=255&a,o[s+1]=a>>8&255,o[s+2]=a>>16&255,o[s+3]=a>>24&255},readASCII:function(o,s,a){for(var i="",h=0;h<a;h++)i+=String.fromCharCode(o[s+h]);return i},writeASCII:function(o,s,a){for(var i=0;i<a.length;i++)o[s+i]=a.charCodeAt(i)},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,s,a){for(var i,h="",f=0;f<a;f++)h+="%"+r.bin.pad(o[s+f].toString(16));try{i=decodeURIComponent(h)}catch{return r.bin.readASCII(o,s,a)}return i},writeUTF8:function(o,s,a){for(var i=a.length,h=0,f=0;f<i;f++){var c=a.charCodeAt(f);if((4294967168&c)==0)o[s+h]=c,h++;else if((4294965248&c)==0)o[s+h]=192|c>>6,o[s+h+1]=128|c>>0&63,h+=2;else if((4294901760&c)==0)o[s+h]=224|c>>12,o[s+h+1]=128|c>>6&63,o[s+h+2]=128|c>>0&63,h+=3;else{if((4292870144&c)!=0)throw"e";o[s+h]=240|c>>18,o[s+h+1]=128|c>>12&63,o[s+h+2]=128|c>>6&63,o[s+h+3]=128|c>>0&63,h+=4}}return h},sizeUTF8:function(o){for(var s=o.length,a=0,i=0;i<s;i++){var h=o.charCodeAt(i);if((4294967168&h)==0)a++;else if((4294965248&h)==0)a+=2;else if((4294901760&h)==0)a+=3;else{if((4292870144&h)!=0)throw"e";a+=4}}return a}},r.F={},r.F.deflateRaw=function(o,s,a,i){var h=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][i],f=r.F.U,c=r.F._goodIndex;r.F._hash;var l=r.F._putsE,u=0,p=a<<3,g=0,v=o.length;if(i==0){for(;u<v;)l(s,p,u+(O=Math.min(65535,v-u))==v?1:0),p=r.F._copyExact(o,u,O,s,p+8),u+=O;return p>>>3}var C=f.lits,b=f.strt,R=f.prev,j=0,_=0,$=0,k=0,N=0,x=0;for(v>2&&(b[x=r.F._hash(o,0)]=0),u=0;u<v;u++){if(N=x,u+1<v-2){x=r.F._hash(o,u+1);var y=u+1&32767;R[y]=b[x],b[x]=y}if(g<=u){(j>14e3||_>26697)&&v-u>100&&(g<u&&(C[j]=u-g,j+=2,g=u),p=r.F._writeBlock(u==v-1||g==v?1:0,C,j,k,o,$,u-$,s,p),j=_=k=0,$=u);var A=0;u<v-2&&(A=r.F._bestMatch(o,u,R,N,Math.min(h[2],v-u),h[3]));var O=A>>>16,P=65535&A;if(A!=0){P=65535&A;var F=c(O=A>>>16,f.of0);f.lhst[257+F]++;var M=c(P,f.df0);f.dhst[M]++,k+=f.exb[F]+f.dxb[M],C[j]=O<<23|u-g,C[j+1]=P<<16|F<<8|M,j+=2,g=u+O}else f.lhst[o[u]]++;_++}}for($==u&&o.length!=0||(g<u&&(C[j]=u-g,j+=2,g=u),p=r.F._writeBlock(1,C,j,k,o,$,u-$,s,p),j=0,_=0,j=_=k=0,$=u);(7&p)!=0;)p++;return p>>>3},r.F._bestMatch=function(o,s,a,i,h,f){var c=32767&s,l=a[c],u=c-l+32768&32767;if(l==c||i!=r.F._hash(o,s-u))return 0;for(var p=0,g=0,v=Math.min(32767,s);u<=v&&--f!=0&&l!=c;){if(p==0||o[s+p]==o[s+p-u]){var C=r.F._howLong(o,s,u);if(C>p){if(g=u,(p=C)>=h)break;u+2<C&&(C=u+2);for(var b=0,R=0;R<C-2;R++){var j=s-u+R+32768&32767,_=j-a[j]+32768&32767;_>b&&(b=_,l=j)}}}u+=(c=l)-(l=a[c])+32768&32767}return p<<16|g},r.F._howLong=function(o,s,a){if(o[s]!=o[s-a]||o[s+1]!=o[s+1-a]||o[s+2]!=o[s+2-a])return 0;var i=s,h=Math.min(o.length,s+258);for(s+=3;s<h&&o[s]==o[s-a];)s++;return s-i},r.F._hash=function(o,s){return(o[s]<<8|o[s+1])+(o[s+2]<<4)&65535},r.saved=0,r.F._writeBlock=function(o,s,a,i,h,f,c,l,u){var p,g,v,C,b,R,j,_,$,k=r.F.U,N=r.F._putsF,x=r.F._putsE;k.lhst[256]++,g=(p=r.F.getTrees())[0],v=p[1],C=p[2],b=p[3],R=p[4],j=p[5],_=p[6],$=p[7];var y=32+((u+3&7)==0?0:8-(u+3&7))+(c<<3),A=i+r.F.contSize(k.fltree,k.lhst)+r.F.contSize(k.fdtree,k.dhst),O=i+r.F.contSize(k.ltree,k.lhst)+r.F.contSize(k.dtree,k.dhst);O+=14+3*j+r.F.contSize(k.itree,k.ihst)+(2*k.ihst[16]+3*k.ihst[17]+7*k.ihst[18]);for(var P=0;P<286;P++)k.lhst[P]=0;for(P=0;P<30;P++)k.dhst[P]=0;for(P=0;P<19;P++)k.ihst[P]=0;var F=y<A&&y<O?0:A<O?1:2;if(N(l,u,o),N(l,u+1,F),u+=3,F==0){for(;(7&u)!=0;)u++;u=r.F._copyExact(h,f,c,l,u)}else{var M,D;if(F==1&&(M=k.fltree,D=k.fdtree),F==2){r.F.makeCodes(k.ltree,g),r.F.revCodes(k.ltree,g),r.F.makeCodes(k.dtree,v),r.F.revCodes(k.dtree,v),r.F.makeCodes(k.itree,C),r.F.revCodes(k.itree,C),M=k.ltree,D=k.dtree,x(l,u,b-257),x(l,u+=5,R-1),x(l,u+=5,j-4),u+=4;for(var S=0;S<j;S++)x(l,u+3*S,k.itree[1+(k.ordr[S]<<1)]);u+=3*j,u=r.F._codeTiny(_,k.itree,l,u),u=r.F._codeTiny($,k.itree,l,u)}for(var w=f,L=0;L<a;L+=2){for(var E=s[L],I=E>>>23,W=w+(8388607&E);w<W;)u=r.F._writeLit(h[w++],M,l,u);if(I!=0){var T=s[L+1],B=T>>16,z=T>>8&255,U=255&T;x(l,u=r.F._writeLit(257+z,M,l,u),I-k.of0[z]),u+=k.exb[z],N(l,u=r.F._writeLit(U,D,l,u),B-k.df0[U]),u+=k.dxb[U],w+=I}}u=r.F._writeLit(256,M,l,u)}return u},r.F._copyExact=function(o,s,a,i,h){var f=h>>>3;return i[f]=a,i[f+1]=a>>>8,i[f+2]=255-i[f],i[f+3]=255-i[f+1],f+=4,i.set(new Uint8Array(o.buffer,s,a),f),h+(a+4<<3)},r.F.getTrees=function(){for(var o=r.F.U,s=r.F._hufTree(o.lhst,o.ltree,15),a=r.F._hufTree(o.dhst,o.dtree,15),i=[],h=r.F._lenCodes(o.ltree,i),f=[],c=r.F._lenCodes(o.dtree,f),l=0;l<i.length;l+=2)o.ihst[i[l]]++;for(l=0;l<f.length;l+=2)o.ihst[f[l]]++;for(var u=r.F._hufTree(o.ihst,o.itree,7),p=19;p>4&&o.itree[1+(o.ordr[p-1]<<1)]==0;)p--;return[s,a,u,h,c,p,i,f]},r.F.getSecond=function(o){for(var s=[],a=0;a<o.length;a+=2)s.push(o[a+1]);return s},r.F.nonZero=function(o){for(var s="",a=0;a<o.length;a+=2)o[a+1]!=0&&(s+=(a>>1)+",");return s},r.F.contSize=function(o,s){for(var a=0,i=0;i<s.length;i++)a+=s[i]*o[1+(i<<1)];return a},r.F._codeTiny=function(o,s,a,i){for(var h=0;h<o.length;h+=2){var f=o[h],c=o[h+1];i=r.F._writeLit(f,s,a,i);var l=f==16?2:f==17?3:7;f>15&&(r.F._putsE(a,i,c,l),i+=l)}return i},r.F._lenCodes=function(o,s){for(var a=o.length;a!=2&&o[a-1]==0;)a-=2;for(var i=0;i<a;i+=2){var h=o[i+1],f=i+3<a?o[i+3]:-1,c=i+5<a?o[i+5]:-1,l=i==0?-1:o[i-1];if(h==0&&f==h&&c==h){for(var u=i+5;u+2<a&&o[u+2]==h;)u+=2;(p=Math.min(u+1-i>>>1,138))<11?s.push(17,p-3):s.push(18,p-11),i+=2*p-2}else if(h==l&&f==h&&c==h){for(u=i+5;u+2<a&&o[u+2]==h;)u+=2;var p=Math.min(u+1-i>>>1,6);s.push(16,p-3),i+=2*p-2}else s.push(h,0)}return a>>>1},r.F._hufTree=function(o,s,a){var i=[],h=o.length,f=s.length,c=0;for(c=0;c<f;c+=2)s[c]=0,s[c+1]=0;for(c=0;c<h;c++)o[c]!=0&&i.push({lit:c,f:o[c]});var l=i.length,u=i.slice(0);if(l==0)return 0;if(l==1){var p=i[0].lit;return u=p==0?1:0,s[1+(p<<1)]=1,s[1+(u<<1)]=1,1}i.sort((function(_,$){return _.f-$.f}));var g=i[0],v=i[1],C=0,b=1,R=2;for(i[0]={lit:-1,f:g.f+v.f,l:g,r:v,d:0};b!=l-1;)g=C!=b&&(R==l||i[C].f<i[R].f)?i[C++]:i[R++],v=C!=b&&(R==l||i[C].f<i[R].f)?i[C++]:i[R++],i[b++]={lit:-1,f:g.f+v.f,l:g,r:v};var j=r.F.setDepth(i[b-1],0);for(j>a&&(r.F.restrictDepth(u,a,j),j=a),c=0;c<l;c++)s[1+(u[c].lit<<1)]=u[c].d;return j},r.F.setDepth=function(o,s){return o.lit!=-1?(o.d=s,s):Math.max(r.F.setDepth(o.l,s+1),r.F.setDepth(o.r,s+1))},r.F.restrictDepth=function(o,s,a){var i=0,h=1<<a-s,f=0;for(o.sort((function(l,u){return u.d==l.d?l.f-u.f:u.d-l.d})),i=0;i<o.length&&o[i].d>s;i++){var c=o[i].d;o[i].d=s,f+=h-(1<<a-c)}for(f>>>=a-s;f>0;)(c=o[i].d)<s?(o[i].d++,f-=1<<s-c-1):i++;for(;i>=0;i--)o[i].d==s&&f<0&&(o[i].d--,f++);f!=0&&console.log("debt left")},r.F._goodIndex=function(o,s){var a=0;return s[16|a]<=o&&(a|=16),s[8|a]<=o&&(a|=8),s[4|a]<=o&&(a|=4),s[2|a]<=o&&(a|=2),s[1|a]<=o&&(a|=1),a},r.F._writeLit=function(o,s,a,i){return r.F._putsF(a,i,s[o<<1]),i+s[1+(o<<1)]},r.F.inflate=function(o,s){var a=Uint8Array;if(o[0]==3&&o[1]==0)return s||new a(0);var i=r.F,h=i._bitsF,f=i._bitsE,c=i._decodeTiny,l=i.makeCodes,u=i.codes2map,p=i._get17,g=i.U,v=s==null;v&&(s=new a(o.length>>>2<<3));for(var C,b,R=0,j=0,_=0,$=0,k=0,N=0,x=0,y=0,A=0;R==0;)if(R=h(o,A,1),j=h(o,A+1,2),A+=3,j!=0){if(v&&(s=r.F._check(s,y+(1<<17))),j==1&&(C=g.flmap,b=g.fdmap,N=511,x=31),j==2){_=f(o,A,5)+257,$=f(o,A+5,5)+1,k=f(o,A+10,4)+4,A+=14;for(var O=0;O<38;O+=2)g.itree[O]=0,g.itree[O+1]=0;var P=1;for(O=0;O<k;O++){var F=f(o,A+3*O,3);g.itree[1+(g.ordr[O]<<1)]=F,F>P&&(P=F)}A+=3*k,l(g.itree,P),u(g.itree,P,g.imap),C=g.lmap,b=g.dmap,A=c(g.imap,(1<<P)-1,_+$,o,A,g.ttree);var M=i._copyOut(g.ttree,0,_,g.ltree);N=(1<<M)-1;var D=i._copyOut(g.ttree,_,$,g.dtree);x=(1<<D)-1,l(g.ltree,M),u(g.ltree,M,C),l(g.dtree,D),u(g.dtree,D,b)}for(;;){var S=C[p(o,A)&N];A+=15&S;var w=S>>>4;if(!(w>>>8))s[y++]=w;else{if(w==256)break;var L=y+w-254;if(w>264){var E=g.ldef[w-257];L=y+(E>>>3)+f(o,A,7&E),A+=7&E}var I=b[p(o,A)&x];A+=15&I;var W=I>>>4,T=g.ddef[W],B=(T>>>4)+h(o,A,15&T);for(A+=15&T,v&&(s=r.F._check(s,y+(1<<17)));y<L;)s[y]=s[y++-B],s[y]=s[y++-B],s[y]=s[y++-B],s[y]=s[y++-B];y=L}}}else{(7&A)!=0&&(A+=8-(7&A));var z=4+(A>>>3),U=o[z-4]|o[z-3]<<8;v&&(s=r.F._check(s,y+U)),s.set(new a(o.buffer,o.byteOffset+z,U),y),A=z+U<<3,y+=U}return s.length==y?s:s.slice(0,y)},r.F._check=function(o,s){var a=o.length;if(s<=a)return o;var i=new Uint8Array(Math.max(a<<1,s));return i.set(o,0),i},r.F._decodeTiny=function(o,s,a,i,h,f){for(var c=r.F._bitsE,l=r.F._get17,u=0;u<a;){var p=o[l(i,h)&s];h+=15&p;var g=p>>>4;if(g<=15)f[u]=g,u++;else{var v=0,C=0;g==16?(C=3+c(i,h,2),h+=2,v=f[u-1]):g==17?(C=3+c(i,h,3),h+=3):g==18&&(C=11+c(i,h,7),h+=7);for(var b=u+C;u<b;)f[u]=v,u++}}return h},r.F._copyOut=function(o,s,a,i){for(var h=0,f=0,c=i.length>>>1;f<a;){var l=o[f+s];i[f<<1]=0,i[1+(f<<1)]=l,l>h&&(h=l),f++}for(;f<c;)i[f<<1]=0,i[1+(f<<1)]=0,f++;return h},r.F.makeCodes=function(o,s){for(var a,i,h,f,c=r.F.U,l=o.length,u=c.bl_count,p=0;p<=s;p++)u[p]=0;for(p=1;p<l;p+=2)u[o[p]]++;var g=c.next_code;for(a=0,u[0]=0,i=1;i<=s;i++)a=a+u[i-1]<<1,g[i]=a;for(h=0;h<l;h+=2)(f=o[h+1])!=0&&(o[h]=g[f],g[f]++)},r.F.codes2map=function(o,s,a){for(var i=o.length,h=r.F.U.rev15,f=0;f<i;f+=2)if(o[f+1]!=0)for(var c=f>>1,l=o[f+1],u=c<<4|l,p=s-l,g=o[f]<<p,v=g+(1<<p);g!=v;)a[h[g]>>>15-s]=u,g++},r.F.revCodes=function(o,s){for(var a=r.F.U.rev15,i=15-s,h=0;h<o.length;h+=2){var f=o[h]<<s-o[h+1];o[h]=a[f]>>>i}},r.F._putsE=function(o,s,a){a<<=7&s;var i=s>>>3;o[i]|=a,o[i+1]|=a>>>8},r.F._putsF=function(o,s,a){a<<=7&s;var i=s>>>3;o[i]|=a,o[i+1]|=a>>>8,o[i+2]|=a>>>16},r.F._bitsE=function(o,s,a){return(o[s>>>3]|o[1+(s>>>3)]<<8)>>>(7&s)&(1<<a)-1},r.F._bitsF=function(o,s,a){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)&(1<<a)-1},r.F._get17=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)},r.F._get25=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16|o[3+(s>>>3)]<<24)>>>(7&s)},r.F.U=(t=Uint16Array,n=Uint32Array,{next_code:new t(16),bl_count:new t(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new t(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new n(32),flmap:new t(512),fltree:[],fdmap:new t(32),fdtree:[],lmap:new t(32768),ltree:[],ttree:[],dmap:new t(32768),dtree:[],imap:new t(512),itree:[],rev15:new t(32768),lhst:new n(286),dhst:new n(30),ihst:new n(19),lits:new n(15e3),strt:new t(65536),prev:new t(32768)}),(function(){for(var o=r.F.U,s=0;s<32768;s++){var a=s;a=(4278255360&(a=(4042322160&(a=(3435973836&(a=(2863311530&a)>>>1|(1431655765&a)<<1))>>>2|(858993459&a)<<2))>>>4|(252645135&a)<<4))>>>8|(16711935&a)<<8,o.rev15[s]=(a>>>16|a<<16)>>>17}function i(h,f,c){for(;f--!=0;)h.push(0,c)}for(s=0;s<32;s++)o.ldef[s]=o.of0[s]<<3|o.exb[s],o.ddef[s]=o.df0[s]<<4|o.dxb[s];i(o.fltree,144,8),i(o.fltree,112,9),i(o.fltree,24,7),i(o.fltree,8,8),r.F.makeCodes(o.fltree,9),r.F.codes2map(o.fltree,9,o.flmap),r.F.revCodes(o.fltree,9),i(o.fdtree,32,5),r.F.makeCodes(o.fdtree,5),r.F.codes2map(o.fdtree,5,o.fdmap),r.F.revCodes(o.fdtree,5),i(o.itree,19,0),i(o.ltree,286,0),i(o.dtree,30,0),i(o.ttree,320,0)})()})();var Gp=Wp({__proto__:null,default:Ln},[Ln]);const Pe=(function(){var e={nextZero(c,l){for(;c[l]!=0;)l++;return l},readUshort:(c,l)=>c[l]<<8|c[l+1],writeUshort(c,l,u){c[l]=u>>8&255,c[l+1]=255&u},readUint:(c,l)=>16777216*c[l]+(c[l+1]<<16|c[l+2]<<8|c[l+3]),writeUint(c,l,u){c[l]=u>>24&255,c[l+1]=u>>16&255,c[l+2]=u>>8&255,c[l+3]=255&u},readASCII(c,l,u){let p="";for(let g=0;g<u;g++)p+=String.fromCharCode(c[l+g]);return p},writeASCII(c,l,u){for(let p=0;p<u.length;p++)c[l+p]=u.charCodeAt(p)},readBytes(c,l,u){const p=[];for(let g=0;g<u;g++)p.push(c[l+g]);return p},pad:c=>c.length<2?`0${c}`:c,readUTF8(c,l,u){let p,g="";for(let v=0;v<u;v++)g+=`%${e.pad(c[l+v].toString(16))}`;try{p=decodeURIComponent(g)}catch{return e.readASCII(c,l,u)}return p}};function t(c,l,u,p){const g=l*u,v=s(p),C=Math.ceil(l*v/8),b=new Uint8Array(4*g),R=new Uint32Array(b.buffer),{ctype:j}=p,{depth:_}=p,$=e.readUshort;if(j==6){const E=g<<2;if(_==8)for(var k=0;k<E;k+=4)b[k]=c[k],b[k+1]=c[k+1],b[k+2]=c[k+2],b[k+3]=c[k+3];if(_==16)for(k=0;k<E;k++)b[k]=c[k<<1]}else if(j==2){const E=p.tabs.tRNS;if(E==null){if(_==8)for(k=0;k<g;k++){var N=3*k;R[k]=255<<24|c[N+2]<<16|c[N+1]<<8|c[N]}if(_==16)for(k=0;k<g;k++)N=6*k,R[k]=255<<24|c[N+4]<<16|c[N+2]<<8|c[N]}else{var x=E[0];const I=E[1],W=E[2];if(_==8)for(k=0;k<g;k++){var y=k<<2;N=3*k,R[k]=255<<24|c[N+2]<<16|c[N+1]<<8|c[N],c[N]==x&&c[N+1]==I&&c[N+2]==W&&(b[y+3]=0)}if(_==16)for(k=0;k<g;k++)y=k<<2,N=6*k,R[k]=255<<24|c[N+4]<<16|c[N+2]<<8|c[N],$(c,N)==x&&$(c,N+2)==I&&$(c,N+4)==W&&(b[y+3]=0)}}else if(j==3){const E=p.tabs.PLTE,I=p.tabs.tRNS,W=I?I.length:0;if(_==1)for(var A=0;A<u;A++){var O=A*C,P=A*l;for(k=0;k<l;k++){y=P+k<<2;var F=3*(M=c[O+(k>>3)]>>7-((7&k)<<0)&1);b[y]=E[F],b[y+1]=E[F+1],b[y+2]=E[F+2],b[y+3]=M<W?I[M]:255}}if(_==2)for(A=0;A<u;A++)for(O=A*C,P=A*l,k=0;k<l;k++)y=P+k<<2,F=3*(M=c[O+(k>>2)]>>6-((3&k)<<1)&3),b[y]=E[F],b[y+1]=E[F+1],b[y+2]=E[F+2],b[y+3]=M<W?I[M]:255;if(_==4)for(A=0;A<u;A++)for(O=A*C,P=A*l,k=0;k<l;k++)y=P+k<<2,F=3*(M=c[O+(k>>1)]>>4-((1&k)<<2)&15),b[y]=E[F],b[y+1]=E[F+1],b[y+2]=E[F+2],b[y+3]=M<W?I[M]:255;if(_==8)for(k=0;k<g;k++){var M;y=k<<2,F=3*(M=c[k]),b[y]=E[F],b[y+1]=E[F+1],b[y+2]=E[F+2],b[y+3]=M<W?I[M]:255}}else if(j==4){if(_==8)for(k=0;k<g;k++){y=k<<2;var D=c[S=k<<1];b[y]=D,b[y+1]=D,b[y+2]=D,b[y+3]=c[S+1]}if(_==16)for(k=0;k<g;k++){var S;y=k<<2,D=c[S=k<<2],b[y]=D,b[y+1]=D,b[y+2]=D,b[y+3]=c[S+2]}}else if(j==0)for(x=p.tabs.tRNS?p.tabs.tRNS:-1,A=0;A<u;A++){const E=A*C,I=A*l;if(_==1)for(var w=0;w<l;w++){var L=(D=255*(c[E+(w>>>3)]>>>7-(7&w)&1))==255*x?0:255;R[I+w]=L<<24|D<<16|D<<8|D}else if(_==2)for(w=0;w<l;w++)L=(D=85*(c[E+(w>>>2)]>>>6-((3&w)<<1)&3))==85*x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==4)for(w=0;w<l;w++)L=(D=17*(c[E+(w>>>1)]>>>4-((1&w)<<2)&15))==17*x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==8)for(w=0;w<l;w++)L=(D=c[E+w])==x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==16)for(w=0;w<l;w++)D=c[E+(w<<1)],L=$(c,E+(w<<1))==x?0:255,R[I+w]=L<<24|D<<16|D<<8|D}return b}function n(c,l,u,p){const g=s(c),v=Math.ceil(u*g/8),C=new Uint8Array((v+1+c.interlace)*p);return l=c.tabs.CgBI?o(l,C):r(l,C),c.interlace==0?l=a(l,c,0,u,p):c.interlace==1&&(l=(function(R,j){const _=j.width,$=j.height,k=s(j),N=k>>3,x=Math.ceil(_*k/8),y=new Uint8Array($*x);let A=0;const O=[0,0,4,0,2,0,1],P=[0,4,0,2,0,1,0],F=[8,8,8,4,4,2,2],M=[8,8,4,4,2,2,1];let D=0;for(;D<7;){const w=F[D],L=M[D];let E=0,I=0,W=O[D];for(;W<$;)W+=w,I++;let T=P[D];for(;T<_;)T+=L,E++;const B=Math.ceil(E*k/8);a(R,j,A,E,I);let z=0,U=O[D];for(;U<$;){let V=P[D],G=A+z*B<<3;for(;V<_;){var S;if(k==1&&(S=(S=R[G>>3])>>7-(7&G)&1,y[U*x+(V>>3)]|=S<<7-((7&V)<<0)),k==2&&(S=(S=R[G>>3])>>6-(7&G)&3,y[U*x+(V>>2)]|=S<<6-((3&V)<<1)),k==4&&(S=(S=R[G>>3])>>4-(7&G)&15,y[U*x+(V>>1)]|=S<<4-((1&V)<<2)),k>=8){const X=U*x+V*N;for(let K=0;K<N;K++)y[X+K]=R[(G>>3)+K]}G+=k,V+=L}z++,U+=w}E*I!=0&&(A+=I*(1+B)),D+=1}return y})(l,c)),l}function r(c,l){return o(new Uint8Array(c.buffer,2,c.length-6),l)}var o=(function(){const c={H:{}};return c.H.N=function(l,u){const p=Uint8Array;let g,v,C=0,b=0,R=0,j=0,_=0,$=0,k=0,N=0,x=0;if(l[0]==3&&l[1]==0)return u||new p(0);const y=c.H,A=y.b,O=y.e,P=y.R,F=y.n,M=y.A,D=y.Z,S=y.m,w=u==null;for(w&&(u=new p(l.length>>>2<<5));C==0;)if(C=A(l,x,1),b=A(l,x+1,2),x+=3,b!=0){if(w&&(u=c.H.W(u,N+(1<<17))),b==1&&(g=S.J,v=S.h,$=511,k=31),b==2){R=O(l,x,5)+257,j=O(l,x+5,5)+1,_=O(l,x+10,4)+4,x+=14;let E=1;for(var L=0;L<38;L+=2)S.Q[L]=0,S.Q[L+1]=0;for(L=0;L<_;L++){const T=O(l,x+3*L,3);S.Q[1+(S.X[L]<<1)]=T,T>E&&(E=T)}x+=3*_,F(S.Q,E),M(S.Q,E,S.u),g=S.w,v=S.d,x=P(S.u,(1<<E)-1,R+j,l,x,S.v);const I=y.V(S.v,0,R,S.C);$=(1<<I)-1;const W=y.V(S.v,R,j,S.D);k=(1<<W)-1,F(S.C,I),M(S.C,I,g),F(S.D,W),M(S.D,W,v)}for(;;){const E=g[D(l,x)&$];x+=15&E;const I=E>>>4;if(!(I>>>8))u[N++]=I;else{if(I==256)break;{let W=N+I-254;if(I>264){const V=S.q[I-257];W=N+(V>>>3)+O(l,x,7&V),x+=7&V}const T=v[D(l,x)&k];x+=15&T;const B=T>>>4,z=S.c[B],U=(z>>>4)+A(l,x,15&z);for(x+=15&z;N<W;)u[N]=u[N++-U],u[N]=u[N++-U],u[N]=u[N++-U],u[N]=u[N++-U];N=W}}}}else{(7&x)!=0&&(x+=8-(7&x));const E=4+(x>>>3),I=l[E-4]|l[E-3]<<8;w&&(u=c.H.W(u,N+I)),u.set(new p(l.buffer,l.byteOffset+E,I),N),x=E+I<<3,N+=I}return u.length==N?u:u.slice(0,N)},c.H.W=function(l,u){const p=l.length;if(u<=p)return l;const g=new Uint8Array(p<<1);return g.set(l,0),g},c.H.R=function(l,u,p,g,v,C){const b=c.H.e,R=c.H.Z;let j=0;for(;j<p;){const _=l[R(g,v)&u];v+=15&_;const $=_>>>4;if($<=15)C[j]=$,j++;else{let k=0,N=0;$==16?(N=3+b(g,v,2),v+=2,k=C[j-1]):$==17?(N=3+b(g,v,3),v+=3):$==18&&(N=11+b(g,v,7),v+=7);const x=j+N;for(;j<x;)C[j]=k,j++}}return v},c.H.V=function(l,u,p,g){let v=0,C=0;const b=g.length>>>1;for(;C<p;){const R=l[C+u];g[C<<1]=0,g[1+(C<<1)]=R,R>v&&(v=R),C++}for(;C<b;)g[C<<1]=0,g[1+(C<<1)]=0,C++;return v},c.H.n=function(l,u){const p=c.H.m,g=l.length;let v,C,b,R;const j=p.j;for(var _=0;_<=u;_++)j[_]=0;for(_=1;_<g;_+=2)j[l[_]]++;const $=p.K;for(v=0,j[0]=0,C=1;C<=u;C++)v=v+j[C-1]<<1,$[C]=v;for(b=0;b<g;b+=2)R=l[b+1],R!=0&&(l[b]=$[R],$[R]++)},c.H.A=function(l,u,p){const g=l.length,v=c.H.m.r;for(let C=0;C<g;C+=2)if(l[C+1]!=0){const b=C>>1,R=l[C+1],j=b<<4|R,_=u-R;let $=l[C]<<_;const k=$+(1<<_);for(;$!=k;)p[v[$]>>>15-u]=j,$++}},c.H.l=function(l,u){const p=c.H.m.r,g=15-u;for(let v=0;v<l.length;v+=2){const C=l[v]<<u-l[v+1];l[v]=p[C]>>>g}},c.H.M=function(l,u,p){p<<=7&u;const g=u>>>3;l[g]|=p,l[g+1]|=p>>>8},c.H.I=function(l,u,p){p<<=7&u;const g=u>>>3;l[g]|=p,l[g+1]|=p>>>8,l[g+2]|=p>>>16},c.H.e=function(l,u,p){return(l[u>>>3]|l[1+(u>>>3)]<<8)>>>(7&u)&(1<<p)-1},c.H.b=function(l,u,p){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16)>>>(7&u)&(1<<p)-1},c.H.Z=function(l,u){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16)>>>(7&u)},c.H.i=function(l,u){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16|l[3+(u>>>3)]<<24)>>>(7&u)},c.H.m=(function(){const l=Uint16Array,u=Uint32Array;return{K:new l(16),j:new l(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new l(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new u(32),J:new l(512),_:[],h:new l(32),$:[],w:new l(32768),C:[],v:[],d:new l(32768),D:[],u:new l(512),Q:[],r:new l(32768),s:new u(286),Y:new u(30),a:new u(19),t:new u(15e3),k:new l(65536),g:new l(32768)}})(),(function(){const l=c.H.m;for(var u=0;u<32768;u++){let g=u;g=(2863311530&g)>>>1|(1431655765&g)<<1,g=(3435973836&g)>>>2|(858993459&g)<<2,g=(4042322160&g)>>>4|(252645135&g)<<4,g=(4278255360&g)>>>8|(16711935&g)<<8,l.r[u]=(g>>>16|g<<16)>>>17}function p(g,v,C){for(;v--!=0;)g.push(0,C)}for(u=0;u<32;u++)l.q[u]=l.S[u]<<3|l.T[u],l.c[u]=l.p[u]<<4|l.z[u];p(l._,144,8),p(l._,112,9),p(l._,24,7),p(l._,8,8),c.H.n(l._,9),c.H.A(l._,9,l.J),c.H.l(l._,9),p(l.$,32,5),c.H.n(l.$,5),c.H.A(l.$,5,l.h),c.H.l(l.$,5),p(l.Q,19,0),p(l.C,286,0),p(l.D,30,0),p(l.v,320,0)})(),c.H.N})();function s(c){return[1,null,3,1,2,null,4][c.ctype]*c.depth}function a(c,l,u,p,g){let v=s(l);const C=Math.ceil(p*v/8);let b,R;v=Math.ceil(v/8);let j=c[u],_=0;if(j>1&&(c[u]=[0,0,1][j-2]),j==3)for(_=v;_<C;_++)c[_+1]=c[_+1]+(c[_+1-v]>>>1)&255;for(let $=0;$<g;$++)if(b=u+$*C,R=b+$+1,j=c[R-1],_=0,j==0)for(;_<C;_++)c[b+_]=c[R+_];else if(j==1){for(;_<v;_++)c[b+_]=c[R+_];for(;_<C;_++)c[b+_]=c[R+_]+c[b+_-v]}else if(j==2)for(;_<C;_++)c[b+_]=c[R+_]+c[b+_-C];else if(j==3){for(;_<v;_++)c[b+_]=c[R+_]+(c[b+_-C]>>>1);for(;_<C;_++)c[b+_]=c[R+_]+(c[b+_-C]+c[b+_-v]>>>1)}else{for(;_<v;_++)c[b+_]=c[R+_]+i(0,c[b+_-C],0);for(;_<C;_++)c[b+_]=c[R+_]+i(c[b+_-v],c[b+_-C],c[b+_-v-C])}return c}function i(c,l,u){const p=c+l-u,g=p-c,v=p-l,C=p-u;return g*g<=v*v&&g*g<=C*C?c:v*v<=C*C?l:u}function h(c,l,u){u.width=e.readUint(c,l),l+=4,u.height=e.readUint(c,l),l+=4,u.depth=c[l],l++,u.ctype=c[l],l++,u.compress=c[l],l++,u.filter=c[l],l++,u.interlace=c[l],l++}function f(c,l,u,p,g,v,C,b,R){const j=Math.min(l,g),_=Math.min(u,v);let $=0,k=0;for(let D=0;D<_;D++)for(let S=0;S<j;S++)if(C>=0&&b>=0?($=D*l+S<<2,k=(b+D)*g+C+S<<2):($=(-b+D)*l-C+S<<2,k=D*g+S<<2),R==0)p[k]=c[$],p[k+1]=c[$+1],p[k+2]=c[$+2],p[k+3]=c[$+3];else if(R==1){var N=c[$+3]*.00392156862745098,x=c[$]*N,y=c[$+1]*N,A=c[$+2]*N,O=p[k+3]*(1/255),P=p[k]*O,F=p[k+1]*O,M=p[k+2]*O;const w=1-N,L=N+O*w,E=L==0?0:1/L;p[k+3]=255*L,p[k+0]=(x+P*w)*E,p[k+1]=(y+F*w)*E,p[k+2]=(A+M*w)*E}else if(R==2)N=c[$+3],x=c[$],y=c[$+1],A=c[$+2],O=p[k+3],P=p[k],F=p[k+1],M=p[k+2],N==O&&x==P&&y==F&&A==M?(p[k]=0,p[k+1]=0,p[k+2]=0,p[k+3]=0):(p[k]=x,p[k+1]=y,p[k+2]=A,p[k+3]=N);else if(R==3){if(N=c[$+3],x=c[$],y=c[$+1],A=c[$+2],O=p[k+3],P=p[k],F=p[k+1],M=p[k+2],N==O&&x==P&&y==F&&A==M)continue;if(N<220&&O>20)return!1}return!0}return{decode:function(l){const u=new Uint8Array(l);let p=8;const g=e,v=g.readUshort,C=g.readUint,b={tabs:{},frames:[]},R=new Uint8Array(u.length);let j,_=0,$=0;const k=[137,80,78,71,13,10,26,10];for(var N=0;N<8;N++)if(u[N]!=k[N])throw"The input is not a PNG file!";for(;p<u.length;){const D=g.readUint(u,p);p+=4;const S=g.readASCII(u,p,4);if(p+=4,S=="IHDR")h(u,p,b);else if(S=="iCCP"){for(var x=p;u[x]!=0;)x++;g.readASCII(u,p,x-p),u[x+1];const w=u.slice(x+2,p+D);let L=null;try{L=r(w)}catch{L=o(w)}b.tabs[S]=L}else if(S=="CgBI")b.tabs[S]=u.slice(p,p+4);else if(S=="IDAT"){for(N=0;N<D;N++)R[_+N]=u[p+N];_+=D}else if(S=="acTL")b.tabs[S]={num_frames:C(u,p),num_plays:C(u,p+4)},j=new Uint8Array(u.length);else if(S=="fcTL"){$!=0&&((M=b.frames[b.frames.length-1]).data=n(b,j.slice(0,$),M.rect.width,M.rect.height),$=0);const w={x:C(u,p+12),y:C(u,p+16),width:C(u,p+4),height:C(u,p+8)};let L=v(u,p+22);L=v(u,p+20)/(L==0?100:L);const E={rect:w,delay:Math.round(1e3*L),dispose:u[p+24],blend:u[p+25]};b.frames.push(E)}else if(S=="fdAT"){for(N=0;N<D-4;N++)j[$+N]=u[p+N+4];$+=D-4}else if(S=="pHYs")b.tabs[S]=[g.readUint(u,p),g.readUint(u,p+4),u[p+8]];else if(S=="cHRM")for(b.tabs[S]=[],N=0;N<8;N++)b.tabs[S].push(g.readUint(u,p+4*N));else if(S=="tEXt"||S=="zTXt"){b.tabs[S]==null&&(b.tabs[S]={});var y=g.nextZero(u,p),A=g.readASCII(u,p,y-p),O=p+D-y-1;if(S=="tEXt")F=g.readASCII(u,y+1,O);else{var P=r(u.slice(y+2,y+2+O));F=g.readUTF8(P,0,P.length)}b.tabs[S][A]=F}else if(S=="iTXt"){b.tabs[S]==null&&(b.tabs[S]={}),y=0,x=p,y=g.nextZero(u,x),A=g.readASCII(u,x,y-x);const w=u[x=y+1];var F;u[x+1],x+=2,y=g.nextZero(u,x),g.readASCII(u,x,y-x),x=y+1,y=g.nextZero(u,x),g.readUTF8(u,x,y-x),O=D-((x=y+1)-p),w==0?F=g.readUTF8(u,x,O):(P=r(u.slice(x,x+O)),F=g.readUTF8(P,0,P.length)),b.tabs[S][A]=F}else if(S=="PLTE")b.tabs[S]=g.readBytes(u,p,D);else if(S=="hIST"){const w=b.tabs.PLTE.length/3;for(b.tabs[S]=[],N=0;N<w;N++)b.tabs[S].push(v(u,p+2*N))}else if(S=="tRNS")b.ctype==3?b.tabs[S]=g.readBytes(u,p,D):b.ctype==0?b.tabs[S]=v(u,p):b.ctype==2&&(b.tabs[S]=[v(u,p),v(u,p+2),v(u,p+4)]);else if(S=="gAMA")b.tabs[S]=g.readUint(u,p)/1e5;else if(S=="sRGB")b.tabs[S]=u[p];else if(S=="bKGD")b.ctype==0||b.ctype==4?b.tabs[S]=[v(u,p)]:b.ctype==2||b.ctype==6?b.tabs[S]=[v(u,p),v(u,p+2),v(u,p+4)]:b.ctype==3&&(b.tabs[S]=u[p]);else if(S=="IEND")break;p+=D,g.readUint(u,p),p+=4}var M;return $!=0&&((M=b.frames[b.frames.length-1]).data=n(b,j.slice(0,$),M.rect.width,M.rect.height)),b.data=n(b,R,b.width,b.height),delete b.compress,delete b.interlace,delete b.filter,b},toRGBA8:function(l){const u=l.width,p=l.height;if(l.tabs.acTL==null)return[t(l.data,u,p,l).buffer];const g=[];l.frames[0].data==null&&(l.frames[0].data=l.data);const v=u*p*4,C=new Uint8Array(v),b=new Uint8Array(v),R=new Uint8Array(v);for(let _=0;_<l.frames.length;_++){const $=l.frames[_],k=$.rect.x,N=$.rect.y,x=$.rect.width,y=$.rect.height,A=t($.data,x,y,l);if(_!=0)for(var j=0;j<v;j++)R[j]=C[j];if($.blend==0?f(A,x,y,C,u,p,k,N,0):$.blend==1&&f(A,x,y,C,u,p,k,N,1),g.push(C.buffer.slice(0)),$.dispose!=0){if($.dispose==1)f(b,x,y,C,u,p,k,N,0);else if($.dispose==2)for(j=0;j<v;j++)C[j]=R[j]}}return g},_paeth:i,_copyTile:f,_bin:e}})();(function(){const{_copyTile:e}=Pe,{_bin:t}=Pe,n=Pe._paeth;var r={table:(function(){const x=new Uint32Array(256);for(let y=0;y<256;y++){let A=y;for(let O=0;O<8;O++)1&A?A=3988292384^A>>>1:A>>>=1;x[y]=A}return x})(),update(x,y,A,O){for(let P=0;P<O;P++)x=r.table[255&(x^y[A+P])]^x>>>8;return x},crc:(x,y,A)=>4294967295^r.update(4294967295,x,y,A)};function o(x,y,A,O){y[A]+=x[0]*O>>4,y[A+1]+=x[1]*O>>4,y[A+2]+=x[2]*O>>4,y[A+3]+=x[3]*O>>4}function s(x){return Math.max(0,Math.min(255,x))}function a(x,y){const A=x[0]-y[0],O=x[1]-y[1],P=x[2]-y[2],F=x[3]-y[3];return A*A+O*O+P*P+F*F}function i(x,y,A,O,P,F,M){M==null&&(M=1);const D=O.length,S=[];for(var w=0;w<D;w++){const U=O[w];S.push([U>>>0&255,U>>>8&255,U>>>16&255,U>>>24&255])}for(w=0;w<D;w++){let U=4294967295;for(var L=0,E=0;E<D;E++){var I=a(S[w],S[E]);E!=w&&I<U&&(U=I,L=E)}}const W=new Uint32Array(P.buffer),T=new Int16Array(y*A*4),B=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(w=0;w<B.length;w++)B[w]=255*((B[w]+.5)/16-.5);for(let U=0;U<A;U++)for(let V=0;V<y;V++){var z;w=4*(U*y+V),M!=2?z=[s(x[w]+T[w]),s(x[w+1]+T[w+1]),s(x[w+2]+T[w+2]),s(x[w+3]+T[w+3])]:(I=B[4*(3&U)+(3&V)],z=[s(x[w]+I),s(x[w+1]+I),s(x[w+2]+I),s(x[w+3]+I)]),L=0;let G=16777215;for(E=0;E<D;E++){const ne=a(z,S[E]);ne<G&&(G=ne,L=E)}const X=S[L],K=[z[0]-X[0],z[1]-X[1],z[2]-X[2],z[3]-X[3]];M==1&&(V!=y-1&&o(K,T,w+4,7),U!=A-1&&(V!=0&&o(K,T,w+4*y-4,3),o(K,T,w+4*y,5),V!=y-1&&o(K,T,w+4*y+4,1))),F[w>>2]=L,W[w>>2]=O[L]}}function h(x,y,A,O,P){P==null&&(P={});const{crc:F}=r,M=t.writeUint,D=t.writeUshort,S=t.writeASCII;let w=8;const L=x.frames.length>1;let E,I=!1,W=33+(L?20:0);if(P.sRGB!=null&&(W+=13),P.pHYs!=null&&(W+=21),P.iCCP!=null&&(E=pako.deflate(P.iCCP),W+=21+E.length+4),x.ctype==3){for(var T=x.plte.length,B=0;B<T;B++)x.plte[B]>>>24!=255&&(I=!0);W+=8+3*T+4+(I?8+1*T+4:0)}for(var z=0;z<x.frames.length;z++)L&&(W+=38),W+=(X=x.frames[z]).cimg.length+12,z!=0&&(W+=4);W+=12;const U=new Uint8Array(W),V=[137,80,78,71,13,10,26,10];for(B=0;B<8;B++)U[B]=V[B];if(M(U,w,13),w+=4,S(U,w,"IHDR"),w+=4,M(U,w,y),w+=4,M(U,w,A),w+=4,U[w]=x.depth,w++,U[w]=x.ctype,w++,U[w]=0,w++,U[w]=0,w++,U[w]=0,w++,M(U,w,F(U,w-17,17)),w+=4,P.sRGB!=null&&(M(U,w,1),w+=4,S(U,w,"sRGB"),w+=4,U[w]=P.sRGB,w++,M(U,w,F(U,w-5,5)),w+=4),P.iCCP!=null){const K=13+E.length;M(U,w,K),w+=4,S(U,w,"iCCP"),w+=4,S(U,w,"ICC profile"),w+=11,w+=2,U.set(E,w),w+=E.length,M(U,w,F(U,w-(K+4),K+4)),w+=4}if(P.pHYs!=null&&(M(U,w,9),w+=4,S(U,w,"pHYs"),w+=4,M(U,w,P.pHYs[0]),w+=4,M(U,w,P.pHYs[1]),w+=4,U[w]=P.pHYs[2],w++,M(U,w,F(U,w-13,13)),w+=4),L&&(M(U,w,8),w+=4,S(U,w,"acTL"),w+=4,M(U,w,x.frames.length),w+=4,M(U,w,P.loop!=null?P.loop:0),w+=4,M(U,w,F(U,w-12,12)),w+=4),x.ctype==3){for(M(U,w,3*(T=x.plte.length)),w+=4,S(U,w,"PLTE"),w+=4,B=0;B<T;B++){const K=3*B,ne=x.plte[B],ae=255&ne,de=ne>>>8&255,me=ne>>>16&255;U[w+K+0]=ae,U[w+K+1]=de,U[w+K+2]=me}if(w+=3*T,M(U,w,F(U,w-3*T-4,3*T+4)),w+=4,I){for(M(U,w,T),w+=4,S(U,w,"tRNS"),w+=4,B=0;B<T;B++)U[w+B]=x.plte[B]>>>24&255;w+=T,M(U,w,F(U,w-T-4,T+4)),w+=4}}let G=0;for(z=0;z<x.frames.length;z++){var X=x.frames[z];L&&(M(U,w,26),w+=4,S(U,w,"fcTL"),w+=4,M(U,w,G++),w+=4,M(U,w,X.rect.width),w+=4,M(U,w,X.rect.height),w+=4,M(U,w,X.rect.x),w+=4,M(U,w,X.rect.y),w+=4,D(U,w,O[z]),w+=2,D(U,w,1e3),w+=2,U[w]=X.dispose,w++,U[w]=X.blend,w++,M(U,w,F(U,w-30,30)),w+=4);const K=X.cimg;M(U,w,(T=K.length)+(z==0?0:4)),w+=4;const ne=w;S(U,w,z==0?"IDAT":"fdAT"),w+=4,z!=0&&(M(U,w,G++),w+=4),U.set(K,w),w+=T,M(U,w,F(U,ne,w-ne)),w+=4}return M(U,w,0),w+=4,S(U,w,"IEND"),w+=4,M(U,w,F(U,w-4,4)),w+=4,U.buffer}function f(x,y,A){for(let O=0;O<x.frames.length;O++){const P=x.frames[O];P.rect.width;const F=P.rect.height,M=new Uint8Array(F*P.bpl+F);P.cimg=p(P.img,F,P.bpp,P.bpl,M,y,A)}}function c(x,y,A,O,P){const F=P[0],M=P[1],D=P[2],S=P[3],w=P[4],L=P[5];let E=6,I=8,W=255;for(var T=0;T<x.length;T++){const J=new Uint8Array(x[T]);for(var B=J.length,z=0;z<B;z+=4)W&=J[z+3]}const U=W!=255,V=(function(te,ie,oe,he,ge,_e){const xe=[];for(var fe=0;fe<te.length;fe++){const we=new Uint8Array(te[fe]),Me=new Uint32Array(we.buffer);var Ee;let Re=0,Ve=0,$e=ie,mt=oe,ir=he?1:0;if(fe!=0){const tc=_e||he||fe==1||xe[fe-2].dispose!=0?1:2;let lr=0,Do=1e9;for(let Gt=0;Gt<tc;Gt++){var Je=new Uint8Array(te[fe-1-Gt]);const nc=new Uint32Array(te[fe-1-Gt]);let et=ie,tt=oe,At=-1,Kt=-1;for(let pt=0;pt<oe;pt++)for(let gt=0;gt<ie;gt++)Me[be=pt*ie+gt]!=nc[be]&&(gt<et&&(et=gt),gt>At&&(At=gt),pt<tt&&(tt=pt),pt>Kt&&(Kt=pt));At==-1&&(et=tt=At=Kt=0),ge&&((1&et)==1&&et--,(1&tt)==1&&tt--);const Lo=(At-et+1)*(Kt-tt+1);Lo<Do&&(Do=Lo,lr=Gt,Re=et,Ve=tt,$e=At-et+1,mt=Kt-tt+1)}Je=new Uint8Array(te[fe-1-lr]),lr==1&&(xe[fe-1].dispose=2),Ee=new Uint8Array($e*mt*4),e(Je,ie,oe,Ee,$e,mt,-Re,-Ve,0),ir=e(we,ie,oe,Ee,$e,mt,-Re,-Ve,3)?1:0,ir==1?u(we,ie,oe,Ee,{x:Re,y:Ve,width:$e,height:mt}):e(we,ie,oe,Ee,$e,mt,-Re,-Ve,0)}else Ee=we.slice(0);xe.push({rect:{x:Re,y:Ve,width:$e,height:mt},img:Ee,blend:ir,dispose:0})}if(he)for(fe=0;fe<xe.length;fe++){if((ht=xe[fe]).blend==1)continue;const we=ht.rect,Me=xe[fe-1].rect,Re=Math.min(we.x,Me.x),Ve=Math.min(we.y,Me.y),$e={x:Re,y:Ve,width:Math.max(we.x+we.width,Me.x+Me.width)-Re,height:Math.max(we.y+we.height,Me.y+Me.height)-Ve};xe[fe-1].dispose=1,fe-1!=0&&l(te,ie,oe,xe,fe-1,$e,ge),l(te,ie,oe,xe,fe,$e,ge)}let xn=0;if(te.length!=1)for(var be=0;be<xe.length;be++){var ht;xn+=(ht=xe[be]).rect.width*ht.rect.height}return xe})(x,y,A,F,M,D),G={},X=[],K=[];if(O!=0){const J=[];for(z=0;z<V.length;z++)J.push(V[z].img.buffer);const te=(function(ge){let _e=0;for(var xe=0;xe<ge.length;xe++)_e+=ge[xe].byteLength;const fe=new Uint8Array(_e);let Ee=0;for(xe=0;xe<ge.length;xe++){const Je=new Uint8Array(ge[xe]),xn=Je.length;for(let be=0;be<xn;be+=4){let ht=Je[be],we=Je[be+1],Me=Je[be+2];const Re=Je[be+3];Re==0&&(ht=we=Me=0),fe[Ee+be]=ht,fe[Ee+be+1]=we,fe[Ee+be+2]=Me,fe[Ee+be+3]=Re}Ee+=xn}return fe.buffer})(J),ie=v(te,O);for(z=0;z<ie.plte.length;z++)X.push(ie.plte[z].est.rgba);let oe=0;for(z=0;z<V.length;z++){const he=(ae=V[z]).img.length;var ne=new Uint8Array(ie.inds.buffer,oe>>2,he>>2);K.push(ne);const ge=new Uint8Array(ie.abuf,oe,he);L&&i(ae.img,ae.rect.width,ae.rect.height,X,ge,ne),ae.img.set(ge),oe+=he}}else for(T=0;T<V.length;T++){var ae=V[T];const J=new Uint32Array(ae.img.buffer);var de=ae.rect.width;for(B=J.length,ne=new Uint8Array(B),K.push(ne),z=0;z<B;z++){const te=J[z];if(z!=0&&te==J[z-1])ne[z]=ne[z-1];else if(z>de&&te==J[z-de])ne[z]=ne[z-de];else{let ie=G[te];if(ie==null&&(G[te]=ie=X.length,X.push(te),X.length>=300))break;ne[z]=ie}}}const me=X.length;for(me<=256&&w==0&&(I=me<=2?1:me<=4?2:me<=16?4:8,I=Math.max(I,S)),T=0;T<V.length;T++){(ae=V[T]).rect.x,ae.rect.y,de=ae.rect.width;const J=ae.rect.height;let te=ae.img;new Uint32Array(te.buffer);let ie=4*de,oe=4;if(me<=256&&w==0){ie=Math.ceil(I*de/8);var H=new Uint8Array(ie*J);const he=K[T];for(let ge=0;ge<J;ge++){z=ge*ie;const _e=ge*de;if(I==8)for(var q=0;q<de;q++)H[z+q]=he[_e+q];else if(I==4)for(q=0;q<de;q++)H[z+(q>>1)]|=he[_e+q]<<4-4*(1&q);else if(I==2)for(q=0;q<de;q++)H[z+(q>>2)]|=he[_e+q]<<6-2*(3&q);else if(I==1)for(q=0;q<de;q++)H[z+(q>>3)]|=he[_e+q]<<7-1*(7&q)}te=H,E=3,oe=1}else if(U==0&&V.length==1){H=new Uint8Array(de*J*3);const he=de*J;for(z=0;z<he;z++){const ge=3*z,_e=4*z;H[ge]=te[_e],H[ge+1]=te[_e+1],H[ge+2]=te[_e+2]}te=H,E=2,oe=3,ie=3*de}ae.img=te,ae.bpl=ie,ae.bpp=oe}return{ctype:E,depth:I,plte:X,frames:V}}function l(x,y,A,O,P,F,M){const D=Uint8Array,S=Uint32Array,w=new D(x[P-1]),L=new S(x[P-1]),E=P+1<x.length?new D(x[P+1]):null,I=new D(x[P]),W=new S(I.buffer);let T=y,B=A,z=-1,U=-1;for(let G=0;G<F.height;G++)for(let X=0;X<F.width;X++){const K=F.x+X,ne=F.y+G,ae=ne*y+K,de=W[ae];de==0||O[P-1].dispose==0&&L[ae]==de&&(E==null||E[4*ae+3]!=0)||(K<T&&(T=K),K>z&&(z=K),ne<B&&(B=ne),ne>U&&(U=ne))}z==-1&&(T=B=z=U=0),M&&((1&T)==1&&T--,(1&B)==1&&B--),F={x:T,y:B,width:z-T+1,height:U-B+1};const V=O[P];V.rect=F,V.blend=1,V.img=new Uint8Array(F.width*F.height*4),O[P-1].dispose==0?(e(w,y,A,V.img,F.width,F.height,-F.x,-F.y,0),u(I,y,A,V.img,F)):e(I,y,A,V.img,F.width,F.height,-F.x,-F.y,0)}function u(x,y,A,O,P){e(x,y,A,O,P.width,P.height,-P.x,-P.y,2)}function p(x,y,A,O,P,F,M){const D=[];let S,w=[0,1,2,3,4];F!=-1?w=[F]:(y*O>5e5||A==1)&&(w=[0]),M&&(S={level:0});const L=Gp;for(var E=0;E<w.length;E++){for(let T=0;T<y;T++)g(P,x,T,O,A,w[E]);D.push(L.deflate(P,S))}let I,W=1e9;for(E=0;E<D.length;E++)D[E].length<W&&(I=E,W=D[E].length);return D[I]}function g(x,y,A,O,P,F){const M=A*O;let D=M+A;if(x[D]=F,D++,F==0)if(O<500)for(var S=0;S<O;S++)x[D+S]=y[M+S];else x.set(new Uint8Array(y.buffer,M,O),D);else if(F==1){for(S=0;S<P;S++)x[D+S]=y[M+S];for(S=P;S<O;S++)x[D+S]=y[M+S]-y[M+S-P]+256&255}else if(A==0){for(S=0;S<P;S++)x[D+S]=y[M+S];if(F==2)for(S=P;S<O;S++)x[D+S]=y[M+S];if(F==3)for(S=P;S<O;S++)x[D+S]=y[M+S]-(y[M+S-P]>>1)+256&255;if(F==4)for(S=P;S<O;S++)x[D+S]=y[M+S]-n(y[M+S-P],0,0)+256&255}else{if(F==2)for(S=0;S<O;S++)x[D+S]=y[M+S]+256-y[M+S-O]&255;if(F==3){for(S=0;S<P;S++)x[D+S]=y[M+S]+256-(y[M+S-O]>>1)&255;for(S=P;S<O;S++)x[D+S]=y[M+S]+256-(y[M+S-O]+y[M+S-P]>>1)&255}if(F==4){for(S=0;S<P;S++)x[D+S]=y[M+S]+256-n(0,y[M+S-O],0)&255;for(S=P;S<O;S++)x[D+S]=y[M+S]+256-n(y[M+S-P],y[M+S-O],y[M+S-P-O])&255}}}function v(x,y){const A=new Uint8Array(x),O=A.slice(0),P=new Uint32Array(O.buffer),F=C(O,y),M=F[0],D=F[1],S=A.length,w=new Uint8Array(S>>2);let L;if(A.length<2e7)for(var E=0;E<S;E+=4)L=b(M,I=A[E]*(1/255),W=A[E+1]*(1/255),T=A[E+2]*(1/255),B=A[E+3]*(1/255)),w[E>>2]=L.ind,P[E>>2]=L.est.rgba;else for(E=0;E<S;E+=4){var I=A[E]*.00392156862745098,W=A[E+1]*(1/255),T=A[E+2]*(1/255),B=A[E+3]*(1/255);for(L=M;L.left;)L=R(L.est,I,W,T,B)<=0?L.left:L.right;w[E>>2]=L.ind,P[E>>2]=L.est.rgba}return{abuf:O.buffer,inds:w,plte:D}}function C(x,y,A){A==null&&(A=1e-4);const O=new Uint32Array(x.buffer),P={i0:0,i1:x.length,bst:null,est:null,tdst:0,left:null,right:null};P.bst=$(x,P.i0,P.i1),P.est=k(P.bst);const F=[P];for(;F.length<y;){let D=0,S=0;for(var M=0;M<F.length;M++)F[M].est.L>D&&(D=F[M].est.L,S=M);if(D<A)break;const w=F[S],L=j(x,O,w.i0,w.i1,w.est.e,w.est.eMq255);if(w.i0>=L||w.i1<=L){w.est.L=0;continue}const E={i0:w.i0,i1:L,bst:null,est:null,tdst:0,left:null,right:null};E.bst=$(x,E.i0,E.i1),E.est=k(E.bst);const I={i0:L,i1:w.i1,bst:null,est:null,tdst:0,left:null,right:null};for(I.bst={R:[],m:[],N:w.bst.N-E.bst.N},M=0;M<16;M++)I.bst.R[M]=w.bst.R[M]-E.bst.R[M];for(M=0;M<4;M++)I.bst.m[M]=w.bst.m[M]-E.bst.m[M];I.est=k(I.bst),w.left=E,w.right=I,F[S]=E,F.push(I)}for(F.sort(((D,S)=>S.bst.N-D.bst.N)),M=0;M<F.length;M++)F[M].ind=M;return[P,F]}function b(x,y,A,O,P){if(x.left==null)return x.tdst=(function(E,I,W,T,B){const z=I-E[0],U=W-E[1],V=T-E[2],G=B-E[3];return z*z+U*U+V*V+G*G})(x.est.q,y,A,O,P),x;const F=R(x.est,y,A,O,P);let M=x.left,D=x.right;F>0&&(M=x.right,D=x.left);const S=b(M,y,A,O,P);if(S.tdst<=F*F)return S;const w=b(D,y,A,O,P);return w.tdst<S.tdst?w:S}function R(x,y,A,O,P){const{e:F}=x;return F[0]*y+F[1]*A+F[2]*O+F[3]*P-x.eMq}function j(x,y,A,O,P,F){for(O-=4;A<O;){for(;_(x,A,P)<=F;)A+=4;for(;_(x,O,P)>F;)O-=4;if(A>=O)break;const M=y[A>>2];y[A>>2]=y[O>>2],y[O>>2]=M,A+=4,O-=4}for(;_(x,A,P)>F;)A-=4;return A+4}function _(x,y,A){return x[y]*A[0]+x[y+1]*A[1]+x[y+2]*A[2]+x[y+3]*A[3]}function $(x,y,A){const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],P=[0,0,0,0],F=A-y>>2;for(let M=y;M<A;M+=4){const D=x[M]*.00392156862745098,S=x[M+1]*(1/255),w=x[M+2]*(1/255),L=x[M+3]*(1/255);P[0]+=D,P[1]+=S,P[2]+=w,P[3]+=L,O[0]+=D*D,O[1]+=D*S,O[2]+=D*w,O[3]+=D*L,O[5]+=S*S,O[6]+=S*w,O[7]+=S*L,O[10]+=w*w,O[11]+=w*L,O[15]+=L*L}return O[4]=O[1],O[8]=O[2],O[9]=O[6],O[12]=O[3],O[13]=O[7],O[14]=O[11],{R:O,m:P,N:F}}function k(x){const{R:y}=x,{m:A}=x,{N:O}=x,P=A[0],F=A[1],M=A[2],D=A[3],S=O==0?0:1/O,w=[y[0]-P*P*S,y[1]-P*F*S,y[2]-P*M*S,y[3]-P*D*S,y[4]-F*P*S,y[5]-F*F*S,y[6]-F*M*S,y[7]-F*D*S,y[8]-M*P*S,y[9]-M*F*S,y[10]-M*M*S,y[11]-M*D*S,y[12]-D*P*S,y[13]-D*F*S,y[14]-D*M*S,y[15]-D*D*S],L=w,E=N;let I=[Math.random(),Math.random(),Math.random(),Math.random()],W=0,T=0;if(O!=0)for(let z=0;z<16&&(I=E.multVec(L,I),T=Math.sqrt(E.dot(I,I)),I=E.sml(1/T,I),!(z!=0&&Math.abs(T-W)<1e-9));z++)W=T;const B=[P*S,F*S,M*S,D*S];return{Cov:w,q:B,e:I,L:W,eMq255:E.dot(E.sml(255,B),I),eMq:E.dot(I,B),rgba:(Math.round(255*B[3])<<24|Math.round(255*B[2])<<16|Math.round(255*B[1])<<8|Math.round(255*B[0])<<0)>>>0}}var N={multVec:(x,y)=>[x[0]*y[0]+x[1]*y[1]+x[2]*y[2]+x[3]*y[3],x[4]*y[0]+x[5]*y[1]+x[6]*y[2]+x[7]*y[3],x[8]*y[0]+x[9]*y[1]+x[10]*y[2]+x[11]*y[3],x[12]*y[0]+x[13]*y[1]+x[14]*y[2]+x[15]*y[3]],dot:(x,y)=>x[0]*y[0]+x[1]*y[1]+x[2]*y[2]+x[3]*y[3],sml:(x,y)=>[x*y[0],x*y[1],x*y[2],x*y[3]]};Pe.encode=function(y,A,O,P,F,M,D){P==null&&(P=0),D==null&&(D=!1);const S=c(y,A,O,P,[!1,!1,!1,0,D,!1]);return f(S,-1),h(S,A,O,F,M)},Pe.encodeLL=function(y,A,O,P,F,M,D,S){const w={ctype:0+(P==1?0:2)+(F==0?0:4),depth:M,frames:[]},L=(P+F)*M,E=L*A;for(let I=0;I<y.length;I++)w.frames.push({rect:{x:0,y:0,width:A,height:O},img:new Uint8Array(y[I]),blend:0,dispose:1,bpp:Math.ceil(L/8),bpl:Math.ceil(E/8)});return f(w,0,!0),h(w,A,O,D,S)},Pe.encode.compress=c,Pe.encode.dither=i,Pe.quantize=v,Pe.quantize.getKDtree=C,Pe.quantize.getNearest=b})();const Zi={toArrayBuffer(e,t){const n=e.width,r=e.height,o=n<<2,s=e.getContext("2d").getImageData(0,0,n,r),a=new Uint32Array(s.data.buffer),i=(32*n+31)/32<<2,h=i*r,f=122+h,c=new ArrayBuffer(f),l=new DataView(c),u=1<<20;let p,g,v,C,b=u,R=0,j=0,_=0;function $(x){l.setUint16(j,x,!0),j+=2}function k(x){l.setUint32(j,x,!0),j+=4}function N(x){j+=x}$(19778),k(f),N(4),k(122),k(108),k(n),k(-r>>>0),$(1),$(32),k(3),k(h),k(2835),k(2835),N(8),k(16711680),k(65280),k(255),k(4278190080),k(1466527264),(function x(){for(;R<r&&b>0;){for(C=122+R*i,p=0;p<o;)b--,g=a[_++],v=g>>>24,l.setUint32(C+p,g<<8|v),p+=4;R++}_<a.length?(b=u,setTimeout(x,Zi._dly)):t(c)})()},toBlob(e,t){this.toArrayBuffer(e,(n=>{t(new Blob([n],{type:"image/bmp"}))}))},_dly:9};var ke={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},Kp={[ke.CHROME]:16384,[ke.FIREFOX]:11180,[ke.DESKTOP_SAFARI]:16384,[ke.IE]:8192,[ke.IOS]:4096,[ke.ETC]:8192};const _o=typeof window<"u",Ji=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,$n=_o&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),qp=(_o||Ji)&&($n&&$n.getOriginalSymbol(window,"File")||typeof File<"u"&&File),el=(_o||Ji)&&($n&&$n.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function Eo(e,t,n=Date.now()){return new Promise((r=>{const o=e.split(","),s=o[0].match(/:(.*?);/)[1],a=globalThis.atob(o[1]);let i=a.length;const h=new Uint8Array(i);for(;i--;)h[i]=a.charCodeAt(i);const f=new Blob([h],{type:s});f.name=t,f.lastModified=n,r(f)}))}function tl(e){return new Promise(((t,n)=>{const r=new el;r.onload=()=>t(r.result),r.onerror=o=>n(o),r.readAsDataURL(e)}))}function nl(e){return new Promise(((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=o=>n(o),r.src=e}))}function yt(){if(yt.cachedResult!==void 0)return yt.cachedResult;let e=ke.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=ke.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=ke.IOS:/Safari/i.test(t)?e=ke.DESKTOP_SAFARI:/Firefox/i.test(t)?e=ke.FIREFOX:(/MSIE/i.test(t)||document.documentMode)&&(e=ke.IE),yt.cachedResult=e,yt.cachedResult}function rl(e,t){const n=yt(),r=Kp[n];let o=e,s=t,a=o*s;const i=o>s?s/o:o/s;for(;a>r*r;){const h=(r+o)/2,f=(r+s)/2;h<f?(s=f,o=f*i):(s=h*i,o=h),a=o*s}return{width:o,height:s}}function er(e,t){let n,r;try{if(n=new OffscreenCanvas(e,t),r=n.getContext("2d"),r===null)throw new Error("getContext of OffscreenCanvas returns null")}catch{n=document.createElement("canvas"),r=n.getContext("2d")}return n.width=e,n.height=t,[n,r]}function ol(e,t){const{width:n,height:r}=rl(e.width,e.height),[o,s]=er(n,r);return t&&/jpe?g/.test(t)&&(s.fillStyle="white",s.fillRect(0,0,o.width,o.height)),s.drawImage(e,0,0,o.width,o.height),o}function En(){return En.cachedResult!==void 0||(En.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&typeof document<"u"&&"ontouchend"in document),En.cachedResult}function Fn(e,t={}){return new Promise((function(n,r){let o,s;var a=function(){try{return s=ol(o,t.fileType||e.type),n([o,s])}catch(h){return r(h)}},i=function(h){try{var f=function(c){try{throw c}catch(l){return r(l)}};try{let c;return tl(e).then((function(l){try{return c=l,nl(c).then((function(u){try{return o=u,(function(){try{return a()}catch(p){return r(p)}})()}catch(p){return f(p)}}),f)}catch(u){return f(u)}}),f)}catch(c){f(c)}}catch(c){return r(c)}};try{if(En()||[ke.DESKTOP_SAFARI,ke.MOBILE_SAFARI].includes(yt()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then((function(h){try{return o=h,a()}catch{return i()}}),i)}catch{i()}}))}function Un(e,t,n,r,o=1){return new Promise((function(s,a){let i;if(t==="image/png"){let f,c,l;return f=e.getContext("2d"),{data:c}=f.getImageData(0,0,e.width,e.height),l=Pe.encode([c.buffer],e.width,e.height,4096*o),i=new Blob([l],{type:t}),i.name=n,i.lastModified=r,h.call(this)}{let f=function(){return h.call(this)};if(t==="image/bmp")return new Promise((c=>Zi.toBlob(e,c))).then((function(c){try{return i=c,i.name=n,i.lastModified=r,f.call(this)}catch(l){return a(l)}}).bind(this),a);{let c=function(){return f.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:o}).then((function(l){try{return i=l,i.name=n,i.lastModified=r,c.call(this)}catch(u){return a(u)}}).bind(this),a);{let l;return l=e.toDataURL(t,o),Eo(l,n,r).then((function(u){try{return i=u,c.call(this)}catch(p){return a(p)}}).bind(this),a)}}}function h(){return s(i)}}))}function Ue(e){e.width=0,e.height=0}function Mt(){return new Promise((function(e,t){let n,r,o,s;return Mt.cachedResult!==void 0?e(Mt.cachedResult):Eo("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(a){try{return n=a,Fn(n).then((function(i){try{return r=i[1],Un(r,n.type,n.name,n.lastModified).then((function(h){try{return o=h,Ue(r),Fn(o).then((function(f){try{return s=f[0],Mt.cachedResult=s.width===1&&s.height===2,e(Mt.cachedResult)}catch(c){return t(c)}}),t)}catch(f){return t(f)}}),t)}catch(h){return t(h)}}),t)}catch(i){return t(i)}}),t)}))}function sl(e){return new Promise(((t,n)=>{const r=new el;r.onload=o=>{const s=new DataView(o.target.result);if(s.getUint16(0,!1)!=65496)return t(-2);const a=s.byteLength;let i=2;for(;i<a;){if(s.getUint16(i+2,!1)<=8)return t(-1);const h=s.getUint16(i,!1);if(i+=2,h==65505){if(s.getUint32(i+=2,!1)!=1165519206)return t(-1);const f=s.getUint16(i+=6,!1)==18761;i+=s.getUint32(i+4,f);const c=s.getUint16(i,f);i+=2;for(let l=0;l<c;l++)if(s.getUint16(i+12*l,f)==274)return t(s.getUint16(i+12*l+8,f))}else{if((65280&h)!=65280)break;i+=s.getUint16(i,!1)}}return t(-1)},r.onerror=o=>n(o),r.readAsArrayBuffer(e)}))}function al(e,t){const{width:n}=e,{height:r}=e,{maxWidthOrHeight:o}=t;let s,a=e;return isFinite(o)&&(n>o||r>o)&&([a,s]=er(n,r),n>r?(a.width=o,a.height=r/n*o):(a.width=n/r*o,a.height=o),s.drawImage(e,0,0,a.width,a.height),Ue(e)),a}function il(e,t){const{width:n}=e,{height:r}=e,[o,s]=er(n,r);switch(t>4&&t<9?(o.width=r,o.height=n):(o.width=n,o.height=r),t){case 2:s.transform(-1,0,0,1,n,0);break;case 3:s.transform(-1,0,0,-1,n,r);break;case 4:s.transform(1,0,0,-1,0,r);break;case 5:s.transform(0,1,1,0,0,0);break;case 6:s.transform(0,1,-1,0,r,0);break;case 7:s.transform(0,-1,-1,0,r,n);break;case 8:s.transform(0,-1,1,0,0,n)}return s.drawImage(e,0,0,n,r),Ue(e),o}function ys(e,t,n=0){return new Promise((function(r,o){let s,a,i,h,f,c,l,u,p,g,v,C,b,R,j,_,$,k,N,x;function y(O=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;s+=O,t.onProgress(Math.min(s,100))}function A(O){if(t.signal&&t.signal.aborted)throw t.signal.reason;s=Math.min(Math.max(O,s),100),t.onProgress(s)}return s=n,a=t.maxIteration||10,i=1024*t.maxSizeMB*1024,y(),Fn(e,t).then((function(O){try{return[,h]=O,y(),f=al(h,t),y(),new Promise((function(P,F){var M;if(!(M=t.exifOrientation))return sl(e).then((function(S){try{return M=S,D.call(this)}catch(w){return F(w)}}).bind(this),F);function D(){return P(M)}return D.call(this)})).then((function(P){try{return c=P,y(),Mt().then((function(F){try{return l=F?f:il(f,c),y(),u=t.initialQuality||1,p=t.fileType||e.type,Un(l,p,e.name,e.lastModified,u).then((function(M){try{{let S=function(){if(a--&&(j>i||j>b)){let L,E;return L=x?.95*N.width:N.width,E=x?.95*N.height:N.height,[$,k]=er(L,E),k.drawImage(N,0,0,L,E),u*=p==="image/png"?.85:.95,Un($,p,e.name,e.lastModified,u).then((function(I){try{return _=I,Ue(N),N=$,j=_.size,A(Math.min(99,Math.floor((R-j)/(R-i)*100))),S}catch(W){return o(W)}}),o)}return[1]},w=function(){return Ue(N),Ue($),Ue(f),Ue(l),Ue(h),A(100),r(_)};if(g=M,y(),v=g.size>i,C=g.size>e.size,!v&&!C)return A(100),r(g);var D;return b=e.size,R=g.size,j=R,N=l,x=!t.alwaysKeepResolution&&v,(D=(function(L){for(;L;){if(L.then)return void L.then(D,o);try{if(L.pop){if(L.length)return L.pop()?w.call(this):L;L=S}else L=L.call(this)}catch(E){return o(E)}}}).bind(this))(S)}}catch(S){return o(S)}}).bind(this),o)}catch(M){return o(M)}}).bind(this),o)}catch(F){return o(F)}}).bind(this),o)}catch(P){return o(P)}}).bind(this),o)}))}const Yp=`
231
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Np="DialogDescriptionWarning",jp=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zi(Np).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Bi=ji,Wi=Ti,Hi=Ii,Vi=Mi,Ap=Oi,Rp=Li,Tp=Fi;function Gi({...e}){return d.jsx(Bi,{"data-slot":"dialog",...e})}function Ip({...e}){return d.jsx(Wi,{"data-slot":"dialog-portal",...e})}function Mp({className:e,...t}){return d.jsx(Hi,{"data-slot":"dialog-overlay",className:Z("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ki({className:e,children:t,showCloseButton:n=!0,...r}){return d.jsxs(Ip,{"data-slot":"dialog-portal",children:[d.jsx(Mp,{}),d.jsxs(Vi,{"data-slot":"dialog-content",className:Z("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&d.jsxs(Tp,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(an,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function qi({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:Z("flex flex-col gap-2 text-center sm:text-left",e),...t})}function xb({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:Z("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Yi({className:e,...t}){return d.jsx(Ap,{"data-slot":"dialog-title",className:Z("text-lg leading-none font-semibold",e),...t})}function Pp({className:e,...t}){return d.jsx(Rp,{"data-slot":"dialog-description",className:Z("text-muted-foreground text-sm",e),...t})}function Op(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m ${e%60}s`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Dp({open:e,onClose:t}){const[n,r]=m.useState(!1),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),[c,l]=m.useState(""),[u,p]=m.useState(""),[g,v]=m.useState(""),[C,y]=m.useState(()=>Dr()),R=m.useRef(null),j=m.useRef(null),_=m.useRef(null),$=yo(),{resolvedTheme:k}=ca(),N=k==="dark"?{dark:"#ECE9E0",light:"#1C1B18"}:{dark:"#141413",light:"#FDFCF8"};if(m.useEffect(()=>{e&&(l(""),vp().then(D=>f(D)).catch(D=>l(D instanceof Error?D.message:"Failed to load server info")))},[e]),m.useEffect(()=>{if(!e||!a)return;const D=requestAnimationFrame(()=>{if(!R.current)return;const S=`${window.location.origin}/code?uuid=${encodeURIComponent($)}`;ic.toCanvas(R.current,S,{width:200,margin:1,color:N}).catch(w=>{console.error("QR generation failed:",w)})});return()=>cancelAnimationFrame(D)},[e,a,$,k,N]),m.useEffect(()=>{!e&&_.current&&(_.current.stop(),_.current.destroy(),_.current=null,s(!1))},[e]),!e)return null;const x=async()=>{await navigator.clipboard.writeText($),r(!0),setTimeout(()=>r(!1),2e3)},b=()=>{const D=u.trim();if(D.length<32){v("Invalid UUID");return}v(""),_n(D),y(Dr()),window.location.reload()},A=()=>{cp()&&(y(null),window.location.reload())},O=async()=>{if(j.current){s(!0);try{const D=new $t(j.current,S=>{F(S.data)},{returnDetailedScanResult:!0});_.current=D,await D.start()}catch(D){console.error("Camera error:",D),s(!1)}}},P=()=>{_.current&&(_.current.stop(),_.current.destroy(),_.current=null),s(!1)},F=D=>{try{const S=JSON.parse(D);if(S.url&&S.token){P(),t(),sessionStorage.setItem("acp_connection",JSON.stringify({url:S.url,token:S.token})),window.location.href="/code/?acp=1";return}}catch{}try{const w=new URL(D).searchParams.get("uuid");if(w){_n(w),P(),t();return}}catch{}if(D.length>=32){_n(D),P(),t();return}},M=()=>{const D=document.createElement("input");D.type="file",D.accept="image/*",D.onchange=async S=>{var L;const w=(L=S.target.files)==null?void 0:L[0];if(w)try{const E=await $t.scanImage(w,{returnDetailedScanResult:!0});F(E.data)}catch{alert("No QR code found in image")}},D.click()};return d.jsx(Gi,{open:e,onOpenChange:D=>{D||t()},children:d.jsxs(Ki,{className:"max-w-sm rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsx(qi,{children:d.jsx(Yi,{className:"font-display text-lg font-semibold text-text-primary",children:"Identity & Server"})}),d.jsxs("div",{className:"space-y-5",children:[d.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 p-3",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-text-secondary",children:[d.jsx(eu,{className:"h-4 w-4"}),"Server"]}),c?d.jsx("p",{className:"text-xs text-status-error",children:c}):h?d.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Version"}),d.jsx("dd",{className:"font-mono text-text-primary",children:h.version})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Uptime"}),d.jsx("dd",{className:"font-mono text-text-primary",children:Op(h.uptime_seconds)})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Workers"}),d.jsxs("dd",{className:"font-mono text-text-primary",children:[h.workers_active," active / ",h.workers_total]})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("dt",{children:"Your sessions"}),d.jsxs("dd",{className:"font-mono text-text-primary",children:[h.sessions_active," active / ",h.sessions_owned," owned"]})]})]}):d.jsx("p",{className:"text-xs text-text-muted",children:"Loading…"})]}),d.jsxs("section",{children:[d.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-text-secondary",children:[d.jsx(aa,{className:"h-4 w-4"}),"Your Identity"]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"flex-1 truncate rounded-lg bg-surface-2 px-3 py-2 font-mono text-xs text-text-primary",children:$}),d.jsx("button",{onClick:x,className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:n?"Copied!":"Copy"})]}),d.jsx("p",{className:"mt-2 text-xs text-text-muted",children:"此 UUID 标识你创建的会话归属。分享它可授予他人访问你创建的会话。"}),C&&C!==$&&d.jsxs("div",{className:"mt-3 flex items-center justify-between rounded-lg border border-border bg-surface-2 px-3 py-2",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-xs font-medium text-text-secondary",children:"已切换至他人身份"}),d.jsxs("p",{className:"truncate font-mono text-xs text-text-muted",children:["原 UUID: ",C]})]}),d.jsx("button",{onClick:A,className:"ml-2 shrink-0 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-1",children:"Switch back"})]}),d.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[d.jsx("input",{type:"text",value:u,onChange:D=>{p(D.target.value),v("")},onKeyDown:D=>{D.key==="Enter"&&u.trim()&&b()},placeholder:"粘贴他人的 UUID 以访问其会话",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 font-mono text-xs text-text-primary placeholder:text-text-muted focus:border-border focus:outline-none"}),d.jsxs("button",{onClick:b,disabled:!u.trim(),className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(ta,{className:"h-4 w-4"}),"Import"]})]}),g&&d.jsx("p",{className:"mt-1 text-xs text-status-error",children:g})]}),d.jsxs("section",{className:"border-t border-border pt-4",children:[d.jsxs("button",{onClick:()=>i(!a),className:"flex w-full items-center justify-between text-sm font-medium text-text-secondary hover:text-text-primary transition-colors",children:[d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(lu,{className:"h-4 w-4"}),"Device Sync"]}),d.jsx("span",{className:"text-xs text-text-muted",children:a?"▾":"▸"})]}),a&&d.jsxs("div",{className:"mt-4 space-y-4",children:[!o&&d.jsxs("div",{children:[d.jsx("label",{className:"mb-2 block text-xs text-text-secondary",children:"Scan on another device"}),d.jsx("div",{className:"flex justify-center",children:d.jsx("canvas",{ref:R})})]}),o&&d.jsxs("div",{children:[d.jsx("label",{className:"mb-2 block text-xs text-text-secondary",children:"Camera scanner"}),d.jsx("div",{className:"relative overflow-hidden rounded-lg",children:d.jsx("video",{ref:j,className:"w-full"})}),d.jsx("button",{onClick:P,className:"mt-2 w-full rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Stop scanning"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("button",{onClick:o?P:O,className:Z("flex flex-1 items-center justify-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors",o?"border-status-error/30 text-status-error hover:bg-status-error/10":"border-border text-text-secondary hover:bg-surface-2"),children:[d.jsx(qd,{className:"h-4 w-4"}),o?"Stop":"Scan"]}),d.jsx("button",{onClick:M,className:"flex flex-1 items-center justify-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Upload"})]})]})]})]})]})})}const ko="rcs_worker_tokens",xs="rcs_worker_token_",vs="rcs_worker_tokens_migrated";function Lp(){let e=Qt();if(typeof window>"u")return e;try{if(localStorage.getItem(vs))return e}catch{return e}try{for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!n||!n.startsWith(xs))continue;const r=n.slice(xs.length);if(!r)continue;const o=localStorage.getItem(n);if(!o)continue;const s=`__legacy_${r}`;e.some(a=>a.envId===s)||(e=[...e,{envId:s,token:o,label:`Migrated (session ${r.slice(0,8)})`}])}localStorage.setItem(ko,JSON.stringify(e)),localStorage.setItem(vs,"1")}catch{}return e}function vb(e){const t=Qt();let n=!1;const r=t.map(o=>{if(!o.envId.startsWith("__legacy_"))return o;const s=o.envId.slice(9),a=e.find(h=>h.id===s),i=a==null?void 0:a.environment_id;return i?t.some(h=>h!==o&&h.envId===i)?(n=!0,null):(n=!0,{...o,envId:i}):o}).filter(o=>o!==null);if(n){try{localStorage.setItem(ko,JSON.stringify(r))}catch{}window.dispatchEvent(new Event("rcs_worker_tokens_changed"))}}function $p(){const[e,t]=m.useState(()=>Lp()),n=m.useCallback(()=>{t(Qt())},[]);m.useEffect(()=>{const i=()=>t(Qt());return window.addEventListener("rcs_worker_tokens_changed",i),window.addEventListener("storage",i),()=>{window.removeEventListener("rcs_worker_tokens_changed",i),window.removeEventListener("storage",i)}},[]);const r=m.useCallback(i=>Lr(i),[]),o=m.useCallback((i,h,f)=>{up(i,h,f),n()},[n]),s=m.useCallback(i=>{fp(i),n()},[n]),a=m.useCallback(async i=>{const h=Lr(i);if(!h)return"unknown";try{const f=await xp(i,h),c=Qt().map(l=>l.envId===i?{...l,verifiedAt:f.valid?Date.now():l.verifiedAt}:l);try{localStorage.setItem(ko,JSON.stringify(c))}catch{}return n(),f.valid?"valid":"invalid"}catch{return"unknown"}},[n]);return{entries:e,getForEnv:r,add:o,remove:s,verify:a,refresh:n}}function Fp(e){return e==="acp"?{shortLabel:"ACP",fullLabel:"ACP Agent",colorClass:"bg-brand/15 text-brand"}:e==="repl"?{shortLabel:"REPL",fullLabel:"Saluzi REPL",colorClass:"bg-status-running/15 text-status-running"}:e==="saluzi"?{shortLabel:"Daemon",fullLabel:"RCS Daemon",colorClass:"bg-status-running/15 text-status-running"}:{shortLabel:e||"Unknown",fullLabel:e||"Unknown",colorClass:"bg-surface-2 text-text-muted"}}function Up({open:e,onClose:t,tokens:n,activeTokenId:r,onSetActive:o,onAdd:s,onRemove:a,onUpdate:i}){const[h,f]=m.useState("api_keys");return d.jsx(Gi,{open:e,onOpenChange:c=>{c||t()},children:d.jsxs(Ki,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsxs(qi,{children:[d.jsx(Yi,{className:"font-display text-lg font-semibold text-text-primary",children:"Token Manager"}),d.jsx(Pp,{className:"text-sm text-text-muted",children:"Manage API tokens and per-environment worker tokens for RCS authentication."})]}),d.jsxs("div",{className:"flex border-b border-border",children:[d.jsx("button",{onClick:()=>f("api_keys"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${h==="api_keys"?"border-b-2 border-brand text-text-primary":"text-text-muted hover:text-text-secondary"}`,children:"API Keys"}),d.jsx("button",{onClick:()=>f("worker_tokens"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${h==="worker_tokens"?"border-b-2 border-brand text-text-primary":"text-text-muted hover:text-text-secondary"}`,children:"Worker Tokens"})]}),h==="api_keys"?d.jsx(zp,{tokens:n,activeTokenId:r,onSetActive:o,onAdd:s,onRemove:a,onUpdate:i,onClose:t}):d.jsx(Bp,{})]})})}function zp({tokens:e,activeTokenId:t,onSetActive:n,onAdd:r,onRemove:o,onUpdate:s,onClose:a}){const[i,h]=m.useState(""),[f,c]=m.useState(""),[l,u]=m.useState(""),[p,g]=m.useState(null),[v,C]=m.useState(""),[y,R]=m.useState(null),[j,_]=m.useState(null),$=(A,O)=>{navigator.clipboard.writeText(O).then(()=>{_(A),setTimeout(()=>_(null),1500)})},k=()=>{const A=r(i,f);if(A){u(A);return}h(""),c(""),u("")},N=A=>{g(A.id),C(A.label)},x=A=>{s(A,v.trim()||"Unnamed"),g(null)},b=A=>{n(A),a()};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(A=>d.jsx("div",{className:"group flex items-center gap-1",children:p===A.id?d.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-lg bg-surface-2 px-3 py-1.5",children:[d.jsx("input",{value:v,onChange:O=>C(O.target.value),onKeyDown:O=>{O.key==="Enter"&&x(A.id),O.key==="Escape"&&g(null)},className:"flex-1 rounded border border-border bg-surface-1 px-2 py-1 text-sm text-text-primary focus:border-brand focus:outline-none",autoFocus:!0}),d.jsx("button",{onClick:()=>x(A.id),className:"text-brand hover:opacity-70 transition-opacity",children:d.jsx(wt,{className:"h-4 w-4"})}),d.jsx("button",{onClick:()=>g(null),className:"text-text-muted hover:text-text-primary transition-colors",children:d.jsx(an,{className:"h-4 w-4"})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>b(A.id),className:`flex flex-1 items-center justify-between rounded-lg px-3 py-2 text-sm transition-colors ${t===A.id?"bg-brand/10 text-brand":"text-text-secondary hover:bg-surface-2"}`,children:[d.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[d.jsx("span",{className:"font-medium truncate w-full",children:A.label}),d.jsx("span",{className:"text-xs text-text-muted font-mono",children:y===A.id?A.token:`${A.token.slice(0,6)}${"•".repeat(6)}`})]}),t===A.id&&d.jsx(wt,{className:"h-4 w-4 flex-shrink-0"})]}),d.jsx("button",{onClick:()=>R(y===A.id?null:A.id),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Toggle token visibility",children:y===A.id?d.jsx(Js,{className:"h-3.5 w-3.5"}):d.jsx(ea,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>$(A.id,A.token),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Copy token",children:j===A.id?d.jsx(wt,{className:"h-3.5 w-3.5 text-status-active"}):d.jsx(Cd,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>N(A),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Edit label",children:d.jsx(Vd,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>o(A.id),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-status-error transition-all",title:"Delete token",children:d.jsx(sa,{className:"h-3.5 w-3.5"})})]})},A.id)),e.length===0&&d.jsx("div",{className:"py-4 text-center text-sm text-text-muted",children:"No tokens saved yet. Add one below."})]}),d.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[d.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"Add Token"}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("input",{type:"text",value:i,onChange:A=>{h(A.target.value),u("")},placeholder:"API Token",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono",onKeyDown:A=>{A.key==="Enter"&&k()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:f,onChange:A=>c(A.target.value),placeholder:"Label (optional)",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:A=>{A.key==="Enter"&&k()}}),d.jsx("button",{onClick:k,disabled:!i.trim(),className:"rounded-lg bg-brand px-3 py-2 text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:d.jsx(Bn,{className:"h-4 w-4"})})]})]}),l&&d.jsx("div",{className:"text-xs text-status-error",children:l})]})]})}function Bp(){const{entries:e,add:t,remove:n,verify:r,refresh:o}=$p(),[s,a]=m.useState([]),[i,h]=m.useState(""),[f,c]=m.useState(""),[l,u]=m.useState(""),[p,g]=m.useState(""),[v,C]=m.useState(new Set),[y,R]=m.useState({});m.useEffect(()=>{gp().then(N=>a(N||[])).catch(N=>console.error("Failed to load environments:",N))},[]),m.useEffect(()=>{if(s.length===0)return;const N=new Set(s.map(b=>b.id)),x=e.filter(b=>!b.envId.startsWith("__legacy_")&&!N.has(b.envId));x.length>0&&x.forEach(b=>n(b.envId))},[s,e,n]);const j=N=>{if(N.startsWith("__legacy_"))return`Legacy session ${N.slice(9).slice(0,8)}`;const x=s.find(b=>b.id===N);return(x==null?void 0:x.machine_name)||N},_=()=>{const N=f.trim();if(!N){g("Token is required");return}if(!i){g("Select an environment");return}t(i,N,l.trim()||void 0),c(""),u(""),g("")},$=async N=>{R(b=>({...b,[N]:"pending"}));const x=await r(N);R(b=>({...b,[N]:x})),o()},k=N=>{C(x=>{const b=new Set(x);return b.has(N)?b.delete(N):b.add(N),b})};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(N=>{const x=y[N.envId];return d.jsxs("div",{className:"group flex items-center gap-1 rounded-lg px-2 py-2 text-sm text-text-secondary hover:bg-surface-2",children:[d.jsxs("div",{className:"flex flex-1 flex-col items-start min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[d.jsx("span",{className:"font-medium truncate",children:j(N.envId)}),N.label&&d.jsxs("span",{className:"text-xs text-text-muted truncate",children:["· ",N.label]}),x==="valid"&&d.jsx(Vo,{className:"h-3.5 w-3.5 text-status-active flex-shrink-0"}),x==="invalid"&&d.jsx(Qr,{className:"h-3.5 w-3.5 text-status-error flex-shrink-0"})]}),d.jsx("span",{className:"text-xs text-text-muted font-mono",children:v.has(N.envId)?N.token:`${N.token.slice(0,6)}${"•".repeat(6)}`})]}),d.jsx("button",{onClick:()=>k(N.envId),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-text-primary transition-all",title:"Toggle token visibility",children:v.has(N.envId)?d.jsx(Js,{className:"h-3.5 w-3.5"}):d.jsx(ea,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>$(N.envId),disabled:x==="pending",className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-brand transition-all disabled:opacity-50",title:"Test token",children:d.jsx(Vo,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>n(N.envId),className:"rounded p-1 text-text-muted opacity-0 group-hover:opacity-100 hover:text-status-error transition-all",title:"Delete worker token",children:d.jsx(sa,{className:"h-3.5 w-3.5"})})]},N.envId)}),e.length===0&&d.jsx("div",{className:"py-4 text-center text-sm text-text-muted",children:"No worker tokens saved. Add one for an environment below."})]}),d.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[d.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"Add Worker Token"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("select",{value:i,onChange:N=>h(N.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[d.jsx("option",{value:"",children:"-- Select environment --"}),s.map(N=>{const x=Fp(N.worker_type).shortLabel;return d.jsxs("option",{value:N.id,children:[N.machine_name||N.id," (",N.branch||"no branch",") · ",x,N.has_worker_token?" · protected":""]},N.id)})]}),d.jsx("input",{type:"password",value:f,onChange:N=>{c(N.target.value),g("")},placeholder:"RCS_WORKER_TOKENS value",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono",onKeyDown:N=>{N.key==="Enter"&&_()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:l,onChange:N=>u(N.target.value),placeholder:"Label (optional)",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:N=>{N.key==="Enter"&&_()}}),d.jsx("button",{onClick:_,disabled:!f.trim()||!i,className:"rounded-lg bg-brand px-3 py-2 text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:d.jsx(Bn,{className:"h-4 w-4"})})]})]}),p&&d.jsx("div",{className:"text-xs text-status-error",children:p}),d.jsx("p",{className:"text-xs text-text-muted",children:"Worker tokens are stored per-environment and applied automatically to all sessions in that environment."})]})]})}function Wp(e){const t=new TextEncoder().encode(e);let n="";for(const o of t)n+=String.fromCharCode(o);return`rcs.auth.${btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}class Xi extends Error{constructor(){super("Disconnect requested"),this.name="DisconnectRequestedError"}}const st=class st{constructor(t){le(this,"ws",null);le(this,"settings");le(this,"connectionState","disconnected");le(this,"sessionId",null);le(this,"_agentCapabilities",null);le(this,"_promptCapabilities",null);le(this,"_modelState",null);le(this,"_availableCommands",[]);le(this,"onModelChanged",new Set);le(this,"onModelStateChanged",new Set);le(this,"onAvailableCommandsChanged",null);le(this,"onSessionLoaded",null);le(this,"onSessionSwitching",null);le(this,"onConnectionStateChange",new Set);le(this,"onSessionUpdate",null);le(this,"onSessionCreated",null);le(this,"onPromptComplete",null);le(this,"onPermissionRequest",null);le(this,"onBrowserToolCall",null);le(this,"onErrorMessage",null);le(this,"pendingSessionList",null);le(this,"pendingSessionLoad",null);le(this,"pendingSessionResume",null);le(this,"pendingSessionTarget",null);le(this,"connectResolve",null);le(this,"connectReject",null);le(this,"heartbeatInterval",null);le(this,"heartbeatTimeout",null);le(this,"missedPongs",0);this.settings=t}updateSettings(t){this.settings=t}setConnectionStateHandler(t){this.onConnectionStateChange.add(t)}removeConnectionStateHandler(t){this.onConnectionStateChange.delete(t)}setSessionUpdateHandler(t){this.onSessionUpdate=t}setSessionCreatedHandler(t){this.onSessionCreated=t}setPromptCompleteHandler(t){this.onPromptComplete=t}setModelChangedHandler(t){this.onModelChanged.add(t)}removeModelChangedHandler(t){this.onModelChanged.delete(t)}setModelStateChangedHandler(t){this.onModelStateChanged.add(t),t(this._modelState)}removeModelStateChangedHandler(t){this.onModelStateChanged.delete(t)}setAvailableCommandsChangedHandler(t){this.onAvailableCommandsChanged=t,t(this._availableCommands)}setPermissionRequestHandler(t){this.onPermissionRequest=t}setBrowserToolCallHandler(t){this.onBrowserToolCall=t}setErrorMessageHandler(t){this.onErrorMessage=t}setSessionSwitchingHandler(t){this.onSessionSwitching=t}setState(t,n){this.connectionState=t;for(const r of this.onConnectionStateChange)r(t,n)}getState(){return this.connectionState}getSessionId(){return this.sessionId}get supportsImages(){var t;return((t=this._promptCapabilities)==null?void 0:t.image)===!0}getPromptCapabilities(){return this._promptCapabilities}get modelState(){return this._modelState}get availableCommands(){return this._availableCommands}get supportsModelSelection(){return this._modelState!==null&&this._modelState.availableModels.length>0}get agentCapabilities(){return this._agentCapabilities}get supportsLoadSession(){var t;return((t=this._agentCapabilities)==null?void 0:t.loadSession)===!0}get supportsResumeSession(){var t,n,r,o;return((n=(t=this._agentCapabilities)==null?void 0:t.sessionCapabilities)==null?void 0:n.resume)!==void 0&&((o=(r=this._agentCapabilities)==null?void 0:r.sessionCapabilities)==null?void 0:o.resume)!==null}get supportsSessionList(){var t,n,r,o;return((n=(t=this._agentCapabilities)==null?void 0:t.sessionCapabilities)==null?void 0:n.list)!==void 0&&((o=(r=this._agentCapabilities)==null?void 0:r.sessionCapabilities)==null?void 0:o.list)!==null}get supportsSessionHistory(){return this.supportsLoadSession||this.supportsResumeSession}async connect(){if(this.ws){const t=this.ws;this.ws=null;try{t.close()}catch{}this.stopHeartbeat(),this.connectResolve=null,this.connectReject=null}return this.setState("connecting"),new Promise((t,n)=>{this.connectResolve=t,this.connectReject=n;try{const r=new WebSocket(this.settings.proxyUrl,this.settings.token?[Wp(this.settings.token)]:void 0);this.ws=r,r.onopen=()=>{if(this.ws!==r){console.log("[ACPClient] WebSocket opened but already disconnected/replaced, closing stale socket"),r.close();return}console.log("[ACPClient] WebSocket connected, sending connect command"),this.send({type:"connect"})},r.onmessage=o=>{if(this.ws===r)try{const s=JSON.parse(o.data);this.handleResponse(s)}catch(s){console.error("[ACPClient] Failed to parse message:",s)}},r.onerror=()=>{var o;this.ws===r&&(console.error("[ACPClient] WebSocket error"),this.setState("error","WebSocket connection error"),(o=this.connectReject)==null||o.call(this,new Error("WebSocket connection error")),this.connectResolve=null,this.connectReject=null)},r.onclose=o=>{if(this.ws===r){if(console.log("[ACPClient] WebSocket closed",o.code,o.reason),this.connectReject){const s=o.reason||`Connection closed (code: ${o.code})`;this.setState("error",s),this.connectReject(new Error(s)),this.connectResolve=null,this.connectReject=null}else this.setState("disconnected");this.ws=null,this.sessionId=null}}}catch(r){this.setState("error",r.message),n(r)}})}handleResponse(t){var n,r,o,s,a,i,h,f,c,l,u;switch(console.log("[ACPClient] Received:",t.type),t.type){case"status":t.payload.connected?(this._agentCapabilities=t.payload.capabilities??null,this.setState("connected"),this.startHeartbeat(),(n=this.connectResolve)==null||n.call(this,void 0)):(this.stopHeartbeat(),this.setState("disconnected")),this.connectResolve=null,this.connectReject=null;break;case"error":console.error("[ACPClient] Error:",t.payload);const p=((r=t.payload)==null?void 0:r.message)||JSON.stringify(t.payload);this.pendingSessionTarget=null,this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.reject(new Error(p)),this.pendingSessionList=null),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.reject(new Error(p)),this.pendingSessionLoad=null),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.reject(new Error(p)),this.pendingSessionResume=null),this.connectReject?(this.connectReject(new Error(p)),this.connectResolve=null,this.connectReject=null):(console.error("[ACPClient] Agent error:",p),(o=this.onErrorMessage)==null||o.call(this,p));break;case"session_created":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session created, promptCapabilities:",this._promptCapabilities,"models:",this._modelState),(s=this.onSessionCreated)==null||s.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_list":console.log("[ACPClient] Session list received:",t.payload.sessions.length,"sessions"),this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.resolve(t.payload),this.pendingSessionList=null);break;case"session_loaded":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session loaded:",t.payload.sessionId),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.resolve(t.payload.sessionId),this.pendingSessionLoad=null),(a=this.onSessionLoaded)==null||a.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_resumed":this.sessionId=t.payload.sessionId,this.pendingSessionTarget=null,this._promptCapabilities=t.payload.promptCapabilities??null,this._modelState=t.payload.models??null,console.log("[ACPClient] Session resumed:",t.payload.sessionId),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.resolve(t.payload.sessionId),this.pendingSessionResume=null),(i=this.onSessionLoaded)==null||i.call(this,t.payload.sessionId);for(const v of this.onModelStateChanged)v(this._modelState);break;case"session_update":const g=(h=t.payload.update)==null?void 0:h.sessionUpdate;console.log("[ACPClient] session_update type:",g,"payload:",t.payload),g==="available_commands_update"&&(this._availableCommands=t.payload.update.availableCommands,console.log("[ACPClient] Available commands updated:",this._availableCommands.length,"commands"),(f=this.onAvailableCommandsChanged)==null||f.call(this,this._availableCommands)),(c=this.onSessionUpdate)==null||c.call(this,t.payload.sessionId,t.payload.update);break;case"prompt_complete":(l=this.onPromptComplete)==null||l.call(this,t.payload.stopReason);break;case"permission_request":console.log("[ACPClient] Permission request:",t.payload),(u=this.onPermissionRequest)==null||u.call(this,t.payload);break;case"model_changed":console.log("[ACPClient] Model changed:",t.payload.modelId),this._modelState&&(this._modelState={...this._modelState,currentModelId:t.payload.modelId});for(const v of this.onModelChanged)v(t.payload.modelId);break;case"browser_tool_call":this.handleBrowserToolCall(t.callId,t.params);break;case"pong":this.missedPongs=0,this.heartbeatTimeout&&(clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=null);break}}async handleBrowserToolCall(t,n){if(console.log("[ACPClient] Browser tool call:",t,n),!this.onBrowserToolCall){console.error("[ACPClient] No browser tool handler registered"),this.send({type:"browser_tool_result",callId:t,result:{error:"No browser tool handler registered"}});return}try{const r=await this.onBrowserToolCall(n);this.send({type:"browser_tool_result",callId:t,result:r})}catch(r){console.error("[ACPClient] Browser tool error:",r),this.send({type:"browser_tool_result",callId:t,result:{error:r.message}})}}startHeartbeat(){this.stopHeartbeat(),this.missedPongs=0,this.heartbeatInterval=setInterval(()=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.stopHeartbeat();return}this.ws.send(JSON.stringify({type:"ping"})),this.heartbeatTimeout=setTimeout(()=>{var t;this.missedPongs++,this.missedPongs>=st.MAX_MISSED_PONGS&&(console.warn(`[ACPClient] Server unresponsive (${this.missedPongs} missed pongs), closing connection`),this.stopHeartbeat(),(t=this.ws)==null||t.close(4e3,"Heartbeat timeout"))},st.PONG_TIMEOUT_MS)},st.HEARTBEAT_INTERVAL_MS)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null),this.heartbeatTimeout&&(clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=null)}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");this.ws.send(JSON.stringify(t))}async createSession(t,n){const r=t??this.settings.cwd;this.send({type:"new_session",payload:{cwd:r,permissionMode:n}})}async sendPrompt(t){if(!this.sessionId)throw new Error("No active session");const n=typeof t=="string"?[{type:"text",text:t}]:t;this.send({type:"prompt",payload:{content:n}})}cancel(){this.send({type:"cancel"})}async setSessionModel(t){if(!this.sessionId)throw new Error("No active session");this.send({type:"set_session_model",payload:{modelId:t}})}respondToPermission(t,n){const r=n?{outcome:"selected",optionId:n}:{outcome:"cancelled"};this.send({type:"permission_response",payload:{requestId:t,outcome:r}})}setSessionLoadedHandler(t){this.onSessionLoaded=t}async listSessions(t){if(!this.supportsSessionList)throw new Error("Listing sessions is not supported by this agent");return new Promise((n,r)=>{const o=setTimeout(()=>{this.pendingSessionList&&(this.pendingSessionList=null,r(new Error("List sessions timed out")))},3e4);this.pendingSessionList={resolve:n,reject:r,timer:o};try{this.send({type:"list_sessions",payload:t})}catch(s){clearTimeout(o),this.pendingSessionList=null,r(s)}})}async loadSession(t){if(!this.supportsLoadSession)throw new Error("Loading sessions is not supported by this agent");return new Promise((n,r)=>{var s;this.pendingSessionTarget=t.sessionId,(s=this.onSessionSwitching)==null||s.call(this,t.sessionId);const o=setTimeout(()=>{this.pendingSessionLoad&&(this.pendingSessionTarget=null,this.pendingSessionLoad=null,r(new Error("Load session timed out")))},6e4);this.pendingSessionLoad={resolve:n,reject:r,timer:o};try{this.send({type:"load_session",payload:t})}catch(a){clearTimeout(o),this.pendingSessionTarget=null,this.pendingSessionLoad=null,r(a)}})}async resumeSession(t){if(!this.supportsResumeSession)throw new Error("Resuming sessions is not supported by this agent");return new Promise((n,r)=>{var s;this.pendingSessionTarget=t.sessionId,(s=this.onSessionSwitching)==null||s.call(this,t.sessionId);const o=setTimeout(()=>{this.pendingSessionResume&&(this.pendingSessionTarget=null,this.pendingSessionResume=null,r(new Error("Resume session timed out")))},3e4);this.pendingSessionResume={resolve:n,reject:r,timer:o};try{this.send({type:"resume_session",payload:t})}catch(a){clearTimeout(o),this.pendingSessionTarget=null,this.pendingSessionResume=null,r(a)}})}disconnect(){var n;this.stopHeartbeat(),this.connectReject&&this.connectReject(new Xi),this.connectResolve=null,this.connectReject=null,this.ws&&(this.ws.close(),this.ws=null),this.setState("disconnected"),this.sessionId=null,this.pendingSessionTarget=null,this._modelState=null,this._agentCapabilities=null,this._availableCommands=[];for(const r of this.onModelStateChanged)r(null);(n=this.onAvailableCommandsChanged)==null||n.call(this,[]);const t=new Error("Disconnected");this.pendingSessionList&&(clearTimeout(this.pendingSessionList.timer),this.pendingSessionList.reject(t),this.pendingSessionList=null),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.reject(t),this.pendingSessionLoad=null),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.reject(t),this.pendingSessionResume=null)}};le(st,"HEARTBEAT_INTERVAL_MS",3e4),le(st,"PONG_TIMEOUT_MS",1e4),le(st,"MAX_MISSED_PONGS",2);let Fr=st;function Hp(e,t){return t.forEach((function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach((function(r){if(r!=="default"&&!(r in e)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}}))})),Object.freeze(e)}function Qi(e,t){return new Promise((function(n,r){let o;return Vp(e).then((function(s){try{return o=s,n(new Blob([t.slice(0,2),o,t.slice(2)],{type:"image/jpeg"}))}catch(a){return r(a)}}),r)}))}const Vp=e=>new Promise(((t,n)=>{const r=new FileReader;r.addEventListener("load",(({target:{result:o}})=>{const s=new DataView(o);let a=0;if(s.getUint16(a)!==65496)return n("not a valid JPEG");for(a+=2;;){const i=s.getUint16(a);if(i===65498)break;const h=s.getUint16(a+2);if(i===65505&&s.getUint32(a+4)===1165519206){const f=a+10;let c;switch(s.getUint16(f)){case 18761:c=!0;break;case 19789:c=!1;break;default:return n("TIFF header contains invalid endian")}if(s.getUint16(f+2,c)!==42)return n("TIFF header contains invalid version");const l=s.getUint32(f+4,c),u=f+l+2+12*s.getUint16(f+l,c);for(let p=f+l+2;p<u;p+=12)if(s.getUint16(p,c)==274){if(s.getUint16(p+2,c)!==3)return n("Orientation data type is invalid");if(s.getUint32(p+4,c)!==1)return n("Orientation data count is invalid");s.setUint16(p+8,1,c);break}return t(o.slice(a,a+2+h))}a+=2+h}return t(new Blob)})),r.readAsArrayBuffer(e)}));var Ln={},Gp={get exports(){return Ln},set exports(e){Ln=e}};(function(e){var t,n,r={};Gp.exports=r,r.parse=function(o,s){for(var a=r.bin.readUshort,i=r.bin.readUint,h=0,f={},c=new Uint8Array(o),l=c.length-4;i(c,l)!=101010256;)l--;h=l,h+=4;var u=a(c,h+=4);a(c,h+=2);var p=i(c,h+=2),g=i(c,h+=4);h+=4,h=g;for(var v=0;v<u;v++){i(c,h),h+=4,h+=4,h+=4,i(c,h+=4),p=i(c,h+=4);var C=i(c,h+=4),y=a(c,h+=4),R=a(c,h+2),j=a(c,h+4);h+=6;var _=i(c,h+=8);h+=4,h+=y+R+j,r._readLocal(c,_,f,p,C,s)}return f},r._readLocal=function(o,s,a,i,h,f){var c=r.bin.readUshort,l=r.bin.readUint;l(o,s),c(o,s+=4),c(o,s+=2);var u=c(o,s+=2);l(o,s+=2),l(o,s+=4),s+=4;var p=c(o,s+=8),g=c(o,s+=2);s+=2;var v=r.bin.readUTF8(o,s,p);if(s+=p,s+=g,f)a[v]={size:h,csize:i};else{var C=new Uint8Array(o.buffer,s);if(u==0)a[v]=new Uint8Array(C.buffer.slice(s,s+i));else{if(u!=8)throw"unknown compression method: "+u;var y=new Uint8Array(h);r.inflateRaw(C,y),a[v]=y}}},r.inflateRaw=function(o,s){return r.F.inflate(o,s)},r.inflate=function(o,s){return o[0],o[1],r.inflateRaw(new Uint8Array(o.buffer,o.byteOffset+2,o.length-6),s)},r.deflate=function(o,s){s==null&&(s={level:6});var a=0,i=new Uint8Array(50+Math.floor(1.1*o.length));i[a]=120,i[a+1]=156,a+=2,a=r.F.deflateRaw(o,i,a,s.level);var h=r.adler(o,0,o.length);return i[a+0]=h>>>24&255,i[a+1]=h>>>16&255,i[a+2]=h>>>8&255,i[a+3]=h>>>0&255,new Uint8Array(i.buffer,0,a+4)},r.deflateRaw=function(o,s){s==null&&(s={level:6});var a=new Uint8Array(50+Math.floor(1.1*o.length)),i=r.F.deflateRaw(o,a,i,s.level);return new Uint8Array(a.buffer,0,i)},r.encode=function(o,s){s==null&&(s=!1);var a=0,i=r.bin.writeUint,h=r.bin.writeUshort,f={};for(var c in o){var l=!r._noNeed(c)&&!s,u=o[c],p=r.crc.crc(u,0,u.length);f[c]={cpr:l,usize:u.length,crc:p,file:l?r.deflateRaw(u):u}}for(var c in f)a+=f[c].file.length+30+46+2*r.bin.sizeUTF8(c);a+=22;var g=new Uint8Array(a),v=0,C=[];for(var c in f){var y=f[c];C.push(v),v=r._writeHeader(g,v,c,y,0)}var R=0,j=v;for(var c in f)y=f[c],C.push(v),v=r._writeHeader(g,v,c,y,1,C[R++]);var _=v-j;return i(g,v,101010256),v+=4,h(g,v+=4,R),h(g,v+=2,R),i(g,v+=2,_),i(g,v+=4,j),v+=4,v+=2,g.buffer},r._noNeed=function(o){var s=o.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(s)!=-1},r._writeHeader=function(o,s,a,i,h,f){var c=r.bin.writeUint,l=r.bin.writeUshort,u=i.file;return c(o,s,h==0?67324752:33639248),s+=4,h==1&&(s+=2),l(o,s,20),l(o,s+=2,0),l(o,s+=2,i.cpr?8:0),c(o,s+=2,0),c(o,s+=4,i.crc),c(o,s+=4,u.length),c(o,s+=4,i.usize),l(o,s+=4,r.bin.sizeUTF8(a)),l(o,s+=2,0),s+=2,h==1&&(s+=2,s+=2,c(o,s+=6,f),s+=4),s+=r.bin.writeUTF8(o,s,a),h==0&&(o.set(u,s),s+=u.length),s},r.crc={table:(function(){for(var o=new Uint32Array(256),s=0;s<256;s++){for(var a=s,i=0;i<8;i++)1&a?a=3988292384^a>>>1:a>>>=1;o[s]=a}return o})(),update:function(o,s,a,i){for(var h=0;h<i;h++)o=r.crc.table[255&(o^s[a+h])]^o>>>8;return o},crc:function(o,s,a){return 4294967295^r.crc.update(4294967295,o,s,a)}},r.adler=function(o,s,a){for(var i=1,h=0,f=s,c=s+a;f<c;){for(var l=Math.min(f+5552,c);f<l;)h+=i+=o[f++];i%=65521,h%=65521}return h<<16|i},r.bin={readUshort:function(o,s){return o[s]|o[s+1]<<8},writeUshort:function(o,s,a){o[s]=255&a,o[s+1]=a>>8&255},readUint:function(o,s){return 16777216*o[s+3]+(o[s+2]<<16|o[s+1]<<8|o[s])},writeUint:function(o,s,a){o[s]=255&a,o[s+1]=a>>8&255,o[s+2]=a>>16&255,o[s+3]=a>>24&255},readASCII:function(o,s,a){for(var i="",h=0;h<a;h++)i+=String.fromCharCode(o[s+h]);return i},writeASCII:function(o,s,a){for(var i=0;i<a.length;i++)o[s+i]=a.charCodeAt(i)},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,s,a){for(var i,h="",f=0;f<a;f++)h+="%"+r.bin.pad(o[s+f].toString(16));try{i=decodeURIComponent(h)}catch{return r.bin.readASCII(o,s,a)}return i},writeUTF8:function(o,s,a){for(var i=a.length,h=0,f=0;f<i;f++){var c=a.charCodeAt(f);if((4294967168&c)==0)o[s+h]=c,h++;else if((4294965248&c)==0)o[s+h]=192|c>>6,o[s+h+1]=128|c>>0&63,h+=2;else if((4294901760&c)==0)o[s+h]=224|c>>12,o[s+h+1]=128|c>>6&63,o[s+h+2]=128|c>>0&63,h+=3;else{if((4292870144&c)!=0)throw"e";o[s+h]=240|c>>18,o[s+h+1]=128|c>>12&63,o[s+h+2]=128|c>>6&63,o[s+h+3]=128|c>>0&63,h+=4}}return h},sizeUTF8:function(o){for(var s=o.length,a=0,i=0;i<s;i++){var h=o.charCodeAt(i);if((4294967168&h)==0)a++;else if((4294965248&h)==0)a+=2;else if((4294901760&h)==0)a+=3;else{if((4292870144&h)!=0)throw"e";a+=4}}return a}},r.F={},r.F.deflateRaw=function(o,s,a,i){var h=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][i],f=r.F.U,c=r.F._goodIndex;r.F._hash;var l=r.F._putsE,u=0,p=a<<3,g=0,v=o.length;if(i==0){for(;u<v;)l(s,p,u+(O=Math.min(65535,v-u))==v?1:0),p=r.F._copyExact(o,u,O,s,p+8),u+=O;return p>>>3}var C=f.lits,y=f.strt,R=f.prev,j=0,_=0,$=0,k=0,N=0,x=0;for(v>2&&(y[x=r.F._hash(o,0)]=0),u=0;u<v;u++){if(N=x,u+1<v-2){x=r.F._hash(o,u+1);var b=u+1&32767;R[b]=y[x],y[x]=b}if(g<=u){(j>14e3||_>26697)&&v-u>100&&(g<u&&(C[j]=u-g,j+=2,g=u),p=r.F._writeBlock(u==v-1||g==v?1:0,C,j,k,o,$,u-$,s,p),j=_=k=0,$=u);var A=0;u<v-2&&(A=r.F._bestMatch(o,u,R,N,Math.min(h[2],v-u),h[3]));var O=A>>>16,P=65535&A;if(A!=0){P=65535&A;var F=c(O=A>>>16,f.of0);f.lhst[257+F]++;var M=c(P,f.df0);f.dhst[M]++,k+=f.exb[F]+f.dxb[M],C[j]=O<<23|u-g,C[j+1]=P<<16|F<<8|M,j+=2,g=u+O}else f.lhst[o[u]]++;_++}}for($==u&&o.length!=0||(g<u&&(C[j]=u-g,j+=2,g=u),p=r.F._writeBlock(1,C,j,k,o,$,u-$,s,p),j=0,_=0,j=_=k=0,$=u);(7&p)!=0;)p++;return p>>>3},r.F._bestMatch=function(o,s,a,i,h,f){var c=32767&s,l=a[c],u=c-l+32768&32767;if(l==c||i!=r.F._hash(o,s-u))return 0;for(var p=0,g=0,v=Math.min(32767,s);u<=v&&--f!=0&&l!=c;){if(p==0||o[s+p]==o[s+p-u]){var C=r.F._howLong(o,s,u);if(C>p){if(g=u,(p=C)>=h)break;u+2<C&&(C=u+2);for(var y=0,R=0;R<C-2;R++){var j=s-u+R+32768&32767,_=j-a[j]+32768&32767;_>y&&(y=_,l=j)}}}u+=(c=l)-(l=a[c])+32768&32767}return p<<16|g},r.F._howLong=function(o,s,a){if(o[s]!=o[s-a]||o[s+1]!=o[s+1-a]||o[s+2]!=o[s+2-a])return 0;var i=s,h=Math.min(o.length,s+258);for(s+=3;s<h&&o[s]==o[s-a];)s++;return s-i},r.F._hash=function(o,s){return(o[s]<<8|o[s+1])+(o[s+2]<<4)&65535},r.saved=0,r.F._writeBlock=function(o,s,a,i,h,f,c,l,u){var p,g,v,C,y,R,j,_,$,k=r.F.U,N=r.F._putsF,x=r.F._putsE;k.lhst[256]++,g=(p=r.F.getTrees())[0],v=p[1],C=p[2],y=p[3],R=p[4],j=p[5],_=p[6],$=p[7];var b=32+((u+3&7)==0?0:8-(u+3&7))+(c<<3),A=i+r.F.contSize(k.fltree,k.lhst)+r.F.contSize(k.fdtree,k.dhst),O=i+r.F.contSize(k.ltree,k.lhst)+r.F.contSize(k.dtree,k.dhst);O+=14+3*j+r.F.contSize(k.itree,k.ihst)+(2*k.ihst[16]+3*k.ihst[17]+7*k.ihst[18]);for(var P=0;P<286;P++)k.lhst[P]=0;for(P=0;P<30;P++)k.dhst[P]=0;for(P=0;P<19;P++)k.ihst[P]=0;var F=b<A&&b<O?0:A<O?1:2;if(N(l,u,o),N(l,u+1,F),u+=3,F==0){for(;(7&u)!=0;)u++;u=r.F._copyExact(h,f,c,l,u)}else{var M,D;if(F==1&&(M=k.fltree,D=k.fdtree),F==2){r.F.makeCodes(k.ltree,g),r.F.revCodes(k.ltree,g),r.F.makeCodes(k.dtree,v),r.F.revCodes(k.dtree,v),r.F.makeCodes(k.itree,C),r.F.revCodes(k.itree,C),M=k.ltree,D=k.dtree,x(l,u,y-257),x(l,u+=5,R-1),x(l,u+=5,j-4),u+=4;for(var S=0;S<j;S++)x(l,u+3*S,k.itree[1+(k.ordr[S]<<1)]);u+=3*j,u=r.F._codeTiny(_,k.itree,l,u),u=r.F._codeTiny($,k.itree,l,u)}for(var w=f,L=0;L<a;L+=2){for(var E=s[L],I=E>>>23,W=w+(8388607&E);w<W;)u=r.F._writeLit(h[w++],M,l,u);if(I!=0){var T=s[L+1],B=T>>16,z=T>>8&255,U=255&T;x(l,u=r.F._writeLit(257+z,M,l,u),I-k.of0[z]),u+=k.exb[z],N(l,u=r.F._writeLit(U,D,l,u),B-k.df0[U]),u+=k.dxb[U],w+=I}}u=r.F._writeLit(256,M,l,u)}return u},r.F._copyExact=function(o,s,a,i,h){var f=h>>>3;return i[f]=a,i[f+1]=a>>>8,i[f+2]=255-i[f],i[f+3]=255-i[f+1],f+=4,i.set(new Uint8Array(o.buffer,s,a),f),h+(a+4<<3)},r.F.getTrees=function(){for(var o=r.F.U,s=r.F._hufTree(o.lhst,o.ltree,15),a=r.F._hufTree(o.dhst,o.dtree,15),i=[],h=r.F._lenCodes(o.ltree,i),f=[],c=r.F._lenCodes(o.dtree,f),l=0;l<i.length;l+=2)o.ihst[i[l]]++;for(l=0;l<f.length;l+=2)o.ihst[f[l]]++;for(var u=r.F._hufTree(o.ihst,o.itree,7),p=19;p>4&&o.itree[1+(o.ordr[p-1]<<1)]==0;)p--;return[s,a,u,h,c,p,i,f]},r.F.getSecond=function(o){for(var s=[],a=0;a<o.length;a+=2)s.push(o[a+1]);return s},r.F.nonZero=function(o){for(var s="",a=0;a<o.length;a+=2)o[a+1]!=0&&(s+=(a>>1)+",");return s},r.F.contSize=function(o,s){for(var a=0,i=0;i<s.length;i++)a+=s[i]*o[1+(i<<1)];return a},r.F._codeTiny=function(o,s,a,i){for(var h=0;h<o.length;h+=2){var f=o[h],c=o[h+1];i=r.F._writeLit(f,s,a,i);var l=f==16?2:f==17?3:7;f>15&&(r.F._putsE(a,i,c,l),i+=l)}return i},r.F._lenCodes=function(o,s){for(var a=o.length;a!=2&&o[a-1]==0;)a-=2;for(var i=0;i<a;i+=2){var h=o[i+1],f=i+3<a?o[i+3]:-1,c=i+5<a?o[i+5]:-1,l=i==0?-1:o[i-1];if(h==0&&f==h&&c==h){for(var u=i+5;u+2<a&&o[u+2]==h;)u+=2;(p=Math.min(u+1-i>>>1,138))<11?s.push(17,p-3):s.push(18,p-11),i+=2*p-2}else if(h==l&&f==h&&c==h){for(u=i+5;u+2<a&&o[u+2]==h;)u+=2;var p=Math.min(u+1-i>>>1,6);s.push(16,p-3),i+=2*p-2}else s.push(h,0)}return a>>>1},r.F._hufTree=function(o,s,a){var i=[],h=o.length,f=s.length,c=0;for(c=0;c<f;c+=2)s[c]=0,s[c+1]=0;for(c=0;c<h;c++)o[c]!=0&&i.push({lit:c,f:o[c]});var l=i.length,u=i.slice(0);if(l==0)return 0;if(l==1){var p=i[0].lit;return u=p==0?1:0,s[1+(p<<1)]=1,s[1+(u<<1)]=1,1}i.sort((function(_,$){return _.f-$.f}));var g=i[0],v=i[1],C=0,y=1,R=2;for(i[0]={lit:-1,f:g.f+v.f,l:g,r:v,d:0};y!=l-1;)g=C!=y&&(R==l||i[C].f<i[R].f)?i[C++]:i[R++],v=C!=y&&(R==l||i[C].f<i[R].f)?i[C++]:i[R++],i[y++]={lit:-1,f:g.f+v.f,l:g,r:v};var j=r.F.setDepth(i[y-1],0);for(j>a&&(r.F.restrictDepth(u,a,j),j=a),c=0;c<l;c++)s[1+(u[c].lit<<1)]=u[c].d;return j},r.F.setDepth=function(o,s){return o.lit!=-1?(o.d=s,s):Math.max(r.F.setDepth(o.l,s+1),r.F.setDepth(o.r,s+1))},r.F.restrictDepth=function(o,s,a){var i=0,h=1<<a-s,f=0;for(o.sort((function(l,u){return u.d==l.d?l.f-u.f:u.d-l.d})),i=0;i<o.length&&o[i].d>s;i++){var c=o[i].d;o[i].d=s,f+=h-(1<<a-c)}for(f>>>=a-s;f>0;)(c=o[i].d)<s?(o[i].d++,f-=1<<s-c-1):i++;for(;i>=0;i--)o[i].d==s&&f<0&&(o[i].d--,f++);f!=0&&console.log("debt left")},r.F._goodIndex=function(o,s){var a=0;return s[16|a]<=o&&(a|=16),s[8|a]<=o&&(a|=8),s[4|a]<=o&&(a|=4),s[2|a]<=o&&(a|=2),s[1|a]<=o&&(a|=1),a},r.F._writeLit=function(o,s,a,i){return r.F._putsF(a,i,s[o<<1]),i+s[1+(o<<1)]},r.F.inflate=function(o,s){var a=Uint8Array;if(o[0]==3&&o[1]==0)return s||new a(0);var i=r.F,h=i._bitsF,f=i._bitsE,c=i._decodeTiny,l=i.makeCodes,u=i.codes2map,p=i._get17,g=i.U,v=s==null;v&&(s=new a(o.length>>>2<<3));for(var C,y,R=0,j=0,_=0,$=0,k=0,N=0,x=0,b=0,A=0;R==0;)if(R=h(o,A,1),j=h(o,A+1,2),A+=3,j!=0){if(v&&(s=r.F._check(s,b+(1<<17))),j==1&&(C=g.flmap,y=g.fdmap,N=511,x=31),j==2){_=f(o,A,5)+257,$=f(o,A+5,5)+1,k=f(o,A+10,4)+4,A+=14;for(var O=0;O<38;O+=2)g.itree[O]=0,g.itree[O+1]=0;var P=1;for(O=0;O<k;O++){var F=f(o,A+3*O,3);g.itree[1+(g.ordr[O]<<1)]=F,F>P&&(P=F)}A+=3*k,l(g.itree,P),u(g.itree,P,g.imap),C=g.lmap,y=g.dmap,A=c(g.imap,(1<<P)-1,_+$,o,A,g.ttree);var M=i._copyOut(g.ttree,0,_,g.ltree);N=(1<<M)-1;var D=i._copyOut(g.ttree,_,$,g.dtree);x=(1<<D)-1,l(g.ltree,M),u(g.ltree,M,C),l(g.dtree,D),u(g.dtree,D,y)}for(;;){var S=C[p(o,A)&N];A+=15&S;var w=S>>>4;if(!(w>>>8))s[b++]=w;else{if(w==256)break;var L=b+w-254;if(w>264){var E=g.ldef[w-257];L=b+(E>>>3)+f(o,A,7&E),A+=7&E}var I=y[p(o,A)&x];A+=15&I;var W=I>>>4,T=g.ddef[W],B=(T>>>4)+h(o,A,15&T);for(A+=15&T,v&&(s=r.F._check(s,b+(1<<17)));b<L;)s[b]=s[b++-B],s[b]=s[b++-B],s[b]=s[b++-B],s[b]=s[b++-B];b=L}}}else{(7&A)!=0&&(A+=8-(7&A));var z=4+(A>>>3),U=o[z-4]|o[z-3]<<8;v&&(s=r.F._check(s,b+U)),s.set(new a(o.buffer,o.byteOffset+z,U),b),A=z+U<<3,b+=U}return s.length==b?s:s.slice(0,b)},r.F._check=function(o,s){var a=o.length;if(s<=a)return o;var i=new Uint8Array(Math.max(a<<1,s));return i.set(o,0),i},r.F._decodeTiny=function(o,s,a,i,h,f){for(var c=r.F._bitsE,l=r.F._get17,u=0;u<a;){var p=o[l(i,h)&s];h+=15&p;var g=p>>>4;if(g<=15)f[u]=g,u++;else{var v=0,C=0;g==16?(C=3+c(i,h,2),h+=2,v=f[u-1]):g==17?(C=3+c(i,h,3),h+=3):g==18&&(C=11+c(i,h,7),h+=7);for(var y=u+C;u<y;)f[u]=v,u++}}return h},r.F._copyOut=function(o,s,a,i){for(var h=0,f=0,c=i.length>>>1;f<a;){var l=o[f+s];i[f<<1]=0,i[1+(f<<1)]=l,l>h&&(h=l),f++}for(;f<c;)i[f<<1]=0,i[1+(f<<1)]=0,f++;return h},r.F.makeCodes=function(o,s){for(var a,i,h,f,c=r.F.U,l=o.length,u=c.bl_count,p=0;p<=s;p++)u[p]=0;for(p=1;p<l;p+=2)u[o[p]]++;var g=c.next_code;for(a=0,u[0]=0,i=1;i<=s;i++)a=a+u[i-1]<<1,g[i]=a;for(h=0;h<l;h+=2)(f=o[h+1])!=0&&(o[h]=g[f],g[f]++)},r.F.codes2map=function(o,s,a){for(var i=o.length,h=r.F.U.rev15,f=0;f<i;f+=2)if(o[f+1]!=0)for(var c=f>>1,l=o[f+1],u=c<<4|l,p=s-l,g=o[f]<<p,v=g+(1<<p);g!=v;)a[h[g]>>>15-s]=u,g++},r.F.revCodes=function(o,s){for(var a=r.F.U.rev15,i=15-s,h=0;h<o.length;h+=2){var f=o[h]<<s-o[h+1];o[h]=a[f]>>>i}},r.F._putsE=function(o,s,a){a<<=7&s;var i=s>>>3;o[i]|=a,o[i+1]|=a>>>8},r.F._putsF=function(o,s,a){a<<=7&s;var i=s>>>3;o[i]|=a,o[i+1]|=a>>>8,o[i+2]|=a>>>16},r.F._bitsE=function(o,s,a){return(o[s>>>3]|o[1+(s>>>3)]<<8)>>>(7&s)&(1<<a)-1},r.F._bitsF=function(o,s,a){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)&(1<<a)-1},r.F._get17=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)},r.F._get25=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16|o[3+(s>>>3)]<<24)>>>(7&s)},r.F.U=(t=Uint16Array,n=Uint32Array,{next_code:new t(16),bl_count:new t(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new t(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new n(32),flmap:new t(512),fltree:[],fdmap:new t(32),fdtree:[],lmap:new t(32768),ltree:[],ttree:[],dmap:new t(32768),dtree:[],imap:new t(512),itree:[],rev15:new t(32768),lhst:new n(286),dhst:new n(30),ihst:new n(19),lits:new n(15e3),strt:new t(65536),prev:new t(32768)}),(function(){for(var o=r.F.U,s=0;s<32768;s++){var a=s;a=(4278255360&(a=(4042322160&(a=(3435973836&(a=(2863311530&a)>>>1|(1431655765&a)<<1))>>>2|(858993459&a)<<2))>>>4|(252645135&a)<<4))>>>8|(16711935&a)<<8,o.rev15[s]=(a>>>16|a<<16)>>>17}function i(h,f,c){for(;f--!=0;)h.push(0,c)}for(s=0;s<32;s++)o.ldef[s]=o.of0[s]<<3|o.exb[s],o.ddef[s]=o.df0[s]<<4|o.dxb[s];i(o.fltree,144,8),i(o.fltree,112,9),i(o.fltree,24,7),i(o.fltree,8,8),r.F.makeCodes(o.fltree,9),r.F.codes2map(o.fltree,9,o.flmap),r.F.revCodes(o.fltree,9),i(o.fdtree,32,5),r.F.makeCodes(o.fdtree,5),r.F.codes2map(o.fdtree,5,o.fdmap),r.F.revCodes(o.fdtree,5),i(o.itree,19,0),i(o.ltree,286,0),i(o.dtree,30,0),i(o.ttree,320,0)})()})();var Kp=Hp({__proto__:null,default:Ln},[Ln]);const Pe=(function(){var e={nextZero(c,l){for(;c[l]!=0;)l++;return l},readUshort:(c,l)=>c[l]<<8|c[l+1],writeUshort(c,l,u){c[l]=u>>8&255,c[l+1]=255&u},readUint:(c,l)=>16777216*c[l]+(c[l+1]<<16|c[l+2]<<8|c[l+3]),writeUint(c,l,u){c[l]=u>>24&255,c[l+1]=u>>16&255,c[l+2]=u>>8&255,c[l+3]=255&u},readASCII(c,l,u){let p="";for(let g=0;g<u;g++)p+=String.fromCharCode(c[l+g]);return p},writeASCII(c,l,u){for(let p=0;p<u.length;p++)c[l+p]=u.charCodeAt(p)},readBytes(c,l,u){const p=[];for(let g=0;g<u;g++)p.push(c[l+g]);return p},pad:c=>c.length<2?`0${c}`:c,readUTF8(c,l,u){let p,g="";for(let v=0;v<u;v++)g+=`%${e.pad(c[l+v].toString(16))}`;try{p=decodeURIComponent(g)}catch{return e.readASCII(c,l,u)}return p}};function t(c,l,u,p){const g=l*u,v=s(p),C=Math.ceil(l*v/8),y=new Uint8Array(4*g),R=new Uint32Array(y.buffer),{ctype:j}=p,{depth:_}=p,$=e.readUshort;if(j==6){const E=g<<2;if(_==8)for(var k=0;k<E;k+=4)y[k]=c[k],y[k+1]=c[k+1],y[k+2]=c[k+2],y[k+3]=c[k+3];if(_==16)for(k=0;k<E;k++)y[k]=c[k<<1]}else if(j==2){const E=p.tabs.tRNS;if(E==null){if(_==8)for(k=0;k<g;k++){var N=3*k;R[k]=255<<24|c[N+2]<<16|c[N+1]<<8|c[N]}if(_==16)for(k=0;k<g;k++)N=6*k,R[k]=255<<24|c[N+4]<<16|c[N+2]<<8|c[N]}else{var x=E[0];const I=E[1],W=E[2];if(_==8)for(k=0;k<g;k++){var b=k<<2;N=3*k,R[k]=255<<24|c[N+2]<<16|c[N+1]<<8|c[N],c[N]==x&&c[N+1]==I&&c[N+2]==W&&(y[b+3]=0)}if(_==16)for(k=0;k<g;k++)b=k<<2,N=6*k,R[k]=255<<24|c[N+4]<<16|c[N+2]<<8|c[N],$(c,N)==x&&$(c,N+2)==I&&$(c,N+4)==W&&(y[b+3]=0)}}else if(j==3){const E=p.tabs.PLTE,I=p.tabs.tRNS,W=I?I.length:0;if(_==1)for(var A=0;A<u;A++){var O=A*C,P=A*l;for(k=0;k<l;k++){b=P+k<<2;var F=3*(M=c[O+(k>>3)]>>7-((7&k)<<0)&1);y[b]=E[F],y[b+1]=E[F+1],y[b+2]=E[F+2],y[b+3]=M<W?I[M]:255}}if(_==2)for(A=0;A<u;A++)for(O=A*C,P=A*l,k=0;k<l;k++)b=P+k<<2,F=3*(M=c[O+(k>>2)]>>6-((3&k)<<1)&3),y[b]=E[F],y[b+1]=E[F+1],y[b+2]=E[F+2],y[b+3]=M<W?I[M]:255;if(_==4)for(A=0;A<u;A++)for(O=A*C,P=A*l,k=0;k<l;k++)b=P+k<<2,F=3*(M=c[O+(k>>1)]>>4-((1&k)<<2)&15),y[b]=E[F],y[b+1]=E[F+1],y[b+2]=E[F+2],y[b+3]=M<W?I[M]:255;if(_==8)for(k=0;k<g;k++){var M;b=k<<2,F=3*(M=c[k]),y[b]=E[F],y[b+1]=E[F+1],y[b+2]=E[F+2],y[b+3]=M<W?I[M]:255}}else if(j==4){if(_==8)for(k=0;k<g;k++){b=k<<2;var D=c[S=k<<1];y[b]=D,y[b+1]=D,y[b+2]=D,y[b+3]=c[S+1]}if(_==16)for(k=0;k<g;k++){var S;b=k<<2,D=c[S=k<<2],y[b]=D,y[b+1]=D,y[b+2]=D,y[b+3]=c[S+2]}}else if(j==0)for(x=p.tabs.tRNS?p.tabs.tRNS:-1,A=0;A<u;A++){const E=A*C,I=A*l;if(_==1)for(var w=0;w<l;w++){var L=(D=255*(c[E+(w>>>3)]>>>7-(7&w)&1))==255*x?0:255;R[I+w]=L<<24|D<<16|D<<8|D}else if(_==2)for(w=0;w<l;w++)L=(D=85*(c[E+(w>>>2)]>>>6-((3&w)<<1)&3))==85*x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==4)for(w=0;w<l;w++)L=(D=17*(c[E+(w>>>1)]>>>4-((1&w)<<2)&15))==17*x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==8)for(w=0;w<l;w++)L=(D=c[E+w])==x?0:255,R[I+w]=L<<24|D<<16|D<<8|D;else if(_==16)for(w=0;w<l;w++)D=c[E+(w<<1)],L=$(c,E+(w<<1))==x?0:255,R[I+w]=L<<24|D<<16|D<<8|D}return y}function n(c,l,u,p){const g=s(c),v=Math.ceil(u*g/8),C=new Uint8Array((v+1+c.interlace)*p);return l=c.tabs.CgBI?o(l,C):r(l,C),c.interlace==0?l=a(l,c,0,u,p):c.interlace==1&&(l=(function(R,j){const _=j.width,$=j.height,k=s(j),N=k>>3,x=Math.ceil(_*k/8),b=new Uint8Array($*x);let A=0;const O=[0,0,4,0,2,0,1],P=[0,4,0,2,0,1,0],F=[8,8,8,4,4,2,2],M=[8,8,4,4,2,2,1];let D=0;for(;D<7;){const w=F[D],L=M[D];let E=0,I=0,W=O[D];for(;W<$;)W+=w,I++;let T=P[D];for(;T<_;)T+=L,E++;const B=Math.ceil(E*k/8);a(R,j,A,E,I);let z=0,U=O[D];for(;U<$;){let V=P[D],G=A+z*B<<3;for(;V<_;){var S;if(k==1&&(S=(S=R[G>>3])>>7-(7&G)&1,b[U*x+(V>>3)]|=S<<7-((7&V)<<0)),k==2&&(S=(S=R[G>>3])>>6-(7&G)&3,b[U*x+(V>>2)]|=S<<6-((3&V)<<1)),k==4&&(S=(S=R[G>>3])>>4-(7&G)&15,b[U*x+(V>>1)]|=S<<4-((1&V)<<2)),k>=8){const X=U*x+V*N;for(let K=0;K<N;K++)b[X+K]=R[(G>>3)+K]}G+=k,V+=L}z++,U+=w}E*I!=0&&(A+=I*(1+B)),D+=1}return b})(l,c)),l}function r(c,l){return o(new Uint8Array(c.buffer,2,c.length-6),l)}var o=(function(){const c={H:{}};return c.H.N=function(l,u){const p=Uint8Array;let g,v,C=0,y=0,R=0,j=0,_=0,$=0,k=0,N=0,x=0;if(l[0]==3&&l[1]==0)return u||new p(0);const b=c.H,A=b.b,O=b.e,P=b.R,F=b.n,M=b.A,D=b.Z,S=b.m,w=u==null;for(w&&(u=new p(l.length>>>2<<5));C==0;)if(C=A(l,x,1),y=A(l,x+1,2),x+=3,y!=0){if(w&&(u=c.H.W(u,N+(1<<17))),y==1&&(g=S.J,v=S.h,$=511,k=31),y==2){R=O(l,x,5)+257,j=O(l,x+5,5)+1,_=O(l,x+10,4)+4,x+=14;let E=1;for(var L=0;L<38;L+=2)S.Q[L]=0,S.Q[L+1]=0;for(L=0;L<_;L++){const T=O(l,x+3*L,3);S.Q[1+(S.X[L]<<1)]=T,T>E&&(E=T)}x+=3*_,F(S.Q,E),M(S.Q,E,S.u),g=S.w,v=S.d,x=P(S.u,(1<<E)-1,R+j,l,x,S.v);const I=b.V(S.v,0,R,S.C);$=(1<<I)-1;const W=b.V(S.v,R,j,S.D);k=(1<<W)-1,F(S.C,I),M(S.C,I,g),F(S.D,W),M(S.D,W,v)}for(;;){const E=g[D(l,x)&$];x+=15&E;const I=E>>>4;if(!(I>>>8))u[N++]=I;else{if(I==256)break;{let W=N+I-254;if(I>264){const V=S.q[I-257];W=N+(V>>>3)+O(l,x,7&V),x+=7&V}const T=v[D(l,x)&k];x+=15&T;const B=T>>>4,z=S.c[B],U=(z>>>4)+A(l,x,15&z);for(x+=15&z;N<W;)u[N]=u[N++-U],u[N]=u[N++-U],u[N]=u[N++-U],u[N]=u[N++-U];N=W}}}}else{(7&x)!=0&&(x+=8-(7&x));const E=4+(x>>>3),I=l[E-4]|l[E-3]<<8;w&&(u=c.H.W(u,N+I)),u.set(new p(l.buffer,l.byteOffset+E,I),N),x=E+I<<3,N+=I}return u.length==N?u:u.slice(0,N)},c.H.W=function(l,u){const p=l.length;if(u<=p)return l;const g=new Uint8Array(p<<1);return g.set(l,0),g},c.H.R=function(l,u,p,g,v,C){const y=c.H.e,R=c.H.Z;let j=0;for(;j<p;){const _=l[R(g,v)&u];v+=15&_;const $=_>>>4;if($<=15)C[j]=$,j++;else{let k=0,N=0;$==16?(N=3+y(g,v,2),v+=2,k=C[j-1]):$==17?(N=3+y(g,v,3),v+=3):$==18&&(N=11+y(g,v,7),v+=7);const x=j+N;for(;j<x;)C[j]=k,j++}}return v},c.H.V=function(l,u,p,g){let v=0,C=0;const y=g.length>>>1;for(;C<p;){const R=l[C+u];g[C<<1]=0,g[1+(C<<1)]=R,R>v&&(v=R),C++}for(;C<y;)g[C<<1]=0,g[1+(C<<1)]=0,C++;return v},c.H.n=function(l,u){const p=c.H.m,g=l.length;let v,C,y,R;const j=p.j;for(var _=0;_<=u;_++)j[_]=0;for(_=1;_<g;_+=2)j[l[_]]++;const $=p.K;for(v=0,j[0]=0,C=1;C<=u;C++)v=v+j[C-1]<<1,$[C]=v;for(y=0;y<g;y+=2)R=l[y+1],R!=0&&(l[y]=$[R],$[R]++)},c.H.A=function(l,u,p){const g=l.length,v=c.H.m.r;for(let C=0;C<g;C+=2)if(l[C+1]!=0){const y=C>>1,R=l[C+1],j=y<<4|R,_=u-R;let $=l[C]<<_;const k=$+(1<<_);for(;$!=k;)p[v[$]>>>15-u]=j,$++}},c.H.l=function(l,u){const p=c.H.m.r,g=15-u;for(let v=0;v<l.length;v+=2){const C=l[v]<<u-l[v+1];l[v]=p[C]>>>g}},c.H.M=function(l,u,p){p<<=7&u;const g=u>>>3;l[g]|=p,l[g+1]|=p>>>8},c.H.I=function(l,u,p){p<<=7&u;const g=u>>>3;l[g]|=p,l[g+1]|=p>>>8,l[g+2]|=p>>>16},c.H.e=function(l,u,p){return(l[u>>>3]|l[1+(u>>>3)]<<8)>>>(7&u)&(1<<p)-1},c.H.b=function(l,u,p){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16)>>>(7&u)&(1<<p)-1},c.H.Z=function(l,u){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16)>>>(7&u)},c.H.i=function(l,u){return(l[u>>>3]|l[1+(u>>>3)]<<8|l[2+(u>>>3)]<<16|l[3+(u>>>3)]<<24)>>>(7&u)},c.H.m=(function(){const l=Uint16Array,u=Uint32Array;return{K:new l(16),j:new l(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new l(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new u(32),J:new l(512),_:[],h:new l(32),$:[],w:new l(32768),C:[],v:[],d:new l(32768),D:[],u:new l(512),Q:[],r:new l(32768),s:new u(286),Y:new u(30),a:new u(19),t:new u(15e3),k:new l(65536),g:new l(32768)}})(),(function(){const l=c.H.m;for(var u=0;u<32768;u++){let g=u;g=(2863311530&g)>>>1|(1431655765&g)<<1,g=(3435973836&g)>>>2|(858993459&g)<<2,g=(4042322160&g)>>>4|(252645135&g)<<4,g=(4278255360&g)>>>8|(16711935&g)<<8,l.r[u]=(g>>>16|g<<16)>>>17}function p(g,v,C){for(;v--!=0;)g.push(0,C)}for(u=0;u<32;u++)l.q[u]=l.S[u]<<3|l.T[u],l.c[u]=l.p[u]<<4|l.z[u];p(l._,144,8),p(l._,112,9),p(l._,24,7),p(l._,8,8),c.H.n(l._,9),c.H.A(l._,9,l.J),c.H.l(l._,9),p(l.$,32,5),c.H.n(l.$,5),c.H.A(l.$,5,l.h),c.H.l(l.$,5),p(l.Q,19,0),p(l.C,286,0),p(l.D,30,0),p(l.v,320,0)})(),c.H.N})();function s(c){return[1,null,3,1,2,null,4][c.ctype]*c.depth}function a(c,l,u,p,g){let v=s(l);const C=Math.ceil(p*v/8);let y,R;v=Math.ceil(v/8);let j=c[u],_=0;if(j>1&&(c[u]=[0,0,1][j-2]),j==3)for(_=v;_<C;_++)c[_+1]=c[_+1]+(c[_+1-v]>>>1)&255;for(let $=0;$<g;$++)if(y=u+$*C,R=y+$+1,j=c[R-1],_=0,j==0)for(;_<C;_++)c[y+_]=c[R+_];else if(j==1){for(;_<v;_++)c[y+_]=c[R+_];for(;_<C;_++)c[y+_]=c[R+_]+c[y+_-v]}else if(j==2)for(;_<C;_++)c[y+_]=c[R+_]+c[y+_-C];else if(j==3){for(;_<v;_++)c[y+_]=c[R+_]+(c[y+_-C]>>>1);for(;_<C;_++)c[y+_]=c[R+_]+(c[y+_-C]+c[y+_-v]>>>1)}else{for(;_<v;_++)c[y+_]=c[R+_]+i(0,c[y+_-C],0);for(;_<C;_++)c[y+_]=c[R+_]+i(c[y+_-v],c[y+_-C],c[y+_-v-C])}return c}function i(c,l,u){const p=c+l-u,g=p-c,v=p-l,C=p-u;return g*g<=v*v&&g*g<=C*C?c:v*v<=C*C?l:u}function h(c,l,u){u.width=e.readUint(c,l),l+=4,u.height=e.readUint(c,l),l+=4,u.depth=c[l],l++,u.ctype=c[l],l++,u.compress=c[l],l++,u.filter=c[l],l++,u.interlace=c[l],l++}function f(c,l,u,p,g,v,C,y,R){const j=Math.min(l,g),_=Math.min(u,v);let $=0,k=0;for(let D=0;D<_;D++)for(let S=0;S<j;S++)if(C>=0&&y>=0?($=D*l+S<<2,k=(y+D)*g+C+S<<2):($=(-y+D)*l-C+S<<2,k=D*g+S<<2),R==0)p[k]=c[$],p[k+1]=c[$+1],p[k+2]=c[$+2],p[k+3]=c[$+3];else if(R==1){var N=c[$+3]*.00392156862745098,x=c[$]*N,b=c[$+1]*N,A=c[$+2]*N,O=p[k+3]*(1/255),P=p[k]*O,F=p[k+1]*O,M=p[k+2]*O;const w=1-N,L=N+O*w,E=L==0?0:1/L;p[k+3]=255*L,p[k+0]=(x+P*w)*E,p[k+1]=(b+F*w)*E,p[k+2]=(A+M*w)*E}else if(R==2)N=c[$+3],x=c[$],b=c[$+1],A=c[$+2],O=p[k+3],P=p[k],F=p[k+1],M=p[k+2],N==O&&x==P&&b==F&&A==M?(p[k]=0,p[k+1]=0,p[k+2]=0,p[k+3]=0):(p[k]=x,p[k+1]=b,p[k+2]=A,p[k+3]=N);else if(R==3){if(N=c[$+3],x=c[$],b=c[$+1],A=c[$+2],O=p[k+3],P=p[k],F=p[k+1],M=p[k+2],N==O&&x==P&&b==F&&A==M)continue;if(N<220&&O>20)return!1}return!0}return{decode:function(l){const u=new Uint8Array(l);let p=8;const g=e,v=g.readUshort,C=g.readUint,y={tabs:{},frames:[]},R=new Uint8Array(u.length);let j,_=0,$=0;const k=[137,80,78,71,13,10,26,10];for(var N=0;N<8;N++)if(u[N]!=k[N])throw"The input is not a PNG file!";for(;p<u.length;){const D=g.readUint(u,p);p+=4;const S=g.readASCII(u,p,4);if(p+=4,S=="IHDR")h(u,p,y);else if(S=="iCCP"){for(var x=p;u[x]!=0;)x++;g.readASCII(u,p,x-p),u[x+1];const w=u.slice(x+2,p+D);let L=null;try{L=r(w)}catch{L=o(w)}y.tabs[S]=L}else if(S=="CgBI")y.tabs[S]=u.slice(p,p+4);else if(S=="IDAT"){for(N=0;N<D;N++)R[_+N]=u[p+N];_+=D}else if(S=="acTL")y.tabs[S]={num_frames:C(u,p),num_plays:C(u,p+4)},j=new Uint8Array(u.length);else if(S=="fcTL"){$!=0&&((M=y.frames[y.frames.length-1]).data=n(y,j.slice(0,$),M.rect.width,M.rect.height),$=0);const w={x:C(u,p+12),y:C(u,p+16),width:C(u,p+4),height:C(u,p+8)};let L=v(u,p+22);L=v(u,p+20)/(L==0?100:L);const E={rect:w,delay:Math.round(1e3*L),dispose:u[p+24],blend:u[p+25]};y.frames.push(E)}else if(S=="fdAT"){for(N=0;N<D-4;N++)j[$+N]=u[p+N+4];$+=D-4}else if(S=="pHYs")y.tabs[S]=[g.readUint(u,p),g.readUint(u,p+4),u[p+8]];else if(S=="cHRM")for(y.tabs[S]=[],N=0;N<8;N++)y.tabs[S].push(g.readUint(u,p+4*N));else if(S=="tEXt"||S=="zTXt"){y.tabs[S]==null&&(y.tabs[S]={});var b=g.nextZero(u,p),A=g.readASCII(u,p,b-p),O=p+D-b-1;if(S=="tEXt")F=g.readASCII(u,b+1,O);else{var P=r(u.slice(b+2,b+2+O));F=g.readUTF8(P,0,P.length)}y.tabs[S][A]=F}else if(S=="iTXt"){y.tabs[S]==null&&(y.tabs[S]={}),b=0,x=p,b=g.nextZero(u,x),A=g.readASCII(u,x,b-x);const w=u[x=b+1];var F;u[x+1],x+=2,b=g.nextZero(u,x),g.readASCII(u,x,b-x),x=b+1,b=g.nextZero(u,x),g.readUTF8(u,x,b-x),O=D-((x=b+1)-p),w==0?F=g.readUTF8(u,x,O):(P=r(u.slice(x,x+O)),F=g.readUTF8(P,0,P.length)),y.tabs[S][A]=F}else if(S=="PLTE")y.tabs[S]=g.readBytes(u,p,D);else if(S=="hIST"){const w=y.tabs.PLTE.length/3;for(y.tabs[S]=[],N=0;N<w;N++)y.tabs[S].push(v(u,p+2*N))}else if(S=="tRNS")y.ctype==3?y.tabs[S]=g.readBytes(u,p,D):y.ctype==0?y.tabs[S]=v(u,p):y.ctype==2&&(y.tabs[S]=[v(u,p),v(u,p+2),v(u,p+4)]);else if(S=="gAMA")y.tabs[S]=g.readUint(u,p)/1e5;else if(S=="sRGB")y.tabs[S]=u[p];else if(S=="bKGD")y.ctype==0||y.ctype==4?y.tabs[S]=[v(u,p)]:y.ctype==2||y.ctype==6?y.tabs[S]=[v(u,p),v(u,p+2),v(u,p+4)]:y.ctype==3&&(y.tabs[S]=u[p]);else if(S=="IEND")break;p+=D,g.readUint(u,p),p+=4}var M;return $!=0&&((M=y.frames[y.frames.length-1]).data=n(y,j.slice(0,$),M.rect.width,M.rect.height)),y.data=n(y,R,y.width,y.height),delete y.compress,delete y.interlace,delete y.filter,y},toRGBA8:function(l){const u=l.width,p=l.height;if(l.tabs.acTL==null)return[t(l.data,u,p,l).buffer];const g=[];l.frames[0].data==null&&(l.frames[0].data=l.data);const v=u*p*4,C=new Uint8Array(v),y=new Uint8Array(v),R=new Uint8Array(v);for(let _=0;_<l.frames.length;_++){const $=l.frames[_],k=$.rect.x,N=$.rect.y,x=$.rect.width,b=$.rect.height,A=t($.data,x,b,l);if(_!=0)for(var j=0;j<v;j++)R[j]=C[j];if($.blend==0?f(A,x,b,C,u,p,k,N,0):$.blend==1&&f(A,x,b,C,u,p,k,N,1),g.push(C.buffer.slice(0)),$.dispose!=0){if($.dispose==1)f(y,x,b,C,u,p,k,N,0);else if($.dispose==2)for(j=0;j<v;j++)C[j]=R[j]}}return g},_paeth:i,_copyTile:f,_bin:e}})();(function(){const{_copyTile:e}=Pe,{_bin:t}=Pe,n=Pe._paeth;var r={table:(function(){const x=new Uint32Array(256);for(let b=0;b<256;b++){let A=b;for(let O=0;O<8;O++)1&A?A=3988292384^A>>>1:A>>>=1;x[b]=A}return x})(),update(x,b,A,O){for(let P=0;P<O;P++)x=r.table[255&(x^b[A+P])]^x>>>8;return x},crc:(x,b,A)=>4294967295^r.update(4294967295,x,b,A)};function o(x,b,A,O){b[A]+=x[0]*O>>4,b[A+1]+=x[1]*O>>4,b[A+2]+=x[2]*O>>4,b[A+3]+=x[3]*O>>4}function s(x){return Math.max(0,Math.min(255,x))}function a(x,b){const A=x[0]-b[0],O=x[1]-b[1],P=x[2]-b[2],F=x[3]-b[3];return A*A+O*O+P*P+F*F}function i(x,b,A,O,P,F,M){M==null&&(M=1);const D=O.length,S=[];for(var w=0;w<D;w++){const U=O[w];S.push([U>>>0&255,U>>>8&255,U>>>16&255,U>>>24&255])}for(w=0;w<D;w++){let U=4294967295;for(var L=0,E=0;E<D;E++){var I=a(S[w],S[E]);E!=w&&I<U&&(U=I,L=E)}}const W=new Uint32Array(P.buffer),T=new Int16Array(b*A*4),B=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(w=0;w<B.length;w++)B[w]=255*((B[w]+.5)/16-.5);for(let U=0;U<A;U++)for(let V=0;V<b;V++){var z;w=4*(U*b+V),M!=2?z=[s(x[w]+T[w]),s(x[w+1]+T[w+1]),s(x[w+2]+T[w+2]),s(x[w+3]+T[w+3])]:(I=B[4*(3&U)+(3&V)],z=[s(x[w]+I),s(x[w+1]+I),s(x[w+2]+I),s(x[w+3]+I)]),L=0;let G=16777215;for(E=0;E<D;E++){const ne=a(z,S[E]);ne<G&&(G=ne,L=E)}const X=S[L],K=[z[0]-X[0],z[1]-X[1],z[2]-X[2],z[3]-X[3]];M==1&&(V!=b-1&&o(K,T,w+4,7),U!=A-1&&(V!=0&&o(K,T,w+4*b-4,3),o(K,T,w+4*b,5),V!=b-1&&o(K,T,w+4*b+4,1))),F[w>>2]=L,W[w>>2]=O[L]}}function h(x,b,A,O,P){P==null&&(P={});const{crc:F}=r,M=t.writeUint,D=t.writeUshort,S=t.writeASCII;let w=8;const L=x.frames.length>1;let E,I=!1,W=33+(L?20:0);if(P.sRGB!=null&&(W+=13),P.pHYs!=null&&(W+=21),P.iCCP!=null&&(E=pako.deflate(P.iCCP),W+=21+E.length+4),x.ctype==3){for(var T=x.plte.length,B=0;B<T;B++)x.plte[B]>>>24!=255&&(I=!0);W+=8+3*T+4+(I?8+1*T+4:0)}for(var z=0;z<x.frames.length;z++)L&&(W+=38),W+=(X=x.frames[z]).cimg.length+12,z!=0&&(W+=4);W+=12;const U=new Uint8Array(W),V=[137,80,78,71,13,10,26,10];for(B=0;B<8;B++)U[B]=V[B];if(M(U,w,13),w+=4,S(U,w,"IHDR"),w+=4,M(U,w,b),w+=4,M(U,w,A),w+=4,U[w]=x.depth,w++,U[w]=x.ctype,w++,U[w]=0,w++,U[w]=0,w++,U[w]=0,w++,M(U,w,F(U,w-17,17)),w+=4,P.sRGB!=null&&(M(U,w,1),w+=4,S(U,w,"sRGB"),w+=4,U[w]=P.sRGB,w++,M(U,w,F(U,w-5,5)),w+=4),P.iCCP!=null){const K=13+E.length;M(U,w,K),w+=4,S(U,w,"iCCP"),w+=4,S(U,w,"ICC profile"),w+=11,w+=2,U.set(E,w),w+=E.length,M(U,w,F(U,w-(K+4),K+4)),w+=4}if(P.pHYs!=null&&(M(U,w,9),w+=4,S(U,w,"pHYs"),w+=4,M(U,w,P.pHYs[0]),w+=4,M(U,w,P.pHYs[1]),w+=4,U[w]=P.pHYs[2],w++,M(U,w,F(U,w-13,13)),w+=4),L&&(M(U,w,8),w+=4,S(U,w,"acTL"),w+=4,M(U,w,x.frames.length),w+=4,M(U,w,P.loop!=null?P.loop:0),w+=4,M(U,w,F(U,w-12,12)),w+=4),x.ctype==3){for(M(U,w,3*(T=x.plte.length)),w+=4,S(U,w,"PLTE"),w+=4,B=0;B<T;B++){const K=3*B,ne=x.plte[B],ae=255&ne,de=ne>>>8&255,me=ne>>>16&255;U[w+K+0]=ae,U[w+K+1]=de,U[w+K+2]=me}if(w+=3*T,M(U,w,F(U,w-3*T-4,3*T+4)),w+=4,I){for(M(U,w,T),w+=4,S(U,w,"tRNS"),w+=4,B=0;B<T;B++)U[w+B]=x.plte[B]>>>24&255;w+=T,M(U,w,F(U,w-T-4,T+4)),w+=4}}let G=0;for(z=0;z<x.frames.length;z++){var X=x.frames[z];L&&(M(U,w,26),w+=4,S(U,w,"fcTL"),w+=4,M(U,w,G++),w+=4,M(U,w,X.rect.width),w+=4,M(U,w,X.rect.height),w+=4,M(U,w,X.rect.x),w+=4,M(U,w,X.rect.y),w+=4,D(U,w,O[z]),w+=2,D(U,w,1e3),w+=2,U[w]=X.dispose,w++,U[w]=X.blend,w++,M(U,w,F(U,w-30,30)),w+=4);const K=X.cimg;M(U,w,(T=K.length)+(z==0?0:4)),w+=4;const ne=w;S(U,w,z==0?"IDAT":"fdAT"),w+=4,z!=0&&(M(U,w,G++),w+=4),U.set(K,w),w+=T,M(U,w,F(U,ne,w-ne)),w+=4}return M(U,w,0),w+=4,S(U,w,"IEND"),w+=4,M(U,w,F(U,w-4,4)),w+=4,U.buffer}function f(x,b,A){for(let O=0;O<x.frames.length;O++){const P=x.frames[O];P.rect.width;const F=P.rect.height,M=new Uint8Array(F*P.bpl+F);P.cimg=p(P.img,F,P.bpp,P.bpl,M,b,A)}}function c(x,b,A,O,P){const F=P[0],M=P[1],D=P[2],S=P[3],w=P[4],L=P[5];let E=6,I=8,W=255;for(var T=0;T<x.length;T++){const J=new Uint8Array(x[T]);for(var B=J.length,z=0;z<B;z+=4)W&=J[z+3]}const U=W!=255,V=(function(te,ie,oe,he,ge,_e){const xe=[];for(var fe=0;fe<te.length;fe++){const we=new Uint8Array(te[fe]),Me=new Uint32Array(we.buffer);var Ee;let Re=0,Ve=0,$e=ie,mt=oe,ir=he?1:0;if(fe!=0){const tc=_e||he||fe==1||xe[fe-2].dispose!=0?1:2;let lr=0,Do=1e9;for(let Gt=0;Gt<tc;Gt++){var Je=new Uint8Array(te[fe-1-Gt]);const nc=new Uint32Array(te[fe-1-Gt]);let et=ie,tt=oe,At=-1,Kt=-1;for(let pt=0;pt<oe;pt++)for(let gt=0;gt<ie;gt++)Me[ye=pt*ie+gt]!=nc[ye]&&(gt<et&&(et=gt),gt>At&&(At=gt),pt<tt&&(tt=pt),pt>Kt&&(Kt=pt));At==-1&&(et=tt=At=Kt=0),ge&&((1&et)==1&&et--,(1&tt)==1&&tt--);const Lo=(At-et+1)*(Kt-tt+1);Lo<Do&&(Do=Lo,lr=Gt,Re=et,Ve=tt,$e=At-et+1,mt=Kt-tt+1)}Je=new Uint8Array(te[fe-1-lr]),lr==1&&(xe[fe-1].dispose=2),Ee=new Uint8Array($e*mt*4),e(Je,ie,oe,Ee,$e,mt,-Re,-Ve,0),ir=e(we,ie,oe,Ee,$e,mt,-Re,-Ve,3)?1:0,ir==1?u(we,ie,oe,Ee,{x:Re,y:Ve,width:$e,height:mt}):e(we,ie,oe,Ee,$e,mt,-Re,-Ve,0)}else Ee=we.slice(0);xe.push({rect:{x:Re,y:Ve,width:$e,height:mt},img:Ee,blend:ir,dispose:0})}if(he)for(fe=0;fe<xe.length;fe++){if((ht=xe[fe]).blend==1)continue;const we=ht.rect,Me=xe[fe-1].rect,Re=Math.min(we.x,Me.x),Ve=Math.min(we.y,Me.y),$e={x:Re,y:Ve,width:Math.max(we.x+we.width,Me.x+Me.width)-Re,height:Math.max(we.y+we.height,Me.y+Me.height)-Ve};xe[fe-1].dispose=1,fe-1!=0&&l(te,ie,oe,xe,fe-1,$e,ge),l(te,ie,oe,xe,fe,$e,ge)}let xn=0;if(te.length!=1)for(var ye=0;ye<xe.length;ye++){var ht;xn+=(ht=xe[ye]).rect.width*ht.rect.height}return xe})(x,b,A,F,M,D),G={},X=[],K=[];if(O!=0){const J=[];for(z=0;z<V.length;z++)J.push(V[z].img.buffer);const te=(function(ge){let _e=0;for(var xe=0;xe<ge.length;xe++)_e+=ge[xe].byteLength;const fe=new Uint8Array(_e);let Ee=0;for(xe=0;xe<ge.length;xe++){const Je=new Uint8Array(ge[xe]),xn=Je.length;for(let ye=0;ye<xn;ye+=4){let ht=Je[ye],we=Je[ye+1],Me=Je[ye+2];const Re=Je[ye+3];Re==0&&(ht=we=Me=0),fe[Ee+ye]=ht,fe[Ee+ye+1]=we,fe[Ee+ye+2]=Me,fe[Ee+ye+3]=Re}Ee+=xn}return fe.buffer})(J),ie=v(te,O);for(z=0;z<ie.plte.length;z++)X.push(ie.plte[z].est.rgba);let oe=0;for(z=0;z<V.length;z++){const he=(ae=V[z]).img.length;var ne=new Uint8Array(ie.inds.buffer,oe>>2,he>>2);K.push(ne);const ge=new Uint8Array(ie.abuf,oe,he);L&&i(ae.img,ae.rect.width,ae.rect.height,X,ge,ne),ae.img.set(ge),oe+=he}}else for(T=0;T<V.length;T++){var ae=V[T];const J=new Uint32Array(ae.img.buffer);var de=ae.rect.width;for(B=J.length,ne=new Uint8Array(B),K.push(ne),z=0;z<B;z++){const te=J[z];if(z!=0&&te==J[z-1])ne[z]=ne[z-1];else if(z>de&&te==J[z-de])ne[z]=ne[z-de];else{let ie=G[te];if(ie==null&&(G[te]=ie=X.length,X.push(te),X.length>=300))break;ne[z]=ie}}}const me=X.length;for(me<=256&&w==0&&(I=me<=2?1:me<=4?2:me<=16?4:8,I=Math.max(I,S)),T=0;T<V.length;T++){(ae=V[T]).rect.x,ae.rect.y,de=ae.rect.width;const J=ae.rect.height;let te=ae.img;new Uint32Array(te.buffer);let ie=4*de,oe=4;if(me<=256&&w==0){ie=Math.ceil(I*de/8);var H=new Uint8Array(ie*J);const he=K[T];for(let ge=0;ge<J;ge++){z=ge*ie;const _e=ge*de;if(I==8)for(var q=0;q<de;q++)H[z+q]=he[_e+q];else if(I==4)for(q=0;q<de;q++)H[z+(q>>1)]|=he[_e+q]<<4-4*(1&q);else if(I==2)for(q=0;q<de;q++)H[z+(q>>2)]|=he[_e+q]<<6-2*(3&q);else if(I==1)for(q=0;q<de;q++)H[z+(q>>3)]|=he[_e+q]<<7-1*(7&q)}te=H,E=3,oe=1}else if(U==0&&V.length==1){H=new Uint8Array(de*J*3);const he=de*J;for(z=0;z<he;z++){const ge=3*z,_e=4*z;H[ge]=te[_e],H[ge+1]=te[_e+1],H[ge+2]=te[_e+2]}te=H,E=2,oe=3,ie=3*de}ae.img=te,ae.bpl=ie,ae.bpp=oe}return{ctype:E,depth:I,plte:X,frames:V}}function l(x,b,A,O,P,F,M){const D=Uint8Array,S=Uint32Array,w=new D(x[P-1]),L=new S(x[P-1]),E=P+1<x.length?new D(x[P+1]):null,I=new D(x[P]),W=new S(I.buffer);let T=b,B=A,z=-1,U=-1;for(let G=0;G<F.height;G++)for(let X=0;X<F.width;X++){const K=F.x+X,ne=F.y+G,ae=ne*b+K,de=W[ae];de==0||O[P-1].dispose==0&&L[ae]==de&&(E==null||E[4*ae+3]!=0)||(K<T&&(T=K),K>z&&(z=K),ne<B&&(B=ne),ne>U&&(U=ne))}z==-1&&(T=B=z=U=0),M&&((1&T)==1&&T--,(1&B)==1&&B--),F={x:T,y:B,width:z-T+1,height:U-B+1};const V=O[P];V.rect=F,V.blend=1,V.img=new Uint8Array(F.width*F.height*4),O[P-1].dispose==0?(e(w,b,A,V.img,F.width,F.height,-F.x,-F.y,0),u(I,b,A,V.img,F)):e(I,b,A,V.img,F.width,F.height,-F.x,-F.y,0)}function u(x,b,A,O,P){e(x,b,A,O,P.width,P.height,-P.x,-P.y,2)}function p(x,b,A,O,P,F,M){const D=[];let S,w=[0,1,2,3,4];F!=-1?w=[F]:(b*O>5e5||A==1)&&(w=[0]),M&&(S={level:0});const L=Kp;for(var E=0;E<w.length;E++){for(let T=0;T<b;T++)g(P,x,T,O,A,w[E]);D.push(L.deflate(P,S))}let I,W=1e9;for(E=0;E<D.length;E++)D[E].length<W&&(I=E,W=D[E].length);return D[I]}function g(x,b,A,O,P,F){const M=A*O;let D=M+A;if(x[D]=F,D++,F==0)if(O<500)for(var S=0;S<O;S++)x[D+S]=b[M+S];else x.set(new Uint8Array(b.buffer,M,O),D);else if(F==1){for(S=0;S<P;S++)x[D+S]=b[M+S];for(S=P;S<O;S++)x[D+S]=b[M+S]-b[M+S-P]+256&255}else if(A==0){for(S=0;S<P;S++)x[D+S]=b[M+S];if(F==2)for(S=P;S<O;S++)x[D+S]=b[M+S];if(F==3)for(S=P;S<O;S++)x[D+S]=b[M+S]-(b[M+S-P]>>1)+256&255;if(F==4)for(S=P;S<O;S++)x[D+S]=b[M+S]-n(b[M+S-P],0,0)+256&255}else{if(F==2)for(S=0;S<O;S++)x[D+S]=b[M+S]+256-b[M+S-O]&255;if(F==3){for(S=0;S<P;S++)x[D+S]=b[M+S]+256-(b[M+S-O]>>1)&255;for(S=P;S<O;S++)x[D+S]=b[M+S]+256-(b[M+S-O]+b[M+S-P]>>1)&255}if(F==4){for(S=0;S<P;S++)x[D+S]=b[M+S]+256-n(0,b[M+S-O],0)&255;for(S=P;S<O;S++)x[D+S]=b[M+S]+256-n(b[M+S-P],b[M+S-O],b[M+S-P-O])&255}}}function v(x,b){const A=new Uint8Array(x),O=A.slice(0),P=new Uint32Array(O.buffer),F=C(O,b),M=F[0],D=F[1],S=A.length,w=new Uint8Array(S>>2);let L;if(A.length<2e7)for(var E=0;E<S;E+=4)L=y(M,I=A[E]*(1/255),W=A[E+1]*(1/255),T=A[E+2]*(1/255),B=A[E+3]*(1/255)),w[E>>2]=L.ind,P[E>>2]=L.est.rgba;else for(E=0;E<S;E+=4){var I=A[E]*.00392156862745098,W=A[E+1]*(1/255),T=A[E+2]*(1/255),B=A[E+3]*(1/255);for(L=M;L.left;)L=R(L.est,I,W,T,B)<=0?L.left:L.right;w[E>>2]=L.ind,P[E>>2]=L.est.rgba}return{abuf:O.buffer,inds:w,plte:D}}function C(x,b,A){A==null&&(A=1e-4);const O=new Uint32Array(x.buffer),P={i0:0,i1:x.length,bst:null,est:null,tdst:0,left:null,right:null};P.bst=$(x,P.i0,P.i1),P.est=k(P.bst);const F=[P];for(;F.length<b;){let D=0,S=0;for(var M=0;M<F.length;M++)F[M].est.L>D&&(D=F[M].est.L,S=M);if(D<A)break;const w=F[S],L=j(x,O,w.i0,w.i1,w.est.e,w.est.eMq255);if(w.i0>=L||w.i1<=L){w.est.L=0;continue}const E={i0:w.i0,i1:L,bst:null,est:null,tdst:0,left:null,right:null};E.bst=$(x,E.i0,E.i1),E.est=k(E.bst);const I={i0:L,i1:w.i1,bst:null,est:null,tdst:0,left:null,right:null};for(I.bst={R:[],m:[],N:w.bst.N-E.bst.N},M=0;M<16;M++)I.bst.R[M]=w.bst.R[M]-E.bst.R[M];for(M=0;M<4;M++)I.bst.m[M]=w.bst.m[M]-E.bst.m[M];I.est=k(I.bst),w.left=E,w.right=I,F[S]=E,F.push(I)}for(F.sort(((D,S)=>S.bst.N-D.bst.N)),M=0;M<F.length;M++)F[M].ind=M;return[P,F]}function y(x,b,A,O,P){if(x.left==null)return x.tdst=(function(E,I,W,T,B){const z=I-E[0],U=W-E[1],V=T-E[2],G=B-E[3];return z*z+U*U+V*V+G*G})(x.est.q,b,A,O,P),x;const F=R(x.est,b,A,O,P);let M=x.left,D=x.right;F>0&&(M=x.right,D=x.left);const S=y(M,b,A,O,P);if(S.tdst<=F*F)return S;const w=y(D,b,A,O,P);return w.tdst<S.tdst?w:S}function R(x,b,A,O,P){const{e:F}=x;return F[0]*b+F[1]*A+F[2]*O+F[3]*P-x.eMq}function j(x,b,A,O,P,F){for(O-=4;A<O;){for(;_(x,A,P)<=F;)A+=4;for(;_(x,O,P)>F;)O-=4;if(A>=O)break;const M=b[A>>2];b[A>>2]=b[O>>2],b[O>>2]=M,A+=4,O-=4}for(;_(x,A,P)>F;)A-=4;return A+4}function _(x,b,A){return x[b]*A[0]+x[b+1]*A[1]+x[b+2]*A[2]+x[b+3]*A[3]}function $(x,b,A){const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],P=[0,0,0,0],F=A-b>>2;for(let M=b;M<A;M+=4){const D=x[M]*.00392156862745098,S=x[M+1]*(1/255),w=x[M+2]*(1/255),L=x[M+3]*(1/255);P[0]+=D,P[1]+=S,P[2]+=w,P[3]+=L,O[0]+=D*D,O[1]+=D*S,O[2]+=D*w,O[3]+=D*L,O[5]+=S*S,O[6]+=S*w,O[7]+=S*L,O[10]+=w*w,O[11]+=w*L,O[15]+=L*L}return O[4]=O[1],O[8]=O[2],O[9]=O[6],O[12]=O[3],O[13]=O[7],O[14]=O[11],{R:O,m:P,N:F}}function k(x){const{R:b}=x,{m:A}=x,{N:O}=x,P=A[0],F=A[1],M=A[2],D=A[3],S=O==0?0:1/O,w=[b[0]-P*P*S,b[1]-P*F*S,b[2]-P*M*S,b[3]-P*D*S,b[4]-F*P*S,b[5]-F*F*S,b[6]-F*M*S,b[7]-F*D*S,b[8]-M*P*S,b[9]-M*F*S,b[10]-M*M*S,b[11]-M*D*S,b[12]-D*P*S,b[13]-D*F*S,b[14]-D*M*S,b[15]-D*D*S],L=w,E=N;let I=[Math.random(),Math.random(),Math.random(),Math.random()],W=0,T=0;if(O!=0)for(let z=0;z<16&&(I=E.multVec(L,I),T=Math.sqrt(E.dot(I,I)),I=E.sml(1/T,I),!(z!=0&&Math.abs(T-W)<1e-9));z++)W=T;const B=[P*S,F*S,M*S,D*S];return{Cov:w,q:B,e:I,L:W,eMq255:E.dot(E.sml(255,B),I),eMq:E.dot(I,B),rgba:(Math.round(255*B[3])<<24|Math.round(255*B[2])<<16|Math.round(255*B[1])<<8|Math.round(255*B[0])<<0)>>>0}}var N={multVec:(x,b)=>[x[0]*b[0]+x[1]*b[1]+x[2]*b[2]+x[3]*b[3],x[4]*b[0]+x[5]*b[1]+x[6]*b[2]+x[7]*b[3],x[8]*b[0]+x[9]*b[1]+x[10]*b[2]+x[11]*b[3],x[12]*b[0]+x[13]*b[1]+x[14]*b[2]+x[15]*b[3]],dot:(x,b)=>x[0]*b[0]+x[1]*b[1]+x[2]*b[2]+x[3]*b[3],sml:(x,b)=>[x*b[0],x*b[1],x*b[2],x*b[3]]};Pe.encode=function(b,A,O,P,F,M,D){P==null&&(P=0),D==null&&(D=!1);const S=c(b,A,O,P,[!1,!1,!1,0,D,!1]);return f(S,-1),h(S,A,O,F,M)},Pe.encodeLL=function(b,A,O,P,F,M,D,S){const w={ctype:0+(P==1?0:2)+(F==0?0:4),depth:M,frames:[]},L=(P+F)*M,E=L*A;for(let I=0;I<b.length;I++)w.frames.push({rect:{x:0,y:0,width:A,height:O},img:new Uint8Array(b[I]),blend:0,dispose:1,bpp:Math.ceil(L/8),bpl:Math.ceil(E/8)});return f(w,0,!0),h(w,A,O,D,S)},Pe.encode.compress=c,Pe.encode.dither=i,Pe.quantize=v,Pe.quantize.getKDtree=C,Pe.quantize.getNearest=y})();const Zi={toArrayBuffer(e,t){const n=e.width,r=e.height,o=n<<2,s=e.getContext("2d").getImageData(0,0,n,r),a=new Uint32Array(s.data.buffer),i=(32*n+31)/32<<2,h=i*r,f=122+h,c=new ArrayBuffer(f),l=new DataView(c),u=1<<20;let p,g,v,C,y=u,R=0,j=0,_=0;function $(x){l.setUint16(j,x,!0),j+=2}function k(x){l.setUint32(j,x,!0),j+=4}function N(x){j+=x}$(19778),k(f),N(4),k(122),k(108),k(n),k(-r>>>0),$(1),$(32),k(3),k(h),k(2835),k(2835),N(8),k(16711680),k(65280),k(255),k(4278190080),k(1466527264),(function x(){for(;R<r&&y>0;){for(C=122+R*i,p=0;p<o;)y--,g=a[_++],v=g>>>24,l.setUint32(C+p,g<<8|v),p+=4;R++}_<a.length?(y=u,setTimeout(x,Zi._dly)):t(c)})()},toBlob(e,t){this.toArrayBuffer(e,(n=>{t(new Blob([n],{type:"image/bmp"}))}))},_dly:9};var ke={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},qp={[ke.CHROME]:16384,[ke.FIREFOX]:11180,[ke.DESKTOP_SAFARI]:16384,[ke.IE]:8192,[ke.IOS]:4096,[ke.ETC]:8192};const _o=typeof window<"u",Ji=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,$n=_o&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),Yp=(_o||Ji)&&($n&&$n.getOriginalSymbol(window,"File")||typeof File<"u"&&File),el=(_o||Ji)&&($n&&$n.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function Eo(e,t,n=Date.now()){return new Promise((r=>{const o=e.split(","),s=o[0].match(/:(.*?);/)[1],a=globalThis.atob(o[1]);let i=a.length;const h=new Uint8Array(i);for(;i--;)h[i]=a.charCodeAt(i);const f=new Blob([h],{type:s});f.name=t,f.lastModified=n,r(f)}))}function tl(e){return new Promise(((t,n)=>{const r=new el;r.onload=()=>t(r.result),r.onerror=o=>n(o),r.readAsDataURL(e)}))}function nl(e){return new Promise(((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=o=>n(o),r.src=e}))}function bt(){if(bt.cachedResult!==void 0)return bt.cachedResult;let e=ke.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=ke.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=ke.IOS:/Safari/i.test(t)?e=ke.DESKTOP_SAFARI:/Firefox/i.test(t)?e=ke.FIREFOX:(/MSIE/i.test(t)||document.documentMode)&&(e=ke.IE),bt.cachedResult=e,bt.cachedResult}function rl(e,t){const n=bt(),r=qp[n];let o=e,s=t,a=o*s;const i=o>s?s/o:o/s;for(;a>r*r;){const h=(r+o)/2,f=(r+s)/2;h<f?(s=f,o=f*i):(s=h*i,o=h),a=o*s}return{width:o,height:s}}function er(e,t){let n,r;try{if(n=new OffscreenCanvas(e,t),r=n.getContext("2d"),r===null)throw new Error("getContext of OffscreenCanvas returns null")}catch{n=document.createElement("canvas"),r=n.getContext("2d")}return n.width=e,n.height=t,[n,r]}function ol(e,t){const{width:n,height:r}=rl(e.width,e.height),[o,s]=er(n,r);return t&&/jpe?g/.test(t)&&(s.fillStyle="white",s.fillRect(0,0,o.width,o.height)),s.drawImage(e,0,0,o.width,o.height),o}function En(){return En.cachedResult!==void 0||(En.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&typeof document<"u"&&"ontouchend"in document),En.cachedResult}function Fn(e,t={}){return new Promise((function(n,r){let o,s;var a=function(){try{return s=ol(o,t.fileType||e.type),n([o,s])}catch(h){return r(h)}},i=function(h){try{var f=function(c){try{throw c}catch(l){return r(l)}};try{let c;return tl(e).then((function(l){try{return c=l,nl(c).then((function(u){try{return o=u,(function(){try{return a()}catch(p){return r(p)}})()}catch(p){return f(p)}}),f)}catch(u){return f(u)}}),f)}catch(c){f(c)}}catch(c){return r(c)}};try{if(En()||[ke.DESKTOP_SAFARI,ke.MOBILE_SAFARI].includes(bt()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then((function(h){try{return o=h,a()}catch{return i()}}),i)}catch{i()}}))}function Un(e,t,n,r,o=1){return new Promise((function(s,a){let i;if(t==="image/png"){let f,c,l;return f=e.getContext("2d"),{data:c}=f.getImageData(0,0,e.width,e.height),l=Pe.encode([c.buffer],e.width,e.height,4096*o),i=new Blob([l],{type:t}),i.name=n,i.lastModified=r,h.call(this)}{let f=function(){return h.call(this)};if(t==="image/bmp")return new Promise((c=>Zi.toBlob(e,c))).then((function(c){try{return i=c,i.name=n,i.lastModified=r,f.call(this)}catch(l){return a(l)}}).bind(this),a);{let c=function(){return f.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:o}).then((function(l){try{return i=l,i.name=n,i.lastModified=r,c.call(this)}catch(u){return a(u)}}).bind(this),a);{let l;return l=e.toDataURL(t,o),Eo(l,n,r).then((function(u){try{return i=u,c.call(this)}catch(p){return a(p)}}).bind(this),a)}}}function h(){return s(i)}}))}function Ue(e){e.width=0,e.height=0}function Mt(){return new Promise((function(e,t){let n,r,o,s;return Mt.cachedResult!==void 0?e(Mt.cachedResult):Eo("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(a){try{return n=a,Fn(n).then((function(i){try{return r=i[1],Un(r,n.type,n.name,n.lastModified).then((function(h){try{return o=h,Ue(r),Fn(o).then((function(f){try{return s=f[0],Mt.cachedResult=s.width===1&&s.height===2,e(Mt.cachedResult)}catch(c){return t(c)}}),t)}catch(f){return t(f)}}),t)}catch(h){return t(h)}}),t)}catch(i){return t(i)}}),t)}))}function sl(e){return new Promise(((t,n)=>{const r=new el;r.onload=o=>{const s=new DataView(o.target.result);if(s.getUint16(0,!1)!=65496)return t(-2);const a=s.byteLength;let i=2;for(;i<a;){if(s.getUint16(i+2,!1)<=8)return t(-1);const h=s.getUint16(i,!1);if(i+=2,h==65505){if(s.getUint32(i+=2,!1)!=1165519206)return t(-1);const f=s.getUint16(i+=6,!1)==18761;i+=s.getUint32(i+4,f);const c=s.getUint16(i,f);i+=2;for(let l=0;l<c;l++)if(s.getUint16(i+12*l,f)==274)return t(s.getUint16(i+12*l+8,f))}else{if((65280&h)!=65280)break;i+=s.getUint16(i,!1)}}return t(-1)},r.onerror=o=>n(o),r.readAsArrayBuffer(e)}))}function al(e,t){const{width:n}=e,{height:r}=e,{maxWidthOrHeight:o}=t;let s,a=e;return isFinite(o)&&(n>o||r>o)&&([a,s]=er(n,r),n>r?(a.width=o,a.height=r/n*o):(a.width=n/r*o,a.height=o),s.drawImage(e,0,0,a.width,a.height),Ue(e)),a}function il(e,t){const{width:n}=e,{height:r}=e,[o,s]=er(n,r);switch(t>4&&t<9?(o.width=r,o.height=n):(o.width=n,o.height=r),t){case 2:s.transform(-1,0,0,1,n,0);break;case 3:s.transform(-1,0,0,-1,n,r);break;case 4:s.transform(1,0,0,-1,0,r);break;case 5:s.transform(0,1,1,0,0,0);break;case 6:s.transform(0,1,-1,0,r,0);break;case 7:s.transform(0,-1,-1,0,r,n);break;case 8:s.transform(0,-1,1,0,0,n)}return s.drawImage(e,0,0,n,r),Ue(e),o}function bs(e,t,n=0){return new Promise((function(r,o){let s,a,i,h,f,c,l,u,p,g,v,C,y,R,j,_,$,k,N,x;function b(O=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;s+=O,t.onProgress(Math.min(s,100))}function A(O){if(t.signal&&t.signal.aborted)throw t.signal.reason;s=Math.min(Math.max(O,s),100),t.onProgress(s)}return s=n,a=t.maxIteration||10,i=1024*t.maxSizeMB*1024,b(),Fn(e,t).then((function(O){try{return[,h]=O,b(),f=al(h,t),b(),new Promise((function(P,F){var M;if(!(M=t.exifOrientation))return sl(e).then((function(S){try{return M=S,D.call(this)}catch(w){return F(w)}}).bind(this),F);function D(){return P(M)}return D.call(this)})).then((function(P){try{return c=P,b(),Mt().then((function(F){try{return l=F?f:il(f,c),b(),u=t.initialQuality||1,p=t.fileType||e.type,Un(l,p,e.name,e.lastModified,u).then((function(M){try{{let S=function(){if(a--&&(j>i||j>y)){let L,E;return L=x?.95*N.width:N.width,E=x?.95*N.height:N.height,[$,k]=er(L,E),k.drawImage(N,0,0,L,E),u*=p==="image/png"?.85:.95,Un($,p,e.name,e.lastModified,u).then((function(I){try{return _=I,Ue(N),N=$,j=_.size,A(Math.min(99,Math.floor((R-j)/(R-i)*100))),S}catch(W){return o(W)}}),o)}return[1]},w=function(){return Ue(N),Ue($),Ue(f),Ue(l),Ue(h),A(100),r(_)};if(g=M,b(),v=g.size>i,C=g.size>e.size,!v&&!C)return A(100),r(g);var D;return y=e.size,R=g.size,j=R,N=l,x=!t.alwaysKeepResolution&&v,(D=(function(L){for(;L;){if(L.then)return void L.then(D,o);try{if(L.pop){if(L.length)return L.pop()?w.call(this):L;L=S}else L=L.call(this)}catch(E){return o(E)}}}).bind(this))(S)}}catch(S){return o(S)}}).bind(this),o)}catch(M){return o(M)}}).bind(this),o)}catch(F){return o(F)}}).bind(this),o)}catch(P){return o(P)}}).bind(this),o)}))}const Xp=`
232
232
  let scriptImported = false
233
233
  self.addEventListener('message', async (e) => {
234
234
  const { file, id, imageCompressionLibUrl, options } = e.data
@@ -247,18 +247,18 @@ self.addEventListener('message', async (e) => {
247
247
  self.postMessage({ error: e.message + '\\n' + e.stack, id })
248
248
  }
249
249
  })
250
- `;let vr;function Xp(e,t){return new Promise(((n,r)=>{vr||(vr=(function(a){const i=[];return i.push(a),URL.createObjectURL(new Blob(i))})(Yp));const o=new Worker(vr);o.addEventListener("message",(function(a){if(t.signal&&t.signal.aborted)o.terminate();else if(a.data.progress===void 0){if(a.data.error)return r(new Error(a.data.error)),void o.terminate();n(a.data.file),o.terminate()}else t.onProgress(a.data.progress)})),o.addEventListener("error",r),t.signal&&t.signal.addEventListener("abort",(()=>{r(t.signal.reason),o.terminate()})),o.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})}))}function ye(e,t){return new Promise((function(n,r){let o,s,a,i,h,f;if(o={...t},a=0,{onProgress:i}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,h=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=p=>{a=p,typeof i=="function"&&i(a)},!(e instanceof Blob||e instanceof qp))return r(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return r(new Error("The file given is not an image"));if(f=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!h||typeof Worker!="function"||f)return ys(e,o).then((function(p){try{return s=p,u.call(this)}catch(g){return r(g)}}).bind(this),r);var c=(function(){try{return u.call(this)}catch(p){return r(p)}}).bind(this),l=function(p){try{return ys(e,o).then((function(g){try{return s=g,c()}catch(v){return r(v)}}),r)}catch(g){return r(g)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Xp(e,o).then((function(p){try{return s=p,c()}catch{return l()}}),l)}catch{l()}function u(){try{s.name=e.name,s.lastModified=e.lastModified}catch{}try{o.preserveExif&&e.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===e.type)&&(s=Qi(e,s))}catch{}return n(s)}}))}ye.getDataUrlFromFile=tl,ye.getFilefromDataUrl=Eo,ye.loadImage=nl,ye.drawImageInCanvas=ol,ye.drawFileInCanvas=Fn,ye.canvasToFile=Un,ye.getExifOrientation=sl,ye.handleMaxWidthOrHeight=al,ye.followExifOrientation=il,ye.cleanupCanvasMemory=Ue,ye.isAutoOrientationInBrowser=Mt,ye.approximateBelowMaximumCanvasSizeOfBrowser=rl,ye.copyExifWithoutOrientation=Qi,ye.getBrowserName=yt,ye.version="2.0.2";var Qp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ut=Qp.reduce((e,t)=>{const n=ua(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,h=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Zp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Jp="VisuallyHidden",ll=m.forwardRef((e,t)=>d.jsx(ue.span,{...e,ref:t,style:{...Zp,...e.style}}));ll.displayName=Jp;var eg=ll,[tr]=Qe("Tooltip",[Ht]),nr=Ht(),cl="TooltipProvider",tg=700,Ur="tooltip.open",[ng,No]=tr(cl),dl=e=>{const{__scopeTooltip:t,delayDuration:n=tg,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=m.useRef(!0),i=m.useRef(!1),h=m.useRef(0);return m.useEffect(()=>{const f=h.current;return()=>window.clearTimeout(f)},[]),d.jsx(ng,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(h.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:i,onPointerInTransitChange:m.useCallback(f=>{i.current=f},[]),disableHoverableContent:o,children:s})};dl.displayName=cl;var nn="Tooltip",[rg,mn]=tr(nn),ul=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:i}=e,h=No(nn,e.__scopeTooltip),f=nr(t),[c,l]=m.useState(null),u=Ce(),p=m.useRef(0),g=a??h.disableHoverableContent,v=i??h.delayDuration,C=m.useRef(!1),[b,R]=at({prop:r,defaultProp:o??!1,onChange:N=>{N?(h.onOpen(),document.dispatchEvent(new CustomEvent(Ur))):h.onClose(),s==null||s(N)},caller:nn}),j=m.useMemo(()=>b?C.current?"delayed-open":"instant-open":"closed",[b]),_=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,C.current=!1,R(!0)},[R]),$=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,R(!1)},[R]),k=m.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{C.current=!0,R(!0),p.current=0},v)},[v,R]);return m.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),d.jsx(lo,{...f,children:d.jsx(rg,{scope:t,contentId:u,open:b,stateAttribute:j,trigger:c,onTriggerChange:l,onTriggerEnter:m.useCallback(()=>{h.isOpenDelayedRef.current?k():_()},[h.isOpenDelayedRef,k,_]),onTriggerLeave:m.useCallback(()=>{g?$():(window.clearTimeout(p.current),p.current=0)},[$,g]),onOpen:_,onClose:$,disableHoverableContent:g,children:n})})};ul.displayName=nn;var zr="TooltipTrigger",fl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mn(zr,n),s=No(zr,n),a=nr(n),i=m.useRef(null),h=pe(t,i,o.onTriggerChange),f=m.useRef(!1),c=m.useRef(!1),l=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",l),[l]),d.jsx(qn,{asChild:!0,...a,children:d.jsx(ue.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:h,onPointerMove:ee(e.onPointerMove,u=>{u.pointerType!=="touch"&&!c.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),c.current=!0)}),onPointerLeave:ee(e.onPointerLeave,()=>{o.onTriggerLeave(),c.current=!1}),onPointerDown:ee(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",l,{once:!0})}),onFocus:ee(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:ee(e.onBlur,o.onClose),onClick:ee(e.onClick,o.onClose)})})});fl.displayName=zr;var jo="TooltipPortal",[og,sg]=tr(jo,{forceMount:void 0}),hl=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=mn(jo,t);return d.jsx(og,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};hl.displayName=jo;var Ft="TooltipContent",ml=m.forwardRef((e,t)=>{const n=sg(Ft,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=mn(Ft,e.__scopeTooltip);return d.jsx(Ae,{present:r||a.open,children:a.disableHoverableContent?d.jsx(pl,{side:o,...s,ref:t}):d.jsx(ag,{side:o,...s,ref:t})})}),ag=m.forwardRef((e,t)=>{const n=mn(Ft,e.__scopeTooltip),r=No(Ft,e.__scopeTooltip),o=m.useRef(null),s=pe(t,o),[a,i]=m.useState(null),{trigger:h,onClose:f}=n,c=o.current,{onPointerInTransitChange:l}=r,u=m.useCallback(()=>{i(null),l(!1)},[l]),p=m.useCallback((g,v)=>{const C=g.currentTarget,b={x:g.clientX,y:g.clientY},R=dg(b,C.getBoundingClientRect()),j=ug(b,R),_=fg(v.getBoundingClientRect()),$=mg([...j,..._]);i($),l(!0)},[l]);return m.useEffect(()=>()=>u(),[u]),m.useEffect(()=>{if(h&&c){const g=C=>p(C,c),v=C=>p(C,h);return h.addEventListener("pointerleave",g),c.addEventListener("pointerleave",v),()=>{h.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",v)}}},[h,c,p,u]),m.useEffect(()=>{if(a){const g=v=>{const C=v.target,b={x:v.clientX,y:v.clientY},R=(h==null?void 0:h.contains(C))||(c==null?void 0:c.contains(C)),j=!hg(b,a);R?u():j&&(u(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[h,c,a,f,u]),d.jsx(pl,{...e,ref:s})}),[ig,lg]=tr(nn,{isInside:!1}),cg=Ou("TooltipContent"),pl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...i}=e,h=mn(Ft,n),f=nr(n),{onClose:c}=h;return m.useEffect(()=>(document.addEventListener(Ur,c),()=>document.removeEventListener(Ur,c)),[c]),m.useEffect(()=>{if(h.trigger){const l=u=>{const p=u.target;p!=null&&p.contains(h.trigger)&&c()};return window.addEventListener("scroll",l,{capture:!0}),()=>window.removeEventListener("scroll",l,{capture:!0})}},[h.trigger,c]),d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:l=>l.preventDefault(),onDismiss:c,children:d.jsxs(co,{"data-state":h.stateAttribute,...f,...i,ref:t,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(cg,{children:r}),d.jsx(ig,{scope:n,isInside:!0,children:d.jsx(eg,{id:h.contentId,role:"tooltip",children:o||r})})]})})});ml.displayName=Ft;var gl="TooltipArrow",xl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=nr(n);return lg(gl,n).isInside?null:d.jsx(uo,{...o,...r,ref:t})});xl.displayName=gl;function dg(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function ug(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fg(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function hg(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],h=t[a],f=i.x,c=i.y,l=h.x,u=h.y;c>r!=u>r&&n<(l-f)*(r-c)/(u-c)+f&&(o=!o)}return o}function mg(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),pg(t)}function pg(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gg=dl,xg=ul,vg=fl,yg=hl,bg=ml,wg=xl;function Cg({delayDuration:e=0,...t}){return d.jsx(gg,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Sg({...e}){return d.jsx(Cg,{children:d.jsx(xg,{"data-slot":"tooltip",...e})})}function kg({...e}){return d.jsx(vg,{"data-slot":"tooltip-trigger",...e})}function _g({className:e,sideOffset:t=0,children:n,...r}){return d.jsx(yg,{children:d.jsxs(bg,{"data-slot":"tooltip-content",sideOffset:t,className:Z("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,d.jsx(wg,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Eg=m.lazy(()=>on(()=>import("./mermaid-VLURNSYL-kyqcLTJM.js").then(e=>e.i),__vite__mapDeps([0,1,2])).then(e=>({default:e.Streamdown})));m.createContext(null);const Ao=m.memo(({className:e,children:t,...n})=>d.jsx(m.Suspense,{fallback:d.jsx("div",{className:Z("whitespace-pre-wrap break-words",e),children:t}),children:d.jsx(Eg,{className:Z("size-full break-words [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...n,children:t})}),(e,t)=>e.children===t.children);Ao.displayName="MessageResponse";var rr="Collapsible",[Ng]=Qe(rr),[jg,Ro]=Ng(rr),vl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...i}=e,[h,f]=at({prop:r,defaultProp:o??!1,onChange:a,caller:rr});return d.jsx(jg,{scope:n,disabled:s,contentId:Ce(),open:h,onOpenToggle:m.useCallback(()=>f(c=>!c),[f]),children:d.jsx(ue.div,{"data-state":Io(h),"data-disabled":s?"":void 0,...i,ref:t})})});vl.displayName=rr;var yl="CollapsibleTrigger",bl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ro(yl,n);return d.jsx(ue.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Io(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ee(e.onClick,o.onOpenToggle)})});bl.displayName=yl;var To="CollapsibleContent",wl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ro(To,e.__scopeCollapsible);return d.jsx(Ae,{present:n||o.open,children:({present:s})=>d.jsx(Ag,{...r,ref:t,present:s})})});wl.displayName=To;var Ag=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=Ro(To,n),[i,h]=m.useState(r),f=m.useRef(null),c=pe(t,f),l=m.useRef(0),u=l.current,p=m.useRef(0),g=p.current,v=a.open||i,C=m.useRef(v),b=m.useRef(void 0);return m.useEffect(()=>{const R=requestAnimationFrame(()=>C.current=!1);return()=>cancelAnimationFrame(R)},[]),Ke(()=>{const R=f.current;if(R){b.current=b.current||{transitionDuration:R.style.transitionDuration,animationName:R.style.animationName},R.style.transitionDuration="0s",R.style.animationName="none";const j=R.getBoundingClientRect();l.current=j.height,p.current=j.width,C.current||(R.style.transitionDuration=b.current.transitionDuration,R.style.animationName=b.current.animationName),h(r)}},[a.open,r]),d.jsx(ue.div,{"data-state":Io(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!v,...s,ref:c,style:{"--radix-collapsible-content-height":u?`${u}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:v&&o})});function Io(e){return e?"open":"closed"}var Rg=vl;function Tg({...e}){return d.jsx(Rg,{"data-slot":"collapsible",...e})}function Ig({...e}){return d.jsx(bl,{"data-slot":"collapsible-trigger",...e})}function Mg({...e}){return d.jsx(wl,{"data-slot":"collapsible-content",...e})}const Pg=({children:e,as:t="p",className:n,duration:r=2})=>{const o=lc.create(t);return d.jsx(o,{animate:{opacity:[.5,1,.5]},className:Z("relative inline-block text-muted-foreground",n),transition:{repeat:Number.POSITIVE_INFINITY,duration:r,ease:"easeInOut"},children:e})},Og=m.memo(Pg),Cl=m.createContext(null),Dg=()=>{const e=m.useContext(Cl);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Lg=1e3,$g=1e3,Sl=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:o,duration:s,children:a,...i})=>{const[h,f]=at({prop:n,defaultProp:r,onChange:o}),[c,l]=at({prop:s,defaultProp:void 0}),[u,p]=m.useState(!1),[g,v]=m.useState(null);m.useEffect(()=>{t?g===null&&v(Date.now()):g!==null&&(l(Math.ceil((Date.now()-g)/$g)),v(null))},[t,g,l]);const C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;m.useEffect(()=>{if(!C&&r&&!t&&h&&!u){const R=setTimeout(()=>{f(!1),p(!0)},Lg);return()=>clearTimeout(R)}},[t,h,r,f,u,C]);const b=R=>{f(R)};return d.jsx(Cl.Provider,{value:{isStreaming:t,isOpen:h??!1,setIsOpen:f,duration:c},children:d.jsx(Tg,{className:Z("not-prose mb-4",e),onOpenChange:b,open:h,...i,children:a})})}),Fg=(e,t)=>e||t===0?d.jsx(Og,{duration:1,children:"Thinking..."}):t===void 0?d.jsx("p",{children:"Thought for a few seconds"}):d.jsxs("p",{children:["Thought for ",t," seconds"]}),kl=m.memo(({className:e,children:t,getThinkingMessage:n=Fg,...r})=>{const{isStreaming:o,isOpen:s,duration:a}=Dg();return d.jsx(Ig,{className:Z("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...r,children:t??d.jsxs(d.Fragment,{children:[d.jsx(ud,{className:"size-4"}),n(o,a),d.jsx(sn,{className:Z("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),_l=m.memo(({className:e,children:t,...n})=>d.jsx(Mg,{className:Z("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t}));Sl.displayName="Reasoning";kl.displayName="ReasoningTrigger";_l.displayName="ReasoningContent";const yr=200;function Ug({entry:e}){const[t,n]=m.useState(!1),[r,o]=m.useState(!1),s=m.useRef(null),a=m.useCallback(()=>{const i=s.current;i&&o(i.scrollHeight>yr+4)},[]);return m.useEffect(()=>{a()},[a,e.content]),d.jsx("div",{className:"flex justify-end",children:d.jsxs("div",{className:"max-w-[85%] sm:max-w-[70%]",children:[e.images&&e.images.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 mb-2 justify-end",children:e.images.map((i,h)=>d.jsx(Bg,{image:i},h))}),e.attachments&&e.attachments.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 mb-2 justify-end",children:e.attachments.map((i,h)=>d.jsx(Wg,{attachment:i},h))}),e.content&&d.jsxs("div",{className:"relative rounded-2xl rounded-br-md bg-user-bubble border border-user-bubble-border overflow-hidden",children:[d.jsx("div",{ref:s,className:Z("px-5 py-3 text-sm text-text-primary whitespace-pre-wrap font-display leading-relaxed",!t&&r&&`max-h-[${yr}px]`),style:!t&&r?{maxHeight:`${yr}px`}:void 0,children:ed(e.content)}),!t&&r&&d.jsx("div",{className:"absolute bottom-0 inset-x-0 flex flex-col items-center pt-8 bg-gradient-to-t from-user-bubble via-user-bubble/80 to-transparent",children:d.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex items-center gap-1 px-3 py-1 rounded-full text-xs font-display font-medium text-text-secondary hover:bg-brand/10 transition-colors",children:[d.jsx("span",{children:"展开"}),d.jsx(sn,{className:"h-3 w-3"})]})})]})]})})}function zg({entry:e,isStreaming:t}){return d.jsxs("div",{className:"flex gap-4 items-start",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 mt-0.5 overflow-hidden",children:d.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:28,height:28,className:"object-contain",draggable:!1})}),d.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[d.jsx("span",{className:"text-sm font-semibold text-text-primary font-display",children:"Saluzi"}),e.chunks.map((n,r)=>{if(n.type==="thought"){const o=r===e.chunks.length-1,s=t&&o;return d.jsxs(Sl,{isStreaming:s,children:[d.jsx(kl,{}),d.jsx(_l,{children:d.jsx("div",{className:"text-sm text-text-secondary leading-relaxed",children:n.text})})]},r)}return d.jsx("div",{className:"message-content text-text-primary leading-[1.75]",children:d.jsx(Ao,{children:n.text})},r)})]})]})}function Bg({image:e}){const t=`data:${e.mimeType};base64,${e.data}`;return d.jsx("button",{type:"button",className:"rounded-lg overflow-hidden border border-border hover:border-brand/40 transition-colors cursor-pointer",onClick:()=>{const n=window.open("");n&&n.document.write(`<img src="${t}" style="max-width:100%;max-height:100%" />`)},children:d.jsx("img",{src:t,alt:"Uploaded image",className:"h-20 w-20 object-cover"})})}function Wg({attachment:e}){const[t,n]=m.useState(!1),r=(()=>{switch(e.kind){case"text":return d.jsx(Zt,{className:"h-4 w-4"});case"table":return d.jsx(Zr,{className:"h-4 w-4"});case"directory":return d.jsx(Xr,{className:"h-4 w-4"});default:return d.jsx(Zt,{className:"h-4 w-4"})}})(),o=e.size!=null?Hg(e.size):null,s=e.kind==="directory"&&e.files?e.files.length:null,a=!!e.textContent;return d.jsxs("div",{className:"min-w-[160px] max-w-[300px]",children:[d.jsxs("button",{type:"button",onClick:()=>a&&n(i=>!i),className:Z("w-full flex items-center gap-2 rounded-lg border border-border bg-surface-1/50 px-3 py-2 text-xs text-text-secondary",a?"hover:border-brand/40 hover:bg-surface-1 cursor-pointer":"cursor-default"),children:[r,d.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[d.jsx("div",{className:"truncate font-mono text-text-primary",title:e.name,children:e.name}),d.jsxs("div",{className:"text-[10px] text-text-muted",children:[o&&d.jsx("span",{children:o}),o&&s!=null&&d.jsx("span",{children:" · "}),s!=null&&d.jsxs("span",{children:[s," 个文件"]})]})]}),a&&d.jsx(sn,{className:Z("h-3.5 w-3.5 flex-shrink-0 transition-transform",t&&"rotate-180")})]}),t&&a&&d.jsx("div",{className:"mt-1 rounded-lg border border-border bg-surface-2 p-3 max-h-[300px] overflow-auto",children:d.jsx("pre",{className:"text-[11px] text-text-secondary font-mono whitespace-pre-wrap break-words",children:e.textContent})})]})}function Hg(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Vg(e){switch(e){case"allow_once":case"allow_always":return"default";case"reject_once":case"reject_always":return"destructive";default:return"outline"}}function Gg(e){switch(e){case"allow_once":case"allow_always":return d.jsx(wt,{className:"size-4"});case"reject_once":case"reject_always":return d.jsx(an,{className:"size-4"});default:return null}}function Kg({requestId:e,options:t,onRespond:n,className:r}){const o=s=>{n(e,s.optionId,s.kind)};return d.jsxs("div",{className:Z("p-3 border-t border-warning-border/30 bg-warning-bg/50",r),children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(Qr,{className:"size-4 text-warning-text"}),d.jsx("span",{className:"text-xs font-medium text-warning-text",children:"Permission Required"})]}),d.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(s=>d.jsxs(Et,{variant:Vg(s.kind),size:"sm",onClick:()=>o(s),className:"gap-1.5",children:[Gg(s.kind),s.name]},s.optionId))})]})}function El({entries:e,onPermissionRespond:t}){const[n,r]=m.useState(!1);if(e.length===0)return null;if(e.length===1)return d.jsx("div",{className:"pl-10",children:d.jsx(bs,{tool:e[0].toolCall,compact:!0,onPermissionRespond:t})});const o=qg(e);return d.jsx("div",{className:"pl-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-surface-2/50 overflow-hidden",children:[d.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-brand font-bold hover:bg-brand/10 transition-colors",onClick:()=>r(!n),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:Z("transition-transform text-text-muted",n&&"rotate-90"),children:d.jsx("path",{d:"M4 2L8 6L4 10",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})}),d.jsx("span",{className:"text-xs text-brand font-bold font-display",children:o})]}),n&&d.jsx("div",{className:"border-t border-border divide-y divide-border",children:e.map((s,a)=>d.jsx(bs,{tool:s.toolCall,compact:!0,onPermissionRespond:t},s.toolCall.id||a))})]})})}function bs({tool:e,compact:t,onPermissionRespond:n}){const[r,o]=m.useState(!t),s=(()=>{switch(e.status){case"running":return d.jsx("span",{className:"text-status-running text-[10px]",children:"▶"});case"complete":return d.jsx("span",{className:"text-status-active text-[10px]",children:"✓"});case"error":return d.jsx("span",{className:"text-status-error text-[10px]",children:"✕"});case"waiting_for_confirmation":return d.jsx("span",{className:"text-brand text-[10px]",children:"⍻"});case"canceled":return d.jsx("span",{className:"text-text-muted text-[10px]",children:"—"});case"rejected":return d.jsx("span",{className:"text-status-error text-[10px]",children:"✕"});default:return null}})(),a=e.status!=="running"&&e.status!=="waiting_for_confirmation"&&(e.rawOutput||e.content);return d.jsxs("div",{className:Z("px-3 py-2",t&&"py-1.5"),children:[d.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 text-left group",onClick:()=>o(!r),children:[s,d.jsx("span",{className:"text-xs font-display font-bold text-brand transition-colors truncate",children:e.title}),e.status==="running"&&d.jsx("span",{className:"text-[10px] text-status-running animate-pulse",children:"running"})]}),e.status==="waiting_for_confirmation"&&e.permissionRequest&&d.jsx("div",{className:"mt-1.5 ml-4",children:d.jsx(Kg,{requestId:e.permissionRequest.requestId,options:e.permissionRequest.options,onRespond:n||(()=>{})})}),r&&d.jsxs("div",{className:"mt-1.5 ml-4 space-y-1.5",children:[e.rawInput&&Object.keys(e.rawInput).length>0&&d.jsx("div",{children:d.jsx("pre",{className:"text-[11px] bg-surface-1 rounded-md p-2 overflow-x-auto font-mono max-h-36 text-text-secondary",children:Br(JSON.stringify(e.rawInput,null,2),2e3)})}),a&&d.jsx("div",{children:d.jsx("pre",{className:Z("text-[11px] rounded-md p-2 overflow-x-auto font-mono max-h-36",e.status==="error"?"bg-status-error/10 text-status-error":"bg-surface-1 text-text-secondary"),children:Xg(e)})})]})]})}function qg(e){const t=new Map;for(const r of e){const o=Yg(r.toolCall.title);t.set(o,(t.get(o)||0)+1)}const n=[];for(const[r,o]of t)n.push(o===1?r:`${o} 次${r}`);return n.length===0?`${e.length} 个工具调用`:n.length===1?n[0]:`${e.length} 个工具: ${n.join("、")}`}function Yg(e){const t=e.match(/^(\w+)/);return t?t[1]:e}function Xg(e){if(e.content&&e.content.length>0){const t=e.content.filter(n=>n.type==="content").filter(n=>n.content.type==="text"&&"text"in n.content).map(n=>n.content.text);if(t.length>0)return Br(t.join(`
251
- `),2e3)}return e.rawOutput&&Object.keys(e.rawOutput).length>0?Br(JSON.stringify(e.rawOutput,null,2),2e3):""}function Br(e,t){return e.length>t?e.slice(0,t)+"...":e}function Qg({entry:e}){const[t,n]=m.useState(!1),{entries:r}=e;if(r.length===0)return null;const o=r.filter(i=>i.status==="completed").length,s=r.length,a=s>0?Math.round(o/s*100):0;return d.jsx("div",{className:"pl-10",children:d.jsxs("div",{className:"rounded-xl border border-border bg-brand/5 overflow-hidden",children:[d.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2.5 text-sm hover:bg-surface-1/50 transition-colors",onClick:()=>n(!t),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:Z("transition-transform text-text-muted flex-shrink-0",t&&"rotate-90"),children:d.jsx("path",{d:"M4 2L8 6L4 10",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})}),d.jsx("span",{className:"text-xs font-display font-medium text-text-secondary",children:"执行计划"}),d.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:[o,"/",s]}),d.jsx("div",{className:"flex-1 h-1 rounded-full bg-surface-1 overflow-hidden ml-1 mr-2",children:d.jsx("div",{className:"h-full rounded-full bg-brand/70 transition-all duration-500",style:{width:`${a}%`}})}),d.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:[a,"%"]})]}),!t&&d.jsx("div",{className:Z("border-t border-border px-3 py-1.5 space-y-0.5",s>5&&"max-h-64 overflow-y-auto"),children:r.map((i,h)=>d.jsx(Zg,{entry:i},h))})]})})}function Zg({entry:e}){return d.jsxs("div",{className:"flex items-start gap-2 py-1.5 px-1",children:[d.jsx("span",{className:"flex-shrink-0 mt-0.5",children:d.jsx(Jg,{status:e.status})}),d.jsx("span",{className:Z("text-xs leading-relaxed flex-1",e.status==="completed"?"text-text-muted line-through":"text-text-secondary",e.status==="in_progress"&&"text-text-primary font-medium"),children:e.content}),d.jsx(ex,{priority:e.priority})]})}function Jg({status:e}){switch(e){case"completed":return d.jsx(vd,{className:"h-3.5 w-3.5 text-status-active"});case"in_progress":return d.jsx(na,{className:"h-3.5 w-3.5 text-brand animate-spin",style:{animationDuration:"2s"}});case"pending":return d.jsx(bd,{className:"h-3.5 w-3.5 text-text-muted"})}}function ex({priority:e}){const t={high:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300",medium:"bg-brand/10 text-brand dark:bg-brand/20",low:"bg-surface-1 text-text-muted"},n={high:"高",medium:"中",low:"低"};return d.jsx("span",{className:Z("text-[9px] font-display rounded-full px-1.5 py-0.5 flex-shrink-0 leading-none",t[e]),children:n[e]})}function tx({entry:e}){const t=e.variant==="error";return d.jsxs("div",{className:"w-full",children:[d.jsx("div",{className:Z("border-t-2",t?"border-status-error":"border-border")}),d.jsxs("div",{className:"pt-3",children:[d.jsx("h3",{className:Z("font-bold font-display text-base",t?"text-status-error":"text-brand"),children:e.title}),e.subtitle&&d.jsx("p",{className:"text-sm text-text-muted mt-0.5",children:e.subtitle})]}),d.jsx("div",{className:"py-3 message-content text-text-primary leading-[1.75]",children:d.jsx(Ao,{children:e.outputText})}),d.jsx("div",{className:"pb-1 text-xs text-text-muted italic",children:"命令已执行 · 输入消息继续"})]})}/*!---------------------------------------------------------------------------------------------
250
+ `;let vr;function Qp(e,t){return new Promise(((n,r)=>{vr||(vr=(function(a){const i=[];return i.push(a),URL.createObjectURL(new Blob(i))})(Xp));const o=new Worker(vr);o.addEventListener("message",(function(a){if(t.signal&&t.signal.aborted)o.terminate();else if(a.data.progress===void 0){if(a.data.error)return r(new Error(a.data.error)),void o.terminate();n(a.data.file),o.terminate()}else t.onProgress(a.data.progress)})),o.addEventListener("error",r),t.signal&&t.signal.addEventListener("abort",(()=>{r(t.signal.reason),o.terminate()})),o.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})}))}function be(e,t){return new Promise((function(n,r){let o,s,a,i,h,f;if(o={...t},a=0,{onProgress:i}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,h=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=p=>{a=p,typeof i=="function"&&i(a)},!(e instanceof Blob||e instanceof Yp))return r(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return r(new Error("The file given is not an image"));if(f=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!h||typeof Worker!="function"||f)return bs(e,o).then((function(p){try{return s=p,u.call(this)}catch(g){return r(g)}}).bind(this),r);var c=(function(){try{return u.call(this)}catch(p){return r(p)}}).bind(this),l=function(p){try{return bs(e,o).then((function(g){try{return s=g,c()}catch(v){return r(v)}}),r)}catch(g){return r(g)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Qp(e,o).then((function(p){try{return s=p,c()}catch{return l()}}),l)}catch{l()}function u(){try{s.name=e.name,s.lastModified=e.lastModified}catch{}try{o.preserveExif&&e.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===e.type)&&(s=Qi(e,s))}catch{}return n(s)}}))}be.getDataUrlFromFile=tl,be.getFilefromDataUrl=Eo,be.loadImage=nl,be.drawImageInCanvas=ol,be.drawFileInCanvas=Fn,be.canvasToFile=Un,be.getExifOrientation=sl,be.handleMaxWidthOrHeight=al,be.followExifOrientation=il,be.cleanupCanvasMemory=Ue,be.isAutoOrientationInBrowser=Mt,be.approximateBelowMaximumCanvasSizeOfBrowser=rl,be.copyExifWithoutOrientation=Qi,be.getBrowserName=bt,be.version="2.0.2";var Zp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ut=Zp.reduce((e,t)=>{const n=ua(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,h=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(h,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Jp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),eg="VisuallyHidden",ll=m.forwardRef((e,t)=>d.jsx(ue.span,{...e,ref:t,style:{...Jp,...e.style}}));ll.displayName=eg;var tg=ll,[tr]=Qe("Tooltip",[Ht]),nr=Ht(),cl="TooltipProvider",ng=700,Ur="tooltip.open",[rg,No]=tr(cl),dl=e=>{const{__scopeTooltip:t,delayDuration:n=ng,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=m.useRef(!0),i=m.useRef(!1),h=m.useRef(0);return m.useEffect(()=>{const f=h.current;return()=>window.clearTimeout(f)},[]),d.jsx(rg,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(h.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:i,onPointerInTransitChange:m.useCallback(f=>{i.current=f},[]),disableHoverableContent:o,children:s})};dl.displayName=cl;var nn="Tooltip",[og,mn]=tr(nn),ul=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:i}=e,h=No(nn,e.__scopeTooltip),f=nr(t),[c,l]=m.useState(null),u=Ce(),p=m.useRef(0),g=a??h.disableHoverableContent,v=i??h.delayDuration,C=m.useRef(!1),[y,R]=at({prop:r,defaultProp:o??!1,onChange:N=>{N?(h.onOpen(),document.dispatchEvent(new CustomEvent(Ur))):h.onClose(),s==null||s(N)},caller:nn}),j=m.useMemo(()=>y?C.current?"delayed-open":"instant-open":"closed",[y]),_=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,C.current=!1,R(!0)},[R]),$=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,R(!1)},[R]),k=m.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{C.current=!0,R(!0),p.current=0},v)},[v,R]);return m.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),d.jsx(lo,{...f,children:d.jsx(og,{scope:t,contentId:u,open:y,stateAttribute:j,trigger:c,onTriggerChange:l,onTriggerEnter:m.useCallback(()=>{h.isOpenDelayedRef.current?k():_()},[h.isOpenDelayedRef,k,_]),onTriggerLeave:m.useCallback(()=>{g?$():(window.clearTimeout(p.current),p.current=0)},[$,g]),onOpen:_,onClose:$,disableHoverableContent:g,children:n})})};ul.displayName=nn;var zr="TooltipTrigger",fl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mn(zr,n),s=No(zr,n),a=nr(n),i=m.useRef(null),h=pe(t,i,o.onTriggerChange),f=m.useRef(!1),c=m.useRef(!1),l=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",l),[l]),d.jsx(qn,{asChild:!0,...a,children:d.jsx(ue.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:h,onPointerMove:ee(e.onPointerMove,u=>{u.pointerType!=="touch"&&!c.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),c.current=!0)}),onPointerLeave:ee(e.onPointerLeave,()=>{o.onTriggerLeave(),c.current=!1}),onPointerDown:ee(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",l,{once:!0})}),onFocus:ee(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:ee(e.onBlur,o.onClose),onClick:ee(e.onClick,o.onClose)})})});fl.displayName=zr;var jo="TooltipPortal",[sg,ag]=tr(jo,{forceMount:void 0}),hl=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=mn(jo,t);return d.jsx(sg,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};hl.displayName=jo;var Ft="TooltipContent",ml=m.forwardRef((e,t)=>{const n=ag(Ft,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=mn(Ft,e.__scopeTooltip);return d.jsx(Ae,{present:r||a.open,children:a.disableHoverableContent?d.jsx(pl,{side:o,...s,ref:t}):d.jsx(ig,{side:o,...s,ref:t})})}),ig=m.forwardRef((e,t)=>{const n=mn(Ft,e.__scopeTooltip),r=No(Ft,e.__scopeTooltip),o=m.useRef(null),s=pe(t,o),[a,i]=m.useState(null),{trigger:h,onClose:f}=n,c=o.current,{onPointerInTransitChange:l}=r,u=m.useCallback(()=>{i(null),l(!1)},[l]),p=m.useCallback((g,v)=>{const C=g.currentTarget,y={x:g.clientX,y:g.clientY},R=ug(y,C.getBoundingClientRect()),j=fg(y,R),_=hg(v.getBoundingClientRect()),$=pg([...j,..._]);i($),l(!0)},[l]);return m.useEffect(()=>()=>u(),[u]),m.useEffect(()=>{if(h&&c){const g=C=>p(C,c),v=C=>p(C,h);return h.addEventListener("pointerleave",g),c.addEventListener("pointerleave",v),()=>{h.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",v)}}},[h,c,p,u]),m.useEffect(()=>{if(a){const g=v=>{const C=v.target,y={x:v.clientX,y:v.clientY},R=(h==null?void 0:h.contains(C))||(c==null?void 0:c.contains(C)),j=!mg(y,a);R?u():j&&(u(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[h,c,a,f,u]),d.jsx(pl,{...e,ref:s})}),[lg,cg]=tr(nn,{isInside:!1}),dg=Ou("TooltipContent"),pl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...i}=e,h=mn(Ft,n),f=nr(n),{onClose:c}=h;return m.useEffect(()=>(document.addEventListener(Ur,c),()=>document.removeEventListener(Ur,c)),[c]),m.useEffect(()=>{if(h.trigger){const l=u=>{const p=u.target;p!=null&&p.contains(h.trigger)&&c()};return window.addEventListener("scroll",l,{capture:!0}),()=>window.removeEventListener("scroll",l,{capture:!0})}},[h.trigger,c]),d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:l=>l.preventDefault(),onDismiss:c,children:d.jsxs(co,{"data-state":h.stateAttribute,...f,...i,ref:t,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(dg,{children:r}),d.jsx(lg,{scope:n,isInside:!0,children:d.jsx(tg,{id:h.contentId,role:"tooltip",children:o||r})})]})})});ml.displayName=Ft;var gl="TooltipArrow",xl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=nr(n);return cg(gl,n).isInside?null:d.jsx(uo,{...o,...r,ref:t})});xl.displayName=gl;function ug(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function fg(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function hg(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function mg(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],h=t[a],f=i.x,c=i.y,l=h.x,u=h.y;c>r!=u>r&&n<(l-f)*(r-c)/(u-c)+f&&(o=!o)}return o}function pg(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),gg(t)}function gg(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xg=dl,vg=ul,bg=fl,yg=hl,wg=ml,Cg=xl;function Sg({delayDuration:e=0,...t}){return d.jsx(xg,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function kg({...e}){return d.jsx(Sg,{children:d.jsx(vg,{"data-slot":"tooltip",...e})})}function _g({...e}){return d.jsx(bg,{"data-slot":"tooltip-trigger",...e})}function Eg({className:e,sideOffset:t=0,children:n,...r}){return d.jsx(yg,{children:d.jsxs(wg,{"data-slot":"tooltip-content",sideOffset:t,className:Z("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,d.jsx(Cg,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Ng=m.lazy(()=>on(()=>import("./mermaid-VLURNSYL-C_e5Vkmm.js").then(e=>e.i),__vite__mapDeps([0,1,2])).then(e=>({default:e.Streamdown})));m.createContext(null);const Ao=m.memo(({className:e,children:t,...n})=>d.jsx(m.Suspense,{fallback:d.jsx("div",{className:Z("whitespace-pre-wrap break-words",e),children:t}),children:d.jsx(Ng,{className:Z("size-full break-words [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...n,children:t})}),(e,t)=>e.children===t.children);Ao.displayName="MessageResponse";var rr="Collapsible",[jg]=Qe(rr),[Ag,Ro]=jg(rr),vl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...i}=e,[h,f]=at({prop:r,defaultProp:o??!1,onChange:a,caller:rr});return d.jsx(Ag,{scope:n,disabled:s,contentId:Ce(),open:h,onOpenToggle:m.useCallback(()=>f(c=>!c),[f]),children:d.jsx(ue.div,{"data-state":Io(h),"data-disabled":s?"":void 0,...i,ref:t})})});vl.displayName=rr;var bl="CollapsibleTrigger",yl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ro(bl,n);return d.jsx(ue.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Io(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ee(e.onClick,o.onOpenToggle)})});yl.displayName=bl;var To="CollapsibleContent",wl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ro(To,e.__scopeCollapsible);return d.jsx(Ae,{present:n||o.open,children:({present:s})=>d.jsx(Rg,{...r,ref:t,present:s})})});wl.displayName=To;var Rg=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=Ro(To,n),[i,h]=m.useState(r),f=m.useRef(null),c=pe(t,f),l=m.useRef(0),u=l.current,p=m.useRef(0),g=p.current,v=a.open||i,C=m.useRef(v),y=m.useRef(void 0);return m.useEffect(()=>{const R=requestAnimationFrame(()=>C.current=!1);return()=>cancelAnimationFrame(R)},[]),Ke(()=>{const R=f.current;if(R){y.current=y.current||{transitionDuration:R.style.transitionDuration,animationName:R.style.animationName},R.style.transitionDuration="0s",R.style.animationName="none";const j=R.getBoundingClientRect();l.current=j.height,p.current=j.width,C.current||(R.style.transitionDuration=y.current.transitionDuration,R.style.animationName=y.current.animationName),h(r)}},[a.open,r]),d.jsx(ue.div,{"data-state":Io(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!v,...s,ref:c,style:{"--radix-collapsible-content-height":u?`${u}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:v&&o})});function Io(e){return e?"open":"closed"}var Tg=vl;function Ig({...e}){return d.jsx(Tg,{"data-slot":"collapsible",...e})}function Mg({...e}){return d.jsx(yl,{"data-slot":"collapsible-trigger",...e})}function Pg({...e}){return d.jsx(wl,{"data-slot":"collapsible-content",...e})}const Og=({children:e,as:t="p",className:n,duration:r=2})=>{const o=lc.create(t);return d.jsx(o,{animate:{opacity:[.5,1,.5]},className:Z("relative inline-block text-muted-foreground",n),transition:{repeat:Number.POSITIVE_INFINITY,duration:r,ease:"easeInOut"},children:e})},Dg=m.memo(Og),Cl=m.createContext(null),Lg=()=>{const e=m.useContext(Cl);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},$g=1e3,Fg=1e3,Sl=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:o,duration:s,children:a,...i})=>{const[h,f]=at({prop:n,defaultProp:r,onChange:o}),[c,l]=at({prop:s,defaultProp:void 0}),[u,p]=m.useState(!1),[g,v]=m.useState(null);m.useEffect(()=>{t?g===null&&v(Date.now()):g!==null&&(l(Math.ceil((Date.now()-g)/Fg)),v(null))},[t,g,l]);const C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;m.useEffect(()=>{if(!C&&r&&!t&&h&&!u){const R=setTimeout(()=>{f(!1),p(!0)},$g);return()=>clearTimeout(R)}},[t,h,r,f,u,C]);const y=R=>{f(R)};return d.jsx(Cl.Provider,{value:{isStreaming:t,isOpen:h??!1,setIsOpen:f,duration:c},children:d.jsx(Ig,{className:Z("not-prose mb-4",e),onOpenChange:y,open:h,...i,children:a})})}),Ug=(e,t)=>e||t===0?d.jsx(Dg,{duration:1,children:"Thinking..."}):t===void 0?d.jsx("p",{children:"Thought for a few seconds"}):d.jsxs("p",{children:["Thought for ",t," seconds"]}),kl=m.memo(({className:e,children:t,getThinkingMessage:n=Ug,...r})=>{const{isStreaming:o,isOpen:s,duration:a}=Lg();return d.jsx(Mg,{className:Z("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...r,children:t??d.jsxs(d.Fragment,{children:[d.jsx(ud,{className:"size-4"}),n(o,a),d.jsx(sn,{className:Z("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),_l=m.memo(({className:e,children:t,...n})=>d.jsx(Pg,{className:Z("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t}));Sl.displayName="Reasoning";kl.displayName="ReasoningTrigger";_l.displayName="ReasoningContent";const br=200;function zg({entry:e}){const[t,n]=m.useState(!1),[r,o]=m.useState(!1),s=m.useRef(null),a=m.useCallback(()=>{const i=s.current;i&&o(i.scrollHeight>br+4)},[]);return m.useEffect(()=>{a()},[a,e.content]),d.jsx("div",{className:"flex justify-end",children:d.jsxs("div",{className:"max-w-[85%] sm:max-w-[70%]",children:[e.images&&e.images.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 mb-2 justify-end",children:e.images.map((i,h)=>d.jsx(Wg,{image:i},h))}),e.attachments&&e.attachments.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 mb-2 justify-end",children:e.attachments.map((i,h)=>d.jsx(Hg,{attachment:i},h))}),e.content&&d.jsxs("div",{className:"relative rounded-2xl rounded-br-md bg-user-bubble border border-user-bubble-border overflow-hidden",children:[d.jsx("div",{ref:s,className:Z("px-5 py-3 text-sm text-text-primary whitespace-pre-wrap font-display leading-relaxed",!t&&r&&`max-h-[${br}px]`),style:!t&&r?{maxHeight:`${br}px`}:void 0,children:ed(e.content)}),!t&&r&&d.jsx("div",{className:"absolute bottom-0 inset-x-0 flex flex-col items-center pt-8 bg-gradient-to-t from-user-bubble via-user-bubble/80 to-transparent",children:d.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex items-center gap-1 px-3 py-1 rounded-full text-xs font-display font-medium text-text-secondary hover:bg-brand/10 transition-colors",children:[d.jsx("span",{children:"展开"}),d.jsx(sn,{className:"h-3 w-3"})]})})]})]})})}function Bg({entry:e,isStreaming:t}){return d.jsxs("div",{className:"flex gap-4 items-start",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 mt-0.5 overflow-hidden",children:d.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:28,height:28,className:"object-contain",draggable:!1})}),d.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[d.jsx("span",{className:"text-sm font-semibold text-text-primary font-display",children:"Saluzi"}),e.chunks.map((n,r)=>{if(n.type==="thought"){const o=r===e.chunks.length-1,s=t&&o;return d.jsxs(Sl,{isStreaming:s,children:[d.jsx(kl,{}),d.jsx(_l,{children:d.jsx("div",{className:"text-sm text-text-secondary leading-relaxed",children:n.text})})]},r)}return d.jsx("div",{className:"message-content text-text-primary leading-[1.75]",children:d.jsx(Ao,{children:n.text})},r)})]})]})}function Wg({image:e}){const t=`data:${e.mimeType};base64,${e.data}`;return d.jsx("button",{type:"button",className:"rounded-lg overflow-hidden border border-border hover:border-brand/40 transition-colors cursor-pointer",onClick:()=>{const n=window.open("");n&&n.document.write(`<img src="${t}" style="max-width:100%;max-height:100%" />`)},children:d.jsx("img",{src:t,alt:"Uploaded image",className:"h-20 w-20 object-cover"})})}function Hg({attachment:e}){const[t,n]=m.useState(!1),r=(()=>{switch(e.kind){case"text":return d.jsx(Zt,{className:"h-4 w-4"});case"table":return d.jsx(Zr,{className:"h-4 w-4"});case"directory":return d.jsx(Xr,{className:"h-4 w-4"});default:return d.jsx(Zt,{className:"h-4 w-4"})}})(),o=e.size!=null?Vg(e.size):null,s=e.kind==="directory"&&e.files?e.files.length:null,a=!!e.textContent;return d.jsxs("div",{className:"min-w-[160px] max-w-[300px]",children:[d.jsxs("button",{type:"button",onClick:()=>a&&n(i=>!i),className:Z("w-full flex items-center gap-2 rounded-lg border border-border bg-surface-1/50 px-3 py-2 text-xs text-text-secondary",a?"hover:border-brand/40 hover:bg-surface-1 cursor-pointer":"cursor-default"),children:[r,d.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[d.jsx("div",{className:"truncate font-mono text-text-primary",title:e.name,children:e.name}),d.jsxs("div",{className:"text-[10px] text-text-muted",children:[o&&d.jsx("span",{children:o}),o&&s!=null&&d.jsx("span",{children:" · "}),s!=null&&d.jsxs("span",{children:[s," 个文件"]})]})]}),a&&d.jsx(sn,{className:Z("h-3.5 w-3.5 flex-shrink-0 transition-transform",t&&"rotate-180")})]}),t&&a&&d.jsx("div",{className:"mt-1 rounded-lg border border-border bg-surface-2 p-3 max-h-[300px] overflow-auto",children:d.jsx("pre",{className:"text-[11px] text-text-secondary font-mono whitespace-pre-wrap break-words",children:e.textContent})})]})}function Vg(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Gg(e){switch(e){case"allow_once":case"allow_always":return"default";case"reject_once":case"reject_always":return"destructive";default:return"outline"}}function Kg(e){switch(e){case"allow_once":case"allow_always":return d.jsx(wt,{className:"size-4"});case"reject_once":case"reject_always":return d.jsx(an,{className:"size-4"});default:return null}}function qg({requestId:e,options:t,onRespond:n,className:r}){const o=s=>{n(e,s.optionId,s.kind)};return d.jsxs("div",{className:Z("p-3 border-t border-warning-border/30 bg-warning-bg/50",r),children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(Qr,{className:"size-4 text-warning-text"}),d.jsx("span",{className:"text-xs font-medium text-warning-text",children:"Permission Required"})]}),d.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(s=>d.jsxs(Et,{variant:Gg(s.kind),size:"sm",onClick:()=>o(s),className:"gap-1.5",children:[Kg(s.kind),s.name]},s.optionId))})]})}function El({entries:e,onPermissionRespond:t}){const[n,r]=m.useState(!1);if(e.length===0)return null;if(e.length===1)return d.jsx("div",{className:"pl-10",children:d.jsx(ys,{tool:e[0].toolCall,compact:!0,onPermissionRespond:t})});const o=Yg(e);return d.jsx("div",{className:"pl-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-surface-2/50 overflow-hidden",children:[d.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-brand font-bold hover:bg-brand/10 transition-colors",onClick:()=>r(!n),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:Z("transition-transform text-text-muted",n&&"rotate-90"),children:d.jsx("path",{d:"M4 2L8 6L4 10",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})}),d.jsx("span",{className:"text-xs text-brand font-bold font-display",children:o})]}),n&&d.jsx("div",{className:"border-t border-border divide-y divide-border",children:e.map((s,a)=>d.jsx(ys,{tool:s.toolCall,compact:!0,onPermissionRespond:t},s.toolCall.id||a))})]})})}function ys({tool:e,compact:t,onPermissionRespond:n}){const[r,o]=m.useState(!t),s=(()=>{switch(e.status){case"running":return d.jsx("span",{className:"text-status-running text-[10px]",children:"▶"});case"complete":return d.jsx("span",{className:"text-status-active text-[10px]",children:"✓"});case"error":return d.jsx("span",{className:"text-status-error text-[10px]",children:"✕"});case"waiting_for_confirmation":return d.jsx("span",{className:"text-brand text-[10px]",children:"⍻"});case"canceled":return d.jsx("span",{className:"text-text-muted text-[10px]",children:"—"});case"rejected":return d.jsx("span",{className:"text-status-error text-[10px]",children:"✕"});default:return null}})(),a=e.status!=="running"&&e.status!=="waiting_for_confirmation"&&(e.rawOutput||e.content);return d.jsxs("div",{className:Z("px-3 py-2",t&&"py-1.5"),children:[d.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 text-left group",onClick:()=>o(!r),children:[s,d.jsx("span",{className:"text-xs font-display font-bold text-brand transition-colors truncate",children:e.title}),e.status==="running"&&d.jsx("span",{className:"text-[10px] text-status-running animate-pulse",children:"running"})]}),e.status==="waiting_for_confirmation"&&e.permissionRequest&&d.jsx("div",{className:"mt-1.5 ml-4",children:d.jsx(qg,{requestId:e.permissionRequest.requestId,options:e.permissionRequest.options,onRespond:n||(()=>{})})}),r&&d.jsxs("div",{className:"mt-1.5 ml-4 space-y-1.5",children:[e.rawInput&&Object.keys(e.rawInput).length>0&&d.jsx("div",{children:d.jsx("pre",{className:"text-[11px] bg-surface-1 rounded-md p-2 overflow-x-auto font-mono max-h-36 text-text-secondary",children:Br(JSON.stringify(e.rawInput,null,2),2e3)})}),a&&d.jsx("div",{children:d.jsx("pre",{className:Z("text-[11px] rounded-md p-2 overflow-x-auto font-mono max-h-36",e.status==="error"?"bg-status-error/10 text-status-error":"bg-surface-1 text-text-secondary"),children:Qg(e)})})]})]})}function Yg(e){const t=new Map;for(const r of e){const o=Xg(r.toolCall.title);t.set(o,(t.get(o)||0)+1)}const n=[];for(const[r,o]of t)n.push(o===1?r:`${o} 次${r}`);return n.length===0?`${e.length} 个工具调用`:n.length===1?n[0]:`${e.length} 个工具: ${n.join("、")}`}function Xg(e){const t=e.match(/^(\w+)/);return t?t[1]:e}function Qg(e){if(e.content&&e.content.length>0){const t=e.content.filter(n=>n.type==="content").filter(n=>n.content.type==="text"&&"text"in n.content).map(n=>n.content.text);if(t.length>0)return Br(t.join(`
251
+ `),2e3)}return e.rawOutput&&Object.keys(e.rawOutput).length>0?Br(JSON.stringify(e.rawOutput,null,2),2e3):""}function Br(e,t){return e.length>t?e.slice(0,t)+"...":e}function Zg({entry:e}){const[t,n]=m.useState(!1),{entries:r}=e;if(r.length===0)return null;const o=r.filter(i=>i.status==="completed").length,s=r.length,a=s>0?Math.round(o/s*100):0;return d.jsx("div",{className:"pl-10",children:d.jsxs("div",{className:"rounded-xl border border-border bg-brand/5 overflow-hidden",children:[d.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2.5 text-sm hover:bg-surface-1/50 transition-colors",onClick:()=>n(!t),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:Z("transition-transform text-text-muted flex-shrink-0",t&&"rotate-90"),children:d.jsx("path",{d:"M4 2L8 6L4 10",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})}),d.jsx("span",{className:"text-xs font-display font-medium text-text-secondary",children:"执行计划"}),d.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:[o,"/",s]}),d.jsx("div",{className:"flex-1 h-1 rounded-full bg-surface-1 overflow-hidden ml-1 mr-2",children:d.jsx("div",{className:"h-full rounded-full bg-brand/70 transition-all duration-500",style:{width:`${a}%`}})}),d.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:[a,"%"]})]}),!t&&d.jsx("div",{className:Z("border-t border-border px-3 py-1.5 space-y-0.5",s>5&&"max-h-64 overflow-y-auto"),children:r.map((i,h)=>d.jsx(Jg,{entry:i},h))})]})})}function Jg({entry:e}){return d.jsxs("div",{className:"flex items-start gap-2 py-1.5 px-1",children:[d.jsx("span",{className:"flex-shrink-0 mt-0.5",children:d.jsx(ex,{status:e.status})}),d.jsx("span",{className:Z("text-xs leading-relaxed flex-1",e.status==="completed"?"text-text-muted line-through":"text-text-secondary",e.status==="in_progress"&&"text-text-primary font-medium"),children:e.content}),d.jsx(tx,{priority:e.priority})]})}function ex({status:e}){switch(e){case"completed":return d.jsx(vd,{className:"h-3.5 w-3.5 text-status-active"});case"in_progress":return d.jsx(na,{className:"h-3.5 w-3.5 text-brand animate-spin",style:{animationDuration:"2s"}});case"pending":return d.jsx(yd,{className:"h-3.5 w-3.5 text-text-muted"})}}function tx({priority:e}){const t={high:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300",medium:"bg-brand/10 text-brand dark:bg-brand/20",low:"bg-surface-1 text-text-muted"},n={high:"高",medium:"中",low:"低"};return d.jsx("span",{className:Z("text-[9px] font-display rounded-full px-1.5 py-0.5 flex-shrink-0 leading-none",t[e]),children:n[e]})}function nx({entry:e}){const t=e.variant==="error";return d.jsxs("div",{className:"w-full",children:[d.jsx("div",{className:Z("border-t-2",t?"border-status-error":"border-border")}),d.jsxs("div",{className:"pt-3",children:[d.jsx("h3",{className:Z("font-bold font-display text-base",t?"text-status-error":"text-brand"),children:e.title}),e.subtitle&&d.jsx("p",{className:"text-sm text-text-muted mt-0.5",children:e.subtitle})]}),d.jsx("div",{className:"py-3 message-content text-text-primary leading-[1.75]",children:d.jsx(Ao,{children:e.outputText})}),d.jsx("div",{className:"pb-1 text-xs text-text-muted italic",children:"命令已执行 · 输入消息继续"})]})}/*!---------------------------------------------------------------------------------------------
252
252
  * Copyright (c) StackBlitz. All rights reserved.
253
253
  * Licensed under the MIT License. See License.txt in the project root for license information.
254
- *--------------------------------------------------------------------------------------------*/const nx={damping:.7,stiffness:.05,mass:1.25},rx=70,ox=1e3/60,sx=350;let or=!1;var Ts;(Ts=globalThis.document)==null||Ts.addEventListener("mousedown",()=>{or=!0});var Is;(Is=globalThis.document)==null||Is.addEventListener("mouseup",()=>{or=!1});var Ms;(Ms=globalThis.document)==null||Ms.addEventListener("click",()=>{or=!1});const ax=(e={})=>{const[t,n]=m.useState(!1),[r,o]=m.useState(e.initial!==!1),[s,a]=m.useState(!1),i=m.useRef(null);i.current=e;const h=m.useCallback(()=>{var _;if(!or)return!1;const R=window.getSelection();if(!R||!R.rangeCount)return!1;const j=R.getRangeAt(0);return j.commonAncestorContainer.contains(C.current)||((_=C.current)==null?void 0:_.contains(j.commonAncestorContainer))},[]),f=m.useCallback(R=>{l.isAtBottom=R,o(R)},[]),c=m.useCallback(R=>{l.escapedFromLock=R,n(R)},[]),l=m.useMemo(()=>{let R;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){var j;return((j=C.current)==null?void 0:j.scrollTop)??0},set scrollTop(j){if(C.current){const{scrollBehavior:_}=getComputedStyle(C.current);_!=="auto"&&(C.current.style.scrollBehavior="auto"),C.current.scrollTop=j,l.ignoreScrollToTop=C.current.scrollTop,_!=="auto"&&(C.current.style.scrollBehavior=_)}},get targetScrollTop(){return!C.current||!b.current?0:C.current.scrollHeight-1-C.current.clientHeight},get calculatedTargetScrollTop(){if(!C.current||!b.current)return 0;const{targetScrollTop:j}=this;if(!e.targetScrollTop)return j;if((R==null?void 0:R.targetScrollTop)===j)return R.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(j,{scrollElement:C.current,contentElement:b.current}),j),0);return R={targetScrollTop:j,calculatedScrollTop:_},requestAnimationFrame(()=>{R=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=rx}}},[]),u=m.useCallback((R={})=>{var y;typeof R=="string"&&(R={animation:R}),R.preserveScrollPosition||f(!0);const j=Date.now()+(Number(R.wait)||0),_=wr(i.current,R.animation),{ignoreEscapes:$=!1}=R;let k,N=l.calculatedTargetScrollTop;R.duration instanceof Promise?R.duration.finally(()=>{k=Date.now()}):k=j+(R.duration??0);const x=async()=>{const A=new Promise(requestAnimationFrame).then(()=>{var M;if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:O}=l,P=performance.now(),F=(P-(l.lastTick??P))/ox;if(l.animation||(l.animation={behavior:_,promise:A,ignoreEscapes:$}),l.animation.behavior===_&&(l.lastTick=P),h()||j>Date.now())return x();if(O<Math.min(N,l.calculatedTargetScrollTop)){if(((M=l.animation)==null?void 0:M.behavior)===_){if(_==="instant")return l.scrollTop=l.calculatedTargetScrollTop,x();l.velocity=(_.damping*l.velocity+_.stiffness*l.scrollDifference)/_.mass,l.accumulated+=l.velocity*F,l.scrollTop+=l.accumulated,l.scrollTop!==O&&(l.accumulated=0)}return x()}return k>Date.now()?(N=l.calculatedTargetScrollTop,x()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?u({animation:wr(i.current,i.current.resize),ignoreEscapes:$,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return A.then(O=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),O))};return R.wait!==!0&&(l.animation=void 0),((y=l.animation)==null?void 0:y.behavior)===_?l.animation.promise:x()},[f,h,l]),p=m.useCallback(()=>{c(!0),f(!1)},[c,f]),g=m.useCallback(({target:R})=>{if(R!==C.current)return;const{scrollTop:j,ignoreScrollToTop:_}=l;let{lastScrollTop:$=j}=l;l.lastScrollTop=j,l.ignoreScrollToTop=void 0,_&&_>j&&($=_),a(l.isNearBottom),setTimeout(()=>{var x;if(l.resizeDifference||j===_)return;if(h()){c(!0),f(!1);return}const k=j>$,N=j<$;if((x=l.animation)!=null&&x.ignoreEscapes){l.scrollTop=$;return}N&&(c(!0),f(!1)),k&&c(!1),!l.escapedFromLock&&l.isNearBottom&&f(!0)},1)},[c,f,h,l]),v=m.useCallback(({target:R,deltaY:j})=>{var $;let _=R;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===C.current&&j<0&&C.current.scrollHeight>C.current.clientHeight&&!(($=l.animation)!=null&&$.ignoreEscapes)&&(c(!0),f(!1))},[c,f,l]),C=ws(R=>{var j,_;(j=C.current)==null||j.removeEventListener("scroll",g),(_=C.current)==null||_.removeEventListener("wheel",v),R==null||R.addEventListener("scroll",g,{passive:!0}),R==null||R.addEventListener("wheel",v,{passive:!0})},[]),b=ws(R=>{var _,$;if((_=l.resizeObserver)==null||_.disconnect(),!R)return;let j;l.resizeObserver=new ResizeObserver(([k])=>{const{height:N}=k.contentRect,x=N-(j??N);if(l.resizeDifference=x,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),a(l.isNearBottom),x>=0){const y=wr(i.current,j?i.current.resize:i.current.initial);u({animation:y,wait:!0,preserveScrollPosition:!0,duration:y==="instant"?void 0:sx})}else l.isNearBottom&&(c(!1),f(!0));j=N,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===x&&(l.resizeDifference=0)},1)})}),($=l.resizeObserver)==null||$.observe(R)},[]);return{contentRef:b,scrollRef:C,scrollToBottom:u,stopScroll:p,isAtBottom:r||s,isNearBottom:s,escapedFromLock:t,state:l}};function ws(e,t){const n=m.useCallback(r=>(n.current=r,e(r)),t);return n}const br=new Map;function wr(...e){const t={...nx};let n=!1;for(const o of e){if(o==="instant"){n=!0;continue}typeof o=="object"&&(n=!1,t.damping=o.damping??t.damping,t.stiffness=o.stiffness??t.stiffness,t.mass=o.mass??t.mass)}const r=JSON.stringify(t);return br.has(r)||br.set(r,Object.freeze(t)),n?"instant":br.get(r)}/*!---------------------------------------------------------------------------------------------
254
+ *--------------------------------------------------------------------------------------------*/const rx={damping:.7,stiffness:.05,mass:1.25},ox=70,sx=1e3/60,ax=350;let or=!1;var Ts;(Ts=globalThis.document)==null||Ts.addEventListener("mousedown",()=>{or=!0});var Is;(Is=globalThis.document)==null||Is.addEventListener("mouseup",()=>{or=!1});var Ms;(Ms=globalThis.document)==null||Ms.addEventListener("click",()=>{or=!1});const ix=(e={})=>{const[t,n]=m.useState(!1),[r,o]=m.useState(e.initial!==!1),[s,a]=m.useState(!1),i=m.useRef(null);i.current=e;const h=m.useCallback(()=>{var _;if(!or)return!1;const R=window.getSelection();if(!R||!R.rangeCount)return!1;const j=R.getRangeAt(0);return j.commonAncestorContainer.contains(C.current)||((_=C.current)==null?void 0:_.contains(j.commonAncestorContainer))},[]),f=m.useCallback(R=>{l.isAtBottom=R,o(R)},[]),c=m.useCallback(R=>{l.escapedFromLock=R,n(R)},[]),l=m.useMemo(()=>{let R;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){var j;return((j=C.current)==null?void 0:j.scrollTop)??0},set scrollTop(j){if(C.current){const{scrollBehavior:_}=getComputedStyle(C.current);_!=="auto"&&(C.current.style.scrollBehavior="auto"),C.current.scrollTop=j,l.ignoreScrollToTop=C.current.scrollTop,_!=="auto"&&(C.current.style.scrollBehavior=_)}},get targetScrollTop(){return!C.current||!y.current?0:C.current.scrollHeight-1-C.current.clientHeight},get calculatedTargetScrollTop(){if(!C.current||!y.current)return 0;const{targetScrollTop:j}=this;if(!e.targetScrollTop)return j;if((R==null?void 0:R.targetScrollTop)===j)return R.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(j,{scrollElement:C.current,contentElement:y.current}),j),0);return R={targetScrollTop:j,calculatedScrollTop:_},requestAnimationFrame(()=>{R=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ox}}},[]),u=m.useCallback((R={})=>{var b;typeof R=="string"&&(R={animation:R}),R.preserveScrollPosition||f(!0);const j=Date.now()+(Number(R.wait)||0),_=wr(i.current,R.animation),{ignoreEscapes:$=!1}=R;let k,N=l.calculatedTargetScrollTop;R.duration instanceof Promise?R.duration.finally(()=>{k=Date.now()}):k=j+(R.duration??0);const x=async()=>{const A=new Promise(requestAnimationFrame).then(()=>{var M;if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:O}=l,P=performance.now(),F=(P-(l.lastTick??P))/sx;if(l.animation||(l.animation={behavior:_,promise:A,ignoreEscapes:$}),l.animation.behavior===_&&(l.lastTick=P),h()||j>Date.now())return x();if(O<Math.min(N,l.calculatedTargetScrollTop)){if(((M=l.animation)==null?void 0:M.behavior)===_){if(_==="instant")return l.scrollTop=l.calculatedTargetScrollTop,x();l.velocity=(_.damping*l.velocity+_.stiffness*l.scrollDifference)/_.mass,l.accumulated+=l.velocity*F,l.scrollTop+=l.accumulated,l.scrollTop!==O&&(l.accumulated=0)}return x()}return k>Date.now()?(N=l.calculatedTargetScrollTop,x()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?u({animation:wr(i.current,i.current.resize),ignoreEscapes:$,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return A.then(O=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),O))};return R.wait!==!0&&(l.animation=void 0),((b=l.animation)==null?void 0:b.behavior)===_?l.animation.promise:x()},[f,h,l]),p=m.useCallback(()=>{c(!0),f(!1)},[c,f]),g=m.useCallback(({target:R})=>{if(R!==C.current)return;const{scrollTop:j,ignoreScrollToTop:_}=l;let{lastScrollTop:$=j}=l;l.lastScrollTop=j,l.ignoreScrollToTop=void 0,_&&_>j&&($=_),a(l.isNearBottom),setTimeout(()=>{var x;if(l.resizeDifference||j===_)return;if(h()){c(!0),f(!1);return}const k=j>$,N=j<$;if((x=l.animation)!=null&&x.ignoreEscapes){l.scrollTop=$;return}N&&(c(!0),f(!1)),k&&c(!1),!l.escapedFromLock&&l.isNearBottom&&f(!0)},1)},[c,f,h,l]),v=m.useCallback(({target:R,deltaY:j})=>{var $;let _=R;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===C.current&&j<0&&C.current.scrollHeight>C.current.clientHeight&&!(($=l.animation)!=null&&$.ignoreEscapes)&&(c(!0),f(!1))},[c,f,l]),C=ws(R=>{var j,_;(j=C.current)==null||j.removeEventListener("scroll",g),(_=C.current)==null||_.removeEventListener("wheel",v),R==null||R.addEventListener("scroll",g,{passive:!0}),R==null||R.addEventListener("wheel",v,{passive:!0})},[]),y=ws(R=>{var _,$;if((_=l.resizeObserver)==null||_.disconnect(),!R)return;let j;l.resizeObserver=new ResizeObserver(([k])=>{const{height:N}=k.contentRect,x=N-(j??N);if(l.resizeDifference=x,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),a(l.isNearBottom),x>=0){const b=wr(i.current,j?i.current.resize:i.current.initial);u({animation:b,wait:!0,preserveScrollPosition:!0,duration:b==="instant"?void 0:ax})}else l.isNearBottom&&(c(!1),f(!0));j=N,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===x&&(l.resizeDifference=0)},1)})}),($=l.resizeObserver)==null||$.observe(R)},[]);return{contentRef:y,scrollRef:C,scrollToBottom:u,stopScroll:p,isAtBottom:r||s,isNearBottom:s,escapedFromLock:t,state:l}};function ws(e,t){const n=m.useCallback(r=>(n.current=r,e(r)),t);return n}const yr=new Map;function wr(...e){const t={...rx};let n=!1;for(const o of e){if(o==="instant"){n=!0;continue}typeof o=="object"&&(n=!1,t.damping=o.damping??t.damping,t.stiffness=o.stiffness??t.stiffness,t.mass=o.mass??t.mass)}const r=JSON.stringify(t);return yr.has(r)||yr.set(r,Object.freeze(t)),n?"instant":yr.get(r)}/*!---------------------------------------------------------------------------------------------
255
255
  * Copyright (c) StackBlitz. All rights reserved.
256
256
  * Licensed under the MIT License. See License.txt in the project root for license information.
257
- *--------------------------------------------------------------------------------------------*/const Nl=m.createContext(null),ix=typeof window<"u"?m.useLayoutEffect:m.useEffect;function zn({instance:e,children:t,resize:n,initial:r,mass:o,damping:s,stiffness:a,targetScrollTop:i,contextRef:h,...f}){const c=m.useRef(null),l=m.useCallback(($,k)=>{const N=(_==null?void 0:_.targetScrollTop)??i;return(N==null?void 0:N($,k))??$},[i]),u=ax({mass:o,damping:s,stiffness:a,resize:n,initial:r,targetScrollTop:l}),{scrollRef:p,contentRef:g,scrollToBottom:v,stopScroll:C,isAtBottom:b,escapedFromLock:R,state:j}=e??u,_=m.useMemo(()=>({scrollToBottom:v,stopScroll:C,scrollRef:p,isAtBottom:b,escapedFromLock:R,contentRef:g,state:j,get targetScrollTop(){return c.current},set targetScrollTop($){c.current=$}}),[v,b,g,p,C,R,j]);return m.useImperativeHandle(h,()=>_,[_]),ix(()=>{p.current&&getComputedStyle(p.current).overflow==="visible"&&(p.current.style.overflow="auto")},[]),m.createElement(Nl.Provider,{value:_},m.createElement("div",{...f},typeof t=="function"?t(_):t))}(function(e){function t({children:n,scrollClassName:r,...o}){const s=Mo();return m.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},m.createElement("div",{...o,ref:s.contentRef},typeof n=="function"?n(s):n))}e.Content=t})(zn||(zn={}));function Mo(){const e=m.useContext(Nl);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}const lx=({className:e,...t})=>d.jsx(zn,{className:Z("relative flex-1 overflow-y-hidden overflow-x-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),cx=({className:e,...t})=>d.jsx(zn.Content,{className:Z("mx-auto flex max-w-3xl flex-col gap-2 px-4 py-8 sm:px-8 sm:py-12 min-w-0",e),...t}),dx=({className:e,title:t="No messages yet",description:n="Start a conversation to see messages here",icon:r,children:o,...s})=>d.jsx("div",{className:Z("flex size-full flex-col items-center justify-center gap-4 p-8 text-center",e),...s,children:o??d.jsxs(d.Fragment,{children:[r&&d.jsx("div",{className:"text-text-muted",children:r}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h3",{className:"font-semibold text-base font-display text-text-primary",children:t}),n&&d.jsx("p",{className:"text-text-muted text-sm leading-relaxed max-w-xs",children:n})]})]})}),ux=({className:e,...t})=>{const{scrollToBottom:n}=Mo(),r=m.useCallback(()=>{n()},[n]);return d.jsx(Et,{className:Z("rounded-full",e),onClick:r,size:"icon",type:"button",variant:"outline",title:"Scroll to bottom",...t,children:d.jsx(cd,{className:"size-4"})})},fx="data-last-user-message",hx=({className:e,...t})=>{const n=m.useCallback(()=>{const r=document.querySelector(`[${fx}="true"]`);r&&r.scrollIntoView({behavior:"smooth",block:"start"})},[]);return d.jsx(Et,{className:Z("rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",title:"Scroll to last user message",...t,children:d.jsx(aa,{className:"size-4"})})},mx=({className:e,hasUserMessages:t=!1,...n})=>{const{isAtBottom:r}=Mo();return r?null:d.jsxs("div",{className:Z("absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2",e),...n,children:[t&&d.jsx(hx,{}),d.jsx(ux,{})]})};function px({entries:e,isLoading:t=!1,onPermissionRespond:n,emptyTitle:r="开始对话",emptyDescription:o="输入消息开始聊天"}){var h;const s=vx(e),a=e.length>0,i=t&&e.length>0&&((h=e[e.length-1])==null?void 0:h.type)==="user_message";return d.jsx(lx,{className:"flex-1",children:d.jsxs(cx,{children:[a?d.jsxs(d.Fragment,{children:[s.map((f,c)=>f.type==="single"?d.jsx("div",{className:Z(gx(e,c)),children:d.jsx(xx,{entry:f.entry,isLoading:t,onPermissionRespond:n})},`entry-${c}`):d.jsx("div",{className:"-mt-2",children:d.jsx(El,{entries:f.entries,onPermissionRespond:n})},`group-${c}`)),i&&d.jsxs("div",{className:"flex gap-4 items-start",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:d.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:28,height:28,className:"object-contain",draggable:!1})}),d.jsx("div",{className:"flex items-center gap-1 pt-2",children:d.jsxs("span",{className:"chat-typing-indicator","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})})]})]}):d.jsx(dx,{title:r,description:o}),d.jsx(mx,{hasUserMessages:e.some(f=>f.type==="user_message")})]})})}function gx(e,t){const n=e[t];if((n==null?void 0:n.type)==="user_message")return"pt-10 pb-3";if((n==null?void 0:n.type)==="assistant_message"){const r=e[t+1];return(r==null?void 0:r.type)==="tool_call"?"pt-3 pb-1":"pt-3 pb-8"}return(n==null?void 0:n.type)==="plan"?"pt-3 pb-3":(n==null?void 0:n.type)==="command_output"?"pt-6 pb-3":"py-2"}function xx({entry:e,isLoading:t,onPermissionRespond:n}){switch(e.type){case"user_message":return d.jsx(Ug,{entry:e});case"assistant_message":return d.jsx(zg,{entry:e,isStreaming:t});case"tool_call":return d.jsx(El,{entries:[e],onPermissionRespond:n});case"plan":return d.jsx(Qg,{entry:e});case"command_output":return d.jsx(tx,{entry:e});default:return null}}function vx(e){const t=[];let n=[];const r=()=>{n.length===1?t.push({type:"single",entry:n[0]}):n.length>1&&t.push({type:"tool_group",entries:n}),n=[]};for(const o of e)o.type==="tool_call"?n.push(o):(r(),t.push({type:"single",entry:o}));return r(),t}function yx(e,t){return e?t.toLowerCase().startsWith(e.toLowerCase()):!0}function bx({commands:e,filter:t,onSelect:n,onClose:r,className:o}){const s=m.useRef(null),[a,i]=m.useState(0),h=m.useMemo(()=>t?e.filter(f=>yx(t,f.name)):e,[e,t]);return m.useEffect(()=>{i(0)},[t]),m.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&r()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r]),m.useEffect(()=>{const f=c=>{if(h.length!==0){if(c.key==="ArrowDown")c.preventDefault(),i(l=>(l+1)%h.length);else if(c.key==="ArrowUp")c.preventDefault(),i(l=>(l-1+h.length)%h.length);else if(c.key==="Enter"&&!c.shiftKey){c.preventDefault();const l=h[a];l&&n(l)}}};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[h,a,n]),m.useEffect(()=>{const f=s.current;if(!f)return;const c=f.querySelector("[data-active='true']");c==null||c.scrollIntoView({block:"nearest"})},[a]),d.jsx("div",{ref:s,className:Z("rounded-xl border border-border bg-surface-2 shadow-lg",o),children:d.jsx("div",{className:"max-h-[320px] overflow-y-auto py-1",children:h.length===0?d.jsx("div",{className:"text-xs text-text-muted font-display py-3 text-center",children:"没有匹配的命令"}):h.map((f,c)=>{var l;return d.jsxs("button",{type:"button","data-active":c===a,onClick:()=>n(f),onMouseEnter:()=>i(c),className:Z("flex w-full items-center gap-2 px-3 py-2 cursor-pointer rounded-lg mx-1 text-left","transition-colors",c===a?"bg-brand/10 text-text-primary":"text-text-secondary hover:bg-surface-1/50"),style:{width:"calc(100% - 8px)"},children:[d.jsxs("span",{className:"text-sm font-display font-medium text-brand",children:["/",f.name]}),d.jsx("span",{className:"text-xs text-text-muted truncate flex-1",children:f.description}),((l=f.input)==null?void 0:l.hint)&&d.jsx("span",{className:"text-[10px] text-text-muted italic",children:f.input.hint})]},f.name)})})})}function bt(e,t){const n=t===void 0?e:`${e}: ${JSON.stringify(t)}`;console.log(n);try{fetch("/code/__debug__",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:e,data:t??null})})}catch{}}const wx={maxSizeMB:2,maxWidthOrHeight:2048,useWebWorker:!0,fileType:"image/jpeg"},Cx=500*1024,jl=2*1024*1024,Cr=200,Cs=5*1024*1024,Sx=new Set([".txt",".md",".markdown",".rst",".json",".jsonl",".yaml",".yml",".toml",".xml",".html",".htm",".csv",".tsv",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".rb",".go",".rs",".java",".kt",".kts",".c",".h",".cc",".cpp",".hpp",".cxx",".cs",".swift",".m",".mm",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".css",".scss",".sass",".less",".styl",".vue",".svelte",".astro",".lua",".r",".R",".jl",".ex",".exs",".erl",".hs",".ml",".php",".pl",".pm",".dockerfile",".makefile",".cmake",".gitignore",".env",".editorconfig",".prettierrc",".eslintrc",".log",".diff",".patch",".ini",".cfg",".conf",".proto",".thrift",".tf",".hcl",".sol"]),kx=new Set([".csv",".tsv",".xlsx",".xls"]);function rn(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}function Al(e){if(e.type.startsWith("text/"))return!0;const t=rn(e.name);return Sx.has(t)}function Wr(e){const t=rn(e.name);return kx.has(t)}function _x({onSubmit:e,isLoading:t=!1,onInterrupt:n,disabled:r=!1,placeholder:o="给 Saluzi 发送消息…",supportsAttachments:s,supportsImages:a,commands:i,className:h}){const f=s??a??!1,[c,l]=m.useState(""),[u,p]=m.useState([]),[g,v]=m.useState([]),[C,b]=m.useState(!1),[R,j]=m.useState(""),[_,$]=m.useState(!1),[k,N]=m.useState(!1),[x,y]=m.useState(!1),A=m.useRef(null),O=m.useRef(null),P=m.useRef(null),F=m.useRef(null),M=m.useRef(null),D=m.useRef(null),S=m.useRef(null);m.useEffect(()=>{bt("[ChatInput] mount/supportsAttachments change",{supportsAttachments:f,commandsCount:(i==null?void 0:i.length)??0})},[f,i]),m.useEffect(()=>{if(!k)return;const H=q=>{var oe,he;const J=q.target,te=(oe=D.current)==null?void 0:oe.contains(J),ie=(he=S.current)==null?void 0:he.contains(J);!te&&!ie&&N(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[k]);const w=m.useCallback(H=>{const q=(H??c).trim(),J=u.length>0||g.length>0;!q&&!J||r||x||(e({text:q,images:u.length>0?u:void 0,attachments:g.length>0?g:void 0}),l(""),p([]),v([]),b(!1),j(""),A.current&&(A.current.style.height="auto"))},[c,u,g,r,x,e]),L=m.useCallback(H=>{if(C){if(H.key==="Escape"){H.preventDefault(),b(!1);return}if(H.key==="ArrowUp"||H.key==="ArrowDown"||H.key==="Enter"){H.preventDefault();return}if(H.key==="Tab"){H.preventDefault(),b(!1);return}}H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),t?n==null||n():w())},[w,t,n,C]),E=m.useCallback(H=>{const q=H.target.value;l(q),q.startsWith("/")&&i&&i.length>0?(b(!0),j(q.slice(1).split(/\s/)[0]||"")):C&&(b(!1),j(""));const J=H.target;J.style.height="auto",J.style.height=Math.min(J.scrollHeight,200)+"px"},[i,C]),I=m.useCallback(async H=>{if(bt("[ChatInput] paste event",{canAttach:f,files:H.clipboardData.files.length,types:H.clipboardData.types}),!f)return;const q=Array.from(H.clipboardData.files).filter(J=>J.type.startsWith("image/"));if(bt("[ChatInput] paste image files",{count:q.length,types:q.map(J=>J.type)}),q.length!==0){H.preventDefault(),y(!0);try{const J=await Sr(q);p(te=>[...te,...J])}finally{y(!1)}}},[f]),W=m.useCallback(async()=>{if(!O.current)return;const H=O.current.files;if(!(!H||H.length===0)){y(!0);try{const q=await Sr(Array.from(H));p(J=>[...J,...q])}finally{O.current.value="",y(!1)}}},[]),T=m.useCallback(async()=>{if(!P.current)return;const H=P.current.files;if(!(!H||H.length===0)){y(!0);try{const q=await Ss(Array.from(H));v(J=>[...J,...q])}finally{P.current.value="",y(!1)}}},[]),B=m.useCallback(async()=>{if(!F.current)return;const H=F.current.files;if(!(!H||H.length===0)){y(!0);try{const q=await ks(Array.from(H));v(J=>[...J,...q])}finally{F.current.value="",y(!1)}}},[]),z=m.useCallback(async()=>{if(!M.current)return;const H=M.current.files;if(!(!H||H.length===0)){y(!0);try{const q=await Nx(Array.from(H));q&&v(J=>[...J,q])}finally{M.current.value="",y(!1)}}},[]),U=m.useCallback(H=>{p(q=>q.filter((J,te)=>te!==H))},[]),V=m.useCallback(H=>{v(q=>q.filter((J,te)=>te!==H))},[]),G=m.useCallback(H=>{var J,te;b(!1),j("");const q=`/${H.name}`;(J=H.input)!=null&&J.hint?(l(`${q} `),(te=A.current)==null||te.focus()):w(q)},[w]),X=m.useCallback(H=>{f&&Array.from(H.dataTransfer.types).includes("Files")&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",_||$(!0))},[f,_]),K=m.useCallback(H=>{const q=H.relatedTarget;(!q||!H.currentTarget.contains(q))&&$(!1)},[]),ne=m.useCallback(async H=>{if(!f)return;const q=Array.from(H.dataTransfer.files);if(q.length!==0){H.preventDefault(),$(!1),y(!0);try{const J=q.filter(oe=>oe.type.startsWith("image/")),te=q.filter(oe=>!oe.type.startsWith("image/")&&Wr(oe)),ie=q.filter(oe=>!oe.type.startsWith("image/")&&!Wr(oe)&&Al(oe));if(J.length>0){const oe=await Sr(J);p(he=>[...he,...oe])}if(te.length>0){const oe=await ks(te);v(he=>[...he,...oe])}if(ie.length>0){const oe=await Ss(ie);v(he=>[...he,...oe])}}finally{y(!1)}}},[f]),ae=m.useCallback(()=>{var H;C?(b(!1),j("")):(c.startsWith("/")||l("/"+c),b(!0),j(c.startsWith("/")&&c.slice(1).split(/\s/)[0]||""),(H=A.current)==null||H.focus())},[C,c]),de=u.length+g.length,me=(c.trim()||de>0)&&!r&&!x;return d.jsxs("div",{className:Z("w-full max-w-3xl mx-auto px-4 sm:px-8 pb-4 pt-2",h),children:[d.jsxs("div",{className:"relative",children:[C&&i&&i.length>0&&d.jsx(bx,{commands:i,filter:R,onSelect:G,onClose:()=>{b(!1),j("")},className:"absolute bottom-full left-0 right-0 mb-1 z-50"}),k&&f&&d.jsxs("div",{ref:D,className:"absolute bottom-full left-3 mb-2 min-w-[180px] rounded-lg border border-border bg-surface-2 shadow-lg py-1 z-50",children:[d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=O.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(jd,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"图片"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=P.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Zt,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"文本文件"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=F.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Zr,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"表格文件"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=M.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Xr,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"目录"})]})]}),d.jsxs("div",{onDragOver:X,onDragLeave:K,onDrop:ne,className:Z("rounded-xl border border-border bg-surface-2 overflow-hidden","focus-within:border-brand/50 focus-within:shadow-[0_0_0_3px_#7D5A8A] transition-all",_&&"border-brand ring-2 ring-brand/40 bg-brand/5"),children:[u.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3",children:u.map((H,q)=>d.jsxs("div",{className:"relative group",children:[d.jsx("img",{src:`data:${H.mimeType};base64,${H.data}`,alt:`Attached image ${q+1}`,className:"h-14 w-14 object-cover rounded-lg border border-border"}),d.jsx("button",{type:"button",onClick:()=>U(q),className:"absolute -top-1.5 -right-1.5 min-h-[32px] min-w-[32px] h-5 w-5 rounded-full bg-surface-2 border border-border flex items-center justify-center text-text-muted hover:text-text-primary text-xs opacity-0 group-hover:opacity-100 transition-opacity","aria-label":`Remove image ${q+1}`,children:"×"})]},q))}),g.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3",children:g.map((H,q)=>d.jsx(Ex,{attachment:H,onRemove:()=>V(q)},q))}),d.jsxs("div",{className:"flex items-end gap-2 px-3 py-2.5",children:[f&&d.jsxs("div",{className:"relative flex-shrink-0",children:[d.jsxs("button",{ref:S,type:"button",onClick:()=>N(H=>!H),disabled:r||x,className:Z("h-8 w-8 flex items-center justify-center rounded-lg transition-colors",k?"bg-brand/15 text-brand":"text-text-muted hover:text-text-secondary hover:bg-surface-1/50"),children:[d.jsx(Wd,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Attach"})]}),d.jsx("input",{ref:O,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:W}),d.jsx("input",{ref:P,type:"file",accept:[".txt",".md",".markdown",".rst",".json",".jsonl",".yaml",".yml",".toml",".xml",".html",".htm",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".rb",".go",".rs",".java",".kt",".c",".h",".cc",".cpp",".hpp",".cs",".swift",".sh",".bash",".zsh",".sql",".graphql",".gql",".css",".scss",".sass",".less",".vue",".svelte",".lua",".r",".jl",".ex",".exs",".php",".pl",".dockerfile",".makefile",".gitignore",".env",".editorconfig",".log",".diff",".patch",".ini",".cfg",".conf",".proto",".tf",".hcl",".sol","text/*"].join(","),multiple:!0,className:"hidden",onChange:T}),d.jsx("input",{ref:F,type:"file",accept:".csv,.tsv,.xlsx,.xls",multiple:!0,className:"hidden",onChange:B}),d.jsx("input",{ref:M,type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",onChange:z})]}),i&&i.length>0&&d.jsx("button",{type:"button",onClick:ae,className:Z("flex-shrink-0 h-8 w-8 flex items-center justify-center rounded-lg transition-colors",C?"bg-brand/15 text-brand":"text-text-muted hover:text-text-secondary hover:bg-surface-1/50"),disabled:r,title:"命令列表",children:d.jsx(au,{className:"h-4 w-4"})}),d.jsx("textarea",{ref:A,value:c,onChange:E,onKeyDown:L,onPaste:I,placeholder:x?"处理文件中…":o,disabled:r,rows:1,className:Z("flex-1 resize-none border-none bg-transparent outline-none","text-sm text-text-primary placeholder:text-text-muted font-display","max-h-[200px] min-h-[24px] leading-normal")}),d.jsx("button",{type:"button",onClick:t?n:()=>w(),disabled:!t&&!me,className:Z("flex-shrink-0 h-8 w-8 flex items-center justify-center rounded-lg transition-all",t?"bg-text-primary text-surface-2 hover:bg-text-secondary":me?"bg-brand text-white hover:bg-brand-light hover:scale-[1.05] active:scale-[0.97]":"bg-surface-1 text-text-muted"),children:t?d.jsx(du,{className:"h-3.5 w-3.5",fill:"currentColor"}):x?d.jsx("div",{className:"h-3.5 w-3.5 border-2 border-current border-t-transparent rounded-full animate-spin"}):d.jsx(Zd,{className:"h-4 w-4"})})]})]})]}),d.jsx("div",{className:"text-center mt-1.5",children:d.jsx("span",{className:"text-[11px] text-text-muted font-display",children:"Enter 发送,Shift+Enter 换行"})})]})}function Ex({attachment:e,onRemove:t}){const n=(()=>{switch(e.kind){case"text":return d.jsx(Zt,{className:"h-3.5 w-3.5"});case"table":return d.jsx(Zr,{className:"h-3.5 w-3.5"});case"directory":return d.jsx(Xr,{className:"h-3.5 w-3.5"});default:return d.jsx(Zt,{className:"h-3.5 w-3.5"})}})(),r=e.size!=null?Ot(e.size):null,o=e.kind==="directory"&&e.files?e.files.length:null;return d.jsxs("div",{className:"group flex items-center gap-1.5 rounded-lg border border-border bg-surface-1/50 px-2.5 py-1.5 text-xs text-text-secondary",children:[n,d.jsx("span",{className:"max-w-[120px] truncate font-mono",title:e.name,children:e.name}),r&&d.jsx("span",{className:"text-text-muted text-[10px]",children:r}),o!=null&&d.jsxs("span",{className:"text-text-muted text-[10px]",children:[o," 文件"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-0.5 min-h-[20px] min-w-[20px] h-4 w-4 flex items-center justify-center rounded text-text-muted hover:text-text-primary opacity-0 group-hover:opacity-100 transition-opacity","aria-label":`Remove ${e.name}`,children:d.jsx(an,{className:"h-3 w-3"})})]})}function Ot(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Sr(e){const t=[];for(const n of e)try{let r=n,o=n.type;n.size>2*1024*1024&&(r=await ye(n,wx),o="image/jpeg");const s=await jx(r);t.push({mimeType:o,data:s})}catch(r){console.error("Failed to process image:",r)}return t}async function Ss(e){const t=[];for(const n of e)try{if(n.size>jl){console.warn(`Skipping ${n.name}: too large (${Ot(n.size)})`);continue}n.size>Cx&&console.warn(`File ${n.name} is large (${Ot(n.size)}), may slow down`);const r=await n.text();t.push({kind:"text",name:n.name,size:n.size,textContent:r,mimeType:n.type||"text/plain"})}catch(r){console.error(`Failed to read text file ${n.name}:`,r)}return t}async function ks(e){const t=[];for(const n of e)try{const r=rn(n.name);if(r===".csv"||r===".tsv"){const o=await n.text();t.push({kind:"table",name:n.name,size:n.size,textContent:o,mimeType:n.type||"text/csv"})}else if(r===".xlsx"||r===".xls"){const o=await n.arrayBuffer(),s=await Rl(o);t.push({kind:"table",name:n.name,size:n.size,textContent:s,mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}}catch(r){console.error(`Failed to process table file ${n.name}:`,r)}return t}async function Rl(e){const t=await on(()=>import("./xlsx-CkFp8p6R.js"),[]),n=t.read(e,{type:"array"}),r=[];for(const o of n.SheetNames){const s=n.Sheets[o];if(!s)continue;const a=t.utils.sheet_to_csv(s);n.SheetNames.length>1?r.push(`## Sheet: ${o}
257
+ *--------------------------------------------------------------------------------------------*/const Nl=m.createContext(null),lx=typeof window<"u"?m.useLayoutEffect:m.useEffect;function zn({instance:e,children:t,resize:n,initial:r,mass:o,damping:s,stiffness:a,targetScrollTop:i,contextRef:h,...f}){const c=m.useRef(null),l=m.useCallback(($,k)=>{const N=(_==null?void 0:_.targetScrollTop)??i;return(N==null?void 0:N($,k))??$},[i]),u=ix({mass:o,damping:s,stiffness:a,resize:n,initial:r,targetScrollTop:l}),{scrollRef:p,contentRef:g,scrollToBottom:v,stopScroll:C,isAtBottom:y,escapedFromLock:R,state:j}=e??u,_=m.useMemo(()=>({scrollToBottom:v,stopScroll:C,scrollRef:p,isAtBottom:y,escapedFromLock:R,contentRef:g,state:j,get targetScrollTop(){return c.current},set targetScrollTop($){c.current=$}}),[v,y,g,p,C,R,j]);return m.useImperativeHandle(h,()=>_,[_]),lx(()=>{p.current&&getComputedStyle(p.current).overflow==="visible"&&(p.current.style.overflow="auto")},[]),m.createElement(Nl.Provider,{value:_},m.createElement("div",{...f},typeof t=="function"?t(_):t))}(function(e){function t({children:n,scrollClassName:r,...o}){const s=Mo();return m.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},m.createElement("div",{...o,ref:s.contentRef},typeof n=="function"?n(s):n))}e.Content=t})(zn||(zn={}));function Mo(){const e=m.useContext(Nl);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}const cx=({className:e,...t})=>d.jsx(zn,{className:Z("relative flex-1 overflow-y-hidden overflow-x-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),dx=({className:e,...t})=>d.jsx(zn.Content,{className:Z("mx-auto flex max-w-3xl flex-col gap-2 px-4 py-8 sm:px-8 sm:py-12 min-w-0",e),...t}),ux=({className:e,title:t="No messages yet",description:n="Start a conversation to see messages here",icon:r,children:o,...s})=>d.jsx("div",{className:Z("flex size-full flex-col items-center justify-center gap-4 p-8 text-center",e),...s,children:o??d.jsxs(d.Fragment,{children:[r&&d.jsx("div",{className:"text-text-muted",children:r}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h3",{className:"font-semibold text-base font-display text-text-primary",children:t}),n&&d.jsx("p",{className:"text-text-muted text-sm leading-relaxed max-w-xs",children:n})]})]})}),fx=({className:e,...t})=>{const{scrollToBottom:n}=Mo(),r=m.useCallback(()=>{n()},[n]);return d.jsx(Et,{className:Z("rounded-full",e),onClick:r,size:"icon",type:"button",variant:"outline",title:"Scroll to bottom",...t,children:d.jsx(cd,{className:"size-4"})})},hx="data-last-user-message",mx=({className:e,...t})=>{const n=m.useCallback(()=>{const r=document.querySelector(`[${hx}="true"]`);r&&r.scrollIntoView({behavior:"smooth",block:"start"})},[]);return d.jsx(Et,{className:Z("rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",title:"Scroll to last user message",...t,children:d.jsx(aa,{className:"size-4"})})},px=({className:e,hasUserMessages:t=!1,...n})=>{const{isAtBottom:r}=Mo();return r?null:d.jsxs("div",{className:Z("absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2",e),...n,children:[t&&d.jsx(mx,{}),d.jsx(fx,{})]})};function gx({entries:e,isLoading:t=!1,onPermissionRespond:n,emptyTitle:r="开始对话",emptyDescription:o="输入消息开始聊天"}){var h;const s=bx(e),a=e.length>0,i=t&&e.length>0&&((h=e[e.length-1])==null?void 0:h.type)==="user_message";return d.jsx(cx,{className:"flex-1",children:d.jsxs(dx,{children:[a?d.jsxs(d.Fragment,{children:[s.map((f,c)=>f.type==="single"?d.jsx("div",{className:Z(xx(e,c)),children:d.jsx(vx,{entry:f.entry,isLoading:t,onPermissionRespond:n})},`entry-${c}`):d.jsx("div",{className:"-mt-2",children:d.jsx(El,{entries:f.entries,onPermissionRespond:n})},`group-${c}`)),i&&d.jsxs("div",{className:"flex gap-4 items-start",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:d.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:28,height:28,className:"object-contain",draggable:!1})}),d.jsx("div",{className:"flex items-center gap-1 pt-2",children:d.jsxs("span",{className:"chat-typing-indicator","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})})]})]}):d.jsx(ux,{title:r,description:o}),d.jsx(px,{hasUserMessages:e.some(f=>f.type==="user_message")})]})})}function xx(e,t){const n=e[t];if((n==null?void 0:n.type)==="user_message")return"pt-10 pb-3";if((n==null?void 0:n.type)==="assistant_message"){const r=e[t+1];return(r==null?void 0:r.type)==="tool_call"?"pt-3 pb-1":"pt-3 pb-8"}return(n==null?void 0:n.type)==="plan"?"pt-3 pb-3":(n==null?void 0:n.type)==="command_output"?"pt-6 pb-3":"py-2"}function vx({entry:e,isLoading:t,onPermissionRespond:n}){switch(e.type){case"user_message":return d.jsx(zg,{entry:e});case"assistant_message":return d.jsx(Bg,{entry:e,isStreaming:t});case"tool_call":return d.jsx(El,{entries:[e],onPermissionRespond:n});case"plan":return d.jsx(Zg,{entry:e});case"command_output":return d.jsx(nx,{entry:e});default:return null}}function bx(e){const t=[];let n=[];const r=()=>{n.length===1?t.push({type:"single",entry:n[0]}):n.length>1&&t.push({type:"tool_group",entries:n}),n=[]};for(const o of e)o.type==="tool_call"?n.push(o):(r(),t.push({type:"single",entry:o}));return r(),t}function yx(e,t){return e?t.toLowerCase().startsWith(e.toLowerCase()):!0}function wx({commands:e,filter:t,onSelect:n,onClose:r,className:o}){const s=m.useRef(null),[a,i]=m.useState(0),h=m.useMemo(()=>t?e.filter(f=>yx(t,f.name)):e,[e,t]);return m.useEffect(()=>{i(0)},[t]),m.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&r()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r]),m.useEffect(()=>{const f=c=>{if(h.length!==0){if(c.key==="ArrowDown")c.preventDefault(),i(l=>(l+1)%h.length);else if(c.key==="ArrowUp")c.preventDefault(),i(l=>(l-1+h.length)%h.length);else if(c.key==="Enter"&&!c.shiftKey){c.preventDefault();const l=h[a];l&&n(l)}}};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[h,a,n]),m.useEffect(()=>{const f=s.current;if(!f)return;const c=f.querySelector("[data-active='true']");c==null||c.scrollIntoView({block:"nearest"})},[a]),d.jsx("div",{ref:s,className:Z("rounded-xl border border-border bg-surface-2 shadow-lg",o),children:d.jsx("div",{className:"max-h-[320px] overflow-y-auto py-1",children:h.length===0?d.jsx("div",{className:"text-xs text-text-muted font-display py-3 text-center",children:"没有匹配的命令"}):h.map((f,c)=>{var l;return d.jsxs("button",{type:"button","data-active":c===a,onClick:()=>n(f),onMouseEnter:()=>i(c),className:Z("flex w-full items-center gap-2 px-3 py-2 cursor-pointer rounded-lg mx-1 text-left","transition-colors",c===a?"bg-brand/10 text-text-primary":"text-text-secondary hover:bg-surface-1/50"),style:{width:"calc(100% - 8px)"},children:[d.jsxs("span",{className:"text-sm font-display font-medium text-brand",children:["/",f.name]}),d.jsx("span",{className:"text-xs text-text-muted truncate flex-1",children:f.description}),((l=f.input)==null?void 0:l.hint)&&d.jsx("span",{className:"text-[10px] text-text-muted italic",children:f.input.hint})]},f.name)})})})}function yt(e,t){const n=t===void 0?e:`${e}: ${JSON.stringify(t)}`;console.log(n);try{fetch("/code/__debug__",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:e,data:t??null})})}catch{}}const Cx={maxSizeMB:2,maxWidthOrHeight:2048,useWebWorker:!0,fileType:"image/jpeg"},Sx=500*1024,jl=2*1024*1024,Cr=200,Cs=5*1024*1024,kx=new Set([".txt",".md",".markdown",".rst",".json",".jsonl",".yaml",".yml",".toml",".xml",".html",".htm",".csv",".tsv",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".rb",".go",".rs",".java",".kt",".kts",".c",".h",".cc",".cpp",".hpp",".cxx",".cs",".swift",".m",".mm",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".css",".scss",".sass",".less",".styl",".vue",".svelte",".astro",".lua",".r",".R",".jl",".ex",".exs",".erl",".hs",".ml",".php",".pl",".pm",".dockerfile",".makefile",".cmake",".gitignore",".env",".editorconfig",".prettierrc",".eslintrc",".log",".diff",".patch",".ini",".cfg",".conf",".proto",".thrift",".tf",".hcl",".sol"]),_x=new Set([".csv",".tsv",".xlsx",".xls"]);function rn(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}function Al(e){if(e.type.startsWith("text/"))return!0;const t=rn(e.name);return kx.has(t)}function Wr(e){const t=rn(e.name);return _x.has(t)}function Ex({onSubmit:e,isLoading:t=!1,onInterrupt:n,disabled:r=!1,placeholder:o="给 Saluzi 发送消息…",supportsAttachments:s,supportsImages:a,commands:i,className:h}){const f=s??a??!1,[c,l]=m.useState(""),[u,p]=m.useState([]),[g,v]=m.useState([]),[C,y]=m.useState(!1),[R,j]=m.useState(""),[_,$]=m.useState(!1),[k,N]=m.useState(!1),[x,b]=m.useState(!1),A=m.useRef(null),O=m.useRef(null),P=m.useRef(null),F=m.useRef(null),M=m.useRef(null),D=m.useRef(null),S=m.useRef(null);m.useEffect(()=>{yt("[ChatInput] mount/supportsAttachments change",{supportsAttachments:f,commandsCount:(i==null?void 0:i.length)??0})},[f,i]),m.useEffect(()=>{if(!k)return;const H=q=>{var oe,he;const J=q.target,te=(oe=D.current)==null?void 0:oe.contains(J),ie=(he=S.current)==null?void 0:he.contains(J);!te&&!ie&&N(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[k]);const w=m.useCallback(H=>{const q=(H??c).trim(),J=u.length>0||g.length>0;!q&&!J||r||x||(e({text:q,images:u.length>0?u:void 0,attachments:g.length>0?g:void 0}),l(""),p([]),v([]),y(!1),j(""),A.current&&(A.current.style.height="auto"))},[c,u,g,r,x,e]),L=m.useCallback(H=>{if(C){if(H.key==="Escape"){H.preventDefault(),y(!1);return}if(H.key==="ArrowUp"||H.key==="ArrowDown"||H.key==="Enter"){H.preventDefault();return}if(H.key==="Tab"){H.preventDefault(),y(!1);return}}H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),t?n==null||n():w())},[w,t,n,C]),E=m.useCallback(H=>{const q=H.target.value;l(q),q.startsWith("/")&&i&&i.length>0?(y(!0),j(q.slice(1).split(/\s/)[0]||"")):C&&(y(!1),j(""));const J=H.target;J.style.height="auto",J.style.height=Math.min(J.scrollHeight,200)+"px"},[i,C]),I=m.useCallback(async H=>{if(yt("[ChatInput] paste event",{canAttach:f,files:H.clipboardData.files.length,types:H.clipboardData.types}),!f)return;const q=Array.from(H.clipboardData.files).filter(J=>J.type.startsWith("image/"));if(yt("[ChatInput] paste image files",{count:q.length,types:q.map(J=>J.type)}),q.length!==0){H.preventDefault(),b(!0);try{const J=await Sr(q);p(te=>[...te,...J])}finally{b(!1)}}},[f]),W=m.useCallback(async()=>{if(!O.current)return;const H=O.current.files;if(!(!H||H.length===0)){b(!0);try{const q=await Sr(Array.from(H));p(J=>[...J,...q])}finally{O.current.value="",b(!1)}}},[]),T=m.useCallback(async()=>{if(!P.current)return;const H=P.current.files;if(!(!H||H.length===0)){b(!0);try{const q=await Ss(Array.from(H));v(J=>[...J,...q])}finally{P.current.value="",b(!1)}}},[]),B=m.useCallback(async()=>{if(!F.current)return;const H=F.current.files;if(!(!H||H.length===0)){b(!0);try{const q=await ks(Array.from(H));v(J=>[...J,...q])}finally{F.current.value="",b(!1)}}},[]),z=m.useCallback(async()=>{if(!M.current)return;const H=M.current.files;if(!(!H||H.length===0)){b(!0);try{const q=await jx(Array.from(H));q&&v(J=>[...J,q])}finally{M.current.value="",b(!1)}}},[]),U=m.useCallback(H=>{p(q=>q.filter((J,te)=>te!==H))},[]),V=m.useCallback(H=>{v(q=>q.filter((J,te)=>te!==H))},[]),G=m.useCallback(H=>{var J,te;y(!1),j("");const q=`/${H.name}`;(J=H.input)!=null&&J.hint?(l(`${q} `),(te=A.current)==null||te.focus()):w(q)},[w]),X=m.useCallback(H=>{f&&Array.from(H.dataTransfer.types).includes("Files")&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",_||$(!0))},[f,_]),K=m.useCallback(H=>{const q=H.relatedTarget;(!q||!H.currentTarget.contains(q))&&$(!1)},[]),ne=m.useCallback(async H=>{if(!f)return;const q=Array.from(H.dataTransfer.files);if(q.length!==0){H.preventDefault(),$(!1),b(!0);try{const J=q.filter(oe=>oe.type.startsWith("image/")),te=q.filter(oe=>!oe.type.startsWith("image/")&&Wr(oe)),ie=q.filter(oe=>!oe.type.startsWith("image/")&&!Wr(oe)&&Al(oe));if(J.length>0){const oe=await Sr(J);p(he=>[...he,...oe])}if(te.length>0){const oe=await ks(te);v(he=>[...he,...oe])}if(ie.length>0){const oe=await Ss(ie);v(he=>[...he,...oe])}}finally{b(!1)}}},[f]),ae=m.useCallback(()=>{var H;C?(y(!1),j("")):(c.startsWith("/")||l("/"+c),y(!0),j(c.startsWith("/")&&c.slice(1).split(/\s/)[0]||""),(H=A.current)==null||H.focus())},[C,c]),de=u.length+g.length,me=(c.trim()||de>0)&&!r&&!x;return d.jsxs("div",{className:Z("w-full max-w-3xl mx-auto px-4 sm:px-8 pb-4 pt-2",h),children:[d.jsxs("div",{className:"relative",children:[C&&i&&i.length>0&&d.jsx(wx,{commands:i,filter:R,onSelect:G,onClose:()=>{y(!1),j("")},className:"absolute bottom-full left-0 right-0 mb-1 z-50"}),k&&f&&d.jsxs("div",{ref:D,className:"absolute bottom-full left-3 mb-2 min-w-[180px] rounded-lg border border-border bg-surface-2 shadow-lg py-1 z-50",children:[d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=O.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(jd,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"图片"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=P.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Zt,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"文本文件"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=F.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Zr,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"表格文件"})]}),d.jsxs("button",{type:"button",onClick:()=>{var H;N(!1),(H=M.current)==null||H.click()},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-text-primary hover:bg-surface-1 transition-colors text-left",children:[d.jsx(Xr,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"目录"})]})]}),d.jsxs("div",{onDragOver:X,onDragLeave:K,onDrop:ne,className:Z("rounded-xl border border-border bg-surface-2 overflow-hidden","focus-within:border-brand/50 focus-within:shadow-[0_0_0_3px_#7D5A8A] transition-all",_&&"border-brand ring-2 ring-brand/40 bg-brand/5"),children:[u.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3",children:u.map((H,q)=>d.jsxs("div",{className:"relative group",children:[d.jsx("img",{src:`data:${H.mimeType};base64,${H.data}`,alt:`Attached image ${q+1}`,className:"h-14 w-14 object-cover rounded-lg border border-border"}),d.jsx("button",{type:"button",onClick:()=>U(q),className:"absolute -top-1.5 -right-1.5 min-h-[32px] min-w-[32px] h-5 w-5 rounded-full bg-surface-2 border border-border flex items-center justify-center text-text-muted hover:text-text-primary text-xs opacity-0 group-hover:opacity-100 transition-opacity","aria-label":`Remove image ${q+1}`,children:"×"})]},q))}),g.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3",children:g.map((H,q)=>d.jsx(Nx,{attachment:H,onRemove:()=>V(q)},q))}),d.jsxs("div",{className:"flex items-end gap-2 px-3 py-2.5",children:[f&&d.jsxs("div",{className:"relative flex-shrink-0",children:[d.jsxs("button",{ref:S,type:"button",onClick:()=>N(H=>!H),disabled:r||x,className:Z("h-8 w-8 flex items-center justify-center rounded-lg transition-colors",k?"bg-brand/15 text-brand":"text-text-muted hover:text-text-secondary hover:bg-surface-1/50"),children:[d.jsx(Wd,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Attach"})]}),d.jsx("input",{ref:O,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:W}),d.jsx("input",{ref:P,type:"file",accept:[".txt",".md",".markdown",".rst",".json",".jsonl",".yaml",".yml",".toml",".xml",".html",".htm",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".rb",".go",".rs",".java",".kt",".c",".h",".cc",".cpp",".hpp",".cs",".swift",".sh",".bash",".zsh",".sql",".graphql",".gql",".css",".scss",".sass",".less",".vue",".svelte",".lua",".r",".jl",".ex",".exs",".php",".pl",".dockerfile",".makefile",".gitignore",".env",".editorconfig",".log",".diff",".patch",".ini",".cfg",".conf",".proto",".tf",".hcl",".sol","text/*"].join(","),multiple:!0,className:"hidden",onChange:T}),d.jsx("input",{ref:F,type:"file",accept:".csv,.tsv,.xlsx,.xls",multiple:!0,className:"hidden",onChange:B}),d.jsx("input",{ref:M,type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",onChange:z})]}),i&&i.length>0&&d.jsx("button",{type:"button",onClick:ae,className:Z("flex-shrink-0 h-8 w-8 flex items-center justify-center rounded-lg transition-colors",C?"bg-brand/15 text-brand":"text-text-muted hover:text-text-secondary hover:bg-surface-1/50"),disabled:r,title:"命令列表",children:d.jsx(au,{className:"h-4 w-4"})}),d.jsx("textarea",{ref:A,value:c,onChange:E,onKeyDown:L,onPaste:I,placeholder:x?"处理文件中…":o,disabled:r,rows:1,className:Z("flex-1 resize-none border-none bg-transparent outline-none","text-sm text-text-primary placeholder:text-text-muted font-display","max-h-[200px] min-h-[24px] leading-normal")}),d.jsx("button",{type:"button",onClick:t?n:()=>w(),disabled:!t&&!me,className:Z("flex-shrink-0 h-8 w-8 flex items-center justify-center rounded-lg transition-all",t?"bg-text-primary text-surface-2 hover:bg-text-secondary":me?"bg-brand text-white hover:bg-brand-light hover:scale-[1.05] active:scale-[0.97]":"bg-surface-1 text-text-muted"),children:t?d.jsx(du,{className:"h-3.5 w-3.5",fill:"currentColor"}):x?d.jsx("div",{className:"h-3.5 w-3.5 border-2 border-current border-t-transparent rounded-full animate-spin"}):d.jsx(Zd,{className:"h-4 w-4"})})]})]})]}),d.jsx("div",{className:"text-center mt-1.5",children:d.jsx("span",{className:"text-[11px] text-text-muted font-display",children:"Enter 发送,Shift+Enter 换行"})})]})}function Nx({attachment:e,onRemove:t}){const n=(()=>{switch(e.kind){case"text":return d.jsx(Zt,{className:"h-3.5 w-3.5"});case"table":return d.jsx(Zr,{className:"h-3.5 w-3.5"});case"directory":return d.jsx(Xr,{className:"h-3.5 w-3.5"});default:return d.jsx(Zt,{className:"h-3.5 w-3.5"})}})(),r=e.size!=null?Ot(e.size):null,o=e.kind==="directory"&&e.files?e.files.length:null;return d.jsxs("div",{className:"group flex items-center gap-1.5 rounded-lg border border-border bg-surface-1/50 px-2.5 py-1.5 text-xs text-text-secondary",children:[n,d.jsx("span",{className:"max-w-[120px] truncate font-mono",title:e.name,children:e.name}),r&&d.jsx("span",{className:"text-text-muted text-[10px]",children:r}),o!=null&&d.jsxs("span",{className:"text-text-muted text-[10px]",children:[o," 文件"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-0.5 min-h-[20px] min-w-[20px] h-4 w-4 flex items-center justify-center rounded text-text-muted hover:text-text-primary opacity-0 group-hover:opacity-100 transition-opacity","aria-label":`Remove ${e.name}`,children:d.jsx(an,{className:"h-3 w-3"})})]})}function Ot(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Sr(e){const t=[];for(const n of e)try{let r=n,o=n.type;n.size>2*1024*1024&&(r=await be(n,Cx),o="image/jpeg");const s=await Ax(r);t.push({mimeType:o,data:s})}catch(r){console.error("Failed to process image:",r)}return t}async function Ss(e){const t=[];for(const n of e)try{if(n.size>jl){console.warn(`Skipping ${n.name}: too large (${Ot(n.size)})`);continue}n.size>Sx&&console.warn(`File ${n.name} is large (${Ot(n.size)}), may slow down`);const r=await n.text();t.push({kind:"text",name:n.name,size:n.size,textContent:r,mimeType:n.type||"text/plain"})}catch(r){console.error(`Failed to read text file ${n.name}:`,r)}return t}async function ks(e){const t=[];for(const n of e)try{const r=rn(n.name);if(r===".csv"||r===".tsv"){const o=await n.text();t.push({kind:"table",name:n.name,size:n.size,textContent:o,mimeType:n.type||"text/csv"})}else if(r===".xlsx"||r===".xls"){const o=await n.arrayBuffer(),s=await Rl(o);t.push({kind:"table",name:n.name,size:n.size,textContent:s,mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}}catch(r){console.error(`Failed to process table file ${n.name}:`,r)}return t}async function Rl(e){const t=await on(()=>import("./xlsx-CkFp8p6R.js"),[]),n=t.read(e,{type:"array"}),r=[];for(const o of n.SheetNames){const s=n.Sheets[o];if(!s)continue;const a=t.utils.sheet_to_csv(s);n.SheetNames.length>1?r.push(`## Sheet: ${o}
258
258
 
259
259
  ${a}`):r.push(a)}return r.join(`
260
260
 
261
- `)}async function Nx(e){if(e.length===0)return null;const t=e.filter(u=>!(u.name.startsWith(".")||u.size>jl));t.length>Cr&&console.warn(`Directory has ${t.length} files, truncating to ${Cr}`);const n=t.slice(0,Cr);let r=0;for(const u of n)r+=u.size;r>Cs&&console.warn(`Directory total size ${Ot(r)} exceeds limit, some files may be truncated`);const o=n[0].webkitRelativePath,s=o&&o.split("/")[0]||"目录",a=[],i=[];let h=0;const f=[...n].sort((u,p)=>{const g=u.webkitRelativePath||u.name,v=p.webkitRelativePath||p.name;return g.localeCompare(v)});for(const u of f){const p=u.webkitRelativePath||u.name;if(a.push(p),Al(u)||Wr(u))if(h+u.size<=Cs)try{let g;if(rn(u.name)===".xlsx"||rn(u.name)===".xls"){const v=await u.arrayBuffer();g=await Rl(v)}else g=await u.text();i.push(`
261
+ `)}async function jx(e){if(e.length===0)return null;const t=e.filter(u=>!(u.name.startsWith(".")||u.size>jl));t.length>Cr&&console.warn(`Directory has ${t.length} files, truncating to ${Cr}`);const n=t.slice(0,Cr);let r=0;for(const u of n)r+=u.size;r>Cs&&console.warn(`Directory total size ${Ot(r)} exceeds limit, some files may be truncated`);const o=n[0].webkitRelativePath,s=o&&o.split("/")[0]||"目录",a=[],i=[];let h=0;const f=[...n].sort((u,p)=>{const g=u.webkitRelativePath||u.name,v=p.webkitRelativePath||p.name;return g.localeCompare(v)});for(const u of f){const p=u.webkitRelativePath||u.name;if(a.push(p),Al(u)||Wr(u))if(h+u.size<=Cs)try{let g;if(rn(u.name)===".xlsx"||rn(u.name)===".xls"){const v=await u.arrayBuffer();g=await Rl(v)}else g=await u.text();i.push(`
262
262
  ### ${p}
263
263
  \`\`\`
264
264
  ${g}
@@ -272,12 +272,12 @@ ${g}
272
272
  ### ${p}
273
273
  (二进制文件,${Ot(u.size)})`)}const c=a.join(`
274
274
  `),l=[`# 目录: ${s}`,`共 ${a.length} 个文件`,"","## 文件结构","```",c,"```","","## 文件内容",...i].join(`
275
- `);return{kind:"directory",name:s,size:r,textContent:l,files:a}}async function jx(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{const o=r.result,s=o.indexOf(",");t(s>=0?o.slice(s+1):o)},r.onerror=()=>n(new Error("FileReader error")),r.readAsDataURL(e)})}function Ax({requests:e,onRespond:t,className:n}){return e.length===0?null:d.jsx("div",{className:Z("w-full max-w-3xl mx-auto px-4",n),children:d.jsx("div",{className:"space-y-2",children:e.map(r=>d.jsx(Rx,{request:r,onRespond:t},r.requestId))})})}function Rx({request:e,onRespond:t}){return d.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-warning-border/30 bg-warning-bg/50 px-4 py-3",children:[d.jsx(Qr,{className:"h-5 w-5 text-warning-text flex-shrink-0"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"text-sm font-medium text-warning-text",children:e.toolName}),e.description&&d.jsx("div",{className:"text-xs text-warning-text/80 mt-0.5 truncate",children:e.description})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.requestId,!0),className:"h-8 px-3 rounded-lg bg-brand text-white text-xs font-medium hover:bg-brand-light transition-colors flex items-center gap-1.5",children:[d.jsx(wt,{className:"h-3.5 w-3.5"}),"允许"]}),d.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.requestId,!1),className:"h-8 px-3 rounded-lg border border-warning-border/30 text-warning-text text-xs font-medium hover:bg-warning-bg transition-colors flex items-center gap-1.5",children:[d.jsx(an,{className:"h-3.5 w-3.5"}),"拒绝"]})]})]})}var sr="Popover",[Tl]=Qe(sr,[Ht]),pn=Ht(),[Tx,ft]=Tl(sr),Il=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!1}=e,i=pn(t),h=m.useRef(null),[f,c]=m.useState(!1),[l,u]=at({prop:r,defaultProp:o??!1,onChange:s,caller:sr});return d.jsx(lo,{...i,children:d.jsx(Tx,{scope:t,contentId:Ce(),triggerRef:h,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(p=>!p),[u]),hasCustomAnchor:f,onCustomAnchorAdd:m.useCallback(()=>c(!0),[]),onCustomAnchorRemove:m.useCallback(()=>c(!1),[]),modal:a,children:n})})};Il.displayName=sr;var Ml="PopoverAnchor",Ix=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Ml,n),s=pn(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:i}=o;return m.useEffect(()=>(a(),()=>i()),[a,i]),d.jsx(qn,{...s,...r,ref:t})});Ix.displayName=Ml;var Pl="PopoverTrigger",Ol=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Pl,n),s=pn(n),a=pe(t,o.triggerRef),i=d.jsx(ue.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ul(o.open),...r,ref:a,onClick:ee(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:d.jsx(qn,{asChild:!0,...s,children:i})});Ol.displayName=Pl;var Po="PopoverPortal",[Mx,Px]=Tl(Po,{forceMount:void 0}),Dl=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=ft(Po,t);return d.jsx(Mx,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};Dl.displayName=Po;var Ut="PopoverContent",Ll=m.forwardRef((e,t)=>{const n=Px(Ut,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=ft(Ut,e.__scopePopover);return d.jsx(Ae,{present:r||s.open,children:s.modal?d.jsx(Dx,{...o,ref:t}):d.jsx(Lx,{...o,ref:t})})});Ll.displayName=Ut;var Ox=Dt("PopoverContent.RemoveScroll"),Dx=m.forwardRef((e,t)=>{const n=ft(Ut,e.__scopePopover),r=m.useRef(null),o=pe(t,r),s=m.useRef(!1);return m.useEffect(()=>{const a=r.current;if(a)return fo(a)},[]),d.jsx(Kr,{as:Ox,allowPinchZoom:!0,children:d.jsx($l,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),s.current||(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,h=i.button===0&&i.ctrlKey===!0,f=i.button===2||h;s.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:ee(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Lx=m.forwardRef((e,t)=>{const n=ft(Ut,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return d.jsx($l,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,i;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var h,f;(h=e.onInteractOutside)==null||h.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),$l=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:c,...l}=e,u=ft(Ut,n),p=pn(n);return Jr(),d.jsx(Wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onDismiss:()=>u.onOpenChange(!1),children:d.jsx(co,{"data-state":Ul(u.open),role:"dialog",id:u.contentId,...p,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Fl="PopoverClose",$x=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Fl,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});$x.displayName=Fl;var Fx="PopoverArrow",Ux=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=pn(n);return d.jsx(uo,{...o,...r,ref:t})});Ux.displayName=Fx;function Ul(e){return e?"open":"closed"}var zx=Il,Bx=Ol,Wx=Dl,Hx=Ll;function zl({...e}){return d.jsx(zx,{"data-slot":"popover",...e})}function Bl({...e}){return d.jsx(Bx,{"data-slot":"popover-trigger",...e})}function Wl({className:e,align:t="center",sideOffset:n=4,...r}){return d.jsx(Wx,{children:d.jsx(Hx,{"data-slot":"popover-content",align:t,sideOffset:n,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",e),...r})})}var _s=1,Vx=.9,Gx=.8,Kx=.17,kr=.1,_r=.999,qx=.9999,Yx=.99,Xx=/[\\\/_+.#"@\[\(\{&]/,Qx=/[\\\/_+.#"@\[\(\{&]/g,Zx=/[\s-]/,Hl=/[\s-]/g;function Hr(e,t,n,r,o,s,a){if(s===t.length)return o===e.length?_s:Yx;var i=`${o},${s}`;if(a[i]!==void 0)return a[i];for(var h=r.charAt(s),f=n.indexOf(h,o),c=0,l,u,p,g;f>=0;)l=Hr(e,t,n,r,f+1,s+1,a),l>c&&(f===o?l*=_s:Xx.test(e.charAt(f-1))?(l*=Gx,p=e.slice(o,f-1).match(Qx),p&&o>0&&(l*=Math.pow(_r,p.length))):Zx.test(e.charAt(f-1))?(l*=Vx,g=e.slice(o,f-1).match(Hl),g&&o>0&&(l*=Math.pow(_r,g.length))):(l*=Kx,o>0&&(l*=Math.pow(_r,f-o))),e.charAt(f)!==t.charAt(s)&&(l*=qx)),(l<kr&&n.charAt(f-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(f-1)!==r.charAt(s))&&(u=Hr(e,t,n,r,f+1,s+2,a),u*kr>l&&(l=u*kr)),l>c&&(c=l),f=n.indexOf(h,f+1);return a[i]=c,c}function Es(e){return e.toLowerCase().replace(Hl," ")}function Jx(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Hr(e,t,Es(e),Es(t),0,0,{})}var Yt='[cmdk-group=""]',Er='[cmdk-group-items=""]',ev='[cmdk-group-heading=""]',Vl='[cmdk-item=""]',Ns=`${Vl}:not([aria-disabled="true"])`,Vr="cmdk-item-select",Tt="data-value",tv=(e,t,n)=>Jx(e,t,n),Gl=m.createContext(void 0),gn=()=>m.useContext(Gl),Kl=m.createContext(void 0),Oo=()=>m.useContext(Kl),ql=m.createContext(void 0),Yl=m.forwardRef((e,t)=>{let n=It(()=>{var T,B;return{search:"",value:(B=(T=e.value)!=null?T:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=It(()=>new Set),o=It(()=>new Map),s=It(()=>new Map),a=It(()=>new Set),i=Xl(e),{label:h,children:f,value:c,onValueChange:l,filter:u,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:C=!0,...b}=e,R=Ce(),j=Ce(),_=Ce(),$=m.useRef(null),k=fv();kt(()=>{if(c!==void 0){let T=c.trim();n.current.value=T,N.emit()}},[c]),kt(()=>{k(6,F)},[]);let N=m.useMemo(()=>({subscribe:T=>(a.current.add(T),()=>a.current.delete(T)),snapshot:()=>n.current,setState:(T,B,z)=>{var U,V,G,X;if(!Object.is(n.current[T],B)){if(n.current[T]=B,T==="search")P(),A(),k(1,O);else if(T==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(_);K?K.focus():(U=document.getElementById(R))==null||U.focus()}if(k(7,()=>{var K;n.current.selectedItemId=(K=M())==null?void 0:K.id,N.emit()}),z||k(5,F),((V=i.current)==null?void 0:V.value)!==void 0){let K=B??"";(X=(G=i.current).onValueChange)==null||X.call(G,K);return}}N.emit()}},emit:()=>{a.current.forEach(T=>T())}}),[]),x=m.useMemo(()=>({value:(T,B,z)=>{var U;B!==((U=s.current.get(T))==null?void 0:U.value)&&(s.current.set(T,{value:B,keywords:z}),n.current.filtered.items.set(T,y(B,z)),k(2,()=>{A(),N.emit()}))},item:(T,B)=>(r.current.add(T),B&&(o.current.has(B)?o.current.get(B).add(T):o.current.set(B,new Set([T]))),k(3,()=>{P(),A(),n.current.value||O(),N.emit()}),()=>{s.current.delete(T),r.current.delete(T),n.current.filtered.items.delete(T);let z=M();k(4,()=>{P(),(z==null?void 0:z.getAttribute("id"))===T&&O(),N.emit()})}),group:T=>(o.current.has(T)||o.current.set(T,new Set),()=>{s.current.delete(T),o.current.delete(T)}),filter:()=>i.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:R,inputId:_,labelId:j,listInnerRef:$}),[]);function y(T,B){var z,U;let V=(U=(z=i.current)==null?void 0:z.filter)!=null?U:tv;return T?V(T,n.current.search,B):0}function A(){if(!n.current.search||i.current.shouldFilter===!1)return;let T=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(U=>{let V=o.current.get(U),G=0;V.forEach(X=>{let K=T.get(X);G=Math.max(K,G)}),B.push([U,G])});let z=$.current;D().sort((U,V)=>{var G,X;let K=U.getAttribute("id"),ne=V.getAttribute("id");return((G=T.get(ne))!=null?G:0)-((X=T.get(K))!=null?X:0)}).forEach(U=>{let V=U.closest(Er);V?V.appendChild(U.parentElement===V?U:U.closest(`${Er} > *`)):z.appendChild(U.parentElement===z?U:U.closest(`${Er} > *`))}),B.sort((U,V)=>V[1]-U[1]).forEach(U=>{var V;let G=(V=$.current)==null?void 0:V.querySelector(`${Yt}[${Tt}="${encodeURIComponent(U[0])}"]`);G==null||G.parentElement.appendChild(G)})}function O(){let T=D().find(z=>z.getAttribute("aria-disabled")!=="true"),B=T==null?void 0:T.getAttribute(Tt);N.setState("value",B||void 0)}function P(){var T,B,z,U;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let V=0;for(let G of r.current){let X=(B=(T=s.current.get(G))==null?void 0:T.value)!=null?B:"",K=(U=(z=s.current.get(G))==null?void 0:z.keywords)!=null?U:[],ne=y(X,K);n.current.filtered.items.set(G,ne),ne>0&&V++}for(let[G,X]of o.current)for(let K of X)if(n.current.filtered.items.get(K)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=V}function F(){var T,B,z;let U=M();U&&(((T=U.parentElement)==null?void 0:T.firstChild)===U&&((z=(B=U.closest(Yt))==null?void 0:B.querySelector(ev))==null||z.scrollIntoView({block:"nearest"})),U.scrollIntoView({block:"nearest"}))}function M(){var T;return(T=$.current)==null?void 0:T.querySelector(`${Vl}[aria-selected="true"]`)}function D(){var T;return Array.from(((T=$.current)==null?void 0:T.querySelectorAll(Ns))||[])}function S(T){let B=D()[T];B&&N.setState("value",B.getAttribute(Tt))}function w(T){var B;let z=M(),U=D(),V=U.findIndex(X=>X===z),G=U[V+T];(B=i.current)!=null&&B.loop&&(G=V+T<0?U[U.length-1]:V+T===U.length?U[0]:U[V+T]),G&&N.setState("value",G.getAttribute(Tt))}function L(T){let B=M(),z=B==null?void 0:B.closest(Yt),U;for(;z&&!U;)z=T>0?dv(z,Yt):uv(z,Yt),U=z==null?void 0:z.querySelector(Ns);U?N.setState("value",U.getAttribute(Tt)):w(T)}let E=()=>S(D().length-1),I=T=>{T.preventDefault(),T.metaKey?E():T.altKey?L(1):w(1)},W=T=>{T.preventDefault(),T.metaKey?S(0):T.altKey?L(-1):w(-1)};return m.createElement(ut.div,{ref:t,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:T=>{var B;(B=b.onKeyDown)==null||B.call(b,T);let z=T.nativeEvent.isComposing||T.keyCode===229;if(!(T.defaultPrevented||z))switch(T.key){case"n":case"j":{C&&T.ctrlKey&&I(T);break}case"ArrowDown":{I(T);break}case"p":case"k":{C&&T.ctrlKey&&W(T);break}case"ArrowUp":{W(T);break}case"Home":{T.preventDefault(),S(0);break}case"End":{T.preventDefault(),E();break}case"Enter":{T.preventDefault();let U=M();if(U){let V=new Event(Vr);U.dispatchEvent(V)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:x.inputId,id:x.labelId,style:mv},h),ar(e,T=>m.createElement(Kl.Provider,{value:N},m.createElement(Gl.Provider,{value:x},T))))}),nv=m.forwardRef((e,t)=>{var n,r;let o=Ce(),s=m.useRef(null),a=m.useContext(ql),i=gn(),h=Xl(e),f=(r=(n=h.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;kt(()=>{if(!f)return i.item(o,a==null?void 0:a.id)},[f]);let c=Ql(o,s,[e.value,e.children,s],e.keywords),l=Oo(),u=ct(k=>k.value&&k.value===c.current),p=ct(k=>f||i.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);m.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(Vr,g),()=>k.removeEventListener(Vr,g)},[p,e.onSelect,e.disabled]);function g(){var k,N;v(),(N=(k=h.current).onSelect)==null||N.call(k,c.current)}function v(){l.setState("value",c.current,!0)}if(!p)return null;let{disabled:C,value:b,onSelect:R,forceMount:j,keywords:_,...$}=e;return m.createElement(ut.div,{ref:We(s,t),...$,id:o,"cmdk-item":"",role:"option","aria-disabled":!!C,"aria-selected":!!u,"data-disabled":!!C,"data-selected":!!u,onPointerMove:C||i.getDisablePointerSelection()?void 0:v,onClick:C?void 0:g},e.children)}),rv=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,a=Ce(),i=m.useRef(null),h=m.useRef(null),f=Ce(),c=gn(),l=ct(p=>o||c.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);kt(()=>c.group(a),[]),Ql(a,i,[e.value,e.heading,h]);let u=m.useMemo(()=>({id:a,forceMount:o}),[o]);return m.createElement(ut.div,{ref:We(i,t),...s,"cmdk-group":"",role:"presentation",hidden:l?void 0:!0},n&&m.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),ar(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},m.createElement(ql.Provider,{value:u},p))))}),ov=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=ct(a=>!a.search);return!n&&!s?null:m.createElement(ut.div,{ref:We(o,t),...r,"cmdk-separator":"",role:"separator"})}),sv=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Oo(),a=ct(f=>f.search),i=ct(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ut.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":i,id:h.inputId,type:"text",value:o?e.value:a,onChange:f=>{o||s.setState("search",f.target.value),n==null||n(f.target.value)}})}),av=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),a=m.useRef(null),i=ct(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{if(a.current&&s.current){let f=a.current,c=s.current,l,u=new ResizeObserver(()=>{l=requestAnimationFrame(()=>{let p=f.offsetHeight;c.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return u.observe(f),()=>{cancelAnimationFrame(l),u.unobserve(f)}}},[]),m.createElement(ut.div,{ref:We(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":r,id:h.listId},ar(e,f=>m.createElement("div",{ref:We(a,h.listInnerRef),"cmdk-list-sizer":""},f)))}),iv=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:a,...i}=e;return m.createElement(Bi,{open:n,onOpenChange:r},m.createElement(Wi,{container:a},m.createElement(Hi,{"cmdk-overlay":"",className:o}),m.createElement(Vi,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Yl,{ref:t,...i}))))}),lv=m.forwardRef((e,t)=>ct(n=>n.filtered.count===0)?m.createElement(ut.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),cv=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(ut.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ar(e,a=>m.createElement("div",{"aria-hidden":!0},a)))}),Vt=Object.assign(Yl,{List:av,Item:nv,Input:sv,Group:rv,Separator:ov,Dialog:iv,Empty:lv,Loading:cv});function dv(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function uv(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Xl(e){let t=m.useRef(e);return kt(()=>{t.current=e}),t}var kt=typeof window>"u"?m.useEffect:m.useLayoutEffect;function It(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function ct(e){let t=Oo(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Ql(e,t,n,r=[]){let o=m.useRef(),s=gn();return kt(()=>{var a;let i=(()=>{var f;for(let c of n){if(typeof c=="string")return c.trim();if(typeof c=="object"&&"current"in c)return c.current?(f=c.current.textContent)==null?void 0:f.trim():o.current}})(),h=r.map(f=>f.trim());s.value(e,i,h),(a=t.current)==null||a.setAttribute(Tt,i),o.current=i}),o}var fv=()=>{let[e,t]=m.useState(),n=It(()=>new Map);return kt(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function hv(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ar({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(hv(t),{ref:t.ref},n(t.props.children)):n(t)}var mv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function pv({className:e,...t}){return d.jsx(Vt,{"data-slot":"command",className:Z("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function gv({className:e,...t}){return d.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[d.jsx(Xd,{className:"size-4 shrink-0 opacity-50"}),d.jsx(Vt.Input,{"data-slot":"command-input",className:Z("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function xv({className:e,...t}){return d.jsx(Vt.List,{"data-slot":"command-list",className:Z("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function vv({...e}){return d.jsx(Vt.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function yv({className:e,...t}){return d.jsx(Vt.Group,{"data-slot":"command-group",className:Z("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function bv({className:e,...t}){return d.jsx(Vt.Item,{"data-slot":"command-item",className:Z("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function js(e,t){if(!e)return!0;const n=e.toLowerCase(),r=t.toLowerCase();let o=0;for(let s=0;s<r.length&&o<n.length;s++)r[s]===n[o]&&o++;return o===n.length}function wv({models:e,currentModelId:t,onSelect:n,showSearch:r=!0,isMobile:o=!1}){const[s,a]=m.useState(""),[i,h]=m.useState(o?"__none__":void 0),f=m.useMemo(()=>s?e.filter(c=>js(s,c.name)||js(s,c.modelId)):e,[e,s]);return d.jsxs(pv,{shouldFilter:!1,value:i,onValueChange:h,children:[r&&d.jsx(gv,{placeholder:"Select a model…",value:s,onValueChange:a}),d.jsxs(xv,{children:[d.jsx(vv,{children:"No models found."}),d.jsx(yv,{children:f.map(c=>d.jsxs(bv,{value:c.modelId,onSelect:()=>n(c),className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[d.jsx("span",{className:"truncate font-medium",children:c.name}),c.description&&d.jsx("span",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),d.jsx(wt,{className:Z("h-4 w-4 shrink-0",t===c.modelId?"opacity-100":"opacity-0")})]},c.modelId))})]})]})}function Zl(e){const[t,n]=m.useState(e.modelState),[r,o]=m.useState(!1);m.useEffect(()=>{const f=l=>{if(n(l),l&&l.availableModels.length>0){const u=localStorage.getItem("acp_model_id");u&&u!==l.currentModelId&&l.availableModels.some(p=>p.modelId===u)&&e.setSessionModel(u).catch(()=>{})}},c=l=>{n(u=>u?{...u,currentModelId:l}:null),o(!1)};return e.setModelStateChangedHandler(f),e.setModelChangedHandler(c),()=>{e.removeModelStateChangedHandler(f),e.removeModelChangedHandler(c)}},[e]);const s=m.useMemo(()=>(t==null?void 0:t.availableModels)??[],[t]),a=(t==null?void 0:t.currentModelId)??null,i=m.useMemo(()=>s.find(f=>f.modelId===a)??null,[s,a]),h=m.useCallback(async f=>{if(!t)throw new Error("Model selection not supported");o(!0);try{await e.setSessionModel(f),localStorage.setItem("acp_model_id",f)}catch(c){throw o(!1),c}},[e,t]);return{supportsModelSelection:t!==null&&s.length>0,availableModels:s,currentModelId:a,currentModel:i,setModel:h,isLoading:r}}function Cv({client:e,onModelSelect:t}){const[n,r]=m.useState(!1),{supportsModelSelection:o,availableModels:s,currentModel:a,setModel:i,isLoading:h}=Zl(e),f=o&&s.length>0,c=typeof window<"u"&&window.matchMedia("(hover: none) and (pointer: coarse)").matches,l=async u=>{try{await i(u.modelId),t==null||t(u.modelId),r(!1)}catch(p){console.error("[ModelSelector] Failed to set model:",p)}};return d.jsxs(zl,{open:n,onOpenChange:f?r:void 0,children:[d.jsx(Bl,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"gap-1.5 text-muted-foreground hover:text-foreground h-7 px-2",disabled:!f||h,children:[h?d.jsx(na,{className:"h-3 w-3 animate-spin"}):null,d.jsx("span",{className:"max-w-32 truncate",children:(a==null?void 0:a.name)??"Select Model"}),n?d.jsx(Zs,{className:"h-3 w-3"}):d.jsx(sn,{className:"h-3 w-3"})]})}),d.jsx(Wl,{className:"w-72 p-0",align:"end",children:d.jsx(wv,{models:s,currentModelId:(a==null?void 0:a.modelId)??null,onSelect:l,showSearch:!c,isMobile:c})})]})}function Sv(e){const[t,n]=m.useState(e.availableCommands);m.useEffect(()=>{const o=s=>{n(s)};return e.setAvailableCommandsChangedHandler(o),()=>{e.setAvailableCommandsChangedHandler(()=>{})}},[e]);const r=m.useMemo(()=>t.length>0,[t]);return{commands:t,hasCommands:r}}const kv=new Set(["clear","new","help","status","model","copy"]),_v=[{name:"compact",desc:"压缩上下文"},{name:"cost",desc:"查看会话费用"},{name:"summary",desc:"生成会话摘要"},{name:"files",desc:"列出上下文中的文件"}];function Ev(e){switch(e){case"help":return"Help";case"status":return"Status";case"model":return"Model";case"copy":return"Copy";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Nv(e){switch(e){case"help":return"可用命令列表";case"status":return"会话状态信息";case"model":return"查看或切换模型";case"copy":return"复制助手消息到剪贴板";default:return""}}function jv(e){var r;const t=[];t.push("**本地命令**(Web UI 直接执行)"),t.push("");const n=[{name:"clear",desc:"清空当前对话"},{name:"new",desc:"新建会话"},{name:"help",desc:"显示此帮助信息"},{name:"status",desc:"显示会话状态"},{name:"model [id]",desc:"查看或切换模型"},{name:"copy",desc:"复制最后一条助手消息"}];for(const o of n)t.push(`- \`/${o.name}\` — ${o.desc}`);t.push(""),t.push("**Agent 命令**(发给 Saluzi agent 执行)"),t.push("");for(const o of _v)t.push(`- \`/${o.name}\` — ${o.desc}`);if(e.length>0)for(const o of e){const s=(r=o.input)!=null&&r.hint?` ${o.input.hint}`:"";t.push(`- \`/${o.name}${s}\` — ${o.description}`)}return t.join(`
276
- `)}function Av(e){var n,r,o;const t=["**会话状态**",""];return t.push(`- 会话 ID: \`${e.sessionId??"无"}\``),t.push(`- 当前模型: ${((n=e.currentModel)==null?void 0:n.name)??((r=e.currentModel)==null?void 0:r.modelId)??"未设置"}`),(o=e.currentModel)!=null&&o.modelId&&t.push(` - ID: \`${e.currentModel.modelId}\``),t.push(`- 可用模型数: ${e.modelCount}`),t.push(`- 图片支持: ${e.supportsImages?"是":"否"}`),t.push(`- 消息条数: ${e.entryCount}`),t.join(`
277
- `)}function Rv(e,t){if(e.length===0)return"当前 agent 未提供模型选择能力。";const n=["**可用模型**",""];for(const r of e){const o=r.modelId===(t==null?void 0:t.modelId)?" ✓":"";n.push(`- \`${r.modelId}\` — ${r.name}${o}`)}return n.push(""),n.push("使用 `/model <id>` 切换模型。"),n.join(`
278
- `)}async function Tv(e,t){var l;if(!e.startsWith("/"))return{handled:!1};const[n,...r]=e.slice(1).split(/\s+/),o=r.join(" ").trim(),s=n==null?void 0:n.toLowerCase();if(!s||!kv.has(s))return{handled:!1};if(s==="clear")return{handled:!0,clearEntries:!0};if(s==="new")return{handled:!0,newSession:!0};let a="",i=!1;if(s==="help")a=jv(t.availableCommands);else if(s==="status")a=Av({sessionId:t.sessionId,currentModel:t.currentModel,supportsImages:t.supportsImages,modelCount:t.availableModels.length,entryCount:t.entries.length});else if(s==="model")if(o)try{await t.setModel(o),a=`已请求切换到模型: \`${o}\``}catch(u){a=`切换模型失败: ${u instanceof Error?u.message:String(u)}`,i=!0}else a=Rv(t.availableModels,t.currentModel);else if(s==="copy"){const u=[...t.entries].reverse().find(g=>g.type==="assistant_message"),p=((l=u==null?void 0:u.chunks)==null?void 0:l.map(g=>g.text).join(`
279
- `))??"";try{await navigator.clipboard.writeText(p),a=p?`已复制 ${p.length} 字符到剪贴板`:"没有可复制的助手消息"}catch{a="复制失败:剪贴板不可用",i=!0}}const h=Date.now(),f={type:"user_message",id:`user-${h}`,content:e},c={type:"command_output",id:`cmd-${h}`,commandName:s,inputText:e,title:Ev(s),subtitle:Nv(s),outputText:a,variant:i?"error":"default"};return{handled:!0,userEntry:f,cmdEntry:c}}const Iv={maxSizeMB:2,maxWidthOrHeight:2048,useWebWorker:!0,fileType:"image/jpeg"};function Mv(e){const t=e.indexOf(",");if(t===-1)throw new Error("Invalid data URL: missing comma separator");const n=e.slice(0,t),r=e.slice(t+1),o=n.match(/^data:([^;,]+)/),s=o?o[1]:"application/octet-stream",a=atob(r),i=new Uint8Array(a.length);for(let h=0;h<a.length;h++)i[h]=a.charCodeAt(h);return new Blob([i],{type:s})}const Nr=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"dontAsk",label:"不询问",description:"不弹出询问,自动拒绝"},{value:"auto",label:"自动判断",description:"AI 自动判断是否批准"}];function Pv({mode:e,onModeChange:t}){const[n,r]=m.useState(!1),o=Nr.find(s=>s.value===e)??Nr[0];return d.jsxs(zl,{open:n,onOpenChange:r,children:[d.jsx(Bl,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"gap-1.5 text-muted-foreground hover:text-foreground h-7 px-2",children:[d.jsx(ou,{className:"h-3 w-3"}),d.jsx("span",{className:"max-w-24 truncate",children:o.label}),n?d.jsx(Zs,{className:"h-3 w-3"}):d.jsx(sn,{className:"h-3 w-3"})]})}),d.jsx(Wl,{className:"w-64 p-1",align:"start",children:Nr.map(s=>d.jsxs("button",{type:"button",onClick:()=>{t(s.value),r(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[d.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:e===s.value&&d.jsx(wt,{className:"h-3.5 w-3.5 text-brand"})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"text-sm font-medium text-text-primary",children:s.label}),d.jsx("div",{className:"text-xs text-text-muted",children:s.description})]})]},s.value))})]})}function As(e){return e==="completed"?"complete":e==="failed"?"error":"running"}function jr(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}function Ov({client:e,agentId:t}){const[n,r]=m.useState([]),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),c=m.useRef(null),l=m.useRef(n);l.current=n;const[u,p]=m.useState(null),g=m.useRef(null),[v,C]=m.useState(()=>localStorage.getItem("acp_permission_mode")||"default"),[b,R]=m.useState(!1),{commands:j}=Sv(e),{availableModels:_,currentModel:$,setModel:k}=Zl(e);m.useEffect(()=>{c.current=h},[h]);const N=m.useCallback(()=>{r([]),s(!1),i(!1)},[]),x=t?`acp_last_session_${t}`:null,y=m.useCallback((L,E)=>{if(((E==null?void 0:E.resetEntries)??!0)&&(r([]),s(!1)),f(L),i(!0),R(e.supportsImages),x)try{localStorage.setItem(x,L)}catch{}console.log("[ChatInterface] Active session:",L,"supportsImages:",e.supportsImages)},[e,x]),A=m.useCallback(L=>{c.current&&L.sessionId!==c.current||(console.log("[ChatInterface] Permission request:",L),r(E=>{const I=jr(E,L.toolCall.toolCallId);if(I>=0)return E.map((W,T)=>T!==I||W.type!=="tool_call"||W.toolCall.status!=="running"?W:{type:"tool_call",toolCall:{...W.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:L.requestId,options:L.options}}});{console.log("[ChatInterface] No matching tool call, creating standalone permission request");const W={type:"tool_call",toolCall:{id:L.toolCall.toolCallId,title:L.toolCall.title||"Permission Request",status:"waiting_for_confirmation",permissionRequest:{requestId:L.requestId,options:L.options},isStandalonePermission:!0}};return[...E,W]}}))},[]),O=m.useCallback((L,E)=>{if(!(c.current&&L!==c.current))if(E.sessionUpdate==="agent_message_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="assistant_message"){const z=T.chunks[T.chunks.length-1];return(z==null?void 0:z.type)==="message"?[...W.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"message",text:z.text+I}]}]:[...W.slice(0,-1),{...T,chunks:[...T.chunks,{type:"message",text:I}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:I}]};return[...W,B]})}else if(E.sessionUpdate==="agent_thought_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="assistant_message"){const z=T.chunks[T.chunks.length-1];return(z==null?void 0:z.type)==="thought"?[...W.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"thought",text:z.text+I}]}]:[...W.slice(0,-1),{...T,chunks:[...T.chunks,{type:"thought",text:I}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"thought",text:I}]};return[...W,B]})}else if(E.sessionUpdate==="user_message_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="user_message")return[...W.slice(0,-1),{...T,content:T.content+I}];const B={type:"user_message",id:`user-${Date.now()}`,content:I};return[...W,B]})}else if(E.sessionUpdate==="tool_call"){const I={id:E.toolCallId,title:E.title,status:As(E.status),content:E.content,rawInput:E.rawInput,rawOutput:E.rawOutput};r(W=>{const T=jr(W,E.toolCallId);if(T>=0)return W.map((z,U)=>U!==T||z.type!=="tool_call"?z:{type:"tool_call",toolCall:{...z.toolCall,...I}});const B={type:"tool_call",toolCall:I};return[...W,B]})}else E.sessionUpdate==="tool_call_update"?r(I=>{const W=jr(I,E.toolCallId);if(W<0){console.warn(`[ChatInterface] Tool call not found for update: ${E.toolCallId}`);const T={type:"tool_call",toolCall:{id:E.toolCallId,title:E.title||"Tool call not found",status:"error",content:[{type:"content",content:{type:"text",text:"Tool call not found"}}]}};return[...I,T]}return I.map((T,B)=>{if(B!==W||T.type!=="tool_call")return T;const z=E.status?As(E.status):T.toolCall.status,U=E.content?[...T.toolCall.content||[],...E.content]:T.toolCall.content;return{type:"tool_call",toolCall:{...T.toolCall,status:z,...E.title&&{title:E.title},content:U,...E.rawInput&&{rawInput:E.rawInput},...E.rawOutput&&{rawOutput:E.rawOutput}}}})}):E.sessionUpdate==="plan"&&r(I=>{if(E.entries.length===0)return I.filter(B=>B.type!=="plan");const W=I.reduce((B,z,U)=>z.type==="plan"?U:B,-1);if(W>=0)return I.map((B,z)=>z===W?{...B,entries:E.entries}:B);const T={type:"plan",id:`plan-${Date.now()}`,entries:E.entries};return[...I,T]})},[]);m.useEffect(()=>{e.setSessionCreatedHandler(E=>{console.log("[ChatInterface] Session created:",E),y(E)}),e.setSessionLoadedHandler(E=>{console.log("[ChatInterface] Session loaded/resumed:",E),y(E,{resetEntries:!1})}),e.setSessionSwitchingHandler(E=>{console.log("[ChatInterface] Switching to session:",E),f(E),N()}),e.setSessionUpdateHandler((E,I)=>{O(E,I)}),e.setPromptCompleteHandler(E=>{console.log("[ChatInterface] Prompt complete:",E),s(!1)}),e.setPermissionRequestHandler(A),e.setErrorMessageHandler(E=>{console.error("[ChatInterface] Agent error:",E),p(E),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>p(null),5e3)});const L=x?localStorage.getItem(x):null;return L&&(e.supportsLoadSession||e.supportsResumeSession)?(console.log("[ChatInterface] Restoring session:",L),(async()=>{try{e.supportsLoadSession?await e.loadSession({sessionId:L}):await e.resumeSession({sessionId:L})}catch(I){console.warn("[ChatInterface] Failed to restore session, creating new one:",I),e.createSession(void 0,v)}})()):e.createSession(void 0,v),()=>{g.current&&clearTimeout(g.current),e.setSessionCreatedHandler(()=>{}),e.setSessionLoadedHandler(()=>{}),e.setSessionSwitchingHandler(null),e.setSessionUpdateHandler(()=>{}),e.setPromptCompleteHandler(()=>{}),e.setPermissionRequestHandler(()=>{}),e.setErrorMessageHandler(()=>{})}},[y,e,A,O,N]);const P=m.useCallback(()=>{console.log("[ChatInterface] Creating new session..."),o&&e.cancel(),N(),f(null),e.createSession(void 0,v)},[e,o,N,v]),F=()=>{console.log("[ChatInterface] Cancel requested"),r(L=>L.map(E=>E.type!=="tool_call"||!(E.toolCall.status==="running"||E.toolCall.status==="waiting_for_confirmation")?E:(console.log("[ChatInterface] Marking tool call as canceled:",E.toolCall.id),{type:"tool_call",toolCall:{...E.toolCall,status:"canceled",permissionRequest:void 0}}))),e.cancel()},M=m.useCallback((L,E,I)=>{console.log("[ChatInterface] Permission response:",{requestId:L,optionId:E,optionKind:I}),e.respondToPermission(L,E);const W=I==="reject_once"||I==="reject_always"||E===null;r(T=>T.map(B=>{var U;if(B.type!=="tool_call"||((U=B.toolCall.permissionRequest)==null?void 0:U.requestId)!==L)return B;let z;return W?z="rejected":B.toolCall.isStandalonePermission?z="complete":z="running",{type:"tool_call",toolCall:{...B.toolCall,status:z,permissionRequest:void 0,isStandalonePermission:void 0}}}))},[e]),D=n.filter(L=>L.type==="tool_call"&&L.toolCall.status==="waiting_for_confirmation"&&!!L.toolCall.permissionRequest).map(L=>({requestId:L.toolCall.permissionRequest.requestId,toolName:L.toolCall.title,toolInput:L.toolCall.rawInput||{},description:L.toolCall.title,options:L.toolCall.permissionRequest.options})),S=m.useCallback((L,E)=>{const I=D.find(B=>B.requestId===L);let W=null,T=null;if(I!=null&&I.options&&I.options.length>0)if(E){const B=I.options.find(z=>z.kind==="allow_once")??I.options.find(z=>z.kind==="allow_always");B&&(W=B.optionId,T=B.kind)}else{const B=I.options.find(z=>z.kind==="reject_once")??I.options.find(z=>z.kind==="reject_always");B&&(W=B.optionId,T=B.kind)}W||(T=E?"allow_once":"reject_once"),M(L,W,T)},[M,D]),w=m.useCallback(async L=>{var V;const E=L.text.trim(),I=L.images||[],W=L.attachments||[];if(!E&&I.length===0&&W.length===0||o||!a)return;if(E.startsWith("/")&&I.length===0){bt("[ChatInterface] slash command input",{text:E});const G=await Tv(E,{sessionId:h,availableCommands:j,availableModels:_,currentModel:$,supportsImages:b,entries:l.current,setModel:k,onNewSession:P}).catch(()=>null);if(G){if(bt("[ChatInterface] local command handled",G),"clearEntries"in G&&G.clearEntries){r([]);return}if("newSession"in G&&G.newSession){P();return}if("userEntry"in G){r(X=>[...X,G.userEntry,G.cmdEntry]);return}}bt("[ChatInterface] slash command NOT in LOCAL_COMMANDS, forwarding to agent",{text:E})}bt("[ChatInterface] forwarding to agent",{text:E,hasImages:I.length>0,sessionReady:a,isLoading:o});const T=[];E&&T.push({type:"text",text:E});const B=[];for(const G of I)try{const X=`data:${G.mimeType};base64,${G.data}`;let K;X.startsWith("data:")?K=Mv(X):K=await(await fetch(X)).blob();let ne=K,ae=G.mimeType;if(K.size>2*1024*1024){const H=new File([K],"image.jpg",{type:K.type});ne=await ye(H,Iv),ae="image/jpeg"}const de=await new Promise((H,q)=>{const J=new FileReader;J.onloadend=()=>{const te=J.result,ie=te.indexOf(",");H(ie>=0?te.slice(ie+1):te)},J.onerror=()=>{var te;return q(new Error("FileReader error: "+((te=J.error)==null?void 0:te.message)))},J.readAsDataURL(ne)}),me={type:"image",mimeType:ae,data:de};T.push(me),B.push({mimeType:ae,data:de})}catch(X){console.error("[ChatInterface] Failed to process image:",X)}const z=[];for(const G of W)try{if(G.textContent){let X;if(G.kind==="directory"){const K=((V=G.files)==null?void 0:V.length)??0;X=`📁 目录: ${G.name} (${K} 个文件)
280
- ${G.textContent}`}else{const K=G.size!=null?` (${Dv(G.size)})`:"";X=`📎 ${G.name}${K}
275
+ `);return{kind:"directory",name:s,size:r,textContent:l,files:a}}async function Ax(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{const o=r.result,s=o.indexOf(",");t(s>=0?o.slice(s+1):o)},r.onerror=()=>n(new Error("FileReader error")),r.readAsDataURL(e)})}function Rx({requests:e,onRespond:t,className:n}){return e.length===0?null:d.jsx("div",{className:Z("w-full max-w-3xl mx-auto px-4",n),children:d.jsx("div",{className:"space-y-2",children:e.map(r=>d.jsx(Tx,{request:r,onRespond:t},r.requestId))})})}function Tx({request:e,onRespond:t}){return d.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-warning-border/30 bg-warning-bg/50 px-4 py-3",children:[d.jsx(Qr,{className:"h-5 w-5 text-warning-text flex-shrink-0"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"text-sm font-medium text-warning-text",children:e.toolName}),e.description&&d.jsx("div",{className:"text-xs text-warning-text/80 mt-0.5 truncate",children:e.description})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.requestId,!0),className:"h-8 px-3 rounded-lg bg-brand text-white text-xs font-medium hover:bg-brand-light transition-colors flex items-center gap-1.5",children:[d.jsx(wt,{className:"h-3.5 w-3.5"}),"允许"]}),d.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(e.requestId,!1),className:"h-8 px-3 rounded-lg border border-warning-border/30 text-warning-text text-xs font-medium hover:bg-warning-bg transition-colors flex items-center gap-1.5",children:[d.jsx(an,{className:"h-3.5 w-3.5"}),"拒绝"]})]})]})}var sr="Popover",[Tl]=Qe(sr,[Ht]),pn=Ht(),[Ix,ft]=Tl(sr),Il=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!1}=e,i=pn(t),h=m.useRef(null),[f,c]=m.useState(!1),[l,u]=at({prop:r,defaultProp:o??!1,onChange:s,caller:sr});return d.jsx(lo,{...i,children:d.jsx(Ix,{scope:t,contentId:Ce(),triggerRef:h,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(p=>!p),[u]),hasCustomAnchor:f,onCustomAnchorAdd:m.useCallback(()=>c(!0),[]),onCustomAnchorRemove:m.useCallback(()=>c(!1),[]),modal:a,children:n})})};Il.displayName=sr;var Ml="PopoverAnchor",Mx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Ml,n),s=pn(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:i}=o;return m.useEffect(()=>(a(),()=>i()),[a,i]),d.jsx(qn,{...s,...r,ref:t})});Mx.displayName=Ml;var Pl="PopoverTrigger",Ol=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Pl,n),s=pn(n),a=pe(t,o.triggerRef),i=d.jsx(ue.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ul(o.open),...r,ref:a,onClick:ee(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:d.jsx(qn,{asChild:!0,...s,children:i})});Ol.displayName=Pl;var Po="PopoverPortal",[Px,Ox]=Tl(Po,{forceMount:void 0}),Dl=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=ft(Po,t);return d.jsx(Px,{scope:t,forceMount:n,children:d.jsx(Ae,{present:n||s.open,children:d.jsx(dn,{asChild:!0,container:o,children:r})})})};Dl.displayName=Po;var Ut="PopoverContent",Ll=m.forwardRef((e,t)=>{const n=Ox(Ut,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=ft(Ut,e.__scopePopover);return d.jsx(Ae,{present:r||s.open,children:s.modal?d.jsx(Lx,{...o,ref:t}):d.jsx($x,{...o,ref:t})})});Ll.displayName=Ut;var Dx=Dt("PopoverContent.RemoveScroll"),Lx=m.forwardRef((e,t)=>{const n=ft(Ut,e.__scopePopover),r=m.useRef(null),o=pe(t,r),s=m.useRef(!1);return m.useEffect(()=>{const a=r.current;if(a)return fo(a)},[]),d.jsx(Kr,{as:Dx,allowPinchZoom:!0,children:d.jsx($l,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),s.current||(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ee(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,h=i.button===0&&i.ctrlKey===!0,f=i.button===2||h;s.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:ee(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),$x=m.forwardRef((e,t)=>{const n=ft(Ut,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return d.jsx($l,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,i;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var h,f;(h=e.onInteractOutside)==null||h.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),$l=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:c,...l}=e,u=ft(Ut,n),p=pn(n);return Jr(),d.jsx(Wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onDismiss:()=>u.onOpenChange(!1),children:d.jsx(co,{"data-state":Ul(u.open),role:"dialog",id:u.contentId,...p,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Fl="PopoverClose",Fx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ft(Fl,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});Fx.displayName=Fl;var Ux="PopoverArrow",zx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=pn(n);return d.jsx(uo,{...o,...r,ref:t})});zx.displayName=Ux;function Ul(e){return e?"open":"closed"}var Bx=Il,Wx=Ol,Hx=Dl,Vx=Ll;function zl({...e}){return d.jsx(Bx,{"data-slot":"popover",...e})}function Bl({...e}){return d.jsx(Wx,{"data-slot":"popover-trigger",...e})}function Wl({className:e,align:t="center",sideOffset:n=4,...r}){return d.jsx(Hx,{children:d.jsx(Vx,{"data-slot":"popover-content",align:t,sideOffset:n,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",e),...r})})}var _s=1,Gx=.9,Kx=.8,qx=.17,kr=.1,_r=.999,Yx=.9999,Xx=.99,Qx=/[\\\/_+.#"@\[\(\{&]/,Zx=/[\\\/_+.#"@\[\(\{&]/g,Jx=/[\s-]/,Hl=/[\s-]/g;function Hr(e,t,n,r,o,s,a){if(s===t.length)return o===e.length?_s:Xx;var i=`${o},${s}`;if(a[i]!==void 0)return a[i];for(var h=r.charAt(s),f=n.indexOf(h,o),c=0,l,u,p,g;f>=0;)l=Hr(e,t,n,r,f+1,s+1,a),l>c&&(f===o?l*=_s:Qx.test(e.charAt(f-1))?(l*=Kx,p=e.slice(o,f-1).match(Zx),p&&o>0&&(l*=Math.pow(_r,p.length))):Jx.test(e.charAt(f-1))?(l*=Gx,g=e.slice(o,f-1).match(Hl),g&&o>0&&(l*=Math.pow(_r,g.length))):(l*=qx,o>0&&(l*=Math.pow(_r,f-o))),e.charAt(f)!==t.charAt(s)&&(l*=Yx)),(l<kr&&n.charAt(f-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(f-1)!==r.charAt(s))&&(u=Hr(e,t,n,r,f+1,s+2,a),u*kr>l&&(l=u*kr)),l>c&&(c=l),f=n.indexOf(h,f+1);return a[i]=c,c}function Es(e){return e.toLowerCase().replace(Hl," ")}function ev(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Hr(e,t,Es(e),Es(t),0,0,{})}var Yt='[cmdk-group=""]',Er='[cmdk-group-items=""]',tv='[cmdk-group-heading=""]',Vl='[cmdk-item=""]',Ns=`${Vl}:not([aria-disabled="true"])`,Vr="cmdk-item-select",Tt="data-value",nv=(e,t,n)=>ev(e,t,n),Gl=m.createContext(void 0),gn=()=>m.useContext(Gl),Kl=m.createContext(void 0),Oo=()=>m.useContext(Kl),ql=m.createContext(void 0),Yl=m.forwardRef((e,t)=>{let n=It(()=>{var T,B;return{search:"",value:(B=(T=e.value)!=null?T:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=It(()=>new Set),o=It(()=>new Map),s=It(()=>new Map),a=It(()=>new Set),i=Xl(e),{label:h,children:f,value:c,onValueChange:l,filter:u,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:C=!0,...y}=e,R=Ce(),j=Ce(),_=Ce(),$=m.useRef(null),k=hv();kt(()=>{if(c!==void 0){let T=c.trim();n.current.value=T,N.emit()}},[c]),kt(()=>{k(6,F)},[]);let N=m.useMemo(()=>({subscribe:T=>(a.current.add(T),()=>a.current.delete(T)),snapshot:()=>n.current,setState:(T,B,z)=>{var U,V,G,X;if(!Object.is(n.current[T],B)){if(n.current[T]=B,T==="search")P(),A(),k(1,O);else if(T==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(_);K?K.focus():(U=document.getElementById(R))==null||U.focus()}if(k(7,()=>{var K;n.current.selectedItemId=(K=M())==null?void 0:K.id,N.emit()}),z||k(5,F),((V=i.current)==null?void 0:V.value)!==void 0){let K=B??"";(X=(G=i.current).onValueChange)==null||X.call(G,K);return}}N.emit()}},emit:()=>{a.current.forEach(T=>T())}}),[]),x=m.useMemo(()=>({value:(T,B,z)=>{var U;B!==((U=s.current.get(T))==null?void 0:U.value)&&(s.current.set(T,{value:B,keywords:z}),n.current.filtered.items.set(T,b(B,z)),k(2,()=>{A(),N.emit()}))},item:(T,B)=>(r.current.add(T),B&&(o.current.has(B)?o.current.get(B).add(T):o.current.set(B,new Set([T]))),k(3,()=>{P(),A(),n.current.value||O(),N.emit()}),()=>{s.current.delete(T),r.current.delete(T),n.current.filtered.items.delete(T);let z=M();k(4,()=>{P(),(z==null?void 0:z.getAttribute("id"))===T&&O(),N.emit()})}),group:T=>(o.current.has(T)||o.current.set(T,new Set),()=>{s.current.delete(T),o.current.delete(T)}),filter:()=>i.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:R,inputId:_,labelId:j,listInnerRef:$}),[]);function b(T,B){var z,U;let V=(U=(z=i.current)==null?void 0:z.filter)!=null?U:nv;return T?V(T,n.current.search,B):0}function A(){if(!n.current.search||i.current.shouldFilter===!1)return;let T=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(U=>{let V=o.current.get(U),G=0;V.forEach(X=>{let K=T.get(X);G=Math.max(K,G)}),B.push([U,G])});let z=$.current;D().sort((U,V)=>{var G,X;let K=U.getAttribute("id"),ne=V.getAttribute("id");return((G=T.get(ne))!=null?G:0)-((X=T.get(K))!=null?X:0)}).forEach(U=>{let V=U.closest(Er);V?V.appendChild(U.parentElement===V?U:U.closest(`${Er} > *`)):z.appendChild(U.parentElement===z?U:U.closest(`${Er} > *`))}),B.sort((U,V)=>V[1]-U[1]).forEach(U=>{var V;let G=(V=$.current)==null?void 0:V.querySelector(`${Yt}[${Tt}="${encodeURIComponent(U[0])}"]`);G==null||G.parentElement.appendChild(G)})}function O(){let T=D().find(z=>z.getAttribute("aria-disabled")!=="true"),B=T==null?void 0:T.getAttribute(Tt);N.setState("value",B||void 0)}function P(){var T,B,z,U;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let V=0;for(let G of r.current){let X=(B=(T=s.current.get(G))==null?void 0:T.value)!=null?B:"",K=(U=(z=s.current.get(G))==null?void 0:z.keywords)!=null?U:[],ne=b(X,K);n.current.filtered.items.set(G,ne),ne>0&&V++}for(let[G,X]of o.current)for(let K of X)if(n.current.filtered.items.get(K)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=V}function F(){var T,B,z;let U=M();U&&(((T=U.parentElement)==null?void 0:T.firstChild)===U&&((z=(B=U.closest(Yt))==null?void 0:B.querySelector(tv))==null||z.scrollIntoView({block:"nearest"})),U.scrollIntoView({block:"nearest"}))}function M(){var T;return(T=$.current)==null?void 0:T.querySelector(`${Vl}[aria-selected="true"]`)}function D(){var T;return Array.from(((T=$.current)==null?void 0:T.querySelectorAll(Ns))||[])}function S(T){let B=D()[T];B&&N.setState("value",B.getAttribute(Tt))}function w(T){var B;let z=M(),U=D(),V=U.findIndex(X=>X===z),G=U[V+T];(B=i.current)!=null&&B.loop&&(G=V+T<0?U[U.length-1]:V+T===U.length?U[0]:U[V+T]),G&&N.setState("value",G.getAttribute(Tt))}function L(T){let B=M(),z=B==null?void 0:B.closest(Yt),U;for(;z&&!U;)z=T>0?uv(z,Yt):fv(z,Yt),U=z==null?void 0:z.querySelector(Ns);U?N.setState("value",U.getAttribute(Tt)):w(T)}let E=()=>S(D().length-1),I=T=>{T.preventDefault(),T.metaKey?E():T.altKey?L(1):w(1)},W=T=>{T.preventDefault(),T.metaKey?S(0):T.altKey?L(-1):w(-1)};return m.createElement(ut.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:T=>{var B;(B=y.onKeyDown)==null||B.call(y,T);let z=T.nativeEvent.isComposing||T.keyCode===229;if(!(T.defaultPrevented||z))switch(T.key){case"n":case"j":{C&&T.ctrlKey&&I(T);break}case"ArrowDown":{I(T);break}case"p":case"k":{C&&T.ctrlKey&&W(T);break}case"ArrowUp":{W(T);break}case"Home":{T.preventDefault(),S(0);break}case"End":{T.preventDefault(),E();break}case"Enter":{T.preventDefault();let U=M();if(U){let V=new Event(Vr);U.dispatchEvent(V)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:x.inputId,id:x.labelId,style:pv},h),ar(e,T=>m.createElement(Kl.Provider,{value:N},m.createElement(Gl.Provider,{value:x},T))))}),rv=m.forwardRef((e,t)=>{var n,r;let o=Ce(),s=m.useRef(null),a=m.useContext(ql),i=gn(),h=Xl(e),f=(r=(n=h.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;kt(()=>{if(!f)return i.item(o,a==null?void 0:a.id)},[f]);let c=Ql(o,s,[e.value,e.children,s],e.keywords),l=Oo(),u=ct(k=>k.value&&k.value===c.current),p=ct(k=>f||i.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);m.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(Vr,g),()=>k.removeEventListener(Vr,g)},[p,e.onSelect,e.disabled]);function g(){var k,N;v(),(N=(k=h.current).onSelect)==null||N.call(k,c.current)}function v(){l.setState("value",c.current,!0)}if(!p)return null;let{disabled:C,value:y,onSelect:R,forceMount:j,keywords:_,...$}=e;return m.createElement(ut.div,{ref:We(s,t),...$,id:o,"cmdk-item":"",role:"option","aria-disabled":!!C,"aria-selected":!!u,"data-disabled":!!C,"data-selected":!!u,onPointerMove:C||i.getDisablePointerSelection()?void 0:v,onClick:C?void 0:g},e.children)}),ov=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,a=Ce(),i=m.useRef(null),h=m.useRef(null),f=Ce(),c=gn(),l=ct(p=>o||c.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);kt(()=>c.group(a),[]),Ql(a,i,[e.value,e.heading,h]);let u=m.useMemo(()=>({id:a,forceMount:o}),[o]);return m.createElement(ut.div,{ref:We(i,t),...s,"cmdk-group":"",role:"presentation",hidden:l?void 0:!0},n&&m.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),ar(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},m.createElement(ql.Provider,{value:u},p))))}),sv=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=ct(a=>!a.search);return!n&&!s?null:m.createElement(ut.div,{ref:We(o,t),...r,"cmdk-separator":"",role:"separator"})}),av=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Oo(),a=ct(f=>f.search),i=ct(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ut.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":i,id:h.inputId,type:"text",value:o?e.value:a,onChange:f=>{o||s.setState("search",f.target.value),n==null||n(f.target.value)}})}),iv=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),a=m.useRef(null),i=ct(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{if(a.current&&s.current){let f=a.current,c=s.current,l,u=new ResizeObserver(()=>{l=requestAnimationFrame(()=>{let p=f.offsetHeight;c.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return u.observe(f),()=>{cancelAnimationFrame(l),u.unobserve(f)}}},[]),m.createElement(ut.div,{ref:We(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":r,id:h.listId},ar(e,f=>m.createElement("div",{ref:We(a,h.listInnerRef),"cmdk-list-sizer":""},f)))}),lv=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:a,...i}=e;return m.createElement(Bi,{open:n,onOpenChange:r},m.createElement(Wi,{container:a},m.createElement(Hi,{"cmdk-overlay":"",className:o}),m.createElement(Vi,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Yl,{ref:t,...i}))))}),cv=m.forwardRef((e,t)=>ct(n=>n.filtered.count===0)?m.createElement(ut.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),dv=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(ut.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ar(e,a=>m.createElement("div",{"aria-hidden":!0},a)))}),Vt=Object.assign(Yl,{List:iv,Item:rv,Input:av,Group:ov,Separator:sv,Dialog:lv,Empty:cv,Loading:dv});function uv(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fv(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Xl(e){let t=m.useRef(e);return kt(()=>{t.current=e}),t}var kt=typeof window>"u"?m.useEffect:m.useLayoutEffect;function It(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function ct(e){let t=Oo(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Ql(e,t,n,r=[]){let o=m.useRef(),s=gn();return kt(()=>{var a;let i=(()=>{var f;for(let c of n){if(typeof c=="string")return c.trim();if(typeof c=="object"&&"current"in c)return c.current?(f=c.current.textContent)==null?void 0:f.trim():o.current}})(),h=r.map(f=>f.trim());s.value(e,i,h),(a=t.current)==null||a.setAttribute(Tt,i),o.current=i}),o}var hv=()=>{let[e,t]=m.useState(),n=It(()=>new Map);return kt(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function mv(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ar({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(mv(t),{ref:t.ref},n(t.props.children)):n(t)}var pv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function gv({className:e,...t}){return d.jsx(Vt,{"data-slot":"command",className:Z("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function xv({className:e,...t}){return d.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[d.jsx(Xd,{className:"size-4 shrink-0 opacity-50"}),d.jsx(Vt.Input,{"data-slot":"command-input",className:Z("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function vv({className:e,...t}){return d.jsx(Vt.List,{"data-slot":"command-list",className:Z("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function bv({...e}){return d.jsx(Vt.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function yv({className:e,...t}){return d.jsx(Vt.Group,{"data-slot":"command-group",className:Z("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function wv({className:e,...t}){return d.jsx(Vt.Item,{"data-slot":"command-item",className:Z("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function js(e,t){if(!e)return!0;const n=e.toLowerCase(),r=t.toLowerCase();let o=0;for(let s=0;s<r.length&&o<n.length;s++)r[s]===n[o]&&o++;return o===n.length}function Cv({models:e,currentModelId:t,onSelect:n,showSearch:r=!0,isMobile:o=!1}){const[s,a]=m.useState(""),[i,h]=m.useState(o?"__none__":void 0),f=m.useMemo(()=>s?e.filter(c=>js(s,c.name)||js(s,c.modelId)):e,[e,s]);return d.jsxs(gv,{shouldFilter:!1,value:i,onValueChange:h,children:[r&&d.jsx(xv,{placeholder:"Select a model…",value:s,onValueChange:a}),d.jsxs(vv,{children:[d.jsx(bv,{children:"No models found."}),d.jsx(yv,{children:f.map(c=>d.jsxs(wv,{value:c.modelId,onSelect:()=>n(c),className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[d.jsx("span",{className:"truncate font-medium",children:c.name}),c.description&&d.jsx("span",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),d.jsx(wt,{className:Z("h-4 w-4 shrink-0",t===c.modelId?"opacity-100":"opacity-0")})]},c.modelId))})]})]})}function Zl(e){const[t,n]=m.useState(e.modelState),[r,o]=m.useState(!1);m.useEffect(()=>{const f=l=>{if(n(l),l&&l.availableModels.length>0){const u=localStorage.getItem("acp_model_id");u&&u!==l.currentModelId&&l.availableModels.some(p=>p.modelId===u)&&e.setSessionModel(u).catch(()=>{})}},c=l=>{n(u=>u?{...u,currentModelId:l}:null),o(!1)};return e.setModelStateChangedHandler(f),e.setModelChangedHandler(c),()=>{e.removeModelStateChangedHandler(f),e.removeModelChangedHandler(c)}},[e]);const s=m.useMemo(()=>(t==null?void 0:t.availableModels)??[],[t]),a=(t==null?void 0:t.currentModelId)??null,i=m.useMemo(()=>s.find(f=>f.modelId===a)??null,[s,a]),h=m.useCallback(async f=>{if(!t)throw new Error("Model selection not supported");o(!0);try{await e.setSessionModel(f),localStorage.setItem("acp_model_id",f)}catch(c){throw o(!1),c}},[e,t]);return{supportsModelSelection:t!==null&&s.length>0,availableModels:s,currentModelId:a,currentModel:i,setModel:h,isLoading:r}}function Sv({client:e,onModelSelect:t}){const[n,r]=m.useState(!1),{supportsModelSelection:o,availableModels:s,currentModel:a,setModel:i,isLoading:h}=Zl(e),f=o&&s.length>0,c=typeof window<"u"&&window.matchMedia("(hover: none) and (pointer: coarse)").matches,l=async u=>{try{await i(u.modelId),t==null||t(u.modelId),r(!1)}catch(p){console.error("[ModelSelector] Failed to set model:",p)}};return d.jsxs(zl,{open:n,onOpenChange:f?r:void 0,children:[d.jsx(Bl,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"gap-1.5 text-muted-foreground hover:text-foreground h-7 px-2",disabled:!f||h,children:[h?d.jsx(na,{className:"h-3 w-3 animate-spin"}):null,d.jsx("span",{className:"max-w-32 truncate",children:(a==null?void 0:a.name)??"Select Model"}),n?d.jsx(Zs,{className:"h-3 w-3"}):d.jsx(sn,{className:"h-3 w-3"})]})}),d.jsx(Wl,{className:"w-72 p-0",align:"end",children:d.jsx(Cv,{models:s,currentModelId:(a==null?void 0:a.modelId)??null,onSelect:l,showSearch:!c,isMobile:c})})]})}function kv(e){const[t,n]=m.useState(e.availableCommands);m.useEffect(()=>{const o=s=>{n(s)};return e.setAvailableCommandsChangedHandler(o),()=>{e.setAvailableCommandsChangedHandler(()=>{})}},[e]);const r=m.useMemo(()=>t.length>0,[t]);return{commands:t,hasCommands:r}}const _v=new Set(["clear","new","help","status","model","copy"]),Ev=[{name:"compact",desc:"压缩上下文"},{name:"cost",desc:"查看会话费用"},{name:"summary",desc:"生成会话摘要"},{name:"files",desc:"列出上下文中的文件"}];function Nv(e){switch(e){case"help":return"Help";case"status":return"Status";case"model":return"Model";case"copy":return"Copy";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function jv(e){switch(e){case"help":return"可用命令列表";case"status":return"会话状态信息";case"model":return"查看或切换模型";case"copy":return"复制助手消息到剪贴板";default:return""}}function Av(e){var r;const t=[];t.push("**本地命令**(Web UI 直接执行)"),t.push("");const n=[{name:"clear",desc:"清空当前对话"},{name:"new",desc:"新建会话"},{name:"help",desc:"显示此帮助信息"},{name:"status",desc:"显示会话状态"},{name:"model [id]",desc:"查看或切换模型"},{name:"copy",desc:"复制最后一条助手消息"}];for(const o of n)t.push(`- \`/${o.name}\` — ${o.desc}`);t.push(""),t.push("**Agent 命令**(发给 Saluzi agent 执行)"),t.push("");for(const o of Ev)t.push(`- \`/${o.name}\` — ${o.desc}`);if(e.length>0)for(const o of e){const s=(r=o.input)!=null&&r.hint?` ${o.input.hint}`:"";t.push(`- \`/${o.name}${s}\` — ${o.description}`)}return t.join(`
276
+ `)}function Rv(e){var n,r,o;const t=["**会话状态**",""];return t.push(`- 会话 ID: \`${e.sessionId??"无"}\``),t.push(`- 当前模型: ${((n=e.currentModel)==null?void 0:n.name)??((r=e.currentModel)==null?void 0:r.modelId)??"未设置"}`),(o=e.currentModel)!=null&&o.modelId&&t.push(` - ID: \`${e.currentModel.modelId}\``),t.push(`- 可用模型数: ${e.modelCount}`),t.push(`- 图片支持: ${e.supportsImages?"是":"否"}`),t.push(`- 消息条数: ${e.entryCount}`),t.join(`
277
+ `)}function Tv(e,t){if(e.length===0)return"当前 agent 未提供模型选择能力。";const n=["**可用模型**",""];for(const r of e){const o=r.modelId===(t==null?void 0:t.modelId)?" ✓":"";n.push(`- \`${r.modelId}\` — ${r.name}${o}`)}return n.push(""),n.push("使用 `/model <id>` 切换模型。"),n.join(`
278
+ `)}async function Iv(e,t){var l;if(!e.startsWith("/"))return{handled:!1};const[n,...r]=e.slice(1).split(/\s+/),o=r.join(" ").trim(),s=n==null?void 0:n.toLowerCase();if(!s||!_v.has(s))return{handled:!1};if(s==="clear")return{handled:!0,clearEntries:!0};if(s==="new")return{handled:!0,newSession:!0};let a="",i=!1;if(s==="help")a=Av(t.availableCommands);else if(s==="status")a=Rv({sessionId:t.sessionId,currentModel:t.currentModel,supportsImages:t.supportsImages,modelCount:t.availableModels.length,entryCount:t.entries.length});else if(s==="model")if(o)try{await t.setModel(o),a=`已请求切换到模型: \`${o}\``}catch(u){a=`切换模型失败: ${u instanceof Error?u.message:String(u)}`,i=!0}else a=Tv(t.availableModels,t.currentModel);else if(s==="copy"){const u=[...t.entries].reverse().find(g=>g.type==="assistant_message"),p=((l=u==null?void 0:u.chunks)==null?void 0:l.map(g=>g.text).join(`
279
+ `))??"";try{await navigator.clipboard.writeText(p),a=p?`已复制 ${p.length} 字符到剪贴板`:"没有可复制的助手消息"}catch{a="复制失败:剪贴板不可用",i=!0}}const h=Date.now(),f={type:"user_message",id:`user-${h}`,content:e},c={type:"command_output",id:`cmd-${h}`,commandName:s,inputText:e,title:Nv(s),subtitle:jv(s),outputText:a,variant:i?"error":"default"};return{handled:!0,userEntry:f,cmdEntry:c}}const Mv={maxSizeMB:2,maxWidthOrHeight:2048,useWebWorker:!0,fileType:"image/jpeg"};function Pv(e){const t=e.indexOf(",");if(t===-1)throw new Error("Invalid data URL: missing comma separator");const n=e.slice(0,t),r=e.slice(t+1),o=n.match(/^data:([^;,]+)/),s=o?o[1]:"application/octet-stream",a=atob(r),i=new Uint8Array(a.length);for(let h=0;h<a.length;h++)i[h]=a.charCodeAt(h);return new Blob([i],{type:s})}const Nr=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"dontAsk",label:"不询问",description:"不弹出询问,自动拒绝"},{value:"auto",label:"自动判断",description:"AI 自动判断是否批准"}];function Ov({mode:e,onModeChange:t}){const[n,r]=m.useState(!1),o=Nr.find(s=>s.value===e)??Nr[0];return d.jsxs(zl,{open:n,onOpenChange:r,children:[d.jsx(Bl,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"gap-1.5 text-muted-foreground hover:text-foreground h-7 px-2",children:[d.jsx(ou,{className:"h-3 w-3"}),d.jsx("span",{className:"max-w-24 truncate",children:o.label}),n?d.jsx(Zs,{className:"h-3 w-3"}):d.jsx(sn,{className:"h-3 w-3"})]})}),d.jsx(Wl,{className:"w-64 p-1",align:"start",children:Nr.map(s=>d.jsxs("button",{type:"button",onClick:()=>{t(s.value),r(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[d.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:e===s.value&&d.jsx(wt,{className:"h-3.5 w-3.5 text-brand"})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"text-sm font-medium text-text-primary",children:s.label}),d.jsx("div",{className:"text-xs text-text-muted",children:s.description})]})]},s.value))})]})}function As(e){return e==="completed"?"complete":e==="failed"?"error":"running"}function jr(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}function Dv({client:e,agentId:t}){const[n,r]=m.useState([]),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),c=m.useRef(null),l=m.useRef(n);l.current=n;const[u,p]=m.useState(null),g=m.useRef(null),[v,C]=m.useState(()=>localStorage.getItem("acp_permission_mode")||"default"),[y,R]=m.useState(!1),{commands:j}=kv(e),{availableModels:_,currentModel:$,setModel:k}=Zl(e);m.useEffect(()=>{c.current=h},[h]);const N=m.useCallback(()=>{r([]),s(!1),i(!1)},[]),x=t?`acp_last_session_${t}`:null,b=m.useCallback((L,E)=>{if(((E==null?void 0:E.resetEntries)??!0)&&(r([]),s(!1)),f(L),i(!0),R(e.supportsImages),x)try{localStorage.setItem(x,L)}catch{}console.log("[ChatInterface] Active session:",L,"supportsImages:",e.supportsImages)},[e,x]),A=m.useCallback(L=>{c.current&&L.sessionId!==c.current||(console.log("[ChatInterface] Permission request:",L),r(E=>{const I=jr(E,L.toolCall.toolCallId);if(I>=0)return E.map((W,T)=>T!==I||W.type!=="tool_call"||W.toolCall.status!=="running"?W:{type:"tool_call",toolCall:{...W.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:L.requestId,options:L.options}}});{console.log("[ChatInterface] No matching tool call, creating standalone permission request");const W={type:"tool_call",toolCall:{id:L.toolCall.toolCallId,title:L.toolCall.title||"Permission Request",status:"waiting_for_confirmation",permissionRequest:{requestId:L.requestId,options:L.options},isStandalonePermission:!0}};return[...E,W]}}))},[]),O=m.useCallback((L,E)=>{if(!(c.current&&L!==c.current))if(E.sessionUpdate==="agent_message_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="assistant_message"){const z=T.chunks[T.chunks.length-1];return(z==null?void 0:z.type)==="message"?[...W.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"message",text:z.text+I}]}]:[...W.slice(0,-1),{...T,chunks:[...T.chunks,{type:"message",text:I}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:I}]};return[...W,B]})}else if(E.sessionUpdate==="agent_thought_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="assistant_message"){const z=T.chunks[T.chunks.length-1];return(z==null?void 0:z.type)==="thought"?[...W.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"thought",text:z.text+I}]}]:[...W.slice(0,-1),{...T,chunks:[...T.chunks,{type:"thought",text:I}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"thought",text:I}]};return[...W,B]})}else if(E.sessionUpdate==="user_message_chunk"){const I=E.content.type==="text"&&E.content.text?E.content.text:"";if(!I)return;r(W=>{const T=W[W.length-1];if((T==null?void 0:T.type)==="user_message")return[...W.slice(0,-1),{...T,content:T.content+I}];const B={type:"user_message",id:`user-${Date.now()}`,content:I};return[...W,B]})}else if(E.sessionUpdate==="tool_call"){const I={id:E.toolCallId,title:E.title,status:As(E.status),content:E.content,rawInput:E.rawInput,rawOutput:E.rawOutput};r(W=>{const T=jr(W,E.toolCallId);if(T>=0)return W.map((z,U)=>U!==T||z.type!=="tool_call"?z:{type:"tool_call",toolCall:{...z.toolCall,...I}});const B={type:"tool_call",toolCall:I};return[...W,B]})}else E.sessionUpdate==="tool_call_update"?r(I=>{const W=jr(I,E.toolCallId);if(W<0){console.warn(`[ChatInterface] Tool call not found for update: ${E.toolCallId}`);const T={type:"tool_call",toolCall:{id:E.toolCallId,title:E.title||"Tool call not found",status:"error",content:[{type:"content",content:{type:"text",text:"Tool call not found"}}]}};return[...I,T]}return I.map((T,B)=>{if(B!==W||T.type!=="tool_call")return T;const z=E.status?As(E.status):T.toolCall.status,U=E.content?[...T.toolCall.content||[],...E.content]:T.toolCall.content;return{type:"tool_call",toolCall:{...T.toolCall,status:z,...E.title&&{title:E.title},content:U,...E.rawInput&&{rawInput:E.rawInput},...E.rawOutput&&{rawOutput:E.rawOutput}}}})}):E.sessionUpdate==="plan"&&r(I=>{if(E.entries.length===0)return I.filter(B=>B.type!=="plan");const W=I.reduce((B,z,U)=>z.type==="plan"?U:B,-1);if(W>=0)return I.map((B,z)=>z===W?{...B,entries:E.entries}:B);const T={type:"plan",id:`plan-${Date.now()}`,entries:E.entries};return[...I,T]})},[]);m.useEffect(()=>{e.setSessionCreatedHandler(E=>{console.log("[ChatInterface] Session created:",E),b(E)}),e.setSessionLoadedHandler(E=>{console.log("[ChatInterface] Session loaded/resumed:",E),b(E,{resetEntries:!1})}),e.setSessionSwitchingHandler(E=>{console.log("[ChatInterface] Switching to session:",E),f(E),N()}),e.setSessionUpdateHandler((E,I)=>{O(E,I)}),e.setPromptCompleteHandler(E=>{console.log("[ChatInterface] Prompt complete:",E),s(!1)}),e.setPermissionRequestHandler(A),e.setErrorMessageHandler(E=>{console.error("[ChatInterface] Agent error:",E),p(E),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>p(null),5e3)});const L=x?localStorage.getItem(x):null;return L&&(e.supportsLoadSession||e.supportsResumeSession)?(console.log("[ChatInterface] Restoring session:",L),(async()=>{try{e.supportsLoadSession?await e.loadSession({sessionId:L}):await e.resumeSession({sessionId:L})}catch(I){console.warn("[ChatInterface] Failed to restore session, creating new one:",I),e.createSession(void 0,v)}})()):e.createSession(void 0,v),()=>{g.current&&clearTimeout(g.current),e.setSessionCreatedHandler(()=>{}),e.setSessionLoadedHandler(()=>{}),e.setSessionSwitchingHandler(null),e.setSessionUpdateHandler(()=>{}),e.setPromptCompleteHandler(()=>{}),e.setPermissionRequestHandler(()=>{}),e.setErrorMessageHandler(()=>{})}},[b,e,A,O,N]);const P=m.useCallback(()=>{console.log("[ChatInterface] Creating new session..."),o&&e.cancel(),N(),f(null),e.createSession(void 0,v)},[e,o,N,v]),F=()=>{console.log("[ChatInterface] Cancel requested"),r(L=>L.map(E=>E.type!=="tool_call"||!(E.toolCall.status==="running"||E.toolCall.status==="waiting_for_confirmation")?E:(console.log("[ChatInterface] Marking tool call as canceled:",E.toolCall.id),{type:"tool_call",toolCall:{...E.toolCall,status:"canceled",permissionRequest:void 0}}))),e.cancel()},M=m.useCallback((L,E,I)=>{console.log("[ChatInterface] Permission response:",{requestId:L,optionId:E,optionKind:I}),e.respondToPermission(L,E);const W=I==="reject_once"||I==="reject_always"||E===null;r(T=>T.map(B=>{var U;if(B.type!=="tool_call"||((U=B.toolCall.permissionRequest)==null?void 0:U.requestId)!==L)return B;let z;return W?z="rejected":B.toolCall.isStandalonePermission?z="complete":z="running",{type:"tool_call",toolCall:{...B.toolCall,status:z,permissionRequest:void 0,isStandalonePermission:void 0}}}))},[e]),D=n.filter(L=>L.type==="tool_call"&&L.toolCall.status==="waiting_for_confirmation"&&!!L.toolCall.permissionRequest).map(L=>({requestId:L.toolCall.permissionRequest.requestId,toolName:L.toolCall.title,toolInput:L.toolCall.rawInput||{},description:L.toolCall.title,options:L.toolCall.permissionRequest.options})),S=m.useCallback((L,E)=>{const I=D.find(B=>B.requestId===L);let W=null,T=null;if(I!=null&&I.options&&I.options.length>0)if(E){const B=I.options.find(z=>z.kind==="allow_once")??I.options.find(z=>z.kind==="allow_always");B&&(W=B.optionId,T=B.kind)}else{const B=I.options.find(z=>z.kind==="reject_once")??I.options.find(z=>z.kind==="reject_always");B&&(W=B.optionId,T=B.kind)}W||(T=E?"allow_once":"reject_once"),M(L,W,T)},[M,D]),w=m.useCallback(async L=>{var V;const E=L.text.trim(),I=L.images||[],W=L.attachments||[];if(!E&&I.length===0&&W.length===0||o||!a)return;if(E.startsWith("/")&&I.length===0){yt("[ChatInterface] slash command input",{text:E});const G=await Iv(E,{sessionId:h,availableCommands:j,availableModels:_,currentModel:$,supportsImages:y,entries:l.current,setModel:k,onNewSession:P}).catch(()=>null);if(G){if(yt("[ChatInterface] local command handled",G),"clearEntries"in G&&G.clearEntries){r([]);return}if("newSession"in G&&G.newSession){P();return}if("userEntry"in G){r(X=>[...X,G.userEntry,G.cmdEntry]);return}}yt("[ChatInterface] slash command NOT in LOCAL_COMMANDS, forwarding to agent",{text:E})}yt("[ChatInterface] forwarding to agent",{text:E,hasImages:I.length>0,sessionReady:a,isLoading:o});const T=[];E&&T.push({type:"text",text:E});const B=[];for(const G of I)try{const X=`data:${G.mimeType};base64,${G.data}`;let K;X.startsWith("data:")?K=Pv(X):K=await(await fetch(X)).blob();let ne=K,ae=G.mimeType;if(K.size>2*1024*1024){const H=new File([K],"image.jpg",{type:K.type});ne=await be(H,Mv),ae="image/jpeg"}const de=await new Promise((H,q)=>{const J=new FileReader;J.onloadend=()=>{const te=J.result,ie=te.indexOf(",");H(ie>=0?te.slice(ie+1):te)},J.onerror=()=>{var te;return q(new Error("FileReader error: "+((te=J.error)==null?void 0:te.message)))},J.readAsDataURL(ne)}),me={type:"image",mimeType:ae,data:de};T.push(me),B.push({mimeType:ae,data:de})}catch(X){console.error("[ChatInterface] Failed to process image:",X)}const z=[];for(const G of W)try{if(G.textContent){let X;if(G.kind==="directory"){const K=((V=G.files)==null?void 0:V.length)??0;X=`📁 目录: ${G.name} (${K} 个文件)
280
+ ${G.textContent}`}else{const K=G.size!=null?` (${Lv(G.size)})`:"";X=`📎 ${G.name}${K}
281
281
  \`\`\`
282
282
  ${G.textContent}
283
- \`\`\``}T.push({type:"text",text:X}),z.push(G)}}catch(X){console.error("[ChatInterface] Failed to process attachment:",X)}if(T.length===0)return;const U={type:"user_message",id:`user-${Date.now()}`,content:E,images:B.length>0?B:void 0,attachments:z.length>0?z:void 0};r(G=>[...G,U]),s(!0);try{await e.sendPrompt(T)}catch(G){console.error("[ChatInterface] Failed to send prompt:",G),s(!1)}},[o,a,e,j,_,$,b,h,k,P]);return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx(px,{entries:n,isLoading:o&&!a?!1:o,onPermissionRespond:(L,E,I)=>{M(L,E,I)},emptyTitle:a?"开始对话":void 0,emptyDescription:a?"输入消息开始与 ACP agent 聊天":void 0}),d.jsx(Ax,{requests:D,onRespond:S}),u&&d.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:d.jsxs("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-2 text-sm text-red-700 dark:text-red-300 flex items-center justify-between",children:[d.jsx("span",{children:u}),d.jsx("button",{type:"button",onClick:()=>p(null),className:"ml-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-200 flex-shrink-0",children:"×"})]})}),d.jsxs("div",{className:"flex-shrink-0",children:[d.jsxs("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Pv,{mode:v,onModeChange:L=>{C(L),localStorage.setItem("acp_permission_mode",L)}}),d.jsx(Cv,{client:e})]}),n.length>0&&d.jsxs(Sg,{children:[d.jsx(kg,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"h-7 text-xs text-text-muted hover:text-brand font-display gap-1",onClick:P,children:[d.jsx(Bn,{className:"h-3 w-3"}),"新会话"]})}),d.jsx(_g,{children:"New Thread"})]})]}),d.jsx(_x,{onSubmit:w,isLoading:o,onInterrupt:F,disabled:!a,placeholder:a?"给 Saluzi 发送消息…":"等待会话...",supportsAttachments:b,commands:j.length>0?j:void 0})]})]})}function Dv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Lv({client:e,agentId:t}){const[n,r]=m.useState(!1),o=m.useCallback(async s=>{try{if(e.supportsLoadSession)await e.loadSession({sessionId:s.sessionId,cwd:s.cwd});else if(e.supportsResumeSession)await e.resumeSession({sessionId:s.sessionId,cwd:s.cwd});else throw new Error("Loading or resuming sessions is not supported by this agent.")}catch(a){console.error("Failed to load/resume session:",a)}},[e]);return d.jsxs("div",{className:"flex h-full w-full",children:[d.jsxs("div",{className:Z("hidden md:flex flex-col border-r border-border/60 bg-surface-1/50 transition-all duration-200 flex-shrink-0",n?"w-12":"w-64"),children:[d.jsxs("div",{className:"flex items-center justify-between px-3 py-4",children:[!n&&d.jsx("span",{className:"text-xs font-display font-semibold text-text-muted uppercase tracking-widest px-1",children:"会话"}),d.jsxs("div",{className:Z("flex items-center gap-0.5",n&&"mx-auto"),children:[!n&&d.jsx("button",{type:"button",onClick:()=>{},className:"h-7 w-7 flex items-center justify-center rounded-lg text-text-muted hover:text-brand hover:bg-brand/10 transition-colors",title:"新会话",children:d.jsx(Bn,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:()=>r(!n),className:"h-7 w-7 flex items-center justify-center rounded-lg text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors",children:n?d.jsx(zd,{className:"h-4 w-4"}):d.jsx(Fd,{className:"h-4 w-4"})})]})]}),!n&&d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx($v,{client:e,onSelectSession:o})})]}),d.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:d.jsx(Ov,{client:e,agentId:t})})]})}function $v({client:e,onSelectSession:t}){const[n,r]=m.useState([]),[o,s]=m.useState(!0),[a,i]=m.useState(null),h=m.useCallback(async()=>{if(!e.supportsSessionList){s(!1);return}s(!0);try{const l=await e.listSessions();r(l.sessions)}catch(l){console.warn("[SidebarSessionList] Failed to load:",l)}finally{s(!1)}},[e]);m.useEffect(()=>{e.getState()==="connected"&&e.supportsSessionList&&h()},[e,h]),m.useEffect(()=>{const l=u=>{u==="connected"&&setTimeout(h,200)};return e.setConnectionStateHandler(l),()=>e.removeConnectionStateHandler(l)},[e,h]),m.useEffect(()=>{const l=setInterval(h,1e4);return()=>clearInterval(l)},[h]);const f=m.useMemo(()=>[...n].sort((l,u)=>{const p=l.updatedAt?new Date(l.updatedAt).getTime():0;return(u.updatedAt?new Date(u.updatedAt).getTime():0)-p}),[n]);if(o&&n.length===0)return d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-xs text-text-muted font-display",children:"加载中..."})});if(n.length===0)return d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-xs text-text-muted font-display",children:"暂无会话"})});const c=Fv(f);return d.jsx("nav",{className:"py-1","aria-label":"历史会话",children:c.map((l,u)=>d.jsxs("div",{children:[u>0&&d.jsx("div",{className:"mx-3 my-2 border-t border-border/40"}),d.jsx("div",{className:"px-4 py-2",children:d.jsx("span",{className:"text-[10px] font-display font-semibold uppercase tracking-widest text-text-muted/70",children:l.label})}),l.sessions.map(p=>d.jsxs("button",{type:"button",onClick:()=>{i(p.sessionId),t(p)},className:Z("w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors rounded-none",p.sessionId===a?"bg-brand/8 text-text-primary":"text-text-secondary hover:bg-surface-2/60 hover:text-text-primary"),title:p.title||p.sessionId,children:[d.jsx(Pd,{className:"h-3.5 w-3.5 flex-shrink-0 opacity-50"}),d.jsx("span",{className:"text-[13px] font-display truncate leading-snug",children:p.title&&p.title.trim()?p.title:"新会话"})]},p.sessionId))]},l.label))})}function Fv(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),o=[{label:"今天",sessions:[]},{label:"昨天",sessions:[]},{label:"更早",sessions:[]}];for(const s of e){const a=s.updatedAt?new Date(s.updatedAt):new Date(0);a>=n?o[0].sessions.push(s):a>=r?o[1].sessions.push(s):o[2].sessions.push(s)}return o.filter(s=>s.sessions.length>0)}function Uv({url:e,token:t,onBack:n}){const[r,o]=m.useState(null),[s,a]=m.useState("disconnected"),[i,h]=m.useState(null),f=m.useRef(null);return m.useEffect(()=>{const c=new Fr({proxyUrl:e,token:t});return c.setConnectionStateHandler((l,u)=>{a(l),h(u||null)}),f.current=c,o(c),c.connect().catch(l=>{l instanceof Xi||(h(l.message),a("error"))}),()=>{c.disconnect(),f.current=null,o(null),a("disconnected")}},[e,t]),d.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i&&s==="error"&&d.jsxs("div",{className:"px-4 py-2 bg-status-error/10 text-status-error text-sm border-b",children:[i,d.jsx("button",{onClick:n,className:"ml-3 underline hover:no-underline",children:"Back to Dashboard"})]}),s==="connecting"&&d.jsx("div",{className:"flex-1 flex items-center justify-center",children:d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),d.jsx("p",{className:"text-text-muted text-sm",children:"Connecting to ACP agent..."})]})}),s==="error"&&!r&&d.jsx("div",{className:"flex-1 flex items-center justify-center",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"font-medium mb-1",children:"Connection Failed"}),d.jsx("p",{className:"text-text-muted text-sm mb-3",children:i}),d.jsx("button",{onClick:n,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Back to Dashboard"})]})}),r&&s==="connected"&&d.jsx(Lv,{client:r})]})}const Jl="rcs_tokens",ec="rcs_active_token",zt="__default__";function zv(){return`tk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Bv(e){if(e.some(n=>n.id===zt))return e;let t=null;try{t=localStorage.getItem("rcs_uuid")}catch{}return t?[{id:zt,token:t,label:"Default"},...e]:e}function Rs(){let e=[];try{const t=localStorage.getItem(Jl);if(t){const n=JSON.parse(t);Array.isArray(n)&&(e=n)}}catch{}return Bv(e)}function Wv(e){var n;try{const r=localStorage.getItem(ec);if(r&&e.some(o=>o.id===r))return r}catch{}const t=e.find(r=>r.id===zt);return t?t.id:((n=e[0])==null?void 0:n.id)??zt}function Hv(){const[e,t]=m.useState(Rs),[n,r]=m.useState(()=>Wv(Rs())),o=m.useCallback(u=>{t(u);try{localStorage.setItem(Jl,JSON.stringify(u))}catch{}},[]),s=m.useCallback(u=>{r(u);try{localStorage.setItem(ec,u),location.reload()}catch{}},[]),a=m.useCallback((u,p)=>{const g=u.trim();if(!g)return"Token is required";const v={id:zv(),token:g,label:p.trim()||g.slice(0,8)},C=[...e,v];return o(C),null},[e,o]),i=m.useCallback(u=>{if(u===zt)return;const p=e.filter(g=>g.id!==u);o(p),n===u&&s(zt)},[e,o,n,s]),h=m.useCallback((u,p)=>{const g=e.map(v=>v.id===u?{...v,label:p}:v);o(g)},[e,o]),f=e.find(u=>u.id===n)??e[0]??null,c=(f==null?void 0:f.label)??"Default",l=(f==null?void 0:f.token)??null;return{tokens:e,activeTokenId:n,activeToken:f,activeLabel:c,activeTokenValue:l,setActiveTokenId:s,addToken:a,removeToken:i,updateToken:h}}const Vv=m.lazy(()=>on(()=>import("./Dashboard-BiApZyPx.js"),__vite__mapDeps([3,2,4,1,5,6])).then(e=>({default:e.Dashboard}))),Gv=m.lazy(()=>on(()=>import("./SessionDetail-CWUE75ns.js"),__vite__mapDeps([7,2,4,1,5,6])).then(e=>({default:e.SessionDetail})));function Kv(){const[e,t]=m.useState(null),[n,r]=m.useState(void 0),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),{tokens:c,activeTokenId:l,activeLabel:u,activeTokenValue:p,setActiveTokenId:g,addToken:v,removeToken:C,updateToken:b}=Hv();m.useEffect(()=>{dp(p)},[p]);const R=m.useCallback(k=>{g(k)},[g]),j=m.useCallback(()=>{bo();const k=window.location.pathname,N=new URLSearchParams(window.location.search),x=N.get("uuid");if(x){_n(x);const P=new URL(window.location.href);P.searchParams.delete("uuid"),window.history.replaceState(null,"",P)}if(N.get("acp")==="1"){const P=sessionStorage.getItem("acp_connection");if(P)try{const F=JSON.parse(P);if(F.url&&F.token){f({url:F.url,token:F.token}),sessionStorage.removeItem("acp_connection");const M=new URL(window.location.href);M.searchParams.delete("acp"),window.history.replaceState(null,"",M);return}}catch{sessionStorage.removeItem("acp_connection")}}const A=N.get("sid");if(A){new URL(window.location.href).searchParams.delete("sid"),window.history.replaceState(null,"",`/code/${A}`),t(A),pp(A).catch(F=>{console.warn("Failed to bind session:",F)});return}const O=k.match(/^\/code\/([^/]+)/);O&&O[1]?(t(O[1]),r(void 0)):(t(null),r(void 0))},[]);m.useEffect(()=>(j(),window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)),[j]);const _=m.useCallback(k=>{window.history.pushState(null,"",`/code/${k}`),t(k),r(void 0)},[]),$=m.useCallback(()=>{window.history.pushState(null,"","/code/"),t(null),r(void 0),f(null)},[]);return d.jsx(vu,{defaultTheme:"system",children:d.jsxs("div",{className:"flex h-screen flex-col bg-surface-0 text-text-primary",children:[d.jsx(ip,{onIdentityClick:()=>s(!0),onTokenClick:()=>i(!0),activeTokenLabel:e?void 0:u,sessionTitle:e||(h?"ACP":void 0),sessionSource:h?"acp":n,onBack:e||h?$:void 0}),d.jsx(m.Suspense,{fallback:d.jsx("div",{className:"flex flex-1 items-center justify-center text-text-muted",children:"Loading..."}),children:h?d.jsx(Uv,{url:h.url,token:h.token,onBack:$}):e?d.jsx(Gv,{sessionId:e,onSessionLoaded:k=>r(k.source)},e):d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx(Vv,{onNavigateSession:_})})}),d.jsx(Dp,{open:o,onClose:()=>s(!1)}),d.jsx(Fp,{open:a,onClose:()=>i(!1),tokens:c,activeTokenId:l,onSetActive:R,onAdd:v,onRemove:C,onUpdate:b})]})})}ac.createRoot(document.getElementById("root")).render(d.jsx(m.StrictMode,{children:d.jsx(Kv,{})}));export{Fr as A,Jv as B,_x as C,Gi as D,nd as E,oy as F,bo as G,hp as H,Lr as I,ey as J,xy as K,na as L,sy as M,ay as N,up as O,ty as P,Tv as Q,Jc as R,du as S,Cg as T,Lv as a,mp as b,px as c,wt as d,Ki as e,gy as f,qi as g,Yi as h,Xi as i,ry as j,sa as k,pp as l,my as m,hy as n,iy as o,gp as p,ly as q,cy as r,fy as s,uy as t,dy as u,Ds as v,Z as w,re as x,bt as y,ed as z};
283
+ \`\`\``}T.push({type:"text",text:X}),z.push(G)}}catch(X){console.error("[ChatInterface] Failed to process attachment:",X)}if(T.length===0)return;const U={type:"user_message",id:`user-${Date.now()}`,content:E,images:B.length>0?B:void 0,attachments:z.length>0?z:void 0};r(G=>[...G,U]),s(!0);try{await e.sendPrompt(T)}catch(G){console.error("[ChatInterface] Failed to send prompt:",G),s(!1)}},[o,a,e,j,_,$,y,h,k,P]);return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx(gx,{entries:n,isLoading:o&&!a?!1:o,onPermissionRespond:(L,E,I)=>{M(L,E,I)},emptyTitle:a?"开始对话":void 0,emptyDescription:a?"输入消息开始与 ACP agent 聊天":void 0}),d.jsx(Rx,{requests:D,onRespond:S}),u&&d.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:d.jsxs("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-2 text-sm text-red-700 dark:text-red-300 flex items-center justify-between",children:[d.jsx("span",{children:u}),d.jsx("button",{type:"button",onClick:()=>p(null),className:"ml-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-200 flex-shrink-0",children:"×"})]})}),d.jsxs("div",{className:"flex-shrink-0",children:[d.jsxs("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Ov,{mode:v,onModeChange:L=>{C(L),localStorage.setItem("acp_permission_mode",L)}}),d.jsx(Sv,{client:e})]}),n.length>0&&d.jsxs(kg,{children:[d.jsx(_g,{asChild:!0,children:d.jsxs(Et,{variant:"ghost",size:"sm",className:"h-7 text-xs text-text-muted hover:text-brand font-display gap-1",onClick:P,children:[d.jsx(Bn,{className:"h-3 w-3"}),"新会话"]})}),d.jsx(Eg,{children:"New Thread"})]})]}),d.jsx(Ex,{onSubmit:w,isLoading:o,onInterrupt:F,disabled:!a,placeholder:a?"给 Saluzi 发送消息…":"等待会话...",supportsAttachments:y,commands:j.length>0?j:void 0})]})]})}function Lv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function $v({client:e,agentId:t}){const[n,r]=m.useState(!1),o=m.useCallback(async s=>{try{if(e.supportsLoadSession)await e.loadSession({sessionId:s.sessionId,cwd:s.cwd});else if(e.supportsResumeSession)await e.resumeSession({sessionId:s.sessionId,cwd:s.cwd});else throw new Error("Loading or resuming sessions is not supported by this agent.")}catch(a){console.error("Failed to load/resume session:",a)}},[e]);return d.jsxs("div",{className:"flex h-full w-full",children:[d.jsxs("div",{className:Z("hidden md:flex flex-col border-r border-border/60 bg-surface-1/50 transition-all duration-200 flex-shrink-0",n?"w-12":"w-64"),children:[d.jsxs("div",{className:"flex items-center justify-between px-3 py-4",children:[!n&&d.jsx("span",{className:"text-xs font-display font-semibold text-text-muted uppercase tracking-widest px-1",children:"会话"}),d.jsxs("div",{className:Z("flex items-center gap-0.5",n&&"mx-auto"),children:[!n&&d.jsx("button",{type:"button",onClick:()=>{},className:"h-7 w-7 flex items-center justify-center rounded-lg text-text-muted hover:text-brand hover:bg-brand/10 transition-colors",title:"新会话",children:d.jsx(Bn,{className:"h-4 w-4"})}),d.jsx("button",{type:"button",onClick:()=>r(!n),className:"h-7 w-7 flex items-center justify-center rounded-lg text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors",children:n?d.jsx(zd,{className:"h-4 w-4"}):d.jsx(Fd,{className:"h-4 w-4"})})]})]}),!n&&d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx(Fv,{client:e,onSelectSession:o})})]}),d.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:d.jsx(Dv,{client:e,agentId:t})})]})}function Fv({client:e,onSelectSession:t}){const[n,r]=m.useState([]),[o,s]=m.useState(!0),[a,i]=m.useState(null),h=m.useCallback(async()=>{if(!e.supportsSessionList){s(!1);return}s(!0);try{const l=await e.listSessions();r(l.sessions)}catch(l){console.warn("[SidebarSessionList] Failed to load:",l)}finally{s(!1)}},[e]);m.useEffect(()=>{e.getState()==="connected"&&e.supportsSessionList&&h()},[e,h]),m.useEffect(()=>{const l=u=>{u==="connected"&&setTimeout(h,200)};return e.setConnectionStateHandler(l),()=>e.removeConnectionStateHandler(l)},[e,h]),m.useEffect(()=>{const l=setInterval(h,1e4);return()=>clearInterval(l)},[h]);const f=m.useMemo(()=>[...n].sort((l,u)=>{const p=l.updatedAt?new Date(l.updatedAt).getTime():0;return(u.updatedAt?new Date(u.updatedAt).getTime():0)-p}),[n]);if(o&&n.length===0)return d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-xs text-text-muted font-display",children:"加载中..."})});if(n.length===0)return d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-xs text-text-muted font-display",children:"暂无会话"})});const c=Uv(f);return d.jsx("nav",{className:"py-1","aria-label":"历史会话",children:c.map((l,u)=>d.jsxs("div",{children:[u>0&&d.jsx("div",{className:"mx-3 my-2 border-t border-border/40"}),d.jsx("div",{className:"px-4 py-2",children:d.jsx("span",{className:"text-[10px] font-display font-semibold uppercase tracking-widest text-text-muted/70",children:l.label})}),l.sessions.map(p=>d.jsxs("button",{type:"button",onClick:()=>{i(p.sessionId),t(p)},className:Z("w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors rounded-none",p.sessionId===a?"bg-brand/8 text-text-primary":"text-text-secondary hover:bg-surface-2/60 hover:text-text-primary"),title:p.title||p.sessionId,children:[d.jsx(Pd,{className:"h-3.5 w-3.5 flex-shrink-0 opacity-50"}),d.jsx("span",{className:"text-[13px] font-display truncate leading-snug",children:p.title&&p.title.trim()?p.title:"新会话"})]},p.sessionId))]},l.label))})}function Uv(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),o=[{label:"今天",sessions:[]},{label:"昨天",sessions:[]},{label:"更早",sessions:[]}];for(const s of e){const a=s.updatedAt?new Date(s.updatedAt):new Date(0);a>=n?o[0].sessions.push(s):a>=r?o[1].sessions.push(s):o[2].sessions.push(s)}return o.filter(s=>s.sessions.length>0)}function zv({url:e,token:t,onBack:n}){const[r,o]=m.useState(null),[s,a]=m.useState("disconnected"),[i,h]=m.useState(null),f=m.useRef(null);return m.useEffect(()=>{const c=new Fr({proxyUrl:e,token:t});return c.setConnectionStateHandler((l,u)=>{a(l),h(u||null)}),f.current=c,o(c),c.connect().catch(l=>{l instanceof Xi||(h(l.message),a("error"))}),()=>{c.disconnect(),f.current=null,o(null),a("disconnected")}},[e,t]),d.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i&&s==="error"&&d.jsxs("div",{className:"px-4 py-2 bg-status-error/10 text-status-error text-sm border-b",children:[i,d.jsx("button",{onClick:n,className:"ml-3 underline hover:no-underline",children:"Back to Dashboard"})]}),s==="connecting"&&d.jsx("div",{className:"flex-1 flex items-center justify-center",children:d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),d.jsx("p",{className:"text-text-muted text-sm",children:"Connecting to ACP agent..."})]})}),s==="error"&&!r&&d.jsx("div",{className:"flex-1 flex items-center justify-center",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"font-medium mb-1",children:"Connection Failed"}),d.jsx("p",{className:"text-text-muted text-sm mb-3",children:i}),d.jsx("button",{onClick:n,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Back to Dashboard"})]})}),r&&s==="connected"&&d.jsx($v,{client:r})]})}const Jl="rcs_tokens",ec="rcs_active_token",zt="__default__";function Bv(){return`tk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Wv(e){if(e.some(n=>n.id===zt))return e;let t=null;try{t=localStorage.getItem("rcs_uuid")}catch{}return t?[{id:zt,token:t,label:"Default"},...e]:e}function Rs(){let e=[];try{const t=localStorage.getItem(Jl);if(t){const n=JSON.parse(t);Array.isArray(n)&&(e=n)}}catch{}return Wv(e)}function Hv(e){var n;try{const r=localStorage.getItem(ec);if(r&&e.some(o=>o.id===r))return r}catch{}const t=e.find(r=>r.id===zt);return t?t.id:((n=e[0])==null?void 0:n.id)??zt}function Vv(){const[e,t]=m.useState(Rs),[n,r]=m.useState(()=>Hv(Rs())),o=m.useCallback(u=>{t(u);try{localStorage.setItem(Jl,JSON.stringify(u))}catch{}},[]),s=m.useCallback(u=>{r(u);try{localStorage.setItem(ec,u),location.reload()}catch{}},[]),a=m.useCallback((u,p)=>{const g=u.trim();if(!g)return"Token is required";const v={id:Bv(),token:g,label:p.trim()||g.slice(0,8)},C=[...e,v];return o(C),null},[e,o]),i=m.useCallback(u=>{if(u===zt)return;const p=e.filter(g=>g.id!==u);o(p),n===u&&s(zt)},[e,o,n,s]),h=m.useCallback((u,p)=>{const g=e.map(v=>v.id===u?{...v,label:p}:v);o(g)},[e,o]),f=e.find(u=>u.id===n)??e[0]??null,c=(f==null?void 0:f.label)??"Default",l=(f==null?void 0:f.token)??null;return{tokens:e,activeTokenId:n,activeToken:f,activeLabel:c,activeTokenValue:l,setActiveTokenId:s,addToken:a,removeToken:i,updateToken:h}}const Gv=m.lazy(()=>on(()=>import("./Dashboard-BjLgSBGe.js"),__vite__mapDeps([3,2,1,4,5])).then(e=>({default:e.Dashboard}))),Kv=m.lazy(()=>on(()=>import("./SessionDetail-CruRK24e.js"),__vite__mapDeps([6,2,1,4,5])).then(e=>({default:e.SessionDetail})));function qv(){const[e,t]=m.useState(null),[n,r]=m.useState(void 0),[o,s]=m.useState(!1),[a,i]=m.useState(!1),[h,f]=m.useState(null),{tokens:c,activeTokenId:l,activeLabel:u,activeTokenValue:p,setActiveTokenId:g,addToken:v,removeToken:C,updateToken:y}=Vv();m.useEffect(()=>{dp(p)},[p]);const R=m.useCallback(k=>{g(k)},[g]),j=m.useCallback(()=>{yo();const k=window.location.pathname,N=new URLSearchParams(window.location.search),x=N.get("uuid");if(x){_n(x);const P=new URL(window.location.href);P.searchParams.delete("uuid"),window.history.replaceState(null,"",P)}if(N.get("acp")==="1"){const P=sessionStorage.getItem("acp_connection");if(P)try{const F=JSON.parse(P);if(F.url&&F.token){f({url:F.url,token:F.token}),sessionStorage.removeItem("acp_connection");const M=new URL(window.location.href);M.searchParams.delete("acp"),window.history.replaceState(null,"",M);return}}catch{sessionStorage.removeItem("acp_connection")}}const A=N.get("sid");if(A){new URL(window.location.href).searchParams.delete("sid"),window.history.replaceState(null,"",`/code/${A}`),t(A),pp(A).catch(F=>{console.warn("Failed to bind session:",F)});return}const O=k.match(/^\/code\/([^/]+)/);O&&O[1]?(t(O[1]),r(void 0)):(t(null),r(void 0))},[]);m.useEffect(()=>(j(),window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)),[j]);const _=m.useCallback(k=>{window.history.pushState(null,"",`/code/${k}`),t(k),r(void 0)},[]),$=m.useCallback(()=>{window.history.pushState(null,"","/code/"),t(null),r(void 0),f(null)},[]);return d.jsx(vu,{defaultTheme:"system",children:d.jsxs("div",{className:"flex h-screen flex-col bg-surface-0 text-text-primary",children:[d.jsx(ip,{onIdentityClick:()=>s(!0),onTokenClick:()=>i(!0),activeTokenLabel:e?void 0:u,sessionTitle:e||(h?"ACP":void 0),sessionSource:h?"acp":n,onBack:e||h?$:void 0}),d.jsx(m.Suspense,{fallback:d.jsx("div",{className:"flex flex-1 items-center justify-center text-text-muted",children:"Loading..."}),children:h?d.jsx(zv,{url:h.url,token:h.token,onBack:$}):e?d.jsx(Kv,{sessionId:e,onSessionLoaded:k=>r(k.source)},e):d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx(Gv,{onNavigateSession:_})})}),d.jsx(Dp,{open:o,onClose:()=>s(!1)}),d.jsx(Up,{open:a,onClose:()=>i(!1),tokens:c,activeTokenId:l,onSetActive:R,onAdd:v,onRemove:C,onUpdate:y})]})})}ac.createRoot(document.getElementById("root")).render(d.jsx(m.StrictMode,{children:d.jsx(qv,{})}));export{Fr as A,eb as B,Ex as C,Gi as D,nd as E,sb as F,yo as G,hp as H,Lr as I,Fp as J,tb as K,na as L,vb as M,ab as N,ib as O,up as P,nb as Q,Iv as R,du as S,Sg as T,Jc as U,$v as a,mp as b,gx as c,wt as d,Ki as e,xb as f,qi as g,Yi as h,Xi as i,ob as j,sa as k,pp as l,pb as m,mb as n,lb as o,gp as p,cb as q,db as r,hb as s,fb as t,ub as u,Ds as v,Z as w,re as x,yt as y,ed as z};