@saluzi/saluzi-edu 0.2.2 → 0.2.4

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 (117) hide show
  1. package/dist/cli.js +47 -47
  2. package/dist/rcs-web/assets/Dashboard-ClYYELch.js +2 -0
  3. package/dist/rcs-web/assets/{SessionDetail-CWUE75ns.js → SessionDetail-D5dCDgDF.js} +3 -3
  4. package/{packages/remote-control-server/web/dist/assets/arc-4X1dRN53.js → dist/rcs-web/assets/arc-7lPfYTKR.js} +1 -1
  5. package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-CLhFlBW3.js} +1 -1
  6. package/dist/rcs-web/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-CRxDmTyw.js} +1 -1
  7. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-GhUzyEB2.js} +1 -1
  8. package/dist/rcs-web/assets/channel-DqKk-agI.js +1 -0
  9. package/dist/rcs-web/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-CdFwFvWI.js} +1 -1
  10. package/dist/rcs-web/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-Bxyari7X.js} +1 -1
  11. package/dist/rcs-web/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-B6itQfF-.js} +1 -1
  12. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BLXUmKhM.js → dist/rcs-web/assets/chunk-727SXJPM-28bp6QhF.js} +1 -1
  13. package/dist/rcs-web/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-Cin2Flu9.js} +1 -1
  14. package/dist/rcs-web/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-Bgh51Lft.js} +1 -1
  15. package/dist/rcs-web/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BmlO4Ydq.js} +1 -1
  16. package/dist/rcs-web/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-sJrTY76r.js} +1 -1
  17. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DXYJPE0n.js +1 -0
  18. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DXYJPE0n.js +1 -0
  19. package/dist/rcs-web/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-C_zrs-gT.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-B6rTlH08.js} +1 -1
  21. package/dist/rcs-web/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-_wl_w4u8.js} +1 -1
  22. package/dist/rcs-web/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-CAM1F0zx.js} +1 -1
  23. package/dist/rcs-web/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-RsfXB4M5.js} +1 -1
  24. package/dist/rcs-web/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-DgE4Jvy8.js} +1 -1
  25. package/dist/rcs-web/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-btrs7dz6.js} +1 -1
  26. package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-DJgCZbOs.js → dist/rcs-web/assets/diagram-OG6HWLK6-B81c8jdJ.js} +1 -1
  27. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DL-CzHVd.js} +1 -1
  28. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-Cl-2EwXo.js} +1 -1
  29. package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-BEUqhgIP.js} +1 -1
  30. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-DeeVgqUk.js} +1 -1
  31. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-DPqTmZOu.js} +1 -1
  32. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-5YBKCgSx.js} +1 -1
  33. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-AnSqa6Hq.js} +1 -1
  34. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-W7cAy0RU.js} +1 -1
  35. package/dist/rcs-web/assets/{linear-DjOGLk2Z.js → linear-QvmQRsBx.js} +1 -1
  36. package/dist/rcs-web/assets/main-UBLYspes.js +283 -0
  37. package/dist/rcs-web/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-Dn1LM1yF.js} +4 -4
  38. package/dist/rcs-web/assets/{mermaid.core-slLRH1UY.js → mermaid.core-C0ceVHNj.js} +5 -5
  39. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-Crj88n-9.js} +1 -1
  40. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-Boh89MZl.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-B1hrNv25.js} +1 -1
  42. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-B6BlGzlU.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BdNcjCvy.js} +1 -1
  44. package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-J9khnYhK.js} +1 -1
  45. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-iaQJb8kI.js} +1 -1
  46. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-CZgBPZ4e.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-zpFpWKc3.js} +1 -1
  48. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-Ld8wzoVI.js} +1 -1
  49. package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-iCj-ntht.js} +1 -1
  50. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-DAAD572L.js} +1 -1
  51. package/dist/rcs-web/index.html +1 -1
  52. package/package.json +2 -2
  53. package/packages/remote-control-server/src/auth/middleware.ts +24 -3
  54. package/packages/remote-control-server/src/services/disconnect-monitor.ts +32 -1
  55. package/packages/remote-control-server/src/services/session.ts +17 -0
  56. package/packages/remote-control-server/web/dist/assets/Dashboard-ClYYELch.js +2 -0
  57. package/packages/remote-control-server/web/dist/assets/{SessionDetail-CWUE75ns.js → SessionDetail-D5dCDgDF.js} +3 -3
  58. package/{dist/rcs-web/assets/arc-4X1dRN53.js → packages/remote-control-server/web/dist/assets/arc-7lPfYTKR.js} +1 -1
  59. package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-CLhFlBW3.js} +1 -1
  60. package/packages/remote-control-server/web/dist/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-CRxDmTyw.js} +1 -1
  61. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-GhUzyEB2.js} +1 -1
  62. package/packages/remote-control-server/web/dist/assets/channel-DqKk-agI.js +1 -0
  63. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-CdFwFvWI.js} +1 -1
  64. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-Bxyari7X.js} +1 -1
  65. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-B6itQfF-.js} +1 -1
  66. package/{dist/rcs-web/assets/chunk-727SXJPM-BLXUmKhM.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-28bp6QhF.js} +1 -1
  67. package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-Cin2Flu9.js} +1 -1
  68. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-Bgh51Lft.js} +1 -1
  69. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BmlO4Ydq.js} +1 -1
  70. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-sJrTY76r.js} +1 -1
  71. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DXYJPE0n.js +1 -0
  72. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DXYJPE0n.js +1 -0
  73. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-C_zrs-gT.js} +1 -1
  74. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-Bs-352tg.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-B6rTlH08.js} +1 -1
  75. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-_wl_w4u8.js} +1 -1
  76. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-CAM1F0zx.js} +1 -1
  77. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-RsfXB4M5.js} +1 -1
  78. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-DgE4Jvy8.js} +1 -1
  79. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-btrs7dz6.js} +1 -1
  80. package/{dist/rcs-web/assets/diagram-OG6HWLK6-DJgCZbOs.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-B81c8jdJ.js} +1 -1
  81. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DL-CzHVd.js} +1 -1
  82. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-Cl-2EwXo.js} +1 -1
  83. package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-BEUqhgIP.js} +1 -1
  84. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-DeeVgqUk.js} +1 -1
  85. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-DPqTmZOu.js} +1 -1
  86. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-5YBKCgSx.js} +1 -1
  87. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-AnSqa6Hq.js} +1 -1
  88. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-W7cAy0RU.js} +1 -1
  89. package/packages/remote-control-server/web/dist/assets/{linear-DjOGLk2Z.js → linear-QvmQRsBx.js} +1 -1
  90. package/packages/remote-control-server/web/dist/assets/main-UBLYspes.js +283 -0
  91. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-Dn1LM1yF.js} +4 -4
  92. package/packages/remote-control-server/web/dist/assets/{mermaid.core-slLRH1UY.js → mermaid.core-C0ceVHNj.js} +5 -5
  93. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-Crj88n-9.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-Boh89MZl.js} +1 -1
  95. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-B1hrNv25.js} +1 -1
  96. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-B6BlGzlU.js} +1 -1
  97. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BdNcjCvy.js} +1 -1
  98. package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-J9khnYhK.js} +1 -1
  99. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-iaQJb8kI.js} +1 -1
  100. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-CZgBPZ4e.js} +1 -1
  101. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-zpFpWKc3.js} +1 -1
  102. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-Ld8wzoVI.js} +1 -1
  103. package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-iCj-ntht.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-DAAD572L.js} +1 -1
  105. package/packages/remote-control-server/web/dist/index.html +1 -1
  106. package/dist/rcs-web/assets/Dashboard-BiApZyPx.js +0 -2
  107. package/dist/rcs-web/assets/channel-D0E2lnim.js +0 -1
  108. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  109. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  110. package/dist/rcs-web/assets/main-5uxJJ_sE.js +0 -283
  111. package/dist/rcs-web/assets/workerType-Bd-zteMi.js +0 -1
  112. package/packages/remote-control-server/web/dist/assets/Dashboard-BiApZyPx.js +0 -2
  113. package/packages/remote-control-server/web/dist/assets/channel-D0E2lnim.js +0 -1
  114. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  115. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  116. package/packages/remote-control-server/web/dist/assets/main-5uxJJ_sE.js +0 -283
  117. package/packages/remote-control-server/web/dist/assets/workerType-Bd-zteMi.js +0 -1
@@ -0,0 +1,283 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-VLURNSYL-Dn1LM1yF.js","assets/shiki-mEP5vQQu.js","assets/vendor-DE_-CLIE.js","assets/Dashboard-ClYYELch.js","assets/qr-C0jP9HcD.js","assets/motion-BILbV7YQ.js","assets/SessionDetail-D5dCDgDF.js"])))=>i.map(i=>d[i]);
2
+ var oc=Object.defineProperty;var sc=(e,t,n)=>t in e?oc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>sc(e,typeof t!="symbol"?t+"":t,n);import{e as m,a as rt,j as d,R as Gr,r as Os,b as ac,c as Kr,d as ic}from"./vendor-DE_-CLIE.js";import{_ as sn}from"./shiki-mEP5vQQu.js";import{Q as lc}from"./qr-C0jP9HcD.js";import{m as cc}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 Ds(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=Ds(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ls(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ds(e))&&(r&&(r+=" "),r+=t);return r}const dc=(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},uc=(e,t)=>({classGroupId:e,validator:t}),$s=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Nn="-",Fo=[],fc="arbitrary..",hc=e=>{const t=pc(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return mc(a);const i=a.split(Nn),h=i[0]===""&&i.length>1?1:0;return Fs(i,h,t)},getConflictingClassGroupIds:(a,i)=>{if(i){const h=r[a],f=n[a];return h?f?dc(f,h):h:f||Fo}return n[a]||Fo}}},Fs=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const f=Fs(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 l=a[f];if(l.validator(i))return l.classGroupId}},mc=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?fc+r:void 0})(),pc=e=>{const{theme:t,classGroups:n}=e;return gc(n,t)},gc=(e,t)=>{const n=$s();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];xc(a,t,n,r)}},xc=(e,t,n,r)=>{if(typeof e=="string"){vc(e,t,n);return}if(typeof e=="function"){bc(e,t,n,r);return}yc(e,t,n,r)},vc=(e,t,n)=>{const r=e===""?t:Us(t,e);r.classGroupId=n},bc=(e,t,n,r)=>{if(wc(e)){qr(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(uc(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,Us(t,i),n,r)}},Us=(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=$s(),n.nextPart.set(a,i)),n=i}return n},wc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Cc=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="!",Uo=":",Sc=[],zo=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),kc=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let a=0,i=0,h=0,f;const l=o.length;for(let v=0;v<l;v++){const w=o[v];if(a===0&&i===0){if(w===Uo){s.push(o.slice(h,v)),h=v+1;continue}if(w==="/"){f=v;continue}}w==="["?a++:w==="]"?a--:w==="("?i++:w===")"&&i--}const c=s.length===0?o:o.slice(h);let u=c,p=!1;c.endsWith(Ar)?(u=c.slice(0,-1),p=!0):c.startsWith(Ar)&&(u=c.slice(1),p=!0);const g=f&&f>h?f-h:void 0;return zo(s,p,u,g)};if(t){const o=t+Uo,s=r;r=a=>a.startsWith(o)?s(a.slice(o.length)):zo(Sc,!1,a,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},_c=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}},Ec=e=>({cache:Cc(e.cacheSize),parseClassName:kc(e),sortModifiers:_c(e),postfixLookupClassGroupIds:Nc(e),...hc(e)}),Nc=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},jc=/\s+/,Ac=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:a}=t,i=[],h=e.trim().split(jc);let f="";for(let l=h.length-1;l>=0;l-=1){const c=h[l],{isExternal:u,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:w}=n(c);if(u){f=c+(f.length>0?" "+f:f);continue}let y=!!w,A;if(y){const E=v.substring(0,w);A=r(E);const x=A&&a[A]?r(v):void 0;x&&x!==A&&(A=x,y=!1)}else A=r(v);if(!A){if(!y){f=c+(f.length>0?" "+f:f);continue}if(A=r(v),!A){f=c+(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,T=_+A;if(i.indexOf(T)>-1)continue;i.push(T);const C=o(A,y);for(let E=0;E<C.length;++E){const x=C[E];i.push(_+x)}f=c+(f.length>0?" "+f:f)}return f},Rc=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=zs(n))&&(o&&(o+=" "),o+=r);return o},zs=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=zs(e[r]))&&(n&&(n+=" "),n+=t);return n},Tc=(e,...t)=>{let n,r,o,s;const a=h=>{const f=t.reduce((l,c)=>c(l),e());return n=Ec(f),r=n.cache.get,o=n.cache.set,s=i,i(h)},i=h=>{const f=r(h);if(f)return f;const l=Ac(h,n);return o(h,l),l};return s=a,(...h)=>s(Rc(...h))},Ic=[],ve=e=>{const t=n=>n[e]||Ic;return t.isThemeGetter=!0,t},Bs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Hs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Mc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Pc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Oc=/\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$/,Dc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Lc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$c=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nt=e=>Mc.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=>Pc.test(e),Ws=()=>!0,Fc=e=>Oc.test(e)&&!Dc.test(e),Yr=()=>!1,Uc=e=>Lc.test(e),zc=e=>$c.test(e),Bc=e=>!Y(e)&&!Q(e),Hc=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=>ut(e,Ks,Yr),Y=e=>Bs.test(e),vt=e=>ut(e,qs,Fc),Bo=e=>ut(e,Zc,se),Vc=e=>ut(e,Xs,Ws),Gc=e=>ut(e,Ys,Yr),Ho=e=>ut(e,Vs,Yr),Kc=e=>ut(e,Gs,zc),vn=e=>ut(e,Qs,Uc),Q=e=>Hs.test(e),Yt=e=>_t(e,qs),qc=e=>_t(e,Ys),Wo=e=>_t(e,Vs),Yc=e=>_t(e,Ks),Xc=e=>_t(e,Gs),bn=e=>_t(e,Qs,!0),Qc=e=>_t(e,Xs,!0),ut=(e,t,n)=>{const r=Bs.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},_t=(e,t,n=!1)=>{const r=Hs.exec(e);return r?r[1]?t(r[1]):n:!1},Vs=e=>e==="position"||e==="percentage",Gs=e=>e==="image"||e==="url",Ks=e=>e==="length"||e==="size"||e==="bg-size",qs=e=>e==="length",Zc=e=>e==="number",Ys=e=>e==="family-name",Xs=e=>e==="number"||e==="weight",Qs=e=>e==="shadow",Jc=()=>{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"),l=ve("shadow"),c=ve("inset-shadow"),u=ve("text-shadow"),p=ve("drop-shadow"),g=ve("blur"),v=ve("perspective"),w=ve("aspect"),y=ve("ease"),A=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"],T=()=>[..._(),Q,Y],C=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],x=()=>[Q,Y,h],b=()=>[nt,"full","auto",...x()],R=()=>[Fe,"none","subgrid",Q,Y],D=()=>["auto",{span:["full",Fe,Q,Y]},Fe,Q,Y],O=()=>[Fe,"auto",Q,Y],F=()=>["auto","min","max","fr",Q,Y],P=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],k=()=>["auto",...x()],S=()=>[nt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],$=()=>[nt,"screen","full","dvw","lvw","svw","min","max","fit",...x()],N=()=>[nt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],M=()=>[e,Q,Y],H=()=>[..._(),Wo,Ho,{position:[Q,Y]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],B=()=>["auto","cover","contain",Yc,Wc,{size:[Q,Y]}],z=()=>[cr,Yt,vt],U=()=>["","none","full",f,Q,Y],V=()=>["",se,Yt,vt],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,Ho],ne=()=>["","none",g,Q,Y],ie=()=>["none",se,Q,Y],de=()=>["none",se,Q,Y],me=()=>[se,Q,Y],W=()=>[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:[Bc],"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,w]}],container:["container"],"container-type":[{"@container":["","normal","size",Q,Y]}],"container-named":[Hc],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:T()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],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":R()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"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:[...P(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...P()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":P()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],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:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:S()}],"inline-size":[{inline:["auto",...$()]}],"min-inline-size":[{"min-inline":["auto",...$()]}],"max-inline-size":[{"max-inline":["none",...$()]}],"block-size":[{block:["auto",...N()]}],"min-block-size":[{"min-block":["auto",...N()]}],"max-block-size":[{"max-block":["none",...N()]}],w:[{w:[i,"screen",...S()]}],"min-w":[{"min-w":[i,"screen","none",...S()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[a]},...S()]}],h:[{h:["screen","lh",...S()]}],"min-h":[{"min-h":["screen","lh","none",...S()]}],"max-h":[{"max-h":["screen","lh",...S()]}],"font-size":[{text:["base",n,Yt,vt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Qc,Vc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",cr,Y]}],"font-family":[{font:[qc,Gc,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,Bo]}],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:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[se,"from-font","auto",Q,vt]}],"text-decoration-color":[{decoration:M()}],"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:H()}],"bg-repeat":[{bg:I()}],"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]},Xc,Kc]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],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:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[se,Q,Y]}],"outline-w":[{outline:["",se,Yt,vt]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",l,bn,vn]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",c,bn,vn]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[se,vt]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",u,bn,vn]}],"text-shadow-color":[{"text-shadow":M()}],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":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"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":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"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":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"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":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"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":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"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":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"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":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"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":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:I()}],"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":M()}],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",A,Q,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,Q,Y]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:ie()}],"rotate-x":[{"rotate-x":ie()}],"rotate-y":[{"rotate-y":ie()}],"rotate-z":[{"rotate-z":ie()}],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:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:W()}],"translate-x":[{"translate-x":W()}],"translate-y":[{"translate-y":W()}],"translate-z":[{"translate-z":W()}],"translate-none":["translate-none"],zoom:[{zoom:[Fe,Q,Y]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"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":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"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",...M()]}],"stroke-w":[{stroke:[se,Yt,vt,Bo]}],stroke:[{stroke:["none",...M()]}],"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"]}},ed=Tc(Jc);function Z(...e){return ed(Ls(e))}function td(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 nd(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 rd(){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),nd(t)}/**
3
+ * @license lucide-react v0.555.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const od=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),sd=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Vo=e=>{const t=sd(e);return t.charAt(0).toUpperCase()+t.slice(1)},Zs=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),ad=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
8
+ * @license lucide-react v0.555.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */var id={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
13
+ * @license lucide-react v0.555.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const ld=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:a,...i},h)=>m.createElement("svg",{ref:h,...id,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Zs("lucide",o),...!s&&!ad(i)&&{"aria-hidden":"true"},...i},[...a.map(([f,l])=>m.createElement(f,l)),...Array.isArray(s)?s:[s]]));/**
18
+ * @license lucide-react v0.555.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const re=(e,t)=>{const n=m.forwardRef(({className:r,...o},s)=>m.createElement(ld,{ref:s,iconNode:t,className:Zs(`lucide-${od(Vo(e))}`,`lucide-${e}`,r),...o}));return n.displayName=Vo(e),n};/**
23
+ * @license lucide-react v0.555.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const cd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],dd=re("arrow-down",cd);/**
28
+ * @license lucide-react v0.555.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const ud=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],fd=re("brain",ud);/**
33
+ * @license lucide-react v0.555.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const hd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],at=re("check",hd);/**
38
+ * @license lucide-react v0.555.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const md=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],an=re("chevron-down",md);/**
43
+ * @license lucide-react v0.555.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const pd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gd=re("chevron-left",pd);/**
48
+ * @license lucide-react v0.555.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const xd=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Js=re("chevron-up",xd);/**
53
+ * @license lucide-react v0.555.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],bd=re("circle-check",vd);/**
58
+ * @license lucide-react v0.555.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
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"}]],wd=re("circle",yd);/**
63
+ * @license lucide-react v0.555.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const Cd=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Sd=re("copy",Cd);/**
68
+ * @license lucide-react v0.555.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const kd=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ea=re("eye-off",kd);/**
73
+ * @license lucide-react v0.555.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const _d=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ta=re("eye",_d);/**
78
+ * @license lucide-react v0.555.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const Ed=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Jt=re("file-text",Ed);/**
83
+ * @license lucide-react v0.555.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const Nd=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Xr=re("folder-open",Nd);/**
88
+ * @license lucide-react v0.555.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const jd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ad=re("image",jd);/**
93
+ * @license lucide-react v0.555.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const Rd=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],na=re("key-round",Rd);/**
98
+ * @license lucide-react v0.555.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const Td=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Id=re("layout-grid",Td);/**
103
+ * @license lucide-react v0.555.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const Md=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ra=re("loader-circle",Md);/**
108
+ * @license lucide-react v0.555.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const Pd=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Od=re("message-square",Pd);/**
113
+ * @license lucide-react v0.555.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const Dd=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Ld=re("monitor",Dd);/**
118
+ * @license lucide-react v0.555.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const $d=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],oa=re("moon",$d);/**
123
+ * @license lucide-react v0.555.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */const Fd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Ud=re("panel-left-close",Fd);/**
128
+ * @license lucide-react v0.555.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const zd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Bd=re("panel-left",zd);/**
133
+ * @license lucide-react v0.555.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const Hd=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Wd=re("paperclip",Hd);/**
138
+ * @license lucide-react v0.555.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const Vd=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],sa=re("pencil",Vd);/**
143
+ * @license lucide-react v0.555.0 - ISC
144
+ *
145
+ * This source code is licensed under the ISC license.
146
+ * See the LICENSE file in the root directory of this source tree.
147
+ */const Gd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Bn=re("plus",Gd);/**
148
+ * @license lucide-react v0.555.0 - ISC
149
+ *
150
+ * This source code is licensed under the ISC license.
151
+ * See the LICENSE file in the root directory of this source tree.
152
+ */const Kd=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],qd=re("scan",Kd);/**
153
+ * @license lucide-react v0.555.0 - ISC
154
+ *
155
+ * This source code is licensed under the ISC license.
156
+ * See the LICENSE file in the root directory of this source tree.
157
+ */const Yd=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xd=re("search",Yd);/**
158
+ * @license lucide-react v0.555.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */const Qd=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Zd=re("send",Qd);/**
163
+ * @license lucide-react v0.555.0 - ISC
164
+ *
165
+ * This source code is licensed under the ISC license.
166
+ * See the LICENSE file in the root directory of this source tree.
167
+ */const Jd=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],eu=re("server",Jd);/**
168
+ * @license lucide-react v0.555.0 - ISC
169
+ *
170
+ * This source code is licensed under the ISC license.
171
+ * See the LICENSE file in the root directory of this source tree.
172
+ */const tu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Qr=re("shield-alert",tu);/**
173
+ * @license lucide-react v0.555.0 - ISC
174
+ *
175
+ * This source code is licensed under the ISC license.
176
+ * See the LICENSE file in the root directory of this source tree.
177
+ */const nu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Go=re("shield-check",nu);/**
178
+ * @license lucide-react v0.555.0 - ISC
179
+ *
180
+ * This source code is licensed under the ISC license.
181
+ * See the LICENSE file in the root directory of this source tree.
182
+ */const ru=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ou=re("shield",ru);/**
183
+ * @license lucide-react v0.555.0 - ISC
184
+ *
185
+ * This source code is licensed under the ISC license.
186
+ * See the LICENSE file in the root directory of this source tree.
187
+ */const su=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],au=re("slash",su);/**
188
+ * @license lucide-react v0.555.0 - ISC
189
+ *
190
+ * This source code is licensed under the ISC license.
191
+ * See the LICENSE file in the root directory of this source tree.
192
+ */const iu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],lu=re("smartphone",iu);/**
193
+ * @license lucide-react v0.555.0 - ISC
194
+ *
195
+ * This source code is licensed under the ISC license.
196
+ * See the LICENSE file in the root directory of this source tree.
197
+ */const cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],du=re("square",cu);/**
198
+ * @license lucide-react v0.555.0 - ISC
199
+ *
200
+ * This source code is licensed under the ISC license.
201
+ * See the LICENSE file in the root directory of this source tree.
202
+ */const uu=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],aa=re("sun",uu);/**
203
+ * @license lucide-react v0.555.0 - ISC
204
+ *
205
+ * This source code is licensed under the ISC license.
206
+ * See the LICENSE file in the root directory of this source tree.
207
+ */const fu=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],Zr=re("table",fu);/**
208
+ * @license lucide-react v0.555.0 - ISC
209
+ *
210
+ * This source code is licensed under the ISC license.
211
+ * See the LICENSE file in the root directory of this source tree.
212
+ */const hu=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Jr=re("trash-2",hu);/**
213
+ * @license lucide-react v0.555.0 - ISC
214
+ *
215
+ * This source code is licensed under the ISC license.
216
+ * See the LICENSE file in the root directory of this source tree.
217
+ */const mu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],pu=re("user-plus",mu);/**
218
+ * @license lucide-react v0.555.0 - ISC
219
+ *
220
+ * This source code is licensed under the ISC license.
221
+ * See the LICENSE file in the root directory of this source tree.
222
+ */const gu=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ia=re("user",gu);/**
223
+ * @license lucide-react v0.555.0 - ISC
224
+ *
225
+ * This source code is licensed under the ISC license.
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"}]],Bt=re("x",xu),la=m.createContext(void 0),ca="theme";function Ko(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qo(){if(typeof window>"u")return"system";try{const e=localStorage.getItem(ca);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"system"}function Yo(e){const t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e)}function da(){const e=m.useContext(la);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(()=>qo()||t),[o,s]=m.useState(()=>{const h=qo()||t;return h==="system"?Ko():h}),a=m.useCallback(h=>{r(h);try{localStorage.setItem(ca,h)}catch{}},[]);m.useEffect(()=>{const h=n==="system"?Ko():n;s(h),Yo(h)},[n]),m.useEffect(()=>{if(n!=="system")return;const h=window.matchMedia("(prefers-color-scheme: dark)"),f=l=>{const c=l.matches?"dark":"light";s(c),Yo(c)};return h.addEventListener("change",f),()=>h.removeEventListener("change",f)},[n]);const i={theme:n,resolvedTheme:o,setTheme:a};return rt.createElement(la.Provider,{value:i},e)}function Xo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function He(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Xo(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():Xo(e[o],null)}}}}function pe(...e){return m.useCallback(He(...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 ua(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===bu&&"_payload"in e&&yu(e._payload)}function fa(e){const t=Cu(e),n=m.forwardRef((r,o)=>{let{children:s,...a}=r;ua(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,l=i.map(c=>c===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:c);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,l):null})}return d.jsx(t,{...a,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var wu=fa("Slot");function Cu(e){const t=m.forwardRef((n,r)=>{let{children:o,...s}=n;if(ua(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?He(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 Qo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Zo=Ls,Nu=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Zo(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 l=n==null?void 0:n[f],c=s==null?void 0:s[f];if(l===null)return null;const u=Qo(l)||Qo(c);return o[f][u]}),i=n&&Object.entries(n).reduce((f,l)=>{let[c,u]=l;return u===void 0||(f[c]=u),f},{}),h=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((f,l)=>{let{class:c,className:u,...p}=l;return Object.entries(p).every(g=>{let[v,w]=g;return Array.isArray(w)?w.includes({...s,...i}[v]):{...s,...i}[v]===w})?[...f,c,u]:f},[]);return Zo(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=c=>{var y;const{scope:u,children:p,...g}=c,v=((y=u==null?void 0:u[e])==null?void 0:y[h])||i,w=m.useMemo(()=>g,Object.values(g));return d.jsx(v.Provider,{value:w,children:p})};f.displayName=s+"Provider";function l(c,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(`\`${c}\` must be used within \`${s}\``)}return[f,l]}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 c=h(s)[`__scope${f}`];return{...i,...c}},{});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 it({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 l=m.useRef(e!==void 0);m.useEffect(()=>{const c=l.current;c!==i&&console.warn(`${r} is changing from ${c?"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.`),l.current=i},[i,r])}const f=m.useCallback(l=>{var c;if(i){const u=Mu(l)?l(e):l;u!==e&&((c=a.current)==null||c.call(a,u))}else s(l)},[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,l=i.map(c=>c===h?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:c);return d.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,l):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?He(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 ha=Symbol("radix.slottable");function Ou(e){const t=({children:n})=>d.jsx(d.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ha,t}function Du(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ha}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 ma(e,t){e&&Os.flushSync(()=>e.dispatchEvent(t))}function pa(e){const t=e+"CollectionProvider",[n,r]=Qe(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:w,children:y}=v,A=rt.useRef(null),j=rt.useRef(new Map).current;return d.jsx(o,{scope:w,itemMap:j,collectionRef:A,children:y})};a.displayName=t;const i=e+"CollectionSlot",h=Dt(i),f=rt.forwardRef((v,w)=>{const{scope:y,children:A}=v,j=s(i,y),_=pe(w,j.collectionRef);return d.jsx(h,{ref:_,children:A})});f.displayName=i;const l=e+"CollectionItemSlot",c="data-radix-collection-item",u=Dt(l),p=rt.forwardRef((v,w)=>{const{scope:y,children:A,...j}=v,_=rt.useRef(null),T=pe(w,_),C=s(l,y);return rt.useEffect(()=>(C.itemMap.set(_,{ref:_,...j}),()=>void C.itemMap.delete(_))),d.jsx(u,{[c]:"",ref:T,children:A})});p.displayName=l;function g(v){const w=s(e+"CollectionConsumer",v);return rt.useCallback(()=>{const A=w.collectionRef.current;if(!A)return[];const j=Array.from(A.querySelectorAll(`[${c}]`));return Array.from(w.itemMap.values()).sort((C,E)=>j.indexOf(C.ref.current)-j.indexOf(E.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:a,Slot:f,ItemSlot:p},g,r]}var Uu=m.createContext(void 0);function ga(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",Hu="dismissableLayer.pointerDownOutside",Wu="dismissableLayer.focusOutside",Jo,xa=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(xa),[l,c]=m.useState(null),u=(l==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),g=pe(t,E=>c(E)),v=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(w),A=l?v.indexOf(l):-1,j=f.layersWithOutsidePointerEventsDisabled.size>0,_=A>=y,T=Ku(E=>{const x=E.target,b=[...f.branches].some(R=>R.contains(x));!_||b||(o==null||o(E),a==null||a(E),E.defaultPrevented||i==null||i())},u),C=qu(E=>{const x=E.target;[...f.branches].some(R=>R.contains(x))||(s==null||s(E),a==null||a(E),E.defaultPrevented||i==null||i())},u);return zu(E=>{A===f.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&i&&(E.preventDefault(),i()))},u),m.useEffect(()=>{if(l)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Jo=u.body.style.pointerEvents,u.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(l)),f.layers.add(l),es(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(u.body.style.pointerEvents=Jo)}},[l,u,n,f]),m.useEffect(()=>()=>{l&&(f.layers.delete(l),f.layersWithOutsidePointerEventsDisabled.delete(l),es())},[l,f]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(Rr,E),()=>document.removeEventListener(Rr,E)},[]),d.jsx(ue.div,{...h,ref:g,style:{pointerEvents:j?_?"auto":"none":void 0,...e.style},onFocusCapture:ee(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ee(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ee(e.onPointerDownCapture,T.onPointerDownCapture)})});ln.displayName=Bu;var Vu="DismissableLayerBranch",Gu=m.forwardRef((e,t)=>{const n=m.useContext(xa),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(){va(Hu,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&&va(Wu,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 es(){const e=new CustomEvent(Rr);document.dispatchEvent(e)}function va(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?ma(o,s):o.dispatchEvent(s)}var dr=0;function eo(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ts()),document.body.insertAdjacentElement("beforeend",e[1]??ts()),dr++,()=>{dr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),dr--}},[])}function ts(){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",ns={bubbles:!1,cancelable:!0},Yu="FocusScope",Hn=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),l=qe(s),c=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(_)?c.current=_:ot(c.current,{select:!0})},w=function(j){if(p.paused||!i)return;const _=j.relatedTarget;_!==null&&(i.contains(_)||ot(c.current,{select:!0}))},y=function(j){if(document.activeElement===document.body)for(const T of j)T.removedNodes.length>0&&ot(i)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const A=new MutationObserver(y);return i&&A.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),A.disconnect()}}},[r,i,p.paused]),m.useEffect(()=>{if(i){os.add(p);const v=document.activeElement;if(!i.contains(v)){const y=new CustomEvent(ur,ns);i.addEventListener(ur,f),i.dispatchEvent(y),y.defaultPrevented||(Xu(tf(ba(i)),{select:!0}),document.activeElement===v&&ot(i))}return()=>{i.removeEventListener(ur,f),setTimeout(()=>{const y=new CustomEvent(fr,ns);i.addEventListener(fr,l),i.dispatchEvent(y),y.defaultPrevented||ot(v??document.body,{select:!0}),i.removeEventListener(fr,l),os.remove(p)},0)}}},[i,f,l,p]);const g=m.useCallback(v=>{if(!n&&!r||p.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,y=document.activeElement;if(w&&y){const A=v.currentTarget,[j,_]=Qu(A);j&&_?!v.shiftKey&&y===_?(v.preventDefault(),n&&ot(j,{select:!0})):v.shiftKey&&y===j&&(v.preventDefault(),n&&ot(_,{select:!0})):y===A&&v.preventDefault()}},[n,r,p.paused]);return d.jsx(ue.div,{tabIndex:-1,...a,ref:u,onKeyDown:g})});Hn.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=ba(e),n=rs(t,e),r=rs(t.reverse(),e);return[n,r]}function ba(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 rs(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 os=ef();function ef(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ss(e,t),e.unshift(t)},remove(t){var n;e=ss(e,t),(n=e[0])==null||n.resume()}}}function ss(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"],lt=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,lt(t,n))}function Ye(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Ht(e){return e.split("-")[1]}function to(e){return e==="x"?"y":"x"}function no(e){return e==="y"?"height":"width"}function ze(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ro(e){return to(ze(e))}function af(e,t,n){n===void 0&&(n=!1);const r=Ht(e),o=ro(e),s=no(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 as=["left","right"],is=["right","left"],cf=["top","bottom"],df=["bottom","top"];function uf(e,t,n){switch(e){case"top":case"bottom":return n?t?is:as:t?as:is;case"left":case"right":return t?cf:df;default:return[]}}function ff(e,t,n,r){const o=Ht(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 ls(e,t,n){let{reference:r,floating:o}=e;const s=ze(t),a=ro(t),i=no(a),h=Xe(t),f=s==="y",l=r.x+r.width/2-o.width/2,c=r.y+r.height/2-o.height/2,u=r[i]/2-o[i]/2;let p;switch(h){case"top":p={x:l,y:r.y-o.height};break;case"bottom":p={x:l,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:c};break;case"left":p={x:r.x-o.width,y:c};break;default:p={x:r.x,y:r.y}}switch(Ht(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:l="viewport",elementContext:c="floating",altBoundary:u=!1,padding:p=0}=Ye(t,e),g=ya(p),w=i[u?c==="floating"?"reference":"floating":c],y=Tn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:f,rootBoundary:l,strategy:h})),A=c==="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},T=Tn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:A,offsetParent:j,strategy:h}):A);return{top:(y.top-T.top+g.top)/_.y,bottom:(T.bottom-y.bottom+g.bottom)/_.y,left:(y.left-T.left+g.left)/_.x,right:(T.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:l,y:c}=ls(f,r,h),u=r,p=0;const g={};for(let v=0;v<s.length;v++){const w=s[v];if(!w)continue;const{name:y,fn:A}=w,{x:j,y:_,data:T,reset:C}=await A({x:l,y:c,initialPlacement:r,placement:u,strategy:o,middlewareData:g,rects:f,platform:i,elements:{reference:e,floating:t}});l=j??l,c=_??c,g[y]={...g[y],...T},C&&p<pf&&(p++,typeof C=="object"&&(C.placement&&(u=C.placement),C.rects&&(f=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:l,y:c}=ls(f,u,h)),v=-1)}return{x:l,y:c,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:l=0}=Ye(e,t)||{};if(f==null)return{};const c=ya(l),u={x:n,y:r},p=ro(o),g=no(p),v=await a.getDimensions(f),w=p==="y",y=w?"top":"left",A=w?"bottom":"right",j=w?"clientHeight":"clientWidth",_=s.reference[g]+s.reference[p]-u[p]-s.floating[g],T=u[p]-s.reference[p],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let E=C?C[j]:0;(!E||!await(a.isElement==null?void 0:a.isElement(C)))&&(E=i.floating[j]||s.floating[g]);const x=_/2-T/2,b=E/2-v[g]/2-1,R=lt(c[y],b),D=lt(c[A],b),O=R,F=E-v[g]-D,P=E/2-v[g]/2+x,L=Tr(O,P,F),k=!h.arrow&&Ht(o)!=null&&P!==L&&s.reference[g]/2-(P<O?R:D)-v[g]/2<0,S=k?P<O?P-O:P-F:0;return{[p]:u[p]+S,data:{[p]:L,centerOffset:P-L-S,...k&&{alignmentOffset:S}},reset:k}}}),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:l=!0,crossAxis:c=!0,fallbackPlacements:u,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...w}=Ye(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Xe(o),A=ze(i),j=Xe(i)===i,_=await(h.isRTL==null?void 0:h.isRTL(f.floating)),T=u||(j||!v?[Rn(i)]:lf(i)),C=g!=="none";!u&&C&&T.push(...ff(i,v,g,_));const E=[i,...T],x=await h.detectOverflow(t,w),b=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(l&&b.push(x[y]),c){const P=af(o,a,_);b.push(x[P[0]],x[P[1]])}if(R=[...R,{placement:o,overflows:b}],!b.every(P=>P<=0)){var D,O;const P=(((D=s.flip)==null?void 0:D.index)||0)+1,L=E[P];if(L&&(!(c==="alignment"?A!==ze(L):!1)||R.every($=>ze($.placement)===A?$.overflows[0]>0:!0)))return{data:{index:P,overflows:R},reset:{placement:L}};let k=(O=R.filter(S=>S.overflows[0]<=0).sort((S,$)=>S.overflows[1]-$.overflows[1])[0])==null?void 0:O.placement;if(!k)switch(p){case"bestFit":{var F;const S=(F=R.filter($=>{if(C){const N=ze($.placement);return N===A||N==="y"}return!0}).map($=>[$.placement,$.overflows.filter(N=>N>0).reduce((N,M)=>N+M,0)]).sort(($,N)=>$[1]-N[1])[0])==null?void 0:F[0];S&&(k=S);break}case"initialPlacement":k=i;break}if(o!==k)return{reset:{placement:k}}}return{}}}};function cs(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ds(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=cs(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ds(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=cs(a,n.floating);return{data:{escapedOffsets:i,escaped:ds(i)}}}default:return{}}}}},wa=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=Ht(n),h=ze(n)==="y",f=wa.has(a)?-1:1,l=s&&h?-1:1,c=Ye(t,e);let{mainAxis:u,crossAxis:p,alignmentAxis:g}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return i&&typeof g=="number"&&(p=i==="end"?g*-1:g),h?{x:p*l,y:u*f}:{x:u*f,y:p*l}}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:A,y:j}=y;return{x:A,y:j}}},...f}=Ye(e,t),l={x:n,y:r},c=await s.detectOverflow(t,f),u=ze(Xe(o)),p=to(u);let g=l[p],v=l[u];if(a){const y=p==="y"?"top":"left",A=p==="y"?"bottom":"right",j=g+c[y],_=g-c[A];g=Tr(j,g,_)}if(i){const y=u==="y"?"top":"left",A=u==="y"?"bottom":"right",j=v+c[y],_=v-c[A];v=Tr(j,v,_)}const w=h.fn({...t,[p]:g,[u]:v});return{...w,data:{x:w.x-n,y:w.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),l={x:n,y:r},c=ze(o),u=to(c);let p=l[u],g=l[c];const v=Ye(i,t),w=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]+w.mainAxis,T=s.reference[u]+s.reference[j]-w.mainAxis;p<_?p=_:p>T&&(p=T)}if(f){var y,A;const j=u==="y"?"width":"height",_=wa.has(Xe(o)),T=s.reference[c]-s.floating[j]+(_&&((y=a.offset)==null?void 0:y[c])||0)+(_?0:w.crossAxis),C=s.reference[c]+s.reference[j]+(_?0:((A=a.offset)==null?void 0:A[c])||0)-(_?w.crossAxis:0);g<T?g=T:g>C&&(g=C)}return{[u]:p,[c]: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),l=await a.detectOverflow(t,f),c=Xe(o),u=Ht(o),p=ze(o)==="y",{width:g,height:v}=s.floating;let w,y;c==="top"||c==="bottom"?(w=c,y=u===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(y=c,w=u==="end"?"top":"bottom");const A=v-l.top-l.bottom,j=g-l.left-l.right,_=lt(v-l[w],A),T=lt(g-l[y],j),C=!t.middlewareData.shift;let E=_,x=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(x=j),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=A),C&&!u){const R=Ne(l.left,0),D=Ne(l.right,0),O=Ne(l.top,0),F=Ne(l.bottom,0);p?x=g-2*(R!==0||D!==0?R+D:Ne(l.left,l.right)):E=v-2*(O!==0||F!==0?O+F:Ne(l.top,l.bottom))}await h({...t,availableWidth:x,availableHeight:E});const b=await a.getDimensions(i.floating);return g!==b.width||v!==b.height?{reset:{rects:!0}}:{}}}};function Wn(){return typeof window<"u"}function Wt(e){return Ca(e)?(e.nodeName||"").toLowerCase():"#document"}function je(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function We(e){var t;return(t=(Ca(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ca(e){return Wn()?e instanceof Node||e instanceof je(e).Node:!1}function Oe(e){return Wn()?e instanceof Element||e instanceof je(e).Element:!1}function Ze(e){return Wn()?e instanceof HTMLElement||e instanceof je(e).HTMLElement:!1}function us(e){return!Wn()||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/,bt=e=>!!e&&e!=="none";let hr;function oo(e){const t=Oe(e)?De(e):e;return bt(t.transform)||bt(t.translate)||bt(t.scale)||bt(t.rotate)||bt(t.perspective)||!so()&&(bt(t.backdropFilter)||bt(t.filter))||Ef.test(t.willChange||"")||Nf.test(t.contain||"")}function jf(e){let t=ct(e);for(;Ze(t)&&!Lt(t);){if(oo(t))return t;if(Vn(t))return null;t=ct(t)}return null}function so(){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 ct(e){if(Wt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||us(e)&&e.host||We(e);return us(t)?t.host:t}function Sa(e){const t=ct(e);return Lt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ze(t)&&cn(t)?t:Sa(t)}function en(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sa(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?en(i):[])}else return t.concat(o,en(o,[],n))}function Mr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ka(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 ao(e){return Oe(e)?e:e.contextElement}function Pt(e){const t=ao(e);if(!Ze(t))return Be(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ka(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 _a(e){const t=je(e);return!so()||!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=ao(e);let a=Be(1);t&&(r?Oe(r)&&(a=Pt(r)):a=Pt(e));const i=Rf(s,n,r)?_a(s):Be(0);let h=(o.left+i.x)/a.x,f=(o.top+i.y)/a.y,l=o.width/a.x,c=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 w=Pt(v),y=v.getBoundingClientRect(),A=De(v),j=y.left+(v.clientLeft+parseFloat(A.paddingLeft))*w.x,_=y.top+(v.clientTop+parseFloat(A.paddingTop))*w.y;h*=w.x,f*=w.y,l*=w.x,c*=w.y,h+=j,f+=_,g=je(v),v=Mr(g)}}return Tn({width:l,height:c,x:h,y:f})}function Kn(e,t){const n=Gn(e).scrollLeft;return t?t.left+n:Ct(We(e)).left+n}function Ea(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=We(r),i=t?Vn(t.floating):!1;if(r===a||i&&s)return n;let h={scrollLeft:0,scrollTop:0},f=Be(1);const l=Be(0),c=Ze(r);if((c||!c&&!s)&&((Wt(r)!=="body"||cn(a))&&(h=Gn(r)),c)){const p=Ct(r);f=Pt(r),l.x=p.x+r.clientLeft,l.y=p.y+r.clientTop}const u=a&&!c&&!s?Ea(a,h):Be(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-h.scrollLeft*f.x+l.x+u.x,y:n.y*f.y-h.scrollTop*f.y+l.y+u.y}}function If(e){return Array.from(e.getClientRects())}function Mf(e){const t=We(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 fs=25;function Pf(e,t){const n=je(e),r=We(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,h=0;if(o){s=o.width,a=o.height;const l=so();(!l||l&&t==="fixed")&&(i=o.offsetLeft,h=o.offsetTop)}const f=Kn(r);if(f<=0){const l=r.ownerDocument,c=l.body,u=getComputedStyle(c),p=l.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(r.clientWidth-c.clientWidth-p);g<=fs&&(s-=g)}else f<=fs&&(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 hs(e,t,n){let r;if(t==="viewport")r=Pf(e,n);else if(t==="document")r=Mf(We(e));else if(Oe(t))r=Of(t,n);else{const o=_a(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Tn(r)}function Na(e,t){const n=ct(e);return n===t||!Oe(n)||Lt(n)?!1:De(n).position==="fixed"||Na(n,t)}function Df(e,t){const n=t.get(e);if(n)return n;let r=en(e,[],!1).filter(i=>Oe(i)&&Wt(i)!=="body"),o=null;const s=De(e).position==="fixed";let a=s?ct(e):e;for(;Oe(a)&&!Lt(a);){const i=De(a),h=oo(a);!h&&i.position==="fixed"&&(o=null),(s?!h&&!o:!h&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||cn(a)&&!h&&Na(e,a))?r=r.filter(l=>l!==a):o=i,a=ct(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=hs(t,a[0],o);let h=i.top,f=i.right,l=i.bottom,c=i.left;for(let u=1;u<a.length;u++){const p=hs(t,a[u],o);h=Ne(p.top,h),f=lt(p.right,f),l=lt(p.bottom,l),c=Ne(p.left,c)}return{width:f-c,height:l-h,x:c,y:h}}function $f(e){const{width:t,height:n}=ka(e);return{width:t,height:n}}function Ff(e,t,n){const r=Ze(t),o=We(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 l=o&&!r&&!s?Ea(o,i):Be(0),c=a.left+i.scrollLeft-h.x-l.x,u=a.top+i.scrollTop-h.y-l.y;return{x:c,y:u,width:a.width,height:a.height}}function mr(e){return De(e).position==="static"}function ms(e,t){if(!Ze(e)||De(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return We(e)===n&&(n=n.ownerDocument.body),n}function ja(e,t){const n=je(e);if(Vn(e))return n;if(!Ze(e)){let o=ct(e);for(;o&&!Lt(o);){if(Oe(o)&&!mr(o))return o;o=ct(o)}return n}let r=ms(e,t);for(;r&&_f(r)&&mr(r);)r=ms(r,t);return r&&Lt(r)&&mr(r)&&!oo(r)?n:r||jf(e)||n}const Uf=async function(e){const t=this.getOffsetParent||ja,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:We,getClippingRect:Lf,getOffsetParent:ja,getElementRects:Uf,getClientRects:If,getDimensions:$f,getScale:Pt,isElement:Oe,isRTL:zf};function Aa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Hf(e,t){let n=null,r;const o=We(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:l,top:c,width:u,height:p}=f;if(i||t(),!u||!p)return;const g=yn(c),v=yn(o.clientWidth-(l+u)),w=yn(o.clientHeight-(c+p)),y=yn(l),j={rootMargin:-g+"px "+-v+"px "+-w+"px "+-y+"px",threshold:Ne(0,lt(1,h))||1};let _=!0;function T(C){const E=C[0].intersectionRatio;if(E!==h){if(!_)return a();E?a(!1,E):r=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!Aa(f,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(T,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,j)}n.observe(e)}return a(!0),s}function Wf(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=ao(e),l=o||s?[...f?en(f):[],...t?en(t):[]]:[];l.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const c=f&&i?Hf(f,n):null;let u=-1,p=null;a&&(p=new ResizeObserver(y=>{let[A]=y;A&&A.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&&w();function w(){const y=Ct(e);v&&!Aa(v,y)&&n(),v=y,g=requestAnimationFrame(w)}return n(),()=>{var y;l.forEach(A=>{o&&A.removeEventListener("scroll",n),s&&A.removeEventListener("resize",n)}),c==null||c(),(y=p)==null||y.disconnect(),p=null,h&&cancelAnimationFrame(g)}}const Vf=wf,Gf=Cf,Kf=vf,qf=kf,Yf=bf,ps=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 Ra(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gs(e,t){const n=Ra(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,[l,c]=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),[w,y]=m.useState(null),A=m.useCallback($=>{$!==C.current&&(C.current=$,v($))},[]),j=m.useCallback($=>{$!==E.current&&(E.current=$,y($))},[]),_=s||g,T=a||w,C=m.useRef(null),E=m.useRef(null),x=m.useRef(l),b=h!=null,R=pr(h),D=pr(o),O=pr(f),F=m.useCallback(()=>{if(!C.current||!E.current)return;const $={placement:t,strategy:n,middleware:u};D.current&&($.platform=D.current),Qf(C.current,E.current,$).then(N=>{const M={...N,isPositioned:O.current!==!1};P.current&&!In(x.current,M)&&(x.current=M,Os.flushSync(()=>{c(M)}))})},[u,t,n,D,O]);kn(()=>{f===!1&&x.current.isPositioned&&(x.current.isPositioned=!1,c($=>({...$,isPositioned:!1})))},[f]);const P=m.useRef(!1);kn(()=>(P.current=!0,()=>{P.current=!1}),[]),kn(()=>{if(_&&(C.current=_),T&&(E.current=T),_&&T){if(R.current)return R.current(_,T,F);F()}},[_,T,F,R,b]);const L=m.useMemo(()=>({reference:C,floating:E,setReference:A,setFloating:j}),[A,j]),k=m.useMemo(()=>({reference:_,floating:T}),[_,T]),S=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!k.floating)return $;const N=gs(k.floating,l.x),M=gs(k.floating,l.y);return i?{...$,transform:"translate("+N+"px, "+M+"px)",...Ra(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:M}},[n,i,k.floating,l.x,l.y]);return m.useMemo(()=>({...l,update:F,refs:L,elements:k,floatingStyles:S}),[l,F,L,k,S])}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?ps({element:r.current,padding:o}).fn(n):{}:r?ps({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",Ta=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"})})});Ta.displayName=ch;var dh=Ta;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 io="Popper",[Ia,Vt]=Qe(io),[fh,Ma]=Ia(io),Pa=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return d.jsx(fh,{scope:t,anchor:r,onAnchorChange:o,children:n})};Pa.displayName=io;var Oa="PopperAnchor",Da=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ma(Oa,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})});Da.displayName=Oa;var lo="PopperContent",[hh,mh]=Ia(lo),La=m.forwardRef((e,t)=>{var G,X,K,ne,ie,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:l=0,sticky:c="partial",hideWhenDetached:u=!1,updatePositionStrategy:p="optimized",onPlaced:g,...v}=e,w=Ma(lo,n),[y,A]=m.useState(null),j=pe(t,me=>A(me)),[_,T]=m.useState(null),C=uh(_),E=(C==null?void 0:C.width)??0,x=(C==null?void 0:C.height)??0,b=r+(s!=="center"?"-"+s:""),R=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},D=Array.isArray(f)?f:[f],O=D.length>0,F={padding:R,boundary:D.filter(gh),altBoundary:O},{refs:P,floatingStyles:L,placement:k,isPositioned:S,middlewareData:$}=eh({strategy:"fixed",placement:b,whileElementsMounted:(...me)=>Wf(...me,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[nh({mainAxis:o+x,alignmentAxis:a}),h&&rh({mainAxis:!0,crossAxis:!1,limiter:c==="partial"?oh():void 0,...F}),h&&sh({...F}),ah({...F,apply:({elements:me,rects:W,availableWidth:q,availableHeight:J})=>{const{width:te,height:le}=W.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",`${le}px`)}}),_&&lh({element:_,padding:i}),xh({arrowWidth:E,arrowHeight:x}),u&&ih({strategy:"referenceHidden",...F})]}),[N,M]=Ua(k),H=qe(g);Ke(()=>{S&&(H==null||H())},[S,H]);const I=(G=$.arrow)==null?void 0:G.x,B=(X=$.arrow)==null?void 0:X.y,z=((K=$.arrow)==null?void 0:K.centerOffset)!==0,[U,V]=m.useState();return Ke(()=>{y&&V(window.getComputedStyle(y).zIndex)},[y]),d.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:S?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:U,"--radix-popper-transform-origin":[(ne=$.transformOrigin)==null?void 0:ne.x,(ie=$.transformOrigin)==null?void 0:ie.y].join(" "),...((de=$.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(hh,{scope:n,placedSide:N,onArrowChange:T,arrowX:I,arrowY:B,shouldHideArrow:z,children:d.jsx(ue.div,{"data-side":N,"data-align":M,...v,ref:j,style:{...v.style,animation:S?void 0:"none"}})})})});La.displayName=lo;var $a="PopperArrow",ph={top:"bottom",right:"left",bottom:"top",left:"right"},Fa=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=mh($a,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"}})})});Fa.displayName=$a;function gh(e){return e!==null}var xh=e=>({name:"transformOrigin",options:e,fn(t){var w,y,A;const{placement:n,rects:r,middlewareData:o}=t,a=((w=o.arrow)==null?void 0:w.centerOffset)!==0,i=a?0:e.arrowWidth,h=a?0:e.arrowHeight,[f,l]=Ua(n),c={start:"0%",center:"50%",end:"100%"}[l],u=(((y=o.arrow)==null?void 0:y.x)??0)+i/2,p=(((A=o.arrow)==null?void 0:A.y)??0)+h/2;let g="",v="";return f==="bottom"?(g=a?c:`${u}px`,v=`${-h}px`):f==="top"?(g=a?c:`${u}px`,v=`${r.floating.height+h}px`):f==="right"?(g=`${-h}px`,v=a?c:`${p}px`):f==="left"&&(g=`${r.floating.width+h}px`,v=a?c:`${p}px`),{data:{x:g,y:v}}}});function Ua(e){const[t,n="center"]=e.split("-");return[t,n]}var co=Pa,qn=Da,uo=La,fo=Fa,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?ac.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,l=o.current;if(l!==e){const u=s.current,p=wn(f);e?h("MOUNT"):p==="none"||(f==null?void 0:f.display)==="none"?h("UNMOUNT"):h(l&&u!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),Ke(()=>{if(t){let f;const l=t.ownerDocument.defaultView??window,c=p=>{const v=wn(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(h("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",f=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},u=p=>{p.target===t&&(s.current=wn(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{l.clearTimeout(f),t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}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,za,Sh]=pa(un),[kh,Ba]=Qe(un,[Sh]),[_h,Eh]=kh(un),Ha=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})})}));Ha.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:l=!1,...c}=e,u=m.useRef(null),p=pe(t,u),g=ga(s),[v,w]=it({prop:a,defaultProp:i??null,onChange:h,caller:un}),[y,A]=m.useState(!1),j=qe(f),_=za(n),T=m.useRef(!1),[C,E]=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=>w(x),[w]),onItemShiftTab:m.useCallback(()=>A(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(x=>x+1),[]),onFocusableItemRemove:m.useCallback(()=>E(x=>x-1),[]),children:d.jsx(ue.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...c,ref:p,style:{outline:"none",...e.style},onMouseDown:ee(e.onMouseDown,()=>{T.current=!0}),onFocus:ee(e.onFocus,x=>{const b=!T.current;if(x.target===x.currentTarget&&b&&!y){const R=new CustomEvent(gr,Ch);if(x.currentTarget.dispatchEvent(R),!R.defaultPrevented){const D=_().filter(k=>k.focusable),O=D.find(k=>k.active),F=D.find(k=>k.id===v),L=[O,F,...D].filter(Boolean).map(k=>k.ref.current);Ga(L,l)}}T.current=!1}),onBlur:ee(e.onBlur,()=>A(!1))})})}),Wa="RovingFocusGroupItem",Va=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...i}=e,h=Ce(),f=s||h,l=Eh(Wa,n),c=l.currentTabStopId===f,u=za(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:v}=l;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:c?0:-1,"data-orientation":l.orientation,...i,ref:t,onMouseDown:ee(e.onMouseDown,w=>{r?l.onItemFocus(f):w.preventDefault()}),onFocus:ee(e.onFocus,()=>l.onItemFocus(f)),onKeyDown:ee(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){l.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const y=Rh(w,l.orientation,l.dir);if(y!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.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(w.currentTarget);j=l.loop?Th(j,_+1):j.slice(_+1)}setTimeout(()=>Ga(j))}}),children:typeof a=="function"?a({isCurrentTabStop:c,hasTabStop:v!=null}):a})})});Va.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 Ga(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=Ha,Mh=Va,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,Ka=function(e){return e&&(e.host||Ka(e.parentNode))},Oh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ka(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(c){!c||i.has(c)||(i.add(c),f(c.parentNode))};o.forEach(f);var l=function(c){!c||h.has(c)||Array.prototype.forEach.call(c.children,function(u){if(i.has(u))l(u);else try{var p=u.getAttribute(r),g=p!==null&&p!=="false",v=(Rt.get(u)||0)+1,w=(s.get(u)||0)+1;Rt.set(u,v),s.set(u,w),a.push(u),v===1&&g&&Cn.set(u,!0),w===1&&u.setAttribute(n,"true"),g||u.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",u,y)}})};return l(t),i.clear(),xr++,function(){a.forEach(function(c){var u=Rt.get(c)-1,p=s.get(c)-1;Rt.set(c,u),s.set(c,p),u||(Cn.has(c)||c.removeAttribute(r),Cn.delete(c)),p||c.removeAttribute(n)}),xr--,xr||(Rt=new WeakMap,Rt=new WeakMap,Cn=new WeakMap,Sn={})}},ho=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"],qa=["ArrowUp","PageDown","End"],$h=[...Lh,...qa],Fh={ltr:[...Or,"ArrowRight"],rtl:[...Or,"ArrowLeft"]},Uh={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fn="Menu",[tn,zh,Bh]=pa(fn),[Nt,Ya]=Qe(fn,[Bh,Vt,Ba]),Yn=Vt(),Xa=Ba(),[Hh,jt]=Nt(fn),[Wh,hn]=Nt(fn),Qa=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),l=m.useRef(!1),c=qe(s),u=ga(o);return m.useEffect(()=>{const p=()=>{l.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>l.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(co,{...i,children:d.jsx(Hh,{scope:t,open:n,onOpenChange:c,content:h,onContentChange:f,children:d.jsx(Wh,{scope:t,onClose:m.useCallback(()=>c(!1),[c]),isUsingKeyboardRef:l,dir:u,modal:a,children:r})})})};Qa.displayName=fn;var Vh="MenuAnchor",mo=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(qn,{...o,...r,ref:t})});mo.displayName=Vh;var po="MenuPortal",[Gh,Za]=Nt(po,{forceMount:void 0}),Ja=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=jt(po,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})})})};Ja.displayName=po;var Te="MenuContent",[Kh,go]=Nt(Te),ei=m.forwardRef((e,t)=>{const n=Za(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu);return d.jsx(tn.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(tn.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 ho(s)},[]),d.jsx(xo,{...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(xo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xh=Dt("MenuContent.ScrollLock"),xo=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEntryFocus:h,onEscapeKeyDown:f,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,onDismiss:p,disableOutsideScroll:g,...v}=e,w=jt(Te,n),y=hn(Te,n),A=Yn(n),j=Xa(n),_=zh(n),[T,C]=m.useState(null),E=m.useRef(null),x=pe(t,E,w.onContentChange),b=m.useRef(0),R=m.useRef(""),D=m.useRef(0),O=m.useRef(null),F=m.useRef("right"),P=m.useRef(0),L=g?Kr:m.Fragment,k=g?{as:Xh,allowPinchZoom:!0}:void 0,S=N=>{var G,X;const M=R.current+N,H=_().filter(K=>!K.disabled),I=document.activeElement,B=(G=H.find(K=>K.ref.current===I))==null?void 0:G.textValue,z=H.map(K=>K.textValue),U=lm(z,M,B),V=(X=H.find(K=>K.textValue===U))==null?void 0:X.ref.current;(function K(ne){R.current=ne,window.clearTimeout(b.current),ne!==""&&(b.current=window.setTimeout(()=>K(""),1e3))})(M),V&&setTimeout(()=>V.focus())};m.useEffect(()=>()=>window.clearTimeout(b.current),[]),eo();const $=m.useCallback(N=>{var H,I;return F.current===((H=O.current)==null?void 0:H.side)&&dm(N,(I=O.current)==null?void 0:I.area)},[]);return d.jsx(Kh,{scope:n,searchRef:R,onItemEnter:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),onItemLeave:m.useCallback(N=>{var M;$(N)||((M=E.current)==null||M.focus(),C(null))},[$]),onTriggerLeave:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback(N=>{O.current=N},[]),children:d.jsx(L,{...k,children:d.jsx(Hn,{asChild:!0,trapped:o,onMountAutoFocus:ee(s,N=>{var M;N.preventDefault(),(M=E.current)==null||M.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:f,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,onDismiss:p,children:d.jsx(Ih,{asChild:!0,...j,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:ee(h,N=>{y.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(uo,{role:"menu","aria-orientation":"vertical","data-state":gi(w.open),"data-radix-menu-content":"",dir:y.dir,...A,...v,ref:x,style:{outline:"none",...v.style},onKeyDown:ee(v.onKeyDown,N=>{const H=N.target.closest("[data-radix-menu-content]")===N.currentTarget,I=N.ctrlKey||N.altKey||N.metaKey,B=N.key.length===1;H&&(N.key==="Tab"&&N.preventDefault(),!I&&B&&S(N.key));const z=E.current;if(N.target!==z||!$h.includes(N.key))return;N.preventDefault();const V=_().filter(G=>!G.disabled).map(G=>G.ref.current);qa.includes(N.key)&&V.reverse(),am(V)}),onBlur:ee(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(b.current),R.current="")}),onPointerMove:ee(e.onPointerMove,nn(N=>{const M=N.target,H=P.current!==N.clientX;if(N.currentTarget.contains(M)&&H){const I=N.clientX>P.current?"right":"left";F.current=I,P.current=N.clientX}}))})})})})})})});ei.displayName=Te;var Qh="MenuGroup",vo=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"group",...r,ref:t})});vo.displayName=Qh;var Zh="MenuLabel",ti=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{...r,ref:t})});ti.displayName=Zh;var Mn="MenuItem",xs="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=go(Mn,e.__scopeMenu),h=pe(t,s),f=m.useRef(!1),l=()=>{const c=s.current;if(!n&&c){const u=new CustomEvent(xs,{bubbles:!0,cancelable:!0});c.addEventListener(xs,p=>r==null?void 0:r(p),{once:!0}),ma(c,u),u.defaultPrevented?f.current=!1:a.onClose()}};return d.jsx(ni,{...o,ref:h,disabled:n,onClick:ee(e.onClick,l),onPointerDown:c=>{var u;(u=e.onPointerDown)==null||u.call(e,c),f.current=!0},onPointerUp:ee(e.onPointerUp,c=>{var u;f.current||(u=c.currentTarget)==null||u.click()}),onKeyDown:ee(e.onKeyDown,c=>{const u=i.searchRef.current!=="";n||u&&c.key===" "||Or.includes(c.key)&&(c.currentTarget.click(),c.preventDefault())})})});Xn.displayName=Mn;var ni=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=go(Mn,n),i=Xa(n),h=m.useRef(null),f=pe(t,h),[l,c]=m.useState(!1),[u,p]=m.useState("");return m.useEffect(()=>{const g=h.current;g&&p((g.textContent??"").trim())},[s.children]),d.jsx(tn.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":l?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:ee(e.onPointerMove,nn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ee(e.onPointerLeave,nn(g=>a.onItemLeave(g))),onFocus:ee(e.onFocus,()=>c(!0)),onBlur:ee(e.onBlur,()=>c(!1))})})})}),Jh="MenuCheckboxItem",ri=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(li,{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})})})});ri.displayName=Jh;var oi="MenuRadioGroup",[em,tm]=Nt(oi,{value:void 0,onValueChange:()=>{}}),si=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(vo,{...o,ref:t})})});si.displayName=oi;var ai="MenuRadioItem",ii=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=tm(ai,e.__scopeMenu),s=n===o.value;return d.jsx(li,{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})})})});ii.displayName=ai;var bo="MenuItemIndicator",[li,nm]=Nt(bo,{checked:!1}),ci=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=nm(bo,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)})})});ci.displayName=bo;var rm="MenuSeparator",di=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(ue.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});di.displayName=rm;var om="MenuArrow",ui=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Yn(n);return d.jsx(fo,{...o,...r,ref:t})});ui.displayName=om;var sm="MenuSub",[rb,fi]=Nt(sm),Qt="MenuSubTrigger",hi=m.forwardRef((e,t)=>{const n=jt(Qt,e.__scopeMenu),r=hn(Qt,e.__scopeMenu),o=fi(Qt,e.__scopeMenu),s=go(Qt,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:h}=s,f={__scopeMenu:e.__scopeMenu},l=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>l,[l]),m.useEffect(()=>{const c=i.current;return()=>{window.clearTimeout(c),h(null)}},[i,h]),d.jsx(mo,{asChild:!0,...f,children:d.jsx(ni,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":gi(n.open),...e,ref:He(t,o.onTriggerChange),onClick:c=>{var u;(u=e.onClick)==null||u.call(e,c),!(e.disabled||c.defaultPrevented)&&(c.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ee(e.onPointerMove,nn(c=>{s.onItemEnter(c),!c.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),l()},100))})),onPointerLeave:ee(e.onPointerLeave,nn(c=>{var p,g;l();const u=(p=n.content)==null?void 0:p.getBoundingClientRect();if(u){const v=(g=n.content)==null?void 0:g.dataset.side,w=v==="right",y=w?-5:5,A=u[w?"left":"right"],j=u[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:c.clientX+y,y:c.clientY},{x:A,y:u.top},{x:j,y:u.top},{x:j,y:u.bottom},{x:A,y:u.bottom}],side:v}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(c),c.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ee(e.onKeyDown,c=>{var p;const u=s.searchRef.current!=="";e.disabled||u&&c.key===" "||Fh[r.dir].includes(c.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),c.preventDefault())})})})});hi.displayName=Qt;var mi="MenuSubContent",pi=m.forwardRef((e,t)=>{const n=Za(Te,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=jt(Te,e.__scopeMenu),a=hn(Te,e.__scopeMenu),i=fi(mi,e.__scopeMenu),h=m.useRef(null),f=pe(t,h);return d.jsx(tn.Provider,{scope:e.__scopeMenu,children:d.jsx(Ae,{present:r||s.open,children:d.jsx(tn.Slot,{scope:e.__scopeMenu,children:d.jsx(xo,{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:l=>{var c;a.isUsingKeyboardRef.current&&((c=h.current)==null||c.focus()),l.preventDefault()},onCloseAutoFocus:l=>l.preventDefault(),onFocusOutside:ee(e.onFocusOutside,l=>{l.target!==i.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ee(e.onEscapeKeyDown,l=>{a.onClose(),l.preventDefault()}),onKeyDown:ee(e.onKeyDown,l=>{var p;const c=l.currentTarget.contains(l.target),u=Uh[a.dir].includes(l.key);c&&u&&(s.onOpenChange(!1),(p=i.trigger)==null||p.focus(),l.preventDefault())})})})})})});pi.displayName=mi;function gi(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,l=i.y,c=h.x,u=h.y;l>r!=u>r&&n<(c-f)*(r-l)/(u-l)+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 nn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var um=Qa,fm=mo,hm=Ja,mm=ei,pm=vo,gm=ti,xm=Xn,vm=ri,bm=si,ym=ii,wm=ci,Cm=di,Sm=ui,km=hi,_m=pi,Qn="DropdownMenu",[Em]=Qe(Qn,[Ya]),Se=Ya(),[Nm,xi]=Em(Qn),vi=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),[l,c]=it({prop:o,defaultProp:s??!1,onChange:a,caller:Qn});return d.jsx(Nm,{scope:t,triggerId:Ce(),triggerRef:f,contentId:Ce(),open:l,onOpenChange:c,onOpenToggle:m.useCallback(()=>c(u=>!u),[c]),modal:i,children:d.jsx(um,{...h,open:l,onOpenChange:c,dir:r,modal:i,children:n})})};vi.displayName=Qn;var bi="DropdownMenuTrigger",yi=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=xi(bi,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:He(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=bi;var jm="DropdownMenuPortal",wi=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Se(t);return d.jsx(hm,{...r,...n})};wi.displayName=jm;var Ci="DropdownMenuContent",Si=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xi(Ci,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,l=h.button===2||f;(!o.modal||l)&&(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)"}})});Si.displayName=Ci;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",ki=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(xm,{...o,...r,ref:t})});ki.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",Hm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Cm,{...o,...r,ref:t})});Hm.displayName=Bm;var Wm="DropdownMenuArrow",Vm=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return d.jsx(Sm,{...o,...r,ref:t})});Vm.displayName=Wm;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=vi,Qm=yi,Zm=wi,Jm=Si,ep=ki;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(aa,{className:"h-4 w-4"})},{value:"dark",label:"Dark",icon:d.jsx(oa,{className:"h-4 w-4"})},{value:"system",label:"System",icon:d.jsx(Ld,{className:"h-4 w-4"})}];function ap(){const{theme:e,setTheme:t,resolvedTheme:n}=da();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(oa,{className:"h-4 w-4"}):d.jsx(aa,{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(gd,{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(Id,{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(na,{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,l;[r,f]=await Promise.all([r||ce.createQrEngine(),ce._loadImage(t)]),[o,l]=ce._drawToCanvas(f,i,o,s);let c;if(r instanceof Worker){let u=r;n||ce._postWorkerMessageSync(u,"inversionMode","both"),c=await new Promise((p,g)=>{let v,w,y,A=-1;w=_=>{_.data.id===A&&(u.removeEventListener("message",w),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",w),u.removeEventListener("error",y),clearTimeout(v),g("Scanner error: "+(_?_.message||_:"Unknown Error"))},u.addEventListener("message",w),u.addEventListener("error",y),v=setTimeout(()=>y("timeout"),1e4);let j=l.getImageData(0,0,o.width,o.height);A=ce._postWorkerMessageSync(u,"decode",j,[j.data.buffer])})}else c=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?c:c.data}catch(f){if(!i||!a)throw f;let l=await ce.scanImage(t,{qrEngine:r,canvas:o,disallowCanvasResizing:s});return h?l:l.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=()=>sn(()=>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,l=n/r,c=o/s;switch(f){case"none":var u=n,p=r;break;case"fill":u=o,p=s;break;default:(f==="cover"?l>c:l<c)?(p=s,u=p*l):(u=o,p=u/l),f==="scale-down"&&(u=Math.min(u,n),p=Math.min(p,r))}var[g,v]=h.objectPosition.split(" ").map((y,A)=>{const j=parseFloat(y);return y.endsWith("%")?(A?s-p:o-u)*j/100:j});h=this._scanRegion.width||n,c=this._scanRegion.height||r,f=this._scanRegion.x||0;var w=this._scanRegion.y||0;l=this.$overlay.style,l.width=`${h/n*u}px`,l.height=`${c/r*p}px`,l.top=`${i+v+w/r*p}px`,r=/scaleX\(-1\)/.test(t.style.transform),l.left=`${a+(r?o-g-u:g)+(r?n-f-h:f)/n*u}px`,l.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 wo(){let e=localStorage.getItem("rcs_uuid");return e||(e=rd(),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 _i="rcs_worker_token_",Ei="rcs_worker_tokens";function Zn(){try{const e=localStorage.getItem(Ei);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 Ni(e){try{localStorage.setItem(Ei,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}),Ni(r)}function fp(e){const t=Zn().filter(n=>n.envId!==e);Ni(t)}function Zt(){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(_i+e)}catch{return null}}function ib(e,t){try{localStorage.setItem(_i+e,t)}catch{}}class mp extends Error{constructor(n,r,o){super(n);ae(this,"type");ae(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 c=o[1],u=hp(c);u&&(r["X-Worker-Token"]=u)}const s=wo(),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),l=await f.json();if(!f.ok){const c=l.error||{type:"unknown",message:f.statusText};throw new mp(c.message||c.type,c.type||"unknown",f.status)}return l}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",[ji]=Qe(Jn),[bp,Le]=ji(Jn),Ai=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,l]=it({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:l,onOpenToggle:m.useCallback(()=>l(c=>!c),[l]),modal:a,children:n})};Ai.displayName=Jn;var Ri="DialogTrigger",yp=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Ri,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":ko(o.open),...r,ref:s,onClick:ee(e.onClick,o.onOpenToggle)})});yp.displayName=Ri;var Co="DialogPortal",[wp,Ti]=ji(Co,{forceMount:void 0}),Ii=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Le(Co,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})}))})};Ii.displayName=Co;var Dn="DialogOverlay",Mi=m.forwardRef((e,t)=>{const n=Ti(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});Mi.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":ko(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),St="DialogContent",Pi=m.forwardRef((e,t)=>{const n=Ti(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})})});Pi.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 ho(s)},[]),d.jsx(Oi,{...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(Oi,{...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()}})}),Oi=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 eo(),d.jsxs(d.Fragment,{children:[d.jsx(Hn,{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":ko(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})]})]})}),So="DialogTitle",Di=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(So,n);return d.jsx(ue.h2,{id:o.titleId,...r,ref:t})});Di.displayName=So;var Li="DialogDescription",$i=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Li,n);return d.jsx(ue.p,{id:o.descriptionId,...r,ref:t})});$i.displayName=Li;var Fi="DialogClose",Ui=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Le(Fi,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});Ui.displayName=Fi;function ko(e){return e?"open":"closed"}var zi="DialogTitleWarning",[gb,Bi]=Au(zi,{contentName:St,titleName:So,docsSlug:"dialog"}),Ep=({titleId:e})=>{const t=Bi(zi),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
228
+
229
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
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 {${Bi(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},Hi=Ai,Wi=Ii,Vi=Mi,Gi=Pi,Ap=Di,Rp=$i,Tp=Ui;function Ki({...e}){return d.jsx(Hi,{"data-slot":"dialog",...e})}function Ip({...e}){return d.jsx(Wi,{"data-slot":"dialog-portal",...e})}function Mp({className:e,...t}){return d.jsx(Vi,{"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 qi({className:e,children:t,showCloseButton:n=!0,...r}){return d.jsxs(Ip,{"data-slot":"dialog-portal",children:[d.jsx(Mp,{}),d.jsxs(Gi,{"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(Bt,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yi({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 Xi({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),[l,c]=m.useState(""),[u,p]=m.useState(""),[g,v]=m.useState(""),[w,y]=m.useState(()=>Dr()),A=m.useRef(null),j=m.useRef(null),_=m.useRef(null),T=wo(),{resolvedTheme:C}=da(),E=C==="dark"?{dark:"#ECE9E0",light:"#1C1B18"}:{dark:"#141413",light:"#FDFCF8"};if(m.useEffect(()=>{e&&(c(""),vp().then(L=>f(L)).catch(L=>c(L instanceof Error?L.message:"Failed to load server info")))},[e]),m.useEffect(()=>{if(!e||!a)return;const L=requestAnimationFrame(()=>{if(!A.current)return;const k=`${window.location.origin}/code?uuid=${encodeURIComponent(T)}`;lc.toCanvas(A.current,k,{width:200,margin:1,color:E}).catch(S=>{console.error("QR generation failed:",S)})});return()=>cancelAnimationFrame(L)},[e,a,T,C,E]),m.useEffect(()=>{!e&&_.current&&(_.current.stop(),_.current.destroy(),_.current=null,s(!1))},[e]),!e)return null;const x=async()=>{await navigator.clipboard.writeText(T),r(!0),setTimeout(()=>r(!1),2e3)},b=()=>{const L=u.trim();if(L.length<32){v("Invalid UUID");return}v(""),_n(L),y(Dr()),window.location.reload()},R=()=>{cp()&&(y(null),window.location.reload())},D=async()=>{if(j.current){s(!0);try{const L=new $t(j.current,k=>{F(k.data)},{returnDetailedScanResult:!0});_.current=L,await L.start()}catch(L){console.error("Camera error:",L),s(!1)}}},O=()=>{_.current&&(_.current.stop(),_.current.destroy(),_.current=null),s(!1)},F=L=>{try{const k=JSON.parse(L);if(k.url&&k.token){O(),t(),sessionStorage.setItem("acp_connection",JSON.stringify({url:k.url,token:k.token})),window.location.href="/code/?acp=1";return}}catch{}try{const S=new URL(L).searchParams.get("uuid");if(S){_n(S),O(),t();return}}catch{}if(L.length>=32){_n(L),O(),t();return}},P=()=>{const L=document.createElement("input");L.type="file",L.accept="image/*",L.onchange=async k=>{var $;const S=($=k.target.files)==null?void 0:$[0];if(S)try{const N=await $t.scanImage(S,{returnDetailedScanResult:!0});F(N.data)}catch{alert("No QR code found in image")}},L.click()};return d.jsx(Ki,{open:e,onOpenChange:L=>{L||t()},children:d.jsxs(qi,{className:"max-w-sm rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsx(Yi,{children:d.jsx(Xi,{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"]}),l?d.jsx("p",{className:"text-xs text-status-error",children:l}):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(ia,{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:T}),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 标识你创建的会话归属。分享它可授予他人访问你创建的会话。"}),w&&w!==T&&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: ",w]})]}),d.jsx("button",{onClick:R,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:L=>{p(L.target.value),v("")},onKeyDown:L=>{L.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(na,{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:A})})]}),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:O,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?O:D,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:P,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 _o="rcs_worker_tokens",vs="rcs_worker_token_",bs="rcs_worker_tokens_migrated";function Lp(){let e=Zt();if(typeof window>"u")return e;try{if(localStorage.getItem(bs))return e}catch{return e}try{for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!n||!n.startsWith(vs))continue;const r=n.slice(vs.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(_o,JSON.stringify(e)),localStorage.setItem(bs,"1")}catch{}return e}function vb(e){const t=Zt();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(_o,JSON.stringify(r))}catch{}window.dispatchEvent(new Event("rcs_worker_tokens_changed"))}}function $p(){const[e,t]=m.useState(()=>Lp()),n=m.useCallback(()=>{t(Zt())},[]);m.useEffect(()=>{const i=()=>t(Zt());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),l=Zt().map(c=>c.envId===i?{...c,verifiedAt:f.valid?Date.now():c.verifiedAt}:c);try{localStorage.setItem(_o,JSON.stringify(l))}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(Ki,{open:e,onOpenChange:l=>{l||t()},children:d.jsxs(qi,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[d.jsxs(Yi,{children:[d.jsx(Xi,{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,l]=m.useState(""),[c,u]=m.useState(""),[p,g]=m.useState(null),[v,w]=m.useState(""),[y,A]=m.useState(null),[j,_]=m.useState(null),T=(R,D)=>{navigator.clipboard.writeText(D).then(()=>{_(R),setTimeout(()=>_(null),1500)})},C=()=>{const R=r(i,f);if(R){u(R);return}h(""),l(""),u("")},E=R=>{g(R.id),w(R.label)},x=R=>{s(R,v.trim()||"Unnamed"),g(null)},b=R=>{n(R),a()};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(R=>d.jsx("div",{className:"group flex items-center gap-1",children:p===R.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:D=>w(D.target.value),onKeyDown:D=>{D.key==="Enter"&&x(R.id),D.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(R.id),className:"text-brand hover:opacity-70 transition-opacity",children:d.jsx(at,{className:"h-4 w-4"})}),d.jsx("button",{onClick:()=>g(null),className:"text-text-muted hover:text-text-primary transition-colors",children:d.jsx(Bt,{className:"h-4 w-4"})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:()=>b(R.id),className:`flex flex-1 items-center justify-between rounded-lg px-3 py-2 text-sm transition-colors ${t===R.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:R.label}),d.jsx("span",{className:"text-xs text-text-muted font-mono",children:y===R.id?R.token:`${R.token.slice(0,6)}${"•".repeat(6)}`})]}),t===R.id&&d.jsx(at,{className:"h-4 w-4 flex-shrink-0"})]}),d.jsx("button",{onClick:()=>A(y===R.id?null:R.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===R.id?d.jsx(ea,{className:"h-3.5 w-3.5"}):d.jsx(ta,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>T(R.id,R.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===R.id?d.jsx(at,{className:"h-3.5 w-3.5 text-status-active"}):d.jsx(Sd,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>E(R),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(sa,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>o(R.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(Jr,{className:"h-3.5 w-3.5"})})]})},R.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:R=>{h(R.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:R=>{R.key==="Enter"&&C()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:f,onChange:R=>l(R.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:R=>{R.key==="Enter"&&C()}}),d.jsx("button",{onClick:C,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"})})]})]}),c&&d.jsx("div",{className:"text-xs text-status-error",children:c})]})]})}function Bp(){const{entries:e,add:t,remove:n,verify:r,refresh:o}=$p(),[s,a]=m.useState([]),[i,h]=m.useState(""),[f,l]=m.useState(""),[c,u]=m.useState(""),[p,g]=m.useState(""),[v,w]=m.useState(new Set),[y,A]=m.useState({});m.useEffect(()=>{gp().then(E=>a(E||[])).catch(E=>console.error("Failed to load environments:",E))},[]),m.useEffect(()=>{if(s.length===0)return;const E=new Set(s.map(b=>b.id)),x=e.filter(b=>!b.envId.startsWith("__legacy_")&&!E.has(b.envId));x.length>0&&x.forEach(b=>n(b.envId))},[s,e,n]);const j=E=>{if(E.startsWith("__legacy_"))return`Legacy session ${E.slice(9).slice(0,8)}`;const x=s.find(b=>b.id===E);return(x==null?void 0:x.machine_name)||E},_=()=>{const E=f.trim();if(!E){g("Token is required");return}if(!i){g("Select an environment");return}t(i,E,c.trim()||void 0),l(""),u(""),g("")},T=async E=>{A(b=>({...b,[E]:"pending"}));const x=await r(E);A(b=>({...b,[E]:x})),o()},C=E=>{w(x=>{const b=new Set(x);return b.has(E)?b.delete(E):b.add(E),b})};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[e.map(E=>{const x=y[E.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(E.envId)}),E.label&&d.jsxs("span",{className:"text-xs text-text-muted truncate",children:["· ",E.label]}),x==="valid"&&d.jsx(Go,{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(E.envId)?E.token:`${E.token.slice(0,6)}${"•".repeat(6)}`})]}),d.jsx("button",{onClick:()=>C(E.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(E.envId)?d.jsx(ea,{className:"h-3.5 w-3.5"}):d.jsx(ta,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>T(E.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(Go,{className:"h-3.5 w-3.5"})}),d.jsx("button",{onClick:()=>n(E.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(Jr,{className:"h-3.5 w-3.5"})})]},E.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:E=>h(E.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(E=>{const x=Fp(E.worker_type).shortLabel;return d.jsxs("option",{value:E.id,children:[E.machine_name||E.id," (",E.branch||"no branch",") · ",x,E.has_worker_token?" · protected":""]},E.id)})]}),d.jsx("input",{type:"password",value:f,onChange:E=>{l(E.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:E=>{E.key==="Enter"&&_()}}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{type:"text",value:c,onChange:E=>u(E.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:E=>{E.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 Hp(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 Qi extends Error{constructor(){super("Disconnect requested"),this.name="DisconnectRequestedError"}}const st=class st{constructor(t){ae(this,"ws",null);ae(this,"settings");ae(this,"connectionState","disconnected");ae(this,"sessionId",null);ae(this,"_agentCapabilities",null);ae(this,"_promptCapabilities",null);ae(this,"_modelState",null);ae(this,"_availableCommands",[]);ae(this,"onModelChanged",new Set);ae(this,"onModelStateChanged",new Set);ae(this,"onAvailableCommandsChanged",null);ae(this,"onSessionLoaded",null);ae(this,"onSessionSwitching",null);ae(this,"onConnectionStateChange",new Set);ae(this,"onSessionUpdate",null);ae(this,"onSessionCreated",null);ae(this,"onPromptComplete",null);ae(this,"onPermissionRequest",null);ae(this,"onBrowserToolCall",null);ae(this,"onErrorMessage",null);ae(this,"onSessionDeleted",null);ae(this,"onSessionRenamed",null);ae(this,"pendingSessionList",null);ae(this,"pendingSessionLoad",null);ae(this,"pendingSessionResume",null);ae(this,"pendingSessionTarget",null);ae(this,"connectResolve",null);ae(this,"connectReject",null);ae(this,"heartbeatInterval",null);ae(this,"heartbeatTimeout",null);ae(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}setSessionDeletedHandler(t){this.onSessionDeleted=t}setSessionRenamedHandler(t){this.onSessionRenamed=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?[Hp(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,l,c,u,p,g;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 v=((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(v)),this.pendingSessionList=null),this.pendingSessionLoad&&(clearTimeout(this.pendingSessionLoad.timer),this.pendingSessionLoad.reject(new Error(v)),this.pendingSessionLoad=null),this.pendingSessionResume&&(clearTimeout(this.pendingSessionResume.timer),this.pendingSessionResume.reject(new Error(v)),this.pendingSessionResume=null),this.connectReject?(this.connectReject(new Error(v)),this.connectResolve=null,this.connectReject=null):(console.error("[ACPClient] Agent error:",v),(o=this.onErrorMessage)==null||o.call(this,v));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 y of this.onModelStateChanged)y(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 y of this.onModelStateChanged)y(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 y of this.onModelStateChanged)y(this._modelState);break;case"session_deleted":(h=this.onSessionDeleted)==null||h.call(this,t.payload.sessionId);break;case"session_renamed":(f=this.onSessionRenamed)==null||f.call(this,t.payload.sessionId,t.payload.title);break;case"session_update":const w=(l=t.payload.update)==null?void 0:l.sessionUpdate;console.log("[ACPClient] session_update type:",w,"payload:",t.payload),w==="available_commands_update"&&(this._availableCommands=t.payload.update.availableCommands,console.log("[ACPClient] Available commands updated:",this._availableCommands.length,"commands"),(c=this.onAvailableCommandsChanged)==null||c.call(this,this._availableCommands)),(u=this.onSessionUpdate)==null||u.call(this,t.payload.sessionId,t.payload.update);break;case"prompt_complete":(p=this.onPromptComplete)==null||p.call(this,t.payload.stopReason);break;case"permission_request":console.log("[ACPClient] Permission request:",t.payload),(g=this.onPermissionRequest)==null||g.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 y of this.onModelChanged)y(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}})}deleteSession(t){this.send({type:"delete_session",payload:{sessionId:t}})}renameSession(t,n){this.send({type:"rename_session",payload:{sessionId:t,title:n}})}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 Qi),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)}};ae(st,"HEARTBEAT_INTERVAL_MS",3e4),ae(st,"PONG_TIMEOUT_MS",1e4),ae(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 Zi(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 l;switch(s.getUint16(f)){case 18761:l=!0;break;case 19789:l=!1;break;default:return n("TIFF header contains invalid endian")}if(s.getUint16(f+2,l)!==42)return n("TIFF header contains invalid version");const c=s.getUint32(f+4,l),u=f+c+2+12*s.getUint16(f+c,l);for(let p=f+c+2;p<u;p+=12)if(s.getUint16(p,l)==274){if(s.getUint16(p+2,l)!==3)return n("Orientation data type is invalid");if(s.getUint32(p+4,l)!==1)return n("Orientation data count is invalid");s.setUint16(p+8,1,l);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={},l=new Uint8Array(o),c=l.length-4;i(l,c)!=101010256;)c--;h=c,h+=4;var u=a(l,h+=4);a(l,h+=2);var p=i(l,h+=2),g=i(l,h+=4);h+=4,h=g;for(var v=0;v<u;v++){i(l,h),h+=4,h+=4,h+=4,i(l,h+=4),p=i(l,h+=4);var w=i(l,h+=4),y=a(l,h+=4),A=a(l,h+2),j=a(l,h+4);h+=6;var _=i(l,h+=8);h+=4,h+=y+A+j,r._readLocal(l,_,f,p,w,s)}return f},r._readLocal=function(o,s,a,i,h,f){var l=r.bin.readUshort,c=r.bin.readUint;c(o,s),l(o,s+=4),l(o,s+=2);var u=l(o,s+=2);c(o,s+=2),c(o,s+=4),s+=4;var p=l(o,s+=8),g=l(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 w=new Uint8Array(o.buffer,s);if(u==0)a[v]=new Uint8Array(w.buffer.slice(s,s+i));else{if(u!=8)throw"unknown compression method: "+u;var y=new Uint8Array(h);r.inflateRaw(w,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 l in o){var c=!r._noNeed(l)&&!s,u=o[l],p=r.crc.crc(u,0,u.length);f[l]={cpr:c,usize:u.length,crc:p,file:c?r.deflateRaw(u):u}}for(var l in f)a+=f[l].file.length+30+46+2*r.bin.sizeUTF8(l);a+=22;var g=new Uint8Array(a),v=0,w=[];for(var l in f){var y=f[l];w.push(v),v=r._writeHeader(g,v,l,y,0)}var A=0,j=v;for(var l in f)y=f[l],w.push(v),v=r._writeHeader(g,v,l,y,1,w[A++]);var _=v-j;return i(g,v,101010256),v+=4,h(g,v+=4,A),h(g,v+=2,A),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 l=r.bin.writeUint,c=r.bin.writeUshort,u=i.file;return l(o,s,h==0?67324752:33639248),s+=4,h==1&&(s+=2),c(o,s,20),c(o,s+=2,0),c(o,s+=2,i.cpr?8:0),l(o,s+=2,0),l(o,s+=4,i.crc),l(o,s+=4,u.length),l(o,s+=4,i.usize),c(o,s+=4,r.bin.sizeUTF8(a)),c(o,s+=2,0),s+=2,h==1&&(s+=2,s+=2,l(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,l=s+a;f<l;){for(var c=Math.min(f+5552,l);f<c;)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 l=a.charCodeAt(f);if((4294967168&l)==0)o[s+h]=l,h++;else if((4294965248&l)==0)o[s+h]=192|l>>6,o[s+h+1]=128|l>>0&63,h+=2;else if((4294901760&l)==0)o[s+h]=224|l>>12,o[s+h+1]=128|l>>6&63,o[s+h+2]=128|l>>0&63,h+=3;else{if((4292870144&l)!=0)throw"e";o[s+h]=240|l>>18,o[s+h+1]=128|l>>12&63,o[s+h+2]=128|l>>6&63,o[s+h+3]=128|l>>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,l=r.F._goodIndex;r.F._hash;var c=r.F._putsE,u=0,p=a<<3,g=0,v=o.length;if(i==0){for(;u<v;)c(s,p,u+(D=Math.min(65535,v-u))==v?1:0),p=r.F._copyExact(o,u,D,s,p+8),u+=D;return p>>>3}var w=f.lits,y=f.strt,A=f.prev,j=0,_=0,T=0,C=0,E=0,x=0;for(v>2&&(y[x=r.F._hash(o,0)]=0),u=0;u<v;u++){if(E=x,u+1<v-2){x=r.F._hash(o,u+1);var b=u+1&32767;A[b]=y[x],y[x]=b}if(g<=u){(j>14e3||_>26697)&&v-u>100&&(g<u&&(w[j]=u-g,j+=2,g=u),p=r.F._writeBlock(u==v-1||g==v?1:0,w,j,C,o,T,u-T,s,p),j=_=C=0,T=u);var R=0;u<v-2&&(R=r.F._bestMatch(o,u,A,E,Math.min(h[2],v-u),h[3]));var D=R>>>16,O=65535&R;if(R!=0){O=65535&R;var F=l(D=R>>>16,f.of0);f.lhst[257+F]++;var P=l(O,f.df0);f.dhst[P]++,C+=f.exb[F]+f.dxb[P],w[j]=D<<23|u-g,w[j+1]=O<<16|F<<8|P,j+=2,g=u+D}else f.lhst[o[u]]++;_++}}for(T==u&&o.length!=0||(g<u&&(w[j]=u-g,j+=2,g=u),p=r.F._writeBlock(1,w,j,C,o,T,u-T,s,p),j=0,_=0,j=_=C=0,T=u);(7&p)!=0;)p++;return p>>>3},r.F._bestMatch=function(o,s,a,i,h,f){var l=32767&s,c=a[l],u=l-c+32768&32767;if(c==l||i!=r.F._hash(o,s-u))return 0;for(var p=0,g=0,v=Math.min(32767,s);u<=v&&--f!=0&&c!=l;){if(p==0||o[s+p]==o[s+p-u]){var w=r.F._howLong(o,s,u);if(w>p){if(g=u,(p=w)>=h)break;u+2<w&&(w=u+2);for(var y=0,A=0;A<w-2;A++){var j=s-u+A+32768&32767,_=j-a[j]+32768&32767;_>y&&(y=_,c=j)}}}u+=(l=c)-(c=a[l])+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,l,c,u){var p,g,v,w,y,A,j,_,T,C=r.F.U,E=r.F._putsF,x=r.F._putsE;C.lhst[256]++,g=(p=r.F.getTrees())[0],v=p[1],w=p[2],y=p[3],A=p[4],j=p[5],_=p[6],T=p[7];var b=32+((u+3&7)==0?0:8-(u+3&7))+(l<<3),R=i+r.F.contSize(C.fltree,C.lhst)+r.F.contSize(C.fdtree,C.dhst),D=i+r.F.contSize(C.ltree,C.lhst)+r.F.contSize(C.dtree,C.dhst);D+=14+3*j+r.F.contSize(C.itree,C.ihst)+(2*C.ihst[16]+3*C.ihst[17]+7*C.ihst[18]);for(var O=0;O<286;O++)C.lhst[O]=0;for(O=0;O<30;O++)C.dhst[O]=0;for(O=0;O<19;O++)C.ihst[O]=0;var F=b<R&&b<D?0:R<D?1:2;if(E(c,u,o),E(c,u+1,F),u+=3,F==0){for(;(7&u)!=0;)u++;u=r.F._copyExact(h,f,l,c,u)}else{var P,L;if(F==1&&(P=C.fltree,L=C.fdtree),F==2){r.F.makeCodes(C.ltree,g),r.F.revCodes(C.ltree,g),r.F.makeCodes(C.dtree,v),r.F.revCodes(C.dtree,v),r.F.makeCodes(C.itree,w),r.F.revCodes(C.itree,w),P=C.ltree,L=C.dtree,x(c,u,y-257),x(c,u+=5,A-1),x(c,u+=5,j-4),u+=4;for(var k=0;k<j;k++)x(c,u+3*k,C.itree[1+(C.ordr[k]<<1)]);u+=3*j,u=r.F._codeTiny(_,C.itree,c,u),u=r.F._codeTiny(T,C.itree,c,u)}for(var S=f,$=0;$<a;$+=2){for(var N=s[$],M=N>>>23,H=S+(8388607&N);S<H;)u=r.F._writeLit(h[S++],P,c,u);if(M!=0){var I=s[$+1],B=I>>16,z=I>>8&255,U=255&I;x(c,u=r.F._writeLit(257+z,P,c,u),M-C.of0[z]),u+=C.exb[z],E(c,u=r.F._writeLit(U,L,c,u),B-C.df0[U]),u+=C.dxb[U],S+=M}}u=r.F._writeLit(256,P,c,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=[],l=r.F._lenCodes(o.dtree,f),c=0;c<i.length;c+=2)o.ihst[i[c]]++;for(c=0;c<f.length;c+=2)o.ihst[f[c]]++;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,l,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],l=o[h+1];i=r.F._writeLit(f,s,a,i);var c=f==16?2:f==17?3:7;f>15&&(r.F._putsE(a,i,l,c),i+=c)}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,l=i+5<a?o[i+5]:-1,c=i==0?-1:o[i-1];if(h==0&&f==h&&l==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==c&&f==h&&l==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,l=0;for(l=0;l<f;l+=2)s[l]=0,s[l+1]=0;for(l=0;l<h;l++)o[l]!=0&&i.push({lit:l,f:o[l]});var c=i.length,u=i.slice(0);if(c==0)return 0;if(c==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(_,T){return _.f-T.f}));var g=i[0],v=i[1],w=0,y=1,A=2;for(i[0]={lit:-1,f:g.f+v.f,l:g,r:v,d:0};y!=c-1;)g=w!=y&&(A==c||i[w].f<i[A].f)?i[w++]:i[A++],v=w!=y&&(A==c||i[w].f<i[A].f)?i[w++]:i[A++],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),l=0;l<c;l++)s[1+(u[l].lit<<1)]=u[l].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(c,u){return u.d==c.d?c.f-u.f:u.d-c.d})),i=0;i<o.length&&o[i].d>s;i++){var l=o[i].d;o[i].d=s,f+=h-(1<<a-l)}for(f>>>=a-s;f>0;)(l=o[i].d)<s?(o[i].d++,f-=1<<s-l-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,l=i._decodeTiny,c=i.makeCodes,u=i.codes2map,p=i._get17,g=i.U,v=s==null;v&&(s=new a(o.length>>>2<<3));for(var w,y,A=0,j=0,_=0,T=0,C=0,E=0,x=0,b=0,R=0;A==0;)if(A=h(o,R,1),j=h(o,R+1,2),R+=3,j!=0){if(v&&(s=r.F._check(s,b+(1<<17))),j==1&&(w=g.flmap,y=g.fdmap,E=511,x=31),j==2){_=f(o,R,5)+257,T=f(o,R+5,5)+1,C=f(o,R+10,4)+4,R+=14;for(var D=0;D<38;D+=2)g.itree[D]=0,g.itree[D+1]=0;var O=1;for(D=0;D<C;D++){var F=f(o,R+3*D,3);g.itree[1+(g.ordr[D]<<1)]=F,F>O&&(O=F)}R+=3*C,c(g.itree,O),u(g.itree,O,g.imap),w=g.lmap,y=g.dmap,R=l(g.imap,(1<<O)-1,_+T,o,R,g.ttree);var P=i._copyOut(g.ttree,0,_,g.ltree);E=(1<<P)-1;var L=i._copyOut(g.ttree,_,T,g.dtree);x=(1<<L)-1,c(g.ltree,P),u(g.ltree,P,w),c(g.dtree,L),u(g.dtree,L,y)}for(;;){var k=w[p(o,R)&E];R+=15&k;var S=k>>>4;if(!(S>>>8))s[b++]=S;else{if(S==256)break;var $=b+S-254;if(S>264){var N=g.ldef[S-257];$=b+(N>>>3)+f(o,R,7&N),R+=7&N}var M=y[p(o,R)&x];R+=15&M;var H=M>>>4,I=g.ddef[H],B=(I>>>4)+h(o,R,15&I);for(R+=15&I,v&&(s=r.F._check(s,b+(1<<17)));b<$;)s[b]=s[b++-B],s[b]=s[b++-B],s[b]=s[b++-B],s[b]=s[b++-B];b=$}}}else{(7&R)!=0&&(R+=8-(7&R));var z=4+(R>>>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),R=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 l=r.F._bitsE,c=r.F._get17,u=0;u<a;){var p=o[c(i,h)&s];h+=15&p;var g=p>>>4;if(g<=15)f[u]=g,u++;else{var v=0,w=0;g==16?(w=3+l(i,h,2),h+=2,v=f[u-1]):g==17?(w=3+l(i,h,3),h+=3):g==18&&(w=11+l(i,h,7),h+=7);for(var y=u+w;u<y;)f[u]=v,u++}}return h},r.F._copyOut=function(o,s,a,i){for(var h=0,f=0,l=i.length>>>1;f<a;){var c=o[f+s];i[f<<1]=0,i[1+(f<<1)]=c,c>h&&(h=c),f++}for(;f<l;)i[f<<1]=0,i[1+(f<<1)]=0,f++;return h},r.F.makeCodes=function(o,s){for(var a,i,h,f,l=r.F.U,c=o.length,u=l.bl_count,p=0;p<=s;p++)u[p]=0;for(p=1;p<c;p+=2)u[o[p]]++;var g=l.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<c;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 l=f>>1,c=o[f+1],u=l<<4|c,p=s-c,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,l){for(;f--!=0;)h.push(0,l)}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=Wp({__proto__:null,default:Ln},[Ln]);const Pe=(function(){var e={nextZero(l,c){for(;l[c]!=0;)c++;return c},readUshort:(l,c)=>l[c]<<8|l[c+1],writeUshort(l,c,u){l[c]=u>>8&255,l[c+1]=255&u},readUint:(l,c)=>16777216*l[c]+(l[c+1]<<16|l[c+2]<<8|l[c+3]),writeUint(l,c,u){l[c]=u>>24&255,l[c+1]=u>>16&255,l[c+2]=u>>8&255,l[c+3]=255&u},readASCII(l,c,u){let p="";for(let g=0;g<u;g++)p+=String.fromCharCode(l[c+g]);return p},writeASCII(l,c,u){for(let p=0;p<u.length;p++)l[c+p]=u.charCodeAt(p)},readBytes(l,c,u){const p=[];for(let g=0;g<u;g++)p.push(l[c+g]);return p},pad:l=>l.length<2?`0${l}`:l,readUTF8(l,c,u){let p,g="";for(let v=0;v<u;v++)g+=`%${e.pad(l[c+v].toString(16))}`;try{p=decodeURIComponent(g)}catch{return e.readASCII(l,c,u)}return p}};function t(l,c,u,p){const g=c*u,v=s(p),w=Math.ceil(c*v/8),y=new Uint8Array(4*g),A=new Uint32Array(y.buffer),{ctype:j}=p,{depth:_}=p,T=e.readUshort;if(j==6){const N=g<<2;if(_==8)for(var C=0;C<N;C+=4)y[C]=l[C],y[C+1]=l[C+1],y[C+2]=l[C+2],y[C+3]=l[C+3];if(_==16)for(C=0;C<N;C++)y[C]=l[C<<1]}else if(j==2){const N=p.tabs.tRNS;if(N==null){if(_==8)for(C=0;C<g;C++){var E=3*C;A[C]=255<<24|l[E+2]<<16|l[E+1]<<8|l[E]}if(_==16)for(C=0;C<g;C++)E=6*C,A[C]=255<<24|l[E+4]<<16|l[E+2]<<8|l[E]}else{var x=N[0];const M=N[1],H=N[2];if(_==8)for(C=0;C<g;C++){var b=C<<2;E=3*C,A[C]=255<<24|l[E+2]<<16|l[E+1]<<8|l[E],l[E]==x&&l[E+1]==M&&l[E+2]==H&&(y[b+3]=0)}if(_==16)for(C=0;C<g;C++)b=C<<2,E=6*C,A[C]=255<<24|l[E+4]<<16|l[E+2]<<8|l[E],T(l,E)==x&&T(l,E+2)==M&&T(l,E+4)==H&&(y[b+3]=0)}}else if(j==3){const N=p.tabs.PLTE,M=p.tabs.tRNS,H=M?M.length:0;if(_==1)for(var R=0;R<u;R++){var D=R*w,O=R*c;for(C=0;C<c;C++){b=O+C<<2;var F=3*(P=l[D+(C>>3)]>>7-((7&C)<<0)&1);y[b]=N[F],y[b+1]=N[F+1],y[b+2]=N[F+2],y[b+3]=P<H?M[P]:255}}if(_==2)for(R=0;R<u;R++)for(D=R*w,O=R*c,C=0;C<c;C++)b=O+C<<2,F=3*(P=l[D+(C>>2)]>>6-((3&C)<<1)&3),y[b]=N[F],y[b+1]=N[F+1],y[b+2]=N[F+2],y[b+3]=P<H?M[P]:255;if(_==4)for(R=0;R<u;R++)for(D=R*w,O=R*c,C=0;C<c;C++)b=O+C<<2,F=3*(P=l[D+(C>>1)]>>4-((1&C)<<2)&15),y[b]=N[F],y[b+1]=N[F+1],y[b+2]=N[F+2],y[b+3]=P<H?M[P]:255;if(_==8)for(C=0;C<g;C++){var P;b=C<<2,F=3*(P=l[C]),y[b]=N[F],y[b+1]=N[F+1],y[b+2]=N[F+2],y[b+3]=P<H?M[P]:255}}else if(j==4){if(_==8)for(C=0;C<g;C++){b=C<<2;var L=l[k=C<<1];y[b]=L,y[b+1]=L,y[b+2]=L,y[b+3]=l[k+1]}if(_==16)for(C=0;C<g;C++){var k;b=C<<2,L=l[k=C<<2],y[b]=L,y[b+1]=L,y[b+2]=L,y[b+3]=l[k+2]}}else if(j==0)for(x=p.tabs.tRNS?p.tabs.tRNS:-1,R=0;R<u;R++){const N=R*w,M=R*c;if(_==1)for(var S=0;S<c;S++){var $=(L=255*(l[N+(S>>>3)]>>>7-(7&S)&1))==255*x?0:255;A[M+S]=$<<24|L<<16|L<<8|L}else if(_==2)for(S=0;S<c;S++)$=(L=85*(l[N+(S>>>2)]>>>6-((3&S)<<1)&3))==85*x?0:255,A[M+S]=$<<24|L<<16|L<<8|L;else if(_==4)for(S=0;S<c;S++)$=(L=17*(l[N+(S>>>1)]>>>4-((1&S)<<2)&15))==17*x?0:255,A[M+S]=$<<24|L<<16|L<<8|L;else if(_==8)for(S=0;S<c;S++)$=(L=l[N+S])==x?0:255,A[M+S]=$<<24|L<<16|L<<8|L;else if(_==16)for(S=0;S<c;S++)L=l[N+(S<<1)],$=T(l,N+(S<<1))==x?0:255,A[M+S]=$<<24|L<<16|L<<8|L}return y}function n(l,c,u,p){const g=s(l),v=Math.ceil(u*g/8),w=new Uint8Array((v+1+l.interlace)*p);return c=l.tabs.CgBI?o(c,w):r(c,w),l.interlace==0?c=a(c,l,0,u,p):l.interlace==1&&(c=(function(A,j){const _=j.width,T=j.height,C=s(j),E=C>>3,x=Math.ceil(_*C/8),b=new Uint8Array(T*x);let R=0;const D=[0,0,4,0,2,0,1],O=[0,4,0,2,0,1,0],F=[8,8,8,4,4,2,2],P=[8,8,4,4,2,2,1];let L=0;for(;L<7;){const S=F[L],$=P[L];let N=0,M=0,H=D[L];for(;H<T;)H+=S,M++;let I=O[L];for(;I<_;)I+=$,N++;const B=Math.ceil(N*C/8);a(A,j,R,N,M);let z=0,U=D[L];for(;U<T;){let V=O[L],G=R+z*B<<3;for(;V<_;){var k;if(C==1&&(k=(k=A[G>>3])>>7-(7&G)&1,b[U*x+(V>>3)]|=k<<7-((7&V)<<0)),C==2&&(k=(k=A[G>>3])>>6-(7&G)&3,b[U*x+(V>>2)]|=k<<6-((3&V)<<1)),C==4&&(k=(k=A[G>>3])>>4-(7&G)&15,b[U*x+(V>>1)]|=k<<4-((1&V)<<2)),C>=8){const X=U*x+V*E;for(let K=0;K<E;K++)b[X+K]=A[(G>>3)+K]}G+=C,V+=$}z++,U+=S}N*M!=0&&(R+=M*(1+B)),L+=1}return b})(c,l)),c}function r(l,c){return o(new Uint8Array(l.buffer,2,l.length-6),c)}var o=(function(){const l={H:{}};return l.H.N=function(c,u){const p=Uint8Array;let g,v,w=0,y=0,A=0,j=0,_=0,T=0,C=0,E=0,x=0;if(c[0]==3&&c[1]==0)return u||new p(0);const b=l.H,R=b.b,D=b.e,O=b.R,F=b.n,P=b.A,L=b.Z,k=b.m,S=u==null;for(S&&(u=new p(c.length>>>2<<5));w==0;)if(w=R(c,x,1),y=R(c,x+1,2),x+=3,y!=0){if(S&&(u=l.H.W(u,E+(1<<17))),y==1&&(g=k.J,v=k.h,T=511,C=31),y==2){A=D(c,x,5)+257,j=D(c,x+5,5)+1,_=D(c,x+10,4)+4,x+=14;let N=1;for(var $=0;$<38;$+=2)k.Q[$]=0,k.Q[$+1]=0;for($=0;$<_;$++){const I=D(c,x+3*$,3);k.Q[1+(k.X[$]<<1)]=I,I>N&&(N=I)}x+=3*_,F(k.Q,N),P(k.Q,N,k.u),g=k.w,v=k.d,x=O(k.u,(1<<N)-1,A+j,c,x,k.v);const M=b.V(k.v,0,A,k.C);T=(1<<M)-1;const H=b.V(k.v,A,j,k.D);C=(1<<H)-1,F(k.C,M),P(k.C,M,g),F(k.D,H),P(k.D,H,v)}for(;;){const N=g[L(c,x)&T];x+=15&N;const M=N>>>4;if(!(M>>>8))u[E++]=M;else{if(M==256)break;{let H=E+M-254;if(M>264){const V=k.q[M-257];H=E+(V>>>3)+D(c,x,7&V),x+=7&V}const I=v[L(c,x)&C];x+=15&I;const B=I>>>4,z=k.c[B],U=(z>>>4)+R(c,x,15&z);for(x+=15&z;E<H;)u[E]=u[E++-U],u[E]=u[E++-U],u[E]=u[E++-U],u[E]=u[E++-U];E=H}}}}else{(7&x)!=0&&(x+=8-(7&x));const N=4+(x>>>3),M=c[N-4]|c[N-3]<<8;S&&(u=l.H.W(u,E+M)),u.set(new p(c.buffer,c.byteOffset+N,M),E),x=N+M<<3,E+=M}return u.length==E?u:u.slice(0,E)},l.H.W=function(c,u){const p=c.length;if(u<=p)return c;const g=new Uint8Array(p<<1);return g.set(c,0),g},l.H.R=function(c,u,p,g,v,w){const y=l.H.e,A=l.H.Z;let j=0;for(;j<p;){const _=c[A(g,v)&u];v+=15&_;const T=_>>>4;if(T<=15)w[j]=T,j++;else{let C=0,E=0;T==16?(E=3+y(g,v,2),v+=2,C=w[j-1]):T==17?(E=3+y(g,v,3),v+=3):T==18&&(E=11+y(g,v,7),v+=7);const x=j+E;for(;j<x;)w[j]=C,j++}}return v},l.H.V=function(c,u,p,g){let v=0,w=0;const y=g.length>>>1;for(;w<p;){const A=c[w+u];g[w<<1]=0,g[1+(w<<1)]=A,A>v&&(v=A),w++}for(;w<y;)g[w<<1]=0,g[1+(w<<1)]=0,w++;return v},l.H.n=function(c,u){const p=l.H.m,g=c.length;let v,w,y,A;const j=p.j;for(var _=0;_<=u;_++)j[_]=0;for(_=1;_<g;_+=2)j[c[_]]++;const T=p.K;for(v=0,j[0]=0,w=1;w<=u;w++)v=v+j[w-1]<<1,T[w]=v;for(y=0;y<g;y+=2)A=c[y+1],A!=0&&(c[y]=T[A],T[A]++)},l.H.A=function(c,u,p){const g=c.length,v=l.H.m.r;for(let w=0;w<g;w+=2)if(c[w+1]!=0){const y=w>>1,A=c[w+1],j=y<<4|A,_=u-A;let T=c[w]<<_;const C=T+(1<<_);for(;T!=C;)p[v[T]>>>15-u]=j,T++}},l.H.l=function(c,u){const p=l.H.m.r,g=15-u;for(let v=0;v<c.length;v+=2){const w=c[v]<<u-c[v+1];c[v]=p[w]>>>g}},l.H.M=function(c,u,p){p<<=7&u;const g=u>>>3;c[g]|=p,c[g+1]|=p>>>8},l.H.I=function(c,u,p){p<<=7&u;const g=u>>>3;c[g]|=p,c[g+1]|=p>>>8,c[g+2]|=p>>>16},l.H.e=function(c,u,p){return(c[u>>>3]|c[1+(u>>>3)]<<8)>>>(7&u)&(1<<p)-1},l.H.b=function(c,u,p){return(c[u>>>3]|c[1+(u>>>3)]<<8|c[2+(u>>>3)]<<16)>>>(7&u)&(1<<p)-1},l.H.Z=function(c,u){return(c[u>>>3]|c[1+(u>>>3)]<<8|c[2+(u>>>3)]<<16)>>>(7&u)},l.H.i=function(c,u){return(c[u>>>3]|c[1+(u>>>3)]<<8|c[2+(u>>>3)]<<16|c[3+(u>>>3)]<<24)>>>(7&u)},l.H.m=(function(){const c=Uint16Array,u=Uint32Array;return{K:new c(16),j:new c(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 c(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 c(512),_:[],h:new c(32),$:[],w:new c(32768),C:[],v:[],d:new c(32768),D:[],u:new c(512),Q:[],r:new c(32768),s:new u(286),Y:new u(30),a:new u(19),t:new u(15e3),k:new c(65536),g:new c(32768)}})(),(function(){const c=l.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,c.r[u]=(g>>>16|g<<16)>>>17}function p(g,v,w){for(;v--!=0;)g.push(0,w)}for(u=0;u<32;u++)c.q[u]=c.S[u]<<3|c.T[u],c.c[u]=c.p[u]<<4|c.z[u];p(c._,144,8),p(c._,112,9),p(c._,24,7),p(c._,8,8),l.H.n(c._,9),l.H.A(c._,9,c.J),l.H.l(c._,9),p(c.$,32,5),l.H.n(c.$,5),l.H.A(c.$,5,c.h),l.H.l(c.$,5),p(c.Q,19,0),p(c.C,286,0),p(c.D,30,0),p(c.v,320,0)})(),l.H.N})();function s(l){return[1,null,3,1,2,null,4][l.ctype]*l.depth}function a(l,c,u,p,g){let v=s(c);const w=Math.ceil(p*v/8);let y,A;v=Math.ceil(v/8);let j=l[u],_=0;if(j>1&&(l[u]=[0,0,1][j-2]),j==3)for(_=v;_<w;_++)l[_+1]=l[_+1]+(l[_+1-v]>>>1)&255;for(let T=0;T<g;T++)if(y=u+T*w,A=y+T+1,j=l[A-1],_=0,j==0)for(;_<w;_++)l[y+_]=l[A+_];else if(j==1){for(;_<v;_++)l[y+_]=l[A+_];for(;_<w;_++)l[y+_]=l[A+_]+l[y+_-v]}else if(j==2)for(;_<w;_++)l[y+_]=l[A+_]+l[y+_-w];else if(j==3){for(;_<v;_++)l[y+_]=l[A+_]+(l[y+_-w]>>>1);for(;_<w;_++)l[y+_]=l[A+_]+(l[y+_-w]+l[y+_-v]>>>1)}else{for(;_<v;_++)l[y+_]=l[A+_]+i(0,l[y+_-w],0);for(;_<w;_++)l[y+_]=l[A+_]+i(l[y+_-v],l[y+_-w],l[y+_-v-w])}return l}function i(l,c,u){const p=l+c-u,g=p-l,v=p-c,w=p-u;return g*g<=v*v&&g*g<=w*w?l:v*v<=w*w?c:u}function h(l,c,u){u.width=e.readUint(l,c),c+=4,u.height=e.readUint(l,c),c+=4,u.depth=l[c],c++,u.ctype=l[c],c++,u.compress=l[c],c++,u.filter=l[c],c++,u.interlace=l[c],c++}function f(l,c,u,p,g,v,w,y,A){const j=Math.min(c,g),_=Math.min(u,v);let T=0,C=0;for(let L=0;L<_;L++)for(let k=0;k<j;k++)if(w>=0&&y>=0?(T=L*c+k<<2,C=(y+L)*g+w+k<<2):(T=(-y+L)*c-w+k<<2,C=L*g+k<<2),A==0)p[C]=l[T],p[C+1]=l[T+1],p[C+2]=l[T+2],p[C+3]=l[T+3];else if(A==1){var E=l[T+3]*.00392156862745098,x=l[T]*E,b=l[T+1]*E,R=l[T+2]*E,D=p[C+3]*(1/255),O=p[C]*D,F=p[C+1]*D,P=p[C+2]*D;const S=1-E,$=E+D*S,N=$==0?0:1/$;p[C+3]=255*$,p[C+0]=(x+O*S)*N,p[C+1]=(b+F*S)*N,p[C+2]=(R+P*S)*N}else if(A==2)E=l[T+3],x=l[T],b=l[T+1],R=l[T+2],D=p[C+3],O=p[C],F=p[C+1],P=p[C+2],E==D&&x==O&&b==F&&R==P?(p[C]=0,p[C+1]=0,p[C+2]=0,p[C+3]=0):(p[C]=x,p[C+1]=b,p[C+2]=R,p[C+3]=E);else if(A==3){if(E=l[T+3],x=l[T],b=l[T+1],R=l[T+2],D=p[C+3],O=p[C],F=p[C+1],P=p[C+2],E==D&&x==O&&b==F&&R==P)continue;if(E<220&&D>20)return!1}return!0}return{decode:function(c){const u=new Uint8Array(c);let p=8;const g=e,v=g.readUshort,w=g.readUint,y={tabs:{},frames:[]},A=new Uint8Array(u.length);let j,_=0,T=0;const C=[137,80,78,71,13,10,26,10];for(var E=0;E<8;E++)if(u[E]!=C[E])throw"The input is not a PNG file!";for(;p<u.length;){const L=g.readUint(u,p);p+=4;const k=g.readASCII(u,p,4);if(p+=4,k=="IHDR")h(u,p,y);else if(k=="iCCP"){for(var x=p;u[x]!=0;)x++;g.readASCII(u,p,x-p),u[x+1];const S=u.slice(x+2,p+L);let $=null;try{$=r(S)}catch{$=o(S)}y.tabs[k]=$}else if(k=="CgBI")y.tabs[k]=u.slice(p,p+4);else if(k=="IDAT"){for(E=0;E<L;E++)A[_+E]=u[p+E];_+=L}else if(k=="acTL")y.tabs[k]={num_frames:w(u,p),num_plays:w(u,p+4)},j=new Uint8Array(u.length);else if(k=="fcTL"){T!=0&&((P=y.frames[y.frames.length-1]).data=n(y,j.slice(0,T),P.rect.width,P.rect.height),T=0);const S={x:w(u,p+12),y:w(u,p+16),width:w(u,p+4),height:w(u,p+8)};let $=v(u,p+22);$=v(u,p+20)/($==0?100:$);const N={rect:S,delay:Math.round(1e3*$),dispose:u[p+24],blend:u[p+25]};y.frames.push(N)}else if(k=="fdAT"){for(E=0;E<L-4;E++)j[T+E]=u[p+E+4];T+=L-4}else if(k=="pHYs")y.tabs[k]=[g.readUint(u,p),g.readUint(u,p+4),u[p+8]];else if(k=="cHRM")for(y.tabs[k]=[],E=0;E<8;E++)y.tabs[k].push(g.readUint(u,p+4*E));else if(k=="tEXt"||k=="zTXt"){y.tabs[k]==null&&(y.tabs[k]={});var b=g.nextZero(u,p),R=g.readASCII(u,p,b-p),D=p+L-b-1;if(k=="tEXt")F=g.readASCII(u,b+1,D);else{var O=r(u.slice(b+2,b+2+D));F=g.readUTF8(O,0,O.length)}y.tabs[k][R]=F}else if(k=="iTXt"){y.tabs[k]==null&&(y.tabs[k]={}),b=0,x=p,b=g.nextZero(u,x),R=g.readASCII(u,x,b-x);const S=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),D=L-((x=b+1)-p),S==0?F=g.readUTF8(u,x,D):(O=r(u.slice(x,x+D)),F=g.readUTF8(O,0,O.length)),y.tabs[k][R]=F}else if(k=="PLTE")y.tabs[k]=g.readBytes(u,p,L);else if(k=="hIST"){const S=y.tabs.PLTE.length/3;for(y.tabs[k]=[],E=0;E<S;E++)y.tabs[k].push(v(u,p+2*E))}else if(k=="tRNS")y.ctype==3?y.tabs[k]=g.readBytes(u,p,L):y.ctype==0?y.tabs[k]=v(u,p):y.ctype==2&&(y.tabs[k]=[v(u,p),v(u,p+2),v(u,p+4)]);else if(k=="gAMA")y.tabs[k]=g.readUint(u,p)/1e5;else if(k=="sRGB")y.tabs[k]=u[p];else if(k=="bKGD")y.ctype==0||y.ctype==4?y.tabs[k]=[v(u,p)]:y.ctype==2||y.ctype==6?y.tabs[k]=[v(u,p),v(u,p+2),v(u,p+4)]:y.ctype==3&&(y.tabs[k]=u[p]);else if(k=="IEND")break;p+=L,g.readUint(u,p),p+=4}var P;return T!=0&&((P=y.frames[y.frames.length-1]).data=n(y,j.slice(0,T),P.rect.width,P.rect.height)),y.data=n(y,A,y.width,y.height),delete y.compress,delete y.interlace,delete y.filter,y},toRGBA8:function(c){const u=c.width,p=c.height;if(c.tabs.acTL==null)return[t(c.data,u,p,c).buffer];const g=[];c.frames[0].data==null&&(c.frames[0].data=c.data);const v=u*p*4,w=new Uint8Array(v),y=new Uint8Array(v),A=new Uint8Array(v);for(let _=0;_<c.frames.length;_++){const T=c.frames[_],C=T.rect.x,E=T.rect.y,x=T.rect.width,b=T.rect.height,R=t(T.data,x,b,c);if(_!=0)for(var j=0;j<v;j++)A[j]=w[j];if(T.blend==0?f(R,x,b,w,u,p,C,E,0):T.blend==1&&f(R,x,b,w,u,p,C,E,1),g.push(w.buffer.slice(0)),T.dispose!=0){if(T.dispose==1)f(y,x,b,w,u,p,C,E,0);else if(T.dispose==2)for(j=0;j<v;j++)w[j]=A[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 R=b;for(let D=0;D<8;D++)1&R?R=3988292384^R>>>1:R>>>=1;x[b]=R}return x})(),update(x,b,R,D){for(let O=0;O<D;O++)x=r.table[255&(x^b[R+O])]^x>>>8;return x},crc:(x,b,R)=>4294967295^r.update(4294967295,x,b,R)};function o(x,b,R,D){b[R]+=x[0]*D>>4,b[R+1]+=x[1]*D>>4,b[R+2]+=x[2]*D>>4,b[R+3]+=x[3]*D>>4}function s(x){return Math.max(0,Math.min(255,x))}function a(x,b){const R=x[0]-b[0],D=x[1]-b[1],O=x[2]-b[2],F=x[3]-b[3];return R*R+D*D+O*O+F*F}function i(x,b,R,D,O,F,P){P==null&&(P=1);const L=D.length,k=[];for(var S=0;S<L;S++){const U=D[S];k.push([U>>>0&255,U>>>8&255,U>>>16&255,U>>>24&255])}for(S=0;S<L;S++){let U=4294967295;for(var $=0,N=0;N<L;N++){var M=a(k[S],k[N]);N!=S&&M<U&&(U=M,$=N)}}const H=new Uint32Array(O.buffer),I=new Int16Array(b*R*4),B=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(S=0;S<B.length;S++)B[S]=255*((B[S]+.5)/16-.5);for(let U=0;U<R;U++)for(let V=0;V<b;V++){var z;S=4*(U*b+V),P!=2?z=[s(x[S]+I[S]),s(x[S+1]+I[S+1]),s(x[S+2]+I[S+2]),s(x[S+3]+I[S+3])]:(M=B[4*(3&U)+(3&V)],z=[s(x[S]+M),s(x[S+1]+M),s(x[S+2]+M),s(x[S+3]+M)]),$=0;let G=16777215;for(N=0;N<L;N++){const ne=a(z,k[N]);ne<G&&(G=ne,$=N)}const X=k[$],K=[z[0]-X[0],z[1]-X[1],z[2]-X[2],z[3]-X[3]];P==1&&(V!=b-1&&o(K,I,S+4,7),U!=R-1&&(V!=0&&o(K,I,S+4*b-4,3),o(K,I,S+4*b,5),V!=b-1&&o(K,I,S+4*b+4,1))),F[S>>2]=$,H[S>>2]=D[$]}}function h(x,b,R,D,O){O==null&&(O={});const{crc:F}=r,P=t.writeUint,L=t.writeUshort,k=t.writeASCII;let S=8;const $=x.frames.length>1;let N,M=!1,H=33+($?20:0);if(O.sRGB!=null&&(H+=13),O.pHYs!=null&&(H+=21),O.iCCP!=null&&(N=pako.deflate(O.iCCP),H+=21+N.length+4),x.ctype==3){for(var I=x.plte.length,B=0;B<I;B++)x.plte[B]>>>24!=255&&(M=!0);H+=8+3*I+4+(M?8+1*I+4:0)}for(var z=0;z<x.frames.length;z++)$&&(H+=38),H+=(X=x.frames[z]).cimg.length+12,z!=0&&(H+=4);H+=12;const U=new Uint8Array(H),V=[137,80,78,71,13,10,26,10];for(B=0;B<8;B++)U[B]=V[B];if(P(U,S,13),S+=4,k(U,S,"IHDR"),S+=4,P(U,S,b),S+=4,P(U,S,R),S+=4,U[S]=x.depth,S++,U[S]=x.ctype,S++,U[S]=0,S++,U[S]=0,S++,U[S]=0,S++,P(U,S,F(U,S-17,17)),S+=4,O.sRGB!=null&&(P(U,S,1),S+=4,k(U,S,"sRGB"),S+=4,U[S]=O.sRGB,S++,P(U,S,F(U,S-5,5)),S+=4),O.iCCP!=null){const K=13+N.length;P(U,S,K),S+=4,k(U,S,"iCCP"),S+=4,k(U,S,"ICC profile"),S+=11,S+=2,U.set(N,S),S+=N.length,P(U,S,F(U,S-(K+4),K+4)),S+=4}if(O.pHYs!=null&&(P(U,S,9),S+=4,k(U,S,"pHYs"),S+=4,P(U,S,O.pHYs[0]),S+=4,P(U,S,O.pHYs[1]),S+=4,U[S]=O.pHYs[2],S++,P(U,S,F(U,S-13,13)),S+=4),$&&(P(U,S,8),S+=4,k(U,S,"acTL"),S+=4,P(U,S,x.frames.length),S+=4,P(U,S,O.loop!=null?O.loop:0),S+=4,P(U,S,F(U,S-12,12)),S+=4),x.ctype==3){for(P(U,S,3*(I=x.plte.length)),S+=4,k(U,S,"PLTE"),S+=4,B=0;B<I;B++){const K=3*B,ne=x.plte[B],ie=255&ne,de=ne>>>8&255,me=ne>>>16&255;U[S+K+0]=ie,U[S+K+1]=de,U[S+K+2]=me}if(S+=3*I,P(U,S,F(U,S-3*I-4,3*I+4)),S+=4,M){for(P(U,S,I),S+=4,k(U,S,"tRNS"),S+=4,B=0;B<I;B++)U[S+B]=x.plte[B]>>>24&255;S+=I,P(U,S,F(U,S-I-4,I+4)),S+=4}}let G=0;for(z=0;z<x.frames.length;z++){var X=x.frames[z];$&&(P(U,S,26),S+=4,k(U,S,"fcTL"),S+=4,P(U,S,G++),S+=4,P(U,S,X.rect.width),S+=4,P(U,S,X.rect.height),S+=4,P(U,S,X.rect.x),S+=4,P(U,S,X.rect.y),S+=4,L(U,S,D[z]),S+=2,L(U,S,1e3),S+=2,U[S]=X.dispose,S++,U[S]=X.blend,S++,P(U,S,F(U,S-30,30)),S+=4);const K=X.cimg;P(U,S,(I=K.length)+(z==0?0:4)),S+=4;const ne=S;k(U,S,z==0?"IDAT":"fdAT"),S+=4,z!=0&&(P(U,S,G++),S+=4),U.set(K,S),S+=I,P(U,S,F(U,ne,S-ne)),S+=4}return P(U,S,0),S+=4,k(U,S,"IEND"),S+=4,P(U,S,F(U,S-4,4)),S+=4,U.buffer}function f(x,b,R){for(let D=0;D<x.frames.length;D++){const O=x.frames[D];O.rect.width;const F=O.rect.height,P=new Uint8Array(F*O.bpl+F);O.cimg=p(O.img,F,O.bpp,O.bpl,P,b,R)}}function l(x,b,R,D,O){const F=O[0],P=O[1],L=O[2],k=O[3],S=O[4],$=O[5];let N=6,M=8,H=255;for(var I=0;I<x.length;I++){const J=new Uint8Array(x[I]);for(var B=J.length,z=0;z<B;z+=4)H&=J[z+3]}const U=H!=255,V=(function(te,le,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=le,pt=oe,ir=he?1:0;if(fe!=0){const nc=_e||he||fe==1||xe[fe-2].dispose!=0?1:2;let lr=0,Lo=1e9;for(let Kt=0;Kt<nc;Kt++){var Je=new Uint8Array(te[fe-1-Kt]);const rc=new Uint32Array(te[fe-1-Kt]);let et=le,tt=oe,At=-1,qt=-1;for(let gt=0;gt<oe;gt++)for(let xt=0;xt<le;xt++)Me[ye=gt*le+xt]!=rc[ye]&&(xt<et&&(et=xt),xt>At&&(At=xt),gt<tt&&(tt=gt),gt>qt&&(qt=gt));At==-1&&(et=tt=At=qt=0),ge&&((1&et)==1&&et--,(1&tt)==1&&tt--);const $o=(At-et+1)*(qt-tt+1);$o<Lo&&(Lo=$o,lr=Kt,Re=et,Ve=tt,$e=At-et+1,pt=qt-tt+1)}Je=new Uint8Array(te[fe-1-lr]),lr==1&&(xe[fe-1].dispose=2),Ee=new Uint8Array($e*pt*4),e(Je,le,oe,Ee,$e,pt,-Re,-Ve,0),ir=e(we,le,oe,Ee,$e,pt,-Re,-Ve,3)?1:0,ir==1?u(we,le,oe,Ee,{x:Re,y:Ve,width:$e,height:pt}):e(we,le,oe,Ee,$e,pt,-Re,-Ve,0)}else Ee=we.slice(0);xe.push({rect:{x:Re,y:Ve,width:$e,height:pt},img:Ee,blend:ir,dispose:0})}if(he)for(fe=0;fe<xe.length;fe++){if((mt=xe[fe]).blend==1)continue;const we=mt.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&&c(te,le,oe,xe,fe-1,$e,ge),c(te,le,oe,xe,fe,$e,ge)}let xn=0;if(te.length!=1)for(var ye=0;ye<xe.length;ye++){var mt;xn+=(mt=xe[ye]).rect.width*mt.rect.height}return xe})(x,b,R,F,P,L),G={},X=[],K=[];if(D!=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 mt=Je[ye],we=Je[ye+1],Me=Je[ye+2];const Re=Je[ye+3];Re==0&&(mt=we=Me=0),fe[Ee+ye]=mt,fe[Ee+ye+1]=we,fe[Ee+ye+2]=Me,fe[Ee+ye+3]=Re}Ee+=xn}return fe.buffer})(J),le=v(te,D);for(z=0;z<le.plte.length;z++)X.push(le.plte[z].est.rgba);let oe=0;for(z=0;z<V.length;z++){const he=(ie=V[z]).img.length;var ne=new Uint8Array(le.inds.buffer,oe>>2,he>>2);K.push(ne);const ge=new Uint8Array(le.abuf,oe,he);$&&i(ie.img,ie.rect.width,ie.rect.height,X,ge,ne),ie.img.set(ge),oe+=he}}else for(I=0;I<V.length;I++){var ie=V[I];const J=new Uint32Array(ie.img.buffer);var de=ie.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 le=G[te];if(le==null&&(G[te]=le=X.length,X.push(te),X.length>=300))break;ne[z]=le}}}const me=X.length;for(me<=256&&S==0&&(M=me<=2?1:me<=4?2:me<=16?4:8,M=Math.max(M,k)),I=0;I<V.length;I++){(ie=V[I]).rect.x,ie.rect.y,de=ie.rect.width;const J=ie.rect.height;let te=ie.img;new Uint32Array(te.buffer);let le=4*de,oe=4;if(me<=256&&S==0){le=Math.ceil(M*de/8);var W=new Uint8Array(le*J);const he=K[I];for(let ge=0;ge<J;ge++){z=ge*le;const _e=ge*de;if(M==8)for(var q=0;q<de;q++)W[z+q]=he[_e+q];else if(M==4)for(q=0;q<de;q++)W[z+(q>>1)]|=he[_e+q]<<4-4*(1&q);else if(M==2)for(q=0;q<de;q++)W[z+(q>>2)]|=he[_e+q]<<6-2*(3&q);else if(M==1)for(q=0;q<de;q++)W[z+(q>>3)]|=he[_e+q]<<7-1*(7&q)}te=W,N=3,oe=1}else if(U==0&&V.length==1){W=new Uint8Array(de*J*3);const he=de*J;for(z=0;z<he;z++){const ge=3*z,_e=4*z;W[ge]=te[_e],W[ge+1]=te[_e+1],W[ge+2]=te[_e+2]}te=W,N=2,oe=3,le=3*de}ie.img=te,ie.bpl=le,ie.bpp=oe}return{ctype:N,depth:M,plte:X,frames:V}}function c(x,b,R,D,O,F,P){const L=Uint8Array,k=Uint32Array,S=new L(x[O-1]),$=new k(x[O-1]),N=O+1<x.length?new L(x[O+1]):null,M=new L(x[O]),H=new k(M.buffer);let I=b,B=R,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,ie=ne*b+K,de=H[ie];de==0||D[O-1].dispose==0&&$[ie]==de&&(N==null||N[4*ie+3]!=0)||(K<I&&(I=K),K>z&&(z=K),ne<B&&(B=ne),ne>U&&(U=ne))}z==-1&&(I=B=z=U=0),P&&((1&I)==1&&I--,(1&B)==1&&B--),F={x:I,y:B,width:z-I+1,height:U-B+1};const V=D[O];V.rect=F,V.blend=1,V.img=new Uint8Array(F.width*F.height*4),D[O-1].dispose==0?(e(S,b,R,V.img,F.width,F.height,-F.x,-F.y,0),u(M,b,R,V.img,F)):e(M,b,R,V.img,F.width,F.height,-F.x,-F.y,0)}function u(x,b,R,D,O){e(x,b,R,D,O.width,O.height,-O.x,-O.y,2)}function p(x,b,R,D,O,F,P){const L=[];let k,S=[0,1,2,3,4];F!=-1?S=[F]:(b*D>5e5||R==1)&&(S=[0]),P&&(k={level:0});const $=Kp;for(var N=0;N<S.length;N++){for(let I=0;I<b;I++)g(O,x,I,D,R,S[N]);L.push($.deflate(O,k))}let M,H=1e9;for(N=0;N<L.length;N++)L[N].length<H&&(M=N,H=L[N].length);return L[M]}function g(x,b,R,D,O,F){const P=R*D;let L=P+R;if(x[L]=F,L++,F==0)if(D<500)for(var k=0;k<D;k++)x[L+k]=b[P+k];else x.set(new Uint8Array(b.buffer,P,D),L);else if(F==1){for(k=0;k<O;k++)x[L+k]=b[P+k];for(k=O;k<D;k++)x[L+k]=b[P+k]-b[P+k-O]+256&255}else if(R==0){for(k=0;k<O;k++)x[L+k]=b[P+k];if(F==2)for(k=O;k<D;k++)x[L+k]=b[P+k];if(F==3)for(k=O;k<D;k++)x[L+k]=b[P+k]-(b[P+k-O]>>1)+256&255;if(F==4)for(k=O;k<D;k++)x[L+k]=b[P+k]-n(b[P+k-O],0,0)+256&255}else{if(F==2)for(k=0;k<D;k++)x[L+k]=b[P+k]+256-b[P+k-D]&255;if(F==3){for(k=0;k<O;k++)x[L+k]=b[P+k]+256-(b[P+k-D]>>1)&255;for(k=O;k<D;k++)x[L+k]=b[P+k]+256-(b[P+k-D]+b[P+k-O]>>1)&255}if(F==4){for(k=0;k<O;k++)x[L+k]=b[P+k]+256-n(0,b[P+k-D],0)&255;for(k=O;k<D;k++)x[L+k]=b[P+k]+256-n(b[P+k-O],b[P+k-D],b[P+k-O-D])&255}}}function v(x,b){const R=new Uint8Array(x),D=R.slice(0),O=new Uint32Array(D.buffer),F=w(D,b),P=F[0],L=F[1],k=R.length,S=new Uint8Array(k>>2);let $;if(R.length<2e7)for(var N=0;N<k;N+=4)$=y(P,M=R[N]*(1/255),H=R[N+1]*(1/255),I=R[N+2]*(1/255),B=R[N+3]*(1/255)),S[N>>2]=$.ind,O[N>>2]=$.est.rgba;else for(N=0;N<k;N+=4){var M=R[N]*.00392156862745098,H=R[N+1]*(1/255),I=R[N+2]*(1/255),B=R[N+3]*(1/255);for($=P;$.left;)$=A($.est,M,H,I,B)<=0?$.left:$.right;S[N>>2]=$.ind,O[N>>2]=$.est.rgba}return{abuf:D.buffer,inds:S,plte:L}}function w(x,b,R){R==null&&(R=1e-4);const D=new Uint32Array(x.buffer),O={i0:0,i1:x.length,bst:null,est:null,tdst:0,left:null,right:null};O.bst=T(x,O.i0,O.i1),O.est=C(O.bst);const F=[O];for(;F.length<b;){let L=0,k=0;for(var P=0;P<F.length;P++)F[P].est.L>L&&(L=F[P].est.L,k=P);if(L<R)break;const S=F[k],$=j(x,D,S.i0,S.i1,S.est.e,S.est.eMq255);if(S.i0>=$||S.i1<=$){S.est.L=0;continue}const N={i0:S.i0,i1:$,bst:null,est:null,tdst:0,left:null,right:null};N.bst=T(x,N.i0,N.i1),N.est=C(N.bst);const M={i0:$,i1:S.i1,bst:null,est:null,tdst:0,left:null,right:null};for(M.bst={R:[],m:[],N:S.bst.N-N.bst.N},P=0;P<16;P++)M.bst.R[P]=S.bst.R[P]-N.bst.R[P];for(P=0;P<4;P++)M.bst.m[P]=S.bst.m[P]-N.bst.m[P];M.est=C(M.bst),S.left=N,S.right=M,F[k]=N,F.push(M)}for(F.sort(((L,k)=>k.bst.N-L.bst.N)),P=0;P<F.length;P++)F[P].ind=P;return[O,F]}function y(x,b,R,D,O){if(x.left==null)return x.tdst=(function(N,M,H,I,B){const z=M-N[0],U=H-N[1],V=I-N[2],G=B-N[3];return z*z+U*U+V*V+G*G})(x.est.q,b,R,D,O),x;const F=A(x.est,b,R,D,O);let P=x.left,L=x.right;F>0&&(P=x.right,L=x.left);const k=y(P,b,R,D,O);if(k.tdst<=F*F)return k;const S=y(L,b,R,D,O);return S.tdst<k.tdst?S:k}function A(x,b,R,D,O){const{e:F}=x;return F[0]*b+F[1]*R+F[2]*D+F[3]*O-x.eMq}function j(x,b,R,D,O,F){for(D-=4;R<D;){for(;_(x,R,O)<=F;)R+=4;for(;_(x,D,O)>F;)D-=4;if(R>=D)break;const P=b[R>>2];b[R>>2]=b[D>>2],b[D>>2]=P,R+=4,D-=4}for(;_(x,R,O)>F;)R-=4;return R+4}function _(x,b,R){return x[b]*R[0]+x[b+1]*R[1]+x[b+2]*R[2]+x[b+3]*R[3]}function T(x,b,R){const D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],O=[0,0,0,0],F=R-b>>2;for(let P=b;P<R;P+=4){const L=x[P]*.00392156862745098,k=x[P+1]*(1/255),S=x[P+2]*(1/255),$=x[P+3]*(1/255);O[0]+=L,O[1]+=k,O[2]+=S,O[3]+=$,D[0]+=L*L,D[1]+=L*k,D[2]+=L*S,D[3]+=L*$,D[5]+=k*k,D[6]+=k*S,D[7]+=k*$,D[10]+=S*S,D[11]+=S*$,D[15]+=$*$}return D[4]=D[1],D[8]=D[2],D[9]=D[6],D[12]=D[3],D[13]=D[7],D[14]=D[11],{R:D,m:O,N:F}}function C(x){const{R:b}=x,{m:R}=x,{N:D}=x,O=R[0],F=R[1],P=R[2],L=R[3],k=D==0?0:1/D,S=[b[0]-O*O*k,b[1]-O*F*k,b[2]-O*P*k,b[3]-O*L*k,b[4]-F*O*k,b[5]-F*F*k,b[6]-F*P*k,b[7]-F*L*k,b[8]-P*O*k,b[9]-P*F*k,b[10]-P*P*k,b[11]-P*L*k,b[12]-L*O*k,b[13]-L*F*k,b[14]-L*P*k,b[15]-L*L*k],$=S,N=E;let M=[Math.random(),Math.random(),Math.random(),Math.random()],H=0,I=0;if(D!=0)for(let z=0;z<16&&(M=N.multVec($,M),I=Math.sqrt(N.dot(M,M)),M=N.sml(1/I,M),!(z!=0&&Math.abs(I-H)<1e-9));z++)H=I;const B=[O*k,F*k,P*k,L*k];return{Cov:S,q:B,e:M,L:H,eMq255:N.dot(N.sml(255,B),M),eMq:N.dot(M,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 E={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,R,D,O,F,P,L){O==null&&(O=0),L==null&&(L=!1);const k=l(b,R,D,O,[!1,!1,!1,0,L,!1]);return f(k,-1),h(k,R,D,F,P)},Pe.encodeLL=function(b,R,D,O,F,P,L,k){const S={ctype:0+(O==1?0:2)+(F==0?0:4),depth:P,frames:[]},$=(O+F)*P,N=$*R;for(let M=0;M<b.length;M++)S.frames.push({rect:{x:0,y:0,width:R,height:D},img:new Uint8Array(b[M]),blend:0,dispose:1,bpp:Math.ceil($/8),bpl:Math.ceil(N/8)});return f(S,0,!0),h(S,R,D,L,k)},Pe.encode.compress=l,Pe.encode.dither=i,Pe.quantize=v,Pe.quantize.getKDtree=w,Pe.quantize.getNearest=y})();const Ji={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,l=new ArrayBuffer(f),c=new DataView(l),u=1<<20;let p,g,v,w,y=u,A=0,j=0,_=0;function T(x){c.setUint16(j,x,!0),j+=2}function C(x){c.setUint32(j,x,!0),j+=4}function E(x){j+=x}T(19778),C(f),E(4),C(122),C(108),C(n),C(-r>>>0),T(1),T(32),C(3),C(h),C(2835),C(2835),E(8),C(16711680),C(65280),C(255),C(4278190080),C(1466527264),(function x(){for(;A<r&&y>0;){for(w=122+A*i,p=0;p<o;)y--,g=a[_++],v=g>>>24,c.setUint32(w+p,g<<8|v),p+=4;A++}_<a.length?(y=u,setTimeout(x,Ji._dly)):t(l)})()},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 Eo=typeof window<"u",el=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,$n=Eo&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),Yp=(Eo||el)&&($n&&$n.getOriginalSymbol(window,"File")||typeof File<"u"&&File),tl=(Eo||el)&&($n&&$n.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function No(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 nl(e){return new Promise(((t,n)=>{const r=new tl;r.onload=()=>t(r.result),r.onerror=o=>n(o),r.readAsDataURL(e)}))}function rl(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 ol(e,t){const n=yt(),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 sl(e,t){const{width:n,height:r}=ol(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=sl(o,t.fileType||e.type),n([o,s])}catch(h){return r(h)}},i=function(h){try{var f=function(l){try{throw l}catch(c){return r(c)}};try{let l;return nl(e).then((function(c){try{return l=c,rl(l).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(l){f(l)}}catch(l){return r(l)}};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,l,c;return f=e.getContext("2d"),{data:l}=f.getImageData(0,0,e.width,e.height),c=Pe.encode([l.buffer],e.width,e.height,4096*o),i=new Blob([c],{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((l=>Ji.toBlob(e,l))).then((function(l){try{return i=l,i.name=n,i.lastModified=r,f.call(this)}catch(c){return a(c)}}).bind(this),a);{let l=function(){return f.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:o}).then((function(c){try{return i=c,i.name=n,i.lastModified=r,l.call(this)}catch(u){return a(u)}}).bind(this),a);{let c;return c=e.toDataURL(t,o),No(c,n,r).then((function(u){try{return i=u,l.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):No("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(l){return t(l)}}),t)}catch(f){return t(f)}}),t)}catch(h){return t(h)}}),t)}catch(i){return t(i)}}),t)}))}function al(e){return new Promise(((t,n)=>{const r=new tl;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 l=s.getUint16(i,f);i+=2;for(let c=0;c<l;c++)if(s.getUint16(i+12*c,f)==274)return t(s.getUint16(i+12*c+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 il(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 ll(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,l,c,u,p,g,v,w,y,A,j,_,T,C,E,x;function b(D=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;s+=D,t.onProgress(Math.min(s,100))}function R(D){if(t.signal&&t.signal.aborted)throw t.signal.reason;s=Math.min(Math.max(D,s),100),t.onProgress(s)}return s=n,a=t.maxIteration||10,i=1024*t.maxSizeMB*1024,b(),Fn(e,t).then((function(D){try{return[,h]=D,b(),f=il(h,t),b(),new Promise((function(O,F){var P;if(!(P=t.exifOrientation))return al(e).then((function(k){try{return P=k,L.call(this)}catch(S){return F(S)}}).bind(this),F);function L(){return O(P)}return L.call(this)})).then((function(O){try{return l=O,b(),Mt().then((function(F){try{return c=F?f:ll(f,l),b(),u=t.initialQuality||1,p=t.fileType||e.type,Un(c,p,e.name,e.lastModified,u).then((function(P){try{{let k=function(){if(a--&&(j>i||j>y)){let $,N;return $=x?.95*E.width:E.width,N=x?.95*E.height:E.height,[T,C]=er($,N),C.drawImage(E,0,0,$,N),u*=p==="image/png"?.85:.95,Un(T,p,e.name,e.lastModified,u).then((function(M){try{return _=M,Ue(E),E=T,j=_.size,R(Math.min(99,Math.floor((A-j)/(A-i)*100))),k}catch(H){return o(H)}}),o)}return[1]},S=function(){return Ue(E),Ue(T),Ue(f),Ue(c),Ue(h),R(100),r(_)};if(g=P,b(),v=g.size>i,w=g.size>e.size,!v&&!w)return R(100),r(g);var L;return y=e.size,A=g.size,j=A,E=c,x=!t.alwaysKeepResolution&&v,(L=(function($){for(;$;){if($.then)return void $.then(L,o);try{if($.pop){if($.length)return $.pop()?S.call(this):$;$=k}else $=$.call(this)}catch(N){return o(N)}}}).bind(this))(k)}}catch(k){return o(k)}}).bind(this),o)}catch(P){return o(P)}}).bind(this),o)}catch(F){return o(F)}}).bind(this),o)}catch(O){return o(O)}}).bind(this),o)}))}const Xp=`
232
+ let scriptImported = false
233
+ self.addEventListener('message', async (e) => {
234
+ const { file, id, imageCompressionLibUrl, options } = e.data
235
+ options.onProgress = (progress) => self.postMessage({ progress, id })
236
+ try {
237
+ if (!scriptImported) {
238
+ // console.log('[worker] importScripts', imageCompressionLibUrl)
239
+ self.importScripts(imageCompressionLibUrl)
240
+ scriptImported = true
241
+ }
242
+ // console.log('[worker] self', self)
243
+ const compressedFile = await imageCompression(file, options)
244
+ self.postMessage({ file: compressedFile, id })
245
+ } catch (e) {
246
+ // console.error('[worker] error', e)
247
+ self.postMessage({ error: e.message + '\\n' + e.stack, id })
248
+ }
249
+ })
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 ys(e,o).then((function(p){try{return s=p,u.call(this)}catch(g){return r(g)}}).bind(this),r);var l=(function(){try{return u.call(this)}catch(p){return r(p)}}).bind(this),c=function(p){try{return ys(e,o).then((function(g){try{return s=g,l()}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,l()}catch{return c()}}),c)}catch{c()}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=Zi(e,s))}catch{}return n(s)}}))}be.getDataUrlFromFile=nl,be.getFilefromDataUrl=No,be.loadImage=rl,be.drawImageInCanvas=sl,be.drawFileInCanvas=Fn,be.canvasToFile=Un,be.getExifOrientation=al,be.handleMaxWidthOrHeight=il,be.followExifOrientation=ll,be.cleanupCanvasMemory=Ue,be.isAutoOrientationInBrowser=Mt,be.approximateBelowMaximumCanvasSizeOfBrowser=ol,be.copyExifWithoutOrientation=Zi,be.getBrowserName=yt,be.version="2.0.2";var Zp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ft=Zp.reduce((e,t)=>{const n=fa(`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",cl=m.forwardRef((e,t)=>d.jsx(ue.span,{...e,ref:t,style:{...Jp,...e.style}}));cl.displayName=eg;var tg=cl,[tr]=Qe("Tooltip",[Vt]),nr=Vt(),dl="TooltipProvider",ng=700,Ur="tooltip.open",[rg,jo]=tr(dl),ul=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})};ul.displayName=dl;var rn="Tooltip",[og,mn]=tr(rn),fl=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:i}=e,h=jo(rn,e.__scopeTooltip),f=nr(t),[l,c]=m.useState(null),u=Ce(),p=m.useRef(0),g=a??h.disableHoverableContent,v=i??h.delayDuration,w=m.useRef(!1),[y,A]=it({prop:r,defaultProp:o??!1,onChange:E=>{E?(h.onOpen(),document.dispatchEvent(new CustomEvent(Ur))):h.onClose(),s==null||s(E)},caller:rn}),j=m.useMemo(()=>y?w.current?"delayed-open":"instant-open":"closed",[y]),_=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,A(!0)},[A]),T=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,A(!1)},[A]),C=m.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,A(!0),p.current=0},v)},[v,A]);return m.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),d.jsx(co,{...f,children:d.jsx(og,{scope:t,contentId:u,open:y,stateAttribute:j,trigger:l,onTriggerChange:c,onTriggerEnter:m.useCallback(()=>{h.isOpenDelayedRef.current?C():_()},[h.isOpenDelayedRef,C,_]),onTriggerLeave:m.useCallback(()=>{g?T():(window.clearTimeout(p.current),p.current=0)},[T,g]),onOpen:_,onClose:T,disableHoverableContent:g,children:n})})};fl.displayName=rn;var zr="TooltipTrigger",hl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mn(zr,n),s=jo(zr,n),a=nr(n),i=m.useRef(null),h=pe(t,i,o.onTriggerChange),f=m.useRef(!1),l=m.useRef(!1),c=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",c),[c]),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"&&!l.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),l.current=!0)}),onPointerLeave:ee(e.onPointerLeave,()=>{o.onTriggerLeave(),l.current=!1}),onPointerDown:ee(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",c,{once:!0})}),onFocus:ee(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:ee(e.onBlur,o.onClose),onClick:ee(e.onClick,o.onClose)})})});hl.displayName=zr;var Ao="TooltipPortal",[sg,ag]=tr(Ao,{forceMount:void 0}),ml=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=mn(Ao,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})})})};ml.displayName=Ao;var Ft="TooltipContent",pl=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(gl,{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=jo(Ft,e.__scopeTooltip),o=m.useRef(null),s=pe(t,o),[a,i]=m.useState(null),{trigger:h,onClose:f}=n,l=o.current,{onPointerInTransitChange:c}=r,u=m.useCallback(()=>{i(null),c(!1)},[c]),p=m.useCallback((g,v)=>{const w=g.currentTarget,y={x:g.clientX,y:g.clientY},A=ug(y,w.getBoundingClientRect()),j=fg(y,A),_=hg(v.getBoundingClientRect()),T=pg([...j,..._]);i(T),c(!0)},[c]);return m.useEffect(()=>()=>u(),[u]),m.useEffect(()=>{if(h&&l){const g=w=>p(w,l),v=w=>p(w,h);return h.addEventListener("pointerleave",g),l.addEventListener("pointerleave",v),()=>{h.removeEventListener("pointerleave",g),l.removeEventListener("pointerleave",v)}}},[h,l,p,u]),m.useEffect(()=>{if(a){const g=v=>{const w=v.target,y={x:v.clientX,y:v.clientY},A=(h==null?void 0:h.contains(w))||(l==null?void 0:l.contains(w)),j=!mg(y,a);A?u():j&&(u(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[h,l,a,f,u]),d.jsx(gl,{...e,ref:s})}),[lg,cg]=tr(rn,{isInside:!1}),dg=Ou("TooltipContent"),gl=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:l}=h;return m.useEffect(()=>(document.addEventListener(Ur,l),()=>document.removeEventListener(Ur,l)),[l]),m.useEffect(()=>{if(h.trigger){const c=u=>{const p=u.target;p!=null&&p.contains(h.trigger)&&l()};return window.addEventListener("scroll",c,{capture:!0}),()=>window.removeEventListener("scroll",c,{capture:!0})}},[h.trigger,l]),d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:c=>c.preventDefault(),onDismiss:l,children:d.jsxs(uo,{"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})})]})})});pl.displayName=Ft;var xl="TooltipArrow",vl=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=nr(n);return cg(xl,n).isInside?null:d.jsx(fo,{...o,...r,ref:t})});vl.displayName=xl;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,l=i.y,c=h.x,u=h.y;l>r!=u>r&&n<(c-f)*(r-l)/(u-l)+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=ul,vg=fl,bg=hl,yg=ml,wg=pl,Cg=vl;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(()=>sn(()=>import("./mermaid-VLURNSYL-Dn1LM1yF.js").then(e=>e.i),__vite__mapDeps([0,1,2])).then(e=>({default:e.Streamdown})));m.createContext(null);const Ro=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);Ro.displayName="MessageResponse";var rr="Collapsible",[jg]=Qe(rr),[Ag,To]=jg(rr),bl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...i}=e,[h,f]=it({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(l=>!l),[f]),children:d.jsx(ue.div,{"data-state":Mo(h),"data-disabled":s?"":void 0,...i,ref:t})})});bl.displayName=rr;var yl="CollapsibleTrigger",wl=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=To(yl,n);return d.jsx(ue.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Mo(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ee(e.onClick,o.onOpenToggle)})});wl.displayName=yl;var Io="CollapsibleContent",Cl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=To(Io,e.__scopeCollapsible);return d.jsx(Ae,{present:n||o.open,children:({present:s})=>d.jsx(Rg,{...r,ref:t,present:s})})});Cl.displayName=Io;var Rg=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=To(Io,n),[i,h]=m.useState(r),f=m.useRef(null),l=pe(t,f),c=m.useRef(0),u=c.current,p=m.useRef(0),g=p.current,v=a.open||i,w=m.useRef(v),y=m.useRef(void 0);return m.useEffect(()=>{const A=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(A)},[]),Ke(()=>{const A=f.current;if(A){y.current=y.current||{transitionDuration:A.style.transitionDuration,animationName:A.style.animationName},A.style.transitionDuration="0s",A.style.animationName="none";const j=A.getBoundingClientRect();c.current=j.height,p.current=j.width,w.current||(A.style.transitionDuration=y.current.transitionDuration,A.style.animationName=y.current.animationName),h(r)}},[a.open,r]),d.jsx(ue.div,{"data-state":Mo(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!v,...s,ref:l,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 Mo(e){return e?"open":"closed"}var Tg=bl;function Ig({...e}){return d.jsx(Tg,{"data-slot":"collapsible",...e})}function Mg({...e}){return d.jsx(wl,{"data-slot":"collapsible-trigger",...e})}function Pg({...e}){return d.jsx(Cl,{"data-slot":"collapsible-content",...e})}const Og=({children:e,as:t="p",className:n,duration:r=2})=>{const o=cc.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),Sl=m.createContext(null),Lg=()=>{const e=m.useContext(Sl);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},$g=1e3,Fg=1e3,kl=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:o,duration:s,children:a,...i})=>{const[h,f]=it({prop:n,defaultProp:r,onChange:o}),[l,c]=it({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&&(c(Math.ceil((Date.now()-g)/Fg)),v(null))},[t,g,c]);const w=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;m.useEffect(()=>{if(!w&&r&&!t&&h&&!u){const A=setTimeout(()=>{f(!1),p(!0)},$g);return()=>clearTimeout(A)}},[t,h,r,f,u,w]);const y=A=>{f(A)};return d.jsx(Sl.Provider,{value:{isStreaming:t,isOpen:h??!1,setIsOpen:f,duration:l},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"]}),_l=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(fd,{className:"size-4"}),n(o,a),d.jsx(an,{className:Z("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),El=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}));kl.displayName="Reasoning";_l.displayName="ReasoningTrigger";El.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(Hg,{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-[${br}px]`),style:!t&&r?{maxHeight:`${br}px`}:void 0,children:td(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(an,{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(kl,{isStreaming:s,children:[d.jsx(_l,{}),d.jsx(El,{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(Ro,{children:n.text})},r)})]})]})}function Hg({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(Jt,{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(Jt,{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(an,{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(at,{className:"size-4"});case"reject_once":case"reject_always":return d.jsx(Bt,{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 Nl({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(ws,{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(ws,{tool:s.toolCall,compact:!0,onPermissionRespond:t},s.toolCall.id||a))})]})})}function ws({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(bd,{className:"h-3.5 w-3.5 text-status-active"});case"in_progress":return d.jsx(ra,{className:"h-3.5 w-3.5 text-brand animate-spin",style:{animationDuration:"2s"}});case"pending":return d.jsx(wd,{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(Ro,{children:e.outputText})}),d.jsx("div",{className:"pb-1 text-xs text-text-muted italic",children:"命令已执行 · 输入消息继续"})]})}/*!---------------------------------------------------------------------------------------------
252
+ * Copyright (c) StackBlitz. All rights reserved.
253
+ * Licensed under the MIT License. See License.txt in the project root for license information.
254
+ *--------------------------------------------------------------------------------------------*/const rx={damping:.7,stiffness:.05,mass:1.25},ox=70,sx=1e3/60,ax=350;let or=!1;var Is;(Is=globalThis.document)==null||Is.addEventListener("mousedown",()=>{or=!0});var Ms;(Ms=globalThis.document)==null||Ms.addEventListener("mouseup",()=>{or=!1});var Ps;(Ps=globalThis.document)==null||Ps.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 A=window.getSelection();if(!A||!A.rangeCount)return!1;const j=A.getRangeAt(0);return j.commonAncestorContainer.contains(w.current)||((_=w.current)==null?void 0:_.contains(j.commonAncestorContainer))},[]),f=m.useCallback(A=>{c.isAtBottom=A,o(A)},[]),l=m.useCallback(A=>{c.escapedFromLock=A,n(A)},[]),c=m.useMemo(()=>{let A;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){var j;return((j=w.current)==null?void 0:j.scrollTop)??0},set scrollTop(j){if(w.current){const{scrollBehavior:_}=getComputedStyle(w.current);_!=="auto"&&(w.current.style.scrollBehavior="auto"),w.current.scrollTop=j,c.ignoreScrollToTop=w.current.scrollTop,_!=="auto"&&(w.current.style.scrollBehavior=_)}},get targetScrollTop(){return!w.current||!y.current?0:w.current.scrollHeight-1-w.current.clientHeight},get calculatedTargetScrollTop(){if(!w.current||!y.current)return 0;const{targetScrollTop:j}=this;if(!e.targetScrollTop)return j;if((A==null?void 0:A.targetScrollTop)===j)return A.calculatedScrollTop;const _=Math.max(Math.min(e.targetScrollTop(j,{scrollElement:w.current,contentElement:y.current}),j),0);return A={targetScrollTop:j,calculatedScrollTop:_},requestAnimationFrame(()=>{A=void 0}),_},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ox}}},[]),u=m.useCallback((A={})=>{var b;typeof A=="string"&&(A={animation:A}),A.preserveScrollPosition||f(!0);const j=Date.now()+(Number(A.wait)||0),_=wr(i.current,A.animation),{ignoreEscapes:T=!1}=A;let C,E=c.calculatedTargetScrollTop;A.duration instanceof Promise?A.duration.finally(()=>{C=Date.now()}):C=j+(A.duration??0);const x=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{var P;if(!c.isAtBottom)return c.animation=void 0,!1;const{scrollTop:D}=c,O=performance.now(),F=(O-(c.lastTick??O))/sx;if(c.animation||(c.animation={behavior:_,promise:R,ignoreEscapes:T}),c.animation.behavior===_&&(c.lastTick=O),h()||j>Date.now())return x();if(D<Math.min(E,c.calculatedTargetScrollTop)){if(((P=c.animation)==null?void 0:P.behavior)===_){if(_==="instant")return c.scrollTop=c.calculatedTargetScrollTop,x();c.velocity=(_.damping*c.velocity+_.stiffness*c.scrollDifference)/_.mass,c.accumulated+=c.velocity*F,c.scrollTop+=c.accumulated,c.scrollTop!==D&&(c.accumulated=0)}return x()}return C>Date.now()?(E=c.calculatedTargetScrollTop,x()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?u({animation:wr(i.current,i.current.resize),ignoreEscapes:T,duration:Math.max(0,C-Date.now())||void 0}):c.isAtBottom)});return R.then(D=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),D))};return A.wait!==!0&&(c.animation=void 0),((b=c.animation)==null?void 0:b.behavior)===_?c.animation.promise:x()},[f,h,c]),p=m.useCallback(()=>{l(!0),f(!1)},[l,f]),g=m.useCallback(({target:A})=>{if(A!==w.current)return;const{scrollTop:j,ignoreScrollToTop:_}=c;let{lastScrollTop:T=j}=c;c.lastScrollTop=j,c.ignoreScrollToTop=void 0,_&&_>j&&(T=_),a(c.isNearBottom),setTimeout(()=>{var x;if(c.resizeDifference||j===_)return;if(h()){l(!0),f(!1);return}const C=j>T,E=j<T;if((x=c.animation)!=null&&x.ignoreEscapes){c.scrollTop=T;return}E&&(l(!0),f(!1)),C&&l(!1),!c.escapedFromLock&&c.isNearBottom&&f(!0)},1)},[l,f,h,c]),v=m.useCallback(({target:A,deltaY:j})=>{var T;let _=A;for(;!["scroll","auto"].includes(getComputedStyle(_).overflow);){if(!_.parentElement)return;_=_.parentElement}_===w.current&&j<0&&w.current.scrollHeight>w.current.clientHeight&&!((T=c.animation)!=null&&T.ignoreEscapes)&&(l(!0),f(!1))},[l,f,c]),w=Cs(A=>{var j,_;(j=w.current)==null||j.removeEventListener("scroll",g),(_=w.current)==null||_.removeEventListener("wheel",v),A==null||A.addEventListener("scroll",g,{passive:!0}),A==null||A.addEventListener("wheel",v,{passive:!0})},[]),y=Cs(A=>{var _,T;if((_=c.resizeObserver)==null||_.disconnect(),!A)return;let j;c.resizeObserver=new ResizeObserver(([C])=>{const{height:E}=C.contentRect,x=E-(j??E);if(c.resizeDifference=x,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),a(c.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 c.isNearBottom&&(l(!1),f(!0));j=E,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===x&&(c.resizeDifference=0)},1)})}),(T=c.resizeObserver)==null||T.observe(A)},[]);return{contentRef:y,scrollRef:w,scrollToBottom:u,stopScroll:p,isAtBottom:r||s,isNearBottom:s,escapedFromLock:t,state:c}};function Cs(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
+ * Copyright (c) StackBlitz. All rights reserved.
256
+ * Licensed under the MIT License. See License.txt in the project root for license information.
257
+ *--------------------------------------------------------------------------------------------*/const jl=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 l=m.useRef(null),c=m.useCallback((T,C)=>{const E=(_==null?void 0:_.targetScrollTop)??i;return(E==null?void 0:E(T,C))??T},[i]),u=ix({mass:o,damping:s,stiffness:a,resize:n,initial:r,targetScrollTop:c}),{scrollRef:p,contentRef:g,scrollToBottom:v,stopScroll:w,isAtBottom:y,escapedFromLock:A,state:j}=e??u,_=m.useMemo(()=>({scrollToBottom:v,stopScroll:w,scrollRef:p,isAtBottom:y,escapedFromLock:A,contentRef:g,state:j,get targetScrollTop(){return l.current},set targetScrollTop(T){l.current=T}}),[v,y,g,p,w,A,j]);return m.useImperativeHandle(h,()=>_,[_]),lx(()=>{p.current&&getComputedStyle(p.current).overflow==="visible"&&(p.current.style.overflow="auto")},[]),m.createElement(jl.Provider,{value:_},m.createElement("div",{...f},typeof t=="function"?t(_):t))}(function(e){function t({children:n,scrollClassName:r,...o}){const s=Po();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 Po(){const e=m.useContext(jl);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}=Po(),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(dd,{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(ia,{className:"size-4"})})},px=({className:e,hasUserMessages:t=!1,...n})=>{const{isAtBottom:r}=Po();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,l)=>f.type==="single"?d.jsx("div",{className:Z(xx(e,l)),children:d.jsx(vx,{entry:f.entry,isLoading:t,onPermissionRespond:n})},`entry-${l}`):d.jsx("div",{className:"-mt-2",children:d.jsx(Nl,{entries:f.entries,onPermissionRespond:n})},`group-${l}`)),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(Nl,{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=l=>{s.current&&!s.current.contains(l.target)&&r()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r]),m.useEffect(()=>{const f=l=>{if(h.length!==0){if(l.key==="ArrowDown")l.preventDefault(),i(c=>(c+1)%h.length);else if(l.key==="ArrowUp")l.preventDefault(),i(c=>(c-1+h.length)%h.length);else if(l.key==="Enter"&&!l.shiftKey){l.preventDefault();const c=h[a];c&&n(c)}}};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[h,a,n]),m.useEffect(()=>{const f=s.current;if(!f)return;const l=f.querySelector("[data-active='true']");l==null||l.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,l)=>{var c;return d.jsxs("button",{type:"button","data-active":l===a,onClick:()=>n(f),onMouseEnter:()=>i(l),className:Z("flex w-full items-center gap-2 px-3 py-2 cursor-pointer rounded-lg mx-1 text-left","transition-colors",l===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}),((c=f.input)==null?void 0:c.hint)&&d.jsx("span",{className:"text-[10px] text-text-muted italic",children:f.input.hint})]},f.name)})})})}function wt(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,Al=2*1024*1024,Cr=200,Ss=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 on(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}function Rl(e){if(e.type.startsWith("text/"))return!0;const t=on(e.name);return kx.has(t)}function Hr(e){const t=on(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,[l,c]=m.useState(""),[u,p]=m.useState([]),[g,v]=m.useState([]),[w,y]=m.useState(!1),[A,j]=m.useState(""),[_,T]=m.useState(!1),[C,E]=m.useState(!1),[x,b]=m.useState(!1),R=m.useRef(null),D=m.useRef(null),O=m.useRef(null),F=m.useRef(null),P=m.useRef(null),L=m.useRef(null),k=m.useRef(null);m.useEffect(()=>{wt("[ChatInput] mount/supportsAttachments change",{supportsAttachments:f,commandsCount:(i==null?void 0:i.length)??0})},[f,i]),m.useEffect(()=>{if(!C)return;const W=q=>{var oe,he;const J=q.target,te=(oe=L.current)==null?void 0:oe.contains(J),le=(he=k.current)==null?void 0:he.contains(J);!te&&!le&&E(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[C]);const S=m.useCallback(W=>{const q=(W??l).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}),c(""),p([]),v([]),y(!1),j(""),R.current&&(R.current.style.height="auto"))},[l,u,g,r,x,e]),$=m.useCallback(W=>{if(w){if(W.key==="Escape"){W.preventDefault(),y(!1);return}if(W.key==="ArrowUp"||W.key==="ArrowDown"||W.key==="Enter"){W.preventDefault();return}if(W.key==="Tab"){W.preventDefault(),y(!1);return}}W.key==="Enter"&&!W.shiftKey&&!W.nativeEvent.isComposing&&(W.preventDefault(),t?n==null||n():S())},[S,t,n,w]),N=m.useCallback(W=>{const q=W.target.value;c(q),q.startsWith("/")&&i&&i.length>0?(y(!0),j(q.slice(1).split(/\s/)[0]||"")):w&&(y(!1),j(""));const J=W.target;J.style.height="auto",J.style.height=Math.min(J.scrollHeight,200)+"px"},[i,w]),M=m.useCallback(async W=>{if(wt("[ChatInput] paste event",{canAttach:f,files:W.clipboardData.files.length,types:W.clipboardData.types}),!f)return;const q=Array.from(W.clipboardData.files).filter(J=>J.type.startsWith("image/"));if(wt("[ChatInput] paste image files",{count:q.length,types:q.map(J=>J.type)}),q.length!==0){W.preventDefault(),b(!0);try{const J=await Sr(q);p(te=>[...te,...J])}finally{b(!1)}}},[f]),H=m.useCallback(async()=>{if(!D.current)return;const W=D.current.files;if(!(!W||W.length===0)){b(!0);try{const q=await Sr(Array.from(W));p(J=>[...J,...q])}finally{D.current.value="",b(!1)}}},[]),I=m.useCallback(async()=>{if(!O.current)return;const W=O.current.files;if(!(!W||W.length===0)){b(!0);try{const q=await ks(Array.from(W));v(J=>[...J,...q])}finally{O.current.value="",b(!1)}}},[]),B=m.useCallback(async()=>{if(!F.current)return;const W=F.current.files;if(!(!W||W.length===0)){b(!0);try{const q=await _s(Array.from(W));v(J=>[...J,...q])}finally{F.current.value="",b(!1)}}},[]),z=m.useCallback(async()=>{if(!P.current)return;const W=P.current.files;if(!(!W||W.length===0)){b(!0);try{const q=await jx(Array.from(W));q&&v(J=>[...J,q])}finally{P.current.value="",b(!1)}}},[]),U=m.useCallback(W=>{p(q=>q.filter((J,te)=>te!==W))},[]),V=m.useCallback(W=>{v(q=>q.filter((J,te)=>te!==W))},[]),G=m.useCallback(W=>{var J,te;y(!1),j("");const q=`/${W.name}`;(J=W.input)!=null&&J.hint?(c(`${q} `),(te=R.current)==null||te.focus()):S(q)},[S]),X=m.useCallback(W=>{f&&Array.from(W.dataTransfer.types).includes("Files")&&(W.preventDefault(),W.dataTransfer.dropEffect="copy",_||T(!0))},[f,_]),K=m.useCallback(W=>{const q=W.relatedTarget;(!q||!W.currentTarget.contains(q))&&T(!1)},[]),ne=m.useCallback(async W=>{if(!f)return;const q=Array.from(W.dataTransfer.files);if(q.length!==0){W.preventDefault(),T(!1),b(!0);try{const J=q.filter(oe=>oe.type.startsWith("image/")),te=q.filter(oe=>!oe.type.startsWith("image/")&&Hr(oe)),le=q.filter(oe=>!oe.type.startsWith("image/")&&!Hr(oe)&&Rl(oe));if(J.length>0){const oe=await Sr(J);p(he=>[...he,...oe])}if(te.length>0){const oe=await _s(te);v(he=>[...he,...oe])}if(le.length>0){const oe=await ks(le);v(he=>[...he,...oe])}}finally{b(!1)}}},[f]),ie=m.useCallback(()=>{var W;w?(y(!1),j("")):(l.startsWith("/")||c("/"+l),y(!0),j(l.startsWith("/")&&l.slice(1).split(/\s/)[0]||""),(W=R.current)==null||W.focus())},[w,l]),de=u.length+g.length,me=(l.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:[w&&i&&i.length>0&&d.jsx(wx,{commands:i,filter:A,onSelect:G,onClose:()=>{y(!1),j("")},className:"absolute bottom-full left-0 right-0 mb-1 z-50"}),C&&f&&d.jsxs("div",{ref:L,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 W;E(!1),(W=D.current)==null||W.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(Ad,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"图片"})]}),d.jsxs("button",{type:"button",onClick:()=>{var W;E(!1),(W=O.current)==null||W.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(Jt,{className:"h-4 w-4 text-text-muted flex-shrink-0"}),d.jsx("span",{children:"文本文件"})]}),d.jsxs("button",{type:"button",onClick:()=>{var W;E(!1),(W=F.current)==null||W.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 W;E(!1),(W=P.current)==null||W.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((W,q)=>d.jsxs("div",{className:"relative group",children:[d.jsx("img",{src:`data:${W.mimeType};base64,${W.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((W,q)=>d.jsx(Nx,{attachment:W,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:k,type:"button",onClick:()=>E(W=>!W),disabled:r||x,className:Z("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"),children:[d.jsx(Wd,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Attach"})]}),d.jsx("input",{ref:D,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:H}),d.jsx("input",{ref:O,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:I}),d.jsx("input",{ref:F,type:"file",accept:".csv,.tsv,.xlsx,.xls",multiple:!0,className:"hidden",onChange:B}),d.jsx("input",{ref:P,type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",onChange:z})]}),i&&i.length>0&&d.jsx("button",{type:"button",onClick:ie,className:Z("flex-shrink-0 h-8 w-8 flex items-center justify-center rounded-lg transition-colors",w?"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:R,value:l,onChange:N,onKeyDown:$,onPaste:M,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:()=>S(),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(Jt,{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(Jt,{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(Bt,{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 ks(e){const t=[];for(const n of e)try{if(n.size>Al){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 _s(e){const t=[];for(const n of e)try{const r=on(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 Tl(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 Tl(e){const t=await sn(()=>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
+
259
+ ${a}`):r.push(a)}return r.join(`
260
+
261
+ `)}async function jx(e){if(e.length===0)return null;const t=e.filter(u=>!(u.name.startsWith(".")||u.size>Al));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>Ss&&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),Rl(u)||Hr(u))if(h+u.size<=Ss)try{let g;if(on(u.name)===".xlsx"||on(u.name)===".xls"){const v=await u.arrayBuffer();g=await Tl(v)}else g=await u.text();i.push(`
262
+ ### ${p}
263
+ \`\`\`
264
+ ${g}
265
+ \`\`\``),h+=u.size}catch{i.push(`
266
+ ### ${p}
267
+ (读取失败)`)}else i.push(`
268
+ ### ${p}
269
+ (文件过大,已跳过)`);else u.type.startsWith("image/")?i.push(`
270
+ ### ${p}
271
+ (图片文件,${Ot(u.size)})`):i.push(`
272
+ ### ${p}
273
+ (二进制文件,${Ot(u.size)})`)}const l=a.join(`
274
+ `),c=[`# 目录: ${s}`,`共 ${a.length} 个文件`,"","## 文件结构","```",l,"```","","## 文件内容",...i].join(`
275
+ `);return{kind:"directory",name:s,size:r,textContent:c,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(at,{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(Bt,{className:"h-3.5 w-3.5"}),"拒绝"]})]})]})}var sr="Popover",[Il]=Qe(sr,[Vt]),pn=Vt(),[Ix,ht]=Il(sr),Ml=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!1}=e,i=pn(t),h=m.useRef(null),[f,l]=m.useState(!1),[c,u]=it({prop:r,defaultProp:o??!1,onChange:s,caller:sr});return d.jsx(co,{...i,children:d.jsx(Ix,{scope:t,contentId:Ce(),triggerRef:h,open:c,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(p=>!p),[u]),hasCustomAnchor:f,onCustomAnchorAdd:m.useCallback(()=>l(!0),[]),onCustomAnchorRemove:m.useCallback(()=>l(!1),[]),modal:a,children:n})})};Ml.displayName=sr;var Pl="PopoverAnchor",Mx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ht(Pl,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=Pl;var Ol="PopoverTrigger",Dl=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ht(Ol,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":zl(o.open),...r,ref:a,onClick:ee(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:d.jsx(qn,{asChild:!0,...s,children:i})});Dl.displayName=Ol;var Oo="PopoverPortal",[Px,Ox]=Il(Oo,{forceMount:void 0}),Ll=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=ht(Oo,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})})})};Ll.displayName=Oo;var Ut="PopoverContent",$l=m.forwardRef((e,t)=>{const n=Ox(Ut,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=ht(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})})});$l.displayName=Ut;var Dx=Dt("PopoverContent.RemoveScroll"),Lx=m.forwardRef((e,t)=>{const n=ht(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 ho(a)},[]),d.jsx(Kr,{as:Dx,allowPinchZoom:!0,children:d.jsx(Fl,{...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=ht(Ut,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return d.jsx(Fl,{...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()}})}),Fl=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:l,...c}=e,u=ht(Ut,n),p=pn(n);return eo(),d.jsx(Hn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(ln,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:l,onEscapeKeyDown:i,onPointerDownOutside:h,onFocusOutside:f,onDismiss:()=>u.onOpenChange(!1),children:d.jsx(uo,{"data-state":zl(u.open),role:"dialog",id:u.contentId,...p,...c,ref:t,style:{...c.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)"}})})})}),Ul="PopoverClose",Fx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ht(Ul,n);return d.jsx(ue.button,{type:"button",...r,ref:t,onClick:ee(e.onClick,()=>o.onOpenChange(!1))})});Fx.displayName=Ul;var Ux="PopoverArrow",zx=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=pn(n);return d.jsx(fo,{...o,...r,ref:t})});zx.displayName=Ux;function zl(e){return e?"open":"closed"}var Bx=Ml,Hx=Dl,Wx=Ll,Vx=$l;function Bl({...e}){return d.jsx(Bx,{"data-slot":"popover",...e})}function Hl({...e}){return d.jsx(Hx,{"data-slot":"popover-trigger",...e})}function Wl({className:e,align:t="center",sideOffset:n=4,...r}){return d.jsx(Wx,{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 Es=1,Gx=.9,Kx=.8,qx=.17,kr=.1,_r=.999,Yx=.9999,Xx=.99,Qx=/[\\\/_+.#"@\[\(\{&]/,Zx=/[\\\/_+.#"@\[\(\{&]/g,Jx=/[\s-]/,Vl=/[\s-]/g;function Wr(e,t,n,r,o,s,a){if(s===t.length)return o===e.length?Es:Xx;var i=`${o},${s}`;if(a[i]!==void 0)return a[i];for(var h=r.charAt(s),f=n.indexOf(h,o),l=0,c,u,p,g;f>=0;)c=Wr(e,t,n,r,f+1,s+1,a),c>l&&(f===o?c*=Es:Qx.test(e.charAt(f-1))?(c*=Kx,p=e.slice(o,f-1).match(Zx),p&&o>0&&(c*=Math.pow(_r,p.length))):Jx.test(e.charAt(f-1))?(c*=Gx,g=e.slice(o,f-1).match(Vl),g&&o>0&&(c*=Math.pow(_r,g.length))):(c*=qx,o>0&&(c*=Math.pow(_r,f-o))),e.charAt(f)!==t.charAt(s)&&(c*=Yx)),(c<kr&&n.charAt(f-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(f-1)!==r.charAt(s))&&(u=Wr(e,t,n,r,f+1,s+2,a),u*kr>c&&(c=u*kr)),c>l&&(l=c),f=n.indexOf(h,f+1);return a[i]=l,l}function Ns(e){return e.toLowerCase().replace(Vl," ")}function ev(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Wr(e,t,Ns(e),Ns(t),0,0,{})}var Xt='[cmdk-group=""]',Er='[cmdk-group-items=""]',tv='[cmdk-group-heading=""]',Gl='[cmdk-item=""]',js=`${Gl}:not([aria-disabled="true"])`,Vr="cmdk-item-select",Tt="data-value",nv=(e,t,n)=>ev(e,t,n),Kl=m.createContext(void 0),gn=()=>m.useContext(Kl),ql=m.createContext(void 0),Do=()=>m.useContext(ql),Yl=m.createContext(void 0),Xl=m.forwardRef((e,t)=>{let n=It(()=>{var I,B;return{search:"",value:(B=(I=e.value)!=null?I: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=Ql(e),{label:h,children:f,value:l,onValueChange:c,filter:u,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:w=!0,...y}=e,A=Ce(),j=Ce(),_=Ce(),T=m.useRef(null),C=hv();kt(()=>{if(l!==void 0){let I=l.trim();n.current.value=I,E.emit()}},[l]),kt(()=>{C(6,F)},[]);let E=m.useMemo(()=>({subscribe:I=>(a.current.add(I),()=>a.current.delete(I)),snapshot:()=>n.current,setState:(I,B,z)=>{var U,V,G,X;if(!Object.is(n.current[I],B)){if(n.current[I]=B,I==="search")O(),R(),C(1,D);else if(I==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(_);K?K.focus():(U=document.getElementById(A))==null||U.focus()}if(C(7,()=>{var K;n.current.selectedItemId=(K=P())==null?void 0:K.id,E.emit()}),z||C(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}}E.emit()}},emit:()=>{a.current.forEach(I=>I())}}),[]),x=m.useMemo(()=>({value:(I,B,z)=>{var U;B!==((U=s.current.get(I))==null?void 0:U.value)&&(s.current.set(I,{value:B,keywords:z}),n.current.filtered.items.set(I,b(B,z)),C(2,()=>{R(),E.emit()}))},item:(I,B)=>(r.current.add(I),B&&(o.current.has(B)?o.current.get(B).add(I):o.current.set(B,new Set([I]))),C(3,()=>{O(),R(),n.current.value||D(),E.emit()}),()=>{s.current.delete(I),r.current.delete(I),n.current.filtered.items.delete(I);let z=P();C(4,()=>{O(),(z==null?void 0:z.getAttribute("id"))===I&&D(),E.emit()})}),group:I=>(o.current.has(I)||o.current.set(I,new Set),()=>{s.current.delete(I),o.current.delete(I)}),filter:()=>i.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:A,inputId:_,labelId:j,listInnerRef:T}),[]);function b(I,B){var z,U;let V=(U=(z=i.current)==null?void 0:z.filter)!=null?U:nv;return I?V(I,n.current.search,B):0}function R(){if(!n.current.search||i.current.shouldFilter===!1)return;let I=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(U=>{let V=o.current.get(U),G=0;V.forEach(X=>{let K=I.get(X);G=Math.max(K,G)}),B.push([U,G])});let z=T.current;L().sort((U,V)=>{var G,X;let K=U.getAttribute("id"),ne=V.getAttribute("id");return((G=I.get(ne))!=null?G:0)-((X=I.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=T.current)==null?void 0:V.querySelector(`${Xt}[${Tt}="${encodeURIComponent(U[0])}"]`);G==null||G.parentElement.appendChild(G)})}function D(){let I=L().find(z=>z.getAttribute("aria-disabled")!=="true"),B=I==null?void 0:I.getAttribute(Tt);E.setState("value",B||void 0)}function O(){var I,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=(I=s.current.get(G))==null?void 0:I.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 I,B,z;let U=P();U&&(((I=U.parentElement)==null?void 0:I.firstChild)===U&&((z=(B=U.closest(Xt))==null?void 0:B.querySelector(tv))==null||z.scrollIntoView({block:"nearest"})),U.scrollIntoView({block:"nearest"}))}function P(){var I;return(I=T.current)==null?void 0:I.querySelector(`${Gl}[aria-selected="true"]`)}function L(){var I;return Array.from(((I=T.current)==null?void 0:I.querySelectorAll(js))||[])}function k(I){let B=L()[I];B&&E.setState("value",B.getAttribute(Tt))}function S(I){var B;let z=P(),U=L(),V=U.findIndex(X=>X===z),G=U[V+I];(B=i.current)!=null&&B.loop&&(G=V+I<0?U[U.length-1]:V+I===U.length?U[0]:U[V+I]),G&&E.setState("value",G.getAttribute(Tt))}function $(I){let B=P(),z=B==null?void 0:B.closest(Xt),U;for(;z&&!U;)z=I>0?uv(z,Xt):fv(z,Xt),U=z==null?void 0:z.querySelector(js);U?E.setState("value",U.getAttribute(Tt)):S(I)}let N=()=>k(L().length-1),M=I=>{I.preventDefault(),I.metaKey?N():I.altKey?$(1):S(1)},H=I=>{I.preventDefault(),I.metaKey?k(0):I.altKey?$(-1):S(-1)};return m.createElement(ft.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:I=>{var B;(B=y.onKeyDown)==null||B.call(y,I);let z=I.nativeEvent.isComposing||I.keyCode===229;if(!(I.defaultPrevented||z))switch(I.key){case"n":case"j":{w&&I.ctrlKey&&M(I);break}case"ArrowDown":{M(I);break}case"p":case"k":{w&&I.ctrlKey&&H(I);break}case"ArrowUp":{H(I);break}case"Home":{I.preventDefault(),k(0);break}case"End":{I.preventDefault(),N();break}case"Enter":{I.preventDefault();let U=P();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,I=>m.createElement(ql.Provider,{value:E},m.createElement(Kl.Provider,{value:x},I))))}),rv=m.forwardRef((e,t)=>{var n,r;let o=Ce(),s=m.useRef(null),a=m.useContext(Yl),i=gn(),h=Ql(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 l=Zl(o,s,[e.value,e.children,s],e.keywords),c=Do(),u=dt(C=>C.value&&C.value===l.current),p=dt(C=>f||i.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);m.useEffect(()=>{let C=s.current;if(!(!C||e.disabled))return C.addEventListener(Vr,g),()=>C.removeEventListener(Vr,g)},[p,e.onSelect,e.disabled]);function g(){var C,E;v(),(E=(C=h.current).onSelect)==null||E.call(C,l.current)}function v(){c.setState("value",l.current,!0)}if(!p)return null;let{disabled:w,value:y,onSelect:A,forceMount:j,keywords:_,...T}=e;return m.createElement(ft.div,{ref:He(s,t),...T,id:o,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!u,"data-disabled":!!w,"data-selected":!!u,onPointerMove:w||i.getDisablePointerSelection()?void 0:v,onClick:w?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(),l=gn(),c=dt(p=>o||l.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);kt(()=>l.group(a),[]),Zl(a,i,[e.value,e.heading,h]);let u=m.useMemo(()=>({id:a,forceMount:o}),[o]);return m.createElement(ft.div,{ref:He(i,t),...s,"cmdk-group":"",role:"presentation",hidden:c?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(Yl.Provider,{value:u},p))))}),sv=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=dt(a=>!a.search);return!n&&!s?null:m.createElement(ft.div,{ref:He(o,t),...r,"cmdk-separator":"",role:"separator"})}),av=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Do(),a=dt(f=>f.search),i=dt(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ft.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=dt(f=>f.selectedItemId),h=gn();return m.useEffect(()=>{if(a.current&&s.current){let f=a.current,l=s.current,c,u=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let p=f.offsetHeight;l.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return u.observe(f),()=>{cancelAnimationFrame(c),u.unobserve(f)}}},[]),m.createElement(ft.div,{ref:He(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:He(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(Hi,{open:n,onOpenChange:r},m.createElement(Wi,{container:a},m.createElement(Vi,{"cmdk-overlay":"",className:o}),m.createElement(Gi,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Xl,{ref:t,...i}))))}),cv=m.forwardRef((e,t)=>dt(n=>n.filtered.count===0)?m.createElement(ft.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(ft.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)))}),Gt=Object.assign(Xl,{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 Ql(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 dt(e){let t=Do(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Zl(e,t,n,r=[]){let o=m.useRef(),s=gn();return kt(()=>{var a;let i=(()=>{var f;for(let l of n){if(typeof l=="string")return l.trim();if(typeof l=="object"&&"current"in l)return l.current?(f=l.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(Gt,{"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(Gt.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(Gt.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(Gt.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function yv({className:e,...t}){return d.jsx(Gt.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(Gt.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 As(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(l=>As(s,l.name)||As(s,l.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(l=>d.jsxs(wv,{value:l.modelId,onSelect:()=>n(l),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:l.name}),l.description&&d.jsx("span",{className:"text-xs text-muted-foreground truncate",children:l.description})]}),d.jsx(at,{className:Z("h-4 w-4 shrink-0",t===l.modelId?"opacity-100":"opacity-0")})]},l.modelId))})]})]})}function Jl(e){const[t,n]=m.useState(e.modelState),[r,o]=m.useState(!1);m.useEffect(()=>{const f=c=>{if(n(c),c&&c.availableModels.length>0){const u=localStorage.getItem("acp_model_id");u&&u!==c.currentModelId&&c.availableModels.some(p=>p.modelId===u)&&e.setSessionModel(u).catch(()=>{})}},l=c=>{n(u=>u?{...u,currentModelId:c}:null),o(!1)};return e.setModelStateChangedHandler(f),e.setModelChangedHandler(l),()=>{e.removeModelStateChangedHandler(f),e.removeModelChangedHandler(l)}},[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(l){throw o(!1),l}},[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}=Jl(e),f=o&&s.length>0,l=typeof window<"u"&&window.matchMedia("(hover: none) and (pointer: coarse)").matches,c=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(Bl,{open:n,onOpenChange:f?r:void 0,children:[d.jsx(Hl,{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(ra,{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(Js,{className:"h-3 w-3"}):d.jsx(an,{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:c,showSearch:!l,isMobile:l})})]})}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 c;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=((c=u==null?void 0:u.chunks)==null?void 0:c.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},l={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:l}}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(Bl,{open:n,onOpenChange:r,children:[d.jsx(Hl,{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(Js,{className:"h-3 w-3"}):d.jsx(an,{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(at,{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 Rs(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),l=m.useRef(null),c=m.useRef(n);c.current=n;const[u,p]=m.useState(null),g=m.useRef(null),[v,w]=m.useState(()=>localStorage.getItem("acp_permission_mode")||"default"),[y,A]=m.useState(!1),{commands:j}=kv(e),{availableModels:_,currentModel:T,setModel:C}=Jl(e);m.useEffect(()=>{l.current=h},[h]);const E=m.useCallback(()=>{r([]),s(!1),i(!1)},[]),x=t?`acp_last_session_${t}`:null,b=m.useCallback(($,N)=>{if(((N==null?void 0:N.resetEntries)??!0)&&(r([]),s(!1)),f($),i(!0),A(e.supportsImages),x)try{localStorage.setItem(x,$)}catch{}console.log("[ChatInterface] Active session:",$,"supportsImages:",e.supportsImages)},[e,x]),R=m.useCallback($=>{l.current&&$.sessionId!==l.current||(console.log("[ChatInterface] Permission request:",$),r(N=>{const M=jr(N,$.toolCall.toolCallId);if(M>=0)return N.map((H,I)=>I!==M||H.type!=="tool_call"||H.toolCall.status!=="running"?H:{type:"tool_call",toolCall:{...H.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:$.requestId,options:$.options}}});{console.log("[ChatInterface] No matching tool call, creating standalone permission request");const H={type:"tool_call",toolCall:{id:$.toolCall.toolCallId,title:$.toolCall.title||"Permission Request",status:"waiting_for_confirmation",permissionRequest:{requestId:$.requestId,options:$.options},isStandalonePermission:!0}};return[...N,H]}}))},[]),D=m.useCallback(($,N)=>{if(!(l.current&&$!==l.current))if(N.sessionUpdate==="agent_message_chunk"){const M=N.content.type==="text"&&N.content.text?N.content.text:"";if(!M)return;r(H=>{const I=H[H.length-1];if((I==null?void 0:I.type)==="assistant_message"){const z=I.chunks[I.chunks.length-1];return(z==null?void 0:z.type)==="message"?[...H.slice(0,-1),{...I,chunks:[...I.chunks.slice(0,-1),{type:"message",text:z.text+M}]}]:[...H.slice(0,-1),{...I,chunks:[...I.chunks,{type:"message",text:M}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:M}]};return[...H,B]})}else if(N.sessionUpdate==="agent_thought_chunk"){const M=N.content.type==="text"&&N.content.text?N.content.text:"";if(!M)return;r(H=>{const I=H[H.length-1];if((I==null?void 0:I.type)==="assistant_message"){const z=I.chunks[I.chunks.length-1];return(z==null?void 0:z.type)==="thought"?[...H.slice(0,-1),{...I,chunks:[...I.chunks.slice(0,-1),{type:"thought",text:z.text+M}]}]:[...H.slice(0,-1),{...I,chunks:[...I.chunks,{type:"thought",text:M}]}]}const B={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"thought",text:M}]};return[...H,B]})}else if(N.sessionUpdate==="user_message_chunk"){const M=N.content.type==="text"&&N.content.text?N.content.text:"";if(!M)return;r(H=>{const I=H[H.length-1];if((I==null?void 0:I.type)==="user_message")return[...H.slice(0,-1),{...I,content:I.content+M}];const B={type:"user_message",id:`user-${Date.now()}`,content:M};return[...H,B]})}else if(N.sessionUpdate==="tool_call"){const M={id:N.toolCallId,title:N.title,status:Rs(N.status),content:N.content,rawInput:N.rawInput,rawOutput:N.rawOutput};r(H=>{const I=jr(H,N.toolCallId);if(I>=0)return H.map((z,U)=>U!==I||z.type!=="tool_call"?z:{type:"tool_call",toolCall:{...z.toolCall,...M}});const B={type:"tool_call",toolCall:M};return[...H,B]})}else N.sessionUpdate==="tool_call_update"?r(M=>{const H=jr(M,N.toolCallId);if(H<0){console.warn(`[ChatInterface] Tool call not found for update: ${N.toolCallId}`);const I={type:"tool_call",toolCall:{id:N.toolCallId,title:N.title||"Tool call not found",status:"error",content:[{type:"content",content:{type:"text",text:"Tool call not found"}}]}};return[...M,I]}return M.map((I,B)=>{if(B!==H||I.type!=="tool_call")return I;const z=N.status?Rs(N.status):I.toolCall.status,U=N.content?[...I.toolCall.content||[],...N.content]:I.toolCall.content;return{type:"tool_call",toolCall:{...I.toolCall,status:z,...N.title&&{title:N.title},content:U,...N.rawInput&&{rawInput:N.rawInput},...N.rawOutput&&{rawOutput:N.rawOutput}}}})}):N.sessionUpdate==="plan"&&r(M=>{if(N.entries.length===0)return M.filter(B=>B.type!=="plan");const H=M.reduce((B,z,U)=>z.type==="plan"?U:B,-1);if(H>=0)return M.map((B,z)=>z===H?{...B,entries:N.entries}:B);const I={type:"plan",id:`plan-${Date.now()}`,entries:N.entries};return[...M,I]})},[]);m.useEffect(()=>{e.setSessionCreatedHandler(N=>{console.log("[ChatInterface] Session created:",N),b(N)}),e.setSessionLoadedHandler(N=>{console.log("[ChatInterface] Session loaded/resumed:",N),b(N,{resetEntries:!1})}),e.setSessionSwitchingHandler(N=>{console.log("[ChatInterface] Switching to session:",N),f(N),E()}),e.setSessionUpdateHandler((N,M)=>{D(N,M)}),e.setPromptCompleteHandler(N=>{console.log("[ChatInterface] Prompt complete:",N),s(!1)}),e.setPermissionRequestHandler(R),e.setErrorMessageHandler(N=>{console.error("[ChatInterface] Agent error:",N),p(N),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>p(null),5e3)});const $=x?localStorage.getItem(x):null;return $&&(e.supportsLoadSession||e.supportsResumeSession)?(console.log("[ChatInterface] Restoring session:",$),(async()=>{try{e.supportsLoadSession?await e.loadSession({sessionId:$}):await e.resumeSession({sessionId:$})}catch(M){console.warn("[ChatInterface] Failed to restore session, creating new one:",M),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,R,D,E]);const O=m.useCallback(()=>{console.log("[ChatInterface] Creating new session..."),o&&e.cancel(),E(),f(null),e.createSession(void 0,v)},[e,o,E,v]),F=()=>{console.log("[ChatInterface] Cancel requested"),r($=>$.map(N=>N.type!=="tool_call"||!(N.toolCall.status==="running"||N.toolCall.status==="waiting_for_confirmation")?N:(console.log("[ChatInterface] Marking tool call as canceled:",N.toolCall.id),{type:"tool_call",toolCall:{...N.toolCall,status:"canceled",permissionRequest:void 0}}))),e.cancel()},P=m.useCallback(($,N,M)=>{console.log("[ChatInterface] Permission response:",{requestId:$,optionId:N,optionKind:M}),e.respondToPermission($,N);const H=M==="reject_once"||M==="reject_always"||N===null;r(I=>I.map(B=>{var U;if(B.type!=="tool_call"||((U=B.toolCall.permissionRequest)==null?void 0:U.requestId)!==$)return B;let z;return H?z="rejected":B.toolCall.isStandalonePermission?z="complete":z="running",{type:"tool_call",toolCall:{...B.toolCall,status:z,permissionRequest:void 0,isStandalonePermission:void 0}}}))},[e]),L=n.filter($=>$.type==="tool_call"&&$.toolCall.status==="waiting_for_confirmation"&&!!$.toolCall.permissionRequest).map($=>({requestId:$.toolCall.permissionRequest.requestId,toolName:$.toolCall.title,toolInput:$.toolCall.rawInput||{},description:$.toolCall.title,options:$.toolCall.permissionRequest.options})),k=m.useCallback(($,N)=>{const M=L.find(B=>B.requestId===$);let H=null,I=null;if(M!=null&&M.options&&M.options.length>0)if(N){const B=M.options.find(z=>z.kind==="allow_once")??M.options.find(z=>z.kind==="allow_always");B&&(H=B.optionId,I=B.kind)}else{const B=M.options.find(z=>z.kind==="reject_once")??M.options.find(z=>z.kind==="reject_always");B&&(H=B.optionId,I=B.kind)}H||(I=N?"allow_once":"reject_once"),P($,H,I)},[P,L]),S=m.useCallback(async $=>{var V;const N=$.text.trim(),M=$.images||[],H=$.attachments||[];if(!N&&M.length===0&&H.length===0||o||!a)return;if(N.startsWith("/")&&M.length===0){wt("[ChatInterface] slash command input",{text:N});const G=await Iv(N,{sessionId:h,availableCommands:j,availableModels:_,currentModel:T,supportsImages:y,entries:c.current,setModel:C,onNewSession:O}).catch(()=>null);if(G){if(wt("[ChatInterface] local command handled",G),"clearEntries"in G&&G.clearEntries){r([]);return}if("newSession"in G&&G.newSession){O();return}if("userEntry"in G){r(X=>[...X,G.userEntry,G.cmdEntry]);return}}wt("[ChatInterface] slash command NOT in LOCAL_COMMANDS, forwarding to agent",{text:N})}wt("[ChatInterface] forwarding to agent",{text:N,hasImages:M.length>0,sessionReady:a,isLoading:o});const I=[];N&&I.push({type:"text",text:N});const B=[];for(const G of M)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,ie=G.mimeType;if(K.size>2*1024*1024){const W=new File([K],"image.jpg",{type:K.type});ne=await be(W,Mv),ie="image/jpeg"}const de=await new Promise((W,q)=>{const J=new FileReader;J.onloadend=()=>{const te=J.result,le=te.indexOf(",");W(le>=0?te.slice(le+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:ie,data:de};I.push(me),B.push({mimeType:ie,data:de})}catch(X){console.error("[ChatInterface] Failed to process image:",X)}const z=[];for(const G of H)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
+ \`\`\`
282
+ ${G.textContent}
283
+ \`\`\``}I.push({type:"text",text:X}),z.push(G)}}catch(X){console.error("[ChatInterface] Failed to process attachment:",X)}if(I.length===0)return;const U={type:"user_message",id:`user-${Date.now()}`,content:N,images:B.length>0?B:void 0,attachments:z.length>0?z:void 0};r(G=>[...G,U]),s(!0);try{await e.sendPrompt(I)}catch(G){console.error("[ChatInterface] Failed to send prompt:",G),s(!1)}},[o,a,e,j,_,T,y,h,C,O]);return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx(gx,{entries:n,isLoading:o&&!a?!1:o,onPermissionRespond:($,N,M)=>{P($,N,M)},emptyTitle:a?"开始对话":void 0,emptyDescription:a?"输入消息开始与 ACP agent 聊天":void 0}),d.jsx(Rx,{requests:L,onRespond:k}),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:$=>{w($),localStorage.setItem("acp_permission_mode",$)}}),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:O,children:[d.jsx(Bn,{className:"h-3 w-3"}),"新会话"]})}),d.jsx(Eg,{children:"New Thread"})]})]}),d.jsx(Ex,{onSubmit:S,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(Bd,{className:"h-4 w-4"}):d.jsx(Ud,{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,f]=m.useState(null),[l,c]=m.useState(""),u=m.useRef(null),p=m.useCallback(async()=>{if(!e.supportsSessionList){s(!1);return}s(!0);try{const T=await e.listSessions();r(T.sessions)}catch(T){console.warn("[SidebarSessionList] Failed to load:",T)}finally{s(!1)}},[e]);m.useEffect(()=>{e.getState()==="connected"&&e.supportsSessionList&&p()},[e,p]),m.useEffect(()=>{const T=C=>{C==="connected"&&setTimeout(p,200)};return e.setConnectionStateHandler(T),()=>e.removeConnectionStateHandler(T)},[e,p]),m.useEffect(()=>{const T=setInterval(p,1e4);return()=>clearInterval(T)},[p]),m.useEffect(()=>{e.setSessionDeletedHandler(T=>{p()}),e.setSessionRenamedHandler((T,C)=>{p()})},[e,p]),m.useEffect(()=>{h&&u.current&&(u.current.focus(),u.current.select())},[h]);const g=m.useCallback(T=>{const C=T.title&&T.title.trim()?T.title:T.sessionId.slice(0,8);if(window.confirm(`删除会话 "${C}"?此操作不可恢复。`))try{e.deleteSession(T.sessionId),r(E=>E.filter(x=>x.sessionId!==T.sessionId)),a===T.sessionId&&i(null)}catch(E){console.error("[SidebarSessionList] delete failed:",E)}},[e,a]),v=m.useCallback(T=>{f(T.sessionId),c(T.title&&T.title.trim()?T.title:"")},[]),w=m.useCallback(()=>{if(!h)return;const T=l.trim();if(!T){f(null);return}try{e.renameSession(h,T),r(C=>C.map(E=>E.sessionId===h?{...E,title:T}:E))}catch(C){console.error("[SidebarSessionList] rename failed:",C)}f(null)},[e,h,l]),y=m.useCallback(()=>{f(null)},[]),A=m.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),w()):T.key==="Escape"&&(T.preventDefault(),y())},[w,y]),j=m.useMemo(()=>[...n].sort((T,C)=>{const E=T.updatedAt?new Date(T.updatedAt).getTime():0;return(C.updatedAt?new Date(C.updatedAt).getTime():0)-E}),[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 _=Uv(j);return d.jsx("nav",{className:"py-1","aria-label":"历史会话",children:_.map((T,C)=>d.jsxs("div",{children:[C>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:T.label})}),T.sessions.map(E=>{const x=h===E.sessionId;return d.jsxs("div",{className:Z("group relative flex items-center gap-2.5 px-4 py-2 transition-colors",E.sessionId===a?"bg-brand/8 text-text-primary":"text-text-secondary hover:bg-surface-2/60 hover:text-text-primary"),children:[d.jsx(Od,{className:"h-3.5 w-3.5 flex-shrink-0 opacity-50"}),x?d.jsx("input",{ref:u,type:"text",value:l,onChange:b=>c(b.target.value),onKeyDown:A,onBlur:w,className:"flex-1 min-w-0 bg-surface-2 border border-border rounded px-1 py-0.5 text-[13px] font-display text-text-primary outline-none focus:border-brand",onClick:b=>b.stopPropagation()}):d.jsx("button",{type:"button",onClick:()=>{i(E.sessionId),t(E)},className:"flex-1 min-w-0 text-left",title:E.title||E.sessionId,children:d.jsx("span",{className:"text-[13px] font-display truncate leading-snug block",children:E.title&&E.title.trim()?E.title:"新会话"})}),x?d.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[d.jsx("button",{type:"button",onClick:w,className:"h-6 w-6 flex items-center justify-center rounded text-text-muted hover:text-brand hover:bg-brand/10 transition-colors",title:"确认",children:d.jsx(at,{className:"h-3.5 w-3.5"})}),d.jsx("button",{type:"button",onClick:y,className:"h-6 w-6 flex items-center justify-center rounded text-text-muted hover:text-status-error hover:bg-status-error/10 transition-colors",title:"取消",children:d.jsx(Bt,{className:"h-3.5 w-3.5"})})]}):d.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[d.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),v(E)},className:"h-6 w-6 flex items-center justify-center rounded text-text-muted hover:text-brand hover:bg-brand/10 transition-colors",title:"重命名",children:d.jsx(sa,{className:"h-3 w-3"})}),d.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),g(E)},className:"h-6 w-6 flex items-center justify-center rounded text-text-muted hover:text-status-error hover:bg-status-error/10 transition-colors",title:"删除",children:d.jsx(Jr,{className:"h-3 w-3"})})]})]},E.sessionId)})]},T.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 l=new Fr({proxyUrl:e,token:t});return l.setConnectionStateHandler((c,u)=>{a(c),h(u||null)}),f.current=l,o(l),l.connect().catch(c=>{c instanceof Qi||(h(c.message),a("error"))}),()=>{l.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 ec="rcs_tokens",tc="rcs_active_token",zt="__default__";function Bv(){return`tk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Hv(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 Ts(){let e=[];try{const t=localStorage.getItem(ec);if(t){const n=JSON.parse(t);Array.isArray(n)&&(e=n)}}catch{}return Hv(e)}function Wv(e){var n;try{const r=localStorage.getItem(tc);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(Ts),[n,r]=m.useState(()=>Wv(Ts())),o=m.useCallback(u=>{t(u);try{localStorage.setItem(ec,JSON.stringify(u))}catch{}},[]),s=m.useCallback(u=>{r(u);try{localStorage.setItem(tc,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)},w=[...e,v];return o(w),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,l=(f==null?void 0:f.label)??"Default",c=(f==null?void 0:f.token)??null;return{tokens:e,activeTokenId:n,activeToken:f,activeLabel:l,activeTokenValue:c,setActiveTokenId:s,addToken:a,removeToken:i,updateToken:h}}const Gv=m.lazy(()=>sn(()=>import("./Dashboard-ClYYELch.js"),__vite__mapDeps([3,2,1,4,5])).then(e=>({default:e.Dashboard}))),Kv=m.lazy(()=>sn(()=>import("./SessionDetail-D5dCDgDF.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:l,activeTokenId:c,activeLabel:u,activeTokenValue:p,setActiveTokenId:g,addToken:v,removeToken:w,updateToken:y}=Vv();m.useEffect(()=>{dp(p)},[p]);const A=m.useCallback(C=>{g(C)},[g]),j=m.useCallback(()=>{wo();const C=window.location.pathname,E=new URLSearchParams(window.location.search),x=E.get("uuid");if(x){_n(x);const O=new URL(window.location.href);O.searchParams.delete("uuid"),window.history.replaceState(null,"",O)}if(E.get("acp")==="1"){const O=sessionStorage.getItem("acp_connection");if(O)try{const F=JSON.parse(O);if(F.url&&F.token){f({url:F.url,token:F.token}),sessionStorage.removeItem("acp_connection");const P=new URL(window.location.href);P.searchParams.delete("acp"),window.history.replaceState(null,"",P);return}}catch{sessionStorage.removeItem("acp_connection")}}const R=E.get("sid");if(R){new URL(window.location.href).searchParams.delete("sid"),window.history.replaceState(null,"",`/code/${R}`),t(R),pp(R).catch(F=>{console.warn("Failed to bind session:",F)});return}const D=C.match(/^\/code\/([^/]+)/);D&&D[1]?(t(D[1]),r(void 0)):(t(null),r(void 0))},[]);m.useEffect(()=>(j(),window.addEventListener("popstate",j),()=>window.removeEventListener("popstate",j)),[j]);const _=m.useCallback(C=>{window.history.pushState(null,"",`/code/${C}`),t(C),r(void 0)},[]),T=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?T: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:T}):e?d.jsx(Kv,{sessionId:e,onSessionLoaded:C=>r(C.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:l,activeTokenId:c,onSetActive:A,onAdd:v,onRemove:w,onUpdate:y})]})})}ic.createRoot(document.getElementById("root")).render(d.jsx(m.StrictMode,{children:d.jsx(qv,{})}));export{Fr as A,eb as B,Ex as C,Ki as D,rd as E,sb as F,wo as G,hp as H,Lr as I,Fp as J,tb as K,ra 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,ed as U,$v as a,mp as b,gx as c,at as d,qi as e,xb as f,Yi as g,Xi as h,Qi as i,ob as j,Jr 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,Ls as v,Z as w,re as x,wt as y,td as z};